@bctrl/cli 0.1.2 → 0.1.3
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/README.md +0 -2
- package/dist/bin/bctrl.js +0 -0
- package/dist/commands/runtime/index.js +9 -56
- package/dist/factory.js +1 -1
- package/dist/generated/help.d.ts +2 -73
- package/dist/generated/help.js +2 -106
- package/package.json +10 -12
package/README.md
CHANGED
|
@@ -38,7 +38,6 @@ bctrl auth status
|
|
|
38
38
|
bctrl space list
|
|
39
39
|
bctrl runtime create --space sp_123 --name checkout-test
|
|
40
40
|
bctrl runtime start rt_123
|
|
41
|
-
bctrl runtime connection create rt_123
|
|
42
41
|
bctrl runtime stop rt_123
|
|
43
42
|
```
|
|
44
43
|
|
|
@@ -93,5 +92,4 @@ Use command help for exact input and output fields:
|
|
|
93
92
|
```bash
|
|
94
93
|
bctrl runtime create --help
|
|
95
94
|
bctrl runtime start --help
|
|
96
|
-
bctrl runtime connection create --help
|
|
97
95
|
```
|
package/dist/bin/bctrl.js
CHANGED
|
File without changes
|
|
@@ -4,7 +4,7 @@ import { addCliHelp } from '../shared/help.js';
|
|
|
4
4
|
import { readBlob, readJsonFile, writeBinary } from '../shared/io.js';
|
|
5
5
|
import { parsePositiveInteger } from '../shared/options.js';
|
|
6
6
|
import { addOutputFlags, outputData } from '../shared/output.js';
|
|
7
|
-
import { addPaginationFlags, createJsonBodyCommand, createListCommand, createViewCommand,
|
|
7
|
+
import { addPaginationFlags, createJsonBodyCommand, createListCommand, createViewCommand, requestAndPrint, } from '../shared/rest.js';
|
|
8
8
|
export function createRuntimeCommand(factory) {
|
|
9
9
|
const command = new Command('runtime').description('Create, start, stop, and manage BCTRL runtimes');
|
|
10
10
|
command.addCommand(createListCommand(factory, {
|
|
@@ -45,37 +45,31 @@ export function createRuntimeCommand(factory) {
|
|
|
45
45
|
type: 'browser',
|
|
46
46
|
spaceId: options.space,
|
|
47
47
|
name: options.name,
|
|
48
|
-
config: typeof options.configFile === 'string'
|
|
48
|
+
config: typeof options.configFile === 'string'
|
|
49
|
+
? await readJsonFile(options.configFile, '--config-file')
|
|
50
|
+
: undefined,
|
|
49
51
|
metadata: typeof options.metadataFile === 'string'
|
|
50
52
|
? await readJsonFile(options.metadataFile, '--metadata-file')
|
|
51
53
|
: undefined,
|
|
52
54
|
};
|
|
53
55
|
},
|
|
54
56
|
}), 'runtime.create'));
|
|
55
|
-
command.addCommand(addCliHelp(addOutputFlags(new Command('start')
|
|
56
|
-
.description('Start a runtime')
|
|
57
|
-
.argument('<id>'))
|
|
58
|
-
.action(async (id, options) => {
|
|
57
|
+
command.addCommand(addCliHelp(addOutputFlags(new Command('start').description('Start a runtime').argument('<id>')).action(async (id, options) => {
|
|
59
58
|
await requestAndPrint(factory, 'post', `/runtimes/${encodeURIComponent(id)}/start`, {
|
|
60
59
|
output: options,
|
|
61
60
|
});
|
|
62
61
|
}), 'runtime.start'));
|
|
63
|
-
command.addCommand(addOutputFlags(new Command('stop')
|
|
64
|
-
.description('Stop a runtime')
|
|
65
|
-
.argument('<id>'))
|
|
66
|
-
.action(async (id, options) => {
|
|
62
|
+
command.addCommand(addOutputFlags(new Command('stop').description('Stop a runtime').argument('<id>')).action(async (id, options) => {
|
|
67
63
|
await requestAndPrint(factory, 'post', `/runtimes/${encodeURIComponent(id)}/stop`, {
|
|
68
64
|
output: options,
|
|
69
65
|
});
|
|
70
66
|
}));
|
|
71
|
-
command.addCommand(createRuntimeConnectionCommand(factory));
|
|
72
67
|
command.addCommand(createRuntimeFileCommand(factory));
|
|
73
68
|
command.addCommand(addOutputFlags(new Command('runs')
|
|
74
69
|
.description('List runs for a runtime')
|
|
75
70
|
.argument('<id>')
|
|
76
71
|
.option('-L, --limit <number>', 'Maximum number of results to return', parsePositiveInteger)
|
|
77
|
-
.option('--cursor <cursor>', 'Pagination cursor'))
|
|
78
|
-
.action(async (id, options) => {
|
|
72
|
+
.option('--cursor <cursor>', 'Pagination cursor')).action(async (id, options) => {
|
|
79
73
|
await requestAndPrint(factory, 'get', `/runtimes/${encodeURIComponent(id)}/runs`, {
|
|
80
74
|
query: { limit: options.limit, cursor: options.cursor },
|
|
81
75
|
output: options,
|
|
@@ -83,45 +77,6 @@ export function createRuntimeCommand(factory) {
|
|
|
83
77
|
}));
|
|
84
78
|
return command;
|
|
85
79
|
}
|
|
86
|
-
function createRuntimeConnectionCommand(factory) {
|
|
87
|
-
const command = new Command('connection').description('Manage runtime connections');
|
|
88
|
-
command.addCommand(addOutputFlags(new Command('list')
|
|
89
|
-
.description('List runtime connections')
|
|
90
|
-
.argument('<runtime>')
|
|
91
|
-
.option('--status <status>', 'Filter by connection status')
|
|
92
|
-
.option('-L, --limit <number>', 'Maximum number of results to return', parsePositiveInteger))
|
|
93
|
-
.action(async (runtime, options) => {
|
|
94
|
-
await requestAndPrint(factory, 'get', `/runtimes/${encodeURIComponent(runtime)}/connections`, {
|
|
95
|
-
query: { status: options.status, limit: options.limit },
|
|
96
|
-
output: options,
|
|
97
|
-
});
|
|
98
|
-
}));
|
|
99
|
-
command.addCommand(addCliHelp(createJsonBodyCommand(factory, {
|
|
100
|
-
name: 'create',
|
|
101
|
-
description: 'Create a runtime connection',
|
|
102
|
-
method: 'post',
|
|
103
|
-
path: '/runtimes/{runtime}/connections',
|
|
104
|
-
argNames: ['runtime'],
|
|
105
|
-
configure: (cmd) => cmd
|
|
106
|
-
.option('--protocol <protocol>', 'Connection protocol', 'cdp')
|
|
107
|
-
.option('--input <path>', 'Read JSON request body from file, or - for stdin'),
|
|
108
|
-
body: async (_args, options) => {
|
|
109
|
-
if (typeof options.input === 'string')
|
|
110
|
-
return readJsonFile(options.input);
|
|
111
|
-
return {
|
|
112
|
-
protocol: options.protocol,
|
|
113
|
-
};
|
|
114
|
-
},
|
|
115
|
-
}), 'runtime.connection.create'));
|
|
116
|
-
command.addCommand(addOutputFlags(new Command('delete')
|
|
117
|
-
.description('Revoke a runtime connection')
|
|
118
|
-
.argument('<runtime>')
|
|
119
|
-
.argument('<connection>'))
|
|
120
|
-
.action(async (runtime, connection, options) => {
|
|
121
|
-
await requestAndPrint(factory, 'delete', pathTemplate('/runtimes/{runtime}/connections/{connection}', { runtime, connection }), { output: options });
|
|
122
|
-
}));
|
|
123
|
-
return command;
|
|
124
|
-
}
|
|
125
80
|
function createRuntimeFileCommand(factory) {
|
|
126
81
|
const command = new Command('file').description('Move files into and out of runtimes');
|
|
127
82
|
command.addCommand(addOutputFlags(new Command('push')
|
|
@@ -130,8 +85,7 @@ function createRuntimeFileCommand(factory) {
|
|
|
130
85
|
.argument('<local-path>')
|
|
131
86
|
.option('--storage-path <path>', 'Advanced: durable BCTRL storage path')
|
|
132
87
|
.option('--name <name>', 'Display name')
|
|
133
|
-
.option('--metadata-file <path>', 'Metadata JSON file'))
|
|
134
|
-
.action(async (runtime, localPath, options) => {
|
|
88
|
+
.option('--metadata-file <path>', 'Metadata JSON file')).action(async (runtime, localPath, options) => {
|
|
135
89
|
const client = await factory.apiClient();
|
|
136
90
|
const file = await readBlob(localPath);
|
|
137
91
|
const metadata = typeof options.metadataFile === 'string'
|
|
@@ -154,8 +108,7 @@ function createRuntimeFileCommand(factory) {
|
|
|
154
108
|
.argument('<runtime-path>')
|
|
155
109
|
.requiredOption('--to <path>', 'Output path, or - for stdout')
|
|
156
110
|
.option('--name <name>', 'Durable file name')
|
|
157
|
-
.option('--storage-path <path>', 'Advanced: durable BCTRL storage path'))
|
|
158
|
-
.action(async (runtime, runtimePath, options) => {
|
|
111
|
+
.option('--storage-path <path>', 'Advanced: durable BCTRL storage path')).action(async (runtime, runtimePath, options) => {
|
|
159
112
|
const client = await factory.apiClient();
|
|
160
113
|
const collected = await client.post(`/runtimes/${encodeURIComponent(runtime)}/files/collect`, {
|
|
161
114
|
body: {
|
package/dist/factory.js
CHANGED
package/dist/generated/help.d.ts
CHANGED
|
@@ -117,85 +117,14 @@ export declare const CLI_HELP_COMMANDS: {
|
|
|
117
117
|
readonly name: "run";
|
|
118
118
|
readonly type: "object";
|
|
119
119
|
readonly required: true;
|
|
120
|
-
}];
|
|
121
|
-
};
|
|
122
|
-
readonly examples: readonly [{
|
|
123
|
-
readonly command: "bctrl runtime start rt_123";
|
|
124
|
-
}];
|
|
125
|
-
readonly next: readonly [{
|
|
126
|
-
readonly command: "bctrl runtime connection create <runtimeId>";
|
|
127
|
-
}];
|
|
128
|
-
};
|
|
129
|
-
readonly "runtime.connection.create": {
|
|
130
|
-
readonly kind: "command";
|
|
131
|
-
readonly command: "runtime.connection.create";
|
|
132
|
-
readonly summary: "Create a short-lived CDP connection lease for a started runtime.";
|
|
133
|
-
readonly usage: "bctrl runtime connection create <runtimeId> [flags]";
|
|
134
|
-
readonly flags: readonly [{
|
|
135
|
-
readonly name: "--protocol";
|
|
136
|
-
readonly value: "<protocol>";
|
|
137
|
-
readonly description: "Connection protocol. Defaults to cdp.";
|
|
138
|
-
readonly mapsTo: "input.protocol";
|
|
139
|
-
}, {
|
|
140
|
-
readonly name: "--input";
|
|
141
|
-
readonly value: "<path>";
|
|
142
|
-
readonly description: "Read the full JSON request body from a file, or - for stdin.";
|
|
143
|
-
}];
|
|
144
|
-
readonly input: {
|
|
145
|
-
readonly fields: readonly [{
|
|
146
|
-
readonly name: "protocol";
|
|
147
|
-
readonly type: "\"cdp\"";
|
|
148
|
-
readonly values: readonly ["\"cdp\""];
|
|
149
|
-
readonly required: true;
|
|
150
|
-
}, {
|
|
151
|
-
readonly name: "options";
|
|
152
|
-
readonly type: "object";
|
|
153
|
-
readonly required: false;
|
|
154
|
-
}];
|
|
155
|
-
};
|
|
156
|
-
readonly output: {
|
|
157
|
-
readonly fields: readonly [{
|
|
158
|
-
readonly name: "id";
|
|
159
|
-
readonly type: "uuid";
|
|
160
|
-
readonly required: true;
|
|
161
|
-
}, {
|
|
162
|
-
readonly name: "protocol";
|
|
163
|
-
readonly type: "\"cdp\" | \"cua\" | \"rdp\" | \"vnc\" | \"mcp\" | \"http\"";
|
|
164
|
-
readonly values: readonly ["\"cdp\"", "\"cua\"", "\"rdp\"", "\"vnc\"", "\"mcp\"", "\"http\""];
|
|
165
|
-
readonly required: true;
|
|
166
|
-
}, {
|
|
167
|
-
readonly name: "status";
|
|
168
|
-
readonly type: "\"active\" | \"expired\" | \"revoked\" | \"closed\"";
|
|
169
|
-
readonly values: readonly ["\"active\"", "\"expired\"", "\"revoked\"", "\"closed\""];
|
|
170
|
-
readonly required: true;
|
|
171
120
|
}, {
|
|
172
|
-
readonly name: "
|
|
173
|
-
readonly type: "uuid";
|
|
174
|
-
readonly required: true;
|
|
175
|
-
}, {
|
|
176
|
-
readonly name: "createdAt";
|
|
177
|
-
readonly type: "datetime";
|
|
178
|
-
readonly required: true;
|
|
179
|
-
}, {
|
|
180
|
-
readonly name: "expiresAt";
|
|
181
|
-
readonly type: "datetime | null";
|
|
182
|
-
readonly required: true;
|
|
183
|
-
}, {
|
|
184
|
-
readonly name: "closedAt";
|
|
185
|
-
readonly type: "datetime | null";
|
|
186
|
-
readonly required: false;
|
|
187
|
-
}, {
|
|
188
|
-
readonly name: "revokedAt";
|
|
189
|
-
readonly type: "datetime | null";
|
|
190
|
-
readonly required: false;
|
|
191
|
-
}, {
|
|
192
|
-
readonly name: "endpoint";
|
|
121
|
+
readonly name: "browser";
|
|
193
122
|
readonly type: "object";
|
|
194
123
|
readonly required: true;
|
|
195
124
|
}];
|
|
196
125
|
};
|
|
197
126
|
readonly examples: readonly [{
|
|
198
|
-
readonly command: "bctrl runtime
|
|
127
|
+
readonly command: "bctrl runtime start rt_123";
|
|
199
128
|
}];
|
|
200
129
|
readonly next: readonly [{
|
|
201
130
|
readonly command: "bctrl run events <runId>";
|
package/dist/generated/help.js
CHANGED
|
@@ -157,113 +157,9 @@ export const CLI_HELP_COMMANDS = {
|
|
|
157
157
|
"name": "run",
|
|
158
158
|
"type": "object",
|
|
159
159
|
"required": true
|
|
160
|
-
}
|
|
161
|
-
]
|
|
162
|
-
},
|
|
163
|
-
"examples": [
|
|
164
|
-
{
|
|
165
|
-
"command": "bctrl runtime start rt_123"
|
|
166
|
-
}
|
|
167
|
-
],
|
|
168
|
-
"next": [
|
|
169
|
-
{
|
|
170
|
-
"command": "bctrl runtime connection create <runtimeId>"
|
|
171
|
-
}
|
|
172
|
-
]
|
|
173
|
-
},
|
|
174
|
-
"runtime.connection.create": {
|
|
175
|
-
"kind": "command",
|
|
176
|
-
"command": "runtime.connection.create",
|
|
177
|
-
"summary": "Create a short-lived CDP connection lease for a started runtime.",
|
|
178
|
-
"usage": "bctrl runtime connection create <runtimeId> [flags]",
|
|
179
|
-
"flags": [
|
|
180
|
-
{
|
|
181
|
-
"name": "--protocol",
|
|
182
|
-
"value": "<protocol>",
|
|
183
|
-
"description": "Connection protocol. Defaults to cdp.",
|
|
184
|
-
"mapsTo": "input.protocol"
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
"name": "--input",
|
|
188
|
-
"value": "<path>",
|
|
189
|
-
"description": "Read the full JSON request body from a file, or - for stdin."
|
|
190
|
-
}
|
|
191
|
-
],
|
|
192
|
-
"input": {
|
|
193
|
-
"fields": [
|
|
194
|
-
{
|
|
195
|
-
"name": "protocol",
|
|
196
|
-
"type": "\"cdp\"",
|
|
197
|
-
"values": [
|
|
198
|
-
"\"cdp\""
|
|
199
|
-
],
|
|
200
|
-
"required": true
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
"name": "options",
|
|
204
|
-
"type": "object",
|
|
205
|
-
"required": false
|
|
206
|
-
}
|
|
207
|
-
]
|
|
208
|
-
},
|
|
209
|
-
"output": {
|
|
210
|
-
"fields": [
|
|
211
|
-
{
|
|
212
|
-
"name": "id",
|
|
213
|
-
"type": "uuid",
|
|
214
|
-
"required": true
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
"name": "protocol",
|
|
218
|
-
"type": "\"cdp\" | \"cua\" | \"rdp\" | \"vnc\" | \"mcp\" | \"http\"",
|
|
219
|
-
"values": [
|
|
220
|
-
"\"cdp\"",
|
|
221
|
-
"\"cua\"",
|
|
222
|
-
"\"rdp\"",
|
|
223
|
-
"\"vnc\"",
|
|
224
|
-
"\"mcp\"",
|
|
225
|
-
"\"http\""
|
|
226
|
-
],
|
|
227
|
-
"required": true
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
"name": "status",
|
|
231
|
-
"type": "\"active\" | \"expired\" | \"revoked\" | \"closed\"",
|
|
232
|
-
"values": [
|
|
233
|
-
"\"active\"",
|
|
234
|
-
"\"expired\"",
|
|
235
|
-
"\"revoked\"",
|
|
236
|
-
"\"closed\""
|
|
237
|
-
],
|
|
238
|
-
"required": true
|
|
239
160
|
},
|
|
240
161
|
{
|
|
241
|
-
"name": "
|
|
242
|
-
"type": "uuid",
|
|
243
|
-
"required": true
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
"name": "createdAt",
|
|
247
|
-
"type": "datetime",
|
|
248
|
-
"required": true
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
"name": "expiresAt",
|
|
252
|
-
"type": "datetime | null",
|
|
253
|
-
"required": true
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
"name": "closedAt",
|
|
257
|
-
"type": "datetime | null",
|
|
258
|
-
"required": false
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
"name": "revokedAt",
|
|
262
|
-
"type": "datetime | null",
|
|
263
|
-
"required": false
|
|
264
|
-
},
|
|
265
|
-
{
|
|
266
|
-
"name": "endpoint",
|
|
162
|
+
"name": "browser",
|
|
267
163
|
"type": "object",
|
|
268
164
|
"required": true
|
|
269
165
|
}
|
|
@@ -271,7 +167,7 @@ export const CLI_HELP_COMMANDS = {
|
|
|
271
167
|
},
|
|
272
168
|
"examples": [
|
|
273
169
|
{
|
|
274
|
-
"command": "bctrl runtime
|
|
170
|
+
"command": "bctrl runtime start rt_123"
|
|
275
171
|
}
|
|
276
172
|
],
|
|
277
173
|
"next": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bctrl/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "BCTRL command-line interface",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -15,15 +15,6 @@
|
|
|
15
15
|
"files": [
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
|
-
"scripts": {
|
|
19
|
-
"clean": "rm -rf dist",
|
|
20
|
-
"build": "pnpm run clean && tsc -p tsconfig.json",
|
|
21
|
-
"dev": "tsx src/bin/bctrl.ts",
|
|
22
|
-
"prepack": "pnpm run build",
|
|
23
|
-
"test": "tsx --test \"tests/**/*.test.ts\"",
|
|
24
|
-
"typecheck": "tsc --noEmit",
|
|
25
|
-
"typecheck:tests": "tsc --noEmit -p tests/tsconfig.json"
|
|
26
|
-
},
|
|
27
18
|
"keywords": [
|
|
28
19
|
"bctrl",
|
|
29
20
|
"cli",
|
|
@@ -32,7 +23,6 @@
|
|
|
32
23
|
],
|
|
33
24
|
"author": "",
|
|
34
25
|
"license": "ISC",
|
|
35
|
-
"packageManager": "pnpm@10.12.4",
|
|
36
26
|
"dependencies": {
|
|
37
27
|
"commander": "^14.0.3",
|
|
38
28
|
"handlebars": "^4.7.9",
|
|
@@ -43,5 +33,13 @@
|
|
|
43
33
|
"@types/node": "^25.7.0",
|
|
44
34
|
"tsx": "^4.21.0",
|
|
45
35
|
"typescript": "^6.0.3"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"clean": "rm -rf dist",
|
|
39
|
+
"build": "pnpm run clean && tsc -p tsconfig.json",
|
|
40
|
+
"dev": "tsx src/bin/bctrl.ts",
|
|
41
|
+
"test": "tsx --test \"tests/**/*.test.ts\"",
|
|
42
|
+
"typecheck": "tsc --noEmit",
|
|
43
|
+
"typecheck:tests": "tsc --noEmit -p tests/tsconfig.json"
|
|
46
44
|
}
|
|
47
|
-
}
|
|
45
|
+
}
|