@commercetools-frontend/deployment-cli 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -39,7 +39,7 @@ var fetch__default = /*#__PURE__*/_interopDefault(fetch);
39
39
 
40
40
  var pkgJson = {
41
41
  name: "@commercetools-frontend/deployment-cli",
42
- version: "0.2.0",
42
+ version: "0.2.2",
43
43
  description: "CLI to manage Custom Applications deployments in Google Storage.",
44
44
  keywords: [
45
45
  "commercetools",
@@ -65,20 +65,20 @@ var pkgJson = {
65
65
  "@babel/runtime": "^7.21.0",
66
66
  "@babel/runtime-corejs3": "^7.21.0",
67
67
  cac: "^6.7.14",
68
- cosmiconfig: "8.1.3",
68
+ cosmiconfig: "8.2.0",
69
69
  lodash: "4.17.21",
70
- "node-fetch": "2.6.9",
70
+ "node-fetch": "2.6.11",
71
71
  "p-retry": "4.6.2",
72
72
  prompts: "2.4.2"
73
73
  },
74
74
  devDependencies: {
75
75
  "@tsconfig/node18": "1.0.3",
76
76
  "@types/lodash": "^4.14.191",
77
- "@types/node": "18.16.5",
78
- "@types/node-fetch": "2.6.3",
77
+ "@types/node": "20.4.0",
78
+ "@types/node-fetch": "2.6.2",
79
79
  "@types/prompts": "2.4.4",
80
- msw: "1.2.1",
81
- typescript: "^4.9.5"
80
+ msw: "1.2.2",
81
+ typescript: "4.9.5"
82
82
  },
83
83
  engines: {
84
84
  node: ">=14",
@@ -432,17 +432,24 @@ async function processCircleCiResponse(response) {
432
432
  * 1. Message: Already approved job
433
433
  * Deployment was already triggered manually or by train the day before.
434
434
  */
435
+
436
+ // Response data is a stream so text OR json can only be read once, so
437
+ // we read it as text first and then try to parse it as json to handle
438
+ // known error responses.
439
+ const error = await response.text();
435
440
  try {
436
- const errorJson = await response.json();
437
- if (errorJson.message.match(/job already approved/i)) {
441
+ // The CircleCI API always uses content-type text/plain, so we always
442
+ // try parsing JSON to see if the message property is present.
443
+ const _JSON$parse = JSON.parse(error),
444
+ message = _JSON$parse.message;
445
+ if (message.match(/job already approved/i)) {
438
446
  console.log('ℹ️ Deployment job is already approved.');
439
447
  process.exit(0);
440
448
  }
441
- } catch (e) {
442
- // ignore
449
+ } catch {
450
+ // Ignore JSON parsing errors
443
451
  }
444
- const errorText = await response.text();
445
- throw new Error(_concatInstanceProperty__default["default"](_context = _concatInstanceProperty__default["default"](_context2 = "".concat(response.status, ": Network response was not ok.\n\n Status text is ")).call(_context2, response.statusText, " and text is ")).call(_context, errorText, "."));
452
+ throw new Error(_concatInstanceProperty__default["default"](_context = _concatInstanceProperty__default["default"](_context2 = "".concat(response.status, ": Network response was not ok.\n\n Status text is ")).call(_context2, response.statusText, " and text is ")).call(_context, error, "."));
446
453
  }
447
454
  return response.json();
448
455
  }
@@ -39,7 +39,7 @@ var fetch__default = /*#__PURE__*/_interopDefault(fetch);
39
39
 
40
40
  var pkgJson = {
41
41
  name: "@commercetools-frontend/deployment-cli",
42
- version: "0.2.0",
42
+ version: "0.2.2",
43
43
  description: "CLI to manage Custom Applications deployments in Google Storage.",
44
44
  keywords: [
45
45
  "commercetools",
@@ -65,20 +65,20 @@ var pkgJson = {
65
65
  "@babel/runtime": "^7.21.0",
66
66
  "@babel/runtime-corejs3": "^7.21.0",
67
67
  cac: "^6.7.14",
68
- cosmiconfig: "8.1.3",
68
+ cosmiconfig: "8.2.0",
69
69
  lodash: "4.17.21",
70
- "node-fetch": "2.6.9",
70
+ "node-fetch": "2.6.11",
71
71
  "p-retry": "4.6.2",
72
72
  prompts: "2.4.2"
73
73
  },
74
74
  devDependencies: {
75
75
  "@tsconfig/node18": "1.0.3",
76
76
  "@types/lodash": "^4.14.191",
77
- "@types/node": "18.16.5",
78
- "@types/node-fetch": "2.6.3",
77
+ "@types/node": "20.4.0",
78
+ "@types/node-fetch": "2.6.2",
79
79
  "@types/prompts": "2.4.4",
80
- msw: "1.2.1",
81
- typescript: "^4.9.5"
80
+ msw: "1.2.2",
81
+ typescript: "4.9.5"
82
82
  },
83
83
  engines: {
84
84
  node: ">=14",
@@ -432,17 +432,24 @@ async function processCircleCiResponse(response) {
432
432
  * 1. Message: Already approved job
433
433
  * Deployment was already triggered manually or by train the day before.
434
434
  */
435
+
436
+ // Response data is a stream so text OR json can only be read once, so
437
+ // we read it as text first and then try to parse it as json to handle
438
+ // known error responses.
439
+ const error = await response.text();
435
440
  try {
436
- const errorJson = await response.json();
437
- if (errorJson.message.match(/job already approved/i)) {
441
+ // The CircleCI API always uses content-type text/plain, so we always
442
+ // try parsing JSON to see if the message property is present.
443
+ const _JSON$parse = JSON.parse(error),
444
+ message = _JSON$parse.message;
445
+ if (message.match(/job already approved/i)) {
438
446
  console.log('ℹ️ Deployment job is already approved.');
439
447
  process.exit(0);
440
448
  }
441
- } catch (e) {
442
- // ignore
449
+ } catch {
450
+ // Ignore JSON parsing errors
443
451
  }
444
- const errorText = await response.text();
445
- throw new Error(_concatInstanceProperty__default["default"](_context = _concatInstanceProperty__default["default"](_context2 = "".concat(response.status, ": Network response was not ok.\n\n Status text is ")).call(_context2, response.statusText, " and text is ")).call(_context, errorText, "."));
452
+ throw new Error(_concatInstanceProperty__default["default"](_context = _concatInstanceProperty__default["default"](_context2 = "".concat(response.status, ": Network response was not ok.\n\n Status text is ")).call(_context2, response.statusText, " and text is ")).call(_context, error, "."));
446
453
  }
447
454
  return response.json();
448
455
  }
@@ -18,7 +18,7 @@ import fetch from 'node-fetch';
18
18
 
19
19
  var pkgJson = {
20
20
  name: "@commercetools-frontend/deployment-cli",
21
- version: "0.2.0",
21
+ version: "0.2.2",
22
22
  description: "CLI to manage Custom Applications deployments in Google Storage.",
23
23
  keywords: [
24
24
  "commercetools",
@@ -44,20 +44,20 @@ var pkgJson = {
44
44
  "@babel/runtime": "^7.21.0",
45
45
  "@babel/runtime-corejs3": "^7.21.0",
46
46
  cac: "^6.7.14",
47
- cosmiconfig: "8.1.3",
47
+ cosmiconfig: "8.2.0",
48
48
  lodash: "4.17.21",
49
- "node-fetch": "2.6.9",
49
+ "node-fetch": "2.6.11",
50
50
  "p-retry": "4.6.2",
51
51
  prompts: "2.4.2"
52
52
  },
53
53
  devDependencies: {
54
54
  "@tsconfig/node18": "1.0.3",
55
55
  "@types/lodash": "^4.14.191",
56
- "@types/node": "18.16.5",
57
- "@types/node-fetch": "2.6.3",
56
+ "@types/node": "20.4.0",
57
+ "@types/node-fetch": "2.6.2",
58
58
  "@types/prompts": "2.4.4",
59
- msw: "1.2.1",
60
- typescript: "^4.9.5"
59
+ msw: "1.2.2",
60
+ typescript: "4.9.5"
61
61
  },
62
62
  engines: {
63
63
  node: ">=14",
@@ -411,17 +411,24 @@ async function processCircleCiResponse(response) {
411
411
  * 1. Message: Already approved job
412
412
  * Deployment was already triggered manually or by train the day before.
413
413
  */
414
+
415
+ // Response data is a stream so text OR json can only be read once, so
416
+ // we read it as text first and then try to parse it as json to handle
417
+ // known error responses.
418
+ const error = await response.text();
414
419
  try {
415
- const errorJson = await response.json();
416
- if (errorJson.message.match(/job already approved/i)) {
420
+ // The CircleCI API always uses content-type text/plain, so we always
421
+ // try parsing JSON to see if the message property is present.
422
+ const _JSON$parse = JSON.parse(error),
423
+ message = _JSON$parse.message;
424
+ if (message.match(/job already approved/i)) {
417
425
  console.log('ℹ️ Deployment job is already approved.');
418
426
  process.exit(0);
419
427
  }
420
- } catch (e) {
421
- // ignore
428
+ } catch {
429
+ // Ignore JSON parsing errors
422
430
  }
423
- const errorText = await response.text();
424
- 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, errorText, "."));
431
+ 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, "."));
425
432
  }
426
433
  return response.json();
427
434
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/deployment-cli",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "CLI to manage Custom Applications deployments in Google Storage.",
5
5
  "keywords": [
6
6
  "commercetools",
@@ -23,20 +23,20 @@
23
23
  "@babel/runtime": "^7.21.0",
24
24
  "@babel/runtime-corejs3": "^7.21.0",
25
25
  "cac": "^6.7.14",
26
- "cosmiconfig": "8.1.3",
26
+ "cosmiconfig": "8.2.0",
27
27
  "lodash": "4.17.21",
28
- "node-fetch": "2.6.9",
28
+ "node-fetch": "2.6.11",
29
29
  "p-retry": "4.6.2",
30
30
  "prompts": "2.4.2"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@tsconfig/node18": "1.0.3",
34
34
  "@types/lodash": "^4.14.191",
35
- "@types/node": "18.16.5",
36
- "@types/node-fetch": "2.6.3",
35
+ "@types/node": "20.4.0",
36
+ "@types/node-fetch": "2.6.2",
37
37
  "@types/prompts": "2.4.4",
38
- "msw": "1.2.1",
39
- "typescript": "^4.9.5"
38
+ "msw": "1.2.2",
39
+ "typescript": "4.9.5"
40
40
  },
41
41
  "engines": {
42
42
  "node": ">=14",