@commercetools-frontend/deployment-cli 1.0.1 → 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';
@@ -14,10 +14,11 @@ import _URLSearchParams from '@babel/runtime-corejs3/core-js-stable/url-search-p
14
14
  import _Object$entries from '@babel/runtime-corejs3/core-js-stable/object/entries';
15
15
  import _Promise from '@babel/runtime-corejs3/core-js-stable/promise';
16
16
  import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
17
+ import { exit } from 'node:process';
17
18
 
18
19
  var pkgJson = {
19
20
  name: "@commercetools-frontend/deployment-cli",
20
- version: "1.0.1",
21
+ version: "2.0.1",
21
22
  description: "CLI to manage Custom Applications deployments in Google Storage.",
22
23
  keywords: [
23
24
  "commercetools",
@@ -29,6 +30,7 @@ var pkgJson = {
29
30
  module: "dist/commercetools-frontend-deployment-cli.esm.js",
30
31
  bin: "bin/cli.js",
31
32
  files: [
33
+ "bin",
32
34
  "cli",
33
35
  "dist",
34
36
  "package.json",
@@ -51,13 +53,13 @@ var pkgJson = {
51
53
  devDependencies: {
52
54
  "@tsconfig/node20": "20.1.4",
53
55
  "@types/lodash": "^4.14.198",
54
- "@types/node": "20.12.7",
56
+ "@types/node": "20.14.14",
55
57
  "@types/prompts": "2.4.9",
56
58
  msw: "1.3.3",
57
59
  typescript: "5.2.2"
58
60
  },
59
61
  engines: {
60
- node: ">=18",
62
+ node: ">=21",
61
63
  npm: ">=6"
62
64
  },
63
65
  publishConfig: {
@@ -88,7 +90,7 @@ async function loadConfig() {
88
90
  };
89
91
  try {
90
92
  const cosmiconfigResult = await deploymentConfigExplorer.search();
91
- const mergedConfig = merge(defaultConfig, cosmiconfigResult === null || cosmiconfigResult === void 0 ? void 0 : cosmiconfigResult.config);
93
+ const mergedConfig = merge(defaultConfig, cosmiconfigResult?.config);
92
94
  return mergedConfig;
93
95
  } catch (e) {
94
96
  console.warn(e);
@@ -97,13 +99,13 @@ async function loadConfig() {
97
99
  }
98
100
  function throwIfConfigurationLacksRequiredValues(parsedConfiguration) {
99
101
  if (!parsedConfiguration.CircleCI.projectName) {
100
- 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!`);
101
103
  }
102
104
  }
103
105
  function throwIfRequiredEnvironmentVariableIsUnset(requiredEnvironmentVariables) {
104
106
  _forEachInstanceProperty(requiredEnvironmentVariables).call(requiredEnvironmentVariables, nameOfRequiredEnvironmentVariable => {
105
107
  const valueOfRequiredEnvironmentVariable = process.env[nameOfRequiredEnvironmentVariable];
106
- if (!valueOfRequiredEnvironmentVariable) throw new Error("Missing '".concat(nameOfRequiredEnvironmentVariable, "' environment variable"));
108
+ if (!valueOfRequiredEnvironmentVariable) throw new Error(`Missing '${nameOfRequiredEnvironmentVariable}' environment variable`);
107
109
  });
108
110
  }
109
111
  const promptOptions = {
@@ -129,23 +131,19 @@ const promptOptions = {
129
131
  type: 'select',
130
132
  name: 'deploymentPipeline',
131
133
  message: 'Select the revision you would like to deploy',
132
- choices: _mapInstanceProperty(deploymentPipelines).call(deploymentPipelines, deploymentPipeline => {
133
- var _context, _context2;
134
- return {
135
- title: _concatInstanceProperty(_context = _concatInstanceProperty(_context2 = "".concat(deploymentPipeline.vcs.revision.substring(0, 7), " - ")).call(_context2, deploymentPipeline.vcs.commit.subject, " <")).call(_context, deploymentPipeline.trigger.actor.login, ">"),
136
- value: deploymentPipeline
137
- };
138
- })
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
+ }))
139
138
  };
140
139
  },
141
140
  deploymentConfirmation: _ref4 => {
142
- var _context3;
143
141
  let approvalJob = _ref4.approvalJob,
144
142
  revision = _ref4.revision;
145
143
  return {
146
144
  type: 'toggle',
147
145
  name: 'confirmed',
148
- 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}?`,
149
147
  initial: false,
150
148
  active: 'Yes',
151
149
  inactive: 'No'
@@ -162,7 +160,7 @@ async function paginateToDeploymentPipeline(_ref5) {
162
160
  let nextPageToken;
163
161
  // eslint-disable-next-line no-plusplus
164
162
  for (let i = 0; i < maxPages; i++) {
165
- var _context4, _context5;
163
+ var _context, _context2;
166
164
  // eslint-disable-next-line no-await-in-loop
167
165
 
168
166
  const pipelineRequest = circleCiApis.pipelines({
@@ -173,19 +171,18 @@ async function paginateToDeploymentPipeline(_ref5) {
173
171
  debug
174
172
  });
175
173
  nextPageToken = pipelines.next_page_token;
176
- 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);
177
175
  if (buildRevision) {
178
- var _context6, _context7;
179
- 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}.`);
180
177
  deploymentPipeline = _findInstanceProperty(nonScheduledPipelines).call(nonScheduledPipelines, pipeline => {
181
- var _context8;
182
- return _startsWithInstanceProperty(_context8 = pipeline.vcs.revision).call(_context8, buildRevision);
178
+ var _context3;
179
+ return _startsWithInstanceProperty(_context3 = pipeline.vcs.revision).call(_context3, buildRevision);
183
180
  });
184
181
  } else {
185
182
  deploymentPipeline = nonScheduledPipelines[0];
186
183
  }
187
184
  if (deploymentPipeline) {
188
- 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}.`);
189
186
  break;
190
187
  }
191
188
  }
@@ -200,7 +197,7 @@ async function collectDeploymentPipelines(_ref6) {
200
197
  let nextPageToken;
201
198
  // eslint-disable-next-line no-plusplus
202
199
  for (let i = 0; i < pagesForPipelineSelection; i++) {
203
- var _context9, _context10;
200
+ var _context4, _context5;
204
201
  // eslint-disable-next-line no-await-in-loop
205
202
  const pipelinesRequest = circleCiApis.pipelines({
206
203
  pageToken: nextPageToken,
@@ -209,7 +206,7 @@ async function collectDeploymentPipelines(_ref6) {
209
206
  const pipelines = await pipelinesRequest.execute({
210
207
  debug
211
208
  });
212
- 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);
213
210
  deploymentPipelines = _concatInstanceProperty(deploymentPipelines).call(deploymentPipelines, nonScheduledPipelines);
214
211
  }
215
212
  return deploymentPipelines;
@@ -248,12 +245,11 @@ async function waitForConfirmationPrompt(_ref8) {
248
245
  }));
249
246
  }
250
247
  function getJobUrl(_ref9) {
251
- var _context11, _context12, _context13;
252
248
  let pipelineNumber = _ref9.pipelineNumber,
253
249
  workflowId = _ref9.workflowId,
254
250
  jobNumber = _ref9.jobNumber,
255
251
  projectName = _ref9.projectName;
256
- 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}`;
257
253
  }
258
254
  function isNonScheduledPipeline(pipeline) {
259
255
  return pipeline.trigger.type !== 'schedule' && pipeline.trigger.type !== 'scheduled_pipeline';
@@ -267,14 +263,14 @@ async function waitForDeploymentJobNumber(_ref10, _ref11) {
267
263
  circleCiApis = _ref10.circleCiApis;
268
264
  let debug = _ref11.debug;
269
265
  const fetchDeploymentJobNumber = async () => {
270
- var _context14;
266
+ var _context6;
271
267
  const jobsRequest = circleCiApis.jobs({
272
268
  workflowId
273
269
  });
274
270
  const jobs = await jobsRequest.execute({
275
271
  debug
276
272
  });
277
- 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);
278
274
  if (!applicationDeploymentJob || applicationDeploymentJob.status === 'blocked') {
279
275
  throw new Error('Deployment job not yet running. Retrying.');
280
276
  }
@@ -282,8 +278,7 @@ async function waitForDeploymentJobNumber(_ref10, _ref11) {
282
278
  };
283
279
  const deploymentJobNumber = await pRetry(fetchDeploymentJobNumber, {
284
280
  onFailedAttempt: error => {
285
- var _context15;
286
- 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.`);
287
282
  },
288
283
  retries: 10
289
284
  });
@@ -291,65 +286,63 @@ async function waitForDeploymentJobNumber(_ref10, _ref11) {
291
286
  }
292
287
 
293
288
  async function approve(cliFlags, config, circleCiApis) {
294
- var _config$CircleCI$pagi, _config$CircleCI$pagi2, _config$CircleCI$pagi3, _config$CircleCI$pagi4, _context2, _context3, _context5, _confirmationPrompt;
289
+ var _context, _context2;
295
290
  let approvalJob;
296
291
  let deploymentJob;
297
292
  if (cliFlags.deployment) {
298
- var _config$deployments, _context;
299
- const requestedDeployment = (_config$deployments = config.deployments) === null || _config$deployments === void 0 ? void 0 : _config$deployments[cliFlags.deployment];
293
+ const requestedDeployment = config.deployments?.[cliFlags.deployment];
300
294
  if (!requestedDeployment) {
301
- 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.`);
302
296
  }
303
297
  approvalJob = requestedDeployment.jobs.approval;
304
298
  deploymentJob = requestedDeployment.jobs.deployment;
305
- 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}.`);
306
300
  } else {
307
301
  approvalJob = cliFlags.approvalJob;
308
302
  deploymentJob = cliFlags.deploymentJob;
309
- console.log("\u2139\uFE0F Approving with approval job ".concat(approvalJob, "."));
303
+ console.log(`ℹ️ Approving with approval job ${approvalJob}.`);
310
304
  }
311
305
  const deploymentPipeline = cliFlags.yes ? await paginateToDeploymentPipeline({
312
306
  circleCiApis,
313
307
  buildRevision: cliFlags.buildRevision,
314
308
  branch: cliFlags.branch,
315
309
  debug: cliFlags.debug,
316
- 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
317
311
  }) : await waitForDeploymentPipelinePrompt({
318
312
  branch: cliFlags.branch,
319
313
  circleCiApis,
320
- 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,
321
315
  debug: cliFlags.debug
322
316
  });
323
317
  if (!deploymentPipeline) {
324
- 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.`);
325
319
  }
326
- 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}.`);
327
321
  const workflowsRequest = circleCiApis.workflows({
328
322
  pipelineId: deploymentPipeline.id
329
323
  });
330
324
  const workflows = await workflowsRequest.execute({
331
325
  debug: cliFlags.debug
332
326
  });
333
- 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);
334
328
  if (!buildAndDeployWorkflow) {
335
- 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.`);
336
330
  }
337
331
  const workflowId = buildAndDeployWorkflow.id;
338
- 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}.`);
339
333
  const jobsRequest = circleCiApis.jobs({
340
334
  workflowId
341
335
  });
342
336
  const jobs = await jobsRequest.execute({
343
337
  debug: cliFlags.debug
344
338
  });
345
- console.log("\u2139\uFE0F Found jobs for workflow.");
346
- const applicationApprovalJob = _findInstanceProperty(_context3 = jobs.items).call(_context3, job => job.name === approvalJob);
347
- 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;
348
342
  if (!applicationApprovalJobId) {
349
- var _context4;
350
- 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.`);
351
344
  }
352
- 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}.`);
353
346
  let confirmationPrompt;
354
347
  if (!cliFlags.yes) {
355
348
  confirmationPrompt = await waitForConfirmationPrompt({
@@ -357,11 +350,11 @@ async function approve(cliFlags, config, circleCiApis) {
357
350
  revision: deploymentPipeline.vcs.revision
358
351
  });
359
352
  }
360
- if (cliFlags.yes || (_confirmationPrompt = confirmationPrompt) !== null && _confirmationPrompt !== void 0 && _confirmationPrompt.confirmed) {
353
+ if (cliFlags.yes || confirmationPrompt?.confirmed) {
361
354
  if (cliFlags.dryRun) {
362
- console.log("\uD83D\uDE4A Not approving deployment job due to dry run.");
355
+ console.log(`🙊 Not approving deployment job due to dry run.`);
363
356
  } else {
364
- console.log("\u2139\uFE0F Approving deployment job.");
357
+ console.log(`ℹ️ Approving deployment job.`);
365
358
  }
366
359
  const approvalRequest = circleCiApis.approve({
367
360
  workflowId,
@@ -372,11 +365,10 @@ async function approve(cliFlags, config, circleCiApis) {
372
365
  skip: cliFlags.dryRun
373
366
  });
374
367
  if (cliFlags.yes) {
375
- 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.`);
376
369
  } else if (cliFlags.dryRun) {
377
- 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}.`);
378
371
  } else if (deploymentJob) {
379
- var _context6, _context7;
380
372
  const deploymentJobNumber = await waitForDeploymentJobNumber({
381
373
  workflowId,
382
374
  deploymentJob,
@@ -386,23 +378,22 @@ async function approve(cliFlags, config, circleCiApis) {
386
378
  dryRun: cliFlags.dryRun,
387
379
  yes: cliFlags.yes
388
380
  });
389
- 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({
390
382
  projectName: config.CircleCI.projectName,
391
383
  pipelineNumber: deploymentPipeline.number,
392
384
  workflowId,
393
385
  jobNumber: deploymentJobNumber
394
- })));
386
+ })}`);
395
387
  } else {
396
- 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.`);
397
389
  }
398
390
  } else {
399
- 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.`);
400
392
  }
401
393
  }
402
394
 
403
395
  async function processCircleCiResponse(response) {
404
396
  if (!response.ok) {
405
- var _context, _context2;
406
397
  /**
407
398
  * NOTE:
408
399
  * Trying to handle known but undocumented responses of the CircleCI API.
@@ -422,12 +413,14 @@ async function processCircleCiResponse(response) {
422
413
  message = _JSON$parse.message;
423
414
  if (message.match(/job already approved/i)) {
424
415
  console.log('ℹ️ Deployment job is already approved.');
425
- process.exit(0);
416
+ // TODO: can we return instead of force exiting?
417
+ exit(0);
426
418
  }
427
419
  } catch {
428
420
  // Ignore JSON parsing errors
429
421
  }
430
- 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}.`);
431
424
  }
432
425
  return response.json();
433
426
  }
@@ -435,11 +428,10 @@ function createCircleCiClient(_ref) {
435
428
  let projectName = _ref.projectName,
436
429
  apiBaseUrl = _ref.apiBaseUrl;
437
430
  async function execute(api) {
438
- var _context3;
439
431
  let _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
440
432
  skip = _ref2.skip,
441
433
  debug = _ref2.debug;
442
- let url = _concatInstanceProperty(_context3 = "".concat(apiBaseUrl)).call(_context3, api.url);
434
+ let url = `${apiBaseUrl}${api.url}`;
443
435
  if (api.params && api.method === 'GET') {
444
436
  const urlSearchParams = new _URLSearchParams();
445
437
  for (const _ref3 of _Object$entries(api.params)) {
@@ -450,18 +442,18 @@ function createCircleCiClient(_ref) {
450
442
  urlSearchParams.append(key, value);
451
443
  }
452
444
  }
453
- url += "?".concat(urlSearchParams.toString());
445
+ url += `?${urlSearchParams.toString()}`;
454
446
  }
455
447
  if (skip) {
456
448
  if (debug) {
457
- console.log("\uD83C\uDFED Skipping CircleCI call API at: ".concat(url, "."));
449
+ console.log(`🏭 Skipping CircleCI call API at: ${url}.`);
458
450
  }
459
451
 
460
452
  // @ts-expect-error
461
453
  return _Promise.resolve();
462
454
  }
463
455
  if (debug) {
464
- console.log("\uD83C\uDFED Calling CircleCI API at: ".concat(url, "."));
456
+ console.log(`🏭 Calling CircleCI API at: ${url}.`);
465
457
  }
466
458
  try {
467
459
  const response = await fetch(url, {
@@ -472,7 +464,7 @@ function createCircleCiClient(_ref) {
472
464
  const processedCircleCiResponse = await processCircleCiResponse(response);
473
465
  return processedCircleCiResponse;
474
466
  } catch (error) {
475
- console.log("\u26A0\uFE0F Calling CircleCI API at: ".concat(url, " failed."));
467
+ console.log(`⚠️ Calling CircleCI API at: ${url} failed.`);
476
468
  throw error;
477
469
  }
478
470
  }
@@ -481,12 +473,12 @@ function createCircleCiClient(_ref) {
481
473
  let _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
482
474
  pageToken = _ref5.pageToken,
483
475
  _ref5$projectSlug = _ref5.projectSlug,
484
- projectSlug = _ref5$projectSlug === void 0 ? "gh/commercetools/".concat(projectName) : _ref5$projectSlug,
476
+ projectSlug = _ref5$projectSlug === void 0 ? `gh/commercetools/${projectName}` : _ref5$projectSlug,
485
477
  _ref5$branch = _ref5.branch,
486
478
  branch = _ref5$branch === void 0 ? 'main' : _ref5$branch;
487
479
  return {
488
480
  execute: options => execute({
489
- url: "/project/".concat(projectSlug, "/pipeline"),
481
+ url: `/project/${projectSlug}/pipeline`,
490
482
  headers: {
491
483
  'Content-Type': 'application/json',
492
484
  // The CLI throws if this is not present on environment
@@ -504,7 +496,7 @@ function createCircleCiClient(_ref) {
504
496
  let pipelineId = _ref6.pipelineId;
505
497
  return {
506
498
  execute: options => execute({
507
- url: "/pipeline/".concat(pipelineId, "/workflow"),
499
+ url: `/pipeline/${pipelineId}/workflow`,
508
500
  headers: {
509
501
  'Content-Type': 'application/json',
510
502
  // The CLI throws if this is not present on environment
@@ -518,7 +510,7 @@ function createCircleCiClient(_ref) {
518
510
  let workflowId = _ref7.workflowId;
519
511
  return {
520
512
  execute: options => execute({
521
- url: "/workflow/".concat(workflowId, "/job"),
513
+ url: `/workflow/${workflowId}/job`,
522
514
  headers: {
523
515
  'Content-Type': 'application/json',
524
516
  // The CLI throws if this is not present on environment
@@ -532,18 +524,15 @@ function createCircleCiClient(_ref) {
532
524
  let workflowId = _ref8.workflowId,
533
525
  approvalRequestId = _ref8.approvalRequestId;
534
526
  return {
535
- execute: options => {
536
- var _context4;
537
- return execute({
538
- url: _concatInstanceProperty(_context4 = "/workflow/".concat(workflowId, "/approve/")).call(_context4, approvalRequestId, " "),
539
- headers: {
540
- 'Content-Type': 'application/json',
541
- // The CLI throws if this is not present on environment
542
- 'Circle-Token': process.env.CIRCLE_TOKEN
543
- },
544
- method: 'POST'
545
- }, options);
546
- }
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)
547
536
  };
548
537
  }
549
538
  };
@@ -571,13 +560,13 @@ async function run() {
571
560
 
572
561
  // Command: Approve
573
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/).';
574
- 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.', {
575
564
  default: 'main'
576
565
  }).option('--yes', '(optional) Skip all confirmation prompts. Useful in Continuous integration (CI) to automatically answer confirmation questions.', {
577
566
  default: false
578
567
  }).action(async options => {
579
568
  if (options.dryRun) {
580
- console.log("\uD83D\uDE4A Do not worry. This is a dry run!");
569
+ console.log(`🙊 Do not worry. This is a dry run!`);
581
570
  }
582
571
  throwIfRequiredEnvironmentVariableIsUnset(['CIRCLE_TOKEN']);
583
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": "1.0.1",
3
+ "version": "2.0.1",
4
4
  "description": "CLI to manage Custom Applications deployments in Google Storage.",
5
5
  "keywords": [
6
6
  "commercetools",
@@ -12,6 +12,7 @@
12
12
  "module": "dist/commercetools-frontend-deployment-cli.esm.js",
13
13
  "bin": "bin/cli.js",
14
14
  "files": [
15
+ "bin",
15
16
  "cli",
16
17
  "dist",
17
18
  "package.json",
@@ -31,13 +32,13 @@
31
32
  "devDependencies": {
32
33
  "@tsconfig/node20": "20.1.4",
33
34
  "@types/lodash": "^4.14.198",
34
- "@types/node": "20.12.7",
35
+ "@types/node": "20.14.14",
35
36
  "@types/prompts": "2.4.9",
36
37
  "msw": "1.3.3",
37
38
  "typescript": "5.2.2"
38
39
  },
39
40
  "engines": {
40
- "node": ">=18",
41
+ "node": ">=21",
41
42
  "npm": ">=6"
42
43
  },
43
44
  "publishConfig": {