CLI Reference
CLI Reference
The @selorax/cli package is a command-line tool for building, testing, and deploying extensions to the SeloraX platform. It handles authentication, esbuild bundling, CDN upload, config validation, and atomic deployment.
Installation
npm install -g @selorax/cliRequires Node.js 18 or later.
After installation, the selorax command is available globally:
selorax --version
selorax --helpAuthentication
selorax auth:login
Authenticate with the SeloraX platform. Credentials are stored locally in ~/.config/selorax-cli/config.json.
selorax auth:login \
--client-id sx_app_abc123 \
--client-secret sx_secret_xyz789 \
--store-id 22| Option | Description | Default |
|---|---|---|
--client-id <id> | Your app's client ID | -- |
--client-secret <secret> | Your app's client secret | -- |
--store-id <id> | Store ID for the target store | -- |
--api-url <url> | API base URL | https://api.selorax.io/api |
Alias: selorax login
Where to find credentials
Your client ID and secret are in the Developer Portal under your app's settings. The store ID is the numeric ID of the merchant store you want to deploy to (visible in the dashboard URL as the slug segment).
selorax auth:logout
Remove stored credentials from the local machine.
selorax auth:logoutAlias: selorax logout
selorax auth:status
Display current authentication state — client ID, store ID, and API URL.
selorax auth:statusAlias: selorax whoami
App Commands
selorax app:info
Show information about the current app and its extensions from selorax.config.json.
selorax app:info
selorax app:info -c path/to/selorax.config.json| Option | Description | Default |
|---|---|---|
-c, --config <path> | Path to config file | selorax.config.json |
Alias: selorax info
selorax app:dev
Start a development server that watches for changes and auto-deploys extensions.
selorax app:dev
selorax app:dev --port 4000
selorax app:dev --no-open| Option | Description | Default |
|---|---|---|
-c, --config <path> | Path to config file | selorax.config.json |
--port <port> | Dev server port for sandbox extensions | 3456 |
--no-open | Do not open browser | -- |
Alias: selorax dev
What dev mode does
- JSON extensions are deployed immediately to the platform via the API.
- Sandbox extensions are built with esbuild in watch mode (with source maps, no minification).
- A local HTTP server starts on the specified port, serving built sandbox bundles.
- An SSE (Server-Sent Events) endpoint at
/__reloadsendsreloadevents when bundles are rebuilt. - Changes to
selorax.config.jsontrigger an automatic re-deploy of JSON extensions.
The dev server serves files with CORS headers (Access-Control-Allow-Origin: *) so sandbox iframes can load bundles from 127.0.0.1.
SeloraX Dev Server
JSON extensions: 2
Sandbox extensions: 1
Dev server: http://127.0.0.1:3456
Serving: /Users/dev/my-app/dist
my-sandbox-ext: http://127.0.0.1:3456/my-sandbox-ext.js
Live reload: connect to http://127.0.0.1:3456/__reload (SSE)
Dev mode active. Press Ctrl+C to stop.
selorax app:deploy
Deploy all extensions defined in the config file. This is an atomic operation — all extensions are replaced at once.
selorax app:deploy
selorax app:deploy --force
selorax app:deploy --dry-run| Option | Description | Default |
|---|---|---|
-c, --config <path> | Path to config file | selorax.config.json |
--force | Skip the confirmation prompt | -- |
--dry-run | Preview deployment without making changes | -- |
Alias: selorax deploy
Deploy flow
- Build — Sandbox extensions with an
entryfield are built with esbuild (bundled, minified, IIFE, ES2020 target). - Upload — If S3/R2 config is present in the config file, bundles are uploaded to CDN and the
sandbox_urlis set automatically. - Preview — The CLI shows a summary of all extensions to be deployed.
- Confirm — Unless
--forceis passed, the CLI asks for confirmation. - Deploy — The full extension set is sent to
POST /api/apps/extensions/app/deploy. The platform validates all extensions, creates a version snapshot, and registers them for all active installations.
The --dry-run flag runs steps 1-3 but does not send anything to the platform. Use it to verify your config and builds before deploying.
selorax app:versions
List the extension version history for your app.
selorax app:versionsAlias: selorax versions
Output shows version number, extension count, and deployment timestamp. The platform retains up to 25 versions.
selorax app:rollback
Rollback extensions to a previous version.
selorax app:rollback -v 3| Option | Description |
|---|---|
-v, --version <number> | Version number to rollback to (required) |
Alias: selorax rollback
The rollback restores the extension set from the version snapshot and re-registers it for all active installations. A new version snapshot is not created by a rollback — the version history is preserved as-is.
Extension Commands
selorax extension:build
Build sandbox extensions with esbuild without deploying.
selorax extension:build
selorax extension:build -c custom-config.json| Option | Description | Default |
|---|---|---|
-c, --config <path> | Path to config file | selorax.config.json |
Alias: selorax build
Produces bundled, minified IIFE files in the outDir directory (default: dist/). Each sandbox extension with an entry field gets a corresponding <extension_id>.js output file.
selorax extension:validate
Validate extension config and UI trees without deploying. Checks:
- Required fields (
extension_id,target,title) - Valid target values
- Valid component types in JSON UI trees
- Valid action types
- Tree depth limits
- Mode-specific requirements (e.g.,
sandbox_urlfor sandbox mode,uifor JSON mode)
selorax extension:validate| Option | Description | Default |
|---|---|---|
-c, --config <path> | Path to config file | selorax.config.json |
Alias: selorax validate
Generate Commands
selorax generate:extension
Scaffold a new extension with boilerplate files.
selorax generate:extension
selorax generate:extension -t order.detail.block -m json -n "Fraud Check"| Option | Description | Default |
|---|---|---|
-t, --target <target> | Extension target (e.g., order.detail.block) | (prompted) |
-m, --mode <mode> | Extension mode: json or sandbox | sandbox |
-n, --name <name> | Extension name | (prompted) |
Alias: selorax generate
When run without options, the CLI prompts interactively for the target, mode, and name.
selorax generate:config
Generate a selorax.config.json for an existing project. Detects existing extension files and populates the config accordingly.
selorax generate:configConfiguration File
The selorax.config.json file is the central configuration for your extensions project. It lives in the root of your project directory.
Schema
{
"appId": "sx_app_abc123",
"outDir": "dist",
"s3": {
"endpoint": "https://abc.r2.cloudflarestorage.com",
"bucket": "pap",
"accessKey": "...",
"secretKey": "...",
"publicUrl": "https://cdn.myapp.com"
},
"extensions": [
{
"extension_id": "order-fraud-check",
"target": "order.detail.block",
"title": "Fraud Risk Score",
"description": "Shows fraud risk assessment for each order",
"mode": "json",
"ui": {
"type": "Card",
"props": { "title": "Fraud Check" },
"children": [{ "type": "Text", "props": { "content": "Risk: Low" } }]
},
"initial_state": { "loaded": false },
"load_action": {
"type": "call_backend",
"url": "https://myapp.com/api/fraud",
"method": "POST"
},
"sort_order": 0,
"settings_schema": []
},
{
"extension_id": "product-tag-manager",
"target": "product.detail.block",
"title": "Tag Manager",
"mode": "sandbox",
"entry": "extensions/tag-manager/index.js",
"sandbox_url": "https://cdn.myapp.com/extensions/product-tag-manager.js",
"settings_schema": [
{
"key": "max_tags",
"label": "Maximum Tags",
"type": "number",
"default": 10
}
]
}
]
}Top-Level Fields
| Field | Type | Required | Description |
|---|---|---|---|
appId | string | No | App client ID (falls back to stored credentials) |
outDir | string | No | Output directory for built sandbox bundles. Default: dist |
s3 | object | No | S3/R2 configuration for uploading sandbox bundles |
extensions | array | Yes | Array of extension definitions |
S3 Configuration
| Field | Type | Required | Description |
|---|---|---|---|
endpoint | string | Yes | S3-compatible endpoint URL |
bucket | string | No | Bucket name. Default: pap |
accessKey | string | Yes | Access key ID |
secretKey | string | Yes | Secret access key |
publicUrl | string | No | Public URL prefix for uploaded files |
Extension Fields
| Field | Type | Required | Description |
|---|---|---|---|
extension_id | string | Yes | Unique identifier for this extension (must be unique within the app) |
target | string | Yes | Where the extension appears. Must be a valid target |
title | string | Yes | Display name shown to merchants |
description | string | No | Brief description |
mode | string | Yes | json or sandbox |
ui | object | json mode | JSON component tree (required when mode is json) |
entry | string | sandbox mode | Local path to the entry file (used by the CLI for building; not sent to the API) |
sandbox_url | string | sandbox mode | URL of the built sandbox bundle (required when mode is sandbox; set automatically if S3 is configured) |
initial_state | object | No | Default state values for JSON extensions |
load_action | object | No | Action to execute when the extension first loads |
sort_order | integer | No | Display order (lower numbers appear first). Default: 0 |
settings_schema | array | No | Merchant-configurable settings. See Merchant Settings |
capabilities | object | No | Extension capabilities metadata |
The entry field is local-only
The entry field tells the CLI where to find the source file for building. It
is stripped from the payload before sending to the API. If you manage your own
build process, omit entry and set sandbox_url directly.
Example Workflow
1. Initialize
mkdir my-selorax-app && cd my-selorax-app
npm init -y
npm install @selorax/ui
npm install -g @selorax/cli
selorax auth:login --client-id sx_app_... --client-secret sx_secret_... --store-id 22
selorax generate:config2. Create an extension
selorax generate:extension -t order.detail.block -m json -n "Order Notes"Edit the generated extension in selorax.config.json.
3. Develop
selorax devMake changes to the config. JSON extensions are re-deployed on save. Sandbox extensions are rebuilt on file change.
4. Validate
selorax validate5. Deploy
selorax deploy --dry-run # Preview first
selorax deploy # Deploy for real6. Manage versions
selorax versions # List version history
selorax rollback -v 2 # Rollback if neededWhat's Next
- Extension Platform Overview — Architecture and concepts
- JSON Extensions — Build declarative UI trees
- Sandbox Extensions — Build with full JavaScript control
- Merchant Settings — Define configurable settings