@commercetools-frontend/deployment-cli 1.0.0 → 2.0.0

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';
2
3
  import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
3
4
  import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
4
5
  import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
5
6
  import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
6
7
  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.0",
21
+ version: "2.0.0",
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",
@@ -49,15 +51,15 @@ var pkgJson = {
49
51
  prompts: "2.4.2"
50
52
  },
51
53
  devDependencies: {
52
- "@tsconfig/node20": "20.1.2",
54
+ "@tsconfig/node20": "20.1.4",
53
55
  "@types/lodash": "^4.14.198",
54
- "@types/node": "20.11.5",
56
+ "@types/node": "20.12.12",
55
57
  "@types/prompts": "2.4.9",
56
- msw: "1.3.2",
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?.config);
93
+ const mergedConfig = merge(defaultConfig, cosmiconfigResult === null || cosmiconfigResult === void 0 ? void 0 : 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 '${nameOfRequiredEnvironmentVariable}' environment variable`);
108
+ if (!valueOfRequiredEnvironmentVariable) throw new Error("Missing '".concat(nameOfRequiredEnvironmentVariable, "' environment variable"));
107
109
  });
108
110
  }
109
111
  const promptOptions = {
@@ -129,19 +131,23 @@ 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
- title: `${deploymentPipeline.vcs.revision.substring(0, 7)} - ${deploymentPipeline.vcs.commit.subject} <${deploymentPipeline.trigger.actor.login}>`,
134
- value: deploymentPipeline
135
- }))
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
+ })
136
141
  };
137
142
  },
138
143
  deploymentConfirmation: _ref4 => {
144
+ var _context3;
139
145
  let approvalJob = _ref4.approvalJob,
140
146
  revision = _ref4.revision;
141
147
  return {
142
148
  type: 'toggle',
143
149
  name: 'confirmed',
144
- message: `Are you sure you want to deploy by approving ${approvalJob} at ${revision}?`,
150
+ message: _concatInstanceProperty(_context3 = "Are you sure you want to deploy by approving ".concat(approvalJob, " at ")).call(_context3, revision, "?"),
145
151
  initial: false,
146
152
  active: 'Yes',
147
153
  inactive: 'No'
@@ -158,7 +164,7 @@ async function paginateToDeploymentPipeline(_ref5) {
158
164
  let nextPageToken;
159
165
  // eslint-disable-next-line no-plusplus
160
166
  for (let i = 0; i < maxPages; i++) {
161
- var _context, _context2;
167
+ var _context4, _context5;
162
168
  // eslint-disable-next-line no-await-in-loop
163
169
 
164
170
  const pipelineRequest = circleCiApis.pipelines({
@@ -169,18 +175,19 @@ async function paginateToDeploymentPipeline(_ref5) {
169
175
  debug
170
176
  });
171
177
  nextPageToken = pipelines.next_page_token;
172
- const nonScheduledPipelines = _filterInstanceProperty(_context = _filterInstanceProperty(_context2 = pipelines.items).call(_context2, isNonScheduledPipeline)).call(_context, isNonErroredPipeline);
178
+ const nonScheduledPipelines = _filterInstanceProperty(_context4 = _filterInstanceProperty(_context5 = pipelines.items).call(_context5, isNonScheduledPipeline)).call(_context4, isNonErroredPipeline);
173
179
  if (buildRevision) {
174
- console.log(`🔄 Trying to find pipeline with revision ${buildRevision}. Attempt ${i + 1} out of ${maxPages}.`);
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, "."));
175
182
  deploymentPipeline = _findInstanceProperty(nonScheduledPipelines).call(nonScheduledPipelines, pipeline => {
176
- var _context3;
177
- return _startsWithInstanceProperty(_context3 = pipeline.vcs.revision).call(_context3, buildRevision);
183
+ var _context8;
184
+ return _startsWithInstanceProperty(_context8 = pipeline.vcs.revision).call(_context8, buildRevision);
178
185
  });
179
186
  } else {
180
187
  deploymentPipeline = nonScheduledPipelines[0];
181
188
  }
182
189
  if (deploymentPipeline) {
183
- console.log(`ℹ️ Using pipeline for deployment with revision ${deploymentPipeline.vcs.revision}.`);
190
+ console.log("\u2139\uFE0F Using pipeline for deployment with revision ".concat(deploymentPipeline.vcs.revision, "."));
184
191
  break;
185
192
  }
186
193
  }
@@ -195,7 +202,7 @@ async function collectDeploymentPipelines(_ref6) {
195
202
  let nextPageToken;
196
203
  // eslint-disable-next-line no-plusplus
197
204
  for (let i = 0; i < pagesForPipelineSelection; i++) {
198
- var _context4, _context5;
205
+ var _context9, _context10;
199
206
  // eslint-disable-next-line no-await-in-loop
200
207
  const pipelinesRequest = circleCiApis.pipelines({
201
208
  pageToken: nextPageToken,
@@ -204,7 +211,7 @@ async function collectDeploymentPipelines(_ref6) {
204
211
  const pipelines = await pipelinesRequest.execute({
205
212
  debug
206
213
  });
207
- const nonScheduledPipelines = _filterInstanceProperty(_context4 = _filterInstanceProperty(_context5 = pipelines.items).call(_context5, isNonScheduledPipeline)).call(_context4, isNonErroredPipeline);
214
+ const nonScheduledPipelines = _filterInstanceProperty(_context9 = _filterInstanceProperty(_context10 = pipelines.items).call(_context10, isNonScheduledPipeline)).call(_context9, isNonErroredPipeline);
208
215
  deploymentPipelines = _concatInstanceProperty(deploymentPipelines).call(deploymentPipelines, nonScheduledPipelines);
209
216
  }
210
217
  return deploymentPipelines;
@@ -243,11 +250,12 @@ async function waitForConfirmationPrompt(_ref8) {
243
250
  }));
244
251
  }
245
252
  function getJobUrl(_ref9) {
253
+ var _context11, _context12, _context13;
246
254
  let pipelineNumber = _ref9.pipelineNumber,
247
255
  workflowId = _ref9.workflowId,
248
256
  jobNumber = _ref9.jobNumber,
249
257
  projectName = _ref9.projectName;
250
- return `https://app.circleci.com/pipelines/github/commercetools/${projectName}/${pipelineNumber}/workflows/${workflowId}/jobs/${jobNumber}`;
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);
251
259
  }
252
260
  function isNonScheduledPipeline(pipeline) {
253
261
  return pipeline.trigger.type !== 'schedule' && pipeline.trigger.type !== 'scheduled_pipeline';
@@ -261,14 +269,14 @@ async function waitForDeploymentJobNumber(_ref10, _ref11) {
261
269
  circleCiApis = _ref10.circleCiApis;
262
270
  let debug = _ref11.debug;
263
271
  const fetchDeploymentJobNumber = async () => {
264
- var _context6;
272
+ var _context14;
265
273
  const jobsRequest = circleCiApis.jobs({
266
274
  workflowId
267
275
  });
268
276
  const jobs = await jobsRequest.execute({
269
277
  debug
270
278
  });
271
- const applicationDeploymentJob = _findInstanceProperty(_context6 = jobs.items).call(_context6, job => job.name === deploymentJob);
279
+ const applicationDeploymentJob = _findInstanceProperty(_context14 = jobs.items).call(_context14, job => job.name === deploymentJob);
272
280
  if (!applicationDeploymentJob || applicationDeploymentJob.status === 'blocked') {
273
281
  throw new Error('Deployment job not yet running. Retrying.');
274
282
  }
@@ -276,7 +284,8 @@ async function waitForDeploymentJobNumber(_ref10, _ref11) {
276
284
  };
277
285
  const deploymentJobNumber = await pRetry(fetchDeploymentJobNumber, {
278
286
  onFailedAttempt: error => {
279
- console.log(`🔄 Trying to find deployment job. Attempt ${error.attemptNumber} with ${error.retriesLeft} retries left.`);
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."));
280
289
  },
281
290
  retries: 10
282
291
  });
@@ -284,63 +293,65 @@ async function waitForDeploymentJobNumber(_ref10, _ref11) {
284
293
  }
285
294
 
286
295
  async function approve(cliFlags, config, circleCiApis) {
287
- var _context, _context2;
296
+ var _config$CircleCI$pagi, _config$CircleCI$pagi2, _config$CircleCI$pagi3, _config$CircleCI$pagi4, _context2, _context3, _context5, _confirmationPrompt;
288
297
  let approvalJob;
289
298
  let deploymentJob;
290
299
  if (cliFlags.deployment) {
291
- const requestedDeployment = config.deployments?.[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];
292
302
  if (!requestedDeployment) {
293
- throw new Error(`⚠️ Deployment ${cliFlags.deployment} not found in configuration. Make sure it exists.`);
303
+ throw new Error("\u26A0\uFE0F Deployment ".concat(cliFlags.deployment, " not found in configuration. Make sure it exists."));
294
304
  }
295
305
  approvalJob = requestedDeployment.jobs.approval;
296
306
  deploymentJob = requestedDeployment.jobs.deployment;
297
- console.log(`ℹ️ Approving requested deployment ${cliFlags.deployment} with approval job ${approvalJob}.`);
307
+ console.log(_concatInstanceProperty(_context = "\u2139\uFE0F Approving requested deployment ".concat(cliFlags.deployment, " with approval job ")).call(_context, approvalJob, "."));
298
308
  } else {
299
309
  approvalJob = cliFlags.approvalJob;
300
310
  deploymentJob = cliFlags.deploymentJob;
301
- console.log(`ℹ️ Approving with approval job ${approvalJob}.`);
311
+ console.log("\u2139\uFE0F Approving with approval job ".concat(approvalJob, "."));
302
312
  }
303
313
  const deploymentPipeline = cliFlags.yes ? await paginateToDeploymentPipeline({
304
314
  circleCiApis,
305
315
  buildRevision: cliFlags.buildRevision,
306
316
  branch: cliFlags.branch,
307
317
  debug: cliFlags.debug,
308
- maxPages: config.CircleCI.pagination?.maxPages ?? 1
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
309
319
  }) : await waitForDeploymentPipelinePrompt({
310
320
  branch: cliFlags.branch,
311
321
  circleCiApis,
312
- pagesForPipelineSelection: config.CircleCI.pagination?.pagesForPipelineSelection ?? 1,
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,
313
323
  debug: cliFlags.debug
314
324
  });
315
325
  if (!deploymentPipeline) {
316
- throw new Error(`⚠️ No workflow called ${config.CircleCI.deploymentWorkflowName} found in any pipeline for deployment.`);
326
+ throw new Error("\u26A0\uFE0F No workflow called ".concat(config.CircleCI.deploymentWorkflowName, " found in any pipeline for deployment."));
317
327
  }
318
- console.log(`ℹ️ Found pipeline for deployment with revision ${deploymentPipeline.vcs.revision}.`);
328
+ console.log("\u2139\uFE0F Found pipeline for deployment with revision ".concat(deploymentPipeline.vcs.revision, "."));
319
329
  const workflowsRequest = circleCiApis.workflows({
320
330
  pipelineId: deploymentPipeline.id
321
331
  });
322
332
  const workflows = await workflowsRequest.execute({
323
333
  debug: cliFlags.debug
324
334
  });
325
- const buildAndDeployWorkflow = _findInstanceProperty(_context = workflows.items).call(_context, workflow => workflow.name === config.CircleCI.deploymentWorkflowName);
335
+ const buildAndDeployWorkflow = _findInstanceProperty(_context2 = workflows.items).call(_context2, workflow => workflow.name === config.CircleCI.deploymentWorkflowName);
326
336
  if (!buildAndDeployWorkflow) {
327
- throw new Error(`⚠️ No workflow called ${config.CircleCI.deploymentWorkflowName} found for deployment.`);
337
+ throw new Error("\u26A0\uFE0F No workflow called ".concat(config.CircleCI.deploymentWorkflowName, " found for deployment."));
328
338
  }
329
339
  const workflowId = buildAndDeployWorkflow.id;
330
- console.log(`ℹ️ Found workflow to build and deploy with id ${workflowId}.`);
340
+ console.log("\u2139\uFE0F Found workflow to build and deploy with id ".concat(workflowId, "."));
331
341
  const jobsRequest = circleCiApis.jobs({
332
342
  workflowId
333
343
  });
334
344
  const jobs = await jobsRequest.execute({
335
345
  debug: cliFlags.debug
336
346
  });
337
- console.log(`ℹ️ Found jobs for workflow.`);
338
- const applicationApprovalJob = _findInstanceProperty(_context2 = jobs.items).call(_context2, job => job.name === approvalJob);
339
- const applicationApprovalJobId = applicationApprovalJob?.id;
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;
340
350
  if (!applicationApprovalJobId) {
341
- throw new Error(`✌️ Could not find deployment approval job named ${approvalJob} at revision ${deploymentPipeline.vcs.revision}. Maybe try again later.`);
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."));
342
353
  }
343
- console.log(`ℹ️ Found deployment approval job named ${approvalJob} with id ${applicationApprovalJobId}.`);
354
+ console.log(_concatInstanceProperty(_context5 = "\u2139\uFE0F Found deployment approval job named ".concat(approvalJob, " with id ")).call(_context5, applicationApprovalJobId, "."));
344
355
  let confirmationPrompt;
345
356
  if (!cliFlags.yes) {
346
357
  confirmationPrompt = await waitForConfirmationPrompt({
@@ -348,11 +359,11 @@ async function approve(cliFlags, config, circleCiApis) {
348
359
  revision: deploymentPipeline.vcs.revision
349
360
  });
350
361
  }
351
- if (cliFlags.yes || confirmationPrompt?.confirmed) {
362
+ if (cliFlags.yes || (_confirmationPrompt = confirmationPrompt) !== null && _confirmationPrompt !== void 0 && _confirmationPrompt.confirmed) {
352
363
  if (cliFlags.dryRun) {
353
- console.log(`🙊 Not approving deployment job due to dry run.`);
364
+ console.log("\uD83D\uDE4A Not approving deployment job due to dry run.");
354
365
  } else {
355
- console.log(`ℹ️ Approving deployment job.`);
366
+ console.log("\u2139\uFE0F Approving deployment job.");
356
367
  }
357
368
  const approvalRequest = circleCiApis.approve({
358
369
  workflowId,
@@ -363,10 +374,11 @@ async function approve(cliFlags, config, circleCiApis) {
363
374
  skip: cliFlags.dryRun
364
375
  });
365
376
  if (cliFlags.yes) {
366
- console.log(`ℹ️ Skipping determining deployment job approved by ${approvalJob} due to '--yes' flag. Please check CircleCI manually.`);
377
+ console.log("\u2139\uFE0F Skipping determining deployment job approved by ".concat(approvalJob, " due to '--yes' flag. Please check CircleCI manually."));
367
378
  } else if (cliFlags.dryRun) {
368
- console.log(`✌️ Dry running hence could not determine deployment job approved by ${approvalJob}.`);
379
+ console.log("\u270C\uFE0F Dry running hence could not determine deployment job approved by ".concat(approvalJob, "."));
369
380
  } else if (deploymentJob) {
381
+ var _context6, _context7;
370
382
  const deploymentJobNumber = await waitForDeploymentJobNumber({
371
383
  workflowId,
372
384
  deploymentJob,
@@ -376,22 +388,23 @@ async function approve(cliFlags, config, circleCiApis) {
376
388
  dryRun: cliFlags.dryRun,
377
389
  yes: cliFlags.yes
378
390
  });
379
- console.log(`🙌 The deployment via ${approvalJob} at revision ${deploymentPipeline.vcs.revision} is running at: ${getJobUrl({
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({
380
392
  projectName: config.CircleCI.projectName,
381
393
  pipelineNumber: deploymentPipeline.number,
382
394
  workflowId,
383
395
  jobNumber: deploymentJobNumber
384
- })}`);
396
+ })));
385
397
  } else {
386
- console.log(`ℹ️ Skipping determining deployment job as no '--deployment-job' name to wait for was passed. Please check CircleCI manually.`);
398
+ console.log("\u2139\uFE0F Skipping determining deployment job as no '--deployment-job' name to wait for was passed. Please check CircleCI manually.");
387
399
  }
388
400
  } else {
389
- console.log(`ℹ️ Not approving deployment job. Confirm the prompt or use '--yes' option.`);
401
+ console.log("\u2139\uFE0F Not approving deployment job. Confirm the prompt or use '--yes' option.");
390
402
  }
391
403
  }
392
404
 
393
405
  async function processCircleCiResponse(response) {
394
406
  if (!response.ok) {
407
+ var _context, _context2;
395
408
  /**
396
409
  * NOTE:
397
410
  * Trying to handle known but undocumented responses of the CircleCI API.
@@ -411,13 +424,13 @@ async function processCircleCiResponse(response) {
411
424
  message = _JSON$parse.message;
412
425
  if (message.match(/job already approved/i)) {
413
426
  console.log('ℹ️ Deployment job is already approved.');
414
- process.exit(0);
427
+ // TODO: can we return instead of force exiting?
428
+ exit(0);
415
429
  }
416
430
  } catch {
417
431
  // Ignore JSON parsing errors
418
432
  }
419
- throw new Error(`${response.status}: Network response was not ok.\n
420
- Status text is ${response.statusText} and text is ${error}.`);
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, "."));
421
434
  }
422
435
  return response.json();
423
436
  }
@@ -425,10 +438,11 @@ function createCircleCiClient(_ref) {
425
438
  let projectName = _ref.projectName,
426
439
  apiBaseUrl = _ref.apiBaseUrl;
427
440
  async function execute(api) {
441
+ var _context3;
428
442
  let _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
429
443
  skip = _ref2.skip,
430
444
  debug = _ref2.debug;
431
- let url = `${apiBaseUrl}${api.url}`;
445
+ let url = _concatInstanceProperty(_context3 = "".concat(apiBaseUrl)).call(_context3, api.url);
432
446
  if (api.params && api.method === 'GET') {
433
447
  const urlSearchParams = new _URLSearchParams();
434
448
  for (const _ref3 of _Object$entries(api.params)) {
@@ -439,18 +453,18 @@ function createCircleCiClient(_ref) {
439
453
  urlSearchParams.append(key, value);
440
454
  }
441
455
  }
442
- url += `?${urlSearchParams.toString()}`;
456
+ url += "?".concat(urlSearchParams.toString());
443
457
  }
444
458
  if (skip) {
445
459
  if (debug) {
446
- console.log(`🏭 Skipping CircleCI call API at: ${url}.`);
460
+ console.log("\uD83C\uDFED Skipping CircleCI call API at: ".concat(url, "."));
447
461
  }
448
462
 
449
463
  // @ts-expect-error
450
464
  return _Promise.resolve();
451
465
  }
452
466
  if (debug) {
453
- console.log(`🏭 Calling CircleCI API at: ${url}.`);
467
+ console.log("\uD83C\uDFED Calling CircleCI API at: ".concat(url, "."));
454
468
  }
455
469
  try {
456
470
  const response = await fetch(url, {
@@ -461,7 +475,7 @@ function createCircleCiClient(_ref) {
461
475
  const processedCircleCiResponse = await processCircleCiResponse(response);
462
476
  return processedCircleCiResponse;
463
477
  } catch (error) {
464
- console.log(`⚠️ Calling CircleCI API at: ${url} failed.`);
478
+ console.log("\u26A0\uFE0F Calling CircleCI API at: ".concat(url, " failed."));
465
479
  throw error;
466
480
  }
467
481
  }
@@ -470,12 +484,12 @@ function createCircleCiClient(_ref) {
470
484
  let _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
471
485
  pageToken = _ref5.pageToken,
472
486
  _ref5$projectSlug = _ref5.projectSlug,
473
- projectSlug = _ref5$projectSlug === void 0 ? `gh/commercetools/${projectName}` : _ref5$projectSlug,
487
+ projectSlug = _ref5$projectSlug === void 0 ? "gh/commercetools/".concat(projectName) : _ref5$projectSlug,
474
488
  _ref5$branch = _ref5.branch,
475
489
  branch = _ref5$branch === void 0 ? 'main' : _ref5$branch;
476
490
  return {
477
491
  execute: options => execute({
478
- url: `/project/${projectSlug}/pipeline`,
492
+ url: "/project/".concat(projectSlug, "/pipeline"),
479
493
  headers: {
480
494
  'Content-Type': 'application/json',
481
495
  // The CLI throws if this is not present on environment
@@ -493,7 +507,7 @@ function createCircleCiClient(_ref) {
493
507
  let pipelineId = _ref6.pipelineId;
494
508
  return {
495
509
  execute: options => execute({
496
- url: `/pipeline/${pipelineId}/workflow`,
510
+ url: "/pipeline/".concat(pipelineId, "/workflow"),
497
511
  headers: {
498
512
  'Content-Type': 'application/json',
499
513
  // The CLI throws if this is not present on environment
@@ -507,7 +521,7 @@ function createCircleCiClient(_ref) {
507
521
  let workflowId = _ref7.workflowId;
508
522
  return {
509
523
  execute: options => execute({
510
- url: `/workflow/${workflowId}/job`,
524
+ url: "/workflow/".concat(workflowId, "/job"),
511
525
  headers: {
512
526
  'Content-Type': 'application/json',
513
527
  // The CLI throws if this is not present on environment
@@ -521,15 +535,18 @@ function createCircleCiClient(_ref) {
521
535
  let workflowId = _ref8.workflowId,
522
536
  approvalRequestId = _ref8.approvalRequestId;
523
537
  return {
524
- execute: options => execute({
525
- url: `/workflow/${workflowId}/approve/${approvalRequestId} `,
526
- headers: {
527
- 'Content-Type': 'application/json',
528
- // The CLI throws if this is not present on environment
529
- 'Circle-Token': process.env.CIRCLE_TOKEN
530
- },
531
- method: 'POST'
532
- }, options)
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
+ }
533
550
  };
534
551
  }
535
552
  };
@@ -557,13 +574,13 @@ async function run() {
557
574
 
558
575
  // Command: Approve
559
576
  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/).';
560
- 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.', {
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.', {
561
578
  default: 'main'
562
579
  }).option('--yes', '(optional) Skip all confirmation prompts. Useful in Continuous integration (CI) to automatically answer confirmation questions.', {
563
580
  default: false
564
581
  }).action(async options => {
565
582
  if (options.dryRun) {
566
- console.log(`🙊 Do not worry. This is a dry run!`);
583
+ console.log("\uD83D\uDE4A Do not worry. This is a dry run!");
567
584
  }
568
585
  throwIfRequiredEnvironmentVariableIsUnset(['CIRCLE_TOKEN']);
569
586
  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.0",
3
+ "version": "2.0.0",
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",
@@ -29,15 +30,15 @@
29
30
  "prompts": "2.4.2"
30
31
  },
31
32
  "devDependencies": {
32
- "@tsconfig/node20": "20.1.2",
33
+ "@tsconfig/node20": "20.1.4",
33
34
  "@types/lodash": "^4.14.198",
34
- "@types/node": "20.11.5",
35
+ "@types/node": "20.12.12",
35
36
  "@types/prompts": "2.4.9",
36
- "msw": "1.3.2",
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": {