@catladder/pipeline 1.41.3 → 1.41.4
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/dist/bundles/catladder-gitlab/index.js +3 -3
- package/dist/constants.js +1 -1
- package/dist/context/index.d.ts +2 -2
- package/dist/context/index.js +310 -132
- package/dist/context/resolveReferences.d.ts +1 -3
- package/dist/context/resolveReferences.js +275 -26
- package/dist/context/resolveReferences.test.js +332 -81
- package/dist/pipeline/createJobs.js +45 -17
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/src/context/index.ts +8 -8
- package/src/context/resolveReferences.test.ts +15 -15
- package/src/context/resolveReferences.ts +37 -30
- package/src/pipeline/createJobs.ts +4 -4
|
@@ -1,31 +1,194 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) {
|
|
5
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
6
|
+
resolve(value);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
+
function fulfilled(value) {
|
|
12
|
+
try {
|
|
13
|
+
step(generator.next(value));
|
|
14
|
+
} catch (e) {
|
|
15
|
+
reject(e);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function rejected(value) {
|
|
20
|
+
try {
|
|
21
|
+
step(generator["throw"](value));
|
|
22
|
+
} catch (e) {
|
|
23
|
+
reject(e);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function step(result) {
|
|
28
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
var __generator = this && this.__generator || function (thisArg, body) {
|
|
36
|
+
var _ = {
|
|
37
|
+
label: 0,
|
|
38
|
+
sent: function () {
|
|
39
|
+
if (t[0] & 1) throw t[1];
|
|
40
|
+
return t[1];
|
|
41
|
+
},
|
|
42
|
+
trys: [],
|
|
43
|
+
ops: []
|
|
44
|
+
},
|
|
45
|
+
f,
|
|
46
|
+
y,
|
|
47
|
+
t,
|
|
48
|
+
g;
|
|
49
|
+
return g = {
|
|
50
|
+
next: verb(0),
|
|
51
|
+
"throw": verb(1),
|
|
52
|
+
"return": verb(2)
|
|
53
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
54
|
+
return this;
|
|
55
|
+
}), g;
|
|
56
|
+
|
|
57
|
+
function verb(n) {
|
|
58
|
+
return function (v) {
|
|
59
|
+
return step([n, v]);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function step(op) {
|
|
64
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
65
|
+
|
|
66
|
+
while (_) try {
|
|
67
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
68
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
69
|
+
|
|
70
|
+
switch (op[0]) {
|
|
71
|
+
case 0:
|
|
72
|
+
case 1:
|
|
73
|
+
t = op;
|
|
74
|
+
break;
|
|
75
|
+
|
|
76
|
+
case 4:
|
|
77
|
+
_.label++;
|
|
78
|
+
return {
|
|
79
|
+
value: op[1],
|
|
80
|
+
done: false
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
case 5:
|
|
84
|
+
_.label++;
|
|
85
|
+
y = op[1];
|
|
86
|
+
op = [0];
|
|
87
|
+
continue;
|
|
88
|
+
|
|
89
|
+
case 7:
|
|
90
|
+
op = _.ops.pop();
|
|
91
|
+
|
|
92
|
+
_.trys.pop();
|
|
93
|
+
|
|
94
|
+
continue;
|
|
95
|
+
|
|
96
|
+
default:
|
|
97
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
98
|
+
_ = 0;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
103
|
+
_.label = op[1];
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
108
|
+
_.label = t[1];
|
|
109
|
+
t = op;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (t && _.label < t[2]) {
|
|
114
|
+
_.label = t[2];
|
|
115
|
+
|
|
116
|
+
_.ops.push(op);
|
|
117
|
+
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (t[2]) _.ops.pop();
|
|
122
|
+
|
|
123
|
+
_.trys.pop();
|
|
124
|
+
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
op = body.call(thisArg, _);
|
|
129
|
+
} catch (e) {
|
|
130
|
+
op = [6, e];
|
|
131
|
+
y = 0;
|
|
132
|
+
} finally {
|
|
133
|
+
f = t = 0;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (op[0] & 5) throw op[1];
|
|
137
|
+
return {
|
|
138
|
+
value: op[0] ? op[1] : void 0,
|
|
139
|
+
done: true
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
3
144
|
exports.__esModule = true;
|
|
4
145
|
|
|
5
146
|
var resolveReferences_1 = require("./resolveReferences");
|
|
6
147
|
|
|
7
148
|
describe("resolveReferences", function () {
|
|
8
149
|
it("replaces occurences of ${componentName:VARIABLE_NAME}", function () {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
150
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
151
|
+
var variables, otherVariables, result;
|
|
152
|
+
return __generator(this, function (_a) {
|
|
153
|
+
switch (_a.label) {
|
|
154
|
+
case 0:
|
|
155
|
+
variables = {
|
|
156
|
+
a: "hello world",
|
|
157
|
+
b: "a replaced value looks like this: '${api:FOO}', nice!"
|
|
158
|
+
};
|
|
159
|
+
otherVariables = {
|
|
160
|
+
api: {
|
|
161
|
+
FOO: "foo from api"
|
|
162
|
+
},
|
|
163
|
+
frontend: {
|
|
164
|
+
FOO: "foo from frontend"
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
return [4
|
|
168
|
+
/*yield*/
|
|
169
|
+
, (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
|
|
170
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
171
|
+
var _a;
|
|
23
172
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
173
|
+
return __generator(this, function (_b) {
|
|
174
|
+
return [2
|
|
175
|
+
/*return*/
|
|
176
|
+
, (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName]];
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
})];
|
|
180
|
+
|
|
181
|
+
case 1:
|
|
182
|
+
result = _a.sent();
|
|
183
|
+
expect(result).toEqual({
|
|
184
|
+
a: "hello world",
|
|
185
|
+
b: "a replaced value looks like this: 'foo from api', nice!"
|
|
186
|
+
});
|
|
187
|
+
return [2
|
|
188
|
+
/*return*/
|
|
189
|
+
];
|
|
190
|
+
}
|
|
191
|
+
});
|
|
29
192
|
});
|
|
30
193
|
});
|
|
31
194
|
it("replaces self references with structure ${VARIABLE_NAME}", function () {
|
|
@@ -40,81 +203,169 @@ describe("resolveReferences", function () {
|
|
|
40
203
|
});
|
|
41
204
|
});
|
|
42
205
|
it("replaces self references mixed with other vars", function () {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
206
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
207
|
+
var variables, otherVariables, result;
|
|
208
|
+
return __generator(this, function (_a) {
|
|
209
|
+
switch (_a.label) {
|
|
210
|
+
case 0:
|
|
211
|
+
variables = {
|
|
212
|
+
FOO: "hello from ${api:FOO}",
|
|
213
|
+
BAR: "this: ${FOO}!"
|
|
214
|
+
};
|
|
215
|
+
otherVariables = {
|
|
216
|
+
api: {
|
|
217
|
+
FOO: "foo from api"
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
return [4
|
|
221
|
+
/*yield*/
|
|
222
|
+
, (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
|
|
223
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
224
|
+
var _a;
|
|
54
225
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
226
|
+
return __generator(this, function (_b) {
|
|
227
|
+
return [2
|
|
228
|
+
/*return*/
|
|
229
|
+
, (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName]];
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
})];
|
|
233
|
+
|
|
234
|
+
case 1:
|
|
235
|
+
result = _a.sent();
|
|
236
|
+
expect(result).toEqual({
|
|
237
|
+
FOO: "hello from foo from api",
|
|
238
|
+
BAR: "this: hello from foo from api!"
|
|
239
|
+
});
|
|
240
|
+
return [2
|
|
241
|
+
/*return*/
|
|
242
|
+
];
|
|
243
|
+
}
|
|
244
|
+
});
|
|
60
245
|
});
|
|
61
246
|
});
|
|
62
247
|
it("keeps variables as is if not found (when null is returned)", function () {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
248
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
249
|
+
var variables, otherVariables, result;
|
|
250
|
+
return __generator(this, function (_a) {
|
|
251
|
+
switch (_a.label) {
|
|
252
|
+
case 0:
|
|
253
|
+
variables = {
|
|
254
|
+
a: "hello world",
|
|
255
|
+
b: "a not found value looks like this: '${api:FOO}'"
|
|
256
|
+
};
|
|
257
|
+
otherVariables = {};
|
|
258
|
+
return [4
|
|
259
|
+
/*yield*/
|
|
260
|
+
, (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
|
|
261
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
262
|
+
var _a;
|
|
70
263
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
264
|
+
return __generator(this, function (_b) {
|
|
265
|
+
return [2
|
|
266
|
+
/*return*/
|
|
267
|
+
, (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName]];
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
})];
|
|
271
|
+
|
|
272
|
+
case 1:
|
|
273
|
+
result = _a.sent();
|
|
274
|
+
expect(result).toEqual({
|
|
275
|
+
a: "hello world",
|
|
276
|
+
b: "a not found value looks like this: '${api:FOO}'"
|
|
277
|
+
});
|
|
278
|
+
return [2
|
|
279
|
+
/*return*/
|
|
280
|
+
];
|
|
281
|
+
}
|
|
282
|
+
});
|
|
76
283
|
});
|
|
77
284
|
});
|
|
78
285
|
it("replaces mulitple levels deep", function () {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
286
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
287
|
+
var variables, otherVariables, result;
|
|
288
|
+
return __generator(this, function (_a) {
|
|
289
|
+
switch (_a.label) {
|
|
290
|
+
case 0:
|
|
291
|
+
variables = {
|
|
292
|
+
a: "value is ${frontend:FOO}!"
|
|
293
|
+
};
|
|
294
|
+
otherVariables = {
|
|
295
|
+
api: {
|
|
296
|
+
FOO: "foo from api"
|
|
297
|
+
},
|
|
298
|
+
frontend: {
|
|
299
|
+
FOO: "hi, ${api:FOO}"
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
return [4
|
|
303
|
+
/*yield*/
|
|
304
|
+
, (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
|
|
305
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
306
|
+
var _a, _b;
|
|
92
307
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
308
|
+
return __generator(this, function (_c) {
|
|
309
|
+
return [2
|
|
310
|
+
/*return*/
|
|
311
|
+
, (_b = (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName]) !== null && _b !== void 0 ? _b : ""];
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
})];
|
|
315
|
+
|
|
316
|
+
case 1:
|
|
317
|
+
result = _a.sent();
|
|
318
|
+
expect(result).toEqual({
|
|
319
|
+
a: "value is hi, foo from api!"
|
|
320
|
+
});
|
|
321
|
+
return [2
|
|
322
|
+
/*return*/
|
|
323
|
+
];
|
|
324
|
+
}
|
|
325
|
+
});
|
|
97
326
|
});
|
|
98
327
|
});
|
|
99
328
|
it("prevents endless loops", function () {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
329
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
330
|
+
var variables, otherVariables, result;
|
|
331
|
+
return __generator(this, function (_a) {
|
|
332
|
+
switch (_a.label) {
|
|
333
|
+
case 0:
|
|
334
|
+
variables = {
|
|
335
|
+
a: "value is ${frontend:FOO}!"
|
|
336
|
+
};
|
|
337
|
+
otherVariables = {
|
|
338
|
+
api: {
|
|
339
|
+
FOO: "api ${frontend:FOO}"
|
|
340
|
+
},
|
|
341
|
+
frontend: {
|
|
342
|
+
FOO: "frontend ${api:FOO}"
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
return [4
|
|
346
|
+
/*yield*/
|
|
347
|
+
, (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
|
|
348
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
349
|
+
var _a, _b;
|
|
113
350
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
351
|
+
return __generator(this, function (_c) {
|
|
352
|
+
return [2
|
|
353
|
+
/*return*/
|
|
354
|
+
, (_b = (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName]) !== null && _b !== void 0 ? _b : ""];
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
})];
|
|
358
|
+
|
|
359
|
+
case 1:
|
|
360
|
+
result = _a.sent();
|
|
361
|
+
expect(result).toEqual({
|
|
362
|
+
a: "value is frontend api ${frontend:FOO}!"
|
|
363
|
+
});
|
|
364
|
+
return [2
|
|
365
|
+
/*return*/
|
|
366
|
+
];
|
|
367
|
+
}
|
|
368
|
+
});
|
|
118
369
|
});
|
|
119
370
|
});
|
|
120
371
|
});
|
|
@@ -367,23 +367,51 @@ var createJobs = function (type, envs, config, componentName, trigger) {
|
|
|
367
367
|
return [2
|
|
368
368
|
/*return*/
|
|
369
369
|
, envs.reduce(function (acc, env) {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
370
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
371
|
+
var context, jobs, result, _a, _b, _c, _d, _e;
|
|
372
|
+
|
|
373
|
+
return __generator(this, function (_f) {
|
|
374
|
+
switch (_f.label) {
|
|
375
|
+
case 0:
|
|
376
|
+
return [4
|
|
377
|
+
/*yield*/
|
|
378
|
+
, (0, context_1.createContext)(config, componentName, env, commitInfo, packageManagerInfo)];
|
|
379
|
+
|
|
380
|
+
case 1:
|
|
381
|
+
context = _f.sent();
|
|
382
|
+
jobs = addStageNeeds(createRawJobs(context));
|
|
383
|
+
_a = [{}];
|
|
384
|
+
return [4
|
|
385
|
+
/*yield*/
|
|
386
|
+
, acc];
|
|
387
|
+
|
|
388
|
+
case 2:
|
|
389
|
+
_b = [__assign.apply(void 0, _a.concat([_f.sent()]))];
|
|
390
|
+
_d = (_c = jobs).reduce;
|
|
391
|
+
_e = [function (acc, job) {
|
|
392
|
+
var _a;
|
|
393
|
+
|
|
394
|
+
var jobWithResolvedReferences = replaceReferences(job, componentName, env, jobs);
|
|
395
|
+
var jobName = getFullJobName(job.name, componentName, job.envMode !== "none" ? env : undefined);
|
|
396
|
+
|
|
397
|
+
if (type === "gitlab") {
|
|
398
|
+
return __assign(__assign({}, acc), (_a = {}, _a[jobName] = (0, makeGitlabJob_1.makeGitlabJob)(jobWithResolvedReferences), _a));
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
throw new Error("not supported");
|
|
402
|
+
}];
|
|
403
|
+
return [4
|
|
404
|
+
/*yield*/
|
|
405
|
+
, Promise.resolve({})];
|
|
406
|
+
|
|
407
|
+
case 3:
|
|
408
|
+
result = __assign.apply(void 0, _b.concat([_d.apply(_c, _e.concat([_f.sent()]))]));
|
|
409
|
+
return [2
|
|
410
|
+
/*return*/
|
|
411
|
+
, result];
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
});
|
|
387
415
|
}, {})];
|
|
388
416
|
}
|
|
389
417
|
});
|