bdy 1.25.5-stage → 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.
- package/distTs/package.json +1 -1
- package/distTs/src/api/client.js +1 -1
- package/distTs/src/cliCommand.js +45 -4
- package/distTs/src/cliError.js +10 -0
- package/distTs/src/command/pipeline/run/approve.js +8 -15
- package/distTs/src/command/pipeline/run/cancel.js +7 -15
- package/distTs/src/command/pipeline/run/execution.js +20 -0
- package/distTs/src/command/pipeline/run/logs.js +6 -14
- package/distTs/src/command/pipeline/run/retry.js +7 -15
- package/distTs/src/command/pipeline/run/start.js +8 -15
- package/distTs/src/command/pipeline/run/status.js +6 -14
- package/distTs/src/command/sandbox/exec/command.js +7 -2
- package/distTs/src/command/sandbox/exec/logs.js +3 -2
- package/distTs/src/command/sandbox/exec/status.js +6 -2
- package/distTs/src/command/sandbox/finishExec.js +19 -2
- package/distTs/src/command/target/exec/command.js +25 -10
- package/distTs/src/command/target/exec/logs.js +14 -8
- package/distTs/src/command/target/exec/status.js +6 -2
- package/distTs/src/command/target/scope.js +3 -2
- package/distTs/src/input.js +1 -1
- package/distTs/src/output/pipeline.js +108 -28
- package/distTs/src/output.js +39 -3
- package/distTs/src/texts.js +130 -20
- package/distTs/src/utils.js +15 -0
- package/package.json +1 -1
|
@@ -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.
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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.
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
53
|
+
throw new cliError_1.default('not_found', texts_1.ERR_TARGET_NOT_FOUND);
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
}
|
package/distTs/src/input.js
CHANGED
|
@@ -1242,7 +1242,7 @@ class Input {
|
|
|
1242
1242
|
sandboxId = await client.findSandboxByIdentifier(workspace, identifier, project, environmentId);
|
|
1243
1243
|
}
|
|
1244
1244
|
if (!sandboxId) {
|
|
1245
|
-
|
|
1245
|
+
throw new cliError_1.default('not_found', texts_1.ERR_SANDBOX_NOT_FOUND);
|
|
1246
1246
|
}
|
|
1247
1247
|
return sandboxId;
|
|
1248
1248
|
}
|
|
@@ -1,9 +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 output_1 = __importDefault(require("../output"));
|
|
40
|
+
const cliError_1 = __importStar(require("../cliError"));
|
|
41
|
+
const texts_1 = require("../texts");
|
|
7
42
|
const pipeline_1 = require("../types/pipeline");
|
|
8
43
|
const utils_1 = require("../utils");
|
|
9
44
|
// @ts-ignore
|
|
@@ -24,17 +59,21 @@ var MODE;
|
|
|
24
59
|
})(MODE || (MODE = {}));
|
|
25
60
|
const LOGS_LIMIT = 1000;
|
|
26
61
|
class OutputPipeline {
|
|
27
|
-
static async runLogs(client, workspace, project, identifier, pipelineId, runId, runActionId, noWait, isJson) {
|
|
28
|
-
if (output_1.default.isTTY() && !noWait && !isJson) {
|
|
62
|
+
static async runLogs(client, workspace, project, identifier, pipelineId, runId, runActionId, noWait, isJson, semanticExitCode = false) {
|
|
63
|
+
if (output_1.default.isTTY() && !noWait && !isJson && !semanticExitCode) {
|
|
29
64
|
return await this._runLogsInteractive(client, workspace, project, pipelineId, runId, runActionId);
|
|
30
65
|
}
|
|
31
|
-
return await this._runLogsNonInteractive(client, workspace, project, identifier, pipelineId, runId, runActionId, noWait, isJson);
|
|
66
|
+
return await this._runLogsNonInteractive(client, workspace, project, identifier, pipelineId, runId, runActionId, noWait, isJson, semanticExitCode);
|
|
32
67
|
}
|
|
33
|
-
static async runStatus(client, workspace, project, identifier, pipelineId, runId, noWait, noFollow, isJson) {
|
|
34
|
-
if (output_1.default.isTTY() &&
|
|
68
|
+
static async runStatus(client, workspace, project, identifier, pipelineId, runId, noWait, noFollow, isJson, semanticExitCode = false) {
|
|
69
|
+
if (output_1.default.isTTY() &&
|
|
70
|
+
!noWait &&
|
|
71
|
+
!noFollow &&
|
|
72
|
+
!isJson &&
|
|
73
|
+
!semanticExitCode) {
|
|
35
74
|
return await this._runStatusInteractive(client, workspace, project, pipelineId, runId);
|
|
36
75
|
}
|
|
37
|
-
return await this._runStatusNonInteractive(client, workspace, project, identifier, pipelineId, runId, noWait, noFollow, isJson);
|
|
76
|
+
return await this._runStatusNonInteractive(client, workspace, project, identifier, pipelineId, runId, noWait, noFollow, isJson, semanticExitCode);
|
|
38
77
|
}
|
|
39
78
|
static _canCancel(status) {
|
|
40
79
|
return ![
|
|
@@ -1082,19 +1121,39 @@ class OutputPipeline {
|
|
|
1082
1121
|
draw();
|
|
1083
1122
|
}, true);
|
|
1084
1123
|
}
|
|
1085
|
-
static
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1124
|
+
static runExitCode(status) {
|
|
1125
|
+
switch (status) {
|
|
1126
|
+
case pipeline_1.PIPELINE_RUN_STATUS.SUCCESSFUL:
|
|
1127
|
+
return cliError_1.SemanticExitCode.SUCCESS;
|
|
1128
|
+
case pipeline_1.PIPELINE_RUN_STATUS.FAILED:
|
|
1129
|
+
case pipeline_1.PIPELINE_RUN_STATUS.TERMINATED:
|
|
1130
|
+
case pipeline_1.PIPELINE_RUN_STATUS.SKIPPED:
|
|
1131
|
+
case pipeline_1.PIPELINE_RUN_STATUS.NOT_EXECUTED:
|
|
1132
|
+
return cliError_1.SemanticExitCode.FAILURE;
|
|
1133
|
+
case pipeline_1.PIPELINE_RUN_STATUS.INITIAL:
|
|
1134
|
+
case pipeline_1.PIPELINE_RUN_STATUS.ENQUEUED:
|
|
1135
|
+
case pipeline_1.PIPELINE_RUN_STATUS.INPROGRESS:
|
|
1136
|
+
case pipeline_1.PIPELINE_RUN_STATUS.TERMINATING:
|
|
1137
|
+
case pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_APPLY:
|
|
1138
|
+
case pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VARIABLES:
|
|
1139
|
+
case pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_SETTABLE_VARIABLES:
|
|
1140
|
+
case pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VT_SESSION:
|
|
1141
|
+
return cliError_1.SemanticExitCode.PENDING;
|
|
1142
|
+
default:
|
|
1143
|
+
throw new cliError_1.default('command_failed', (0, texts_1.ERR_PIPELINE_RUN_STATUS_UNKNOWN)(status));
|
|
1096
1144
|
}
|
|
1097
1145
|
}
|
|
1146
|
+
static _exitByStatus(isJson, status, semanticExitCode = false) {
|
|
1147
|
+
const code = semanticExitCode
|
|
1148
|
+
? this.runExitCode(status)
|
|
1149
|
+
: status === pipeline_1.PIPELINE_RUN_STATUS.FAILED ||
|
|
1150
|
+
status === pipeline_1.PIPELINE_RUN_STATUS.TERMINATED
|
|
1151
|
+
? 1
|
|
1152
|
+
: 0;
|
|
1153
|
+
if (isJson)
|
|
1154
|
+
this.jsonExit(code);
|
|
1155
|
+
output_1.default.exitCode(code);
|
|
1156
|
+
}
|
|
1098
1157
|
static jsonExit(code) {
|
|
1099
1158
|
output_1.default.json({ type: 'exit', code });
|
|
1100
1159
|
}
|
|
@@ -1124,7 +1183,7 @@ class OutputPipeline {
|
|
|
1124
1183
|
static jsonLog(log) {
|
|
1125
1184
|
output_1.default.json({ type: 'log', log });
|
|
1126
1185
|
}
|
|
1127
|
-
static async _runLogsNonInteractive(client, workspace, project, identifier, pipelineId, runId, runActionId, noWait, isJson) {
|
|
1186
|
+
static async _runLogsNonInteractive(client, workspace, project, identifier, pipelineId, runId, runActionId, noWait, isJson, semanticExitCode = false) {
|
|
1128
1187
|
let action = null;
|
|
1129
1188
|
let actionLogsStart = 0;
|
|
1130
1189
|
let lastActionLogsStart = -1;
|
|
@@ -1252,7 +1311,7 @@ class OutputPipeline {
|
|
|
1252
1311
|
}
|
|
1253
1312
|
}
|
|
1254
1313
|
}
|
|
1255
|
-
this._exitByStatus(isJson, action?.status);
|
|
1314
|
+
this._exitByStatus(isJson, action?.status, semanticExitCode);
|
|
1256
1315
|
}
|
|
1257
1316
|
};
|
|
1258
1317
|
this._actionLogsLoop(client, workspace, project, pipelineId, runId, runActionId, draw)
|
|
@@ -1263,10 +1322,12 @@ class OutputPipeline {
|
|
|
1263
1322
|
action = a;
|
|
1264
1323
|
totalFetchesCount += 1;
|
|
1265
1324
|
draw();
|
|
1325
|
+
if (semanticExitCode)
|
|
1326
|
+
this.runExitCode(a.status);
|
|
1266
1327
|
}
|
|
1267
|
-
});
|
|
1328
|
+
}, false, semanticExitCode);
|
|
1268
1329
|
}
|
|
1269
|
-
static async _runStatusNonInteractive(client, workspace, project, identifier, pipelineId, runId, noWait, noFollow, isJson) {
|
|
1330
|
+
static async _runStatusNonInteractive(client, workspace, project, identifier, pipelineId, runId, noWait, noFollow, isJson, semanticExitCode = false) {
|
|
1270
1331
|
let run = null;
|
|
1271
1332
|
let totalFetchesCount = 0;
|
|
1272
1333
|
const tabs = 40;
|
|
@@ -1342,10 +1403,25 @@ class OutputPipeline {
|
|
|
1342
1403
|
else
|
|
1343
1404
|
draw(run);
|
|
1344
1405
|
}
|
|
1406
|
+
if (semanticExitCode) {
|
|
1407
|
+
try {
|
|
1408
|
+
this.runExitCode(run.status);
|
|
1409
|
+
}
|
|
1410
|
+
catch (error) {
|
|
1411
|
+
// Even --no-follow must identify the run before reporting an unknown status.
|
|
1412
|
+
if (noFollow && !noWait) {
|
|
1413
|
+
if (isJson)
|
|
1414
|
+
this.jsonRun(identifier, run);
|
|
1415
|
+
else
|
|
1416
|
+
draw(run);
|
|
1417
|
+
}
|
|
1418
|
+
throw error;
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1345
1421
|
if (noWait) {
|
|
1346
|
-
this._exitByStatus(isJson, run.status);
|
|
1422
|
+
this._exitByStatus(isJson, run.status, semanticExitCode);
|
|
1347
1423
|
}
|
|
1348
|
-
});
|
|
1424
|
+
}, false, semanticExitCode);
|
|
1349
1425
|
if (isJson) {
|
|
1350
1426
|
this.jsonRun(identifier, run);
|
|
1351
1427
|
}
|
|
@@ -1389,7 +1465,7 @@ class OutputPipeline {
|
|
|
1389
1465
|
output_1.default.normal(this._dimLine());
|
|
1390
1466
|
output_1.default.normal(this._runActionsLogsHelp(identifier, runId));
|
|
1391
1467
|
}
|
|
1392
|
-
this._exitByStatus(isJson, run.status);
|
|
1468
|
+
this._exitByStatus(isJson, run.status, semanticExitCode);
|
|
1393
1469
|
}
|
|
1394
1470
|
static async _actionLogsLoop(client, workspace, project, pipelineId, runId, actionExecutionId, onChange) {
|
|
1395
1471
|
let logs = [];
|
|
@@ -1419,7 +1495,7 @@ class OutputPipeline {
|
|
|
1419
1495
|
await (0, utils_1.sleep)(3000);
|
|
1420
1496
|
}
|
|
1421
1497
|
}
|
|
1422
|
-
static async _actionStatusLoop(client, workspace, project, pipelineId, runId, actionExecutionId, onChange, dontExit = false) {
|
|
1498
|
+
static async _actionStatusLoop(client, workspace, project, pipelineId, runId, actionExecutionId, onChange, dontExit = false, semanticExitCode = false) {
|
|
1423
1499
|
const fetchAction = async () => {
|
|
1424
1500
|
return await client.getPipelineRunActionExecution(workspace, project, pipelineId, runId, actionExecutionId);
|
|
1425
1501
|
};
|
|
@@ -1437,7 +1513,9 @@ class OutputPipeline {
|
|
|
1437
1513
|
let finished = null;
|
|
1438
1514
|
if (a.finish_date)
|
|
1439
1515
|
finished = new Date(a.finish_date);
|
|
1440
|
-
status =
|
|
1516
|
+
status = semanticExitCode
|
|
1517
|
+
? a.status
|
|
1518
|
+
: a.status || pipeline_1.PIPELINE_RUN_STATUS.INITIAL;
|
|
1441
1519
|
const name = a.action?.name || '';
|
|
1442
1520
|
const actionId = a.action?.id || -1;
|
|
1443
1521
|
const url = a.html_url || '';
|
|
@@ -1514,7 +1592,7 @@ class OutputPipeline {
|
|
|
1514
1592
|
return;
|
|
1515
1593
|
}
|
|
1516
1594
|
}
|
|
1517
|
-
static async _runStatusLoop(client, workspace, project, pipelineId, runId, onChange, dontExit = false) {
|
|
1595
|
+
static async _runStatusLoop(client, workspace, project, pipelineId, runId, onChange, dontExit = false, semanticExitCode = false) {
|
|
1518
1596
|
let lastRun;
|
|
1519
1597
|
const fetchRun = async () => {
|
|
1520
1598
|
return await client.getPipelineRun(workspace, project, pipelineId, runId);
|
|
@@ -1537,7 +1615,9 @@ class OutputPipeline {
|
|
|
1537
1615
|
const run = await fetchRun();
|
|
1538
1616
|
started = new Date(run.start_date || new Date());
|
|
1539
1617
|
trigger = run.triggered_on || pipeline_1.PIPELINE_RUN_TRIGGER.CLICK;
|
|
1540
|
-
status =
|
|
1618
|
+
status = semanticExitCode
|
|
1619
|
+
? run.status
|
|
1620
|
+
: run.status || pipeline_1.PIPELINE_RUN_STATUS.INITIAL;
|
|
1541
1621
|
url = run.html_url;
|
|
1542
1622
|
if (run.creator) {
|
|
1543
1623
|
if (run.creator.name)
|
package/distTs/src/output.js
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
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
|
};
|
|
@@ -7,7 +40,7 @@ const texts_1 = require("./texts");
|
|
|
7
40
|
const utils_1 = require("./utils");
|
|
8
41
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
42
|
const node_readline_1 = require("node:readline");
|
|
10
|
-
const cliError_1 =
|
|
43
|
+
const cliError_1 = __importStar(require("./cliError"));
|
|
11
44
|
let _terminal = null;
|
|
12
45
|
function getTerminal() {
|
|
13
46
|
if (!_terminal) {
|
|
@@ -18,6 +51,7 @@ function getTerminal() {
|
|
|
18
51
|
}
|
|
19
52
|
class Output {
|
|
20
53
|
static errorFormat = 'text';
|
|
54
|
+
static errorExitCode = 1;
|
|
21
55
|
static s;
|
|
22
56
|
static _a;
|
|
23
57
|
static getCyanColor(text) {
|
|
@@ -693,11 +727,13 @@ class Output {
|
|
|
693
727
|
}
|
|
694
728
|
}
|
|
695
729
|
}
|
|
696
|
-
static exitError(err) {
|
|
730
|
+
static exitError(err, code = this.errorExitCode) {
|
|
731
|
+
if (code === cliError_1.SemanticExitCode.ERROR && cliError_1.default.details(err).code === 'not_found')
|
|
732
|
+
code = cliError_1.SemanticExitCode.NOT_FOUND;
|
|
697
733
|
this.clearUndici();
|
|
698
734
|
this.clearTerminal();
|
|
699
735
|
this.writeError(err);
|
|
700
|
-
process.exit(
|
|
736
|
+
process.exit(code);
|
|
701
737
|
}
|
|
702
738
|
static writeError(err, format = this.errorFormat) {
|
|
703
739
|
const error = cliError_1.default.details(err);
|