@spencer-kit/coder-studio 0.4.9 → 0.5.1
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/CHANGELOG.md +12 -0
- package/dist/esm/bin.mjs +29621 -16015
- package/dist/esm/bin.mjs.map +4 -4
- package/dist/esm/server-runner.mjs +27706 -14489
- package/dist/esm/server-runner.mjs.map +4 -4
- package/dist/web/assets/components-CBwEj8F3.css +1 -0
- package/dist/web/assets/components-CGHXUDfF.js +158 -0
- package/dist/web/assets/components-CGHXUDfF.js.map +1 -0
- package/dist/web/assets/main-Na2CPXZJ.js +2 -0
- package/dist/web/assets/main-Na2CPXZJ.js.map +1 -0
- package/dist/web/assets/ui-preview-DHlB71h3.js +23 -0
- package/dist/web/assets/ui-preview-DHlB71h3.js.map +1 -0
- package/dist/web/index.html +3 -3
- package/dist/web/ui-preview.html +3 -3
- package/package.json +1 -1
- package/src/automation-client.ts +36 -0
- package/src/automation-command-client.ts +142 -0
- package/src/bin.test.ts +194 -0
- package/src/cli.ts +121 -0
- package/src/parse-args.ts +221 -2
- package/dist/web/assets/components-6O5yG1fL.css +0 -1
- package/dist/web/assets/components-SjBXPKn9.js +0 -108
- package/dist/web/assets/components-SjBXPKn9.js.map +0 -1
- package/dist/web/assets/main-BjHz157g.js +0 -2
- package/dist/web/assets/main-BjHz157g.js.map +0 -1
- package/dist/web/assets/ui-preview-tdq8QPlu.js +0 -22
- package/dist/web/assets/ui-preview-tdq8QPlu.js.map +0 -1
package/src/parse-args.ts
CHANGED
|
@@ -7,8 +7,18 @@ type CliCommand =
|
|
|
7
7
|
| "logs"
|
|
8
8
|
| "help"
|
|
9
9
|
| "version"
|
|
10
|
-
| "auth"
|
|
10
|
+
| "auth"
|
|
11
|
+
| "identify"
|
|
12
|
+
| "capabilities"
|
|
13
|
+
| "workspace"
|
|
14
|
+
| "session"
|
|
15
|
+
| "terminal"
|
|
16
|
+
| "git";
|
|
11
17
|
type AuthCommand = "ban-list" | "unblock";
|
|
18
|
+
type WorkspaceCommand = "list";
|
|
19
|
+
type SessionCommand = "list";
|
|
20
|
+
type TerminalCommand = "read";
|
|
21
|
+
type GitCommand = "status" | "diff";
|
|
12
22
|
|
|
13
23
|
export const RUNTIME_CONFIG_ERROR =
|
|
14
24
|
"Host, port, state-dir, password, and auth settings must be configured via the config command";
|
|
@@ -20,6 +30,10 @@ export interface CliArgs {
|
|
|
20
30
|
tail?: number;
|
|
21
31
|
errorsOnly?: boolean;
|
|
22
32
|
authCommand?: AuthCommand;
|
|
33
|
+
workspaceCommand?: WorkspaceCommand;
|
|
34
|
+
sessionCommand?: SessionCommand;
|
|
35
|
+
terminalCommand?: TerminalCommand;
|
|
36
|
+
gitCommand?: GitCommand;
|
|
23
37
|
configHelp?: boolean;
|
|
24
38
|
port?: number;
|
|
25
39
|
host?: string;
|
|
@@ -27,6 +41,13 @@ export interface CliArgs {
|
|
|
27
41
|
password?: string;
|
|
28
42
|
noAuth?: boolean;
|
|
29
43
|
ip?: string;
|
|
44
|
+
json?: boolean;
|
|
45
|
+
workspaceId?: string;
|
|
46
|
+
terminalId?: string;
|
|
47
|
+
bytes?: number;
|
|
48
|
+
path?: string;
|
|
49
|
+
staged?: boolean;
|
|
50
|
+
apiUrl?: string;
|
|
30
51
|
}
|
|
31
52
|
|
|
32
53
|
function getActiveCommand(args: CliArgs): CliCommand {
|
|
@@ -47,6 +68,19 @@ function clearAuthArgs(args: CliArgs): void {
|
|
|
47
68
|
delete args.ip;
|
|
48
69
|
}
|
|
49
70
|
|
|
71
|
+
function clearAutomationArgs(args: CliArgs): void {
|
|
72
|
+
delete args.workspaceCommand;
|
|
73
|
+
delete args.sessionCommand;
|
|
74
|
+
delete args.terminalCommand;
|
|
75
|
+
delete args.gitCommand;
|
|
76
|
+
delete args.workspaceId;
|
|
77
|
+
delete args.terminalId;
|
|
78
|
+
delete args.bytes;
|
|
79
|
+
delete args.path;
|
|
80
|
+
delete args.staged;
|
|
81
|
+
delete args.apiUrl;
|
|
82
|
+
}
|
|
83
|
+
|
|
50
84
|
function clearLogsArgs(args: CliArgs): void {
|
|
51
85
|
delete args.tail;
|
|
52
86
|
delete args.errorsOnly;
|
|
@@ -65,6 +99,18 @@ function setCommand(args: CliArgs, command: CliCommand): void {
|
|
|
65
99
|
clearLogsArgs(args);
|
|
66
100
|
}
|
|
67
101
|
|
|
102
|
+
if (!["workspace", "session", "terminal", "git"].includes(command)) {
|
|
103
|
+
clearAutomationArgs(args);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (
|
|
107
|
+
command !== "identify" &&
|
|
108
|
+
command !== "capabilities" &&
|
|
109
|
+
!["workspace", "session", "terminal", "git"].includes(command)
|
|
110
|
+
) {
|
|
111
|
+
delete args.json;
|
|
112
|
+
}
|
|
113
|
+
|
|
68
114
|
if (command !== "serve") {
|
|
69
115
|
delete args.foreground;
|
|
70
116
|
}
|
|
@@ -122,10 +168,24 @@ export function parseArgs(argv: string[]): CliArgs {
|
|
|
122
168
|
case "open":
|
|
123
169
|
case "config":
|
|
124
170
|
case "stop":
|
|
125
|
-
case "status":
|
|
126
171
|
case "logs":
|
|
127
172
|
case "version":
|
|
128
173
|
case "auth":
|
|
174
|
+
case "identify":
|
|
175
|
+
case "capabilities":
|
|
176
|
+
case "workspace":
|
|
177
|
+
case "session":
|
|
178
|
+
case "terminal":
|
|
179
|
+
case "git":
|
|
180
|
+
setCommand(args, arg);
|
|
181
|
+
break;
|
|
182
|
+
|
|
183
|
+
case "status":
|
|
184
|
+
if (getActiveCommand(args) === "git") {
|
|
185
|
+
args.gitCommand = arg;
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
|
|
129
189
|
setCommand(args, arg);
|
|
130
190
|
break;
|
|
131
191
|
|
|
@@ -196,6 +256,94 @@ export function parseArgs(argv: string[]): CliArgs {
|
|
|
196
256
|
args.errorsOnly = true;
|
|
197
257
|
break;
|
|
198
258
|
|
|
259
|
+
case "--json": {
|
|
260
|
+
const command = getActiveCommand(args);
|
|
261
|
+
|
|
262
|
+
if (
|
|
263
|
+
command !== "identify" &&
|
|
264
|
+
command !== "capabilities" &&
|
|
265
|
+
!["workspace", "session", "terminal", "git"].includes(command)
|
|
266
|
+
) {
|
|
267
|
+
throwUnknownOption(arg);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
args.json = true;
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
case "--workspace":
|
|
275
|
+
case "--workspace-id": {
|
|
276
|
+
const command = getActiveCommand(args);
|
|
277
|
+
if (command !== "session" && command !== "git") {
|
|
278
|
+
throwUnknownOption(arg);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
args.workspaceId = readOptionValue(argv, i + 1, "workspace");
|
|
282
|
+
i += 1;
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
case "--terminal":
|
|
287
|
+
case "--terminal-id": {
|
|
288
|
+
if (getActiveCommand(args) !== "terminal") {
|
|
289
|
+
throwUnknownOption(arg);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
args.terminalId = readOptionValue(argv, i + 1, "terminal");
|
|
293
|
+
i += 1;
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
case "--bytes": {
|
|
298
|
+
if (getActiveCommand(args) !== "terminal") {
|
|
299
|
+
throwUnknownOption(arg);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const bytesValue = readOptionValue(argv, i + 1, "bytes");
|
|
303
|
+
if (!/^[1-9]\d*$/u.test(bytesValue)) {
|
|
304
|
+
throw new Error("Invalid bytes number");
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const bytes = Number(bytesValue);
|
|
308
|
+
if (!Number.isSafeInteger(bytes)) {
|
|
309
|
+
throw new Error("Invalid bytes number");
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
args.bytes = bytes;
|
|
313
|
+
i += 1;
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
case "--path": {
|
|
318
|
+
if (getActiveCommand(args) !== "git" || args.gitCommand !== "diff") {
|
|
319
|
+
throwUnknownOption(arg);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
args.path = readOptionValue(argv, i + 1, "path");
|
|
323
|
+
i += 1;
|
|
324
|
+
break;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
case "--staged": {
|
|
328
|
+
if (getActiveCommand(args) !== "git" || args.gitCommand !== "diff") {
|
|
329
|
+
throwUnknownOption(arg);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
args.staged = true;
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
case "--api-url": {
|
|
337
|
+
const command = getActiveCommand(args);
|
|
338
|
+
if (!["workspace", "session", "terminal", "git"].includes(command)) {
|
|
339
|
+
throwUnknownOption(arg);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
args.apiUrl = readOptionValue(argv, i + 1, "api-url");
|
|
343
|
+
i += 1;
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
|
|
199
347
|
case "--port":
|
|
200
348
|
case "-p": {
|
|
201
349
|
ensureConfigContext(args, arg);
|
|
@@ -247,6 +395,37 @@ export function parseArgs(argv: string[]): CliArgs {
|
|
|
247
395
|
args.authCommand = arg;
|
|
248
396
|
break;
|
|
249
397
|
|
|
398
|
+
case "list": {
|
|
399
|
+
const command = getActiveCommand(args);
|
|
400
|
+
if (command === "workspace") {
|
|
401
|
+
args.workspaceCommand = arg;
|
|
402
|
+
break;
|
|
403
|
+
}
|
|
404
|
+
if (command === "session") {
|
|
405
|
+
args.sessionCommand = arg;
|
|
406
|
+
break;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
throwUnknownArgument(arg);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
case "read":
|
|
413
|
+
if (getActiveCommand(args) !== "terminal") {
|
|
414
|
+
throwUnknownArgument(arg);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
args.terminalCommand = arg;
|
|
418
|
+
break;
|
|
419
|
+
|
|
420
|
+
case "status":
|
|
421
|
+
case "diff":
|
|
422
|
+
if (getActiveCommand(args) !== "git") {
|
|
423
|
+
throwUnknownArgument(arg);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
args.gitCommand = arg;
|
|
427
|
+
break;
|
|
428
|
+
|
|
250
429
|
case "--ip":
|
|
251
430
|
if (getActiveCommand(args) !== "auth" || args.authCommand !== "unblock") {
|
|
252
431
|
throwUnknownOption(arg);
|
|
@@ -279,5 +458,45 @@ export function parseArgs(argv: string[]): CliArgs {
|
|
|
279
458
|
}
|
|
280
459
|
}
|
|
281
460
|
|
|
461
|
+
if (args.command === "workspace") {
|
|
462
|
+
if (args.workspaceCommand === undefined) {
|
|
463
|
+
throw new Error("Missing workspace subcommand");
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
if (args.command === "session") {
|
|
468
|
+
if (args.sessionCommand === undefined) {
|
|
469
|
+
throw new Error("Missing session subcommand");
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
if (args.sessionCommand === "list" && args.workspaceId === undefined) {
|
|
473
|
+
throw new Error("Missing workspace value");
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
if (args.command === "terminal") {
|
|
478
|
+
if (args.terminalCommand === undefined) {
|
|
479
|
+
throw new Error("Missing terminal subcommand");
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
if (args.terminalCommand === "read" && args.terminalId === undefined) {
|
|
483
|
+
throw new Error("Missing terminal value");
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
if (args.command === "git") {
|
|
488
|
+
if (args.gitCommand === undefined) {
|
|
489
|
+
throw new Error("Missing git subcommand");
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
if (args.workspaceId === undefined) {
|
|
493
|
+
throw new Error("Missing workspace value");
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
if (args.gitCommand === "diff" && args.path === undefined) {
|
|
497
|
+
throw new Error("Missing path value");
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
282
501
|
return args;
|
|
283
502
|
}
|