@stateset/sandbox-cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/client.test.d.ts +2 -0
- package/dist/__tests__/client.test.d.ts.map +1 -0
- package/dist/__tests__/client.test.js +198 -0
- package/dist/__tests__/client.test.js.map +1 -0
- package/dist/__tests__/config.test.d.ts +2 -0
- package/dist/__tests__/config.test.d.ts.map +1 -0
- package/dist/__tests__/config.test.js +50 -0
- package/dist/__tests__/config.test.js.map +1 -0
- package/dist/client.d.ts +158 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +89 -0
- package/dist/client.js.map +1 -0
- package/dist/commands/artifact.d.ts +3 -0
- package/dist/commands/artifact.d.ts.map +1 -0
- package/dist/commands/artifact.js +220 -0
- package/dist/commands/artifact.js.map +1 -0
- package/dist/commands/checkpoint.d.ts +3 -0
- package/dist/commands/checkpoint.d.ts.map +1 -0
- package/dist/commands/checkpoint.js +261 -0
- package/dist/commands/checkpoint.js.map +1 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +134 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/deploy.d.ts +3 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +51 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/pool.d.ts +3 -0
- package/dist/commands/pool.d.ts.map +1 -0
- package/dist/commands/pool.js +114 -0
- package/dist/commands/pool.js.map +1 -0
- package/dist/commands/sandbox.d.ts +3 -0
- package/dist/commands/sandbox.d.ts.map +1 -0
- package/dist/commands/sandbox.js +324 -0
- package/dist/commands/sandbox.js.map +1 -0
- package/dist/commands/session.d.ts +3 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +351 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/commands/tunnel.d.ts +3 -0
- package/dist/commands/tunnel.d.ts.map +1 -0
- package/dist/commands/tunnel.js +103 -0
- package/dist/commands/tunnel.js.map +1 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +31 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +50 -0
- package/dist/index.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import { table } from 'table';
|
|
5
|
+
import { getClient } from '../client.js';
|
|
6
|
+
export const artifactCommand = new Command('artifact')
|
|
7
|
+
.alias('art')
|
|
8
|
+
.description('Manage sandbox artifacts');
|
|
9
|
+
// Upload artifact
|
|
10
|
+
artifactCommand
|
|
11
|
+
.command('upload <sandbox-id> <path>')
|
|
12
|
+
.description('Upload a file from sandbox to cloud storage')
|
|
13
|
+
.option('-t, --type <content-type>', 'Content type (e.g., "application/pdf")')
|
|
14
|
+
.option('-e, --expires <seconds>', 'Expiry time in seconds')
|
|
15
|
+
.option('-m, --metadata <key=value...>', 'Metadata key-value pairs')
|
|
16
|
+
.action(async (sandboxId, path, options) => {
|
|
17
|
+
const spinner = ora('Uploading artifact...').start();
|
|
18
|
+
try {
|
|
19
|
+
const client = getClient();
|
|
20
|
+
const metadata = {};
|
|
21
|
+
if (options.metadata) {
|
|
22
|
+
for (const m of options.metadata) {
|
|
23
|
+
const [key, ...valueParts] = m.split('=');
|
|
24
|
+
metadata[key] = valueParts.join('=');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const result = await client.artifacts.upload(sandboxId, path, {
|
|
28
|
+
content_type: options.type,
|
|
29
|
+
expires_in: options.expires ? parseInt(options.expires) : undefined,
|
|
30
|
+
metadata: Object.keys(metadata).length > 0 ? metadata : undefined,
|
|
31
|
+
});
|
|
32
|
+
spinner.succeed('Artifact uploaded');
|
|
33
|
+
console.log();
|
|
34
|
+
console.log(chalk.green('Artifact ID:'), result.id);
|
|
35
|
+
console.log(chalk.gray('Path:'), result.path);
|
|
36
|
+
console.log(chalk.gray('Size:'), formatBytes(result.size));
|
|
37
|
+
console.log(chalk.gray('Content Type:'), result.content_type ?? '-');
|
|
38
|
+
console.log(chalk.gray('Checksum:'), result.checksum.substring(0, 16) + '...');
|
|
39
|
+
if (result.expires_at) {
|
|
40
|
+
console.log(chalk.gray('Expires:'), result.expires_at);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
spinner.fail('Failed to upload artifact');
|
|
45
|
+
console.error(chalk.red(error.message));
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
// List artifacts
|
|
50
|
+
artifactCommand
|
|
51
|
+
.command('list')
|
|
52
|
+
.alias('ls')
|
|
53
|
+
.description('List all artifacts')
|
|
54
|
+
.option('-s, --sandbox <sandbox-id>', 'Filter by sandbox ID')
|
|
55
|
+
.option('--json', 'Output as JSON')
|
|
56
|
+
.action(async (options) => {
|
|
57
|
+
const spinner = ora('Fetching artifacts...').start();
|
|
58
|
+
try {
|
|
59
|
+
const client = getClient();
|
|
60
|
+
const result = await client.artifacts.list(options.sandbox);
|
|
61
|
+
spinner.stop();
|
|
62
|
+
if (options.json) {
|
|
63
|
+
console.log(JSON.stringify(result.artifacts, null, 2));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (result.artifacts.length === 0) {
|
|
67
|
+
console.log(chalk.yellow('No artifacts found'));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const tableData = [
|
|
71
|
+
['ID', 'Path', 'Sandbox', 'Size', 'Type', 'Expires'].map(h => chalk.bold(h)),
|
|
72
|
+
...result.artifacts.map((a) => [
|
|
73
|
+
a.id.substring(0, 16),
|
|
74
|
+
truncate(a.path, 30),
|
|
75
|
+
a.sandbox_id.substring(0, 12),
|
|
76
|
+
formatBytes(a.size),
|
|
77
|
+
truncate(a.content_type ?? '-', 15),
|
|
78
|
+
a.expires_at ? formatDate(a.expires_at) : '-',
|
|
79
|
+
]),
|
|
80
|
+
];
|
|
81
|
+
console.log(table(tableData));
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
spinner.fail('Failed to list artifacts');
|
|
85
|
+
console.error(chalk.red(error.message));
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
// Get artifact details
|
|
90
|
+
artifactCommand
|
|
91
|
+
.command('get <artifact-id>')
|
|
92
|
+
.description('Get artifact details')
|
|
93
|
+
.option('--json', 'Output as JSON')
|
|
94
|
+
.action(async (artifactId, options) => {
|
|
95
|
+
const spinner = ora('Fetching artifact...').start();
|
|
96
|
+
try {
|
|
97
|
+
const client = getClient();
|
|
98
|
+
const result = await client.artifacts.get(artifactId);
|
|
99
|
+
spinner.stop();
|
|
100
|
+
if (options.json) {
|
|
101
|
+
console.log(JSON.stringify(result, null, 2));
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
console.log(chalk.bold('Artifact Details'));
|
|
105
|
+
console.log(chalk.gray('─'.repeat(40)));
|
|
106
|
+
console.log(`ID: ${result.id}`);
|
|
107
|
+
console.log(`Path: ${result.path}`);
|
|
108
|
+
console.log(`Remote Path: ${result.remote_path ?? '-'}`);
|
|
109
|
+
console.log(`Sandbox: ${result.sandbox_id}`);
|
|
110
|
+
console.log(`Size: ${formatBytes(result.size)}`);
|
|
111
|
+
console.log(`Content Type: ${result.content_type ?? '-'}`);
|
|
112
|
+
console.log(`Checksum: ${result.checksum}`);
|
|
113
|
+
console.log(`Created: ${result.created_at}`);
|
|
114
|
+
if (result.expires_at) {
|
|
115
|
+
console.log(`Expires: ${result.expires_at}`);
|
|
116
|
+
}
|
|
117
|
+
if (result.metadata && Object.keys(result.metadata).length > 0) {
|
|
118
|
+
console.log(`Metadata:`);
|
|
119
|
+
for (const [key, value] of Object.entries(result.metadata)) {
|
|
120
|
+
console.log(` ${key}: ${value}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
spinner.fail('Failed to get artifact');
|
|
126
|
+
console.error(chalk.red(error.message));
|
|
127
|
+
process.exit(1);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
// Get download URL
|
|
131
|
+
artifactCommand
|
|
132
|
+
.command('url <artifact-id>')
|
|
133
|
+
.description('Get a presigned download URL for an artifact')
|
|
134
|
+
.option('-e, --expires <seconds>', 'URL expiry time in seconds', '3600')
|
|
135
|
+
.action(async (artifactId, options) => {
|
|
136
|
+
const spinner = ora('Generating download URL...').start();
|
|
137
|
+
try {
|
|
138
|
+
const client = getClient();
|
|
139
|
+
const result = await client.artifacts.getUrl(artifactId, parseInt(options.expires));
|
|
140
|
+
spinner.stop();
|
|
141
|
+
console.log(chalk.bold('Download URL'));
|
|
142
|
+
console.log(chalk.gray('─'.repeat(40)));
|
|
143
|
+
console.log(result.url);
|
|
144
|
+
console.log();
|
|
145
|
+
console.log(chalk.gray(`Valid for ${result.expires_in} seconds`));
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
spinner.fail('Failed to generate download URL');
|
|
149
|
+
console.error(chalk.red(error.message));
|
|
150
|
+
process.exit(1);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
// Download artifact to sandbox
|
|
154
|
+
artifactCommand
|
|
155
|
+
.command('download <sandbox-id> <artifact-id> <target-path>')
|
|
156
|
+
.description('Download an artifact to a sandbox')
|
|
157
|
+
.action(async (sandboxId, artifactId, targetPath) => {
|
|
158
|
+
const spinner = ora('Downloading artifact...').start();
|
|
159
|
+
try {
|
|
160
|
+
const client = getClient();
|
|
161
|
+
await client.artifacts.download(sandboxId, artifactId, targetPath);
|
|
162
|
+
spinner.succeed(`Artifact downloaded to ${targetPath}`);
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
spinner.fail('Failed to download artifact');
|
|
166
|
+
console.error(chalk.red(error.message));
|
|
167
|
+
process.exit(1);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
// Delete artifact
|
|
171
|
+
artifactCommand
|
|
172
|
+
.command('delete <artifact-id>')
|
|
173
|
+
.alias('rm')
|
|
174
|
+
.description('Delete an artifact')
|
|
175
|
+
.option('-f, --force', 'Skip confirmation')
|
|
176
|
+
.action(async (artifactId, options) => {
|
|
177
|
+
if (!options.force) {
|
|
178
|
+
const { default: inquirer } = await import('inquirer');
|
|
179
|
+
const { confirm } = await inquirer.prompt([{
|
|
180
|
+
type: 'confirm',
|
|
181
|
+
name: 'confirm',
|
|
182
|
+
message: `Are you sure you want to delete artifact ${artifactId}?`,
|
|
183
|
+
default: false,
|
|
184
|
+
}]);
|
|
185
|
+
if (!confirm) {
|
|
186
|
+
console.log(chalk.yellow('Aborted'));
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
const spinner = ora('Deleting artifact...').start();
|
|
191
|
+
try {
|
|
192
|
+
const client = getClient();
|
|
193
|
+
await client.artifacts.delete(artifactId);
|
|
194
|
+
spinner.succeed('Artifact deleted');
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
spinner.fail('Failed to delete artifact');
|
|
198
|
+
console.error(chalk.red(error.message));
|
|
199
|
+
process.exit(1);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
// Helper functions
|
|
203
|
+
function formatBytes(bytes) {
|
|
204
|
+
if (bytes === 0)
|
|
205
|
+
return '0 B';
|
|
206
|
+
const k = 1024;
|
|
207
|
+
const sizes = ['B', 'KB', 'MB', 'GB'];
|
|
208
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
209
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
|
|
210
|
+
}
|
|
211
|
+
function formatDate(dateStr) {
|
|
212
|
+
const date = new Date(dateStr);
|
|
213
|
+
return date.toLocaleString();
|
|
214
|
+
}
|
|
215
|
+
function truncate(str, length) {
|
|
216
|
+
if (str.length <= length)
|
|
217
|
+
return str;
|
|
218
|
+
return str.substring(0, length - 3) + '...';
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=artifact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact.js","sourceRoot":"","sources":["../../src/commands/artifact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;KACnD,KAAK,CAAC,KAAK,CAAC;KACZ,WAAW,CAAC,0BAA0B,CAAC,CAAC;AAE3C,kBAAkB;AAClB,eAAe;KACZ,OAAO,CAAC,4BAA4B,CAAC;KACrC,WAAW,CAAC,6CAA6C,CAAC;KAC1D,MAAM,CAAC,2BAA2B,EAAE,wCAAwC,CAAC;KAC7E,MAAM,CAAC,yBAAyB,EAAE,wBAAwB,CAAC;KAC3D,MAAM,CAAC,+BAA+B,EAAE,0BAA0B,CAAC;KACnE,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;IACzC,MAAM,OAAO,GAAG,GAAG,CAAC,uBAAuB,CAAC,CAAC,KAAK,EAAE,CAAC;IAErD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAE3B,MAAM,QAAQ,GAA2B,EAAE,CAAC;QAC5C,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YACrB,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC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AG,KAAK,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkpoint.d.ts","sourceRoot":"","sources":["../../src/commands/checkpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,eAAO,MAAM,iBAAiB,SAEc,CAAC"}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import { table } from 'table';
|
|
5
|
+
import { getClient } from '../client.js';
|
|
6
|
+
export const checkpointCommand = new Command('checkpoint')
|
|
7
|
+
.alias('cp')
|
|
8
|
+
.description('Manage sandbox checkpoints');
|
|
9
|
+
// Create checkpoint
|
|
10
|
+
checkpointCommand
|
|
11
|
+
.command('create <sandbox-id> <name>')
|
|
12
|
+
.description('Create a checkpoint from a sandbox')
|
|
13
|
+
.option('-d, --description <description>', 'Checkpoint description')
|
|
14
|
+
.option('-i, --include <paths...>', 'Paths to include')
|
|
15
|
+
.option('-e, --exclude <paths...>', 'Paths to exclude')
|
|
16
|
+
.option('--no-env', 'Do not include environment variables')
|
|
17
|
+
.action(async (sandboxId, name, options) => {
|
|
18
|
+
const spinner = ora('Creating checkpoint...').start();
|
|
19
|
+
try {
|
|
20
|
+
const client = getClient();
|
|
21
|
+
const result = await client.checkpoints.create(sandboxId, name, {
|
|
22
|
+
description: options.description,
|
|
23
|
+
include_paths: options.include,
|
|
24
|
+
exclude_paths: options.exclude,
|
|
25
|
+
include_env: options.env,
|
|
26
|
+
});
|
|
27
|
+
spinner.succeed('Checkpoint created');
|
|
28
|
+
console.log();
|
|
29
|
+
console.log(chalk.green('Checkpoint ID:'), result.id);
|
|
30
|
+
console.log(chalk.gray('Name:'), result.name);
|
|
31
|
+
console.log(chalk.gray('Size:'), formatBytes(result.size));
|
|
32
|
+
console.log(chalk.gray('Files:'), result.file_count);
|
|
33
|
+
console.log(chalk.gray('Checksum:'), result.checksum.substring(0, 16) + '...');
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
spinner.fail('Failed to create checkpoint');
|
|
37
|
+
console.error(chalk.red(error.message));
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
// List checkpoints
|
|
42
|
+
checkpointCommand
|
|
43
|
+
.command('list')
|
|
44
|
+
.alias('ls')
|
|
45
|
+
.description('List all checkpoints')
|
|
46
|
+
.option('-s, --sandbox <sandbox-id>', 'Filter by sandbox ID')
|
|
47
|
+
.option('-n, --name <name>', 'Filter by name')
|
|
48
|
+
.option('--json', 'Output as JSON')
|
|
49
|
+
.action(async (options) => {
|
|
50
|
+
const spinner = ora('Fetching checkpoints...').start();
|
|
51
|
+
try {
|
|
52
|
+
const client = getClient();
|
|
53
|
+
const result = await client.checkpoints.list(options.sandbox);
|
|
54
|
+
spinner.stop();
|
|
55
|
+
let checkpoints = result.checkpoints;
|
|
56
|
+
if (options.name) {
|
|
57
|
+
checkpoints = checkpoints.filter((cp) => cp.name.includes(options.name));
|
|
58
|
+
}
|
|
59
|
+
if (options.json) {
|
|
60
|
+
console.log(JSON.stringify(checkpoints, null, 2));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (checkpoints.length === 0) {
|
|
64
|
+
console.log(chalk.yellow('No checkpoints found'));
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const tableData = [
|
|
68
|
+
['ID', 'Name', 'Sandbox', 'Size', 'Files', 'Created'].map(h => chalk.bold(h)),
|
|
69
|
+
...checkpoints.map((cp) => [
|
|
70
|
+
cp.id.substring(0, 16),
|
|
71
|
+
cp.name,
|
|
72
|
+
cp.sandbox_id.substring(0, 16),
|
|
73
|
+
formatBytes(cp.size),
|
|
74
|
+
cp.file_count.toString(),
|
|
75
|
+
formatDate(cp.created_at),
|
|
76
|
+
]),
|
|
77
|
+
];
|
|
78
|
+
console.log(table(tableData));
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
spinner.fail('Failed to list checkpoints');
|
|
82
|
+
console.error(chalk.red(error.message));
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
// Get checkpoint details
|
|
87
|
+
checkpointCommand
|
|
88
|
+
.command('get <checkpoint-id>')
|
|
89
|
+
.description('Get checkpoint details')
|
|
90
|
+
.option('--json', 'Output as JSON')
|
|
91
|
+
.action(async (checkpointId, options) => {
|
|
92
|
+
const spinner = ora('Fetching checkpoint...').start();
|
|
93
|
+
try {
|
|
94
|
+
const client = getClient();
|
|
95
|
+
const result = await client.checkpoints.get(checkpointId);
|
|
96
|
+
spinner.stop();
|
|
97
|
+
if (options.json) {
|
|
98
|
+
console.log(JSON.stringify(result, null, 2));
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
console.log(chalk.bold('Checkpoint Details'));
|
|
102
|
+
console.log(chalk.gray('─'.repeat(40)));
|
|
103
|
+
console.log(`ID: ${result.id}`);
|
|
104
|
+
console.log(`Name: ${result.name}`);
|
|
105
|
+
if (result.description) {
|
|
106
|
+
console.log(`Description: ${result.description}`);
|
|
107
|
+
}
|
|
108
|
+
console.log(`Sandbox: ${result.sandbox_id}`);
|
|
109
|
+
console.log(`Size: ${formatBytes(result.size)}`);
|
|
110
|
+
console.log(`Files: ${result.file_count}`);
|
|
111
|
+
console.log(`Checksum: ${result.checksum}`);
|
|
112
|
+
console.log(`Created: ${result.created_at}`);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
spinner.fail('Failed to get checkpoint');
|
|
116
|
+
console.error(chalk.red(error.message));
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
// Restore checkpoint
|
|
121
|
+
checkpointCommand
|
|
122
|
+
.command('restore <sandbox-id> <checkpoint-id>')
|
|
123
|
+
.description('Restore a checkpoint to a sandbox')
|
|
124
|
+
.option('--no-files', 'Do not restore files')
|
|
125
|
+
.option('--no-env', 'Do not restore environment variables')
|
|
126
|
+
.option('--no-overwrite', 'Do not overwrite existing files')
|
|
127
|
+
.action(async (sandboxId, checkpointId, options) => {
|
|
128
|
+
const spinner = ora('Restoring checkpoint...').start();
|
|
129
|
+
try {
|
|
130
|
+
const client = getClient();
|
|
131
|
+
await client.checkpoints.restore(sandboxId, checkpointId, {
|
|
132
|
+
restore_files: options.files,
|
|
133
|
+
restore_env: options.env,
|
|
134
|
+
overwrite: options.overwrite,
|
|
135
|
+
});
|
|
136
|
+
spinner.succeed('Checkpoint restored');
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
spinner.fail('Failed to restore checkpoint');
|
|
140
|
+
console.error(chalk.red(error.message));
|
|
141
|
+
process.exit(1);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
// Clone checkpoint
|
|
145
|
+
checkpointCommand
|
|
146
|
+
.command('clone <checkpoint-id> <new-name>')
|
|
147
|
+
.description('Clone a checkpoint')
|
|
148
|
+
.action(async (checkpointId, newName) => {
|
|
149
|
+
const spinner = ora('Cloning checkpoint...').start();
|
|
150
|
+
try {
|
|
151
|
+
const client = getClient();
|
|
152
|
+
const result = await client.checkpoints.clone(checkpointId, newName);
|
|
153
|
+
spinner.succeed('Checkpoint cloned');
|
|
154
|
+
console.log();
|
|
155
|
+
console.log(chalk.green('New Checkpoint ID:'), result.id);
|
|
156
|
+
console.log(chalk.gray('Name:'), result.name);
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
spinner.fail('Failed to clone checkpoint');
|
|
160
|
+
console.error(chalk.red(error.message));
|
|
161
|
+
process.exit(1);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
// Compare checkpoints
|
|
165
|
+
checkpointCommand
|
|
166
|
+
.command('compare <checkpoint-1> <checkpoint-2>')
|
|
167
|
+
.alias('diff')
|
|
168
|
+
.description('Compare two checkpoints')
|
|
169
|
+
.option('--json', 'Output as JSON')
|
|
170
|
+
.action(async (checkpoint1, checkpoint2, options) => {
|
|
171
|
+
const spinner = ora('Comparing checkpoints...').start();
|
|
172
|
+
try {
|
|
173
|
+
const client = getClient();
|
|
174
|
+
const result = await client.checkpoints.compare(checkpoint1, checkpoint2);
|
|
175
|
+
spinner.stop();
|
|
176
|
+
if (options.json) {
|
|
177
|
+
console.log(JSON.stringify(result, null, 2));
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
console.log(chalk.bold('Checkpoint Comparison'));
|
|
181
|
+
console.log(chalk.gray('─'.repeat(40)));
|
|
182
|
+
console.log(`Checkpoint 1: ${result.checkpoint_1.name} (${result.checkpoint_1.id})`);
|
|
183
|
+
console.log(`Checkpoint 2: ${result.checkpoint_2.name} (${result.checkpoint_2.id})`);
|
|
184
|
+
console.log();
|
|
185
|
+
if (result.diff.added.length === 0 &&
|
|
186
|
+
result.diff.removed.length === 0 &&
|
|
187
|
+
result.diff.modified.length === 0) {
|
|
188
|
+
console.log(chalk.green('No differences found'));
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (result.diff.added.length > 0) {
|
|
192
|
+
console.log(chalk.green(`Added (${result.diff.added.length}):`));
|
|
193
|
+
for (const file of result.diff.added) {
|
|
194
|
+
console.log(chalk.green(` + ${file}`));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (result.diff.removed.length > 0) {
|
|
198
|
+
console.log(chalk.red(`Removed (${result.diff.removed.length}):`));
|
|
199
|
+
for (const file of result.diff.removed) {
|
|
200
|
+
console.log(chalk.red(` - ${file}`));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (result.diff.modified.length > 0) {
|
|
204
|
+
console.log(chalk.yellow(`Modified (${result.diff.modified.length}):`));
|
|
205
|
+
for (const file of result.diff.modified) {
|
|
206
|
+
console.log(chalk.yellow(` ~ ${file}`));
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
spinner.fail('Failed to compare checkpoints');
|
|
212
|
+
console.error(chalk.red(error.message));
|
|
213
|
+
process.exit(1);
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
// Delete checkpoint
|
|
217
|
+
checkpointCommand
|
|
218
|
+
.command('delete <checkpoint-id>')
|
|
219
|
+
.alias('rm')
|
|
220
|
+
.description('Delete a checkpoint')
|
|
221
|
+
.option('-f, --force', 'Skip confirmation')
|
|
222
|
+
.action(async (checkpointId, options) => {
|
|
223
|
+
if (!options.force) {
|
|
224
|
+
const { default: inquirer } = await import('inquirer');
|
|
225
|
+
const { confirm } = await inquirer.prompt([{
|
|
226
|
+
type: 'confirm',
|
|
227
|
+
name: 'confirm',
|
|
228
|
+
message: `Are you sure you want to delete checkpoint ${checkpointId}?`,
|
|
229
|
+
default: false,
|
|
230
|
+
}]);
|
|
231
|
+
if (!confirm) {
|
|
232
|
+
console.log(chalk.yellow('Aborted'));
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
const spinner = ora('Deleting checkpoint...').start();
|
|
237
|
+
try {
|
|
238
|
+
const client = getClient();
|
|
239
|
+
await client.checkpoints.delete(checkpointId);
|
|
240
|
+
spinner.succeed('Checkpoint deleted');
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
spinner.fail('Failed to delete checkpoint');
|
|
244
|
+
console.error(chalk.red(error.message));
|
|
245
|
+
process.exit(1);
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
// Helper functions
|
|
249
|
+
function formatBytes(bytes) {
|
|
250
|
+
if (bytes === 0)
|
|
251
|
+
return '0 B';
|
|
252
|
+
const k = 1024;
|
|
253
|
+
const sizes = ['B', 'KB', 'MB', 'GB'];
|
|
254
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
255
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
|
|
256
|
+
}
|
|
257
|
+
function formatDate(dateStr) {
|
|
258
|
+
const date = new Date(dateStr);
|
|
259
|
+
return date.toLocaleString();
|
|
260
|
+
}
|
|
261
|
+
//# sourceMappingURL=checkpoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkpoint.js","sourceRoot":"","sources":["../../src/commands/checkpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC;KACvD,KAAK,CAAC,IAAI,CAAC;KACX,WAAW,CAAC,4BAA4B,CAAC,CAAC;AAE7C,oBAAoB;AACpB,iBAAiB;KACd,OAAO,CAAC,4BAA4B,CAAC;KACrC,WAAW,CAAC,oCAAoC,CAAC;KACjD,MAAM,CAAC,iCAAiC,EAAE,wBAAwB,CAAC;KACnE,MAAM,CAAC,0BAA0B,EAAE,kBAAkB,CAAC;KACtD,MAAM,CAAC,0BAA0B,EAAE,kBAAkB,CAAC;KACtD,MAAM,CAAC,UAAU,EAAE,sCAAsC,CAAC;KAC1D,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;IACzC,MAAM,OAAO,GAAG,GAAG,CAAC,wBAAwB,CAAC,CAAC,KAAK,EAAE,CAAC;IAEtD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE;YAC9D,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,aAAa,EAAE,OAAO,C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AE,IAAI,CAAC,CAAC;IACtC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,OAAO,GAAG,UAAU,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1E,CAAC;AAED,SAAS,UAAU,CAAC,OAAe;IACjC,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/B,OAAO,IAAI,CAAC,cAAc,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWpC,eAAO,MAAM,aAAa,SACgB,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { getConfig, setApiKey, setApiUrl, setDefaultTimeout, clearConfig, getConfigPath, } from '../config.js';
|
|
4
|
+
export const configCommand = new Command('config')
|
|
5
|
+
.description('Manage CLI configuration');
|
|
6
|
+
// Show current config
|
|
7
|
+
configCommand
|
|
8
|
+
.command('show')
|
|
9
|
+
.description('Show current configuration')
|
|
10
|
+
.option('--json', 'Output as JSON')
|
|
11
|
+
.action((options) => {
|
|
12
|
+
const config = getConfig();
|
|
13
|
+
if (options.json) {
|
|
14
|
+
console.log(JSON.stringify({
|
|
15
|
+
...config,
|
|
16
|
+
apiKey: config.apiKey ? '***' + config.apiKey.slice(-4) : null,
|
|
17
|
+
}, null, 2));
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
console.log(chalk.bold('Current Configuration'));
|
|
21
|
+
console.log(chalk.gray('─'.repeat(40)));
|
|
22
|
+
console.log(`API Key: ${config.apiKey ? chalk.green('***' + config.apiKey.slice(-4)) : chalk.red('Not set')}`);
|
|
23
|
+
console.log(`API URL: ${config.apiUrl}`);
|
|
24
|
+
console.log(`Default Timeout: ${config.defaultTimeout}s`);
|
|
25
|
+
console.log();
|
|
26
|
+
console.log(chalk.gray(`Config file: ${getConfigPath()}`));
|
|
27
|
+
});
|
|
28
|
+
// Set API key
|
|
29
|
+
configCommand
|
|
30
|
+
.command('set-key <api-key>')
|
|
31
|
+
.description('Set the API key')
|
|
32
|
+
.action((apiKey) => {
|
|
33
|
+
setApiKey(apiKey);
|
|
34
|
+
console.log(chalk.green('✓ API key configured'));
|
|
35
|
+
console.log(chalk.gray(` Key: ***${apiKey.slice(-4)}`));
|
|
36
|
+
});
|
|
37
|
+
// Set API URL
|
|
38
|
+
configCommand
|
|
39
|
+
.command('set-url <url>')
|
|
40
|
+
.description('Set the API URL')
|
|
41
|
+
.action((url) => {
|
|
42
|
+
setApiUrl(url);
|
|
43
|
+
console.log(chalk.green('✓ API URL configured'));
|
|
44
|
+
console.log(chalk.gray(` URL: ${url}`));
|
|
45
|
+
});
|
|
46
|
+
// Set default timeout
|
|
47
|
+
configCommand
|
|
48
|
+
.command('set-timeout <seconds>')
|
|
49
|
+
.description('Set the default sandbox timeout')
|
|
50
|
+
.action((seconds) => {
|
|
51
|
+
const timeout = parseInt(seconds);
|
|
52
|
+
if (isNaN(timeout) || timeout <= 0) {
|
|
53
|
+
console.error(chalk.red('Error: Timeout must be a positive number'));
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
setDefaultTimeout(timeout);
|
|
57
|
+
console.log(chalk.green('✓ Default timeout configured'));
|
|
58
|
+
console.log(chalk.gray(` Timeout: ${timeout}s`));
|
|
59
|
+
});
|
|
60
|
+
// Clear config
|
|
61
|
+
configCommand
|
|
62
|
+
.command('clear')
|
|
63
|
+
.description('Clear all configuration')
|
|
64
|
+
.option('-f, --force', 'Skip confirmation')
|
|
65
|
+
.action(async (options) => {
|
|
66
|
+
if (!options.force) {
|
|
67
|
+
const { default: inquirer } = await import('inquirer');
|
|
68
|
+
const { confirm } = await inquirer.prompt([{
|
|
69
|
+
type: 'confirm',
|
|
70
|
+
name: 'confirm',
|
|
71
|
+
message: 'Are you sure you want to clear all configuration?',
|
|
72
|
+
default: false,
|
|
73
|
+
}]);
|
|
74
|
+
if (!confirm) {
|
|
75
|
+
console.log(chalk.yellow('Aborted'));
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
clearConfig();
|
|
80
|
+
console.log(chalk.green('✓ Configuration cleared'));
|
|
81
|
+
});
|
|
82
|
+
// Show config path
|
|
83
|
+
configCommand
|
|
84
|
+
.command('path')
|
|
85
|
+
.description('Show the configuration file path')
|
|
86
|
+
.action(() => {
|
|
87
|
+
console.log(getConfigPath());
|
|
88
|
+
});
|
|
89
|
+
// Interactive setup
|
|
90
|
+
configCommand
|
|
91
|
+
.command('setup')
|
|
92
|
+
.description('Interactive configuration setup')
|
|
93
|
+
.action(async () => {
|
|
94
|
+
const { default: inquirer } = await import('inquirer');
|
|
95
|
+
const config = getConfig();
|
|
96
|
+
console.log(chalk.bold('StateSet Sandbox CLI Setup'));
|
|
97
|
+
console.log(chalk.gray('─'.repeat(40)));
|
|
98
|
+
console.log();
|
|
99
|
+
const answers = await inquirer.prompt([
|
|
100
|
+
{
|
|
101
|
+
type: 'password',
|
|
102
|
+
name: 'apiKey',
|
|
103
|
+
message: 'Enter your API key:',
|
|
104
|
+
default: config.apiKey,
|
|
105
|
+
validate: (input) => {
|
|
106
|
+
if (!input)
|
|
107
|
+
return 'API key is required';
|
|
108
|
+
return true;
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
type: 'input',
|
|
113
|
+
name: 'apiUrl',
|
|
114
|
+
message: 'API URL:',
|
|
115
|
+
default: config.apiUrl,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
type: 'number',
|
|
119
|
+
name: 'defaultTimeout',
|
|
120
|
+
message: 'Default sandbox timeout (seconds):',
|
|
121
|
+
default: config.defaultTimeout,
|
|
122
|
+
},
|
|
123
|
+
]);
|
|
124
|
+
setApiKey(answers.apiKey);
|
|
125
|
+
setApiUrl(answers.apiUrl);
|
|
126
|
+
setDefaultTimeout(answers.defaultTimeout);
|
|
127
|
+
console.log();
|
|
128
|
+
console.log(chalk.green('✓ Configuration saved'));
|
|
129
|
+
console.log();
|
|
130
|
+
console.log('You can now use the StateSet CLI. Try:');
|
|
131
|
+
console.log(chalk.cyan(' stateset sandbox create'));
|
|
132
|
+
console.log(chalk.cyan(' stateset sandbox list'));
|
|
133
|
+
});
|
|
134
|
+
//# sourceMappingURL=config.js.map
|