bdy 1.22.24-dev → 1.22.24-dev-pipeline
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 +110 -2
- package/distTs/src/command/pipeline/create.js +51 -0
- package/distTs/src/command/pipeline/delete.js +41 -0
- package/distTs/src/command/pipeline/get.js +51 -0
- package/distTs/src/command/pipeline/list.js +47 -0
- package/distTs/src/command/pipeline/run/apply.js +62 -0
- package/distTs/src/command/pipeline/run/approve.js +65 -0
- package/distTs/src/command/pipeline/run/cancel.js +39 -0
- package/distTs/src/command/pipeline/run/list.js +58 -0
- package/distTs/src/command/pipeline/run/logs.js +39 -0
- package/distTs/src/command/pipeline/run/retry.js +39 -0
- package/distTs/src/command/pipeline/run/start.js +99 -0
- package/distTs/src/command/pipeline/run/status.js +38 -0
- package/distTs/src/command/pipeline/run.js +22 -125
- package/distTs/src/command/pipeline/update.js +47 -0
- package/distTs/src/command/pipeline/yaml.js +38 -0
- package/distTs/src/command/pipeline.js +26 -0
- package/distTs/src/command/pre.js +1 -1
- package/distTs/src/command/project/link.js +11 -11
- package/distTs/src/input.js +11 -10
- package/distTs/src/output/pipeline.js +1695 -0
- package/distTs/src/output.js +156 -32
- package/distTs/src/texts.js +212 -169
- package/distTs/src/tunnel/output/interactive/tunnel.js +2 -2
- package/distTs/src/tunnel/tunnel.js +0 -24
- package/distTs/src/types/pipeline.js +424 -0
- package/package.json +1 -1
- package/distTs/src/command/project/get.js +0 -18
- package/distTs/src/command/project/set.js +0 -31
- package/distTs/src/command/sandbox/get/yaml.js +0 -30
- package/distTs/src/command/vt/scrape.js +0 -193
|
@@ -0,0 +1,1695 @@
|
|
|
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 output_1 = __importDefault(require("../output"));
|
|
7
|
+
const pipeline_1 = require("../types/pipeline");
|
|
8
|
+
const utils_1 = require("../utils");
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
const termkit_no_lazy_require_1 = __importDefault(require("terminal-kit/lib/termkit-no-lazy-require"));
|
|
11
|
+
var LOOP_STATUS;
|
|
12
|
+
(function (LOOP_STATUS) {
|
|
13
|
+
LOOP_STATUS["DISABLED"] = "DISABLED";
|
|
14
|
+
LOOP_STATUS["RESOLVED"] = "RESOLVED";
|
|
15
|
+
LOOP_STATUS["NO_LOOP"] = "NO_LOOP";
|
|
16
|
+
LOOP_STATUS["LIMIT_REACHED"] = "LIMIT_REACHED";
|
|
17
|
+
LOOP_STATUS["ERROR"] = "ERROR";
|
|
18
|
+
LOOP_STATUS["DYNAMIC"] = "DYNAMIC";
|
|
19
|
+
})(LOOP_STATUS || (LOOP_STATUS = {}));
|
|
20
|
+
var MODE;
|
|
21
|
+
(function (MODE) {
|
|
22
|
+
MODE["RUN"] = "RUN";
|
|
23
|
+
MODE["ACTION"] = "ACTION";
|
|
24
|
+
})(MODE || (MODE = {}));
|
|
25
|
+
const LOGS_LIMIT = 1000;
|
|
26
|
+
class OutputPipeline {
|
|
27
|
+
static async runLogs(client, workspace, project, pipelineId, runId, runActionId, noWait, isJson) {
|
|
28
|
+
if (output_1.default.isTTY() && !noWait && !isJson) {
|
|
29
|
+
return await this._runLogsInteractive(client, workspace, project, pipelineId, runId, runActionId);
|
|
30
|
+
}
|
|
31
|
+
return await this._runLogsNonInteractive(client, workspace, project, pipelineId, runId, runActionId, noWait, isJson);
|
|
32
|
+
}
|
|
33
|
+
static async runStatus(client, workspace, project, identifier, pipelineId, runId, noWait, noFollow, isJson) {
|
|
34
|
+
if (output_1.default.isTTY() && !noWait && !noFollow && !isJson) {
|
|
35
|
+
return await this._runStatusInteractive(client, workspace, project, pipelineId, runId);
|
|
36
|
+
}
|
|
37
|
+
return await this._runStatusNonInteractive(client, workspace, project, identifier, pipelineId, runId, noWait, noFollow, isJson);
|
|
38
|
+
}
|
|
39
|
+
static _canCancel(status) {
|
|
40
|
+
return ![
|
|
41
|
+
pipeline_1.PIPELINE_RUN_STATUS.SKIPPED,
|
|
42
|
+
pipeline_1.PIPELINE_RUN_STATUS.TERMINATED,
|
|
43
|
+
pipeline_1.PIPELINE_RUN_STATUS.TERMINATING,
|
|
44
|
+
pipeline_1.PIPELINE_RUN_STATUS.FAILED,
|
|
45
|
+
pipeline_1.PIPELINE_RUN_STATUS.NOT_EXECUTED,
|
|
46
|
+
pipeline_1.PIPELINE_RUN_STATUS.SUCCESSFUL,
|
|
47
|
+
].includes(status);
|
|
48
|
+
}
|
|
49
|
+
static _canRetry(status) {
|
|
50
|
+
return [
|
|
51
|
+
pipeline_1.PIPELINE_RUN_STATUS.TERMINATED,
|
|
52
|
+
pipeline_1.PIPELINE_RUN_STATUS.FAILED,
|
|
53
|
+
].includes(status);
|
|
54
|
+
}
|
|
55
|
+
static _canApprove(status) {
|
|
56
|
+
return [pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_APPLY].includes(status);
|
|
57
|
+
}
|
|
58
|
+
static _fillString(str, length) {
|
|
59
|
+
if (str.length >= length - 1)
|
|
60
|
+
return str.substring(0, length - 1) + ' ';
|
|
61
|
+
for (let i = str.length; i < length; i += 1)
|
|
62
|
+
str += ' ';
|
|
63
|
+
return str;
|
|
64
|
+
}
|
|
65
|
+
static _makeSpaces(length) {
|
|
66
|
+
let str = '';
|
|
67
|
+
for (let i = 0; i < length; i += 1)
|
|
68
|
+
str += ' ';
|
|
69
|
+
return str;
|
|
70
|
+
}
|
|
71
|
+
static _formatDate(date) {
|
|
72
|
+
let str = `${date.getFullYear()}-`;
|
|
73
|
+
const m = date.getMonth() + 1;
|
|
74
|
+
if (m < 10)
|
|
75
|
+
str += '0';
|
|
76
|
+
str += `${m}-`;
|
|
77
|
+
const d = date.getDate();
|
|
78
|
+
if (d < 10)
|
|
79
|
+
str += '0';
|
|
80
|
+
str += `${d} `;
|
|
81
|
+
const h = date.getHours();
|
|
82
|
+
if (h < 10)
|
|
83
|
+
str += '0';
|
|
84
|
+
str += `${h}:`;
|
|
85
|
+
const mm = date.getMinutes();
|
|
86
|
+
if (mm < 10)
|
|
87
|
+
str += '0';
|
|
88
|
+
str += `${mm}:`;
|
|
89
|
+
const s = date.getSeconds();
|
|
90
|
+
if (s < 10)
|
|
91
|
+
str += '0';
|
|
92
|
+
str += s;
|
|
93
|
+
return str;
|
|
94
|
+
}
|
|
95
|
+
static _formatTimespan(start, end) {
|
|
96
|
+
if (!end)
|
|
97
|
+
end = new Date();
|
|
98
|
+
let ts = Math.abs(end.getTime() - start.getTime());
|
|
99
|
+
if (!ts)
|
|
100
|
+
return '';
|
|
101
|
+
const hours = Math.floor(ts / 1000 / 60 / 60);
|
|
102
|
+
ts -= hours * 60 * 60 * 1000;
|
|
103
|
+
const minutes = Math.floor(ts / 1000 / 60);
|
|
104
|
+
ts -= minutes * 60 * 1000;
|
|
105
|
+
const seconds = Math.ceil(ts / 1000);
|
|
106
|
+
let str = '';
|
|
107
|
+
if (hours > 0)
|
|
108
|
+
str += `${hours}h `;
|
|
109
|
+
if (minutes > 0 || hours > 0)
|
|
110
|
+
str += `${minutes}m `;
|
|
111
|
+
if (seconds < 10 && (hours > 0 || minutes > 0))
|
|
112
|
+
str += '0';
|
|
113
|
+
str += `${seconds}s`;
|
|
114
|
+
return str;
|
|
115
|
+
}
|
|
116
|
+
static _runDetailsHeader() {
|
|
117
|
+
return `${output_1.default.getTermKitBlueColor('/')} ${output_1.default.getTermKitLabelColor('DETAILS')}`;
|
|
118
|
+
}
|
|
119
|
+
static _runLogsHeader() {
|
|
120
|
+
return `${output_1.default.getTermKitBlueColor('/')} ${output_1.default.getTermKitLabelColor('LOGS')}`;
|
|
121
|
+
}
|
|
122
|
+
static _runOutputHeader() {
|
|
123
|
+
return `${output_1.default.getTermKitBlueColor('/')} ${output_1.default.getTermKitLabelColor('OUTPUT')}`;
|
|
124
|
+
}
|
|
125
|
+
static _runDetailsStarted(status, started, delayed, tabs) {
|
|
126
|
+
if (delayed && status === pipeline_1.PIPELINE_RUN_STATUS.ENQUEUED) {
|
|
127
|
+
let str = ` ${output_1.default.getTermKitDimColor(this._fillString('Scheduled', tabs))}`;
|
|
128
|
+
str += output_1.default.getTermKitMutedColor(this._formatDate(delayed || new Date()));
|
|
129
|
+
return str;
|
|
130
|
+
}
|
|
131
|
+
if ([
|
|
132
|
+
pipeline_1.PIPELINE_RUN_STATUS.TERMINATED,
|
|
133
|
+
pipeline_1.PIPELINE_RUN_STATUS.TERMINATING,
|
|
134
|
+
pipeline_1.PIPELINE_RUN_STATUS.SUCCESSFUL,
|
|
135
|
+
pipeline_1.PIPELINE_RUN_STATUS.FAILED,
|
|
136
|
+
pipeline_1.PIPELINE_RUN_STATUS.INPROGRESS,
|
|
137
|
+
pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_APPLY,
|
|
138
|
+
pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_SETTABLE_VARIABLES,
|
|
139
|
+
pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VARIABLES,
|
|
140
|
+
pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VT_SESSION,
|
|
141
|
+
].includes(status)) {
|
|
142
|
+
let str = ` ${output_1.default.getTermKitDimColor(this._fillString('Started', tabs))}`;
|
|
143
|
+
str += output_1.default.getTermKitMutedColor(this._formatDate(started || new Date()));
|
|
144
|
+
return str;
|
|
145
|
+
}
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
static _runActionsHeader(tabs) {
|
|
149
|
+
return `${output_1.default.getTermKitBlueColor('/')} ${output_1.default.getTermKitLabelColor(this._fillString('ACTIONS', 3 * tabs))} ${output_1.default.getTermKitLabelColor('ID')}`;
|
|
150
|
+
}
|
|
151
|
+
static _actionLogs(logs, scroll, limit = 0) {
|
|
152
|
+
const str = [];
|
|
153
|
+
if (logs.length > 0) {
|
|
154
|
+
let start = logs.length - scroll - limit;
|
|
155
|
+
if (start < 0)
|
|
156
|
+
start = 0;
|
|
157
|
+
let end = start + limit;
|
|
158
|
+
if (end > logs.length)
|
|
159
|
+
end = logs.length;
|
|
160
|
+
for (let i = start; i < end; i += 1) {
|
|
161
|
+
str.push(`${output_1.default.getTermKitDimColor(logs[i])}`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
str.push(` ${output_1.default.getTermKitDimColor('Waiting...')}`);
|
|
166
|
+
}
|
|
167
|
+
return str;
|
|
168
|
+
}
|
|
169
|
+
static _getActionLoop(action, highlight, tabs) {
|
|
170
|
+
let outer = '[';
|
|
171
|
+
let dim = false;
|
|
172
|
+
let red = false;
|
|
173
|
+
if (action.loop === LOOP_STATUS.DYNAMIC) {
|
|
174
|
+
outer += 'Loop';
|
|
175
|
+
dim = true;
|
|
176
|
+
}
|
|
177
|
+
else if (action.loop === LOOP_STATUS.RESOLVED) {
|
|
178
|
+
outer += 'Loop';
|
|
179
|
+
}
|
|
180
|
+
else if (action.loop !== LOOP_STATUS.DISABLED) {
|
|
181
|
+
red = true;
|
|
182
|
+
outer += 'Loop';
|
|
183
|
+
}
|
|
184
|
+
if (action.target) {
|
|
185
|
+
if (action.loop !== LOOP_STATUS.DISABLED)
|
|
186
|
+
outer += ', ';
|
|
187
|
+
outer += action.target;
|
|
188
|
+
}
|
|
189
|
+
if (outer.length + 2 >= tabs) {
|
|
190
|
+
outer = outer.substring(0, tabs - 2);
|
|
191
|
+
}
|
|
192
|
+
outer += ']';
|
|
193
|
+
outer = this._fillString(outer, tabs);
|
|
194
|
+
if (highlight) {
|
|
195
|
+
return output_1.default.getTermKitCyanColor(outer);
|
|
196
|
+
}
|
|
197
|
+
if (red) {
|
|
198
|
+
return output_1.default.getTermKitRedColor(outer);
|
|
199
|
+
}
|
|
200
|
+
if (dim) {
|
|
201
|
+
return output_1.default.getTermKitDimColor(outer);
|
|
202
|
+
}
|
|
203
|
+
return output_1.default.getTermKitArgColor(outer);
|
|
204
|
+
}
|
|
205
|
+
static _getActionName(action, highlight, tabs) {
|
|
206
|
+
let s = '';
|
|
207
|
+
let name = action.name || '';
|
|
208
|
+
if (name.length + 1 >= tabs)
|
|
209
|
+
name = name.substring(0, tabs - 1);
|
|
210
|
+
if (highlight) {
|
|
211
|
+
s += output_1.default.getTermKitCyanColor(name);
|
|
212
|
+
}
|
|
213
|
+
else if ([
|
|
214
|
+
pipeline_1.PIPELINE_RUN_STATUS.INPROGRESS,
|
|
215
|
+
pipeline_1.PIPELINE_RUN_STATUS.TERMINATING,
|
|
216
|
+
].includes(action.status)) {
|
|
217
|
+
s += output_1.default.getTermKitBlueColor(name);
|
|
218
|
+
}
|
|
219
|
+
else if ([
|
|
220
|
+
pipeline_1.PIPELINE_RUN_STATUS.INITIAL,
|
|
221
|
+
pipeline_1.PIPELINE_RUN_STATUS.ENQUEUED,
|
|
222
|
+
pipeline_1.PIPELINE_RUN_STATUS.NOT_EXECUTED,
|
|
223
|
+
pipeline_1.PIPELINE_RUN_STATUS.SKIPPED,
|
|
224
|
+
].includes(action.status)) {
|
|
225
|
+
s += output_1.default.getTermKitDimColor(name);
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
s += output_1.default.getTermKitMutedColor(name);
|
|
229
|
+
}
|
|
230
|
+
const loopLength = tabs - name.length;
|
|
231
|
+
if (action.loopValues.length > 0 && loopLength >= 5) {
|
|
232
|
+
let loop = ' [';
|
|
233
|
+
action.loopValues.forEach((v, i) => {
|
|
234
|
+
if (i > 0)
|
|
235
|
+
loop += ', ';
|
|
236
|
+
loop += `${v.value}`;
|
|
237
|
+
});
|
|
238
|
+
if (loop.length > loopLength - 2) {
|
|
239
|
+
loop = loop.substring(0, loopLength - 2);
|
|
240
|
+
}
|
|
241
|
+
loop += ']';
|
|
242
|
+
if (highlight) {
|
|
243
|
+
s += output_1.default.getTermKitCyanColor(loop);
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
s += output_1.default.getTermKitArgColor(loop);
|
|
247
|
+
}
|
|
248
|
+
s += this._fillString('', loopLength - loop.length + 1);
|
|
249
|
+
}
|
|
250
|
+
else if (loopLength > 0) {
|
|
251
|
+
s += this._fillString('', loopLength + 1);
|
|
252
|
+
}
|
|
253
|
+
return s;
|
|
254
|
+
}
|
|
255
|
+
static _getActionType(action, highlight, tabs) {
|
|
256
|
+
let s = '';
|
|
257
|
+
let l = action.type.length;
|
|
258
|
+
if (highlight) {
|
|
259
|
+
s += output_1.default.getTermKitCyanColor('❯ ');
|
|
260
|
+
s += output_1.default.getTermKitCyanColor(action.type);
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
s += ' ';
|
|
264
|
+
s += output_1.default.getTermKitDimColor(action.type);
|
|
265
|
+
}
|
|
266
|
+
if (tabs - l > 6 &&
|
|
267
|
+
(action.target || action.loop !== LOOP_STATUS.DISABLED)) {
|
|
268
|
+
l += 1;
|
|
269
|
+
s += ' ';
|
|
270
|
+
s += this._getActionLoop(action, highlight, tabs - l);
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
s += this._makeSpaces(tabs - l);
|
|
274
|
+
}
|
|
275
|
+
return s;
|
|
276
|
+
}
|
|
277
|
+
static _runActions(run, onlyChanged = false, limit, selected, tabs) {
|
|
278
|
+
const str = [];
|
|
279
|
+
if (!run)
|
|
280
|
+
return str;
|
|
281
|
+
if (!onlyChanged) {
|
|
282
|
+
str.push(this._runActionsHeader(tabs));
|
|
283
|
+
}
|
|
284
|
+
let count = 0;
|
|
285
|
+
let start = 0;
|
|
286
|
+
if (selected >= limit / 2) {
|
|
287
|
+
start = selected - Math.floor(limit / 2);
|
|
288
|
+
if (start + limit >= run.actions.length) {
|
|
289
|
+
start = run.actions.length - limit;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
for (let i = start; i < run.actions.length; i += 1) {
|
|
293
|
+
const a = run.actions[i];
|
|
294
|
+
if (!a || (onlyChanged && !a.changed))
|
|
295
|
+
continue;
|
|
296
|
+
let s = '';
|
|
297
|
+
const highlight = i === selected;
|
|
298
|
+
s += this._getActionType(a, highlight, tabs);
|
|
299
|
+
s += this._getActionName(a, highlight, 2 * tabs);
|
|
300
|
+
if (![
|
|
301
|
+
pipeline_1.PIPELINE_RUN_STATUS.ENQUEUED,
|
|
302
|
+
pipeline_1.PIPELINE_RUN_STATUS.INITIAL,
|
|
303
|
+
pipeline_1.PIPELINE_RUN_STATUS.SKIPPED,
|
|
304
|
+
pipeline_1.PIPELINE_RUN_STATUS.NOT_EXECUTED,
|
|
305
|
+
].includes(a.status)) {
|
|
306
|
+
if (highlight) {
|
|
307
|
+
s += output_1.default.getTermKitCyanColor(this._fillString(a.runId, 25));
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
s += output_1.default.getTermKitDimColor(this._fillString(a.runId, 25));
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
s += this._fillString('', 25);
|
|
315
|
+
}
|
|
316
|
+
let ts = false;
|
|
317
|
+
const txt = this.runStatusText(a.status);
|
|
318
|
+
if (a.status === pipeline_1.PIPELINE_RUN_STATUS.INPROGRESS) {
|
|
319
|
+
if (onlyChanged) {
|
|
320
|
+
s += output_1.default.getTermKitBlueColor(pipeline_1.PIPELINE_STATUS_ICONS.INPROGRESS);
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
s += output_1.default.getTermKitBlueColor(this._statusAnimationString());
|
|
324
|
+
}
|
|
325
|
+
ts = true;
|
|
326
|
+
}
|
|
327
|
+
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.ENQUEUED) {
|
|
328
|
+
s += output_1.default.getTermKitDimColor(pipeline_1.PIPELINE_STATUS_ICONS.ENQUEUED);
|
|
329
|
+
s += ` ${output_1.default.getTermKitDimColor(txt)}`;
|
|
330
|
+
}
|
|
331
|
+
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.TERMINATED) {
|
|
332
|
+
s += output_1.default.getTermKitRedColor(pipeline_1.PIPELINE_STATUS_ICONS.TERMINATED);
|
|
333
|
+
ts = true;
|
|
334
|
+
}
|
|
335
|
+
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.SUCCESSFUL) {
|
|
336
|
+
s += output_1.default.getTermKitGreenColor(pipeline_1.PIPELINE_STATUS_ICONS.SUCCESSFUL);
|
|
337
|
+
ts = true;
|
|
338
|
+
}
|
|
339
|
+
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.FAILED) {
|
|
340
|
+
s += output_1.default.getTermKitRedColor(pipeline_1.PIPELINE_STATUS_ICONS.FAILED);
|
|
341
|
+
ts = true;
|
|
342
|
+
}
|
|
343
|
+
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.INITIAL) {
|
|
344
|
+
s += output_1.default.getTermKitDimColor(pipeline_1.PIPELINE_STATUS_ICONS.INITIAL);
|
|
345
|
+
s += ` ${output_1.default.getTermKitDimColor(txt)}`;
|
|
346
|
+
}
|
|
347
|
+
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.NOT_EXECUTED) {
|
|
348
|
+
s += output_1.default.getTermKitDimColor(pipeline_1.PIPELINE_STATUS_ICONS.NOT_EXECUTED);
|
|
349
|
+
s += ` ${output_1.default.getTermKitDimColor(txt)}`;
|
|
350
|
+
}
|
|
351
|
+
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.SKIPPED) {
|
|
352
|
+
s += output_1.default.getTermKitDimColor(pipeline_1.PIPELINE_STATUS_ICONS.SKIPPED);
|
|
353
|
+
s += ` ${output_1.default.getTermKitDimColor(txt)}`;
|
|
354
|
+
}
|
|
355
|
+
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.TERMINATING) {
|
|
356
|
+
if (onlyChanged) {
|
|
357
|
+
s += output_1.default.getTermKitDimColor(pipeline_1.PIPELINE_STATUS_ICONS.TERMINATING);
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
s += output_1.default.getTermKitBlueColor(this._statusAnimationString());
|
|
361
|
+
}
|
|
362
|
+
ts = true;
|
|
363
|
+
}
|
|
364
|
+
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_APPLY) {
|
|
365
|
+
s += output_1.default.getTermKitPurpleColor(pipeline_1.PIPELINE_STATUS_ICONS.WAITING_FOR_APPLY);
|
|
366
|
+
s += ` ${output_1.default.getTermKitPurpleColor(txt)}`;
|
|
367
|
+
}
|
|
368
|
+
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VARIABLES) {
|
|
369
|
+
s += output_1.default.getTermKitPurpleColor(pipeline_1.PIPELINE_STATUS_ICONS.WAITING_FOR_VARIABLES);
|
|
370
|
+
s += ` ${output_1.default.getTermKitPurpleColor(txt)}`;
|
|
371
|
+
}
|
|
372
|
+
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_SETTABLE_VARIABLES) {
|
|
373
|
+
s += output_1.default.getTermKitPurpleColor(pipeline_1.PIPELINE_STATUS_ICONS.WAITING_FOR_SETTABLE_VARIABLES);
|
|
374
|
+
s += ` ${output_1.default.getTermKitPurpleColor(txt)}`;
|
|
375
|
+
}
|
|
376
|
+
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VT_SESSION) {
|
|
377
|
+
s += output_1.default.getTermKitPurpleColor(pipeline_1.PIPELINE_STATUS_ICONS.WAITING_FOR_VT_SESSION);
|
|
378
|
+
s += ` ${output_1.default.getTermKitPurpleColor(txt)}`;
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
s += output_1.default.getTermKitDimColor(pipeline_1.PIPELINE_STATUS_ICONS.SKIPPED);
|
|
382
|
+
s += ` ${output_1.default.getTermKitDimColor(a.status)}`;
|
|
383
|
+
}
|
|
384
|
+
if (ts && a.started) {
|
|
385
|
+
s += ` ${output_1.default.getTermKitMutedColor(this._formatTimespan(a.started, a.finished))}`;
|
|
386
|
+
}
|
|
387
|
+
str.push(s);
|
|
388
|
+
count += 1;
|
|
389
|
+
if (limit && count >= limit)
|
|
390
|
+
break;
|
|
391
|
+
}
|
|
392
|
+
return str;
|
|
393
|
+
}
|
|
394
|
+
static _runContext(run, tabs) {
|
|
395
|
+
const str = [];
|
|
396
|
+
if (run?.context) {
|
|
397
|
+
str.push(`${output_1.default.getTermKitBlueColor('/')} ${output_1.default.getTermKitLabelColor('CONTEXT')}`);
|
|
398
|
+
const ctx = run.context;
|
|
399
|
+
Object.keys(ctx).forEach((name) => {
|
|
400
|
+
str.push(` ${output_1.default.getTermKitDimColor(this._fillString(name, tabs))}${output_1.default.getTermKitMutedColor(ctx[name])}`);
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
return str;
|
|
404
|
+
}
|
|
405
|
+
static _runActionTarget(action, tabs) {
|
|
406
|
+
if (!action.target)
|
|
407
|
+
return null;
|
|
408
|
+
let str = ` ${output_1.default.getTermKitDimColor(this._fillString('Target', tabs))}`;
|
|
409
|
+
str += output_1.default.getTermKitMutedColor(action.target);
|
|
410
|
+
return str;
|
|
411
|
+
}
|
|
412
|
+
static _runLoopText(loop, variables) {
|
|
413
|
+
if (loop === LOOP_STATUS.NO_LOOP) {
|
|
414
|
+
return 'Not found';
|
|
415
|
+
}
|
|
416
|
+
else if (loop === LOOP_STATUS.LIMIT_REACHED) {
|
|
417
|
+
return 'Limit reached';
|
|
418
|
+
}
|
|
419
|
+
else if (loop === LOOP_STATUS.ERROR) {
|
|
420
|
+
return 'Something went wrong';
|
|
421
|
+
}
|
|
422
|
+
else if (loop === LOOP_STATUS.DYNAMIC) {
|
|
423
|
+
return 'Not calculated yet';
|
|
424
|
+
}
|
|
425
|
+
else if (!variables.length) {
|
|
426
|
+
return 'No variables resolved';
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
let vars = '';
|
|
430
|
+
variables.forEach((v, i) => {
|
|
431
|
+
if (i > 0)
|
|
432
|
+
vars += ', ';
|
|
433
|
+
vars += `${v.key}:${v.value}`;
|
|
434
|
+
});
|
|
435
|
+
return vars;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
static _runLoopVariables(loop, variables, tabs) {
|
|
439
|
+
if (loop === LOOP_STATUS.DISABLED)
|
|
440
|
+
return null;
|
|
441
|
+
let str = ` ${output_1.default.getTermKitDimColor(this._fillString('Loop', tabs))}`;
|
|
442
|
+
const txt = this._runLoopText(loop, variables);
|
|
443
|
+
if (loop === LOOP_STATUS.NO_LOOP) {
|
|
444
|
+
str += output_1.default.getTermKitRedColor(txt);
|
|
445
|
+
}
|
|
446
|
+
else if (loop === LOOP_STATUS.LIMIT_REACHED) {
|
|
447
|
+
str += output_1.default.getTermKitRedColor(txt);
|
|
448
|
+
}
|
|
449
|
+
else if (loop === LOOP_STATUS.ERROR) {
|
|
450
|
+
str += output_1.default.getTermKitRedColor(txt);
|
|
451
|
+
}
|
|
452
|
+
else if (loop === LOOP_STATUS.DYNAMIC) {
|
|
453
|
+
str += output_1.default.getTermKitDimColor(txt);
|
|
454
|
+
}
|
|
455
|
+
else if (!variables.length) {
|
|
456
|
+
str += output_1.default.getTermKitMutedColor(txt);
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
str += output_1.default.getTermKitMutedColor(txt);
|
|
460
|
+
}
|
|
461
|
+
return str;
|
|
462
|
+
}
|
|
463
|
+
static _dimLine() {
|
|
464
|
+
const termWidth = termkit_no_lazy_require_1.default.terminal.width;
|
|
465
|
+
const width = Number.isFinite(termWidth) && termWidth > 2 ? termWidth - 2 : 25;
|
|
466
|
+
return output_1.default.getTermKitDimColor(` ${'—'.repeat(width)}`);
|
|
467
|
+
}
|
|
468
|
+
static _runActionsLogsHelp(identifier, runId) {
|
|
469
|
+
return `${output_1.default.getTermKitDimColor(' To view action logs run: ')}${output_1.default.getTermKitMutedColor(`bdy pip run logs ${identifier} ${runId} <action-run-id>`)}`;
|
|
470
|
+
}
|
|
471
|
+
static _jsonActionsLogsHelp(identifier, runId) {
|
|
472
|
+
return `To view action logs run: \`bdy pip run logs ${identifier} ${runId} <action-run-id>\``;
|
|
473
|
+
}
|
|
474
|
+
static _runDetailsFinished(status, finished, tabs) {
|
|
475
|
+
if (finished &&
|
|
476
|
+
[
|
|
477
|
+
pipeline_1.PIPELINE_RUN_STATUS.FAILED,
|
|
478
|
+
pipeline_1.PIPELINE_RUN_STATUS.SUCCESSFUL,
|
|
479
|
+
pipeline_1.PIPELINE_RUN_STATUS.TERMINATED,
|
|
480
|
+
].includes(status)) {
|
|
481
|
+
let str = ` ${output_1.default.getTermKitDimColor(this._fillString('Finished', tabs))}`;
|
|
482
|
+
str += output_1.default.getTermKitMutedColor(this._formatDate(finished));
|
|
483
|
+
return str;
|
|
484
|
+
}
|
|
485
|
+
return null;
|
|
486
|
+
}
|
|
487
|
+
static _runDetailsTriggerer(run, tabs) {
|
|
488
|
+
let str = ` ${output_1.default.getTermKitDimColor(this._fillString('Trigger', tabs))}`;
|
|
489
|
+
if (run?.creator) {
|
|
490
|
+
str += `${output_1.default.getTermKitBlueColor(run.creator)} - `;
|
|
491
|
+
}
|
|
492
|
+
if (!run || run.trigger === pipeline_1.PIPELINE_RUN_TRIGGER.CLICK) {
|
|
493
|
+
str += output_1.default.getTermKitMutedColor('Manual');
|
|
494
|
+
}
|
|
495
|
+
else if (run.trigger === pipeline_1.PIPELINE_RUN_TRIGGER.SCHEDULE) {
|
|
496
|
+
str += output_1.default.getTermKitMutedColor('Schedule');
|
|
497
|
+
}
|
|
498
|
+
else if (run.trigger === pipeline_1.PIPELINE_RUN_TRIGGER.EVENT) {
|
|
499
|
+
str += output_1.default.getTermKitMutedColor('Event');
|
|
500
|
+
}
|
|
501
|
+
else if (run.trigger === pipeline_1.PIPELINE_RUN_TRIGGER.PIPELINE) {
|
|
502
|
+
str += output_1.default.getTermKitMutedColor('Pipeline');
|
|
503
|
+
}
|
|
504
|
+
else if (run.trigger === pipeline_1.PIPELINE_RUN_TRIGGER.WEBHOOK) {
|
|
505
|
+
str += output_1.default.getTermKitMutedColor('Webhook');
|
|
506
|
+
}
|
|
507
|
+
else if (run.trigger === pipeline_1.PIPELINE_RUN_TRIGGER.EMAIL) {
|
|
508
|
+
str += output_1.default.getTermKitMutedColor('Email');
|
|
509
|
+
}
|
|
510
|
+
else {
|
|
511
|
+
str += run.trigger;
|
|
512
|
+
}
|
|
513
|
+
if (run?.priority === pipeline_1.PIPELINE_PRIORITY.HIGH) {
|
|
514
|
+
str += output_1.default.getTermKitMutedColor(', High');
|
|
515
|
+
}
|
|
516
|
+
else if (run?.priority === pipeline_1.PIPELINE_PRIORITY.LOW) {
|
|
517
|
+
str += output_1.default.getTermKitMutedColor(', Low');
|
|
518
|
+
}
|
|
519
|
+
if (run?.refresh) {
|
|
520
|
+
str += output_1.default.getTermKitMutedColor(', From scratch');
|
|
521
|
+
}
|
|
522
|
+
if (run?.clearCache) {
|
|
523
|
+
str += output_1.default.getTermKitMutedColor(', Clear cache');
|
|
524
|
+
}
|
|
525
|
+
return str;
|
|
526
|
+
}
|
|
527
|
+
static _runDetailsDescription(run, tabs) {
|
|
528
|
+
let str = ` ${output_1.default.getTermKitDimColor(this._fillString('Description', tabs))}`;
|
|
529
|
+
str += output_1.default.getTermKitMutedColor(run?.description || '');
|
|
530
|
+
return str;
|
|
531
|
+
}
|
|
532
|
+
static _statusAnimationIndex = 0;
|
|
533
|
+
static _statusAnimationTs;
|
|
534
|
+
static _statusAnimationString() {
|
|
535
|
+
const opts = pipeline_1.PIPELINE_STATUS_PROGRESS_ANIMATION;
|
|
536
|
+
if (!this._statusAnimationTs) {
|
|
537
|
+
this._statusAnimationTs = setInterval(() => {
|
|
538
|
+
this._statusAnimationIndex += 1;
|
|
539
|
+
if (this._statusAnimationIndex > opts.length - 1)
|
|
540
|
+
this._statusAnimationIndex = 0;
|
|
541
|
+
}, 100);
|
|
542
|
+
}
|
|
543
|
+
return opts[this._statusAnimationIndex];
|
|
544
|
+
}
|
|
545
|
+
static _runHtmlUrl(htmlUrl, tabs) {
|
|
546
|
+
let str = ` ${output_1.default.getTermKitDimColor(this._fillString('URL', tabs))}`;
|
|
547
|
+
str += output_1.default.getTermKitMutedColor(htmlUrl);
|
|
548
|
+
return str;
|
|
549
|
+
}
|
|
550
|
+
static _runDetailsId(id, tabs) {
|
|
551
|
+
let str = ` ${output_1.default.getTermKitDimColor(this._fillString('ID', tabs))}`;
|
|
552
|
+
str += output_1.default.getTermKitMutedColor(String(id));
|
|
553
|
+
return str;
|
|
554
|
+
}
|
|
555
|
+
static runStatusText(status) {
|
|
556
|
+
if (status === pipeline_1.PIPELINE_RUN_STATUS.INITIAL) {
|
|
557
|
+
return 'Created';
|
|
558
|
+
}
|
|
559
|
+
else if (status === pipeline_1.PIPELINE_RUN_STATUS.INPROGRESS) {
|
|
560
|
+
return 'Running';
|
|
561
|
+
}
|
|
562
|
+
else if (status === pipeline_1.PIPELINE_RUN_STATUS.ENQUEUED) {
|
|
563
|
+
return 'Queued';
|
|
564
|
+
}
|
|
565
|
+
else if (status === pipeline_1.PIPELINE_RUN_STATUS.TERMINATED) {
|
|
566
|
+
return 'Canceled';
|
|
567
|
+
}
|
|
568
|
+
else if (status === pipeline_1.PIPELINE_RUN_STATUS.SUCCESSFUL) {
|
|
569
|
+
return 'Passed';
|
|
570
|
+
}
|
|
571
|
+
else if (status === pipeline_1.PIPELINE_RUN_STATUS.FAILED) {
|
|
572
|
+
return 'Failed';
|
|
573
|
+
}
|
|
574
|
+
else if (status === pipeline_1.PIPELINE_RUN_STATUS.NOT_EXECUTED) {
|
|
575
|
+
return 'Created';
|
|
576
|
+
}
|
|
577
|
+
else if (status === pipeline_1.PIPELINE_RUN_STATUS.SKIPPED) {
|
|
578
|
+
return 'Skipped';
|
|
579
|
+
}
|
|
580
|
+
else if (status === pipeline_1.PIPELINE_RUN_STATUS.TERMINATING) {
|
|
581
|
+
return 'Canceling';
|
|
582
|
+
}
|
|
583
|
+
else if ([
|
|
584
|
+
pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VT_SESSION,
|
|
585
|
+
pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_SETTABLE_VARIABLES,
|
|
586
|
+
pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VARIABLES,
|
|
587
|
+
pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_APPLY,
|
|
588
|
+
].includes(status)) {
|
|
589
|
+
return 'Awaiting';
|
|
590
|
+
}
|
|
591
|
+
else {
|
|
592
|
+
return status;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
static _runDetailsStatus(status, started, finished, tabs) {
|
|
596
|
+
let str = ` ${output_1.default.getTermKitDimColor(this._fillString('Status', tabs))}`;
|
|
597
|
+
let ts = false;
|
|
598
|
+
const txt = this.runStatusText(status);
|
|
599
|
+
if (status === pipeline_1.PIPELINE_RUN_STATUS.INITIAL) {
|
|
600
|
+
str += output_1.default.getTermKitDimColor(txt);
|
|
601
|
+
}
|
|
602
|
+
else if (status === pipeline_1.PIPELINE_RUN_STATUS.INPROGRESS) {
|
|
603
|
+
str += output_1.default.getTermKitBlueColor(txt);
|
|
604
|
+
ts = true;
|
|
605
|
+
}
|
|
606
|
+
else if (status === pipeline_1.PIPELINE_RUN_STATUS.ENQUEUED) {
|
|
607
|
+
str += output_1.default.getTermKitDimColor(txt);
|
|
608
|
+
}
|
|
609
|
+
else if (status === pipeline_1.PIPELINE_RUN_STATUS.TERMINATED) {
|
|
610
|
+
str += output_1.default.getTermKitRedColor(txt);
|
|
611
|
+
ts = true;
|
|
612
|
+
}
|
|
613
|
+
else if (status === pipeline_1.PIPELINE_RUN_STATUS.SUCCESSFUL) {
|
|
614
|
+
str += output_1.default.getTermKitGreenColor(txt);
|
|
615
|
+
ts = true;
|
|
616
|
+
}
|
|
617
|
+
else if (status === pipeline_1.PIPELINE_RUN_STATUS.FAILED) {
|
|
618
|
+
str += output_1.default.getTermKitRedColor(txt);
|
|
619
|
+
ts = true;
|
|
620
|
+
}
|
|
621
|
+
else if (status === pipeline_1.PIPELINE_RUN_STATUS.NOT_EXECUTED) {
|
|
622
|
+
str += output_1.default.getTermKitDimColor(txt);
|
|
623
|
+
}
|
|
624
|
+
else if (status === pipeline_1.PIPELINE_RUN_STATUS.SKIPPED) {
|
|
625
|
+
str += output_1.default.getTermKitDimColor(txt);
|
|
626
|
+
}
|
|
627
|
+
else if (status === pipeline_1.PIPELINE_RUN_STATUS.TERMINATING) {
|
|
628
|
+
str += output_1.default.getTermKitBlueColor(txt);
|
|
629
|
+
ts = true;
|
|
630
|
+
}
|
|
631
|
+
else if ([
|
|
632
|
+
pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VT_SESSION,
|
|
633
|
+
pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_SETTABLE_VARIABLES,
|
|
634
|
+
pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VARIABLES,
|
|
635
|
+
pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_APPLY,
|
|
636
|
+
].includes(status)) {
|
|
637
|
+
str += output_1.default.getTermKitPurpleColor(txt);
|
|
638
|
+
}
|
|
639
|
+
else {
|
|
640
|
+
str += output_1.default.getTermKitMutedColor(status);
|
|
641
|
+
}
|
|
642
|
+
if (ts && started) {
|
|
643
|
+
str += ` ${output_1.default.getTermKitDimColor(this._formatTimespan(started, finished))}`;
|
|
644
|
+
}
|
|
645
|
+
return str;
|
|
646
|
+
}
|
|
647
|
+
static _runInteractiveHelp(run) {
|
|
648
|
+
let help = output_1.default.getTermKitLabelColor('↑↓');
|
|
649
|
+
help += output_1.default.getTermKitDimColor(' navigate •');
|
|
650
|
+
help += output_1.default.getTermKitLabelColor(' ⏎');
|
|
651
|
+
help += output_1.default.getTermKitDimColor(' view logs •');
|
|
652
|
+
if (this._canCancel(run.status)) {
|
|
653
|
+
help += output_1.default.getTermKitLabelColor(' c');
|
|
654
|
+
help += output_1.default.getTermKitDimColor(' cancel •');
|
|
655
|
+
}
|
|
656
|
+
if (this._canRetry(run.status)) {
|
|
657
|
+
help += output_1.default.getTermKitLabelColor(' r');
|
|
658
|
+
help += output_1.default.getTermKitDimColor(' retry •');
|
|
659
|
+
}
|
|
660
|
+
if (this._canApprove(run.status)) {
|
|
661
|
+
help += output_1.default.getTermKitLabelColor(' a');
|
|
662
|
+
help += output_1.default.getTermKitDimColor(' approve •');
|
|
663
|
+
}
|
|
664
|
+
help += output_1.default.getTermKitLabelColor(' esc');
|
|
665
|
+
help += output_1.default.getTermKitDimColor(' exit');
|
|
666
|
+
return help;
|
|
667
|
+
}
|
|
668
|
+
static _actionInteractiveHelp(action) {
|
|
669
|
+
let help = output_1.default.getTermKitLabelColor('↑↓|⇞⇟|↖↘');
|
|
670
|
+
help += output_1.default.getTermKitDimColor(' navigate •');
|
|
671
|
+
if (this._canCancel(action.status)) {
|
|
672
|
+
help += output_1.default.getTermKitLabelColor(' c');
|
|
673
|
+
help += output_1.default.getTermKitDimColor(' cancel •');
|
|
674
|
+
}
|
|
675
|
+
if (this._canRetry(action.status)) {
|
|
676
|
+
help += output_1.default.getTermKitLabelColor(' r');
|
|
677
|
+
help += output_1.default.getTermKitDimColor(' retry •');
|
|
678
|
+
}
|
|
679
|
+
if (this._canApprove(action.status)) {
|
|
680
|
+
help += output_1.default.getTermKitLabelColor(' a');
|
|
681
|
+
help += output_1.default.getTermKitDimColor(' approve •');
|
|
682
|
+
}
|
|
683
|
+
help += output_1.default.getTermKitLabelColor(' esc');
|
|
684
|
+
help += output_1.default.getTermKitDimColor(' exit');
|
|
685
|
+
return help;
|
|
686
|
+
}
|
|
687
|
+
static _drawInteractiveAction(action, actionLogs, put, blank, opts) {
|
|
688
|
+
const fullActionLogs = [...actionLogs.map((str) => ` ${str}`)];
|
|
689
|
+
if (action?.outputtedVariables.length) {
|
|
690
|
+
if (actionLogs.length > 0)
|
|
691
|
+
fullActionLogs.push('');
|
|
692
|
+
fullActionLogs.push(this._runOutputHeader());
|
|
693
|
+
action.outputtedVariables.forEach((v, i) => {
|
|
694
|
+
let line = ' ';
|
|
695
|
+
if (i <= 0)
|
|
696
|
+
line += 'Variables ';
|
|
697
|
+
else
|
|
698
|
+
line += ' ';
|
|
699
|
+
line += output_1.default.getTermKitMutedColor(v.key);
|
|
700
|
+
line += ' = "';
|
|
701
|
+
line += output_1.default.getTermKitBlueColor(v.value);
|
|
702
|
+
line += '"';
|
|
703
|
+
fullActionLogs.push(line);
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
const tabs = 25;
|
|
707
|
+
if (action) {
|
|
708
|
+
put(this._runDetailsHeader());
|
|
709
|
+
put(this._runDetailsId(action.runId, tabs));
|
|
710
|
+
put(this._runHtmlUrl(action.url, tabs));
|
|
711
|
+
put(this._runDetailsStatus(action.status, action.started, action.finished, tabs));
|
|
712
|
+
const target = this._runActionTarget(action, tabs);
|
|
713
|
+
if (target) {
|
|
714
|
+
put(target);
|
|
715
|
+
}
|
|
716
|
+
const loop = this._runLoopVariables(action.loop, action.loopValues, tabs);
|
|
717
|
+
if (loop) {
|
|
718
|
+
put(loop);
|
|
719
|
+
}
|
|
720
|
+
const started = this._runDetailsStarted(action.status, action.started, null, tabs);
|
|
721
|
+
if (started) {
|
|
722
|
+
put(started);
|
|
723
|
+
}
|
|
724
|
+
const finished = this._runDetailsFinished(action.status, action.finished, tabs);
|
|
725
|
+
if (finished) {
|
|
726
|
+
put(finished);
|
|
727
|
+
}
|
|
728
|
+
blank();
|
|
729
|
+
const y = put(this._runLogsHeader());
|
|
730
|
+
let logsLimit = termkit_no_lazy_require_1.default.terminal.height - y - 3;
|
|
731
|
+
if (logsLimit < 2)
|
|
732
|
+
logsLimit = 2;
|
|
733
|
+
if (opts.actionLogsScroll > fullActionLogs.length - logsLimit) {
|
|
734
|
+
opts.actionLogsScroll = fullActionLogs.length - logsLimit;
|
|
735
|
+
}
|
|
736
|
+
if (opts.actionLogsScroll < 0) {
|
|
737
|
+
opts.actionLogsScroll = 0;
|
|
738
|
+
}
|
|
739
|
+
const logs = this._actionLogs(fullActionLogs, opts.actionLogsScroll, logsLimit);
|
|
740
|
+
logs.forEach((str) => {
|
|
741
|
+
put(str);
|
|
742
|
+
});
|
|
743
|
+
blank();
|
|
744
|
+
put(this._actionInteractiveHelp(action));
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
static _drawInteractiveRun(run, put, blank, getY, opts) {
|
|
748
|
+
const tabs = 40;
|
|
749
|
+
if (run) {
|
|
750
|
+
put(this._runDetailsHeader());
|
|
751
|
+
put(this._runDetailsId(run.runId, tabs));
|
|
752
|
+
put(this._runHtmlUrl(run.url, tabs));
|
|
753
|
+
put(this._runDetailsStatus(run.status || pipeline_1.PIPELINE_RUN_STATUS.INITIAL, run.started, run.finished, tabs));
|
|
754
|
+
put(this._runDetailsTriggerer(run, tabs));
|
|
755
|
+
if (run.description) {
|
|
756
|
+
put(this._runDetailsDescription(run, tabs));
|
|
757
|
+
}
|
|
758
|
+
const started = this._runDetailsStarted(run.status, run.started, run.delayed, tabs);
|
|
759
|
+
if (started) {
|
|
760
|
+
put(started);
|
|
761
|
+
}
|
|
762
|
+
const finished = this._runDetailsFinished(run.status, run.finished, tabs);
|
|
763
|
+
if (finished) {
|
|
764
|
+
put(finished);
|
|
765
|
+
}
|
|
766
|
+
const context = this._runContext(run, tabs);
|
|
767
|
+
if (context.length > 0) {
|
|
768
|
+
blank();
|
|
769
|
+
context.forEach((str) => {
|
|
770
|
+
put(str);
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
const y = getY();
|
|
774
|
+
let actionsLimit = termkit_no_lazy_require_1.default.terminal.height - y - 5;
|
|
775
|
+
if (actionsLimit < 2)
|
|
776
|
+
actionsLimit = 2;
|
|
777
|
+
if (opts.selectedActionIndex >= (run?.actions.length || actionsLimit)) {
|
|
778
|
+
opts.selectedActionIndex = run.actions.length - 1;
|
|
779
|
+
}
|
|
780
|
+
const actions = this._runActions(run, false, actionsLimit, opts.selectedActionIndex, tabs);
|
|
781
|
+
if (actions.length > 0) {
|
|
782
|
+
blank();
|
|
783
|
+
actions.forEach((str) => {
|
|
784
|
+
put(str);
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
blank();
|
|
788
|
+
put(this._runInteractiveHelp(run));
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
static async _approveRun(client, workspace, project, pipelineId, runId, action, forceFetch) {
|
|
792
|
+
await client.pipelineRunApply(workspace, project, pipelineId, runId, {
|
|
793
|
+
operation: 'APPLY',
|
|
794
|
+
approve_action_id: action.runId,
|
|
795
|
+
});
|
|
796
|
+
if (forceFetch)
|
|
797
|
+
setTimeout(forceFetch, 100);
|
|
798
|
+
}
|
|
799
|
+
static async _retryRun(client, workspace, project, pipelineId, runId, forceFetch) {
|
|
800
|
+
try {
|
|
801
|
+
await client.pipelineRunRetry(workspace, project, pipelineId, runId);
|
|
802
|
+
if (forceFetch)
|
|
803
|
+
setTimeout(forceFetch, 100);
|
|
804
|
+
}
|
|
805
|
+
catch (err) {
|
|
806
|
+
if (err.message !== 'Unable to update/delete pipeline in progress') {
|
|
807
|
+
throw err;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
static async _cancelRun(client, workspace, project, pipelineId, runId, forceFetch) {
|
|
812
|
+
try {
|
|
813
|
+
await client.pipelineRunCancel(workspace, project, pipelineId, runId);
|
|
814
|
+
if (forceFetch)
|
|
815
|
+
setTimeout(forceFetch, 100);
|
|
816
|
+
}
|
|
817
|
+
catch (err) {
|
|
818
|
+
if (err.message !== 'Unable to cancel pipeline execution') {
|
|
819
|
+
throw err;
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
static async _runLogsInteractive(client, workspace, project, pipelineId, runId, runActionId) {
|
|
824
|
+
let action = null;
|
|
825
|
+
let forceFetchAction = () => { };
|
|
826
|
+
let actionLogs = [];
|
|
827
|
+
const opts = {
|
|
828
|
+
actionLogsScroll: 0,
|
|
829
|
+
};
|
|
830
|
+
let draw = () => { };
|
|
831
|
+
const { put, apply, reset, blank } = output_1.default.createScreenBuffer((name) => {
|
|
832
|
+
let logsPage = termkit_no_lazy_require_1.default.terminal.height - 15;
|
|
833
|
+
if (logsPage <= 0)
|
|
834
|
+
logsPage = 1;
|
|
835
|
+
if (name === 'CTRL_C') {
|
|
836
|
+
return true;
|
|
837
|
+
}
|
|
838
|
+
else if (name === 'ESCAPE') {
|
|
839
|
+
return true;
|
|
840
|
+
}
|
|
841
|
+
else if (name === 'DOWN') {
|
|
842
|
+
opts.actionLogsScroll -= 1;
|
|
843
|
+
if (opts.actionLogsScroll < 0)
|
|
844
|
+
opts.actionLogsScroll = 0;
|
|
845
|
+
draw();
|
|
846
|
+
}
|
|
847
|
+
else if (name === 'UP') {
|
|
848
|
+
opts.actionLogsScroll += 1;
|
|
849
|
+
draw();
|
|
850
|
+
}
|
|
851
|
+
else if (name === 'PAGE_UP') {
|
|
852
|
+
opts.actionLogsScroll += logsPage;
|
|
853
|
+
draw();
|
|
854
|
+
}
|
|
855
|
+
else if (name === 'PAGE_DOWN') {
|
|
856
|
+
opts.actionLogsScroll -= logsPage;
|
|
857
|
+
if (opts.actionLogsScroll < 0)
|
|
858
|
+
opts.actionLogsScroll = 0;
|
|
859
|
+
draw();
|
|
860
|
+
}
|
|
861
|
+
else if (name === 'HOME') {
|
|
862
|
+
opts.actionLogsScroll = actionLogs.length;
|
|
863
|
+
draw();
|
|
864
|
+
}
|
|
865
|
+
else if (name === 'END') {
|
|
866
|
+
opts.actionLogsScroll = 0;
|
|
867
|
+
draw();
|
|
868
|
+
}
|
|
869
|
+
else if (action &&
|
|
870
|
+
name.toLowerCase() === 'c' &&
|
|
871
|
+
this._canCancel(action.status)) {
|
|
872
|
+
this._cancelRun(client, workspace, project, pipelineId, runId, forceFetchAction)
|
|
873
|
+
.then()
|
|
874
|
+
.catch((err) => output_1.default.exitError(err));
|
|
875
|
+
}
|
|
876
|
+
else if (action &&
|
|
877
|
+
name.toLowerCase() === 'r' &&
|
|
878
|
+
this._canRetry(action.status)) {
|
|
879
|
+
this._retryRun(client, workspace, project, pipelineId, runId, forceFetchAction)
|
|
880
|
+
.then()
|
|
881
|
+
.catch((err) => output_1.default.exitError(err));
|
|
882
|
+
}
|
|
883
|
+
else if (action &&
|
|
884
|
+
name.toLowerCase() === 'a' &&
|
|
885
|
+
this._canApprove(action.status)) {
|
|
886
|
+
this._approveRun(client, workspace, project, pipelineId, runId, action, forceFetchAction)
|
|
887
|
+
.then()
|
|
888
|
+
.catch((err) => output_1.default.exitError(err));
|
|
889
|
+
}
|
|
890
|
+
return false;
|
|
891
|
+
}, () => {
|
|
892
|
+
draw();
|
|
893
|
+
});
|
|
894
|
+
draw = () => {
|
|
895
|
+
reset();
|
|
896
|
+
this._drawInteractiveAction(action, actionLogs, put, blank, opts);
|
|
897
|
+
apply();
|
|
898
|
+
};
|
|
899
|
+
setInterval(() => draw(), 100);
|
|
900
|
+
draw();
|
|
901
|
+
this._actionLogsLoop(client, workspace, project, pipelineId, runId, runActionId, (logs) => {
|
|
902
|
+
actionLogs = logs;
|
|
903
|
+
draw();
|
|
904
|
+
})
|
|
905
|
+
.then()
|
|
906
|
+
.catch((err) => output_1.default.exitError(err));
|
|
907
|
+
await this._actionStatusLoop(client, workspace, project, pipelineId, runId, runActionId, (a, _, ffa) => {
|
|
908
|
+
action = a;
|
|
909
|
+
forceFetchAction = ffa;
|
|
910
|
+
draw();
|
|
911
|
+
}, true);
|
|
912
|
+
}
|
|
913
|
+
static async _runStatusInteractive(client, workspace, project, pipelineId, runId) {
|
|
914
|
+
let mode = MODE.RUN;
|
|
915
|
+
let run = null;
|
|
916
|
+
let forceFetchRun = null;
|
|
917
|
+
let action = null;
|
|
918
|
+
let actionLogs = [];
|
|
919
|
+
let cancelActionFetch = () => { };
|
|
920
|
+
let forceActionFetch = () => { };
|
|
921
|
+
let cancelActionLogs = () => { };
|
|
922
|
+
let selectedActionId = null;
|
|
923
|
+
const opts = {
|
|
924
|
+
selectedActionIndex: -1,
|
|
925
|
+
actionLogsScroll: 0,
|
|
926
|
+
};
|
|
927
|
+
let draw = () => { };
|
|
928
|
+
const { put, apply, reset, blank, getY } = output_1.default.createScreenBuffer((name) => {
|
|
929
|
+
let logsPage = termkit_no_lazy_require_1.default.terminal.height - 15;
|
|
930
|
+
if (logsPage <= 0)
|
|
931
|
+
logsPage = 1;
|
|
932
|
+
if (name === 'CTRL_C') {
|
|
933
|
+
return true;
|
|
934
|
+
}
|
|
935
|
+
else if (name === 'ESCAPE') {
|
|
936
|
+
if (mode === MODE.RUN) {
|
|
937
|
+
return true;
|
|
938
|
+
}
|
|
939
|
+
else {
|
|
940
|
+
selectedActionId = null;
|
|
941
|
+
action = null;
|
|
942
|
+
actionLogs = [];
|
|
943
|
+
opts.actionLogsScroll = 0;
|
|
944
|
+
cancelActionFetch();
|
|
945
|
+
cancelActionLogs();
|
|
946
|
+
forceActionFetch = () => { };
|
|
947
|
+
cancelActionFetch = () => { };
|
|
948
|
+
cancelActionLogs = () => { };
|
|
949
|
+
mode = MODE.RUN;
|
|
950
|
+
draw();
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
else if (name === 'DOWN') {
|
|
954
|
+
if (mode === MODE.RUN) {
|
|
955
|
+
opts.selectedActionIndex += 1;
|
|
956
|
+
draw();
|
|
957
|
+
}
|
|
958
|
+
else {
|
|
959
|
+
opts.actionLogsScroll -= 1;
|
|
960
|
+
if (opts.actionLogsScroll < 0)
|
|
961
|
+
opts.actionLogsScroll = 0;
|
|
962
|
+
draw();
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
else if (name === 'UP') {
|
|
966
|
+
if (mode === MODE.RUN) {
|
|
967
|
+
opts.selectedActionIndex -= 1;
|
|
968
|
+
if (opts.selectedActionIndex < 0)
|
|
969
|
+
opts.selectedActionIndex = -1;
|
|
970
|
+
draw();
|
|
971
|
+
}
|
|
972
|
+
else {
|
|
973
|
+
opts.actionLogsScroll += 1;
|
|
974
|
+
draw();
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
else if (name === 'PAGE_UP') {
|
|
978
|
+
if (mode === MODE.ACTION) {
|
|
979
|
+
opts.actionLogsScroll += logsPage;
|
|
980
|
+
draw();
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
else if (name === 'PAGE_DOWN') {
|
|
984
|
+
if (mode === MODE.ACTION) {
|
|
985
|
+
opts.actionLogsScroll -= logsPage;
|
|
986
|
+
if (opts.actionLogsScroll < 0)
|
|
987
|
+
opts.actionLogsScroll = 0;
|
|
988
|
+
draw();
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
else if (name === 'HOME') {
|
|
992
|
+
if (mode === MODE.ACTION) {
|
|
993
|
+
opts.actionLogsScroll = actionLogs.length;
|
|
994
|
+
draw();
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
else if (name === 'END') {
|
|
998
|
+
if (mode === MODE.ACTION) {
|
|
999
|
+
opts.actionLogsScroll = 0;
|
|
1000
|
+
draw();
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
else if (name === 'ENTER') {
|
|
1004
|
+
if (mode === MODE.RUN &&
|
|
1005
|
+
run &&
|
|
1006
|
+
run.actions[opts.selectedActionIndex]) {
|
|
1007
|
+
selectedActionId = run.actions[opts.selectedActionIndex].runId;
|
|
1008
|
+
mode = MODE.ACTION;
|
|
1009
|
+
this._actionLogsLoop(client, workspace, project, pipelineId, runId, selectedActionId, (logs, cancel) => {
|
|
1010
|
+
cancelActionLogs = cancel;
|
|
1011
|
+
actionLogs = logs;
|
|
1012
|
+
draw();
|
|
1013
|
+
});
|
|
1014
|
+
this._actionStatusLoop(client, workspace, project, pipelineId, runId, selectedActionId, (a, cancel, ffa) => {
|
|
1015
|
+
if (cancel)
|
|
1016
|
+
cancelActionFetch = cancel;
|
|
1017
|
+
if (a && selectedActionId === a.runId)
|
|
1018
|
+
action = a;
|
|
1019
|
+
if (ffa)
|
|
1020
|
+
forceActionFetch = ffa;
|
|
1021
|
+
draw();
|
|
1022
|
+
}, true);
|
|
1023
|
+
draw();
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
else if (run &&
|
|
1027
|
+
name.toLowerCase() === 'c' &&
|
|
1028
|
+
this._canCancel(run.status)) {
|
|
1029
|
+
this._cancelRun(client, workspace, project, pipelineId, runId, mode === MODE.RUN ? forceFetchRun : forceActionFetch)
|
|
1030
|
+
.then()
|
|
1031
|
+
.catch((err) => output_1.default.exitError(err));
|
|
1032
|
+
}
|
|
1033
|
+
else if (run &&
|
|
1034
|
+
name.toLowerCase() === 'r' &&
|
|
1035
|
+
this._canRetry(run.status)) {
|
|
1036
|
+
this._retryRun(client, workspace, project, pipelineId, runId, mode === MODE.RUN ? forceFetchRun : forceActionFetch)
|
|
1037
|
+
.then()
|
|
1038
|
+
.catch((err) => output_1.default.exitError(err));
|
|
1039
|
+
}
|
|
1040
|
+
else if (run &&
|
|
1041
|
+
name.toLowerCase() === 'a' &&
|
|
1042
|
+
this._canApprove(run.status)) {
|
|
1043
|
+
let a = null;
|
|
1044
|
+
if (mode === MODE.ACTION) {
|
|
1045
|
+
a = action;
|
|
1046
|
+
}
|
|
1047
|
+
else if (mode === MODE.RUN) {
|
|
1048
|
+
if (run.actions[opts.selectedActionIndex]) {
|
|
1049
|
+
a = run.actions[opts.selectedActionIndex];
|
|
1050
|
+
}
|
|
1051
|
+
if (!a || !this._canApprove(a.status)) {
|
|
1052
|
+
a = run.actions.find((a) => this._canApprove(a.status));
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
if (a && this._canApprove(a.status)) {
|
|
1056
|
+
this._approveRun(client, workspace, project, pipelineId, runId, a, mode === MODE.RUN ? forceFetchRun : forceActionFetch)
|
|
1057
|
+
.then()
|
|
1058
|
+
.catch((err) => output_1.default.exitError(err));
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
return false;
|
|
1062
|
+
}, () => {
|
|
1063
|
+
draw();
|
|
1064
|
+
});
|
|
1065
|
+
draw = () => {
|
|
1066
|
+
reset();
|
|
1067
|
+
if (mode === MODE.RUN) {
|
|
1068
|
+
this._drawInteractiveRun(run, put, blank, getY, opts);
|
|
1069
|
+
}
|
|
1070
|
+
else {
|
|
1071
|
+
this._drawInteractiveAction(action, actionLogs, put, blank, opts);
|
|
1072
|
+
}
|
|
1073
|
+
apply();
|
|
1074
|
+
};
|
|
1075
|
+
setInterval(() => draw(), 100);
|
|
1076
|
+
draw();
|
|
1077
|
+
await this._runStatusLoop(client, workspace, project, pipelineId, runId, (r, ffr) => {
|
|
1078
|
+
run = r;
|
|
1079
|
+
forceFetchRun = ffr;
|
|
1080
|
+
draw();
|
|
1081
|
+
}, true);
|
|
1082
|
+
}
|
|
1083
|
+
static _exitByStatus(isJson, status) {
|
|
1084
|
+
if (status &&
|
|
1085
|
+
[pipeline_1.PIPELINE_RUN_STATUS.FAILED, pipeline_1.PIPELINE_RUN_STATUS.TERMINATED].includes(status)) {
|
|
1086
|
+
if (isJson)
|
|
1087
|
+
this.jsonExit(1);
|
|
1088
|
+
process.exit(1);
|
|
1089
|
+
}
|
|
1090
|
+
else {
|
|
1091
|
+
if (isJson)
|
|
1092
|
+
this.jsonExit(0);
|
|
1093
|
+
process.exit(0);
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
static jsonExit(code) {
|
|
1097
|
+
output_1.default.json({ type: 'exit', code });
|
|
1098
|
+
}
|
|
1099
|
+
static jsonInfo(message) {
|
|
1100
|
+
output_1.default.json({ type: 'info', message });
|
|
1101
|
+
}
|
|
1102
|
+
static jsonAction(action) {
|
|
1103
|
+
output_1.default.json({ type: 'action', action });
|
|
1104
|
+
}
|
|
1105
|
+
static jsonRun(run) {
|
|
1106
|
+
output_1.default.json({ type: 'run', run });
|
|
1107
|
+
}
|
|
1108
|
+
static jsonLog(log) {
|
|
1109
|
+
output_1.default.json({ type: 'log', log });
|
|
1110
|
+
}
|
|
1111
|
+
static async _runLogsNonInteractive(client, workspace, project, pipelineId, runId, runActionId, noWait, isJson) {
|
|
1112
|
+
let action = null;
|
|
1113
|
+
let actionLogsStart = 0;
|
|
1114
|
+
let lastActionLogsStart = -1;
|
|
1115
|
+
let drawnStart = false;
|
|
1116
|
+
let logsEnd = false;
|
|
1117
|
+
let totalFetchesCount = 0;
|
|
1118
|
+
const tabs = 40;
|
|
1119
|
+
if (noWait) {
|
|
1120
|
+
const msg = 'Fetching action and not waiting to finish...';
|
|
1121
|
+
if (isJson) {
|
|
1122
|
+
this.jsonInfo(msg);
|
|
1123
|
+
}
|
|
1124
|
+
else {
|
|
1125
|
+
output_1.default.getTerminal().gray(msg);
|
|
1126
|
+
output_1.default.newline();
|
|
1127
|
+
output_1.default.newline();
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
else {
|
|
1131
|
+
const msg = 'Fetching action and following changes...';
|
|
1132
|
+
if (isJson) {
|
|
1133
|
+
this.jsonInfo(msg);
|
|
1134
|
+
}
|
|
1135
|
+
else {
|
|
1136
|
+
output_1.default.getTerminal().gray(msg);
|
|
1137
|
+
output_1.default.newline();
|
|
1138
|
+
output_1.default.newline();
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
const draw = (logs) => {
|
|
1142
|
+
if (!drawnStart && action) {
|
|
1143
|
+
if (isJson) {
|
|
1144
|
+
this.jsonAction(action);
|
|
1145
|
+
}
|
|
1146
|
+
else {
|
|
1147
|
+
output_1.default.normal(this._runDetailsHeader());
|
|
1148
|
+
output_1.default.normal(this._runDetailsId(action.runId, tabs));
|
|
1149
|
+
output_1.default.normal(this._runHtmlUrl(action.url, tabs));
|
|
1150
|
+
output_1.default.normal(this._runDetailsStatus(action.status, action.started, action.finished, tabs));
|
|
1151
|
+
const target = this._runActionTarget(action, tabs);
|
|
1152
|
+
if (target) {
|
|
1153
|
+
output_1.default.normal(target);
|
|
1154
|
+
}
|
|
1155
|
+
const loop = this._runLoopVariables(action.loop, action.loopValues, tabs);
|
|
1156
|
+
if (loop) {
|
|
1157
|
+
output_1.default.normal(loop);
|
|
1158
|
+
}
|
|
1159
|
+
const started = this._runDetailsStarted(action.status, action.started, null, tabs);
|
|
1160
|
+
if (started) {
|
|
1161
|
+
output_1.default.normal(started);
|
|
1162
|
+
}
|
|
1163
|
+
const finished = this._runDetailsFinished(action.status, action.finished, tabs);
|
|
1164
|
+
if (finished) {
|
|
1165
|
+
output_1.default.normal(finished);
|
|
1166
|
+
}
|
|
1167
|
+
output_1.default.normal('');
|
|
1168
|
+
output_1.default.normal(this._runLogsHeader());
|
|
1169
|
+
}
|
|
1170
|
+
drawnStart = true;
|
|
1171
|
+
}
|
|
1172
|
+
if (drawnStart && logs && !logsEnd) {
|
|
1173
|
+
for (; actionLogsStart < logs.length; actionLogsStart += 1) {
|
|
1174
|
+
if (isJson) {
|
|
1175
|
+
this.jsonLog(logs[actionLogsStart]);
|
|
1176
|
+
}
|
|
1177
|
+
else {
|
|
1178
|
+
output_1.default.normal(output_1.default.getTermKitDimColor(` ${logs[actionLogsStart]}`));
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
if (action &&
|
|
1182
|
+
[
|
|
1183
|
+
pipeline_1.PIPELINE_RUN_STATUS.FAILED,
|
|
1184
|
+
pipeline_1.PIPELINE_RUN_STATUS.SKIPPED,
|
|
1185
|
+
pipeline_1.PIPELINE_RUN_STATUS.NOT_EXECUTED,
|
|
1186
|
+
pipeline_1.PIPELINE_RUN_STATUS.SUCCESSFUL,
|
|
1187
|
+
pipeline_1.PIPELINE_RUN_STATUS.TERMINATED,
|
|
1188
|
+
].includes(action.status) &&
|
|
1189
|
+
(actionLogsStart === lastActionLogsStart || logs.length < LOGS_LIMIT)) {
|
|
1190
|
+
logsEnd = true;
|
|
1191
|
+
}
|
|
1192
|
+
lastActionLogsStart = actionLogsStart;
|
|
1193
|
+
}
|
|
1194
|
+
if (logsEnd || (drawnStart && noWait && logs)) {
|
|
1195
|
+
if (isJson) {
|
|
1196
|
+
if (action)
|
|
1197
|
+
this.jsonAction(action);
|
|
1198
|
+
}
|
|
1199
|
+
else {
|
|
1200
|
+
if (logsEnd && action?.outputtedVariables.length) {
|
|
1201
|
+
output_1.default.normal('');
|
|
1202
|
+
output_1.default.normal(this._runOutputHeader());
|
|
1203
|
+
output_1.default.normal(output_1.default.getTermKitDimColor(' Variables '), false);
|
|
1204
|
+
action.outputtedVariables.forEach((v, i) => {
|
|
1205
|
+
let line = '';
|
|
1206
|
+
if (i > 0)
|
|
1207
|
+
line += ' ';
|
|
1208
|
+
line += output_1.default.getTermKitMutedColor(v.key);
|
|
1209
|
+
line += output_1.default.getTermKitDimColor(` = "`);
|
|
1210
|
+
line += output_1.default.getTermKitBlueColor(v.value);
|
|
1211
|
+
line += output_1.default.getTermKitDimColor('"');
|
|
1212
|
+
output_1.default.normal(line);
|
|
1213
|
+
});
|
|
1214
|
+
}
|
|
1215
|
+
if (logsEnd && action && totalFetchesCount > 1) {
|
|
1216
|
+
output_1.default.normal('');
|
|
1217
|
+
output_1.default.normal(this._runDetailsHeader());
|
|
1218
|
+
output_1.default.normal(this._runDetailsStatus(action.status, action.started, action.finished, tabs));
|
|
1219
|
+
const target = this._runActionTarget(action, tabs);
|
|
1220
|
+
if (target) {
|
|
1221
|
+
output_1.default.normal(target);
|
|
1222
|
+
}
|
|
1223
|
+
const loop = this._runLoopVariables(action.loop, action.loopValues, tabs);
|
|
1224
|
+
if (loop) {
|
|
1225
|
+
output_1.default.normal(loop);
|
|
1226
|
+
}
|
|
1227
|
+
const started = this._runDetailsStarted(action.status, action.started, null, tabs);
|
|
1228
|
+
if (started) {
|
|
1229
|
+
output_1.default.normal(started);
|
|
1230
|
+
}
|
|
1231
|
+
const finished = this._runDetailsFinished(action.status, action.finished, tabs);
|
|
1232
|
+
if (finished) {
|
|
1233
|
+
output_1.default.normal(finished);
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
this._exitByStatus(isJson, action?.status);
|
|
1238
|
+
}
|
|
1239
|
+
};
|
|
1240
|
+
this._actionLogsLoop(client, workspace, project, pipelineId, runId, runActionId, draw)
|
|
1241
|
+
.then()
|
|
1242
|
+
.catch((err) => output_1.default.exitError(err));
|
|
1243
|
+
await this._actionStatusLoop(client, workspace, project, pipelineId, runId, runActionId, (a) => {
|
|
1244
|
+
if (a) {
|
|
1245
|
+
action = a;
|
|
1246
|
+
totalFetchesCount += 1;
|
|
1247
|
+
draw();
|
|
1248
|
+
}
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1251
|
+
static async _runStatusNonInteractive(client, workspace, project, identifier, pipelineId, runId, noWait, noFollow, isJson) {
|
|
1252
|
+
let run = null;
|
|
1253
|
+
let totalFetchesCount = 0;
|
|
1254
|
+
const tabs = 40;
|
|
1255
|
+
if (noWait) {
|
|
1256
|
+
const msg = 'Fetching execution and not waiting to finish...';
|
|
1257
|
+
if (isJson) {
|
|
1258
|
+
this.jsonInfo(msg);
|
|
1259
|
+
}
|
|
1260
|
+
else {
|
|
1261
|
+
output_1.default.getTerminal().gray(msg);
|
|
1262
|
+
output_1.default.newline();
|
|
1263
|
+
output_1.default.newline();
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
else if (noFollow) {
|
|
1267
|
+
const msg = 'Fetching execution and waiting for finish...';
|
|
1268
|
+
if (isJson) {
|
|
1269
|
+
this.jsonInfo(msg);
|
|
1270
|
+
}
|
|
1271
|
+
else {
|
|
1272
|
+
output_1.default.getTerminal().gray(msg);
|
|
1273
|
+
output_1.default.newline();
|
|
1274
|
+
output_1.default.newline();
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
else {
|
|
1278
|
+
const msg = 'Fetching execution and following changes...';
|
|
1279
|
+
if (isJson) {
|
|
1280
|
+
this.jsonInfo(msg);
|
|
1281
|
+
}
|
|
1282
|
+
else {
|
|
1283
|
+
output_1.default.getTerminal().gray(msg);
|
|
1284
|
+
output_1.default.newline();
|
|
1285
|
+
output_1.default.newline();
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
const draw = (r) => {
|
|
1289
|
+
if (!run) {
|
|
1290
|
+
output_1.default.normal(this._runDetailsHeader());
|
|
1291
|
+
output_1.default.normal(this._runDetailsId(r.runId, tabs));
|
|
1292
|
+
output_1.default.normal(this._runHtmlUrl(r.url, tabs));
|
|
1293
|
+
output_1.default.normal(this._runDetailsStatus(r.status, r.started, r.finished, tabs));
|
|
1294
|
+
output_1.default.normal(this._runDetailsTriggerer(r, tabs));
|
|
1295
|
+
if (r?.description)
|
|
1296
|
+
output_1.default.normal(this._runDetailsDescription(r, tabs));
|
|
1297
|
+
const started = this._runDetailsStarted(r.status, r.started, r.delayed, tabs);
|
|
1298
|
+
if (started)
|
|
1299
|
+
output_1.default.normal(started);
|
|
1300
|
+
const finished = this._runDetailsFinished(r.status, r.finished, tabs);
|
|
1301
|
+
if (finished)
|
|
1302
|
+
output_1.default.normal(finished);
|
|
1303
|
+
const context = this._runContext(r, tabs);
|
|
1304
|
+
if (context.length > 0) {
|
|
1305
|
+
output_1.default.normal('');
|
|
1306
|
+
context.forEach((str) => {
|
|
1307
|
+
output_1.default.normal(str);
|
|
1308
|
+
});
|
|
1309
|
+
}
|
|
1310
|
+
output_1.default.normal('');
|
|
1311
|
+
output_1.default.normal(this._runActionsHeader(tabs));
|
|
1312
|
+
}
|
|
1313
|
+
const actions = this._runActions(r, true, 0, -1, tabs);
|
|
1314
|
+
actions.forEach((str) => {
|
|
1315
|
+
output_1.default.normal(str);
|
|
1316
|
+
});
|
|
1317
|
+
run = r;
|
|
1318
|
+
};
|
|
1319
|
+
run = await this._runStatusLoop(client, workspace, project, pipelineId, runId, (run) => {
|
|
1320
|
+
totalFetchesCount += 1;
|
|
1321
|
+
if (!noFollow || noWait) {
|
|
1322
|
+
if (isJson)
|
|
1323
|
+
this.jsonRun(run);
|
|
1324
|
+
else
|
|
1325
|
+
draw(run);
|
|
1326
|
+
}
|
|
1327
|
+
if (noWait) {
|
|
1328
|
+
this._exitByStatus(isJson, run.status);
|
|
1329
|
+
}
|
|
1330
|
+
});
|
|
1331
|
+
if (isJson) {
|
|
1332
|
+
this.jsonRun(run);
|
|
1333
|
+
this.jsonInfo(this._jsonActionsLogsHelp(identifier, runId));
|
|
1334
|
+
}
|
|
1335
|
+
else {
|
|
1336
|
+
if (totalFetchesCount > 1 || noFollow) {
|
|
1337
|
+
if (!noFollow)
|
|
1338
|
+
output_1.default.normal('');
|
|
1339
|
+
output_1.default.normal(this._runDetailsHeader());
|
|
1340
|
+
if (noFollow) {
|
|
1341
|
+
output_1.default.normal(this._runDetailsId(run.runId, tabs));
|
|
1342
|
+
output_1.default.normal(this._runHtmlUrl(run.url, tabs));
|
|
1343
|
+
}
|
|
1344
|
+
output_1.default.normal(this._runDetailsStatus(run.status, run.started, run.finished, tabs));
|
|
1345
|
+
if (noFollow) {
|
|
1346
|
+
output_1.default.normal(this._runDetailsTriggerer(run, tabs));
|
|
1347
|
+
if (run?.description)
|
|
1348
|
+
output_1.default.normal(this._runDetailsDescription(run, tabs));
|
|
1349
|
+
}
|
|
1350
|
+
const started = this._runDetailsStarted(run.status, run.started, run.delayed, tabs);
|
|
1351
|
+
if (started)
|
|
1352
|
+
output_1.default.normal(started);
|
|
1353
|
+
const finished = this._runDetailsFinished(run.status, run.finished, tabs);
|
|
1354
|
+
if (finished)
|
|
1355
|
+
output_1.default.normal(finished);
|
|
1356
|
+
if (noFollow) {
|
|
1357
|
+
const context = this._runContext(run, tabs);
|
|
1358
|
+
if (context.length > 0) {
|
|
1359
|
+
output_1.default.normal('');
|
|
1360
|
+
context.forEach((str) => {
|
|
1361
|
+
output_1.default.normal(str);
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
output_1.default.normal('');
|
|
1365
|
+
output_1.default.normal(this._runActionsHeader(tabs));
|
|
1366
|
+
const actions = this._runActions(run, true, 0, -1, tabs);
|
|
1367
|
+
actions.forEach((str) => {
|
|
1368
|
+
output_1.default.normal(str);
|
|
1369
|
+
});
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
output_1.default.normal(this._dimLine());
|
|
1373
|
+
output_1.default.normal(this._runActionsLogsHelp(identifier, runId));
|
|
1374
|
+
}
|
|
1375
|
+
this._exitByStatus(isJson, run.status);
|
|
1376
|
+
}
|
|
1377
|
+
static async _actionLogsLoop(client, workspace, project, pipelineId, runId, actionExecutionId, onChange) {
|
|
1378
|
+
let logs = [];
|
|
1379
|
+
let offset = 0;
|
|
1380
|
+
let shouldCancel = false;
|
|
1381
|
+
const cancel = () => {
|
|
1382
|
+
shouldCancel = true;
|
|
1383
|
+
};
|
|
1384
|
+
onChange(logs, cancel);
|
|
1385
|
+
const fetchLogs = async () => {
|
|
1386
|
+
return await client.getPipelineRunActionLogs(workspace, project, pipelineId, runId, actionExecutionId, offset, LOGS_LIMIT);
|
|
1387
|
+
};
|
|
1388
|
+
for (;;) {
|
|
1389
|
+
let o = await fetchLogs();
|
|
1390
|
+
if (o.total_element_count < offset) {
|
|
1391
|
+
logs = [];
|
|
1392
|
+
offset = 0;
|
|
1393
|
+
o = await fetchLogs();
|
|
1394
|
+
}
|
|
1395
|
+
offset = o.offset + o.element_count;
|
|
1396
|
+
logs.push(...o.logs);
|
|
1397
|
+
if (shouldCancel)
|
|
1398
|
+
return;
|
|
1399
|
+
onChange(logs, cancel);
|
|
1400
|
+
if (o.logs.length > 0)
|
|
1401
|
+
continue;
|
|
1402
|
+
await (0, utils_1.sleep)(3000);
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
static async _actionStatusLoop(client, workspace, project, pipelineId, runId, actionExecutionId, onChange, dontExit = false) {
|
|
1406
|
+
const fetchAction = async () => {
|
|
1407
|
+
return await client.getPipelineRunActionExecution(workspace, project, pipelineId, runId, actionExecutionId);
|
|
1408
|
+
};
|
|
1409
|
+
let status = pipeline_1.PIPELINE_RUN_STATUS.INITIAL;
|
|
1410
|
+
let oldStatus = null;
|
|
1411
|
+
let shouldCancel = false;
|
|
1412
|
+
const cancel = () => {
|
|
1413
|
+
shouldCancel = true;
|
|
1414
|
+
};
|
|
1415
|
+
const forceFetchAction = async () => {
|
|
1416
|
+
const a = await fetchAction();
|
|
1417
|
+
let started = null;
|
|
1418
|
+
if (a.start_date)
|
|
1419
|
+
started = new Date(a.start_date);
|
|
1420
|
+
let finished = null;
|
|
1421
|
+
if (a.finish_date)
|
|
1422
|
+
finished = new Date(a.finish_date);
|
|
1423
|
+
status = a.status || pipeline_1.PIPELINE_RUN_STATUS.INITIAL;
|
|
1424
|
+
const name = a.action?.name || '';
|
|
1425
|
+
const actionId = a.action?.id || -1;
|
|
1426
|
+
const url = a.html_url || '';
|
|
1427
|
+
const originalType = a.action?.type || pipeline_1.PIPELINE_ACTION_TYPE.BUILD;
|
|
1428
|
+
let type = originalType;
|
|
1429
|
+
if (pipeline_1.PIPELINE_ACTION_NAME[originalType]) {
|
|
1430
|
+
type = pipeline_1.PIPELINE_ACTION_NAME[originalType];
|
|
1431
|
+
}
|
|
1432
|
+
let target = null;
|
|
1433
|
+
if (a.target)
|
|
1434
|
+
target = a.target;
|
|
1435
|
+
let outputtedVariables = [];
|
|
1436
|
+
if (a.outputted_variables) {
|
|
1437
|
+
outputtedVariables = [];
|
|
1438
|
+
a.outputted_variables.forEach((v) => {
|
|
1439
|
+
outputtedVariables.push({
|
|
1440
|
+
key: String(v.key),
|
|
1441
|
+
value: String(v.value),
|
|
1442
|
+
});
|
|
1443
|
+
});
|
|
1444
|
+
}
|
|
1445
|
+
let loop = LOOP_STATUS.DISABLED;
|
|
1446
|
+
let loopValues = [];
|
|
1447
|
+
if (a.loop_details) {
|
|
1448
|
+
loop = a.loop_details.status;
|
|
1449
|
+
if (a.loop_details.resolved_variables) {
|
|
1450
|
+
loopValues = [];
|
|
1451
|
+
a.loop_details.resolved_variables.forEach((v) => {
|
|
1452
|
+
if (v.value)
|
|
1453
|
+
loopValues.push({
|
|
1454
|
+
key: String(v.key),
|
|
1455
|
+
value: String(v.value),
|
|
1456
|
+
});
|
|
1457
|
+
});
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
const changed = !oldStatus || status !== oldStatus;
|
|
1461
|
+
const action = {
|
|
1462
|
+
runId: actionExecutionId,
|
|
1463
|
+
id: actionId,
|
|
1464
|
+
url,
|
|
1465
|
+
status,
|
|
1466
|
+
target,
|
|
1467
|
+
loop,
|
|
1468
|
+
loopValues,
|
|
1469
|
+
outputtedVariables,
|
|
1470
|
+
started,
|
|
1471
|
+
finished,
|
|
1472
|
+
name,
|
|
1473
|
+
type,
|
|
1474
|
+
changed,
|
|
1475
|
+
};
|
|
1476
|
+
onChange(action, cancel, forceFetchAction);
|
|
1477
|
+
return action;
|
|
1478
|
+
};
|
|
1479
|
+
await forceFetchAction();
|
|
1480
|
+
for (;;) {
|
|
1481
|
+
await (0, utils_1.sleep)(3000);
|
|
1482
|
+
if (shouldCancel)
|
|
1483
|
+
return;
|
|
1484
|
+
await forceFetchAction();
|
|
1485
|
+
oldStatus = status;
|
|
1486
|
+
if (!dontExit &&
|
|
1487
|
+
[
|
|
1488
|
+
pipeline_1.PIPELINE_RUN_STATUS.FAILED,
|
|
1489
|
+
pipeline_1.PIPELINE_RUN_STATUS.SKIPPED,
|
|
1490
|
+
pipeline_1.PIPELINE_RUN_STATUS.NOT_EXECUTED,
|
|
1491
|
+
pipeline_1.PIPELINE_RUN_STATUS.SUCCESSFUL,
|
|
1492
|
+
pipeline_1.PIPELINE_RUN_STATUS.TERMINATED,
|
|
1493
|
+
].includes(status)) {
|
|
1494
|
+
cancel();
|
|
1495
|
+
}
|
|
1496
|
+
if (shouldCancel)
|
|
1497
|
+
return;
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
static async _runStatusLoop(client, workspace, project, pipelineId, runId, onChange, dontExit = false) {
|
|
1501
|
+
let lastRun;
|
|
1502
|
+
const fetchRun = async () => {
|
|
1503
|
+
return await client.getPipelineRun(workspace, project, pipelineId, runId);
|
|
1504
|
+
};
|
|
1505
|
+
const id = runId;
|
|
1506
|
+
let url;
|
|
1507
|
+
let status;
|
|
1508
|
+
let started;
|
|
1509
|
+
let finished = null;
|
|
1510
|
+
let delayed = null;
|
|
1511
|
+
let trigger;
|
|
1512
|
+
let creator = 'Unknown';
|
|
1513
|
+
let description = '';
|
|
1514
|
+
let refresh = false;
|
|
1515
|
+
let clearCache = false;
|
|
1516
|
+
let priority = pipeline_1.PIPELINE_PRIORITY.NORMAL;
|
|
1517
|
+
let context = null;
|
|
1518
|
+
let actions = [];
|
|
1519
|
+
const forceFetchRun = async () => {
|
|
1520
|
+
const run = await fetchRun();
|
|
1521
|
+
started = new Date(run.start_date || new Date());
|
|
1522
|
+
trigger = run.triggered_on || pipeline_1.PIPELINE_RUN_TRIGGER.CLICK;
|
|
1523
|
+
status = run.status || pipeline_1.PIPELINE_RUN_STATUS.INITIAL;
|
|
1524
|
+
url = run.html_url;
|
|
1525
|
+
if (run.creator) {
|
|
1526
|
+
if (run.creator.name)
|
|
1527
|
+
creator = run.creator.name;
|
|
1528
|
+
else if (run.creator.email)
|
|
1529
|
+
creator = run.creator.email;
|
|
1530
|
+
}
|
|
1531
|
+
if (run.finish_date)
|
|
1532
|
+
finished = new Date(run.finish_date);
|
|
1533
|
+
if (run.comment)
|
|
1534
|
+
description = run.comment;
|
|
1535
|
+
if (run.priority)
|
|
1536
|
+
priority = run.priority;
|
|
1537
|
+
if (run.delay_until)
|
|
1538
|
+
delayed = new Date(run.delay_until);
|
|
1539
|
+
if (run.refresh)
|
|
1540
|
+
refresh = true;
|
|
1541
|
+
if (run.clear_cache)
|
|
1542
|
+
clearCache = true;
|
|
1543
|
+
if (run.branch) {
|
|
1544
|
+
if (!context)
|
|
1545
|
+
context = {};
|
|
1546
|
+
context['Branch'] = run.branch.name;
|
|
1547
|
+
}
|
|
1548
|
+
if (run.tag) {
|
|
1549
|
+
if (!context)
|
|
1550
|
+
context = {};
|
|
1551
|
+
context['Tag'] = run.tag.name;
|
|
1552
|
+
}
|
|
1553
|
+
if (run.pull_request) {
|
|
1554
|
+
if (!context)
|
|
1555
|
+
context = {};
|
|
1556
|
+
context['Pull request'] = run.pull_request.name;
|
|
1557
|
+
}
|
|
1558
|
+
if (run.to_revision) {
|
|
1559
|
+
if (!context)
|
|
1560
|
+
context = {};
|
|
1561
|
+
context['Revision'] = `#${run.to_revision.revision.substring(0, 7)}`;
|
|
1562
|
+
if (run.to_revision.message)
|
|
1563
|
+
context['Revision'] += `: ${run.to_revision.message}`;
|
|
1564
|
+
}
|
|
1565
|
+
if (run.environment) {
|
|
1566
|
+
if (!context)
|
|
1567
|
+
context = {};
|
|
1568
|
+
context['Environment'] = run.environment.identifier;
|
|
1569
|
+
}
|
|
1570
|
+
if (run.package && run.package_version) {
|
|
1571
|
+
if (!context)
|
|
1572
|
+
context = {};
|
|
1573
|
+
context['Package'] =
|
|
1574
|
+
`${run.package.identifier}:${run.package_version.version}`;
|
|
1575
|
+
}
|
|
1576
|
+
if (run.loop_details) {
|
|
1577
|
+
if (!context)
|
|
1578
|
+
context = {};
|
|
1579
|
+
context['Loop'] = this._runLoopText(run.loop_details.status, run.loop_details.resolved_variables || []);
|
|
1580
|
+
}
|
|
1581
|
+
if (run.action_executions) {
|
|
1582
|
+
const old = actions;
|
|
1583
|
+
actions = (run.action_executions || []).map((a) => {
|
|
1584
|
+
const originalType = a.action?.type ||
|
|
1585
|
+
pipeline_1.PIPELINE_ACTION_TYPE.BUILD;
|
|
1586
|
+
let type = originalType;
|
|
1587
|
+
if (pipeline_1.PIPELINE_ACTION_NAME[originalType]) {
|
|
1588
|
+
type = pipeline_1.PIPELINE_ACTION_NAME[originalType];
|
|
1589
|
+
}
|
|
1590
|
+
const name = a.action?.name || '';
|
|
1591
|
+
const id = a.action_execution_id;
|
|
1592
|
+
const url = a.html_url;
|
|
1593
|
+
const actionId = a.action?.id || -1;
|
|
1594
|
+
const status = a.status || pipeline_1.PIPELINE_RUN_STATUS.INITIAL;
|
|
1595
|
+
let target = null;
|
|
1596
|
+
let loop = LOOP_STATUS.DISABLED;
|
|
1597
|
+
const loopValues = [];
|
|
1598
|
+
const outputtedVariables = [];
|
|
1599
|
+
if (a.target)
|
|
1600
|
+
target = a.target;
|
|
1601
|
+
if (a.outputted_variables) {
|
|
1602
|
+
a.outputted_variables.forEach((v) => {
|
|
1603
|
+
outputtedVariables.push({
|
|
1604
|
+
key: String(v.key),
|
|
1605
|
+
value: String(v.value),
|
|
1606
|
+
});
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
if (a.loop_details) {
|
|
1610
|
+
loop = a.loop_details.status;
|
|
1611
|
+
if (a.loop_details.resolved_variables) {
|
|
1612
|
+
a.loop_details.resolved_variables.forEach((v) => {
|
|
1613
|
+
if (v.value)
|
|
1614
|
+
loopValues.push({
|
|
1615
|
+
key: String(v.key),
|
|
1616
|
+
value: String(v.value),
|
|
1617
|
+
});
|
|
1618
|
+
});
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
let started = null;
|
|
1622
|
+
if (a.start_date)
|
|
1623
|
+
started = new Date(a.start_date);
|
|
1624
|
+
let finished = null;
|
|
1625
|
+
if (a.finish_date)
|
|
1626
|
+
finished = new Date(a.finish_date);
|
|
1627
|
+
const oldAction = old.find((o) => o.runId === id);
|
|
1628
|
+
const changed = !oldAction || oldAction.status !== status;
|
|
1629
|
+
const action = {
|
|
1630
|
+
type,
|
|
1631
|
+
name,
|
|
1632
|
+
url,
|
|
1633
|
+
loop,
|
|
1634
|
+
loopValues,
|
|
1635
|
+
outputtedVariables,
|
|
1636
|
+
target,
|
|
1637
|
+
id: actionId,
|
|
1638
|
+
runId: id,
|
|
1639
|
+
status,
|
|
1640
|
+
started,
|
|
1641
|
+
finished,
|
|
1642
|
+
changed,
|
|
1643
|
+
};
|
|
1644
|
+
return action;
|
|
1645
|
+
});
|
|
1646
|
+
actions = actions.filter((a) => {
|
|
1647
|
+
if (a.target)
|
|
1648
|
+
return true;
|
|
1649
|
+
return !actions.find((a2) => {
|
|
1650
|
+
if (a2.runId === a.runId)
|
|
1651
|
+
return false;
|
|
1652
|
+
if (a2.id !== a.id)
|
|
1653
|
+
return false;
|
|
1654
|
+
return !!a2.target;
|
|
1655
|
+
});
|
|
1656
|
+
});
|
|
1657
|
+
}
|
|
1658
|
+
const r = {
|
|
1659
|
+
runId: id,
|
|
1660
|
+
creator,
|
|
1661
|
+
description,
|
|
1662
|
+
started,
|
|
1663
|
+
url,
|
|
1664
|
+
status,
|
|
1665
|
+
trigger,
|
|
1666
|
+
finished,
|
|
1667
|
+
clearCache,
|
|
1668
|
+
refresh,
|
|
1669
|
+
priority,
|
|
1670
|
+
delayed,
|
|
1671
|
+
context,
|
|
1672
|
+
actions,
|
|
1673
|
+
};
|
|
1674
|
+
onChange(r, forceFetchRun);
|
|
1675
|
+
return r;
|
|
1676
|
+
};
|
|
1677
|
+
lastRun = await forceFetchRun();
|
|
1678
|
+
for (;;) {
|
|
1679
|
+
if (!dontExit &&
|
|
1680
|
+
[
|
|
1681
|
+
pipeline_1.PIPELINE_RUN_STATUS.FAILED,
|
|
1682
|
+
pipeline_1.PIPELINE_RUN_STATUS.SKIPPED,
|
|
1683
|
+
pipeline_1.PIPELINE_RUN_STATUS.NOT_EXECUTED,
|
|
1684
|
+
pipeline_1.PIPELINE_RUN_STATUS.SUCCESSFUL,
|
|
1685
|
+
pipeline_1.PIPELINE_RUN_STATUS.TERMINATED,
|
|
1686
|
+
].includes(lastRun.status)) {
|
|
1687
|
+
break;
|
|
1688
|
+
}
|
|
1689
|
+
await (0, utils_1.sleep)(3000);
|
|
1690
|
+
lastRun = await forceFetchRun();
|
|
1691
|
+
}
|
|
1692
|
+
return lastRun;
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
exports.default = OutputPipeline;
|