@ubox-tools/deploy-xperience
v1.1.14
Published
Deploy a Ubox experience to studio.ubox.world
Readme
deploy.js
Automated deployment script for Ubox experiences. Uses Puppeteer to drive the Ubox Studio web interface and deploy apps and Uboxes without manual browser interaction.
Run from the project root. Always invoke
npx @ubox-tools/deploy-xperiencefrom the experience directory (the one containingapps/andassets/).
Requirements
- Node.js 18+
- A clipboard utility — only needed when the Monaco/CodeMirror editor API is unavailable:
- macOS:
pbcopy(built-in) - Windows: PowerShell
Set-Clipboardorclip.exe(both built-in) - Linux:
wl-copy(Wayland),xclip(X11), orxsel(X11)
- macOS:
Usage
npx @ubox-tools/deploy-xperience [app1 app2 ...] [options]Options
| Flag | Description |
|---|---|
| --email <email> | Ubox Studio login email (or UBOX_EMAIL env var) |
| --password <pass> | Ubox Studio password (or UBOX_PASSWORD env var) |
| --project-name <name> | Override the project name (default: parent directory name) |
| --noassets | Skip uploading assets (images, fonts, files) |
| --nosource | Skip source injection entirely |
| --nosource <files> | Skip specific files (comma-separated, e.g. ubox.js,logic.js) |
| --noplayer | Skip Phase 3 — deploy apps only, do not create/update Uboxes |
| --ubox-id <id> | Use a pre-existing Ubox by ID — skips search/create (single-app deployments) |
| --ubox-id <app>:<id> | Scoped form for multi-app deployments (repeatable) |
| --xpace <name> | Xpace (place) to assign the Ubox to — case-insensitive match; defaults to the first available xpace if omitted or not found |
| --show | Show the browser window (default: headless) |
| --help | Print usage and exit |
Credentials are resolved in this order:
- CLI flags (
--email,--password) - Environment variables (
UBOX_EMAIL,UBOX_PASSWORD) ubox-credentials.jsonin the project root- Interactive prompt (if the terminal is interactive)
ubox-credentials.json (place in the experience project root):
{
"email": "[email protected]",
"password": "secret"
}Environment variables:
[email protected] UBOX_PASSWORD=secret npx @ubox-tools/deploy-xperienceIf a credential is provided by a higher-priority source, the file value for that field is ignored.
Examples
npx @ubox-tools/deploy-xperience # Deploy all apps (headless)
npx @ubox-tools/deploy-xperience --show # Deploy all apps, show browser
npx @ubox-tools/deploy-xperience mobile # Deploy only the mobile app
npx @ubox-tools/deploy-xperience main --noassets # Deploy main app, skip asset uploads
npx @ubox-tools/deploy-xperience --nosource # Deploy without re-injecting source
npx @ubox-tools/deploy-xperience --nosource ubox.js # Skip only ubox.js injection
npx @ubox-tools/deploy-xperience --noplayer # Deploy apps only, skip Uboxes
npx @ubox-tools/deploy-xperience --project-name "MyProject"
npx @ubox-tools/deploy-xperience mobile --ubox-id 42 # Use existing Ubox #42 for mobile
npx @ubox-tools/deploy-xperience --ubox-id mobile:42 --ubox-id main:99
npx @ubox-tools/deploy-xperience --xpace workshop # Assign Ubox to "Workshop" xpaceDeployment Phases
Phase 1 — Login
Navigates to studio.ubox.world and signs in. Skipped automatically if a session is already active.
Phase 2 — Application Deployment
Runs once per app (always mobile before main):
- Find or create the application card by its full name (
<ProjectName> <appName>). - Upload resources — groups assets by type (Images / Fonts / Files), deletes any existing file with the same name first, then uploads via CDP (bypasses the OS file picker dialog).
- Configure parameters — reads
apps/<appName>/parameters.json; only creates parameters that don't already exist. - Inject source — opens the Source editor, iterates the tab list (
HTML,CSS,Ubox Events,Workflow,Business logic,Data source) and sets each file's content via the Monaco or CodeMirror API, or via clipboard paste as a fallback.
Phase 3 — Ubox Deployment
Runs once per app:
- Find or create the Ubox by its full name. Handles the Terms & Conditions modal on first creation.
- Check "Make public" — enables the public checkbox if not already checked.
- Install app — switches to the "Available applications" tab, searches for the app card, and clicks Install.
- Mobile virtual link — for the
mobileapp, clicks "Open Virtual Ubox Link" and captures the URL from the newly opened tab. - Set
mobileLinkparameter — for themainUbox (if the app defines amobileLinkparameter), opens "Change params" and writes the captured mobile virtual link.
If the Ubox already exists, installation and parameter changes are skipped; the mobile virtual link is still retrieved so the main Ubox can use it.
When --ubox-id is provided, the search/create step is skipped entirely and the script navigates directly to https://studio.ubox.world/#/ubox/<id>. The same "already exists" logic then applies.
Proxy / Source Transformation
Before injecting source files, generateProxy() applies three transforms to each file:
| Transform | Applies to | What it does |
|---|---|---|
| Parameter substitution | JS | Replaces const KEY = "value" with const KEY = "{parameter:KEY}" for every key in parameters.json |
| Asset path substitution | JS, CSS | Replaces ../assets/file.ext references with {resources:type/file.ext} tokens |
| Emoji escaping | JS | Converts non-ASCII characters to \uXXXX Unicode escape sequences |
| Local tag stripping | HTML | Removes local <link href> and <script src> tags (CDN URLs are kept) |
Project Layout Expected
<project-root>/
apps/
mobile/
index.html
style.css
ubox.js
workflow.js
logic.js
data.js
parameters.json (optional)
main/
...same files...
assets/
*.jpg / *.png / *.woff2 / ...
deploy.jsThe project name defaults to the directory name of <project-root>. App full names are formed as "<projectName> <appName>" (e.g. "Claude - Slide Puzzle mobile").
Error Handling
On any unhandled error the script:
- Prints the error message.
- Saves a screenshot to
deploy_error.pngin the project root. - Exits with code 1.
The browser is kept open after both success and failure so you can inspect the final state. Press Ctrl+C to close it.
