@commercetools-frontend/mc-scripts 25.0.0 → 25.2.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.
Files changed (84) hide show
  1. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.dev.js +1 -1
  2. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js +1 -1
  3. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.esm.js +1 -1
  4. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +28 -14
  5. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +28 -14
  6. package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +28 -14
  7. package/dist/{build-50f29fb0.cjs.prod.js → build-182a099c.cjs.prod.js} +7 -7
  8. package/dist/{build-0b4c6b04.esm.js → build-220a1658.esm.js} +7 -7
  9. package/dist/{build-1baf8a00.cjs.dev.js → build-519d246d.cjs.dev.js} +7 -7
  10. package/dist/{build-vite-e26f6c9f.cjs.dev.js → build-vite-837e7c94.cjs.dev.js} +64 -43
  11. package/dist/{build-vite-85211835.esm.js → build-vite-8cae71a0.esm.js} +61 -24
  12. package/dist/{build-vite-4a6c90c2.cjs.prod.js → build-vite-b007241b.cjs.prod.js} +64 -43
  13. package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +1 -1
  14. package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +1 -1
  15. package/dist/commercetools-frontend-mc-scripts.esm.js +1 -1
  16. package/dist/{compile-html-adfef598.esm.js → compile-html-025cd493.esm.js} +2 -4
  17. package/dist/{compile-html-b80f9651.cjs.prod.js → compile-html-50fd05ec.cjs.prod.js} +2 -5
  18. package/dist/{compile-html-8679f721.cjs.dev.js → compile-html-f4ac88cc.cjs.dev.js} +2 -5
  19. package/dist/config-sync-0b96d430.esm.js +255 -0
  20. package/dist/config-sync-b3072939.cjs.prod.js +265 -0
  21. package/dist/config-sync-ci-4a09aa00.cjs.prod.js +305 -0
  22. package/dist/config-sync-ci-85e3fec2.esm.js +294 -0
  23. package/dist/config-sync-ci-eadb8bfc.cjs.dev.js +305 -0
  24. package/dist/config-sync-f8fca39f.cjs.dev.js +265 -0
  25. package/dist/{config-sync-87ba9f28.cjs.prod.js → config-sync-helpers-11fc328f.cjs.prod.js} +193 -326
  26. package/dist/{config-sync-27ca0c93.cjs.dev.js → config-sync-helpers-dab59ed9.cjs.dev.js} +195 -328
  27. package/dist/{config-sync-ff4b1e5b.esm.js → config-sync-helpers-fe6ea729.esm.js} +186 -323
  28. package/dist/{create-postcss-config-34bab342.cjs.prod.js → create-postcss-config-56b74a34.cjs.prod.js} +1 -1
  29. package/dist/{create-postcss-config-0e833724.cjs.dev.js → create-postcss-config-78879a12.cjs.dev.js} +1 -1
  30. package/dist/{create-postcss-config-e6dfba3f.esm.js → create-postcss-config-95f9bf62.esm.js} +1 -1
  31. package/dist/{create-webpack-config-for-development-fe0945ce.cjs.prod.js → create-webpack-config-for-development-3eb1b365.cjs.prod.js} +7 -7
  32. package/dist/{create-webpack-config-for-development-2ac1d86f.cjs.dev.js → create-webpack-config-for-development-62b89920.cjs.dev.js} +7 -7
  33. package/dist/{create-webpack-config-for-development-be2722d6.esm.js → create-webpack-config-for-development-a28736fa.esm.js} +7 -7
  34. package/dist/{create-webpack-config-for-production-66c77849.esm.js → create-webpack-config-for-production-21ea561f.esm.js} +8 -8
  35. package/dist/{create-webpack-config-for-production-2200e554.cjs.prod.js → create-webpack-config-for-production-3b6599db.cjs.prod.js} +8 -8
  36. package/dist/{create-webpack-config-for-production-d2c41a9d.cjs.dev.js → create-webpack-config-for-production-e5ed8805.cjs.dev.js} +8 -8
  37. package/dist/{credentials-storage-381abf27.cjs.prod.js → credentials-storage-6d592cd6.cjs.prod.js} +21 -3
  38. package/dist/{credentials-storage-de220814.cjs.dev.js → credentials-storage-c4c5980e.cjs.dev.js} +21 -3
  39. package/dist/{credentials-storage-7285d7b4.esm.js → credentials-storage-fcc77fb6.esm.js} +21 -3
  40. package/dist/declarations/src/types.d.ts +4 -0
  41. package/dist/{deployment-previews-set-7f9fbfe5.esm.js → deployment-previews-set-7d49e7df.esm.js} +22 -27
  42. package/dist/{deployment-previews-set-3697be5e.cjs.dev.js → deployment-previews-set-8d6a1e99.cjs.dev.js} +22 -28
  43. package/dist/{deployment-previews-set-e92403f7.cjs.prod.js → deployment-previews-set-f8ce3db7.cjs.prod.js} +22 -28
  44. package/dist/{graphql-requests-bab5fcc3.cjs.dev.js → graphql-requests-b57fca4c.cjs.prod.js} +5 -8
  45. package/dist/{graphql-requests-d8bc2292.esm.js → graphql-requests-d2fa2ca7.esm.js} +6 -9
  46. package/dist/{graphql-requests-8ef89149.cjs.prod.js → graphql-requests-da194989.cjs.dev.js} +5 -8
  47. package/dist/{i18n-message-complilation-8aec9d1b.esm.js → i18n-message-complilation-21d3b0aa.esm.js} +1 -1
  48. package/dist/{i18n-message-complilation-3f80e8d6.cjs.dev.js → i18n-message-complilation-7311cb29.cjs.dev.js} +1 -1
  49. package/dist/{i18n-message-complilation-393d344a.cjs.prod.js → i18n-message-complilation-7762da61.cjs.prod.js} +1 -1
  50. package/dist/{login-5fd67aac.cjs.prod.js → login-9774c9cc.cjs.prod.js} +154 -38
  51. package/dist/login-abb38213.esm.js +337 -0
  52. package/dist/{login-9fac9eee.cjs.dev.js → login-f4550251.cjs.dev.js} +154 -38
  53. package/dist/{optimizations-ea21b802.cjs.prod.js → optimizations-7789145e.cjs.dev.js} +5 -8
  54. package/dist/{optimizations-ea71a24a.esm.js → optimizations-bf991634.esm.js} +5 -7
  55. package/dist/{optimizations-ebbeaf88.cjs.dev.js → optimizations-fb93514f.cjs.prod.js} +5 -8
  56. package/dist/{package-ff04bcf7.cjs.dev.js → package-0eebca1b.cjs.dev.js} +21 -11
  57. package/dist/{package-4bdd2ccf.esm.js → package-9e6910b8.esm.js} +21 -11
  58. package/dist/{package-428d5001.cjs.prod.js → package-b9298ce3.cjs.prod.js} +21 -11
  59. package/dist/{paths-7bf7e88e.esm.js → paths-39f22b8b.esm.js} +4 -9
  60. package/dist/{paths-af1a725a.cjs.prod.js → paths-7768b440.cjs.prod.js} +4 -10
  61. package/dist/{paths-ec3e3a7d.cjs.dev.js → paths-b76fc753.cjs.dev.js} +4 -10
  62. package/dist/{serve-04a03d5f.cjs.dev.js → serve-38456e1b.cjs.dev.js} +7 -6
  63. package/dist/{serve-fb1a0f5a.esm.js → serve-be1f9439.esm.js} +6 -6
  64. package/dist/{serve-2a863026.cjs.prod.js → serve-cc4a766d.cjs.prod.js} +7 -6
  65. package/dist/{start-643a55bb.esm.js → start-109f9462.esm.js} +8 -9
  66. package/dist/{start-47ea5e04.cjs.dev.js → start-7765f44c.cjs.dev.js} +8 -9
  67. package/dist/{start-84cdf12b.cjs.prod.js → start-e014127c.cjs.prod.js} +8 -9
  68. package/dist/{start-vite-eea72ba9.cjs.dev.js → start-vite-068e9f73.cjs.dev.js} +3 -4
  69. package/dist/{start-vite-d548c121.cjs.prod.js → start-vite-29078b3a.cjs.prod.js} +3 -4
  70. package/dist/{start-vite-d649d1f3.esm.js → start-vite-7d1161e8.esm.js} +3 -4
  71. package/dist/{vite-plugin-svgr-53ef97c7.cjs.dev.js → vite-plugin-svgr-4034a834.cjs.prod.js} +4 -4
  72. package/dist/{vite-plugin-svgr-5de1cad9.cjs.prod.js → vite-plugin-svgr-7d06f400.cjs.dev.js} +4 -4
  73. package/dist/{vite-plugin-svgr-22c8d518.esm.js → vite-plugin-svgr-de6ee7da.esm.js} +4 -4
  74. package/package.json +21 -11
  75. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +2 -2
  76. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +2 -2
  77. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +2 -2
  78. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +6 -6
  79. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +6 -6
  80. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +6 -6
  81. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.dev.js +1 -1
  82. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.prod.js +1 -1
  83. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.esm.js +1 -1
  84. package/dist/login-9ee43381.esm.js +0 -223
@@ -1,16 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
4
- var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
5
- var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
6
- var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
7
- var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
8
3
  var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
9
4
  var chalk = require('chalk');
10
5
  var omit = require('lodash/omit');
11
- var prompts = require('prompts');
12
- var applicationConfig = require('@commercetools-frontend/application-config');
13
- var credentialsStorage$1 = require('./credentials-storage-de220814.cjs.dev.js');
14
6
  var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
15
7
  var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
16
8
  var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
@@ -20,33 +12,19 @@ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
20
12
  var _repeatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/repeat');
21
13
  var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
22
14
  var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
15
+ var _bindInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/bind');
23
16
  var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
17
+ var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
24
18
  var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
25
- var graphqlRequests = require('./graphql-requests-bab5fcc3.cjs.dev.js');
26
- require('@babel/runtime-corejs3/helpers/classCallCheck');
27
- require('@babel/runtime-corejs3/helpers/createClass');
28
- require('@babel/runtime-corejs3/core-js-stable/date/now');
29
- require('node:fs');
30
- require('node:os');
31
- require('node:path');
32
- require('./does-file-exist-eb86baca.cjs.dev.js');
33
- require('@babel/runtime-corejs3/core-js-stable/instance/some');
34
- require('graphql');
35
- require('graphql-request');
36
- require('@commercetools-frontend/constants');
37
- require('@commercetools/http-user-agent');
38
- require('./package-ff04bcf7.cjs.dev.js');
19
+ var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
20
+ var applicationConfig = require('@commercetools-frontend/application-config');
21
+ var graphqlRequests = require('./graphql-requests-da194989.cjs.dev.js');
39
22
 
40
23
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
41
24
 
42
- var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
43
- var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
44
- var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
45
- var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
46
25
  var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
47
26
  var chalk__default = /*#__PURE__*/_interopDefault(chalk);
48
27
  var omit__default = /*#__PURE__*/_interopDefault(omit);
49
- var prompts__default = /*#__PURE__*/_interopDefault(prompts);
50
28
  var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
51
29
  var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
52
30
  var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
@@ -55,21 +33,24 @@ var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defin
55
33
  var _repeatInstanceProperty__default = /*#__PURE__*/_interopDefault(_repeatInstanceProperty);
56
34
  var _Set__default = /*#__PURE__*/_interopDefault(_Set);
57
35
  var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
36
+ var _bindInstanceProperty__default = /*#__PURE__*/_interopDefault(_bindInstanceProperty);
58
37
  var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
38
+ var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
59
39
  var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
40
+ var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
60
41
 
61
42
  function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
62
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context21, _context22; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context21 = ownKeys(Object(t), !0)).call(_context21, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context22 = ownKeys(Object(t))).call(_context22, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
43
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context9, _context0; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context9 = ownKeys(Object(t), !0)).call(_context9, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context0 = ownKeys(Object(t))).call(_context0, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
63
44
 
64
45
  // Since not all terminal supports colors, to make things more consistent for testing purposes,
65
46
  // during tests the color used is appended before the string instead of coloring it.
66
47
  const isTest = process.env.NODE_ENV === 'test';
67
48
  const red = str => {
68
- if (isTest) return "<color-red>".concat(str, "</color-red>");
49
+ if (isTest) return `<color-red>${str}</color-red>`;
69
50
  return chalk__default["default"].red(str);
70
51
  };
71
52
  const green = str => {
72
- if (isTest) return "<color-green>".concat(str, "</color-green>");
53
+ if (isTest) return `<color-green>${str}</color-green>`;
73
54
  return chalk__default["default"].green(str);
74
55
  };
75
56
 
@@ -85,21 +66,19 @@ const getStringDiff = _ref => {
85
66
  _ref$indentLevel = _ref.indentLevel,
86
67
  indentLevel = _ref$indentLevel === void 0 ? 0 : _ref$indentLevel;
87
68
  if (!previousValue && nextValue) {
88
- var _context2, _context3;
89
- return _concatInstanceProperty__default["default"](_context2 = _concatInstanceProperty__default["default"](_context3 = "".concat(indent(indentLevel))).call(_context3, label, " added: ")).call(_context2, green(nextValue));
69
+ return `${indent(indentLevel)}${label} added: ${green(nextValue)}`;
90
70
  }
91
71
  if (previousValue && !nextValue) {
92
- var _context4, _context5;
93
- return _concatInstanceProperty__default["default"](_context4 = _concatInstanceProperty__default["default"](_context5 = "".concat(indent(indentLevel))).call(_context5, label, " removed: ")).call(_context4, red(previousValue));
72
+ return `${indent(indentLevel)}${label} removed: ${red(previousValue)}`;
94
73
  }
95
74
  if (previousValue && nextValue && previousValue !== nextValue) {
96
- var _context6, _context7, _context8;
97
- return _concatInstanceProperty__default["default"](_context6 = _concatInstanceProperty__default["default"](_context7 = _concatInstanceProperty__default["default"](_context8 = "".concat(indent(indentLevel))).call(_context8, label, " changed: ")).call(_context7, red(previousValue), " => ")).call(_context6, green(nextValue));
75
+ return `${indent(indentLevel)}${label} changed: ${red(previousValue)} => ${green(nextValue)}`;
98
76
  }
99
77
  return null;
100
78
  };
101
79
  // NOTE: this assumes that the array values are scalar values (not objects).
102
80
  const getArrayDiff = _ref2 => {
81
+ var _context2, _context3;
103
82
  let previousValue = _ref2.previousValue,
104
83
  nextValue = _ref2.nextValue,
105
84
  label = _ref2.label,
@@ -107,7 +86,7 @@ const getArrayDiff = _ref2 => {
107
86
  indentLevel = _ref2$indentLevel === void 0 ? 0 : _ref2$indentLevel;
108
87
  const oldArraySet = new _Set__default["default"](previousValue);
109
88
  const arrayDiff = [];
110
- nextValue === null || nextValue === void 0 || _forEachInstanceProperty__default["default"](nextValue).call(nextValue, item => {
89
+ ((_context2 = nextValue) == null ? void 0 : _bindInstanceProperty__default["default"](_context3 = Function.call).call(_context3, _forEachInstanceProperty__default["default"](_context2), _context2))?.(item => {
111
90
  if (oldArraySet.has(item)) {
112
91
  oldArraySet.delete(item);
113
92
  } else {
@@ -128,7 +107,7 @@ const getArrayDiff = _ref2 => {
128
107
  return arrayDiff.join('\n');
129
108
  };
130
109
  const getPermissionsDiff = _ref3 => {
131
- var _context1;
110
+ var _context4;
132
111
  let previousValue = _ref3.previousValue,
133
112
  nextValue = _ref3.nextValue;
134
113
  const permissionDiff = ['permissions changed'];
@@ -141,12 +120,10 @@ const getPermissionsDiff = _ref3 => {
141
120
  }, {});
142
121
  const indentLevel = 1;
143
122
  _forEachInstanceProperty__default["default"](nextValue).call(nextValue, newPermission => {
144
- var _context9;
145
- const currentDiff = [_concatInstanceProperty__default["default"](_context9 = "".concat(indent(indentLevel), "\"")).call(_context9, newPermission.name, "\" changed")];
123
+ const currentDiff = [`${indent(indentLevel)}"${newPermission.name}" changed`];
146
124
  // if the permission name is not in the old config, it means it is a new addition.
147
125
  if (!mappedOldPermissions[newPermission.name]) {
148
- var _context0;
149
- permissionDiff.push(_concatInstanceProperty__default["default"](_context0 = "".concat(indent(indentLevel), "\"")).call(_context0, green(newPermission.name), "\" was added"));
126
+ permissionDiff.push(`${indent(indentLevel)}"${green(newPermission.name)}" was added`);
150
127
  }
151
128
 
152
129
  // if permission name is in the old config, now we check if there was a change
@@ -163,22 +140,21 @@ const getPermissionsDiff = _ref3 => {
163
140
  });
164
141
 
165
142
  // if there are old permissions left, it means they were deleted in the new Permissions.
166
- _forEachInstanceProperty__default["default"](_context1 = _Object$keys__default["default"](mappedOldPermissions)).call(_context1, oldPermissionName => {
167
- var _context10;
168
- permissionDiff.push(_concatInstanceProperty__default["default"](_context10 = "".concat(indent(indentLevel), "\"")).call(_context10, red(oldPermissionName), "\" was removed"));
143
+ _forEachInstanceProperty__default["default"](_context4 = _Object$keys__default["default"](mappedOldPermissions)).call(_context4, oldPermissionName => {
144
+ permissionDiff.push(`${indent(indentLevel)}"${red(oldPermissionName)}" was removed`);
169
145
  });
170
146
  if (permissionDiff.length > 1) return permissionDiff.join('\n');
171
147
  return null;
172
148
  };
173
149
  const getLabelAllLocalesDiff = _ref5 => {
174
- var _context14;
150
+ var _context5;
175
151
  let _ref5$previousValue = _ref5.previousValue,
176
152
  previousValue = _ref5$previousValue === void 0 ? [] : _ref5$previousValue,
177
153
  _ref5$nextValue = _ref5.nextValue,
178
154
  nextValue = _ref5$nextValue === void 0 ? [] : _ref5$nextValue,
179
155
  _ref5$indentLevel = _ref5.indentLevel,
180
156
  indentLevel = _ref5$indentLevel === void 0 ? 0 : _ref5$indentLevel;
181
- const labelAllLocalesDiff = ["".concat(indent(indentLevel - 1), "labelAllLocales changed")];
157
+ const labelAllLocalesDiff = [`${indent(indentLevel - 1)}labelAllLocales changed`];
182
158
  const mappedOldLabelAllLocales = _reduceInstanceProperty__default["default"](previousValue).call(previousValue, (previousLabelAllLocale, _ref6) => {
183
159
  let locale = _ref6.locale,
184
160
  value = _ref6.value;
@@ -190,8 +166,7 @@ const getLabelAllLocalesDiff = _ref5 => {
190
166
  if (newLabelAllLocale.locale in mappedOldLabelAllLocales) {
191
167
  const oldLocaleValue = mappedOldLabelAllLocales[newLabelAllLocale.locale];
192
168
  if (oldLocaleValue !== newLabelAllLocale.value) {
193
- var _context11, _context12, _context13;
194
- labelAllLocalesDiff.push(_concatInstanceProperty__default["default"](_context11 = _concatInstanceProperty__default["default"](_context12 = _concatInstanceProperty__default["default"](_context13 = "".concat(indent(indentLevel), "locale \"")).call(_context13, newLabelAllLocale.locale, "\" changed: ")).call(_context12, red(oldLocaleValue), " => ")).call(_context11, green(newLabelAllLocale.value)));
169
+ labelAllLocalesDiff.push(`${indent(indentLevel)}locale "${newLabelAllLocale.locale}" changed: ${red(oldLocaleValue)} => ${green(newLabelAllLocale.value)}`);
195
170
  }
196
171
  delete mappedOldLabelAllLocales[newLabelAllLocale.locale];
197
172
  } else {
@@ -205,7 +180,7 @@ const getLabelAllLocalesDiff = _ref5 => {
205
180
  }
206
181
  }
207
182
  });
208
- _forEachInstanceProperty__default["default"](_context14 = _Object$keys__default["default"](mappedOldLabelAllLocales)).call(_context14, key => {
183
+ _forEachInstanceProperty__default["default"](_context5 = _Object$keys__default["default"](mappedOldLabelAllLocales)).call(_context5, key => {
209
184
  const localeDiff = getStringDiff({
210
185
  previousValue: key,
211
186
  label: 'locale',
@@ -219,14 +194,14 @@ const getLabelAllLocalesDiff = _ref5 => {
219
194
  return null;
220
195
  };
221
196
  const getTypeSettingsDiff = _ref7 => {
222
- var _context15;
197
+ var _context6;
223
198
  let previousValue = _ref7.previousValue,
224
199
  nextValue = _ref7.nextValue;
225
200
  const nonNullablePreviousValue = previousValue || {};
226
201
  const nonNullableNextValue = nextValue || {};
227
202
  const indentLevel = 1;
228
- const typeSettingsDiff = ["".concat(indent(indentLevel - 1), "type settings changed")];
229
- _forEachInstanceProperty__default["default"](_context15 = _Object$keys__default["default"](nonNullablePreviousValue)).call(_context15, key => {
203
+ const typeSettingsDiff = [`${indent(indentLevel - 1)}type settings changed`];
204
+ _forEachInstanceProperty__default["default"](_context6 = _Object$keys__default["default"](nonNullablePreviousValue)).call(_context6, key => {
230
205
  const typeSettingDiff = getStringDiff({
231
206
  previousValue: nonNullablePreviousValue[key],
232
207
  nextValue: nonNullableNextValue[key],
@@ -276,7 +251,7 @@ const getMainMenuLinkDiff = _ref9 => {
276
251
  indentLevel: 2
277
252
  });
278
253
  if (mainMenuLinkPermissionsDiff.length > 0) {
279
- mainMenuLinkDiff.push("".concat(indent(1), "permissions changed"));
254
+ mainMenuLinkDiff.push(`${indent(1)}permissions changed`);
280
255
  mainMenuLinkDiff.push(mainMenuLinkPermissionsDiff);
281
256
  }
282
257
  const menuLabelsDiff = getLabelAllLocalesDiff({
@@ -292,7 +267,7 @@ const getMainMenuLinkDiff = _ref9 => {
292
267
  return null;
293
268
  };
294
269
  const getSubmenuLinksDiff = _ref0 => {
295
- var _context20;
270
+ var _context8;
296
271
  let previousValue = _ref0.previousValue,
297
272
  nextValue = _ref0.nextValue;
298
273
  const submenuLinksDiff = ['submenuLink changed'];
@@ -303,17 +278,16 @@ const getSubmenuLinksDiff = _ref0 => {
303
278
  const previousOrder = getOrder(previousValue);
304
279
  const newOrder = getOrder(nextValue);
305
280
  if (previousOrder !== newOrder) {
306
- var _context16, _context17;
307
- submenuLinksDiff.push("".concat(indent(1), "submenu order changed"));
308
- submenuLinksDiff.push(_concatInstanceProperty__default["default"](_context16 = "".concat(indent(2), "previous order: [")).call(_context16, previousOrder, "]"));
309
- submenuLinksDiff.push(_concatInstanceProperty__default["default"](_context17 = "".concat(indent(2), "new order: [")).call(_context17, newOrder, "]"));
281
+ submenuLinksDiff.push(`${indent(1)}submenu order changed`);
282
+ submenuLinksDiff.push(`${indent(2)}previous order: [${previousOrder}]`);
283
+ submenuLinksDiff.push(`${indent(2)}new order: [${newOrder}]`);
310
284
  }
311
285
  _forEachInstanceProperty__default["default"](nextValue).call(nextValue, newSubmenuLink => {
312
286
  const oldSubMenuLink = mappedSubmenuLinks[newSubmenuLink.uriPath];
313
287
  if (newSubmenuLink.uriPath in mappedSubmenuLinks) {
314
- var _context18, _context19;
315
- const submenuLinkDiff = [_concatInstanceProperty__default["default"](_context18 = "".concat(indent(1), "menu link \"")).call(_context18, newSubmenuLink.uriPath, "\" changed")];
316
- _forEachInstanceProperty__default["default"](_context19 = _Object$keys__default["default"](mappedSubmenuLinks[newSubmenuLink.uriPath])).call(_context19, key => {
288
+ var _context7;
289
+ const submenuLinkDiff = [`${indent(1)}menu link "${newSubmenuLink.uriPath}" changed`];
290
+ _forEachInstanceProperty__default["default"](_context7 = _Object$keys__default["default"](mappedSubmenuLinks[newSubmenuLink.uriPath])).call(_context7, key => {
317
291
  switch (key) {
318
292
  case 'defaultLabel':
319
293
  {
@@ -337,7 +311,7 @@ const getSubmenuLinksDiff = _ref0 => {
337
311
  indentLevel: 3
338
312
  });
339
313
  if (submenuLinkPermissionsDiff.length > 0) {
340
- submenuLinkDiff.push("".concat(indent(2), "permissions changed"));
314
+ submenuLinkDiff.push(`${indent(2)}permissions changed`);
341
315
  submenuLinkDiff.push(submenuLinkPermissionsDiff);
342
316
  }
343
317
  break;
@@ -372,7 +346,7 @@ const getSubmenuLinksDiff = _ref0 => {
372
346
  }
373
347
  }
374
348
  });
375
- _forEachInstanceProperty__default["default"](_context20 = _Object$keys__default["default"](mappedSubmenuLinks)).call(_context20, key => {
349
+ _forEachInstanceProperty__default["default"](_context8 = _Object$keys__default["default"](mappedSubmenuLinks)).call(_context8, key => {
376
350
  const linksDiff = getStringDiff({
377
351
  previousValue: key,
378
352
  label: 'menu link',
@@ -545,319 +519,212 @@ const getCustomViewConfigDiff = (oldConfig, newConfig) => {
545
519
  return diff.join('\n');
546
520
  };
547
521
 
548
- const credentialsStorage = new credentialsStorage$1.CredentialsStorage();
549
522
  const getMcUrlLink = _ref => {
550
- var _context, _context2, _context3;
551
523
  let mcApiUrl = _ref.mcApiUrl,
552
524
  organizationId = _ref.organizationId,
553
525
  customEntityId = _ref.customEntityId,
554
526
  isCustomView = _ref.isCustomView;
555
527
  const mcUrl = mcApiUrl.replace('mc-api', 'mc');
556
- const customEntityLink = _concatInstanceProperty__default["default"](_context = _concatInstanceProperty__default["default"](_context2 = _concatInstanceProperty__default["default"](_context3 = "".concat(mcUrl, "/account/organizations/")).call(_context3, organizationId, "/custom-")).call(_context2, isCustomView ? 'views' : 'applications', "/owned/")).call(_context, customEntityId);
528
+ const customEntityLink = `${mcUrl}/account/organizations/${organizationId}/custom-${isCustomView ? 'views' : 'applications'}/owned/${customEntityId}`;
557
529
  return customEntityLink;
558
530
  };
559
531
  const isCustomViewData = data => data.entryPointUriPath === undefined;
560
- async function createOrUpdateCustomApplication(_ref2) {
561
- var _context6;
532
+ async function performCreateCustomApplication(_ref2) {
562
533
  let mcApiUrl = _ref2.mcApiUrl,
534
+ organizationId = _ref2.organizationId,
535
+ organizationName = _ref2.organizationName,
563
536
  localCustomEntityData = _ref2.localCustomEntityData,
564
537
  applicationIdentifier = _ref2.applicationIdentifier,
565
- options = _ref2.options;
566
- const fetchedCustomApplication = await graphqlRequests.fetchCustomApplication({
538
+ dryRun = _ref2.dryRun;
539
+ console.log(`Creating Custom Application in organization "${chalk__default["default"].green(organizationName)}"...`);
540
+ const data = omit__default["default"](localCustomEntityData, ['id']);
541
+ if (dryRun) {
542
+ console.log();
543
+ console.log('Dry run - would create Custom Application with:');
544
+ console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
545
+ return null;
546
+ }
547
+ const createdCustomApplication = await graphqlRequests.createCustomApplication({
567
548
  mcApiUrl,
568
- entryPointUriPath: localCustomEntityData.entryPointUriPath,
549
+ organizationId,
550
+ data,
569
551
  applicationIdentifier
570
552
  });
571
- if (!fetchedCustomApplication) {
572
- var _context5;
573
- const userOrganizations = await graphqlRequests.fetchUserOrganizations({
574
- mcApiUrl,
575
- applicationIdentifier
576
- });
577
- let organizationId, organizationName;
578
- if (userOrganizations.total === 0) {
579
- throw new Error("It seems you are not an admin of any Organization. Please make sure to be part of the Administrators team of the Organization you want the Custom Application to be configured to.");
580
- }
581
- if (userOrganizations.total === 1) {
582
- const _userOrganizations$re = _slicedToArray(userOrganizations.results, 1),
583
- organization = _userOrganizations$re[0];
584
- organizationId = organization.id;
585
- organizationName = organization.name;
586
- } else {
587
- var _context4;
588
- const organizationChoices = _mapInstanceProperty__default["default"](_context4 = userOrganizations.results).call(_context4, organization => ({
589
- title: organization.name,
590
- value: organization.id
591
- }));
592
- const _await$prompts = await prompts__default["default"]({
593
- type: 'select',
594
- name: 'organizationId',
595
- message: 'Select an Organization',
596
- choices: organizationChoices,
597
- initial: 0
598
- }),
599
- selectedOrganizationId = _await$prompts.organizationId;
600
- if (!selectedOrganizationId) {
601
- throw new Error("No Organization selected, aborting.");
602
- }
603
- organizationId = selectedOrganizationId;
604
- organizationName = _findInstanceProperty__default["default"](organizationChoices).call(organizationChoices, _ref3 => {
605
- let value = _ref3.value;
606
- return value === organizationId;
607
- }).title;
608
- }
609
- const _await$prompts2 = await prompts__default["default"]({
610
- type: 'text',
611
- name: 'confirmation',
612
- message: _filterInstanceProperty__default["default"](_context5 = ["You are about to create a new Custom Application in the \"".concat(chalk__default["default"].green(organizationName), "\" organization. Are you sure you want to proceed?"), options.dryRun && chalk__default["default"].gray('Using "--dry-run", no data will be created.')]).call(_context5, Boolean).join('\n'),
613
- initial: 'yes'
614
- }),
615
- confirmation = _await$prompts2.confirmation;
616
- if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
617
- console.log(chalk__default["default"].red('Aborted.'));
618
- return;
619
- }
620
- const data = omit__default["default"](localCustomEntityData, ['id']);
621
- if (options.dryRun) {
622
- console.log();
623
- console.log("The following payload would be used to create a new Custom Application.");
624
- console.log();
625
- console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
626
- return;
627
- }
628
- const createdCustomApplication = await graphqlRequests.createCustomApplication({
629
- mcApiUrl,
630
- organizationId,
631
- data,
632
- applicationIdentifier
633
- });
634
-
635
- // This check is technically not necessary, as the `graphql-request` client
636
- // throws an error in case of GraphQL errors.
637
- // However, the generated TypeScript data related to the GraphQL query has the
638
- // field typed as optional, thus having an extra check for type correctness.
639
- if (!createdCustomApplication) {
640
- throw new Error('Failed to create the Custom Application.');
641
- }
642
- const customAppLink = getMcUrlLink({
643
- mcApiUrl,
644
- organizationId,
645
- customEntityId: createdCustomApplication.id
646
- });
647
- console.log(chalk__default["default"].green("Custom Application created.\nPlease update the \"env.production.applicationId\" field in your local Custom Application config file with the following value: \"".concat(chalk__default["default"].green(createdCustomApplication.id), "\".")));
648
- console.log("You can inspect the Custom Application data in the Merchant Center at \"".concat(chalk__default["default"].gray(customAppLink), "\"."));
649
- return;
553
+ if (!createdCustomApplication) {
554
+ throw new Error('Failed to create the Custom Application.');
650
555
  }
651
556
  const customAppLink = getMcUrlLink({
652
557
  mcApiUrl,
653
- organizationId: fetchedCustomApplication.organizationId,
654
- customEntityId: fetchedCustomApplication.application.id
655
- });
656
- const configDiff = getCustomApplicationConfigDiff(fetchedCustomApplication.application, localCustomEntityData);
657
- if (!configDiff) {
658
- console.log(chalk__default["default"].green("Custom Application up-to-date."));
659
- console.log("You can inspect the Custom Application data in the Merchant Center at \"".concat(chalk__default["default"].gray(customAppLink), "\"."));
660
- return;
661
- }
662
- console.log('Changes detected:');
663
- console.log(configDiff);
664
- console.log();
665
- const _await$prompts3 = await prompts__default["default"]({
666
- type: 'text',
667
- name: 'confirmation',
668
- message: _filterInstanceProperty__default["default"](_context6 = ["You are about to update the Custom Application \"".concat(chalk__default["default"].green(localCustomEntityData.entryPointUriPath), "\" with the changes above. Are you sure you want to proceed?"), options.dryRun && chalk__default["default"].gray('Using "--dry-run", no data will be updated.')]).call(_context6, Boolean).join('\n'),
669
- initial: 'yes'
670
- }),
671
- confirmation = _await$prompts3.confirmation;
672
- if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
673
- console.log(chalk__default["default"].red('Aborted.'));
674
- return;
675
- }
558
+ organizationId,
559
+ customEntityId: createdCustomApplication.id
560
+ });
561
+ console.log(chalk__default["default"].green('Custom Application created successfully.'));
562
+ console.log(`ID: ${chalk__default["default"].cyan(createdCustomApplication.id)}`);
563
+ console.log(`Please update the "env.production.applicationId" field in your local Custom Application config file with the ID above.`);
564
+ console.log(`URL: ${chalk__default["default"].gray(customAppLink)}`);
565
+ return createdCustomApplication.id;
566
+ }
567
+ async function performUpdateCustomApplication(_ref3) {
568
+ let mcApiUrl = _ref3.mcApiUrl,
569
+ organizationId = _ref3.organizationId,
570
+ applicationId = _ref3.applicationId,
571
+ localCustomEntityData = _ref3.localCustomEntityData,
572
+ applicationIdentifier = _ref3.applicationIdentifier,
573
+ dryRun = _ref3.dryRun;
676
574
  const data = omit__default["default"](localCustomEntityData, ['id']);
677
- if (options.dryRun) {
678
- console.log();
679
- console.log("The following payload would be used to update the Custom Application \"".concat(chalk__default["default"].green(data.entryPointUriPath), "\"."));
575
+ if (dryRun) {
680
576
  console.log();
577
+ console.log(`Dry run - would update Custom Application "${chalk__default["default"].green(data.entryPointUriPath)}" with:`);
681
578
  console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
682
579
  return;
683
580
  }
581
+ console.log('Updating Custom Application...');
684
582
  await graphqlRequests.updateCustomApplication({
685
583
  mcApiUrl,
686
- organizationId: fetchedCustomApplication.organizationId,
687
- data: omit__default["default"](localCustomEntityData, ['id']),
688
- applicationId: fetchedCustomApplication.application.id,
584
+ organizationId,
585
+ data,
586
+ applicationId,
689
587
  applicationIdentifier
690
588
  });
691
- console.log(chalk__default["default"].green("Custom Application updated."));
692
- console.log("You can inspect the Custom Application data in the Merchant Center at \"".concat(chalk__default["default"].gray(customAppLink), "\"."));
589
+ const customAppLink = getMcUrlLink({
590
+ mcApiUrl,
591
+ organizationId,
592
+ customEntityId: applicationId
593
+ });
594
+ console.log(chalk__default["default"].green('Custom Application updated successfully.'));
595
+ console.log(`URL: ${chalk__default["default"].gray(customAppLink)}`);
693
596
  }
694
- async function createOrUpdateCustomView(_ref4) {
695
- var _fetchedCustomView$cu, _context9, _fetchedCustomView$cu2;
597
+ async function performCreateCustomView(_ref4) {
696
598
  let mcApiUrl = _ref4.mcApiUrl,
599
+ organizationId = _ref4.organizationId,
600
+ organizationName = _ref4.organizationName,
697
601
  localCustomEntityData = _ref4.localCustomEntityData,
698
- customViewId = _ref4.customViewId,
699
- options = _ref4.options,
700
- applicationIdentifier = _ref4.applicationIdentifier;
701
- const fetchedCustomView = await graphqlRequests.fetchCustomView({
602
+ applicationIdentifier = _ref4.applicationIdentifier,
603
+ dryRun = _ref4.dryRun;
604
+ console.log(`Creating Custom View in organization "${chalk__default["default"].green(organizationName)}"...`);
605
+ const data = omit__default["default"](localCustomEntityData, ['id']);
606
+ if (dryRun) {
607
+ console.log();
608
+ console.log('Dry run - would create Custom View with:');
609
+ console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
610
+ return null;
611
+ }
612
+ const createdCustomView = await graphqlRequests.createCustomView({
702
613
  mcApiUrl,
703
- customViewId,
614
+ organizationId,
615
+ data,
704
616
  applicationIdentifier
705
617
  });
706
- if (!fetchedCustomView) {
707
- var _context8;
708
- const userOrganizations = await graphqlRequests.fetchUserOrganizations({
709
- mcApiUrl,
710
- customViewId,
711
- applicationIdentifier
712
- });
713
- let organizationId, organizationName;
714
- if (userOrganizations.total === 0) {
715
- throw new Error("It seems you are not an admin of any Organization. Please make sure to be part of the Administrators team of the Organization you want the Custom View to be configured to.");
716
- }
717
- if (userOrganizations.total === 1) {
718
- const _userOrganizations$re2 = _slicedToArray(userOrganizations.results, 1),
719
- organization = _userOrganizations$re2[0];
720
- organizationId = organization.id;
721
- organizationName = organization.name;
722
- } else {
723
- var _context7;
724
- const organizationChoices = _mapInstanceProperty__default["default"](_context7 = userOrganizations.results).call(_context7, organization => ({
725
- title: organization.name,
726
- value: organization.id
727
- }));
728
- const _await$prompts4 = await prompts__default["default"]({
729
- type: 'select',
730
- name: 'organizationId',
731
- message: 'Select an Organization',
732
- choices: organizationChoices,
733
- initial: 0
734
- }),
735
- selectedOrganizationId = _await$prompts4.organizationId;
736
- if (!selectedOrganizationId) {
737
- throw new Error("No Organization selected, aborting.");
738
- }
739
- organizationId = selectedOrganizationId;
740
- organizationName = _findInstanceProperty__default["default"](organizationChoices).call(organizationChoices, _ref5 => {
741
- let value = _ref5.value;
742
- return value === organizationId;
743
- }).title;
744
- }
745
- const _await$prompts5 = await prompts__default["default"]({
746
- type: 'text',
747
- name: 'confirmation',
748
- message: _filterInstanceProperty__default["default"](_context8 = ["You are about to create a new Custom View in the \"".concat(chalk__default["default"].green(organizationName), "\" organization. Are you sure you want to proceed?"), options.dryRun && chalk__default["default"].gray('Using "--dry-run", no data will be created.')]).call(_context8, Boolean).join('\n'),
749
- initial: 'yes'
750
- }),
751
- confirmation = _await$prompts5.confirmation;
752
- if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
753
- console.log(chalk__default["default"].red('Aborted.'));
754
- return;
755
- }
756
- const data = omit__default["default"](localCustomEntityData, ['id']);
757
- if (options.dryRun) {
758
- console.log();
759
- console.log("The following payload would be used to create a new Custom View.");
760
- console.log();
761
- console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
762
- return;
763
- }
764
- const createdCustomView = await graphqlRequests.createCustomView({
765
- mcApiUrl,
766
- organizationId,
767
- data,
768
- applicationIdentifier
769
- });
770
-
771
- // This check is technically not necessary, as the `graphql-request` client
772
- // throws an error in case of GraphQL errors.
773
- // However, the generated TypeScript data related to the GraphQL query has the
774
- // field typed as optional, thus having an extra check for type correctness.
775
- if (!createdCustomView) {
776
- throw new Error('Failed to create the Custom View.');
777
- }
778
- const customViewLink = getMcUrlLink({
779
- mcApiUrl,
780
- organizationId,
781
- customEntityId: createdCustomView.id,
782
- isCustomView: true
783
- });
784
- console.log(chalk__default["default"].green("Custom View created.\nPlease update the \"env.production.customViewId\" field in your local Custom View config file with the following value: \"".concat(chalk__default["default"].green(createdCustomView.id), "\".")));
785
- console.log("You can inspect the Custom View data in the Merchant Center at \"".concat(chalk__default["default"].gray(customViewLink), "\"."));
786
- return;
618
+ if (!createdCustomView) {
619
+ throw new Error('Failed to create the Custom View.');
787
620
  }
788
621
  const customViewLink = getMcUrlLink({
789
622
  mcApiUrl,
790
- organizationId: fetchedCustomView.organizationId,
791
- customEntityId: (fetchedCustomView === null || fetchedCustomView === void 0 || (_fetchedCustomView$cu = fetchedCustomView.customView) === null || _fetchedCustomView$cu === void 0 ? void 0 : _fetchedCustomView$cu.id) || '',
623
+ organizationId,
624
+ customEntityId: createdCustomView.id,
792
625
  isCustomView: true
793
626
  });
794
- const configDiff = getCustomViewConfigDiff(fetchedCustomView.customView, localCustomEntityData);
795
- if (!configDiff) {
796
- console.log(chalk__default["default"].green("Custom View up-to-date."));
797
- console.log("You can inspect the Custom View data in the Merchant Center at \"".concat(chalk__default["default"].gray(customViewLink), "\"."));
798
- return;
799
- }
800
- console.log('Changes detected:');
801
- console.log(configDiff);
802
- console.log();
803
- const _await$prompts6 = await prompts__default["default"]({
804
- type: 'text',
805
- name: 'confirmation',
806
- message: _filterInstanceProperty__default["default"](_context9 = ["You are about to update the Custom View \"".concat(chalk__default["default"].green(localCustomEntityData.defaultLabel), "\" with the changes above. Are you sure you want to proceed?"), options.dryRun && chalk__default["default"].gray('Using "--dry-run", no data will be updated.')]).call(_context9, Boolean).join('\n'),
807
- initial: 'yes'
808
- }),
809
- confirmation = _await$prompts6.confirmation;
810
- if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
811
- console.log(chalk__default["default"].red('Aborted.'));
812
- return;
813
- }
627
+ console.log(chalk__default["default"].green('Custom View created successfully.'));
628
+ console.log(`ID: ${chalk__default["default"].cyan(createdCustomView.id)}`);
629
+ console.log(`Please update the "env.production.customViewId" field in your local Custom View config file with the ID above.`);
630
+ console.log(`URL: ${chalk__default["default"].gray(customViewLink)}`);
631
+ return createdCustomView.id;
632
+ }
633
+ async function performUpdateCustomView(_ref5) {
634
+ let mcApiUrl = _ref5.mcApiUrl,
635
+ organizationId = _ref5.organizationId,
636
+ customViewId = _ref5.customViewId,
637
+ localCustomEntityData = _ref5.localCustomEntityData,
638
+ applicationIdentifier = _ref5.applicationIdentifier,
639
+ dryRun = _ref5.dryRun;
814
640
  const data = omit__default["default"](localCustomEntityData, ['id']);
815
- if (options.dryRun) {
816
- console.log();
817
- console.log("The following payload would be used to update the Custom View \"".concat(chalk__default["default"].green(data.defaultLabel), "\"."));
641
+ if (dryRun) {
818
642
  console.log();
643
+ console.log(`Dry run - would update Custom View "${chalk__default["default"].green(data.defaultLabel)}" with:`);
819
644
  console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
820
645
  return;
821
646
  }
647
+ console.log('Updating Custom View...');
822
648
  await graphqlRequests.updateCustomView({
823
649
  mcApiUrl,
824
- organizationId: fetchedCustomView.organizationId,
825
- data: omit__default["default"](localCustomEntityData, ['id']),
826
- customViewId: (fetchedCustomView === null || fetchedCustomView === void 0 || (_fetchedCustomView$cu2 = fetchedCustomView.customView) === null || _fetchedCustomView$cu2 === void 0 ? void 0 : _fetchedCustomView$cu2.id) || '',
650
+ organizationId,
651
+ data,
652
+ customViewId,
827
653
  applicationIdentifier
828
654
  });
829
- console.log(chalk__default["default"].green("Custom View updated."));
830
- console.log("You can inspect the Custom View data in the Merchant Center at \"".concat(chalk__default["default"].gray(customViewLink), "\"."));
655
+ const customViewLink = getMcUrlLink({
656
+ mcApiUrl,
657
+ organizationId,
658
+ customEntityId: customViewId,
659
+ isCustomView: true
660
+ });
661
+ console.log(chalk__default["default"].green('Custom View updated successfully.'));
662
+ console.log(`URL: ${chalk__default["default"].gray(customViewLink)}`);
831
663
  }
832
- async function run(options) {
833
- const applicationConfig$1 = await applicationConfig.processConfig();
834
- const localCustomEntityData = applicationConfig$1.data;
835
- const _applicationConfig$en = applicationConfig$1.env,
836
- mcApiUrl = _applicationConfig$en.mcApiUrl,
837
- applicationIdentifier = _applicationConfig$en.applicationIdentifier,
838
- customViewId = _applicationConfig$en.customViewId;
839
- console.log("Using Merchant Center environment \"".concat(chalk__default["default"].green(mcApiUrl), "\"."));
840
- console.log();
841
- const isSessionValid = credentialsStorage.isSessionValid(mcApiUrl);
842
- if (!isSessionValid) {
843
- throw new Error("You don't have a valid session. Please, run the \"mc-scripts login\" command to authenticate yourself.");
664
+ async function checkCustomApplicationStatus(_ref6) {
665
+ let mcApiUrl = _ref6.mcApiUrl,
666
+ entryPointUriPath = _ref6.entryPointUriPath,
667
+ applicationIdentifier = _ref6.applicationIdentifier,
668
+ localCustomEntityData = _ref6.localCustomEntityData;
669
+ const fetchedCustomApplication = await graphqlRequests.fetchCustomApplication({
670
+ mcApiUrl,
671
+ entryPointUriPath,
672
+ applicationIdentifier
673
+ });
674
+ if (!fetchedCustomApplication) {
675
+ return {
676
+ exists: false
677
+ };
844
678
  }
845
- if (isCustomViewData(localCustomEntityData)) {
846
- createOrUpdateCustomView({
847
- mcApiUrl,
848
- localCustomEntityData,
849
- applicationIdentifier,
850
- customViewId: customViewId || localCustomEntityData.id,
851
- options
852
- });
853
- } else {
854
- createOrUpdateCustomApplication({
855
- mcApiUrl,
856
- localCustomEntityData,
857
- applicationIdentifier,
858
- options
859
- });
679
+ const configDiff = getCustomApplicationConfigDiff(fetchedCustomApplication.application, localCustomEntityData);
680
+ const customAppLink = getMcUrlLink({
681
+ mcApiUrl,
682
+ organizationId: fetchedCustomApplication.organizationId,
683
+ customEntityId: fetchedCustomApplication.application.id
684
+ });
685
+ return {
686
+ exists: true,
687
+ organizationId: fetchedCustomApplication.organizationId,
688
+ applicationId: fetchedCustomApplication.application.id,
689
+ configDiff,
690
+ link: customAppLink
691
+ };
692
+ }
693
+ async function checkCustomViewStatus(_ref7) {
694
+ let mcApiUrl = _ref7.mcApiUrl,
695
+ customViewId = _ref7.customViewId,
696
+ applicationIdentifier = _ref7.applicationIdentifier,
697
+ localCustomEntityData = _ref7.localCustomEntityData;
698
+ const fetchedCustomView = await graphqlRequests.fetchCustomView({
699
+ mcApiUrl,
700
+ customViewId,
701
+ applicationIdentifier
702
+ });
703
+ if (!fetchedCustomView) {
704
+ return {
705
+ exists: false
706
+ };
860
707
  }
708
+ const configDiff = getCustomViewConfigDiff(fetchedCustomView.customView, localCustomEntityData);
709
+ const customViewLink = getMcUrlLink({
710
+ mcApiUrl,
711
+ organizationId: fetchedCustomView.organizationId,
712
+ customEntityId: fetchedCustomView?.customView?.id || '',
713
+ isCustomView: true
714
+ });
715
+ return {
716
+ exists: true,
717
+ organizationId: fetchedCustomView.organizationId,
718
+ customViewId: fetchedCustomView?.customView?.id || '',
719
+ configDiff,
720
+ link: customViewLink
721
+ };
861
722
  }
862
723
 
863
- exports["default"] = run;
724
+ exports.checkCustomApplicationStatus = checkCustomApplicationStatus;
725
+ exports.checkCustomViewStatus = checkCustomViewStatus;
726
+ exports.isCustomViewData = isCustomViewData;
727
+ exports.performCreateCustomApplication = performCreateCustomApplication;
728
+ exports.performCreateCustomView = performCreateCustomView;
729
+ exports.performUpdateCustomApplication = performUpdateCustomApplication;
730
+ exports.performUpdateCustomView = performUpdateCustomView;