@commercetools-frontend/deployment-cli 2.0.0 â 2.0.2
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/cli/dist/commercetools-frontend-deployment-cli-cli.cjs.d.ts +1 -1
- package/cli/dist/commercetools-frontend-deployment-cli-cli.cjs.dev.js +73 -87
- package/cli/dist/commercetools-frontend-deployment-cli-cli.cjs.prod.js +73 -87
- package/cli/dist/commercetools-frontend-deployment-cli-cli.esm.js +72 -86
- package/dist/commercetools-frontend-deployment-cli.cjs.d.ts +1 -1
- package/package.json +3 -3
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { cac } from 'cac';
|
|
2
|
-
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
3
2
|
import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
|
|
4
3
|
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
|
|
5
4
|
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
6
5
|
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
7
6
|
import _startsWithInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/starts-with';
|
|
7
|
+
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
8
8
|
import { cosmiconfig } from 'cosmiconfig';
|
|
9
9
|
import merge from 'lodash/merge';
|
|
10
10
|
import prompts from 'prompts';
|
|
@@ -18,7 +18,7 @@ import { exit } from 'node:process';
|
|
|
18
18
|
|
|
19
19
|
var pkgJson = {
|
|
20
20
|
name: "@commercetools-frontend/deployment-cli",
|
|
21
|
-
version: "2.0.
|
|
21
|
+
version: "2.0.2",
|
|
22
22
|
description: "CLI to manage Custom Applications deployments in Google Storage.",
|
|
23
23
|
keywords: [
|
|
24
24
|
"commercetools",
|
|
@@ -53,9 +53,9 @@ var pkgJson = {
|
|
|
53
53
|
devDependencies: {
|
|
54
54
|
"@tsconfig/node20": "20.1.4",
|
|
55
55
|
"@types/lodash": "^4.14.198",
|
|
56
|
-
"@types/node": "20.
|
|
56
|
+
"@types/node": "20.16.10",
|
|
57
57
|
"@types/prompts": "2.4.9",
|
|
58
|
-
msw: "1.3.
|
|
58
|
+
msw: "1.3.5",
|
|
59
59
|
typescript: "5.2.2"
|
|
60
60
|
},
|
|
61
61
|
engines: {
|
|
@@ -90,7 +90,7 @@ async function loadConfig() {
|
|
|
90
90
|
};
|
|
91
91
|
try {
|
|
92
92
|
const cosmiconfigResult = await deploymentConfigExplorer.search();
|
|
93
|
-
const mergedConfig = merge(defaultConfig, cosmiconfigResult
|
|
93
|
+
const mergedConfig = merge(defaultConfig, cosmiconfigResult?.config);
|
|
94
94
|
return mergedConfig;
|
|
95
95
|
} catch (e) {
|
|
96
96
|
console.warn(e);
|
|
@@ -99,13 +99,13 @@ async function loadConfig() {
|
|
|
99
99
|
}
|
|
100
100
|
function throwIfConfigurationLacksRequiredValues(parsedConfiguration) {
|
|
101
101
|
if (!parsedConfiguration.CircleCI.projectName) {
|
|
102
|
-
throw new Error(
|
|
102
|
+
throw new Error(`Missing 'projectName' in 'CircleCI' on configuration. Make sure it exists!`);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
function throwIfRequiredEnvironmentVariableIsUnset(requiredEnvironmentVariables) {
|
|
106
106
|
_forEachInstanceProperty(requiredEnvironmentVariables).call(requiredEnvironmentVariables, nameOfRequiredEnvironmentVariable => {
|
|
107
107
|
const valueOfRequiredEnvironmentVariable = process.env[nameOfRequiredEnvironmentVariable];
|
|
108
|
-
if (!valueOfRequiredEnvironmentVariable) throw new Error(
|
|
108
|
+
if (!valueOfRequiredEnvironmentVariable) throw new Error(`Missing '${nameOfRequiredEnvironmentVariable}' environment variable`);
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
111
|
const promptOptions = {
|
|
@@ -131,23 +131,19 @@ const promptOptions = {
|
|
|
131
131
|
type: 'select',
|
|
132
132
|
name: 'deploymentPipeline',
|
|
133
133
|
message: 'Select the revision you would like to deploy',
|
|
134
|
-
choices: _mapInstanceProperty(deploymentPipelines).call(deploymentPipelines, deploymentPipeline => {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
value: deploymentPipeline
|
|
139
|
-
};
|
|
140
|
-
})
|
|
134
|
+
choices: _mapInstanceProperty(deploymentPipelines).call(deploymentPipelines, deploymentPipeline => ({
|
|
135
|
+
title: `${deploymentPipeline.vcs.revision.substring(0, 7)} - ${deploymentPipeline.vcs.commit.subject} <${deploymentPipeline.trigger.actor.login}>`,
|
|
136
|
+
value: deploymentPipeline
|
|
137
|
+
}))
|
|
141
138
|
};
|
|
142
139
|
},
|
|
143
140
|
deploymentConfirmation: _ref4 => {
|
|
144
|
-
var _context3;
|
|
145
141
|
let approvalJob = _ref4.approvalJob,
|
|
146
142
|
revision = _ref4.revision;
|
|
147
143
|
return {
|
|
148
144
|
type: 'toggle',
|
|
149
145
|
name: 'confirmed',
|
|
150
|
-
message:
|
|
146
|
+
message: `Are you sure you want to deploy by approving ${approvalJob} at ${revision}?`,
|
|
151
147
|
initial: false,
|
|
152
148
|
active: 'Yes',
|
|
153
149
|
inactive: 'No'
|
|
@@ -164,7 +160,7 @@ async function paginateToDeploymentPipeline(_ref5) {
|
|
|
164
160
|
let nextPageToken;
|
|
165
161
|
// eslint-disable-next-line no-plusplus
|
|
166
162
|
for (let i = 0; i < maxPages; i++) {
|
|
167
|
-
var
|
|
163
|
+
var _context, _context2;
|
|
168
164
|
// eslint-disable-next-line no-await-in-loop
|
|
169
165
|
|
|
170
166
|
const pipelineRequest = circleCiApis.pipelines({
|
|
@@ -175,19 +171,18 @@ async function paginateToDeploymentPipeline(_ref5) {
|
|
|
175
171
|
debug
|
|
176
172
|
});
|
|
177
173
|
nextPageToken = pipelines.next_page_token;
|
|
178
|
-
const nonScheduledPipelines = _filterInstanceProperty(
|
|
174
|
+
const nonScheduledPipelines = _filterInstanceProperty(_context = _filterInstanceProperty(_context2 = pipelines.items).call(_context2, isNonScheduledPipeline)).call(_context, isNonErroredPipeline);
|
|
179
175
|
if (buildRevision) {
|
|
180
|
-
|
|
181
|
-
console.log(_concatInstanceProperty(_context6 = _concatInstanceProperty(_context7 = "\uD83D\uDD04 Trying to find pipeline with revision ".concat(buildRevision, ". Attempt ")).call(_context7, i + 1, " out of ")).call(_context6, maxPages, "."));
|
|
176
|
+
console.log(`đ Trying to find pipeline with revision ${buildRevision}. Attempt ${i + 1} out of ${maxPages}.`);
|
|
182
177
|
deploymentPipeline = _findInstanceProperty(nonScheduledPipelines).call(nonScheduledPipelines, pipeline => {
|
|
183
|
-
var
|
|
184
|
-
return _startsWithInstanceProperty(
|
|
178
|
+
var _context3;
|
|
179
|
+
return _startsWithInstanceProperty(_context3 = pipeline.vcs.revision).call(_context3, buildRevision);
|
|
185
180
|
});
|
|
186
181
|
} else {
|
|
187
182
|
deploymentPipeline = nonScheduledPipelines[0];
|
|
188
183
|
}
|
|
189
184
|
if (deploymentPipeline) {
|
|
190
|
-
console.log(
|
|
185
|
+
console.log(`âšī¸ Using pipeline for deployment with revision ${deploymentPipeline.vcs.revision}.`);
|
|
191
186
|
break;
|
|
192
187
|
}
|
|
193
188
|
}
|
|
@@ -202,7 +197,7 @@ async function collectDeploymentPipelines(_ref6) {
|
|
|
202
197
|
let nextPageToken;
|
|
203
198
|
// eslint-disable-next-line no-plusplus
|
|
204
199
|
for (let i = 0; i < pagesForPipelineSelection; i++) {
|
|
205
|
-
var
|
|
200
|
+
var _context4, _context5;
|
|
206
201
|
// eslint-disable-next-line no-await-in-loop
|
|
207
202
|
const pipelinesRequest = circleCiApis.pipelines({
|
|
208
203
|
pageToken: nextPageToken,
|
|
@@ -211,7 +206,7 @@ async function collectDeploymentPipelines(_ref6) {
|
|
|
211
206
|
const pipelines = await pipelinesRequest.execute({
|
|
212
207
|
debug
|
|
213
208
|
});
|
|
214
|
-
const nonScheduledPipelines = _filterInstanceProperty(
|
|
209
|
+
const nonScheduledPipelines = _filterInstanceProperty(_context4 = _filterInstanceProperty(_context5 = pipelines.items).call(_context5, isNonScheduledPipeline)).call(_context4, isNonErroredPipeline);
|
|
215
210
|
deploymentPipelines = _concatInstanceProperty(deploymentPipelines).call(deploymentPipelines, nonScheduledPipelines);
|
|
216
211
|
}
|
|
217
212
|
return deploymentPipelines;
|
|
@@ -250,12 +245,11 @@ async function waitForConfirmationPrompt(_ref8) {
|
|
|
250
245
|
}));
|
|
251
246
|
}
|
|
252
247
|
function getJobUrl(_ref9) {
|
|
253
|
-
var _context11, _context12, _context13;
|
|
254
248
|
let pipelineNumber = _ref9.pipelineNumber,
|
|
255
249
|
workflowId = _ref9.workflowId,
|
|
256
250
|
jobNumber = _ref9.jobNumber,
|
|
257
251
|
projectName = _ref9.projectName;
|
|
258
|
-
return
|
|
252
|
+
return `https://app.circleci.com/pipelines/github/commercetools/${projectName}/${pipelineNumber}/workflows/${workflowId}/jobs/${jobNumber}`;
|
|
259
253
|
}
|
|
260
254
|
function isNonScheduledPipeline(pipeline) {
|
|
261
255
|
return pipeline.trigger.type !== 'schedule' && pipeline.trigger.type !== 'scheduled_pipeline';
|
|
@@ -269,14 +263,14 @@ async function waitForDeploymentJobNumber(_ref10, _ref11) {
|
|
|
269
263
|
circleCiApis = _ref10.circleCiApis;
|
|
270
264
|
let debug = _ref11.debug;
|
|
271
265
|
const fetchDeploymentJobNumber = async () => {
|
|
272
|
-
var
|
|
266
|
+
var _context6;
|
|
273
267
|
const jobsRequest = circleCiApis.jobs({
|
|
274
268
|
workflowId
|
|
275
269
|
});
|
|
276
270
|
const jobs = await jobsRequest.execute({
|
|
277
271
|
debug
|
|
278
272
|
});
|
|
279
|
-
const applicationDeploymentJob = _findInstanceProperty(
|
|
273
|
+
const applicationDeploymentJob = _findInstanceProperty(_context6 = jobs.items).call(_context6, job => job.name === deploymentJob);
|
|
280
274
|
if (!applicationDeploymentJob || applicationDeploymentJob.status === 'blocked') {
|
|
281
275
|
throw new Error('Deployment job not yet running. Retrying.');
|
|
282
276
|
}
|
|
@@ -284,8 +278,7 @@ async function waitForDeploymentJobNumber(_ref10, _ref11) {
|
|
|
284
278
|
};
|
|
285
279
|
const deploymentJobNumber = await pRetry(fetchDeploymentJobNumber, {
|
|
286
280
|
onFailedAttempt: error => {
|
|
287
|
-
|
|
288
|
-
console.log(_concatInstanceProperty(_context15 = "\uD83D\uDD04 Trying to find deployment job. Attempt ".concat(error.attemptNumber, " with ")).call(_context15, error.retriesLeft, " retries left."));
|
|
281
|
+
console.log(`đ Trying to find deployment job. Attempt ${error.attemptNumber} with ${error.retriesLeft} retries left.`);
|
|
289
282
|
},
|
|
290
283
|
retries: 10
|
|
291
284
|
});
|
|
@@ -293,65 +286,63 @@ async function waitForDeploymentJobNumber(_ref10, _ref11) {
|
|
|
293
286
|
}
|
|
294
287
|
|
|
295
288
|
async function approve(cliFlags, config, circleCiApis) {
|
|
296
|
-
var
|
|
289
|
+
var _context, _context2;
|
|
297
290
|
let approvalJob;
|
|
298
291
|
let deploymentJob;
|
|
299
292
|
if (cliFlags.deployment) {
|
|
300
|
-
|
|
301
|
-
const requestedDeployment = (_config$deployments = config.deployments) === null || _config$deployments === void 0 ? void 0 : _config$deployments[cliFlags.deployment];
|
|
293
|
+
const requestedDeployment = config.deployments?.[cliFlags.deployment];
|
|
302
294
|
if (!requestedDeployment) {
|
|
303
|
-
throw new Error(
|
|
295
|
+
throw new Error(`â ī¸ Deployment ${cliFlags.deployment} not found in configuration. Make sure it exists.`);
|
|
304
296
|
}
|
|
305
297
|
approvalJob = requestedDeployment.jobs.approval;
|
|
306
298
|
deploymentJob = requestedDeployment.jobs.deployment;
|
|
307
|
-
console.log(
|
|
299
|
+
console.log(`âšī¸ Approving requested deployment ${cliFlags.deployment} with approval job ${approvalJob}.`);
|
|
308
300
|
} else {
|
|
309
301
|
approvalJob = cliFlags.approvalJob;
|
|
310
302
|
deploymentJob = cliFlags.deploymentJob;
|
|
311
|
-
console.log(
|
|
303
|
+
console.log(`âšī¸ Approving with approval job ${approvalJob}.`);
|
|
312
304
|
}
|
|
313
305
|
const deploymentPipeline = cliFlags.yes ? await paginateToDeploymentPipeline({
|
|
314
306
|
circleCiApis,
|
|
315
307
|
buildRevision: cliFlags.buildRevision,
|
|
316
308
|
branch: cliFlags.branch,
|
|
317
309
|
debug: cliFlags.debug,
|
|
318
|
-
maxPages:
|
|
310
|
+
maxPages: config.CircleCI.pagination?.maxPages ?? 1
|
|
319
311
|
}) : await waitForDeploymentPipelinePrompt({
|
|
320
312
|
branch: cliFlags.branch,
|
|
321
313
|
circleCiApis,
|
|
322
|
-
pagesForPipelineSelection:
|
|
314
|
+
pagesForPipelineSelection: config.CircleCI.pagination?.pagesForPipelineSelection ?? 1,
|
|
323
315
|
debug: cliFlags.debug
|
|
324
316
|
});
|
|
325
317
|
if (!deploymentPipeline) {
|
|
326
|
-
throw new Error(
|
|
318
|
+
throw new Error(`â ī¸ No workflow called ${config.CircleCI.deploymentWorkflowName} found in any pipeline for deployment.`);
|
|
327
319
|
}
|
|
328
|
-
console.log(
|
|
320
|
+
console.log(`âšī¸ Found pipeline for deployment with revision ${deploymentPipeline.vcs.revision}.`);
|
|
329
321
|
const workflowsRequest = circleCiApis.workflows({
|
|
330
322
|
pipelineId: deploymentPipeline.id
|
|
331
323
|
});
|
|
332
324
|
const workflows = await workflowsRequest.execute({
|
|
333
325
|
debug: cliFlags.debug
|
|
334
326
|
});
|
|
335
|
-
const buildAndDeployWorkflow = _findInstanceProperty(
|
|
327
|
+
const buildAndDeployWorkflow = _findInstanceProperty(_context = workflows.items).call(_context, workflow => workflow.name === config.CircleCI.deploymentWorkflowName);
|
|
336
328
|
if (!buildAndDeployWorkflow) {
|
|
337
|
-
throw new Error(
|
|
329
|
+
throw new Error(`â ī¸ No workflow called ${config.CircleCI.deploymentWorkflowName} found for deployment.`);
|
|
338
330
|
}
|
|
339
331
|
const workflowId = buildAndDeployWorkflow.id;
|
|
340
|
-
console.log(
|
|
332
|
+
console.log(`âšī¸ Found workflow to build and deploy with id ${workflowId}.`);
|
|
341
333
|
const jobsRequest = circleCiApis.jobs({
|
|
342
334
|
workflowId
|
|
343
335
|
});
|
|
344
336
|
const jobs = await jobsRequest.execute({
|
|
345
337
|
debug: cliFlags.debug
|
|
346
338
|
});
|
|
347
|
-
console.log(
|
|
348
|
-
const applicationApprovalJob = _findInstanceProperty(
|
|
349
|
-
const applicationApprovalJobId = applicationApprovalJob
|
|
339
|
+
console.log(`âšī¸ Found jobs for workflow.`);
|
|
340
|
+
const applicationApprovalJob = _findInstanceProperty(_context2 = jobs.items).call(_context2, job => job.name === approvalJob);
|
|
341
|
+
const applicationApprovalJobId = applicationApprovalJob?.id;
|
|
350
342
|
if (!applicationApprovalJobId) {
|
|
351
|
-
|
|
352
|
-
throw new Error(_concatInstanceProperty(_context4 = "\u270C\uFE0F Could not find deployment approval job named ".concat(approvalJob, " at revision ")).call(_context4, deploymentPipeline.vcs.revision, ". Maybe try again later."));
|
|
343
|
+
throw new Error(`âī¸ Could not find deployment approval job named ${approvalJob} at revision ${deploymentPipeline.vcs.revision}. Maybe try again later.`);
|
|
353
344
|
}
|
|
354
|
-
console.log(
|
|
345
|
+
console.log(`âšī¸ Found deployment approval job named ${approvalJob} with id ${applicationApprovalJobId}.`);
|
|
355
346
|
let confirmationPrompt;
|
|
356
347
|
if (!cliFlags.yes) {
|
|
357
348
|
confirmationPrompt = await waitForConfirmationPrompt({
|
|
@@ -359,11 +350,11 @@ async function approve(cliFlags, config, circleCiApis) {
|
|
|
359
350
|
revision: deploymentPipeline.vcs.revision
|
|
360
351
|
});
|
|
361
352
|
}
|
|
362
|
-
if (cliFlags.yes ||
|
|
353
|
+
if (cliFlags.yes || confirmationPrompt?.confirmed) {
|
|
363
354
|
if (cliFlags.dryRun) {
|
|
364
|
-
console.log(
|
|
355
|
+
console.log(`đ Not approving deployment job due to dry run.`);
|
|
365
356
|
} else {
|
|
366
|
-
console.log(
|
|
357
|
+
console.log(`âšī¸ Approving deployment job.`);
|
|
367
358
|
}
|
|
368
359
|
const approvalRequest = circleCiApis.approve({
|
|
369
360
|
workflowId,
|
|
@@ -374,11 +365,10 @@ async function approve(cliFlags, config, circleCiApis) {
|
|
|
374
365
|
skip: cliFlags.dryRun
|
|
375
366
|
});
|
|
376
367
|
if (cliFlags.yes) {
|
|
377
|
-
console.log(
|
|
368
|
+
console.log(`âšī¸ Skipping determining deployment job approved by ${approvalJob} due to '--yes' flag. Please check CircleCI manually.`);
|
|
378
369
|
} else if (cliFlags.dryRun) {
|
|
379
|
-
console.log(
|
|
370
|
+
console.log(`âī¸ Dry running hence could not determine deployment job approved by ${approvalJob}.`);
|
|
380
371
|
} else if (deploymentJob) {
|
|
381
|
-
var _context6, _context7;
|
|
382
372
|
const deploymentJobNumber = await waitForDeploymentJobNumber({
|
|
383
373
|
workflowId,
|
|
384
374
|
deploymentJob,
|
|
@@ -388,23 +378,22 @@ async function approve(cliFlags, config, circleCiApis) {
|
|
|
388
378
|
dryRun: cliFlags.dryRun,
|
|
389
379
|
yes: cliFlags.yes
|
|
390
380
|
});
|
|
391
|
-
console.log(
|
|
381
|
+
console.log(`đ The deployment via ${approvalJob} at revision ${deploymentPipeline.vcs.revision} is running at: ${getJobUrl({
|
|
392
382
|
projectName: config.CircleCI.projectName,
|
|
393
383
|
pipelineNumber: deploymentPipeline.number,
|
|
394
384
|
workflowId,
|
|
395
385
|
jobNumber: deploymentJobNumber
|
|
396
|
-
}))
|
|
386
|
+
})}`);
|
|
397
387
|
} else {
|
|
398
|
-
console.log(
|
|
388
|
+
console.log(`âšī¸ Skipping determining deployment job as no '--deployment-job' name to wait for was passed. Please check CircleCI manually.`);
|
|
399
389
|
}
|
|
400
390
|
} else {
|
|
401
|
-
console.log(
|
|
391
|
+
console.log(`âšī¸ Not approving deployment job. Confirm the prompt or use '--yes' option.`);
|
|
402
392
|
}
|
|
403
393
|
}
|
|
404
394
|
|
|
405
395
|
async function processCircleCiResponse(response) {
|
|
406
396
|
if (!response.ok) {
|
|
407
|
-
var _context, _context2;
|
|
408
397
|
/**
|
|
409
398
|
* NOTE:
|
|
410
399
|
* Trying to handle known but undocumented responses of the CircleCI API.
|
|
@@ -430,7 +419,8 @@ async function processCircleCiResponse(response) {
|
|
|
430
419
|
} catch {
|
|
431
420
|
// Ignore JSON parsing errors
|
|
432
421
|
}
|
|
433
|
-
throw new Error(
|
|
422
|
+
throw new Error(`${response.status}: Network response was not ok.\n
|
|
423
|
+
Status text is ${response.statusText} and text is ${error}.`);
|
|
434
424
|
}
|
|
435
425
|
return response.json();
|
|
436
426
|
}
|
|
@@ -438,11 +428,10 @@ function createCircleCiClient(_ref) {
|
|
|
438
428
|
let projectName = _ref.projectName,
|
|
439
429
|
apiBaseUrl = _ref.apiBaseUrl;
|
|
440
430
|
async function execute(api) {
|
|
441
|
-
var _context3;
|
|
442
431
|
let _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
443
432
|
skip = _ref2.skip,
|
|
444
433
|
debug = _ref2.debug;
|
|
445
|
-
let url =
|
|
434
|
+
let url = `${apiBaseUrl}${api.url}`;
|
|
446
435
|
if (api.params && api.method === 'GET') {
|
|
447
436
|
const urlSearchParams = new _URLSearchParams();
|
|
448
437
|
for (const _ref3 of _Object$entries(api.params)) {
|
|
@@ -453,18 +442,18 @@ function createCircleCiClient(_ref) {
|
|
|
453
442
|
urlSearchParams.append(key, value);
|
|
454
443
|
}
|
|
455
444
|
}
|
|
456
|
-
url +=
|
|
445
|
+
url += `?${urlSearchParams.toString()}`;
|
|
457
446
|
}
|
|
458
447
|
if (skip) {
|
|
459
448
|
if (debug) {
|
|
460
|
-
console.log(
|
|
449
|
+
console.log(`đ Skipping CircleCI call API at: ${url}.`);
|
|
461
450
|
}
|
|
462
451
|
|
|
463
452
|
// @ts-expect-error
|
|
464
453
|
return _Promise.resolve();
|
|
465
454
|
}
|
|
466
455
|
if (debug) {
|
|
467
|
-
console.log(
|
|
456
|
+
console.log(`đ Calling CircleCI API at: ${url}.`);
|
|
468
457
|
}
|
|
469
458
|
try {
|
|
470
459
|
const response = await fetch(url, {
|
|
@@ -475,7 +464,7 @@ function createCircleCiClient(_ref) {
|
|
|
475
464
|
const processedCircleCiResponse = await processCircleCiResponse(response);
|
|
476
465
|
return processedCircleCiResponse;
|
|
477
466
|
} catch (error) {
|
|
478
|
-
console.log(
|
|
467
|
+
console.log(`â ī¸ Calling CircleCI API at: ${url} failed.`);
|
|
479
468
|
throw error;
|
|
480
469
|
}
|
|
481
470
|
}
|
|
@@ -484,12 +473,12 @@ function createCircleCiClient(_ref) {
|
|
|
484
473
|
let _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
485
474
|
pageToken = _ref5.pageToken,
|
|
486
475
|
_ref5$projectSlug = _ref5.projectSlug,
|
|
487
|
-
projectSlug = _ref5$projectSlug === void 0 ?
|
|
476
|
+
projectSlug = _ref5$projectSlug === void 0 ? `gh/commercetools/${projectName}` : _ref5$projectSlug,
|
|
488
477
|
_ref5$branch = _ref5.branch,
|
|
489
478
|
branch = _ref5$branch === void 0 ? 'main' : _ref5$branch;
|
|
490
479
|
return {
|
|
491
480
|
execute: options => execute({
|
|
492
|
-
url:
|
|
481
|
+
url: `/project/${projectSlug}/pipeline`,
|
|
493
482
|
headers: {
|
|
494
483
|
'Content-Type': 'application/json',
|
|
495
484
|
// The CLI throws if this is not present on environment
|
|
@@ -507,7 +496,7 @@ function createCircleCiClient(_ref) {
|
|
|
507
496
|
let pipelineId = _ref6.pipelineId;
|
|
508
497
|
return {
|
|
509
498
|
execute: options => execute({
|
|
510
|
-
url:
|
|
499
|
+
url: `/pipeline/${pipelineId}/workflow`,
|
|
511
500
|
headers: {
|
|
512
501
|
'Content-Type': 'application/json',
|
|
513
502
|
// The CLI throws if this is not present on environment
|
|
@@ -521,7 +510,7 @@ function createCircleCiClient(_ref) {
|
|
|
521
510
|
let workflowId = _ref7.workflowId;
|
|
522
511
|
return {
|
|
523
512
|
execute: options => execute({
|
|
524
|
-
url:
|
|
513
|
+
url: `/workflow/${workflowId}/job`,
|
|
525
514
|
headers: {
|
|
526
515
|
'Content-Type': 'application/json',
|
|
527
516
|
// The CLI throws if this is not present on environment
|
|
@@ -535,18 +524,15 @@ function createCircleCiClient(_ref) {
|
|
|
535
524
|
let workflowId = _ref8.workflowId,
|
|
536
525
|
approvalRequestId = _ref8.approvalRequestId;
|
|
537
526
|
return {
|
|
538
|
-
execute: options => {
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
method: 'POST'
|
|
548
|
-
}, options);
|
|
549
|
-
}
|
|
527
|
+
execute: options => execute({
|
|
528
|
+
url: `/workflow/${workflowId}/approve/${approvalRequestId} `,
|
|
529
|
+
headers: {
|
|
530
|
+
'Content-Type': 'application/json',
|
|
531
|
+
// The CLI throws if this is not present on environment
|
|
532
|
+
'Circle-Token': process.env.CIRCLE_TOKEN
|
|
533
|
+
},
|
|
534
|
+
method: 'POST'
|
|
535
|
+
}, options)
|
|
550
536
|
};
|
|
551
537
|
}
|
|
552
538
|
};
|
|
@@ -574,13 +560,13 @@ async function run() {
|
|
|
574
560
|
|
|
575
561
|
// Command: Approve
|
|
576
562
|
const usageApprove = '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/).';
|
|
577
|
-
cli.command('approve', usageApprove).usage(
|
|
563
|
+
cli.command('approve', usageApprove).usage(`approve \n\n ${usageApprove}`).option('--approval-job <string>', 'The name of the approval job to approve a deployment with.').option('--deployment-job [string]', '(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.').option('--deployment [string]', '(optional) The name of a deployment configured in the configuration file.').option('--build-revision [git-sha]', '(optional) The git commit SHA that needs to be deployed. If not specified, the last successful pipeline is used.').option('--branch [string]', '(optional) The git branch to deploy from. If not specified.', {
|
|
578
564
|
default: 'main'
|
|
579
565
|
}).option('--yes', '(optional) Skip all confirmation prompts. Useful in Continuous integration (CI) to automatically answer confirmation questions.', {
|
|
580
566
|
default: false
|
|
581
567
|
}).action(async options => {
|
|
582
568
|
if (options.dryRun) {
|
|
583
|
-
console.log(
|
|
569
|
+
console.log(`đ Do not worry. This is a dry run!`);
|
|
584
570
|
}
|
|
585
571
|
throwIfRequiredEnvironmentVariableIsUnset(['CIRCLE_TOKEN']);
|
|
586
572
|
await approve(options, config, circleCiApis);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./declarations/src/index";
|
|
1
|
+
export * from "./declarations/src/index.js";
|
|
2
2
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWVyY2V0b29scy1mcm9udGVuZC1kZXBsb3ltZW50LWNsaS5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4vZGVjbGFyYXRpb25zL3NyYy9pbmRleC5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/deployment-cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "CLI to manage Custom Applications deployments in Google Storage.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"commercetools",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@tsconfig/node20": "20.1.4",
|
|
34
34
|
"@types/lodash": "^4.14.198",
|
|
35
|
-
"@types/node": "20.
|
|
35
|
+
"@types/node": "20.16.10",
|
|
36
36
|
"@types/prompts": "2.4.9",
|
|
37
|
-
"msw": "1.3.
|
|
37
|
+
"msw": "1.3.5",
|
|
38
38
|
"typescript": "5.2.2"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|