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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.25.5-stage",
4
+ "version": "1.25.7-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 {
@@ -19,11 +52,13 @@ class CliCommand extends commander_1.Command {
19
52
  hideVersionUpdate;
20
53
  agentPort;
21
54
  skipPre = false;
55
+ usesDefaultContext = false;
22
56
  defaultErrorFormat = 'text';
23
57
  metadata;
24
58
  constructor(name, metadata = {}) {
25
59
  super(name);
26
60
  this.metadata = metadata;
61
+ this.option('--context <name>', texts_1.OPTION_CONTEXT);
27
62
  }
28
63
  addOption(option) {
29
64
  if (option.long === '--format' && !option.argChoices) {
@@ -35,8 +70,11 @@ class CliCommand extends commander_1.Command {
35
70
  }
36
71
  parseOptions(args) {
37
72
  output_1.default.errorFormat = this.defaultErrorFormat;
73
+ output_1.default.errorExitCode = 1;
38
74
  const formatOption = this.options.find((option) => option.long === '--format');
39
- if (formatOption && this.defaultErrorFormat === 'text') {
75
+ const exitCodeOption = this.options.some((option) => option.long === '--exit-code');
76
+ if ((formatOption && this.defaultErrorFormat === 'text') ||
77
+ exitCodeOption) {
40
78
  // Let Commander handle option syntax without running our parsers, hooks
41
79
  // or actions. Even if a required value is missing, earlier format values
42
80
  // are available before the real parser reports the error.
@@ -53,16 +91,21 @@ class CliCommand extends commander_1.Command {
53
91
  throw err;
54
92
  }
55
93
  const format = probe.opts().format;
56
- if (formatOption.argChoices?.includes(format) &&
94
+ if (formatOption?.argChoices?.includes(format) &&
57
95
  (format === 'json' || format === 'jsonl'))
58
96
  output_1.default.errorFormat = format;
97
+ if (exitCodeOption && probe.opts().exitCode)
98
+ output_1.default.errorExitCode = cliError_1.SemanticExitCode.ERROR;
59
99
  }
60
100
  this.showSuggestionAfterError(output_1.default.errorFormat === 'text');
61
101
  return super.parseOptions(args);
62
102
  }
63
103
  error(message, options) {
64
104
  if (output_1.default.errorFormat === 'text')
65
- return super.error(message, options);
105
+ return super.error(message, {
106
+ ...options,
107
+ exitCode: output_1.default.errorExitCode,
108
+ });
66
109
  const path = [this.name()];
67
110
  for (let command = this.parent; command; command = command.parent)
68
111
  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;
@@ -30,10 +30,19 @@ const environment_1 = __importDefault(require("./command/environment"));
30
30
  const register_1 = __importDefault(require("./command/register"));
31
31
  const mcp_1 = __importDefault(require("./command/mcp"));
32
32
  const discover_1 = __importDefault(require("./command/discover"));
33
+ const context_1 = __importDefault(require("./command/context"));
34
+ const input_1 = __importDefault(require("./input"));
33
35
  const cliError_1 = __importDefault(require("./cliError"));
36
+ const cliCommand_1 = __importDefault(require("./cliCommand"));
34
37
  const texts_2 = require("./texts");
35
38
  function cliIndex() {
36
39
  const program = (0, utils_1.newCommand)('bdy', texts_1.DESC_PROGRAM);
40
+ program.hook('preAction', (_, command) => {
41
+ const options = command.optsWithGlobals();
42
+ input_1.default.configureContext(command instanceof cliCommand_1.default && command.usesDefaultContext
43
+ ? { ...options, context: 'default' }
44
+ : options);
45
+ });
37
46
  program.hook('preAction', pre_1.default);
38
47
  program.configureHelp({
39
48
  formatHelp: utils_1.formatHelp,
@@ -65,6 +74,7 @@ function cliIndex() {
65
74
  program.addCommand(api_1.default);
66
75
  program.addCommand(mcp_1.default);
67
76
  program.addCommand(discover_1.default);
77
+ program.addCommand(context_1.default);
68
78
  program.action((_, cmd) => {
69
79
  if (cmd.args.length > 0) {
70
80
  output_1.default.exitError(new cliError_1.default('unknown_command', (0, texts_1.ERR_COMMAND_NOT_FOUND)(cmd.args[0]), (0, texts_2.TXT_CLI_USAGE_HINT)('bdy')));
@@ -0,0 +1,38 @@
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
+ const utils_1 = require("../../utils");
7
+ const input_1 = __importDefault(require("../../input"));
8
+ const output_1 = __importDefault(require("../../output"));
9
+ const cfg_1 = __importDefault(require("../../tunnel/cfg"));
10
+ const cliError_1 = __importDefault(require("../../cliError"));
11
+ const texts_1 = require("../../texts");
12
+ const command = (0, utils_1.newCommand)('add', texts_1.DESC_CONTEXT_ADD, {
13
+ requiredScopes: [],
14
+ examples: texts_1.EXAMPLE_CONTEXT_ADD,
15
+ helpText: texts_1.HELP_CONTEXT_ADD,
16
+ });
17
+ command.skipPre = true;
18
+ command.argument('<name>', texts_1.OPTION_CONTEXT_NAME);
19
+ command.option('--format <text|json>', texts_1.OPTION_FORMAT);
20
+ command.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
21
+ command.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
22
+ command.option('--token <token>', texts_1.OPTION_CONTEXT_TOKEN);
23
+ command.option('--api <endpoint>', texts_1.OPTION_CONTEXT_API);
24
+ command.option('--from-link', texts_1.OPTION_CONTEXT_LINK);
25
+ command.option('--from-git', texts_1.OPTION_CONTEXT_GIT);
26
+ command.option('--remote <name>', texts_1.OPTION_CONTEXT_REMOTE);
27
+ command.action((name, options) => {
28
+ input_1.default.contextEditableName(name);
29
+ if (Object.hasOwn(cfg_1.default.getContexts(), name))
30
+ throw new cliError_1.default('usage_error', (0, texts_1.ERR_CONTEXT_EXISTS)(name));
31
+ const context = input_1.default.contextDefinition(options);
32
+ cfg_1.default.setContext(name, context);
33
+ if (options.format === 'json')
34
+ output_1.default.json({ name, source: context.source });
35
+ else
36
+ output_1.default.normal((0, texts_1.TXT_CONTEXT_SAVED)(name));
37
+ });
38
+ exports.default = command;
@@ -0,0 +1,33 @@
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
+ const utils_1 = require("../../utils");
7
+ const output_1 = __importDefault(require("../../output"));
8
+ const cfg_1 = __importDefault(require("../../tunnel/cfg"));
9
+ const texts_1 = require("../../texts");
10
+ const command = (0, utils_1.newCommand)('list', texts_1.DESC_CONTEXT_LIST, {
11
+ requiredScopes: [],
12
+ examples: texts_1.EXAMPLE_CONTEXT_LIST,
13
+ helpText: texts_1.HELP_CONTEXT_LIST,
14
+ });
15
+ command.skipPre = true;
16
+ command.alias('ls');
17
+ command.option('--format <text|json>', texts_1.OPTION_FORMAT);
18
+ command.action((options) => {
19
+ const builtins = ['default', 'git', 'link'];
20
+ const active = cfg_1.default.getActiveContext();
21
+ const values = [...builtins, ...Object.keys(cfg_1.default.getContexts()).sort()].map((name) => ({
22
+ name,
23
+ active: name === active,
24
+ builtin: builtins.includes(name),
25
+ source: cfg_1.default.getContext(name)?.source || 'default',
26
+ }));
27
+ if (options.format === 'json')
28
+ output_1.default.json(values);
29
+ else
30
+ for (const item of values)
31
+ output_1.default.normal(`${item.active ? '*' : ' '} ${item.name}`);
32
+ });
33
+ exports.default = command;
@@ -0,0 +1,36 @@
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
+ const utils_1 = require("../../utils");
7
+ const input_1 = __importDefault(require("../../input"));
8
+ const output_1 = __importDefault(require("../../output"));
9
+ const cfg_1 = __importDefault(require("../../tunnel/cfg"));
10
+ const texts_1 = require("../../texts");
11
+ const command = (0, utils_1.newCommand)('remove', texts_1.DESC_CONTEXT_REMOVE, {
12
+ requiredScopes: [],
13
+ examples: texts_1.EXAMPLE_CONTEXT_REMOVE,
14
+ helpText: texts_1.HELP_CONTEXT_REMOVE,
15
+ });
16
+ command.skipPre = true;
17
+ command.alias('rm');
18
+ command.argument('<name>', texts_1.OPTION_CONTEXT_NAME);
19
+ command.option('--format <text|json>', texts_1.OPTION_FORMAT);
20
+ command.option('-f, --force', texts_1.OPTION_CONFIRM_FORCE);
21
+ command.action(async (name, options) => {
22
+ input_1.default.contextEditableName(name);
23
+ cfg_1.default.getContext(name);
24
+ const confirmed = options.force ||
25
+ (await output_1.default.confirm((0, texts_1.TXT_CONTEXT_REMOVE_CONFIRM)(name), options.format === 'json'));
26
+ if (confirmed)
27
+ cfg_1.default.removeContext(name);
28
+ if (options.format === 'json')
29
+ output_1.default.json({
30
+ removed: confirmed ? name : null,
31
+ active: cfg_1.default.getActiveContext(),
32
+ });
33
+ else if (confirmed)
34
+ output_1.default.normal((0, texts_1.TXT_CONTEXT_REMOVED)(name));
35
+ });
36
+ exports.default = command;
@@ -0,0 +1,35 @@
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
+ const utils_1 = require("../../utils");
7
+ const input_1 = __importDefault(require("../../input"));
8
+ const output_1 = __importDefault(require("../../output"));
9
+ const texts_1 = require("../../texts");
10
+ const command = (0, utils_1.newCommand)('show', texts_1.DESC_CONTEXT_SHOW, {
11
+ requiredScopes: [],
12
+ examples: texts_1.EXAMPLE_CONTEXT_SHOW,
13
+ helpText: texts_1.HELP_CONTEXT_SHOW,
14
+ });
15
+ command.skipPre = true;
16
+ command.argument('[name]', texts_1.OPTION_CONTEXT_NAME);
17
+ command.option('--format <text|json>', texts_1.OPTION_FORMAT);
18
+ command.action((name, options, cmd) => {
19
+ if (name)
20
+ input_1.default.configureContext({ ...cmd.optsWithGlobals(), context: name });
21
+ const result = input_1.default.showContext();
22
+ if (options.format === 'json')
23
+ output_1.default.json(result);
24
+ else
25
+ output_1.default.object({
26
+ [texts_1.TXT_CONTEXT_LABEL]: result.name,
27
+ [texts_1.TXT_CONTEXT_SOURCE_LABEL]: result.source,
28
+ [texts_1.TXT_CONTEXT_WORKSPACE_LABEL]: `${result.workspace || '-'} (${result.sources.workspace || '-'})`,
29
+ [texts_1.TXT_CONTEXT_PROJECT_LABEL]: `${result.project || '-'} (${result.sources.project || '-'})`,
30
+ [texts_1.TXT_CONTEXT_API_LABEL]: `${result.api} (${result.sources.api})`,
31
+ [texts_1.TXT_CONTEXT_REMOTE_LABEL]: result.remote || '-',
32
+ [texts_1.TXT_CONTEXT_TOKEN_LABEL]: `${result.token.available ? texts_1.TXT_CONTEXT_TOKEN_AVAILABLE : texts_1.TXT_CONTEXT_TOKEN_MISSING} (${result.token.source || '-'})`,
33
+ });
34
+ });
35
+ exports.default = command;
@@ -0,0 +1,25 @@
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
+ const utils_1 = require("../../utils");
7
+ const output_1 = __importDefault(require("../../output"));
8
+ const cfg_1 = __importDefault(require("../../tunnel/cfg"));
9
+ const texts_1 = require("../../texts");
10
+ const command = (0, utils_1.newCommand)('use', texts_1.DESC_CONTEXT_USE, {
11
+ requiredScopes: [],
12
+ examples: texts_1.EXAMPLE_CONTEXT_USE,
13
+ helpText: texts_1.HELP_CONTEXT_USE,
14
+ });
15
+ command.skipPre = true;
16
+ command.argument('<name>', texts_1.OPTION_CONTEXT_NAME);
17
+ command.option('--format <text|json>', texts_1.OPTION_FORMAT);
18
+ command.action((name, options) => {
19
+ cfg_1.default.setActiveContext(name);
20
+ if (options.format === 'json')
21
+ output_1.default.json({ active: name });
22
+ else
23
+ output_1.default.normal((0, texts_1.TXT_CONTEXT_ACTIVE)(name));
24
+ });
25
+ exports.default = command;
@@ -0,0 +1,22 @@
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
+ const utils_1 = require("../utils");
7
+ const texts_1 = require("../texts");
8
+ const add_1 = __importDefault(require("./context/add"));
9
+ const list_1 = __importDefault(require("./context/list"));
10
+ const show_1 = __importDefault(require("./context/show"));
11
+ const use_1 = __importDefault(require("./context/use"));
12
+ const remove_1 = __importDefault(require("./context/remove"));
13
+ const commandContext = (0, utils_1.newCommand)('context', texts_1.DESC_CONTEXT, {
14
+ requiredScopes: [],
15
+ helpText: texts_1.HELP_CONTEXT,
16
+ });
17
+ commandContext.addCommand(add_1.default);
18
+ commandContext.addCommand(list_1.default);
19
+ commandContext.addCommand(show_1.default);
20
+ commandContext.addCommand(use_1.default);
21
+ commandContext.addCommand(remove_1.default);
22
+ exports.default = commandContext;
@@ -293,6 +293,7 @@ async function authorize(options, forceRegisterEmail, forceRegisterName) {
293
293
  }
294
294
  }
295
295
  const commandLogin = (0, utils_1.newCommand)('login', texts_1.DESC_COMMAND_LOGIN);
296
+ commandLogin.usesDefaultContext = true;
296
297
  commandLogin.alias('sign-in');
297
298
  commandLogin.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
298
299
  commandLogin.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
@@ -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 commandLogout = (0, utils_1.newCommand)('logout', texts_1.DESC_COMMAND_LOGOUT);
12
+ commandLogout.usesDefaultContext = true;
12
13
  const tryRemovingApp = async () => {
13
14
  try {
14
15
  const clientId = cfg_1.default.getApiClientId();
@@ -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;