@sapiom/cli
Advanced tools
| import { action, json } from '../shared.js'; | ||
| import { runPreview } from './preview.js'; | ||
| /** | ||
| * Mount the `sapiom sandbox …` command group. `preview` deploys local web-app code | ||
| * to a sandbox and exposes a live URL. Distinct from `agents` (the composition | ||
| * product) and from the future production `applications` product. | ||
| */ | ||
| export function registerSandboxCommands(program) { | ||
| const group = program.command('sandbox').alias('sbx').description('Run and preview code on Sapiom sandboxes.'); | ||
| json(group.command('preview [name]').description('Provision, upload, build, start, and expose a live preview URL.')) | ||
| // Sandboxes run on the compute host, not the API host — so this is a precise | ||
| // services-base override, not the agents' --host/--target (API host). | ||
| .option('--services-url <url>', 'override the compute/sandbox service base URL') | ||
| .action(action(runPreview)); | ||
| } |
| import { previewSandbox, PreviewOperationError } from '@sapiom/sandbox-preview'; | ||
| import { resolveApiKey } from '../../lib/client.js'; | ||
| import { CliError, isJsonMode, ok } from '../../lib/output.js'; | ||
| /** | ||
| * `sapiom sandbox preview [name]` — provision a sandbox (if needed), upload the | ||
| * local code, build it, start it, and expose a live preview URL. Reads the | ||
| * sandbox's declared intent from `sapiom.json` (`type: "sandbox"`, singular-default | ||
| * when there's exactly one). | ||
| */ | ||
| export async function runPreview(name, opts) { | ||
| try { | ||
| const apiKey = resolveApiKey(); | ||
| const result = await previewSandbox({ | ||
| dir: process.cwd(), | ||
| name, | ||
| apiKey, | ||
| servicesBaseUrl: opts.servicesUrl, | ||
| // Progress goes to stderr so it never pollutes --json stdout. | ||
| log: (msg) => { | ||
| if (!isJsonMode()) | ||
| process.stderr.write(` ${msg}\n`); | ||
| }, | ||
| }); | ||
| if (isJsonMode()) { | ||
| ok({ name: result.name, url: result.url, status: result.status }); | ||
| } | ||
| else if (result.status === 'failed') { | ||
| ok({}, [`✗ ${result.name} build/start failed:`, result.logs]); | ||
| } | ||
| else { | ||
| const verified = result.status === 'deployed' ? 'live' : 'started (unverified)'; | ||
| ok({}, [`✓ ${result.name} ${verified}: ${result.url}`]); | ||
| } | ||
| } | ||
| catch (err) { | ||
| if (err instanceof PreviewOperationError) | ||
| throw new CliError(err.toStructured()); | ||
| throw err; | ||
| } | ||
| } |
+2
-0
@@ -6,2 +6,3 @@ import { Command } from 'commander'; | ||
| import { registerCommandAnalytics } from './lib/analytics.js'; | ||
| import { registerSandboxCommands } from './commands/sandbox/index.js'; | ||
| /** | ||
@@ -20,3 +21,4 @@ * Build the root `sapiom` program. Account-level commands (login/logout) sit at | ||
| registerAgentsCommands(program); | ||
| registerSandboxCommands(program); | ||
| return program; | ||
| } |
@@ -19,3 +19,3 @@ /** | ||
| */ | ||
| function resolveApiKey() { | ||
| export function resolveApiKey() { | ||
| const env = process.env.SAPIOM_API_KEY; | ||
@@ -22,0 +22,0 @@ if (env) |
+4
-3
| { | ||
| "name": "@sapiom/cli", | ||
| "version": "0.4.0", | ||
| "version": "0.4.1", | ||
| "description": "The Sapiom command-line interface — scaffold, validate, and ship Sapiom orchestrations.", | ||
@@ -34,4 +34,5 @@ "license": "MIT", | ||
| "@sapiom/agent": "^0.6.2", | ||
| "@sapiom/agent-core": "^0.9.0", | ||
| "@sapiom/analytics-core": "^0.2.0" | ||
| "@sapiom/agent-core": "^0.9.1", | ||
| "@sapiom/analytics-core": "^0.2.0", | ||
| "@sapiom/sandbox-preview": "^0.1.2" | ||
| }, | ||
@@ -38,0 +39,0 @@ "devDependencies": { |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
82908
3.27%41
5.13%1738
3.39%6
20%+ Added
Updated