bdy 1.25.5-stage → 1.25.7-dev

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.
Files changed (42) hide show
  1. package/distTs/package.json +1 -1
  2. package/distTs/src/api/client.js +1 -1
  3. package/distTs/src/cliCommand.js +47 -4
  4. package/distTs/src/cliError.js +10 -0
  5. package/distTs/src/cliIndex.js +10 -0
  6. package/distTs/src/command/context/add.js +38 -0
  7. package/distTs/src/command/context/list.js +33 -0
  8. package/distTs/src/command/context/remove.js +36 -0
  9. package/distTs/src/command/context/show.js +35 -0
  10. package/distTs/src/command/context/use.js +25 -0
  11. package/distTs/src/command/context.js +22 -0
  12. package/distTs/src/command/login.js +1 -0
  13. package/distTs/src/command/logout.js +1 -0
  14. package/distTs/src/command/pipeline/run/approve.js +8 -15
  15. package/distTs/src/command/pipeline/run/cancel.js +7 -15
  16. package/distTs/src/command/pipeline/run/execution.js +20 -0
  17. package/distTs/src/command/pipeline/run/logs.js +6 -14
  18. package/distTs/src/command/pipeline/run/retry.js +7 -15
  19. package/distTs/src/command/pipeline/run/start.js +8 -15
  20. package/distTs/src/command/pipeline/run/status.js +6 -14
  21. package/distTs/src/command/project/link.js +1 -0
  22. package/distTs/src/command/register.js +1 -0
  23. package/distTs/src/command/sandbox/exec/command.js +7 -2
  24. package/distTs/src/command/sandbox/exec/logs.js +3 -2
  25. package/distTs/src/command/sandbox/exec/status.js +6 -2
  26. package/distTs/src/command/sandbox/finishExec.js +19 -2
  27. package/distTs/src/command/target/exec/command.js +25 -10
  28. package/distTs/src/command/target/exec/logs.js +14 -8
  29. package/distTs/src/command/target/exec/status.js +6 -2
  30. package/distTs/src/command/target/scope.js +3 -2
  31. package/distTs/src/command/whoami.js +7 -10
  32. package/distTs/src/command/workspace/get.js +2 -2
  33. package/distTs/src/command/workspace/set.js +1 -0
  34. package/distTs/src/input.js +205 -27
  35. package/distTs/src/output/pipeline.js +108 -28
  36. package/distTs/src/output.js +46 -8
  37. package/distTs/src/project/context.js +97 -0
  38. package/distTs/src/texts.js +257 -22
  39. package/distTs/src/tunnel/cfg.js +43 -4
  40. package/distTs/src/types/context.js +2 -0
  41. package/distTs/src/utils.js +15 -0
  42. package/package.json +1 -1
@@ -6,17 +6,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const utils_1 = require("../../../utils");
7
7
  const texts_1 = require("../../../texts");
8
8
  const input_1 = __importDefault(require("../../../input"));
9
- const output_1 = __importDefault(require("../../../output"));
9
+ const execution_1 = require("./execution");
10
10
  const commandPipelineRunStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_PIPELINE_RUN_STATUS, {
11
11
  requiredScopes: [utils_1.REST_API_SCOPE.PIPELINE_READ],
12
12
  examples: texts_1.EXAMPLE_PIPELINE_RUN_STATUS,
13
- helpText: texts_1.HELP_PIPELINE_RUN_JSONL,
13
+ helpText: texts_1.HELP_PIPELINE_RUN_STATUS,
14
14
  });
15
15
  commandPipelineRunStatus.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
16
  commandPipelineRunStatus.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
17
  commandPipelineRunStatus.option('-n, --no-wait', texts_1.OPTION_PIPELINE_RUN_NO_WAIT);
18
18
  commandPipelineRunStatus.option('--no-follow', texts_1.OPTION_PIPELINE_RUN_NO_FOLLOW);
19
- commandPipelineRunStatus.option('--format <text|jsonl>', texts_1.OPTION_FORMAT_JSONL);
19
+ commandPipelineRunStatus.option('--exit-code', texts_1.OPTION_EXEC_EXIT_CODE);
20
+ commandPipelineRunStatus.option('--format <text|jsonl>', texts_1.OPTION_EXEC_FORMAT_JSONL);
20
21
  commandPipelineRunStatus.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
21
22
  commandPipelineRunStatus.argument('<run-id>', texts_1.OPTION_PIPELINE_RUN_ID);
22
23
  commandPipelineRunStatus.action(async (identifier, runId, options) => {
@@ -24,17 +25,8 @@ commandPipelineRunStatus.action(async (identifier, runId, options) => {
24
25
  const project = input_1.default.restApiProject(options.project);
25
26
  const client = input_1.default.restApiTokenClient();
26
27
  const rid = input_1.default.pipelineRunId(runId);
27
- const data = await client.getPipelineByIdentifier(workspace, project, identifier);
28
- if (!data || !data.domain) {
29
- output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
30
- }
31
- if (!data.project_identifier) {
32
- output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
33
- }
34
- if (!data.pipeline_id) {
35
- output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
36
- }
28
+ const pipelineId = await (0, execution_1.resolvePipelineId)(client, workspace, project, identifier);
37
29
  const OutputPipeline = require('../../../output/pipeline').default;
38
- await OutputPipeline.runStatus(client, workspace, project, identifier, data.pipeline_id, rid, !options.wait, !options.follow, options.format === 'jsonl');
30
+ await OutputPipeline.runStatus(client, workspace, project, identifier, pipelineId, rid, !options.wait, !options.follow, options.format === 'jsonl', !!options.exitCode);
39
31
  });
40
32
  exports.default = commandPipelineRunStatus;
@@ -10,6 +10,7 @@ const output_1 = __importDefault(require("../../output"));
10
10
  const node_path_1 = require("node:path");
11
11
  const node_fs_1 = __importDefault(require("node:fs"));
12
12
  const commandProjectLink = (0, utils_1.newCommand)('link', texts_1.DESC_COMMAND_PROJECT_LINK);
13
+ commandProjectLink.usesDefaultContext = true;
13
14
  commandProjectLink.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
14
15
  commandProjectLink.option('-r, --relink', texts_1.OPT_COMMAND_PROJECT_LINK_RELINK);
15
16
  commandProjectLink.option('-g, --git', texts_1.OPT_COMMAND_PROJECT_LINK_GIT);
@@ -8,6 +8,7 @@ const texts_1 = require("../texts");
8
8
  const output_1 = __importDefault(require("../output"));
9
9
  const login_1 = require("./login");
10
10
  const commandRegister = (0, utils_1.newCommand)('register', texts_1.DESC_COMMAND_REGISTER);
11
+ commandRegister.usesDefaultContext = true;
11
12
  commandRegister.alias('sign-up');
12
13
  commandRegister.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
13
14
  commandRegister.option('--region <region>', texts_1.OPTION_REST_API_REGION);
@@ -18,7 +18,8 @@ commandSandboxExecCommand.option('--runtime <runtime>', texts_1.OPTION_SANDBOX_R
18
18
  commandSandboxExecCommand.option('--wait', texts_1.OPTION_SANDBOX_WAIT);
19
19
  commandSandboxExecCommand.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
20
20
  commandSandboxExecCommand.argument('<command>');
21
- commandSandboxExecCommand.option('--format <text|jsonl>', texts_1.OPTION_FORMAT_JSONL);
21
+ commandSandboxExecCommand.option('--format <text|jsonl>', texts_1.OPTION_EXEC_FORMAT_JSONL);
22
+ commandSandboxExecCommand.option('--exit-code', texts_1.OPTION_EXEC_EXIT_CODE);
22
23
  commandSandboxExecCommand.action(async (identifier, command, options) => {
23
24
  output_1.default.handleSignals();
24
25
  const workspace = input_1.default.restApiWorkspace(options.workspace);
@@ -35,13 +36,17 @@ commandSandboxExecCommand.action(async (identifier, command, options) => {
35
36
  else {
36
37
  output_1.default.gray((0, texts_1.TXT_SANDBOX_EXEC_ID)(cmdResult.id));
37
38
  }
39
+ if (options.exitCode)
40
+ (0, utils_1.executionExitCode)(cmdResult.status);
38
41
  if (!options.wait) {
42
+ if (options.exitCode)
43
+ (0, finishExec_1.finishSandboxCommand)(cmdResult, identifier, cmdResult.id, options.format === 'jsonl', true, true);
39
44
  if (options.format === 'jsonl')
40
45
  output_1.default.exitNormal();
41
46
  output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_EXEC_BACKGROUND)(identifier, cmdResult.id));
42
47
  }
43
48
  else {
44
- await (0, finishExec_1.finishExec)(client, workspace, sandboxId, identifier, cmdResult.id, true, options.format === 'jsonl');
49
+ await (0, finishExec_1.finishExec)(client, workspace, sandboxId, identifier, cmdResult.id, true, options.format === 'jsonl', !!options.exitCode);
45
50
  }
46
51
  });
47
52
  exports.default = commandSandboxExecCommand;
@@ -13,12 +13,13 @@ const commandSandboxExecLogs = (0, utils_1.newCommand)('logs', texts_1.DESC_COMM
13
13
  commandSandboxExecLogs.option('--wait', texts_1.OPTION_SANDBOX_WAIT);
14
14
  commandSandboxExecLogs.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
15
15
  commandSandboxExecLogs.argument('<command-id>', texts_1.OPTION_SANDBOX_COMMAND_ID);
16
- commandSandboxExecLogs.option('--format <text|jsonl>', texts_1.OPTION_FORMAT_JSONL);
16
+ commandSandboxExecLogs.option('--format <text|jsonl>', texts_1.OPTION_EXEC_FORMAT_JSONL);
17
+ commandSandboxExecLogs.option('--exit-code', texts_1.OPTION_EXEC_EXIT_CODE);
17
18
  commandSandboxExecLogs.action(async (identifier, commandId, options) => {
18
19
  output_1.default.handleSignals();
19
20
  const workspace = input_1.default.restApiWorkspace(options.workspace);
20
21
  const client = input_1.default.restApiTokenClient();
21
22
  const sandboxId = await input_1.default.sandboxId(client, workspace, options, identifier);
22
- await (0, finishExec_1.finishExec)(client, workspace, sandboxId, identifier, commandId, !!options.wait, options.format === 'jsonl');
23
+ await (0, finishExec_1.finishExec)(client, workspace, sandboxId, identifier, commandId, !!options.wait, options.format === 'jsonl', !!options.exitCode);
23
24
  });
24
25
  exports.default = commandSandboxExecLogs;
@@ -7,16 +7,18 @@ const utils_1 = require("../../../utils");
7
7
  const texts_1 = require("../../../texts");
8
8
  const input_1 = __importDefault(require("../../../input"));
9
9
  const output_1 = __importDefault(require("../../../output"));
10
- const commandSandboxExecStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_SANDBOX_EXEC_STATUS, { examples: texts_1.EXAMPLE_SANDBOX_EXEC_STATUS });
10
+ const commandSandboxExecStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_SANDBOX_EXEC_STATUS, { examples: texts_1.EXAMPLE_SANDBOX_EXEC_STATUS, helpText: texts_1.HELP_SANDBOX_EXEC_STATUS });
11
11
  (0, utils_1.sandboxScopeOptions)(commandSandboxExecStatus);
12
- commandSandboxExecStatus.option('--format <text|json>', texts_1.OPTION_FORMAT);
12
+ commandSandboxExecStatus.option('--format <text|json>', texts_1.OPTION_EXEC_FORMAT_JSON);
13
13
  commandSandboxExecStatus.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
14
14
  commandSandboxExecStatus.argument('<command-id>', texts_1.OPTION_SANDBOX_COMMAND_ID);
15
+ commandSandboxExecStatus.option('--exit-code', texts_1.OPTION_EXEC_EXIT_CODE);
15
16
  commandSandboxExecStatus.action(async (identifier, commandId, options) => {
16
17
  const workspace = input_1.default.restApiWorkspace(options.workspace);
17
18
  const client = input_1.default.restApiTokenClient();
18
19
  const sandboxId = await input_1.default.sandboxId(client, workspace, options, identifier);
19
20
  const cmd = await client.getSandboxCommand(workspace, sandboxId, commandId);
21
+ const code = options.exitCode ? (0, utils_1.executionExitCode)(cmd.status) : undefined;
20
22
  if (options.format === 'json') {
21
23
  output_1.default.json(cmd);
22
24
  }
@@ -34,6 +36,8 @@ commandSandboxExecStatus.action(async (identifier, commandId, options) => {
34
36
  ];
35
37
  output_1.default.table(data);
36
38
  }
39
+ if (code !== undefined)
40
+ output_1.default.exitCode(code);
37
41
  output_1.default.exitNormal();
38
42
  });
39
43
  exports.default = commandSandboxExecStatus;
@@ -4,31 +4,48 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.finishExec = finishExec;
7
+ exports.finishSandboxCommand = finishSandboxCommand;
7
8
  const output_1 = __importDefault(require("../../output"));
8
9
  const utils_1 = require("../../utils");
9
10
  const texts_1 = require("../../texts");
10
- async function finishExec(client, workspace, sandboxId, identifier, commandId, follow, jsonl) {
11
+ async function finishExec(client, workspace, sandboxId, identifier, commandId, follow, jsonl, semanticExitCode = false) {
11
12
  const body = await client.streamSandboxCommandLogs(workspace, sandboxId, commandId, follow);
12
13
  await output_1.default.streamCommandLogs(body, jsonl);
13
14
  const cmdExit = await client.getSandboxCommand(workspace, sandboxId, commandId);
15
+ finishSandboxCommand(cmdExit, identifier, commandId, jsonl, semanticExitCode);
16
+ }
17
+ /** Shared final record and process status, including commands started without --wait. */
18
+ function finishSandboxCommand(cmdExit, identifier, commandId, jsonl, semanticExitCode, background = false) {
19
+ const code = semanticExitCode ? (0, utils_1.executionExitCode)(cmdExit.status) : undefined;
14
20
  if (jsonl) {
15
21
  output_1.default.json({
16
22
  type: 'exit',
17
23
  status: cmdExit.status,
18
24
  exit_code: cmdExit.exit_code ?? null,
25
+ ...(semanticExitCode ? { code } : {}),
19
26
  });
27
+ if (code !== undefined)
28
+ output_1.default.exitCode(code);
20
29
  if ([utils_1.SANDBOX_EXEC_STATUS.SUCCESSFUL, utils_1.SANDBOX_EXEC_STATUS.INPROGRESS].includes(cmdExit.status)) {
21
30
  output_1.default.exitNormal();
22
31
  }
23
32
  output_1.default.exitCode(1);
24
33
  }
34
+ if (background) {
35
+ output_1.default.normal(output_1.default.getGreenColor((0, texts_1.TXT_SANDBOX_EXEC_BACKGROUND)(identifier, commandId)));
36
+ output_1.default.exitCode(code ?? 0);
37
+ }
25
38
  if (cmdExit.status === utils_1.SANDBOX_EXEC_STATUS.SUCCESSFUL) {
26
39
  output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_EXEC_SUCCESS)(identifier, commandId));
27
40
  }
28
41
  else if (cmdExit.status === utils_1.SANDBOX_EXEC_STATUS.INPROGRESS) {
42
+ if (code !== undefined) {
43
+ output_1.default.normal((0, texts_1.TXT_SANDBOX_EXEC_INPROGRESS)(identifier, commandId));
44
+ output_1.default.exitCode(code);
45
+ }
29
46
  output_1.default.exitNormal((0, texts_1.TXT_SANDBOX_EXEC_INPROGRESS)(identifier, commandId));
30
47
  }
31
48
  else {
32
- output_1.default.exitError((0, texts_1.TXT_SANDBOX_EXEC_FAILED)(identifier, commandId));
49
+ output_1.default.exitError((0, texts_1.TXT_SANDBOX_EXEC_FAILED)(identifier, commandId), 1);
33
50
  }
34
51
  }
@@ -10,7 +10,7 @@ const output_1 = __importDefault(require("../../../output"));
10
10
  const input_1 = __importDefault(require("../../../input"));
11
11
  const scope_1 = require("../scope");
12
12
  const EXEC_WAIT_MS = 10000;
13
- const commandTargetExecCommand = (0, utils_1.newCommand)('command', texts_1.DESC_COMMAND_TARGET_EXEC_COMMAND, { examples: texts_1.EXAMPLE_TARGET_EXEC_COMMAND });
13
+ const commandTargetExecCommand = (0, utils_1.newCommand)('command', texts_1.DESC_COMMAND_TARGET_EXEC_COMMAND, { examples: texts_1.EXAMPLE_TARGET_EXEC_COMMAND, helpText: texts_1.HELP_TARGET_EXEC_COMMAND });
14
14
  commandTargetExecCommand.alias('cmd');
15
15
  commandTargetExecCommand.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
16
  commandTargetExecCommand.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
@@ -18,9 +18,10 @@ commandTargetExecCommand.option('--pipeline <identifier>', texts_1.OPTION_TARGET
18
18
  commandTargetExecCommand.option('--environment <identifier>', texts_1.OPTION_TARGET_ENVIRONMENT);
19
19
  commandTargetExecCommand.option('--async', texts_1.OPTION_TARGET_EXEC_ASYNC);
20
20
  commandTargetExecCommand.option('--file <path>', texts_1.OPTION_TARGET_EXEC_FILE);
21
- commandTargetExecCommand.option('--format <text|json>', texts_1.OPTION_FORMAT);
21
+ commandTargetExecCommand.option('--format <text|json>', texts_1.OPTION_EXEC_FORMAT_JSON);
22
22
  commandTargetExecCommand.argument('<identifier>', texts_1.OPTION_TARGET_IDENTIFIER);
23
23
  commandTargetExecCommand.argument('[command]', texts_1.OPTION_TARGET_EXEC_COMMAND);
24
+ commandTargetExecCommand.option('--exit-code', texts_1.OPTION_EXEC_EXIT_CODE);
24
25
  commandTargetExecCommand.action(async (identifier, command, options) => {
25
26
  output_1.default.handleSignals();
26
27
  if (options.file && command !== undefined) {
@@ -47,26 +48,38 @@ commandTargetExecCommand.action(async (identifier, command, options) => {
47
48
  });
48
49
  const execId = exec.execution_id;
49
50
  const json = options.format === 'json';
50
- if (options.async) {
51
- if (json) {
52
- output_1.default.json(exec);
53
- }
54
- else {
51
+ // Preserve the execution id before status validation can fail.
52
+ if (!json) {
53
+ if (options.async) {
55
54
  output_1.default.note((0, texts_1.TXT_TARGET_EXEC_BACKGROUND)(execId));
56
55
  output_1.default.data(execId);
57
56
  }
57
+ else {
58
+ output_1.default.note((0, texts_1.TXT_TARGET_EXEC_ID)(execId));
59
+ }
60
+ }
61
+ const recoveryHint = (0, texts_1.TXT_TARGET_EXEC_RECOVERY)(execId);
62
+ let code = options.exitCode
63
+ ? (0, utils_1.executionExitCode)(exec.status, recoveryHint)
64
+ : undefined;
65
+ if (options.async) {
66
+ if (json)
67
+ output_1.default.json(exec);
68
+ if (code !== undefined)
69
+ output_1.default.exitCode(code);
58
70
  output_1.default.exitNormal();
59
71
  }
60
72
  if (json) {
61
73
  while (exec.status === utils_1.TARGET_EXEC_STATUS.INPROGRESS) {
62
74
  exec = await client.getTargetExec(workspace, execId, EXEC_WAIT_MS);
75
+ if (options.exitCode)
76
+ code = (0, utils_1.executionExitCode)(exec.status, recoveryHint);
63
77
  }
64
78
  const log = [];
65
79
  await (0, scope_1.forwardExecLog)(client, workspace, execId, 0, (lines) => log.push(...lines));
66
80
  output_1.default.json({ ...exec, log });
67
- output_1.default.exitCode(exec.status === utils_1.TARGET_EXEC_STATUS.SUCCESSFUL ? 0 : 1);
81
+ output_1.default.exitCode(code ?? (exec.status === utils_1.TARGET_EXEC_STATUS.SUCCESSFUL ? 0 : 1));
68
82
  }
69
- output_1.default.note((0, texts_1.TXT_TARGET_EXEC_ID)(execId));
70
83
  let offset = 0;
71
84
  let truncated = false;
72
85
  // bytes_out from the status long-poll tells whether there is anything
@@ -80,6 +93,8 @@ commandTargetExecCommand.action(async (identifier, command, options) => {
80
93
  };
81
94
  while (exec.status === utils_1.TARGET_EXEC_STATUS.INPROGRESS) {
82
95
  exec = await client.getTargetExec(workspace, execId, EXEC_WAIT_MS);
96
+ if (options.exitCode)
97
+ (0, utils_1.executionExitCode)(exec.status, recoveryHint);
83
98
  if (exec.bytes_out !== loggedBytes)
84
99
  await drainLog();
85
100
  }
@@ -95,6 +110,6 @@ commandTargetExecCommand.action(async (identifier, command, options) => {
95
110
  }
96
111
  output_1.default.exitError(exec.status === utils_1.TARGET_EXEC_STATUS.CANCELLED
97
112
  ? (0, texts_1.TXT_TARGET_EXEC_CANCELLED)(execId)
98
- : (0, texts_1.TXT_TARGET_EXEC_FAILED)(execId, exec.failure_reason));
113
+ : (0, texts_1.TXT_TARGET_EXEC_FAILED)(execId, exec.failure_reason), 1);
99
114
  });
100
115
  exports.default = commandTargetExecCommand;
@@ -13,7 +13,8 @@ commandTargetExecLogs.option('-w, --workspace <domain>', texts_1.OPTION_REST_API
13
13
  commandTargetExecLogs.option('--offset <n>', texts_1.OPTION_TARGET_EXEC_LOG_OFFSET);
14
14
  commandTargetExecLogs.option('--limit <n>', texts_1.OPTION_TARGET_EXEC_LOG_LIMIT);
15
15
  commandTargetExecLogs.argument('<exec-id>', texts_1.OPTION_TARGET_EXEC_ID);
16
- commandTargetExecLogs.option('--format <text|jsonl>', texts_1.OPTION_FORMAT_JSONL);
16
+ commandTargetExecLogs.option('--format <text|jsonl>', texts_1.OPTION_EXEC_FORMAT_JSONL);
17
+ commandTargetExecLogs.option('--exit-code', texts_1.OPTION_EXEC_EXIT_CODE);
17
18
  commandTargetExecLogs.action(async (execId, options) => {
18
19
  const workspace = input_1.default.restApiWorkspace(options.workspace);
19
20
  const client = input_1.default.restApiTokenClient();
@@ -24,14 +25,19 @@ commandTargetExecLogs.action(async (execId, options) => {
24
25
  : undefined, limit);
25
26
  if (truncated)
26
27
  output_1.default.noteWarning(texts_1.WARN_TARGET_EXEC_TRUNCATED);
27
- if (options.format === 'jsonl') {
28
+ if (options.format === 'jsonl' || options.exitCode) {
28
29
  const exec = await client.getTargetExec(workspace, execId);
29
- output_1.default.json({
30
- type: 'exit',
31
- status: exec.status,
32
- exit_code: exec.exit_code ?? null,
33
- truncated,
34
- });
30
+ const code = options.exitCode ? (0, utils_1.executionExitCode)(exec.status) : undefined;
31
+ if (options.format === 'jsonl')
32
+ output_1.default.json({
33
+ type: 'exit',
34
+ status: exec.status,
35
+ exit_code: exec.exit_code ?? null,
36
+ truncated,
37
+ ...(options.exitCode ? { code } : {}),
38
+ });
39
+ if (code !== undefined)
40
+ output_1.default.exitCode(code);
35
41
  output_1.default.exitNormal();
36
42
  }
37
43
  output_1.default.exitNormal();
@@ -7,14 +7,16 @@ const utils_1 = require("../../../utils");
7
7
  const texts_1 = require("../../../texts");
8
8
  const input_1 = __importDefault(require("../../../input"));
9
9
  const output_1 = __importDefault(require("../../../output"));
10
- const commandTargetExecStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_TARGET_EXEC_STATUS, { examples: texts_1.EXAMPLE_TARGET_EXEC_STATUS });
10
+ const commandTargetExecStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_TARGET_EXEC_STATUS, { examples: texts_1.EXAMPLE_TARGET_EXEC_STATUS, helpText: texts_1.HELP_TARGET_EXEC_STATUS });
11
11
  commandTargetExecStatus.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
12
- commandTargetExecStatus.option('--format <text|json>', texts_1.OPTION_FORMAT);
12
+ commandTargetExecStatus.option('--format <text|json>', texts_1.OPTION_EXEC_FORMAT_JSON);
13
13
  commandTargetExecStatus.argument('<exec-id>', texts_1.OPTION_TARGET_EXEC_ID);
14
+ commandTargetExecStatus.option('--exit-code', texts_1.OPTION_EXEC_EXIT_CODE);
14
15
  commandTargetExecStatus.action(async (execId, options) => {
15
16
  const workspace = input_1.default.restApiWorkspace(options.workspace);
16
17
  const client = input_1.default.restApiTokenClient();
17
18
  const exec = await client.getTargetExec(workspace, execId);
19
+ const code = options.exitCode ? (0, utils_1.executionExitCode)(exec.status) : undefined;
18
20
  if (options.format === 'json') {
19
21
  output_1.default.json(exec);
20
22
  }
@@ -38,6 +40,8 @@ commandTargetExecStatus.action(async (execId, options) => {
38
40
  ];
39
41
  output_1.default.table(data);
40
42
  }
43
+ if (code !== undefined)
44
+ output_1.default.exitCode(code);
41
45
  output_1.default.exitNormal();
42
46
  });
43
47
  exports.default = commandTargetExecStatus;
@@ -7,6 +7,7 @@ exports.resolveTargetScope = exports.targetScopeOf = exports.targetAddressOf = e
7
7
  const utils_1 = require("../../utils");
8
8
  const texts_1 = require("../../texts");
9
9
  const output_1 = __importDefault(require("../../output"));
10
+ const cliError_1 = __importDefault(require("../../cliError"));
10
11
  const input_1 = __importDefault(require("../../input"));
11
12
  // Shared resolve preamble for commands taking a target identifier: line
12
13
  // context from flags/env -> /identifiers -> hash id, exiting on a miss.
@@ -30,7 +31,7 @@ const resolveTargetId = async (client, workspace, identifier, options, strictLin
30
31
  resolved = await client.getTargetByIdentifier(workspace, identifier);
31
32
  }
32
33
  if (!resolved.target_id) {
33
- output_1.default.exitError(texts_1.ERR_TARGET_NOT_FOUND);
34
+ throw new cliError_1.default('not_found', texts_1.ERR_TARGET_NOT_FOUND);
34
35
  }
35
36
  if (strictLine) {
36
37
  const requested = options.pipeline
@@ -49,7 +50,7 @@ const resolveTargetId = async (client, workspace, identifier, options, strictLin
49
50
  : (0, exports.targetScopeOf)(target) === utils_1.TARGET_SCOPE.PROJECT &&
50
51
  target.project?.name === resolved.project_identifier;
51
52
  if (!matches) {
52
- output_1.default.exitError(texts_1.ERR_TARGET_NOT_FOUND);
53
+ throw new cliError_1.default('not_found', texts_1.ERR_TARGET_NOT_FOUND);
53
54
  }
54
55
  }
55
56
  }
@@ -5,16 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const utils_1 = require("../utils");
7
7
  const texts_1 = require("../texts");
8
- const cfg_1 = __importDefault(require("../tunnel/cfg"));
9
8
  const output_1 = __importDefault(require("../output"));
10
9
  const input_1 = __importDefault(require("../input"));
11
- const cfg_2 = __importDefault(require("../project/cfg"));
10
+ const cfg_1 = __importDefault(require("../project/cfg"));
12
11
  const commandWhoami = (0, utils_1.newCommand)('whoami', texts_1.DESC_COMMAND_WHOAMI);
13
12
  commandWhoami.option('--format <text|json>', texts_1.OPTION_FORMAT);
14
13
  commandWhoami.action(async (options) => {
15
- const workspace = cfg_1.default.getWorkspace();
16
- const localWorkspace = cfg_2.default.getWorkspace();
17
- const localProject = cfg_2.default.getProject();
14
+ const { workspace, project, localWorkspace } = input_1.default.accountScope();
18
15
  const client = input_1.default.restApiTokenClient();
19
16
  const user = await client.getInvoker();
20
17
  if (!user) {
@@ -30,12 +27,12 @@ commandWhoami.action(async (options) => {
30
27
  else {
31
28
  obj.Workspace = !workspace ? texts_1.TXT_WHOAMI_NO_WORKSPACE : workspace;
32
29
  }
33
- if (localProject) {
34
- obj.Project = localProject;
30
+ if (project) {
31
+ obj.Project = project;
35
32
  }
36
- const vtSuite = cfg_2.default.getVtSuite();
37
- const utSuite = cfg_2.default.getUtSuite();
38
- const crawlSuite = cfg_2.default.getCrawlSuite();
33
+ const vtSuite = cfg_1.default.getVtSuite();
34
+ const utSuite = cfg_1.default.getUtSuite();
35
+ const crawlSuite = cfg_1.default.getCrawlSuite();
39
36
  if (vtSuite) {
40
37
  obj['Visual test suite'] = vtSuite;
41
38
  }
@@ -3,13 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const cfg_1 = __importDefault(require("../../tunnel/cfg"));
6
+ const input_1 = __importDefault(require("../../input"));
7
7
  const output_1 = __importDefault(require("../../output"));
8
8
  const texts_1 = require("../../texts");
9
9
  const utils_1 = require("../../utils");
10
10
  const commandWorkspaceGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_WORKSPACE_GET);
11
11
  commandWorkspaceGet.action(async () => {
12
- const workspace = cfg_1.default.getWorkspace();
12
+ const { workspace } = input_1.default.accountScope();
13
13
  if (!workspace) {
14
14
  output_1.default.exitError(texts_1.TXT_WORKSPACE_NONE);
15
15
  }
@@ -9,6 +9,7 @@ const texts_1 = require("../../texts");
9
9
  const utils_1 = require("../../utils");
10
10
  const input_1 = __importDefault(require("../../input"));
11
11
  const commandWorkspaceSet = (0, utils_1.newCommand)('set', texts_1.DESC_COMMAND_WORKSPACE_SET);
12
+ commandWorkspaceSet.usesDefaultContext = true;
12
13
  commandWorkspaceSet.argument('[workspace]', texts_1.ARG_COMMAND_WORKSPACE);
13
14
  commandWorkspaceSet.action(async (workspaceDomain) => {
14
15
  output_1.default.handleSignals();