@commercetools-frontend/deployment-cli 0.0.4 → 0.0.5
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.
|
@@ -50,37 +50,35 @@ function _loadConfig() {
|
|
|
50
50
|
_loadConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
|
|
51
51
|
var deploymentConfigExplorer, defaultConfig, cosmiconfigResult, mergedConfig;
|
|
52
52
|
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context7) {
|
|
53
|
-
while (1) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return _context7.stop();
|
|
83
|
-
}
|
|
53
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
54
|
+
case 0:
|
|
55
|
+
deploymentConfigExplorer = cosmiconfig.cosmiconfig('deployment');
|
|
56
|
+
defaultConfig = {
|
|
57
|
+
CircleCI: {
|
|
58
|
+
apiBaseUrl: 'https://circleci.com/api/v2',
|
|
59
|
+
deploymentWorkflowName: 'test_build_and_deploy',
|
|
60
|
+
pagination: {
|
|
61
|
+
maxPages: 42,
|
|
62
|
+
pagesForPipelineSelection: 5
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
MerchantCenter: {}
|
|
66
|
+
};
|
|
67
|
+
_context7.prev = 2;
|
|
68
|
+
_context7.next = 5;
|
|
69
|
+
return deploymentConfigExplorer.search();
|
|
70
|
+
case 5:
|
|
71
|
+
cosmiconfigResult = _context7.sent;
|
|
72
|
+
mergedConfig = merge__default["default"](defaultConfig, cosmiconfigResult === null || cosmiconfigResult === void 0 ? void 0 : cosmiconfigResult.config);
|
|
73
|
+
return _context7.abrupt("return", mergedConfig);
|
|
74
|
+
case 10:
|
|
75
|
+
_context7.prev = 10;
|
|
76
|
+
_context7.t0 = _context7["catch"](2);
|
|
77
|
+
console.warn(_context7.t0);
|
|
78
|
+
throw new Error('Failed loading a deployment configuration. Create a cosmiconfig for `deployment` for example `deployment.config.cjs`.');
|
|
79
|
+
case 14:
|
|
80
|
+
case "end":
|
|
81
|
+
return _context7.stop();
|
|
84
82
|
}
|
|
85
83
|
}, _callee, null, [[2, 10]]);
|
|
86
84
|
}));
|
|
@@ -150,54 +148,52 @@ function _paginateToDeploymentPipeline() {
|
|
|
150
148
|
_paginateToDeploymentPipeline = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(_ref5) {
|
|
151
149
|
var circleCiApis, buildRevision, branch, debug, maxPages, deploymentPipeline, nextPageToken, i, _context8, _context9, pipelineRequest, pipelines, nonScheduledPipelines, _context10, _context11;
|
|
152
150
|
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context13) {
|
|
153
|
-
while (1) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
151
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
152
|
+
case 0:
|
|
153
|
+
circleCiApis = _ref5.circleCiApis, buildRevision = _ref5.buildRevision, branch = _ref5.branch, debug = _ref5.debug, maxPages = _ref5.maxPages;
|
|
154
|
+
i = 0;
|
|
155
|
+
case 2:
|
|
156
|
+
if (!(i < maxPages)) {
|
|
157
|
+
_context13.next = 16;
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
// eslint-disable-next-line no-await-in-loop
|
|
161
|
+
pipelineRequest = circleCiApis.pipelines({
|
|
162
|
+
pageToken: nextPageToken,
|
|
163
|
+
branch: branch
|
|
164
|
+
});
|
|
165
|
+
_context13.next = 6;
|
|
166
|
+
return pipelineRequest.execute({
|
|
167
|
+
debug: debug
|
|
168
|
+
});
|
|
169
|
+
case 6:
|
|
170
|
+
pipelines = _context13.sent;
|
|
171
|
+
nextPageToken = pipelines.next_page_token;
|
|
172
|
+
nonScheduledPipelines = _filterInstanceProperty__default["default"](_context8 = _filterInstanceProperty__default["default"](_context9 = pipelines.items).call(_context9, isNonScheduledPipeline)).call(_context8, isNonErroredPipeline);
|
|
173
|
+
if (buildRevision) {
|
|
174
|
+
console.log(_concatInstanceProperty__default["default"](_context10 = _concatInstanceProperty__default["default"](_context11 = "\uD83D\uDD04 Trying to find pipeline with revision ".concat(buildRevision, ". Attempt ")).call(_context11, i + 1, " out of ")).call(_context10, maxPages, "."));
|
|
175
|
+
deploymentPipeline = _findInstanceProperty__default["default"](nonScheduledPipelines).call(nonScheduledPipelines, function (pipeline) {
|
|
176
|
+
var _context12;
|
|
177
|
+
return _startsWithInstanceProperty__default["default"](_context12 = pipeline.vcs.revision).call(_context12, buildRevision);
|
|
171
178
|
});
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
console.log(_concatInstanceProperty__default["default"](_context10 = _concatInstanceProperty__default["default"](_context11 = "\uD83D\uDD04 Trying to find pipeline with revision ".concat(buildRevision, ". Attempt ")).call(_context11, i + 1, " out of ")).call(_context10, maxPages, "."));
|
|
178
|
-
deploymentPipeline = _findInstanceProperty__default["default"](nonScheduledPipelines).call(nonScheduledPipelines, function (pipeline) {
|
|
179
|
-
var _context12;
|
|
180
|
-
return _startsWithInstanceProperty__default["default"](_context12 = pipeline.vcs.revision).call(_context12, buildRevision);
|
|
181
|
-
});
|
|
182
|
-
} else {
|
|
183
|
-
deploymentPipeline = nonScheduledPipelines[0];
|
|
184
|
-
}
|
|
185
|
-
if (!deploymentPipeline) {
|
|
186
|
-
_context13.next = 13;
|
|
187
|
-
break;
|
|
188
|
-
}
|
|
189
|
-
console.log("\u2139\uFE0F Using pipeline for deployment with revision ".concat(deploymentPipeline.vcs.revision, "."));
|
|
190
|
-
return _context13.abrupt("break", 16);
|
|
191
|
-
case 13:
|
|
192
|
-
i++;
|
|
193
|
-
_context13.next = 2;
|
|
179
|
+
} else {
|
|
180
|
+
deploymentPipeline = nonScheduledPipelines[0];
|
|
181
|
+
}
|
|
182
|
+
if (!deploymentPipeline) {
|
|
183
|
+
_context13.next = 13;
|
|
194
184
|
break;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
185
|
+
}
|
|
186
|
+
console.log("\u2139\uFE0F Using pipeline for deployment with revision ".concat(deploymentPipeline.vcs.revision, "."));
|
|
187
|
+
return _context13.abrupt("break", 16);
|
|
188
|
+
case 13:
|
|
189
|
+
i++;
|
|
190
|
+
_context13.next = 2;
|
|
191
|
+
break;
|
|
192
|
+
case 16:
|
|
193
|
+
return _context13.abrupt("return", deploymentPipeline);
|
|
194
|
+
case 17:
|
|
195
|
+
case "end":
|
|
196
|
+
return _context13.stop();
|
|
201
197
|
}
|
|
202
198
|
}, _callee2);
|
|
203
199
|
}));
|
|
@@ -210,40 +206,38 @@ function _collectDeploymentPipelines() {
|
|
|
210
206
|
_collectDeploymentPipelines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(_ref6) {
|
|
211
207
|
var circleCiApis, branch, pagesForPipelineSelection, debug, deploymentPipelines, nextPageToken, i, _context14, _context15, pipelinesRequest, pipelines, nonScheduledPipelines;
|
|
212
208
|
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context16) {
|
|
213
|
-
while (1) {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
_context16.next = 13;
|
|
222
|
-
break;
|
|
223
|
-
}
|
|
224
|
-
// eslint-disable-next-line no-await-in-loop
|
|
225
|
-
pipelinesRequest = circleCiApis.pipelines({
|
|
226
|
-
pageToken: nextPageToken,
|
|
227
|
-
branch: branch
|
|
228
|
-
});
|
|
229
|
-
_context16.next = 7;
|
|
230
|
-
return pipelinesRequest.execute({
|
|
231
|
-
debug: debug
|
|
232
|
-
});
|
|
233
|
-
case 7:
|
|
234
|
-
pipelines = _context16.sent;
|
|
235
|
-
nonScheduledPipelines = _filterInstanceProperty__default["default"](_context14 = _filterInstanceProperty__default["default"](_context15 = pipelines.items).call(_context15, isNonScheduledPipeline)).call(_context14, isNonErroredPipeline);
|
|
236
|
-
deploymentPipelines = _concatInstanceProperty__default["default"](deploymentPipelines).call(deploymentPipelines, nonScheduledPipelines);
|
|
237
|
-
case 10:
|
|
238
|
-
i++;
|
|
239
|
-
_context16.next = 3;
|
|
209
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
210
|
+
case 0:
|
|
211
|
+
circleCiApis = _ref6.circleCiApis, branch = _ref6.branch, pagesForPipelineSelection = _ref6.pagesForPipelineSelection, debug = _ref6.debug;
|
|
212
|
+
deploymentPipelines = [];
|
|
213
|
+
i = 0;
|
|
214
|
+
case 3:
|
|
215
|
+
if (!(i < pagesForPipelineSelection)) {
|
|
216
|
+
_context16.next = 13;
|
|
240
217
|
break;
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
218
|
+
}
|
|
219
|
+
// eslint-disable-next-line no-await-in-loop
|
|
220
|
+
pipelinesRequest = circleCiApis.pipelines({
|
|
221
|
+
pageToken: nextPageToken,
|
|
222
|
+
branch: branch
|
|
223
|
+
});
|
|
224
|
+
_context16.next = 7;
|
|
225
|
+
return pipelinesRequest.execute({
|
|
226
|
+
debug: debug
|
|
227
|
+
});
|
|
228
|
+
case 7:
|
|
229
|
+
pipelines = _context16.sent;
|
|
230
|
+
nonScheduledPipelines = _filterInstanceProperty__default["default"](_context14 = _filterInstanceProperty__default["default"](_context15 = pipelines.items).call(_context15, isNonScheduledPipeline)).call(_context14, isNonErroredPipeline);
|
|
231
|
+
deploymentPipelines = _concatInstanceProperty__default["default"](deploymentPipelines).call(deploymentPipelines, nonScheduledPipelines);
|
|
232
|
+
case 10:
|
|
233
|
+
i++;
|
|
234
|
+
_context16.next = 3;
|
|
235
|
+
break;
|
|
236
|
+
case 13:
|
|
237
|
+
return _context16.abrupt("return", deploymentPipelines);
|
|
238
|
+
case 14:
|
|
239
|
+
case "end":
|
|
240
|
+
return _context16.stop();
|
|
247
241
|
}
|
|
248
242
|
}, _callee3);
|
|
249
243
|
}));
|
|
@@ -256,40 +250,38 @@ function _waitForDeploymentPipelinePrompt() {
|
|
|
256
250
|
_waitForDeploymentPipelinePrompt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(_ref7) {
|
|
257
251
|
var circleCiApis, branch, pagesForPipelineSelection, debug, deploymentPipelines, deploymentPipelinePrompt, revision;
|
|
258
252
|
return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context17) {
|
|
259
|
-
while (1) {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
return _context17.stop();
|
|
292
|
-
}
|
|
253
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
254
|
+
case 0:
|
|
255
|
+
circleCiApis = _ref7.circleCiApis, branch = _ref7.branch, pagesForPipelineSelection = _ref7.pagesForPipelineSelection, debug = _ref7.debug;
|
|
256
|
+
_context17.next = 3;
|
|
257
|
+
return collectDeploymentPipelines({
|
|
258
|
+
branch: branch,
|
|
259
|
+
pagesForPipelineSelection: pagesForPipelineSelection,
|
|
260
|
+
circleCiApis: circleCiApis,
|
|
261
|
+
debug: debug
|
|
262
|
+
});
|
|
263
|
+
case 3:
|
|
264
|
+
deploymentPipelines = _context17.sent;
|
|
265
|
+
_context17.next = 6;
|
|
266
|
+
return prompts__default["default"](
|
|
267
|
+
// @ts-expect-error prompts is not typed
|
|
268
|
+
promptOptions.deploymentPipelineSelect({
|
|
269
|
+
deploymentPipelines: deploymentPipelines
|
|
270
|
+
}));
|
|
271
|
+
case 6:
|
|
272
|
+
deploymentPipelinePrompt = _context17.sent;
|
|
273
|
+
revision = deploymentPipelinePrompt.deploymentPipeline.vcs.revision;
|
|
274
|
+
if (revision) {
|
|
275
|
+
_context17.next = 11;
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
console.log('☝️ Please select a revision or specify it as a CLI argument via `--build-revision`.');
|
|
279
|
+
throw new Error('No revision specified.');
|
|
280
|
+
case 11:
|
|
281
|
+
return _context17.abrupt("return", deploymentPipelinePrompt.deploymentPipeline);
|
|
282
|
+
case 12:
|
|
283
|
+
case "end":
|
|
284
|
+
return _context17.stop();
|
|
293
285
|
}
|
|
294
286
|
}, _callee4);
|
|
295
287
|
}));
|
|
@@ -302,20 +294,18 @@ function _waitForConfirmationPrompt() {
|
|
|
302
294
|
_waitForConfirmationPrompt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee5(_ref8) {
|
|
303
295
|
var approvalJob, revision;
|
|
304
296
|
return _regeneratorRuntime__default["default"].wrap(function _callee5$(_context18) {
|
|
305
|
-
while (1) {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
return _context18.stop();
|
|
318
|
-
}
|
|
297
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
298
|
+
case 0:
|
|
299
|
+
approvalJob = _ref8.approvalJob, revision = _ref8.revision;
|
|
300
|
+
return _context18.abrupt("return", prompts__default["default"](
|
|
301
|
+
// @ts-expect-error prompts is not typed
|
|
302
|
+
promptOptions.deploymentConfirmation({
|
|
303
|
+
approvalJob: approvalJob,
|
|
304
|
+
revision: revision
|
|
305
|
+
})));
|
|
306
|
+
case 2:
|
|
307
|
+
case "end":
|
|
308
|
+
return _context18.stop();
|
|
319
309
|
}
|
|
320
310
|
}, _callee5);
|
|
321
311
|
}));
|
|
@@ -342,64 +332,60 @@ function _waitForDeploymentJobNumber() {
|
|
|
342
332
|
_waitForDeploymentJobNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee7(_ref10, _ref11) {
|
|
343
333
|
var workflowId, deploymentJob, circleCiApis, debug, fetchDeploymentJobNumber, deploymentJobNumber;
|
|
344
334
|
return _regeneratorRuntime__default["default"].wrap(function _callee7$(_context22) {
|
|
345
|
-
while (1) {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
var
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
_context20.next = 7;
|
|
372
|
-
break;
|
|
373
|
-
}
|
|
374
|
-
throw new Error('Deployment job not yet running. Retrying.');
|
|
375
|
-
case 7:
|
|
376
|
-
return _context20.abrupt("return", applicationDeploymentJob.job_number);
|
|
377
|
-
case 8:
|
|
378
|
-
case "end":
|
|
379
|
-
return _context20.stop();
|
|
335
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
336
|
+
case 0:
|
|
337
|
+
workflowId = _ref10.workflowId, deploymentJob = _ref10.deploymentJob, circleCiApis = _ref10.circleCiApis;
|
|
338
|
+
debug = _ref11.debug;
|
|
339
|
+
fetchDeploymentJobNumber = /*#__PURE__*/function () {
|
|
340
|
+
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee6() {
|
|
341
|
+
var _context19;
|
|
342
|
+
var jobsRequest, jobs, applicationDeploymentJob;
|
|
343
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee6$(_context20) {
|
|
344
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
345
|
+
case 0:
|
|
346
|
+
jobsRequest = circleCiApis.jobs({
|
|
347
|
+
workflowId: workflowId
|
|
348
|
+
});
|
|
349
|
+
_context20.next = 3;
|
|
350
|
+
return jobsRequest.execute({
|
|
351
|
+
debug: debug
|
|
352
|
+
});
|
|
353
|
+
case 3:
|
|
354
|
+
jobs = _context20.sent;
|
|
355
|
+
applicationDeploymentJob = _findInstanceProperty__default["default"](_context19 = jobs.items).call(_context19, function (job) {
|
|
356
|
+
return job.name === deploymentJob;
|
|
357
|
+
});
|
|
358
|
+
if (!(!applicationDeploymentJob || applicationDeploymentJob.status === 'blocked')) {
|
|
359
|
+
_context20.next = 7;
|
|
360
|
+
break;
|
|
380
361
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
362
|
+
throw new Error('Deployment job not yet running. Retrying.');
|
|
363
|
+
case 7:
|
|
364
|
+
return _context20.abrupt("return", applicationDeploymentJob.job_number);
|
|
365
|
+
case 8:
|
|
366
|
+
case "end":
|
|
367
|
+
return _context20.stop();
|
|
368
|
+
}
|
|
369
|
+
}, _callee6);
|
|
370
|
+
}));
|
|
371
|
+
return function fetchDeploymentJobNumber() {
|
|
372
|
+
return _ref12.apply(this, arguments);
|
|
373
|
+
};
|
|
374
|
+
}();
|
|
375
|
+
_context22.next = 5;
|
|
376
|
+
return pRetry__default["default"](fetchDeploymentJobNumber, {
|
|
377
|
+
onFailedAttempt: function onFailedAttempt(error) {
|
|
378
|
+
var _context21;
|
|
379
|
+
console.log(_concatInstanceProperty__default["default"](_context21 = "\uD83D\uDD04 Trying to find deployment job. Attempt ".concat(error.attemptNumber, " with ")).call(_context21, error.retriesLeft, " retries left."));
|
|
380
|
+
},
|
|
381
|
+
retries: 10
|
|
382
|
+
});
|
|
383
|
+
case 5:
|
|
384
|
+
deploymentJobNumber = _context22.sent;
|
|
385
|
+
return _context22.abrupt("return", deploymentJobNumber);
|
|
386
|
+
case 7:
|
|
387
|
+
case "end":
|
|
388
|
+
return _context22.stop();
|
|
403
389
|
}
|
|
404
390
|
}, _callee7);
|
|
405
391
|
}));
|
|
@@ -414,188 +400,186 @@ function _approve() {
|
|
|
414
400
|
var _config$CircleCI$pagi, _config$CircleCI$pagi2, _config$CircleCI$pagi3, _config$CircleCI$pagi4, _context2, _context3, _context5, _confirmationPrompt;
|
|
415
401
|
var approvalJob, deploymentJob, _config$deployments, _context, requestedDeployment, deploymentPipeline, workflowsRequest, workflows, buildAndDeployWorkflow, workflowId, jobsRequest, jobs, applicationApprovalJob, applicationApprovalJobId, _context4, confirmationPrompt, approvalRequest, _context6, _context7, deploymentJobNumber;
|
|
416
402
|
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context8) {
|
|
417
|
-
while (1) {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
_context8.next = 9;
|
|
422
|
-
break;
|
|
423
|
-
}
|
|
424
|
-
requestedDeployment = (_config$deployments = config.deployments) === null || _config$deployments === void 0 ? void 0 : _config$deployments[cliFlags.deployment];
|
|
425
|
-
if (requestedDeployment) {
|
|
426
|
-
_context8.next = 4;
|
|
427
|
-
break;
|
|
428
|
-
}
|
|
429
|
-
throw new Error("\u26A0\uFE0F Deployment ".concat(cliFlags.deployment, " not found in configuration. Make sure it exists."));
|
|
430
|
-
case 4:
|
|
431
|
-
approvalJob = requestedDeployment.jobs.approval;
|
|
432
|
-
deploymentJob = requestedDeployment.jobs.deployment;
|
|
433
|
-
console.log(_concatInstanceProperty__default["default"](_context = "\u2139\uFE0F Approving requested deployment ".concat(cliFlags.deployment, " with approval job ")).call(_context, approvalJob, "."));
|
|
434
|
-
_context8.next = 12;
|
|
403
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
404
|
+
case 0:
|
|
405
|
+
if (!cliFlags.deployment) {
|
|
406
|
+
_context8.next = 9;
|
|
435
407
|
break;
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
case 12:
|
|
441
|
-
if (!cliFlags.yes) {
|
|
442
|
-
_context8.next = 18;
|
|
443
|
-
break;
|
|
444
|
-
}
|
|
445
|
-
_context8.next = 15;
|
|
446
|
-
return paginateToDeploymentPipeline({
|
|
447
|
-
circleCiApis: circleCiApis,
|
|
448
|
-
buildRevision: cliFlags.buildRevision,
|
|
449
|
-
branch: cliFlags.branch,
|
|
450
|
-
debug: cliFlags.debug,
|
|
451
|
-
maxPages: (_config$CircleCI$pagi = (_config$CircleCI$pagi2 = config.CircleCI.pagination) === null || _config$CircleCI$pagi2 === void 0 ? void 0 : _config$CircleCI$pagi2.maxPages) !== null && _config$CircleCI$pagi !== void 0 ? _config$CircleCI$pagi : 1
|
|
452
|
-
});
|
|
453
|
-
case 15:
|
|
454
|
-
_context8.t0 = _context8.sent;
|
|
455
|
-
_context8.next = 21;
|
|
408
|
+
}
|
|
409
|
+
requestedDeployment = (_config$deployments = config.deployments) === null || _config$deployments === void 0 ? void 0 : _config$deployments[cliFlags.deployment];
|
|
410
|
+
if (requestedDeployment) {
|
|
411
|
+
_context8.next = 4;
|
|
456
412
|
break;
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
}
|
|
473
|
-
throw new Error("\u26A0\uFE0F No workflow called ".concat(config.CircleCI.deploymentWorkflowName, " found in any pipeline for deployment."));
|
|
474
|
-
case 24:
|
|
475
|
-
console.log("\u2139\uFE0F Found pipeline for deployment with revision ".concat(deploymentPipeline.vcs.revision, "."));
|
|
476
|
-
workflowsRequest = circleCiApis.workflows({
|
|
477
|
-
pipelineId: deploymentPipeline.id
|
|
478
|
-
});
|
|
479
|
-
_context8.next = 28;
|
|
480
|
-
return workflowsRequest.execute({
|
|
481
|
-
debug: cliFlags.debug
|
|
482
|
-
});
|
|
483
|
-
case 28:
|
|
484
|
-
workflows = _context8.sent;
|
|
485
|
-
buildAndDeployWorkflow = _findInstanceProperty__default["default"](_context2 = workflows.items).call(_context2, function (workflow) {
|
|
486
|
-
return workflow.name === config.CircleCI.deploymentWorkflowName;
|
|
487
|
-
});
|
|
488
|
-
if (buildAndDeployWorkflow) {
|
|
489
|
-
_context8.next = 32;
|
|
490
|
-
break;
|
|
491
|
-
}
|
|
492
|
-
throw new Error("\u26A0\uFE0F No workflow called ".concat(config.CircleCI.deploymentWorkflowName, " found for deployment."));
|
|
493
|
-
case 32:
|
|
494
|
-
workflowId = buildAndDeployWorkflow.id;
|
|
495
|
-
console.log("\u2139\uFE0F Found workflow to build and deploy with id ".concat(workflowId, "."));
|
|
496
|
-
jobsRequest = circleCiApis.jobs({
|
|
497
|
-
workflowId: workflowId
|
|
498
|
-
});
|
|
499
|
-
_context8.next = 37;
|
|
500
|
-
return jobsRequest.execute({
|
|
501
|
-
debug: cliFlags.debug
|
|
502
|
-
});
|
|
503
|
-
case 37:
|
|
504
|
-
jobs = _context8.sent;
|
|
505
|
-
console.log("\u2139\uFE0F Found jobs for workflow.");
|
|
506
|
-
applicationApprovalJob = _findInstanceProperty__default["default"](_context3 = jobs.items).call(_context3, function (job) {
|
|
507
|
-
return job.name === approvalJob;
|
|
508
|
-
});
|
|
509
|
-
applicationApprovalJobId = applicationApprovalJob === null || applicationApprovalJob === void 0 ? void 0 : applicationApprovalJob.id;
|
|
510
|
-
if (applicationApprovalJobId) {
|
|
511
|
-
_context8.next = 43;
|
|
512
|
-
break;
|
|
513
|
-
}
|
|
514
|
-
throw new Error(_concatInstanceProperty__default["default"](_context4 = "\u270C\uFE0F Could not find deployment approval job named ".concat(approvalJob, " at revision ")).call(_context4, deploymentPipeline.vcs.revision, ". Maybe try again later."));
|
|
515
|
-
case 43:
|
|
516
|
-
console.log(_concatInstanceProperty__default["default"](_context5 = "\u2139\uFE0F Found deployment approval job named ".concat(approvalJob, " with id ")).call(_context5, applicationApprovalJobId, "."));
|
|
517
|
-
if (cliFlags.yes) {
|
|
518
|
-
_context8.next = 48;
|
|
519
|
-
break;
|
|
520
|
-
}
|
|
521
|
-
_context8.next = 47;
|
|
522
|
-
return waitForConfirmationPrompt({
|
|
523
|
-
approvalJob: approvalJob,
|
|
524
|
-
revision: deploymentPipeline.vcs.revision
|
|
525
|
-
});
|
|
526
|
-
case 47:
|
|
527
|
-
confirmationPrompt = _context8.sent;
|
|
528
|
-
case 48:
|
|
529
|
-
if (!(cliFlags.yes || (_confirmationPrompt = confirmationPrompt) !== null && _confirmationPrompt !== void 0 && _confirmationPrompt.confirmed)) {
|
|
530
|
-
_context8.next = 71;
|
|
531
|
-
break;
|
|
532
|
-
}
|
|
533
|
-
if (cliFlags.dryRun) {
|
|
534
|
-
console.log("\uD83D\uDE4A Not approving deployment job due to dry run.");
|
|
535
|
-
} else {
|
|
536
|
-
console.log("\u2139\uFE0F Approving deployment job.");
|
|
537
|
-
}
|
|
538
|
-
approvalRequest = circleCiApis.approve({
|
|
539
|
-
workflowId: workflowId,
|
|
540
|
-
approvalRequestId: applicationApprovalJobId
|
|
541
|
-
});
|
|
542
|
-
_context8.next = 53;
|
|
543
|
-
return approvalRequest.execute({
|
|
544
|
-
debug: cliFlags.debug,
|
|
545
|
-
skip: cliFlags.dryRun
|
|
546
|
-
});
|
|
547
|
-
case 53:
|
|
548
|
-
if (!cliFlags.yes) {
|
|
549
|
-
_context8.next = 57;
|
|
550
|
-
break;
|
|
551
|
-
}
|
|
552
|
-
console.log("\u2139\uFE0F Skipping determining deployment job approved by ".concat(approvalJob, " due to '--yes' flag. Please check CircleCI manually."));
|
|
553
|
-
_context8.next = 69;
|
|
413
|
+
}
|
|
414
|
+
throw new Error("\u26A0\uFE0F Deployment ".concat(cliFlags.deployment, " not found in configuration. Make sure it exists."));
|
|
415
|
+
case 4:
|
|
416
|
+
approvalJob = requestedDeployment.jobs.approval;
|
|
417
|
+
deploymentJob = requestedDeployment.jobs.deployment;
|
|
418
|
+
console.log(_concatInstanceProperty__default["default"](_context = "\u2139\uFE0F Approving requested deployment ".concat(cliFlags.deployment, " with approval job ")).call(_context, approvalJob, "."));
|
|
419
|
+
_context8.next = 12;
|
|
420
|
+
break;
|
|
421
|
+
case 9:
|
|
422
|
+
approvalJob = cliFlags.approvalJob;
|
|
423
|
+
deploymentJob = cliFlags.deploymentJob;
|
|
424
|
+
console.log("\u2139\uFE0F Approving with approval job ".concat(approvalJob, "."));
|
|
425
|
+
case 12:
|
|
426
|
+
if (!cliFlags.yes) {
|
|
427
|
+
_context8.next = 18;
|
|
554
428
|
break;
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
429
|
+
}
|
|
430
|
+
_context8.next = 15;
|
|
431
|
+
return paginateToDeploymentPipeline({
|
|
432
|
+
circleCiApis: circleCiApis,
|
|
433
|
+
buildRevision: cliFlags.buildRevision,
|
|
434
|
+
branch: cliFlags.branch,
|
|
435
|
+
debug: cliFlags.debug,
|
|
436
|
+
maxPages: (_config$CircleCI$pagi = (_config$CircleCI$pagi2 = config.CircleCI.pagination) === null || _config$CircleCI$pagi2 === void 0 ? void 0 : _config$CircleCI$pagi2.maxPages) !== null && _config$CircleCI$pagi !== void 0 ? _config$CircleCI$pagi : 1
|
|
437
|
+
});
|
|
438
|
+
case 15:
|
|
439
|
+
_context8.t0 = _context8.sent;
|
|
440
|
+
_context8.next = 21;
|
|
441
|
+
break;
|
|
442
|
+
case 18:
|
|
443
|
+
_context8.next = 20;
|
|
444
|
+
return waitForDeploymentPipelinePrompt({
|
|
445
|
+
branch: cliFlags.branch,
|
|
446
|
+
circleCiApis: circleCiApis,
|
|
447
|
+
pagesForPipelineSelection: (_config$CircleCI$pagi3 = (_config$CircleCI$pagi4 = config.CircleCI.pagination) === null || _config$CircleCI$pagi4 === void 0 ? void 0 : _config$CircleCI$pagi4.pagesForPipelineSelection) !== null && _config$CircleCI$pagi3 !== void 0 ? _config$CircleCI$pagi3 : 1,
|
|
448
|
+
debug: cliFlags.debug
|
|
449
|
+
});
|
|
450
|
+
case 20:
|
|
451
|
+
_context8.t0 = _context8.sent;
|
|
452
|
+
case 21:
|
|
453
|
+
deploymentPipeline = _context8.t0;
|
|
454
|
+
if (deploymentPipeline) {
|
|
455
|
+
_context8.next = 24;
|
|
562
456
|
break;
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
projectName: config.CircleCI.projectName,
|
|
582
|
-
pipelineNumber: deploymentPipeline.number,
|
|
583
|
-
workflowId: workflowId,
|
|
584
|
-
jobNumber: deploymentJobNumber
|
|
585
|
-
})));
|
|
586
|
-
_context8.next = 69;
|
|
457
|
+
}
|
|
458
|
+
throw new Error("\u26A0\uFE0F No workflow called ".concat(config.CircleCI.deploymentWorkflowName, " found in any pipeline for deployment."));
|
|
459
|
+
case 24:
|
|
460
|
+
console.log("\u2139\uFE0F Found pipeline for deployment with revision ".concat(deploymentPipeline.vcs.revision, "."));
|
|
461
|
+
workflowsRequest = circleCiApis.workflows({
|
|
462
|
+
pipelineId: deploymentPipeline.id
|
|
463
|
+
});
|
|
464
|
+
_context8.next = 28;
|
|
465
|
+
return workflowsRequest.execute({
|
|
466
|
+
debug: cliFlags.debug
|
|
467
|
+
});
|
|
468
|
+
case 28:
|
|
469
|
+
workflows = _context8.sent;
|
|
470
|
+
buildAndDeployWorkflow = _findInstanceProperty__default["default"](_context2 = workflows.items).call(_context2, function (workflow) {
|
|
471
|
+
return workflow.name === config.CircleCI.deploymentWorkflowName;
|
|
472
|
+
});
|
|
473
|
+
if (buildAndDeployWorkflow) {
|
|
474
|
+
_context8.next = 32;
|
|
587
475
|
break;
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
476
|
+
}
|
|
477
|
+
throw new Error("\u26A0\uFE0F No workflow called ".concat(config.CircleCI.deploymentWorkflowName, " found for deployment."));
|
|
478
|
+
case 32:
|
|
479
|
+
workflowId = buildAndDeployWorkflow.id;
|
|
480
|
+
console.log("\u2139\uFE0F Found workflow to build and deploy with id ".concat(workflowId, "."));
|
|
481
|
+
jobsRequest = circleCiApis.jobs({
|
|
482
|
+
workflowId: workflowId
|
|
483
|
+
});
|
|
484
|
+
_context8.next = 37;
|
|
485
|
+
return jobsRequest.execute({
|
|
486
|
+
debug: cliFlags.debug
|
|
487
|
+
});
|
|
488
|
+
case 37:
|
|
489
|
+
jobs = _context8.sent;
|
|
490
|
+
console.log("\u2139\uFE0F Found jobs for workflow.");
|
|
491
|
+
applicationApprovalJob = _findInstanceProperty__default["default"](_context3 = jobs.items).call(_context3, function (job) {
|
|
492
|
+
return job.name === approvalJob;
|
|
493
|
+
});
|
|
494
|
+
applicationApprovalJobId = applicationApprovalJob === null || applicationApprovalJob === void 0 ? void 0 : applicationApprovalJob.id;
|
|
495
|
+
if (applicationApprovalJobId) {
|
|
496
|
+
_context8.next = 43;
|
|
592
497
|
break;
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
498
|
+
}
|
|
499
|
+
throw new Error(_concatInstanceProperty__default["default"](_context4 = "\u270C\uFE0F Could not find deployment approval job named ".concat(approvalJob, " at revision ")).call(_context4, deploymentPipeline.vcs.revision, ". Maybe try again later."));
|
|
500
|
+
case 43:
|
|
501
|
+
console.log(_concatInstanceProperty__default["default"](_context5 = "\u2139\uFE0F Found deployment approval job named ".concat(approvalJob, " with id ")).call(_context5, applicationApprovalJobId, "."));
|
|
502
|
+
if (cliFlags.yes) {
|
|
503
|
+
_context8.next = 48;
|
|
504
|
+
break;
|
|
505
|
+
}
|
|
506
|
+
_context8.next = 47;
|
|
507
|
+
return waitForConfirmationPrompt({
|
|
508
|
+
approvalJob: approvalJob,
|
|
509
|
+
revision: deploymentPipeline.vcs.revision
|
|
510
|
+
});
|
|
511
|
+
case 47:
|
|
512
|
+
confirmationPrompt = _context8.sent;
|
|
513
|
+
case 48:
|
|
514
|
+
if (!(cliFlags.yes || (_confirmationPrompt = confirmationPrompt) !== null && _confirmationPrompt !== void 0 && _confirmationPrompt.confirmed)) {
|
|
515
|
+
_context8.next = 71;
|
|
516
|
+
break;
|
|
517
|
+
}
|
|
518
|
+
if (cliFlags.dryRun) {
|
|
519
|
+
console.log("\uD83D\uDE4A Not approving deployment job due to dry run.");
|
|
520
|
+
} else {
|
|
521
|
+
console.log("\u2139\uFE0F Approving deployment job.");
|
|
522
|
+
}
|
|
523
|
+
approvalRequest = circleCiApis.approve({
|
|
524
|
+
workflowId: workflowId,
|
|
525
|
+
approvalRequestId: applicationApprovalJobId
|
|
526
|
+
});
|
|
527
|
+
_context8.next = 53;
|
|
528
|
+
return approvalRequest.execute({
|
|
529
|
+
debug: cliFlags.debug,
|
|
530
|
+
skip: cliFlags.dryRun
|
|
531
|
+
});
|
|
532
|
+
case 53:
|
|
533
|
+
if (!cliFlags.yes) {
|
|
534
|
+
_context8.next = 57;
|
|
535
|
+
break;
|
|
536
|
+
}
|
|
537
|
+
console.log("\u2139\uFE0F Skipping determining deployment job approved by ".concat(approvalJob, " due to '--yes' flag. Please check CircleCI manually."));
|
|
538
|
+
_context8.next = 69;
|
|
539
|
+
break;
|
|
540
|
+
case 57:
|
|
541
|
+
if (!cliFlags.dryRun) {
|
|
542
|
+
_context8.next = 61;
|
|
543
|
+
break;
|
|
544
|
+
}
|
|
545
|
+
console.log("\u270C\uFE0F Dry running hence could not determine deployment job approved by ".concat(approvalJob, "."));
|
|
546
|
+
_context8.next = 69;
|
|
547
|
+
break;
|
|
548
|
+
case 61:
|
|
549
|
+
if (!deploymentJob) {
|
|
550
|
+
_context8.next = 68;
|
|
551
|
+
break;
|
|
552
|
+
}
|
|
553
|
+
_context8.next = 64;
|
|
554
|
+
return waitForDeploymentJobNumber({
|
|
555
|
+
workflowId: workflowId,
|
|
556
|
+
deploymentJob: deploymentJob,
|
|
557
|
+
circleCiApis: circleCiApis
|
|
558
|
+
}, {
|
|
559
|
+
debug: cliFlags.debug,
|
|
560
|
+
dryRun: cliFlags.dryRun,
|
|
561
|
+
yes: cliFlags.yes
|
|
562
|
+
});
|
|
563
|
+
case 64:
|
|
564
|
+
deploymentJobNumber = _context8.sent;
|
|
565
|
+
console.log(_concatInstanceProperty__default["default"](_context6 = _concatInstanceProperty__default["default"](_context7 = "\uD83D\uDE4C The deployment via ".concat(approvalJob, " at revision ")).call(_context7, deploymentPipeline.vcs.revision, " is running at: ")).call(_context6, getJobUrl({
|
|
566
|
+
projectName: config.CircleCI.projectName,
|
|
567
|
+
pipelineNumber: deploymentPipeline.number,
|
|
568
|
+
workflowId: workflowId,
|
|
569
|
+
jobNumber: deploymentJobNumber
|
|
570
|
+
})));
|
|
571
|
+
_context8.next = 69;
|
|
572
|
+
break;
|
|
573
|
+
case 68:
|
|
574
|
+
console.log("\u2139\uFE0F Skipping determining deployment job as no '--deployment-job' name to wait for was passed. Please check CircleCI manually.");
|
|
575
|
+
case 69:
|
|
576
|
+
_context8.next = 72;
|
|
577
|
+
break;
|
|
578
|
+
case 71:
|
|
579
|
+
console.log("\u2139\uFE0F Not approving deployment job. Confirm the prompt or use '--yes' option.");
|
|
580
|
+
case 72:
|
|
581
|
+
case "end":
|
|
582
|
+
return _context8.stop();
|
|
599
583
|
}
|
|
600
584
|
}, _callee);
|
|
601
585
|
}));
|
|
@@ -609,39 +593,37 @@ function _processCircleCiResponse() {
|
|
|
609
593
|
_processCircleCiResponse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(response) {
|
|
610
594
|
var _context4, _context5, errorJson, errorText;
|
|
611
595
|
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context6) {
|
|
612
|
-
while (1) {
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
_context6.next = 14;
|
|
617
|
-
break;
|
|
618
|
-
}
|
|
619
|
-
_context6.prev = 1;
|
|
620
|
-
_context6.next = 4;
|
|
621
|
-
return response.json();
|
|
622
|
-
case 4:
|
|
623
|
-
errorJson = _context6.sent;
|
|
624
|
-
if (errorJson.message.match(/job already approved/i)) {
|
|
625
|
-
console.log('ℹ️ Deployment job is already approved.');
|
|
626
|
-
process.exit(0);
|
|
627
|
-
}
|
|
628
|
-
_context6.next = 10;
|
|
596
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
597
|
+
case 0:
|
|
598
|
+
if (response.ok) {
|
|
599
|
+
_context6.next = 14;
|
|
629
600
|
break;
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
601
|
+
}
|
|
602
|
+
_context6.prev = 1;
|
|
603
|
+
_context6.next = 4;
|
|
604
|
+
return response.json();
|
|
605
|
+
case 4:
|
|
606
|
+
errorJson = _context6.sent;
|
|
607
|
+
if (errorJson.message.match(/job already approved/i)) {
|
|
608
|
+
console.log('ℹ️ Deployment job is already approved.');
|
|
609
|
+
process.exit(0);
|
|
610
|
+
}
|
|
611
|
+
_context6.next = 10;
|
|
612
|
+
break;
|
|
613
|
+
case 8:
|
|
614
|
+
_context6.prev = 8;
|
|
615
|
+
_context6.t0 = _context6["catch"](1);
|
|
616
|
+
case 10:
|
|
617
|
+
_context6.next = 12;
|
|
618
|
+
return response.text();
|
|
619
|
+
case 12:
|
|
620
|
+
errorText = _context6.sent;
|
|
621
|
+
throw new Error(_concatInstanceProperty__default["default"](_context4 = _concatInstanceProperty__default["default"](_context5 = "".concat(response.status, ": Network response was not ok.\n\n Status text is ")).call(_context5, response.statusText, " and text is ")).call(_context4, errorText, "."));
|
|
622
|
+
case 14:
|
|
623
|
+
return _context6.abrupt("return", response.json());
|
|
624
|
+
case 15:
|
|
625
|
+
case "end":
|
|
626
|
+
return _context6.stop();
|
|
645
627
|
}
|
|
646
628
|
}, _callee2, null, [[1, 8]]);
|
|
647
629
|
}));
|
|
@@ -663,7 +645,7 @@ function createCircleCiClient(_ref) {
|
|
|
663
645
|
urlSearchParams,
|
|
664
646
|
_i,
|
|
665
647
|
_Object$entries,
|
|
666
|
-
|
|
648
|
+
_ref7,
|
|
667
649
|
_ref8,
|
|
668
650
|
key,
|
|
669
651
|
value,
|
|
@@ -671,61 +653,59 @@ function createCircleCiClient(_ref) {
|
|
|
671
653
|
processedCircleCiResponse,
|
|
672
654
|
_args = arguments;
|
|
673
655
|
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context3) {
|
|
674
|
-
while (1) {
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
urlSearchParams.append(key, value);
|
|
688
|
-
}
|
|
656
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
657
|
+
case 0:
|
|
658
|
+
_ref6 = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}, skip = _ref6.skip, debug = _ref6.debug;
|
|
659
|
+
url = _concatInstanceProperty__default["default"](_context2 = "".concat(apiBaseUrl)).call(_context2, api.url);
|
|
660
|
+
if (api.params && api.method === 'GET') {
|
|
661
|
+
urlSearchParams = new _URLSearchParams__default["default"]();
|
|
662
|
+
for (_i = 0, _Object$entries = _Object$entries2__default["default"](api.params); _i < _Object$entries.length; _i++) {
|
|
663
|
+
_ref7 = _Object$entries[_i];
|
|
664
|
+
_ref8 = _slicedToArray(_ref7, 2);
|
|
665
|
+
key = _ref8[0];
|
|
666
|
+
value = _ref8[1];
|
|
667
|
+
if (value !== null && value !== undefined) {
|
|
668
|
+
urlSearchParams.append(key, value);
|
|
689
669
|
}
|
|
690
|
-
url += "?".concat(urlSearchParams.toString());
|
|
691
|
-
}
|
|
692
|
-
if (!skip) {
|
|
693
|
-
_context3.next = 6;
|
|
694
|
-
break;
|
|
695
|
-
}
|
|
696
|
-
if (debug) {
|
|
697
|
-
console.log("\uD83C\uDFED Skipping CircleCI call API at: ".concat(url, "."));
|
|
698
670
|
}
|
|
671
|
+
url += "?".concat(urlSearchParams.toString());
|
|
672
|
+
}
|
|
673
|
+
if (!skip) {
|
|
674
|
+
_context3.next = 6;
|
|
675
|
+
break;
|
|
676
|
+
}
|
|
677
|
+
if (debug) {
|
|
678
|
+
console.log("\uD83C\uDFED Skipping CircleCI call API at: ".concat(url, "."));
|
|
679
|
+
}
|
|
699
680
|
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
}
|
|
681
|
+
// @ts-expect-error
|
|
682
|
+
return _context3.abrupt("return", _Promise__default["default"].resolve());
|
|
683
|
+
case 6:
|
|
684
|
+
if (debug) {
|
|
685
|
+
console.log("\uD83C\uDFED Calling CircleCI API at: ".concat(url, "."));
|
|
686
|
+
}
|
|
687
|
+
_context3.prev = 7;
|
|
688
|
+
_context3.next = 10;
|
|
689
|
+
return fetch__default["default"](url, {
|
|
690
|
+
headers: api.headers,
|
|
691
|
+
method: api.method,
|
|
692
|
+
body: api.method === 'POST' ? _JSON$stringify__default["default"](api.params) : undefined
|
|
693
|
+
});
|
|
694
|
+
case 10:
|
|
695
|
+
response = _context3.sent;
|
|
696
|
+
_context3.next = 13;
|
|
697
|
+
return processCircleCiResponse(response);
|
|
698
|
+
case 13:
|
|
699
|
+
processedCircleCiResponse = _context3.sent;
|
|
700
|
+
return _context3.abrupt("return", processedCircleCiResponse);
|
|
701
|
+
case 17:
|
|
702
|
+
_context3.prev = 17;
|
|
703
|
+
_context3.t0 = _context3["catch"](7);
|
|
704
|
+
console.log("\u26A0\uFE0F Calling CircleCI API at: ".concat(url, " failed."));
|
|
705
|
+
throw _context3.t0;
|
|
706
|
+
case 21:
|
|
707
|
+
case "end":
|
|
708
|
+
return _context3.stop();
|
|
729
709
|
}
|
|
730
710
|
}, _callee, null, [[7, 17]]);
|
|
731
711
|
}));
|
|
@@ -817,72 +797,70 @@ function _run() {
|
|
|
817
797
|
_run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
|
|
818
798
|
var config, circleCiApis, _context, cliFlags, cliCommands, cliCommand;
|
|
819
799
|
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context2) {
|
|
820
|
-
while (1) {
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
branch: 'main'
|
|
840
|
-
}
|
|
841
|
-
});
|
|
842
|
-
cliCommands = cliFlags._;
|
|
843
|
-
if (cliCommands.length === 0 ||
|
|
844
|
-
// @ts-expect-error mri is not typed for the help command.
|
|
845
|
-
cliCommands.help && cliCommands.length === 0) {
|
|
846
|
-
console.log("\nUsage: deployment-cli [command] [flags]\n\nDisplays help information.\n\nCommand:\n approve Approves a job and by this triggers a deployment of a component. It requires a \"CIRCLE_TOKEN\" environment variable (https://circleci.com/docs/2.0/managing-api-tokens/).\n\nOptions:\n --approval-job The name of the approval job to approve a deployment with.\n --deployment-job (optional) The name of the deployment job triggered by the approval job. If passed the CLI will print a URL to the deployment triggered on CircleCI.\n --deployment (optional) The name of a deployment configured in the configuration file.\n --build-revision <git-sha> (optional) The git commit SHA that needs to be deployed. If not specified, the last successful pipeline is used.\n --branch (optional) The git branch to deploy from. If not specified, defaults to 'main'.\n --yes (optional) Skip all confirmation prompts. Useful in Continuous integration (CI) to automatically answer confirmation questions.\n\nGeneral options:\n --dry-run (optional) Simulate a deployment.\n --debug (optional) Print additional debug information.\n");
|
|
847
|
-
process.exit(0);
|
|
848
|
-
}
|
|
849
|
-
cliCommand = cliCommands[0];
|
|
850
|
-
if (cliFlags['dry-run']) {
|
|
851
|
-
console.log("\n \uD83D\uDE4A Do not worry. This is a dry run!\n ");
|
|
800
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
801
|
+
case 0:
|
|
802
|
+
_context2.next = 2;
|
|
803
|
+
return loadConfig();
|
|
804
|
+
case 2:
|
|
805
|
+
config = _context2.sent;
|
|
806
|
+
throwIfConfigurationLacksRequiredValues(config);
|
|
807
|
+
circleCiApis = createCircleCiClient({
|
|
808
|
+
projectName: config.CircleCI.projectName,
|
|
809
|
+
apiBaseUrl: config.CircleCI.apiBaseUrl
|
|
810
|
+
});
|
|
811
|
+
_context2.prev = 5;
|
|
812
|
+
cliFlags = mri__default["default"](_sliceInstanceProperty__default["default"](_context = process.argv).call(_context, 2), {
|
|
813
|
+
alias: {
|
|
814
|
+
help: ['h']
|
|
815
|
+
},
|
|
816
|
+
boolean: ['dry-run', 'debug', 'yes'],
|
|
817
|
+
default: {
|
|
818
|
+
branch: 'main'
|
|
852
819
|
}
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
_context2.next = 18;
|
|
860
|
-
return approve({
|
|
861
|
-
deployment: cliFlags.deployment,
|
|
862
|
-
branch: cliFlags.branch,
|
|
863
|
-
approvalJob: cliFlags['approval-job'],
|
|
864
|
-
deploymentJob: cliFlags['deployment-job'],
|
|
865
|
-
buildRevision: cliFlags['build-revision'],
|
|
866
|
-
yes: cliFlags.yes,
|
|
867
|
-
debug: cliFlags.debug,
|
|
868
|
-
dryRun: cliFlags['dry-run']
|
|
869
|
-
}, config, circleCiApis);
|
|
870
|
-
case 18:
|
|
820
|
+
});
|
|
821
|
+
cliCommands = cliFlags._;
|
|
822
|
+
if (cliCommands.length === 0 ||
|
|
823
|
+
// @ts-expect-error mri is not typed for the help command.
|
|
824
|
+
cliCommands.help && cliCommands.length === 0) {
|
|
825
|
+
console.log("\nUsage: deployment-cli [command] [flags]\n\nDisplays help information.\n\nCommand:\n approve Approves a job and by this triggers a deployment of a component. It requires a \"CIRCLE_TOKEN\" environment variable (https://circleci.com/docs/2.0/managing-api-tokens/).\n\nOptions:\n --approval-job The name of the approval job to approve a deployment with.\n --deployment-job (optional) The name of the deployment job triggered by the approval job. If passed the CLI will print a URL to the deployment triggered on CircleCI.\n --deployment (optional) The name of a deployment configured in the configuration file.\n --build-revision <git-sha> (optional) The git commit SHA that needs to be deployed. If not specified, the last successful pipeline is used.\n --branch (optional) The git branch to deploy from. If not specified, defaults to 'main'.\n --yes (optional) Skip all confirmation prompts. Useful in Continuous integration (CI) to automatically answer confirmation questions.\n\nGeneral options:\n --dry-run (optional) Simulate a deployment.\n --debug (optional) Print additional debug information.\n");
|
|
871
826
|
process.exit(0);
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
827
|
+
}
|
|
828
|
+
cliCommand = cliCommands[0];
|
|
829
|
+
if (cliFlags['dry-run']) {
|
|
830
|
+
console.log("\n \uD83D\uDE4A Do not worry. This is a dry run!\n ");
|
|
831
|
+
}
|
|
832
|
+
console.log("\uD83C\uDFC3 Running ".concat(cliCommand, " command"));
|
|
833
|
+
_context2.t0 = cliCommand;
|
|
834
|
+
_context2.next = _context2.t0 === 'approve' ? 15 : 19;
|
|
835
|
+
break;
|
|
836
|
+
case 15:
|
|
837
|
+
throwIfRequiredEnvironmentVariableIsUnset(['CIRCLE_TOKEN']);
|
|
838
|
+
_context2.next = 18;
|
|
839
|
+
return approve({
|
|
840
|
+
deployment: cliFlags.deployment,
|
|
841
|
+
branch: cliFlags.branch,
|
|
842
|
+
approvalJob: cliFlags['approval-job'],
|
|
843
|
+
deploymentJob: cliFlags['deployment-job'],
|
|
844
|
+
buildRevision: cliFlags['build-revision'],
|
|
845
|
+
yes: cliFlags.yes,
|
|
846
|
+
debug: cliFlags.debug,
|
|
847
|
+
dryRun: cliFlags['dry-run']
|
|
848
|
+
}, config, circleCiApis);
|
|
849
|
+
case 18:
|
|
850
|
+
process.exit(0);
|
|
851
|
+
case 19:
|
|
852
|
+
throw new Error("\uD83D\uDC80 Unknown command \"".concat(cliCommand, "\"."));
|
|
853
|
+
case 20:
|
|
854
|
+
_context2.next = 26;
|
|
855
|
+
break;
|
|
856
|
+
case 22:
|
|
857
|
+
_context2.prev = 22;
|
|
858
|
+
_context2.t1 = _context2["catch"](5);
|
|
859
|
+
console.error(_context2.t1);
|
|
860
|
+
process.exit(1);
|
|
861
|
+
case 26:
|
|
862
|
+
case "end":
|
|
863
|
+
return _context2.stop();
|
|
886
864
|
}
|
|
887
865
|
}, _callee, null, [[5, 22]]);
|
|
888
866
|
}));
|