bdy 1.25.5-dev → 1.25.6-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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.25.5-dev",
4
+ "version": "1.25.6-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "homepage": "https://buddy.works/docs/cli",
@@ -1282,7 +1282,7 @@ class ApiClient {
1282
1282
  // answering for a different scope than asked (TARGET_API_REQUIREMENTS.md
1283
1283
  // p6). project_identifier is present whenever the project exists.
1284
1284
  if (params.project && !resolved.project_identifier) {
1285
- throw new Error(texts_1.ERR_PROJECT_NOT_FOUND);
1285
+ throw new cliError_1.default('not_found', texts_1.ERR_PROJECT_NOT_FOUND);
1286
1286
  }
1287
1287
  return resolved;
1288
1288
  }
@@ -1,11 +1,44 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
5
38
  Object.defineProperty(exports, "__esModule", { value: true });
6
39
  const commander_1 = require("commander");
7
40
  const output_1 = __importDefault(require("./output"));
8
- const cliError_1 = __importDefault(require("./cliError"));
41
+ const cliError_1 = __importStar(require("./cliError"));
9
42
  const texts_1 = require("./texts");
10
43
  /** Command documentation shared by terminal help and machine discovery. */
11
44
  class CliCommand extends commander_1.Command {
@@ -35,8 +68,11 @@ class CliCommand extends commander_1.Command {
35
68
  }
36
69
  parseOptions(args) {
37
70
  output_1.default.errorFormat = this.defaultErrorFormat;
71
+ output_1.default.errorExitCode = 1;
38
72
  const formatOption = this.options.find((option) => option.long === '--format');
39
- if (formatOption && this.defaultErrorFormat === 'text') {
73
+ const exitCodeOption = this.options.some((option) => option.long === '--exit-code');
74
+ if ((formatOption && this.defaultErrorFormat === 'text') ||
75
+ exitCodeOption) {
40
76
  // Let Commander handle option syntax without running our parsers, hooks
41
77
  // or actions. Even if a required value is missing, earlier format values
42
78
  // are available before the real parser reports the error.
@@ -53,16 +89,21 @@ class CliCommand extends commander_1.Command {
53
89
  throw err;
54
90
  }
55
91
  const format = probe.opts().format;
56
- if (formatOption.argChoices?.includes(format) &&
92
+ if (formatOption?.argChoices?.includes(format) &&
57
93
  (format === 'json' || format === 'jsonl'))
58
94
  output_1.default.errorFormat = format;
95
+ if (exitCodeOption && probe.opts().exitCode)
96
+ output_1.default.errorExitCode = cliError_1.SemanticExitCode.ERROR;
59
97
  }
60
98
  this.showSuggestionAfterError(output_1.default.errorFormat === 'text');
61
99
  return super.parseOptions(args);
62
100
  }
63
101
  error(message, options) {
64
102
  if (output_1.default.errorFormat === 'text')
65
- return super.error(message, options);
103
+ return super.error(message, {
104
+ ...options,
105
+ exitCode: output_1.default.errorExitCode,
106
+ });
66
107
  const path = [this.name()];
67
108
  for (let command = this.parent; command; command = command.parent)
68
109
  path.unshift(command.name());
@@ -1,5 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SemanticExitCode = void 0;
4
+ /** Process codes used by commands opting into --exit-code. */
5
+ var SemanticExitCode;
6
+ (function (SemanticExitCode) {
7
+ SemanticExitCode[SemanticExitCode["SUCCESS"] = 0] = "SUCCESS";
8
+ SemanticExitCode[SemanticExitCode["FAILURE"] = 1] = "FAILURE";
9
+ SemanticExitCode[SemanticExitCode["ERROR"] = 2] = "ERROR";
10
+ SemanticExitCode[SemanticExitCode["NOT_FOUND"] = 3] = "NOT_FOUND";
11
+ SemanticExitCode[SemanticExitCode["PENDING"] = 8] = "PENDING";
12
+ })(SemanticExitCode || (exports.SemanticExitCode = SemanticExitCode = {}));
3
13
  class CliError extends Error {
4
14
  code;
5
15
  hint;
@@ -7,17 +7,19 @@ 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 execution_1 = require("./execution");
10
11
  const pipeline_1 = require("../../../types/pipeline");
11
12
  const commandPipelineRunApprove = (0, utils_1.newCommand)('approve', texts_1.DESC_COMMAND_PIPELINE_RUN_APPLY, {
12
13
  requiredScopes: [utils_1.REST_API_SCOPE.PIPELINE_RUN],
13
14
  examples: texts_1.EXAMPLE_PIPELINE_RUN_APPLY,
14
- helpText: texts_1.HELP_PIPELINE_RUN_JSONL,
15
+ helpText: texts_1.HELP_PIPELINE_RUN_STATUS,
15
16
  });
16
17
  commandPipelineRunApprove.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
17
18
  commandPipelineRunApprove.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
18
19
  commandPipelineRunApprove.option('-n, --no-wait', texts_1.OPTION_PIPELINE_RUN_NO_WAIT);
19
20
  commandPipelineRunApprove.option('--no-follow', texts_1.OPTION_PIPELINE_RUN_NO_FOLLOW);
20
- commandPipelineRunApprove.option('--format <text|jsonl>', texts_1.OPTION_FORMAT_JSONL);
21
+ commandPipelineRunApprove.option('--exit-code', texts_1.OPTION_EXEC_EXIT_CODE);
22
+ commandPipelineRunApprove.option('--format <text|jsonl>', texts_1.OPTION_EXEC_FORMAT_JSONL);
21
23
  commandPipelineRunApprove.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
22
24
  commandPipelineRunApprove.argument('<run-id>', texts_1.OPTION_PIPELINE_RUN_ID);
23
25
  commandPipelineRunApprove.argument('<action-run-id>', texts_1.OPTION_PIPELINE_RUN_ACTION_ID);
@@ -28,17 +30,8 @@ commandPipelineRunApprove.action(async (identifier, runId, runActionId, options)
28
30
  const rid = input_1.default.pipelineRunId(runId);
29
31
  const variables = input_1.default.runVariable(options.variable || [], false);
30
32
  const client = input_1.default.restApiTokenClient();
31
- const data = await client.getPipelineByIdentifier(workspace, project, identifier);
32
- if (!data || !data.domain) {
33
- output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
34
- }
35
- if (!data.project_identifier) {
36
- output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
37
- }
38
- if (!data.pipeline_id) {
39
- output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
40
- }
41
- const a = await client.getPipelineRunActionExecution(workspace, project, data.pipeline_id, rid, runActionId);
33
+ const pipelineId = await (0, execution_1.resolvePipelineId)(client, workspace, project, identifier);
34
+ const a = await client.getPipelineRunActionExecution(workspace, project, pipelineId, rid, runActionId);
42
35
  let type;
43
36
  if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_APPLY) {
44
37
  type = 'APPLY';
@@ -60,8 +53,8 @@ commandPipelineRunApprove.action(async (identifier, runId, runActionId, options)
60
53
  approve_action_id: runActionId,
61
54
  variables,
62
55
  };
63
- await client.pipelineRunApply(workspace, project, data.pipeline_id, rid, body);
56
+ await client.pipelineRunApply(workspace, project, pipelineId, rid, body);
64
57
  const OutputPipeline = require('../../../output/pipeline').default;
65
- await OutputPipeline.runStatus(client, workspace, project, identifier, data.pipeline_id, rid, !options.wait, !options.follow, options.format === 'jsonl');
58
+ await OutputPipeline.runStatus(client, workspace, project, identifier, pipelineId, rid, !options.wait, !options.follow, options.format === 'jsonl', !!options.exitCode);
66
59
  });
67
60
  exports.default = commandPipelineRunApprove;
@@ -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 commandPipelineRunCancel = (0, utils_1.newCommand)('cancel', texts_1.DESC_COMMAND_PIPELINE_RUN_CANCEL, {
11
11
  requiredScopes: [utils_1.REST_API_SCOPE.PIPELINE_RUN],
12
12
  examples: texts_1.EXAMPLE_PIPELINE_RUN_CANCEL,
13
- helpText: texts_1.HELP_PIPELINE_RUN_JSONL,
13
+ helpText: texts_1.HELP_PIPELINE_RUN_STATUS,
14
14
  });
15
15
  commandPipelineRunCancel.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
16
  commandPipelineRunCancel.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
17
  commandPipelineRunCancel.option('-n, --no-wait', texts_1.OPTION_PIPELINE_RUN_NO_WAIT);
18
18
  commandPipelineRunCancel.option('--no-follow', texts_1.OPTION_PIPELINE_RUN_NO_FOLLOW);
19
- commandPipelineRunCancel.option('--format <text|jsonl>', texts_1.OPTION_FORMAT_JSONL);
19
+ commandPipelineRunCancel.option('--exit-code', texts_1.OPTION_EXEC_EXIT_CODE);
20
+ commandPipelineRunCancel.option('--format <text|jsonl>', texts_1.OPTION_EXEC_FORMAT_JSONL);
20
21
  commandPipelineRunCancel.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
21
22
  commandPipelineRunCancel.argument('<run-id>', texts_1.OPTION_PIPELINE_RUN_ID);
22
23
  commandPipelineRunCancel.action(async (identifier, runId, options) => {
@@ -24,18 +25,9 @@ commandPipelineRunCancel.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
- }
37
- await client.pipelineRunCancel(workspace, project, data.pipeline_id, rid);
28
+ const pipelineId = await (0, execution_1.resolvePipelineId)(client, workspace, project, identifier);
29
+ await client.pipelineRunCancel(workspace, project, pipelineId, rid);
38
30
  const OutputPipeline = require('../../../output/pipeline').default;
39
- await OutputPipeline.runStatus(client, workspace, project, identifier, data.pipeline_id, rid, !options.wait, !options.follow, options.format === 'jsonl');
31
+ await OutputPipeline.runStatus(client, workspace, project, identifier, pipelineId, rid, !options.wait, !options.follow, options.format === 'jsonl', !!options.exitCode);
40
32
  });
41
33
  exports.default = commandPipelineRunCancel;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.resolvePipelineId = resolvePipelineId;
7
+ const cliError_1 = __importDefault(require("../../../cliError"));
8
+ const texts_1 = require("../../../texts");
9
+ /** Resolve and validate the execution's parent resources. */
10
+ async function resolvePipelineId(client, workspace, project, identifier) {
11
+ const data = await client.getPipelineByIdentifier(workspace, project, identifier);
12
+ if (!data || !data.domain)
13
+ throw new cliError_1.default('not_found', texts_1.ERR_WORKSPACE_NOT_FOUND);
14
+ if (!data.project_identifier)
15
+ throw new cliError_1.default('not_found', texts_1.ERR_PROJECT_NOT_FOUND);
16
+ if (!data.pipeline_id) {
17
+ throw new cliError_1.default('not_found', texts_1.ERR_PIPELINE_NOT_FOUND);
18
+ }
19
+ return data.pipeline_id;
20
+ }
@@ -6,16 +6,17 @@ 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 commandPipelineRunLogs = (0, utils_1.newCommand)('logs', texts_1.DESC_COMMAND_PIPELINE_RUN_LOGS, {
11
11
  requiredScopes: [utils_1.REST_API_SCOPE.PIPELINE_READ],
12
12
  examples: texts_1.EXAMPLE_PIPELINE_RUN_LOGS,
13
- helpText: texts_1.HELP_PIPELINE_RUN_JSONL,
13
+ helpText: texts_1.HELP_PIPELINE_RUN_LOGS,
14
14
  });
15
15
  commandPipelineRunLogs.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
16
  commandPipelineRunLogs.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
17
  commandPipelineRunLogs.option('-n, --no-wait', texts_1.OPTION_PIPELINE_RUN_NO_WAIT);
18
- commandPipelineRunLogs.option('--format <text|jsonl>', texts_1.OPTION_FORMAT_JSONL);
18
+ commandPipelineRunLogs.option('--exit-code', texts_1.OPTION_EXEC_EXIT_CODE);
19
+ commandPipelineRunLogs.option('--format <text|jsonl>', texts_1.OPTION_EXEC_FORMAT_JSONL);
19
20
  commandPipelineRunLogs.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
20
21
  commandPipelineRunLogs.argument('<run-id>', texts_1.OPTION_PIPELINE_RUN_ID);
21
22
  commandPipelineRunLogs.argument('<action-run-id>', texts_1.OPTION_PIPELINE_RUN_ACTION_ID);
@@ -25,17 +26,8 @@ commandPipelineRunLogs.action(async (identifier, runId, runActionId, options) =>
25
26
  const client = input_1.default.restApiTokenClient();
26
27
  const rid = input_1.default.pipelineRunId(runId);
27
28
  const raid = input_1.default.pipelineRunActionId(runActionId);
28
- const data = await client.getPipelineByIdentifier(workspace, project, identifier);
29
- if (!data || !data.domain) {
30
- output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
31
- }
32
- if (!data.project_identifier) {
33
- output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
34
- }
35
- if (!data.pipeline_id) {
36
- output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
37
- }
29
+ const pipelineId = await (0, execution_1.resolvePipelineId)(client, workspace, project, identifier);
38
30
  const OutputPipeline = require('../../../output/pipeline').default;
39
- await OutputPipeline.runLogs(client, workspace, project, identifier, data.pipeline_id, rid, raid, !options.wait, options.format === 'jsonl');
31
+ await OutputPipeline.runLogs(client, workspace, project, identifier, pipelineId, rid, raid, !options.wait, options.format === 'jsonl', !!options.exitCode);
40
32
  });
41
33
  exports.default = commandPipelineRunLogs;
@@ -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 commandPipelineRunRetry = (0, utils_1.newCommand)('retry', texts_1.DESC_COMMAND_PIPELINE_RUN_RETRY, {
11
11
  requiredScopes: [utils_1.REST_API_SCOPE.PIPELINE_RUN],
12
12
  examples: texts_1.EXAMPLE_PIPELINE_RUN_RETRY,
13
- helpText: texts_1.HELP_PIPELINE_RUN_JSONL,
13
+ helpText: texts_1.HELP_PIPELINE_RUN_STATUS,
14
14
  });
15
15
  commandPipelineRunRetry.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
16
  commandPipelineRunRetry.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
17
  commandPipelineRunRetry.option('-n, --no-wait', texts_1.OPTION_PIPELINE_RUN_NO_WAIT);
18
18
  commandPipelineRunRetry.option('--no-follow', texts_1.OPTION_PIPELINE_RUN_NO_FOLLOW);
19
- commandPipelineRunRetry.option('--format <text|jsonl>', texts_1.OPTION_FORMAT_JSONL);
19
+ commandPipelineRunRetry.option('--exit-code', texts_1.OPTION_EXEC_EXIT_CODE);
20
+ commandPipelineRunRetry.option('--format <text|jsonl>', texts_1.OPTION_EXEC_FORMAT_JSONL);
20
21
  commandPipelineRunRetry.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
21
22
  commandPipelineRunRetry.argument('<run-id>', texts_1.OPTION_PIPELINE_RUN_ID);
22
23
  commandPipelineRunRetry.action(async (identifier, runId, options) => {
@@ -24,18 +25,9 @@ commandPipelineRunRetry.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
- }
37
- await client.pipelineRunRetry(workspace, project, data.pipeline_id, rid);
28
+ const pipelineId = await (0, execution_1.resolvePipelineId)(client, workspace, project, identifier);
29
+ await client.pipelineRunRetry(workspace, project, pipelineId, rid);
38
30
  const OutputPipeline = require('../../../output/pipeline').default;
39
- await OutputPipeline.runStatus(client, workspace, project, identifier, data.pipeline_id, rid, !options.wait, !options.follow, options.format === 'jsonl');
31
+ await OutputPipeline.runStatus(client, workspace, project, identifier, pipelineId, rid, !options.wait, !options.follow, options.format === 'jsonl', !!options.exitCode);
40
32
  });
41
33
  exports.default = commandPipelineRunRetry;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const utils_1 = require("../../../utils");
7
7
  const texts_1 = require("../../../texts");
8
8
  const output_1 = __importDefault(require("../../../output"));
9
+ const execution_1 = require("./execution");
9
10
  const input_1 = __importDefault(require("../../../input"));
10
11
  const node_fs_1 = __importDefault(require("node:fs"));
11
12
  const path_1 = require("path");
@@ -13,7 +14,7 @@ const client_1 = require("../../../api/client");
13
14
  const commandPipelineRunStart = (0, utils_1.newCommand)('start', texts_1.DESC_COMMAND_PIPELINE_RUN_START, {
14
15
  requiredScopes: [utils_1.REST_API_SCOPE.PIPELINE_RUN],
15
16
  examples: texts_1.EXAMPLE_PIPELINE_RUN_START,
16
- helpText: texts_1.HELP_PIPELINE_RUN_JSONL,
17
+ helpText: texts_1.HELP_PIPELINE_RUN_STATUS,
17
18
  });
18
19
  commandPipelineRunStart.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
19
20
  commandPipelineRunStart.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
@@ -38,7 +39,8 @@ commandPipelineRunStart.option('--schedule <date>', texts_1.OPTION_PIPELINE_RUN_
38
39
  commandPipelineRunStart.option('--action <actions...>', texts_1.OPTION_PIPELINE_RUN_ACTION);
39
40
  commandPipelineRunStart.option('-n,--no-wait', texts_1.OPTION_PIPELINE_RUN_NO_WAIT);
40
41
  commandPipelineRunStart.option('--no-follow', texts_1.OPTION_PIPELINE_RUN_NO_FOLLOW);
41
- commandPipelineRunStart.option('--format <text|jsonl>', texts_1.OPTION_FORMAT_JSONL);
42
+ commandPipelineRunStart.option('--exit-code', texts_1.OPTION_EXEC_EXIT_CODE);
43
+ commandPipelineRunStart.option('--format <text|jsonl>', texts_1.OPTION_EXEC_FORMAT_JSONL);
42
44
  commandPipelineRunStart.argument('<identifier>', texts_1.OPTION_PIPELINE_IDENTIFIER);
43
45
  commandPipelineRunStart.usage('<identifier> [options]');
44
46
  /**
@@ -135,16 +137,7 @@ commandPipelineRunStart.action(async (identifier, options) => {
135
137
  const workspace = input_1.default.restApiWorkspace(options.workspace);
136
138
  const project = input_1.default.restApiProject(options.project);
137
139
  const client = input_1.default.restApiTokenClient();
138
- const data = await client.getPipelineByIdentifier(workspace, project, identifier);
139
- if (!data || !data.domain) {
140
- output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
141
- }
142
- if (!data.project_identifier) {
143
- output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
144
- }
145
- if (!data.pipeline_id) {
146
- output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
147
- }
140
+ const pipelineId = await (0, execution_1.resolvePipelineId)(client, workspace, project, identifier);
148
141
  const body = {};
149
142
  if (options.branch) {
150
143
  body.branch = {
@@ -194,9 +187,9 @@ commandPipelineRunStart.action(async (identifier, options) => {
194
187
  if (actions) {
195
188
  body.actions_to_run = actions;
196
189
  }
197
- body.payload_files = await uploadPayloadFiles(client, workspace, project, data.pipeline_id, options.payload);
198
- const result = await client.pipelineRun(workspace, project, data.pipeline_id, body);
190
+ body.payload_files = await uploadPayloadFiles(client, workspace, project, pipelineId, options.payload);
191
+ const result = await client.pipelineRun(workspace, project, pipelineId, body);
199
192
  const OutputPipeline = require('../../../output/pipeline').default;
200
- await OutputPipeline.runStatus(client, workspace, project, identifier, data.pipeline_id, result.id, !options.wait, !options.follow, options.format === 'jsonl');
193
+ await OutputPipeline.runStatus(client, workspace, project, identifier, pipelineId, result.id, !options.wait, !options.follow, options.format === 'jsonl', !!options.exitCode);
201
194
  });
202
195
  exports.default = commandPipelineRunStart;
@@ -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;
@@ -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
  }