UNPKG

@controlplane/cli

Version:

Control Plane Corporation CLI

64 lines 2.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SandboxConnect = exports.SandboxCmd = void 0; const command_1 = require("../cli/command"); const options_1 = require("./options"); const generic_1 = require("./generic"); const functions_1 = require("../util/functions"); const sandbox_connector_1 = require("../sandbox/sandbox-connector"); function withSandboxConnectOptions(yargs) { return yargs.options({ ide: { requiresArg: true, default: 'vscode', choices: [...sandbox_connector_1.SANDBOX_IDES], description: 'IDE or connection mode to launch.', }, port: { requiresArg: true, number: true, description: 'Preferred local SSH port. Defaults to an available port chosen automatically.', }, }); } // ANCHOR - Command class SandboxCmd extends command_1.Command { constructor() { super(...arguments); this.command = 'sandbox'; this.describe = 'Manage sandboxes'; } builder(yargs) { return yargs.demandCommand().version(false).help().command(new SandboxConnect().toYargs()); } handle() { } } exports.SandboxCmd = SandboxCmd; class SandboxConnect extends command_1.Command { constructor() { super(...arguments); this.command = 'connect <ref>'; this.describe = 'Connect to a running sandbox'; } builder(yargs) { return (0, functions_1.pipe)(generic_1.withSingleRef, withSandboxConnectOptions, options_1.withAllOptions)(yargs); } async handle(args) { var _a; this.requireFullContext(); // The connector owns the connect flow; turn any failure into a clean exit at the boundary. const connector = new sandbox_connector_1.SandboxConnector(this.client, this.session); try { await connector.connect({ ref: args.ref, ide: ((_a = args.ide) !== null && _a !== void 0 ? _a : 'vscode'), port: args.port, }); } catch (e) { this.session.abort({ error: e }); } } } exports.SandboxConnect = SandboxConnect; //# sourceMappingURL=sandbox.js.map