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