@commercetools-frontend/deployment-cli 2.0.0 → 2.0.1

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.
@@ -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.0",
21
+ version: "2.0.1",
22
22
  description: "CLI to manage Custom Applications deployments in Google Storage.",
23
23
  keywords: [
24
24
  "commercetools",
@@ -53,7 +53,7 @@ var pkgJson = {
53
53
  devDependencies: {
54
54
  "@tsconfig/node20": "20.1.4",
55
55
  "@types/lodash": "^4.14.198",
56
- "@types/node": "20.12.12",
56
+ "@types/node": "20.14.14",
57
57
  "@types/prompts": "2.4.9",
58
58
  msw: "1.3.3",
59
59
  typescript: "5.2.2"
@@ -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 === null || cosmiconfigResult === void 0 ? void 0 : cosmiconfigResult.config);
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("Missing 'projectName' in 'CircleCI' on configuration. Make sure it exists!");
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("Missing '".concat(nameOfRequiredEnvironmentVariable, "' environment variable"));
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
- var _context, _context2;
136
- return {
137
- title: _concatInstanceProperty(_context = _concatInstanceProperty(_context2 = "".concat(deploymentPipeline.vcs.revision.substring(0, 7), " - ")).call(_context2, deploymentPipeline.vcs.commit.subject, " <")).call(_context, deploymentPipeline.trigger.actor.login, ">"),
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: _concatInstanceProperty(_context3 = "Are you sure you want to deploy by approving ".concat(approvalJob, " at ")).call(_context3, revision, "?"),
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 _context4, _context5;
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(_context4 = _filterInstanceProperty(_context5 = pipelines.items).call(_context5, isNonScheduledPipeline)).call(_context4, isNonErroredPipeline);
174
+ const nonScheduledPipelines = _filterInstanceProperty(_context = _filterInstanceProperty(_context2 = pipelines.items).call(_context2, isNonScheduledPipeline)).call(_context, isNonErroredPipeline);
179
175
  if (buildRevision) {
180
- var _context6, _context7;
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 _context8;
184
- return _startsWithInstanceProperty(_context8 = pipeline.vcs.revision).call(_context8, buildRevision);
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("\u2139\uFE0F Using pipeline for deployment with revision ".concat(deploymentPipeline.vcs.revision, "."));
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 _context9, _context10;
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(_context9 = _filterInstanceProperty(_context10 = pipelines.items).call(_context10, isNonScheduledPipeline)).call(_context9, isNonErroredPipeline);
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 _concatInstanceProperty(_context11 = _concatInstanceProperty(_context12 = _concatInstanceProperty(_context13 = "https://app.circleci.com/pipelines/github/commercetools/".concat(projectName, "/")).call(_context13, pipelineNumber, "/workflows/")).call(_context12, workflowId, "/jobs/")).call(_context11, jobNumber);
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 _context14;
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(_context14 = jobs.items).call(_context14, job => job.name === deploymentJob);
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
- var _context15;
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 _config$CircleCI$pagi, _config$CircleCI$pagi2, _config$CircleCI$pagi3, _config$CircleCI$pagi4, _context2, _context3, _context5, _confirmationPrompt;
289
+ var _context, _context2;
297
290
  let approvalJob;
298
291
  let deploymentJob;
299
292
  if (cliFlags.deployment) {
300
- var _config$deployments, _context;
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("\u26A0\uFE0F Deployment ".concat(cliFlags.deployment, " not found in configuration. Make sure it exists."));
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(_concatInstanceProperty(_context = "\u2139\uFE0F Approving requested deployment ".concat(cliFlags.deployment, " with approval job ")).call(_context, approvalJob, "."));
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("\u2139\uFE0F Approving with approval job ".concat(approvalJob, "."));
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: (_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
310
+ maxPages: config.CircleCI.pagination?.maxPages ?? 1
319
311
  }) : await waitForDeploymentPipelinePrompt({
320
312
  branch: cliFlags.branch,
321
313
  circleCiApis,
322
- 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,
314
+ pagesForPipelineSelection: config.CircleCI.pagination?.pagesForPipelineSelection ?? 1,
323
315
  debug: cliFlags.debug
324
316
  });
325
317
  if (!deploymentPipeline) {
326
- throw new Error("\u26A0\uFE0F No workflow called ".concat(config.CircleCI.deploymentWorkflowName, " found in any pipeline for deployment."));
318
+ throw new Error(`âš ī¸ No workflow called ${config.CircleCI.deploymentWorkflowName} found in any pipeline for deployment.`);
327
319
  }
328
- console.log("\u2139\uFE0F Found pipeline for deployment with revision ".concat(deploymentPipeline.vcs.revision, "."));
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(_context2 = workflows.items).call(_context2, workflow => workflow.name === config.CircleCI.deploymentWorkflowName);
327
+ const buildAndDeployWorkflow = _findInstanceProperty(_context = workflows.items).call(_context, workflow => workflow.name === config.CircleCI.deploymentWorkflowName);
336
328
  if (!buildAndDeployWorkflow) {
337
- throw new Error("\u26A0\uFE0F No workflow called ".concat(config.CircleCI.deploymentWorkflowName, " found for deployment."));
329
+ throw new Error(`âš ī¸ No workflow called ${config.CircleCI.deploymentWorkflowName} found for deployment.`);
338
330
  }
339
331
  const workflowId = buildAndDeployWorkflow.id;
340
- console.log("\u2139\uFE0F Found workflow to build and deploy with id ".concat(workflowId, "."));
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("\u2139\uFE0F Found jobs for workflow.");
348
- const applicationApprovalJob = _findInstanceProperty(_context3 = jobs.items).call(_context3, job => job.name === approvalJob);
349
- const applicationApprovalJobId = applicationApprovalJob === null || applicationApprovalJob === void 0 ? void 0 : applicationApprovalJob.id;
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
- var _context4;
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(_concatInstanceProperty(_context5 = "\u2139\uFE0F Found deployment approval job named ".concat(approvalJob, " with id ")).call(_context5, applicationApprovalJobId, "."));
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 || (_confirmationPrompt = confirmationPrompt) !== null && _confirmationPrompt !== void 0 && _confirmationPrompt.confirmed) {
353
+ if (cliFlags.yes || confirmationPrompt?.confirmed) {
363
354
  if (cliFlags.dryRun) {
364
- console.log("\uD83D\uDE4A Not approving deployment job due to dry run.");
355
+ console.log(`🙊 Not approving deployment job due to dry run.`);
365
356
  } else {
366
- console.log("\u2139\uFE0F Approving deployment job.");
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("\u2139\uFE0F Skipping determining deployment job approved by ".concat(approvalJob, " due to '--yes' flag. Please check CircleCI manually."));
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("\u270C\uFE0F Dry running hence could not determine deployment job approved by ".concat(approvalJob, "."));
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(_concatInstanceProperty(_context6 = _concatInstanceProperty(_context7 = "\uD83D\uDE4C The deployment via ".concat(approvalJob, " at revision ")).call(_context7, deploymentPipeline.vcs.revision, " is running at: ")).call(_context6, getJobUrl({
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("\u2139\uFE0F Skipping determining deployment job as no '--deployment-job' name to wait for was passed. Please check CircleCI manually.");
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("\u2139\uFE0F Not approving deployment job. Confirm the prompt or use '--yes' option.");
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(_concatInstanceProperty(_context = _concatInstanceProperty(_context2 = "".concat(response.status, ": Network response was not ok.\n\n Status text is ")).call(_context2, response.statusText, " and text is ")).call(_context, 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 = _concatInstanceProperty(_context3 = "".concat(apiBaseUrl)).call(_context3, api.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 += "?".concat(urlSearchParams.toString());
445
+ url += `?${urlSearchParams.toString()}`;
457
446
  }
458
447
  if (skip) {
459
448
  if (debug) {
460
- console.log("\uD83C\uDFED Skipping CircleCI call API at: ".concat(url, "."));
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("\uD83C\uDFED Calling CircleCI API at: ".concat(url, "."));
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("\u26A0\uFE0F Calling CircleCI API at: ".concat(url, " failed."));
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 ? "gh/commercetools/".concat(projectName) : _ref5$projectSlug,
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: "/project/".concat(projectSlug, "/pipeline"),
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: "/pipeline/".concat(pipelineId, "/workflow"),
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: "/workflow/".concat(workflowId, "/job"),
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
- var _context4;
540
- return execute({
541
- url: _concatInstanceProperty(_context4 = "/workflow/".concat(workflowId, "/approve/")).call(_context4, approvalRequestId, " "),
542
- headers: {
543
- 'Content-Type': 'application/json',
544
- // The CLI throws if this is not present on environment
545
- 'Circle-Token': process.env.CIRCLE_TOKEN
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("approve \n\n ".concat(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.', {
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("\uD83D\uDE4A Do not worry. This is a dry run!");
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/deployment-cli",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "CLI to manage Custom Applications deployments in Google Storage.",
5
5
  "keywords": [
6
6
  "commercetools",
@@ -32,7 +32,7 @@
32
32
  "devDependencies": {
33
33
  "@tsconfig/node20": "20.1.4",
34
34
  "@types/lodash": "^4.14.198",
35
- "@types/node": "20.12.12",
35
+ "@types/node": "20.14.14",
36
36
  "@types/prompts": "2.4.9",
37
37
  "msw": "1.3.3",
38
38
  "typescript": "5.2.2"