🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@sapiom/cli

Package Overview
Dependencies
Maintainers
3
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sapiom/cli - npm Package Compare versions

Comparing version
0.4.0
to
0.4.1
+15
dist/commands/sandbox/index.js
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;
}
+1
-1

@@ -19,3 +19,3 @@ /**

*/
function resolveApiKey() {
export function resolveApiKey() {
const env = process.env.SAPIOM_API_KEY;

@@ -22,0 +22,0 @@ if (env)

{
"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": {