@commercetools-frontend/mc-scripts 22.2.1 → 22.3.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.
Files changed (62) hide show
  1. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +51 -41
  2. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +51 -41
  3. package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +51 -41
  4. package/dist/{build-72d9896f.esm.js → build-7993cea9.esm.js} +22 -31
  5. package/dist/{build-0ef080b9.cjs.prod.js → build-8c9e8a8b.cjs.prod.js} +22 -31
  6. package/dist/{build-4773d61a.cjs.dev.js → build-94dc48cd.cjs.dev.js} +22 -31
  7. package/dist/{build-vite-2dc2b366.cjs.prod.js → build-vite-1ba28dd8.cjs.prod.js} +18 -19
  8. package/dist/{build-vite-290aaf04.esm.js → build-vite-9de4820c.esm.js} +18 -19
  9. package/dist/{build-vite-b5c7ac91.cjs.dev.js → build-vite-e7a6315c.cjs.dev.js} +18 -19
  10. package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +2 -3
  11. package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +2 -3
  12. package/dist/commercetools-frontend-mc-scripts.esm.js +2 -3
  13. package/dist/{compile-html-41195e35.cjs.dev.js → compile-html-079067bd.cjs.prod.js} +1 -7
  14. package/dist/{compile-html-5abd78aa.cjs.prod.js → compile-html-3ff2fed0.cjs.dev.js} +1 -7
  15. package/dist/{compile-html-f9de842c.esm.js → compile-html-606b302e.esm.js} +1 -7
  16. package/dist/{config-sync-54299066.esm.js → config-sync-15f35d05.esm.js} +83 -194
  17. package/dist/{config-sync-c914ca7a.cjs.dev.js → config-sync-782033fb.cjs.dev.js} +83 -194
  18. package/dist/{config-sync-8e8e18a9.cjs.prod.js → config-sync-8f0326af.cjs.prod.js} +81 -193
  19. package/dist/{create-postcss-config-6277233e.cjs.prod.js → create-postcss-config-254aa0d9.cjs.prod.js} +9 -13
  20. package/dist/{create-postcss-config-a0659cf5.cjs.dev.js → create-postcss-config-aaff8b1e.cjs.dev.js} +9 -13
  21. package/dist/{create-postcss-config-f39f54b5.esm.js → create-postcss-config-e44b5231.esm.js} +9 -13
  22. package/dist/{create-webpack-config-for-development-9539f804.esm.js → create-webpack-config-for-development-12d3233c.esm.js} +46 -37
  23. package/dist/{create-webpack-config-for-development-9aa85081.cjs.dev.js → create-webpack-config-for-development-30914bb4.cjs.dev.js} +46 -37
  24. package/dist/{create-webpack-config-for-development-629a8982.cjs.prod.js → create-webpack-config-for-development-c90350a7.cjs.prod.js} +46 -37
  25. package/dist/{create-webpack-config-for-production-0fac47e1.cjs.dev.js → create-webpack-config-for-production-410e4748.cjs.dev.js} +37 -32
  26. package/dist/{create-webpack-config-for-production-4476fc5f.esm.js → create-webpack-config-for-production-487aa17d.esm.js} +37 -32
  27. package/dist/{create-webpack-config-for-production-84e2db7d.cjs.prod.js → create-webpack-config-for-production-48ef18fc.cjs.prod.js} +37 -32
  28. package/dist/{credentials-storage-da0754c9.cjs.dev.js → credentials-storage-935d3ca1.cjs.prod.js} +3 -15
  29. package/dist/{credentials-storage-fc0c59c3.cjs.prod.js → credentials-storage-a0ea2ecc.cjs.dev.js} +3 -15
  30. package/dist/{credentials-storage-5939dd35.esm.js → credentials-storage-beb854dd.esm.js} +3 -15
  31. package/dist/declarations/src/generated/settings.d.ts +90 -1172
  32. package/dist/{has-jsx-runtime-0b03b72e.cjs.prod.js → has-jsx-runtime-aa5d21ee.cjs.dev.js} +0 -2
  33. package/dist/{has-jsx-runtime-3d4bb633.cjs.dev.js → has-jsx-runtime-c3202df5.cjs.prod.js} +0 -2
  34. package/dist/{has-jsx-runtime-8314226e.esm.js → has-jsx-runtime-e3ecb09b.esm.js} +0 -2
  35. package/dist/{login-9f821336.cjs.dev.js → login-7b8b5027.cjs.prod.js} +12 -23
  36. package/dist/{login-d1c2268a.esm.js → login-c806579c.esm.js} +12 -23
  37. package/dist/{login-f747390f.cjs.prod.js → login-ceb541f1.cjs.dev.js} +12 -23
  38. package/dist/{package-83202e32.cjs.prod.js → package-4276a7a9.cjs.prod.js} +15 -13
  39. package/dist/{package-cc5b8665.cjs.dev.js → package-70894b4c.cjs.dev.js} +15 -13
  40. package/dist/{package-e6713e98.esm.js → package-834453bb.esm.js} +15 -13
  41. package/dist/{paths-284c77fb.cjs.prod.js → paths-854af5ef.cjs.prod.js} +8 -12
  42. package/dist/{paths-db35ac0f.cjs.dev.js → paths-d1febc82.cjs.dev.js} +8 -12
  43. package/dist/{paths-55c5d5a2.esm.js → paths-ded20ae1.esm.js} +8 -12
  44. package/dist/{serve-b8063204.cjs.dev.js → serve-12571b42.cjs.prod.js} +1 -2
  45. package/dist/{serve-660e2ee0.esm.js → serve-65b5a149.esm.js} +1 -2
  46. package/dist/{serve-41077dad.cjs.prod.js → serve-7339c495.cjs.dev.js} +1 -2
  47. package/dist/{start-33fd6d70.cjs.dev.js → start-03683a4d.cjs.dev.js} +26 -34
  48. package/dist/{start-f93c62f9.cjs.prod.js → start-763b3477.cjs.prod.js} +26 -34
  49. package/dist/{start-93205b87.esm.js → start-d3e82b50.esm.js} +26 -34
  50. package/dist/{start-vite-8f03b0df.cjs.dev.js → start-vite-3966d625.cjs.dev.js} +18 -17
  51. package/dist/{start-vite-324af14d.cjs.prod.js → start-vite-5c78605b.cjs.prod.js} +18 -17
  52. package/dist/{start-vite-7d10ae71.esm.js → start-vite-cf0213a1.esm.js} +18 -17
  53. package/dist/{vite-plugin-svgr-f17db78a.esm.js → vite-plugin-svgr-5c953fe7.esm.js} +1 -6
  54. package/dist/{vite-plugin-svgr-fdb37ccf.cjs.dev.js → vite-plugin-svgr-5eb1c511.cjs.dev.js} +1 -6
  55. package/dist/{vite-plugin-svgr-9a4e7f77.cjs.prod.js → vite-plugin-svgr-a732f8df.cjs.prod.js} +1 -6
  56. package/package.json +31 -17
  57. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +2 -2
  58. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +2 -2
  59. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +2 -2
  60. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +6 -6
  61. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +6 -6
  62. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +6 -6
@@ -10,7 +10,7 @@ var chalk = require('chalk');
10
10
  var omit = require('lodash/omit');
11
11
  var prompts = require('prompts');
12
12
  var applicationConfig = require('@commercetools-frontend/application-config');
13
- var credentialsStorage$2 = require('./credentials-storage-fc0c59c3.cjs.prod.js');
13
+ var credentialsStorage$2 = require('./credentials-storage-935d3ca1.cjs.prod.js');
14
14
  var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
15
15
  var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
16
16
  var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
@@ -27,7 +27,7 @@ var graphql = require('graphql');
27
27
  var graphqlRequest = require('graphql-request');
28
28
  var constants = require('@commercetools-frontend/constants');
29
29
  require('@commercetools/http-user-agent');
30
- require('./package-83202e32.cjs.prod.js');
30
+ require('./package-4276a7a9.cjs.prod.js');
31
31
  require('@babel/runtime-corejs3/helpers/classCallCheck');
32
32
  require('@babel/runtime-corejs3/helpers/createClass');
33
33
  require('@babel/runtime-corejs3/core-js-stable/date/now');
@@ -58,59 +58,46 @@ var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
58
58
  var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
59
59
 
60
60
  function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
61
-
62
61
  function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context20, _context21; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context20 = ownKeys$1(Object(source), !0)).call(_context20, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context21 = ownKeys$1(Object(source))).call(_context21, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
63
-
64
62
  const red = str => {
65
63
  return chalk__default["default"].red(str);
66
64
  };
67
-
68
65
  const green = str => {
69
66
  return chalk__default["default"].green(str);
70
- }; // Two spaces are used for indentation.
71
-
67
+ };
72
68
 
69
+ // Two spaces are used for indentation.
73
70
  const indent = indentLevel => {
74
71
  var _context;
75
-
76
72
  return _repeatInstanceProperty__default["default"](_context = ' ').call(_context, indentLevel);
77
73
  };
78
-
79
74
  const getStringDiff = _ref => {
80
75
  let previousValue = _ref.previousValue,
81
- nextValue = _ref.nextValue,
82
- label = _ref.label,
83
- _ref$indentLevel = _ref.indentLevel,
84
- indentLevel = _ref$indentLevel === void 0 ? 0 : _ref$indentLevel;
85
-
76
+ nextValue = _ref.nextValue,
77
+ label = _ref.label,
78
+ _ref$indentLevel = _ref.indentLevel,
79
+ indentLevel = _ref$indentLevel === void 0 ? 0 : _ref$indentLevel;
86
80
  if (!previousValue && nextValue) {
87
81
  var _context2, _context3;
88
-
89
82
  return _concatInstanceProperty__default["default"](_context2 = _concatInstanceProperty__default["default"](_context3 = "".concat(indent(indentLevel))).call(_context3, label, " added: ")).call(_context2, green(nextValue));
90
83
  }
91
-
92
84
  if (previousValue && !nextValue) {
93
85
  var _context4, _context5;
94
-
95
86
  return _concatInstanceProperty__default["default"](_context4 = _concatInstanceProperty__default["default"](_context5 = "".concat(indent(indentLevel))).call(_context5, label, " removed: ")).call(_context4, red(previousValue));
96
87
  }
97
-
98
88
  if (previousValue && nextValue && previousValue !== nextValue) {
99
89
  var _context6, _context7, _context8;
100
-
101
90
  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));
102
91
  }
103
-
104
92
  return null;
105
93
  };
106
-
107
94
  // NOTE: this assumes that the array values are scalar values (not objects).
108
95
  const getArrayDiff = _ref2 => {
109
96
  let previousValue = _ref2.previousValue,
110
- nextValue = _ref2.nextValue,
111
- label = _ref2.label,
112
- _ref2$indentLevel = _ref2.indentLevel,
113
- indentLevel = _ref2$indentLevel === void 0 ? 0 : _ref2$indentLevel;
97
+ nextValue = _ref2.nextValue,
98
+ label = _ref2.label,
99
+ _ref2$indentLevel = _ref2.indentLevel,
100
+ indentLevel = _ref2$indentLevel === void 0 ? 0 : _ref2$indentLevel;
114
101
  const oldArraySet = new _Set__default["default"](previousValue);
115
102
  const arrayDiff = [];
116
103
  nextValue === null || nextValue === void 0 ? void 0 : _forEachInstanceProperty__default["default"](nextValue).call(nextValue, item => {
@@ -124,7 +111,6 @@ const getArrayDiff = _ref2 => {
124
111
  }));
125
112
  }
126
113
  });
127
-
128
114
  _forEachInstanceProperty__default["default"](oldArraySet).call(oldArraySet, item => {
129
115
  arrayDiff.push(getStringDiff({
130
116
  previousValue: item,
@@ -132,37 +118,31 @@ const getArrayDiff = _ref2 => {
132
118
  indentLevel
133
119
  }));
134
120
  });
135
-
136
121
  return arrayDiff.join('\n');
137
122
  };
138
-
139
123
  const getPermissionsDiff = _ref3 => {
140
124
  var _context11;
141
-
142
125
  let previousValue = _ref3.previousValue,
143
- nextValue = _ref3.nextValue;
126
+ nextValue = _ref3.nextValue;
144
127
  const permissionDiff = ['permissions changed'];
145
-
146
128
  const mappedOldPermissions = _reduceInstanceProperty__default["default"](previousValue).call(previousValue, (previousPermission, _ref4) => {
147
129
  let name = _ref4.name,
148
- oAuthScopes = _ref4.oAuthScopes;
130
+ oAuthScopes = _ref4.oAuthScopes;
149
131
  return _objectSpread$1(_objectSpread$1({}, previousPermission), {}, {
150
132
  [name]: oAuthScopes
151
133
  });
152
134
  }, {});
153
-
154
135
  const indentLevel = 1;
155
-
156
136
  _forEachInstanceProperty__default["default"](nextValue).call(nextValue, newPermission => {
157
137
  var _context9;
158
-
159
- const currentDiff = [_concatInstanceProperty__default["default"](_context9 = "".concat(indent(indentLevel), "\"")).call(_context9, newPermission.name, "\" changed")]; // if the permission name is not in the old config, it means it is a new addition.
160
-
138
+ const currentDiff = [_concatInstanceProperty__default["default"](_context9 = "".concat(indent(indentLevel), "\"")).call(_context9, newPermission.name, "\" changed")];
139
+ // if the permission name is not in the old config, it means it is a new addition.
161
140
  if (!mappedOldPermissions[newPermission.name]) {
162
141
  var _context10;
163
-
164
142
  permissionDiff.push(_concatInstanceProperty__default["default"](_context10 = "".concat(indent(indentLevel), "\"")).call(_context10, green(newPermission.name), "\" was added"));
165
- } // if permission name is in the old config, now we check if there was a change
143
+ }
144
+
145
+ // if permission name is in the old config, now we check if there was a change
166
146
  else {
167
147
  currentDiff.push(getArrayDiff({
168
148
  previousValue: mappedOldPermissions[newPermission.name],
@@ -172,50 +152,40 @@ const getPermissionsDiff = _ref3 => {
172
152
  }));
173
153
  delete mappedOldPermissions[newPermission.name];
174
154
  }
175
-
176
155
  _filterInstanceProperty__default["default"](currentDiff).call(currentDiff, Boolean).length > 1 && permissionDiff.push(currentDiff.join('\n'));
177
- }); // if there are old permissions left, it means they were deleted in the new Permissions.
178
-
156
+ });
179
157
 
158
+ // if there are old permissions left, it means they were deleted in the new Permissions.
180
159
  _forEachInstanceProperty__default["default"](_context11 = _Object$keys__default["default"](mappedOldPermissions)).call(_context11, oldPermissionName => {
181
160
  var _context12;
182
-
183
161
  permissionDiff.push(_concatInstanceProperty__default["default"](_context12 = "".concat(indent(indentLevel), "\"")).call(_context12, red(oldPermissionName), "\" was removed"));
184
162
  });
185
-
186
163
  if (permissionDiff.length > 1) return permissionDiff.join('\n');
187
164
  return null;
188
165
  };
189
-
190
166
  const getLabelAllLocalesDiff = _ref5 => {
191
167
  var _context16;
192
-
193
168
  let _ref5$previousValue = _ref5.previousValue,
194
- previousValue = _ref5$previousValue === void 0 ? [] : _ref5$previousValue,
195
- _ref5$nextValue = _ref5.nextValue,
196
- nextValue = _ref5$nextValue === void 0 ? [] : _ref5$nextValue,
197
- _ref5$indentLevel = _ref5.indentLevel,
198
- indentLevel = _ref5$indentLevel === void 0 ? 0 : _ref5$indentLevel;
169
+ previousValue = _ref5$previousValue === void 0 ? [] : _ref5$previousValue,
170
+ _ref5$nextValue = _ref5.nextValue,
171
+ nextValue = _ref5$nextValue === void 0 ? [] : _ref5$nextValue,
172
+ _ref5$indentLevel = _ref5.indentLevel,
173
+ indentLevel = _ref5$indentLevel === void 0 ? 0 : _ref5$indentLevel;
199
174
  const labelAllLocalesDiff = ["".concat(indent(indentLevel - 1), "labelAllLocales changed")];
200
-
201
175
  const mappedOldLabelAllLocales = _reduceInstanceProperty__default["default"](previousValue).call(previousValue, (previousLabelAllLocale, _ref6) => {
202
176
  let locale = _ref6.locale,
203
- value = _ref6.value;
177
+ value = _ref6.value;
204
178
  return _objectSpread$1(_objectSpread$1({}, previousLabelAllLocale), {}, {
205
179
  [locale]: value
206
180
  });
207
181
  }, {});
208
-
209
182
  _forEachInstanceProperty__default["default"](nextValue).call(nextValue, newLabelAllLocale => {
210
183
  if (newLabelAllLocale.locale in mappedOldLabelAllLocales) {
211
184
  const oldLocaleValue = mappedOldLabelAllLocales[newLabelAllLocale.locale];
212
-
213
185
  if (oldLocaleValue !== newLabelAllLocale.value) {
214
186
  var _context13, _context14, _context15;
215
-
216
187
  labelAllLocalesDiff.push(_concatInstanceProperty__default["default"](_context13 = _concatInstanceProperty__default["default"](_context14 = _concatInstanceProperty__default["default"](_context15 = "".concat(indent(indentLevel), "locale \"")).call(_context15, newLabelAllLocale.locale, "\" changed: ")).call(_context14, red(oldLocaleValue), " => ")).call(_context13, green(newLabelAllLocale.value)));
217
188
  }
218
-
219
189
  delete mappedOldLabelAllLocales[newLabelAllLocale.locale];
220
190
  } else {
221
191
  const localeDiff = getStringDiff({
@@ -223,32 +193,27 @@ const getLabelAllLocalesDiff = _ref5 => {
223
193
  label: 'locale',
224
194
  indentLevel
225
195
  });
226
-
227
196
  if (localeDiff) {
228
197
  labelAllLocalesDiff.push(localeDiff);
229
198
  }
230
199
  }
231
200
  });
232
-
233
201
  _forEachInstanceProperty__default["default"](_context16 = _Object$keys__default["default"](mappedOldLabelAllLocales)).call(_context16, key => {
234
202
  const localeDiff = getStringDiff({
235
203
  previousValue: key,
236
204
  label: 'locale',
237
205
  indentLevel
238
206
  });
239
-
240
207
  if (localeDiff) {
241
208
  labelAllLocalesDiff.push(localeDiff);
242
209
  }
243
210
  });
244
-
245
211
  if (labelAllLocalesDiff.length > 1) return labelAllLocalesDiff.join('\n');
246
212
  return null;
247
213
  };
248
-
249
214
  const getMainMenuLinkDiff = _ref7 => {
250
215
  let previousValue = _ref7.previousValue,
251
- nextValue = _ref7.nextValue;
216
+ nextValue = _ref7.nextValue;
252
217
  const mainMenuLinkDiff = ['mainMenuLink changed'];
253
218
  const menuDiff = getStringDiff({
254
219
  previousValue: previousValue.defaultLabel,
@@ -256,58 +221,44 @@ const getMainMenuLinkDiff = _ref7 => {
256
221
  label: 'defaultLabel',
257
222
  indentLevel: 1
258
223
  });
259
-
260
224
  if (menuDiff) {
261
225
  mainMenuLinkDiff.push(menuDiff);
262
226
  }
263
-
264
227
  const mainMenuLinkPermissionsDiff = getArrayDiff({
265
228
  previousValue: previousValue.permissions,
266
229
  nextValue: nextValue.permissions,
267
230
  label: 'applied permission',
268
231
  indentLevel: 2
269
232
  });
270
-
271
233
  if (mainMenuLinkPermissionsDiff.length > 0) {
272
234
  mainMenuLinkDiff.push("".concat(indent(1), "permissions changed"));
273
235
  mainMenuLinkDiff.push(mainMenuLinkPermissionsDiff);
274
236
  }
275
-
276
237
  const menuLabelsDiff = getLabelAllLocalesDiff({
277
238
  previousValue: previousValue.labelAllLocales,
278
239
  nextValue: nextValue.labelAllLocales,
279
240
  indentLevel: 2
280
241
  });
281
-
282
242
  if (menuLabelsDiff) {
283
243
  mainMenuLinkDiff.push(menuLabelsDiff);
284
244
  }
285
-
286
245
  const filteredMainMenuLinkDiff = _filterInstanceProperty__default["default"](mainMenuLinkDiff).call(mainMenuLinkDiff, Boolean);
287
-
288
246
  if (filteredMainMenuLinkDiff.length > 1) return filteredMainMenuLinkDiff.join('\n');
289
247
  return null;
290
248
  };
291
-
292
249
  const getSubmenuLinksDiff = _ref8 => {
293
250
  var _context19;
294
-
295
251
  let previousValue = _ref8.previousValue,
296
- nextValue = _ref8.nextValue;
252
+ nextValue = _ref8.nextValue;
297
253
  const submenuLinksDiff = ['submenuLink changed'];
298
-
299
254
  const mappedSubmenuLinks = _reduceInstanceProperty__default["default"](previousValue).call(previousValue, (previousSubmenuLink, currentSubmenuLink) => _objectSpread$1(_objectSpread$1({}, previousSubmenuLink), {}, {
300
255
  [currentSubmenuLink.uriPath]: currentSubmenuLink
301
256
  }), {});
302
-
303
257
  _forEachInstanceProperty__default["default"](nextValue).call(nextValue, newSubmenuLink => {
304
258
  const oldSubMenuLink = mappedSubmenuLinks[newSubmenuLink.uriPath];
305
-
306
259
  if (newSubmenuLink.uriPath in mappedSubmenuLinks) {
307
260
  var _context17, _context18;
308
-
309
261
  const submenuLinkDiff = [_concatInstanceProperty__default["default"](_context17 = "".concat(indent(1), "menu link \"")).call(_context17, newSubmenuLink.uriPath, "\" changed")];
310
-
311
262
  _forEachInstanceProperty__default["default"](_context18 = _Object$keys__default["default"](mappedSubmenuLinks[newSubmenuLink.uriPath])).call(_context18, key => {
312
263
  switch (key) {
313
264
  case 'defaultLabel':
@@ -318,14 +269,11 @@ const getSubmenuLinksDiff = _ref8 => {
318
269
  label: 'defaultLabel',
319
270
  indentLevel: 2
320
271
  });
321
-
322
272
  if (labelDiff) {
323
273
  submenuLinkDiff.push(labelDiff);
324
274
  }
325
-
326
275
  break;
327
276
  }
328
-
329
277
  case 'permissions':
330
278
  {
331
279
  const submenuLinkPermissionsDiff = getArrayDiff({
@@ -334,15 +282,12 @@ const getSubmenuLinksDiff = _ref8 => {
334
282
  label: 'applied permission',
335
283
  indentLevel: 3
336
284
  });
337
-
338
285
  if (submenuLinkPermissionsDiff.length > 0) {
339
286
  submenuLinkDiff.push("".concat(indent(2), "permissions changed"));
340
287
  submenuLinkDiff.push(submenuLinkPermissionsDiff);
341
288
  }
342
-
343
289
  break;
344
290
  }
345
-
346
291
  case 'labelAllLocales':
347
292
  {
348
293
  const labelsDiff = getLabelAllLocalesDiff({
@@ -350,20 +295,15 @@ const getSubmenuLinksDiff = _ref8 => {
350
295
  nextValue: newSubmenuLink.labelAllLocales,
351
296
  indentLevel: 3
352
297
  });
353
-
354
298
  if (labelsDiff) {
355
299
  submenuLinkDiff.push(labelsDiff);
356
300
  }
357
-
358
301
  break;
359
302
  }
360
303
  }
361
304
  });
362
-
363
305
  delete mappedSubmenuLinks[newSubmenuLink.uriPath];
364
-
365
306
  const filteredSubmenuLinksDiff = _filterInstanceProperty__default["default"](submenuLinkDiff).call(submenuLinkDiff, Boolean);
366
-
367
307
  if (filteredSubmenuLinksDiff.length > 1) {
368
308
  submenuLinksDiff.push(filteredSubmenuLinksDiff.join('\n'));
369
309
  }
@@ -373,13 +313,11 @@ const getSubmenuLinksDiff = _ref8 => {
373
313
  label: 'menu link',
374
314
  indentLevel: 1
375
315
  });
376
-
377
316
  if (linksDiff) {
378
317
  submenuLinksDiff.push(linksDiff);
379
318
  }
380
319
  }
381
320
  });
382
-
383
321
  _forEachInstanceProperty__default["default"](_context19 = _Object$keys__default["default"](mappedSubmenuLinks)).call(_context19, key => {
384
322
  const linksDiff = getStringDiff({
385
323
  previousValue: key,
@@ -388,49 +326,46 @@ const getSubmenuLinksDiff = _ref8 => {
388
326
  });
389
327
  if (linksDiff) submenuLinksDiff.push(linksDiff);
390
328
  });
391
-
392
329
  if (submenuLinksDiff.length > 1) return submenuLinksDiff.join('\n');
393
330
  return null;
394
- }; // Compute diff changes of the Custom Application config.
395
- // NOTE: Only known keys are evaluated.
396
-
331
+ };
397
332
 
333
+ // Compute diff changes of the Custom Application config.
334
+ // NOTE: Only known keys are evaluated.
398
335
  const getConfigDiff = (oldConfig, newConfig) => {
399
- const diff = []; // Name
336
+ const diff = [];
400
337
 
338
+ // Name
401
339
  const nameDiff = getStringDiff({
402
340
  previousValue: oldConfig.name,
403
341
  nextValue: newConfig.name,
404
342
  label: 'name'
405
343
  });
406
-
407
344
  if (nameDiff) {
408
345
  diff.push(nameDiff);
409
- } // Description
410
-
346
+ }
411
347
 
348
+ // Description
412
349
  const descriptionDiff = getStringDiff({
413
350
  previousValue: oldConfig.description,
414
351
  nextValue: newConfig.description,
415
352
  label: 'description'
416
353
  });
417
-
418
354
  if (descriptionDiff) {
419
355
  diff.push(descriptionDiff);
420
- } // URL
421
-
356
+ }
422
357
 
358
+ // URL
423
359
  const urlDiff = getStringDiff({
424
360
  previousValue: oldConfig.url,
425
361
  nextValue: newConfig.url,
426
362
  label: 'url'
427
363
  });
428
-
429
364
  if (urlDiff) {
430
365
  diff.push(urlDiff);
431
- } // Icon
432
-
366
+ }
433
367
 
368
+ // Icon
434
369
  const iconDiff = getStringDiff({
435
370
  // This icon stored in the database has already been sanitized.
436
371
  previousValue: oldConfig.icon,
@@ -439,53 +374,48 @@ const getConfigDiff = (oldConfig, newConfig) => {
439
374
  nextValue: applicationConfig.sanitizeSvg(newConfig.icon),
440
375
  label: 'icon'
441
376
  });
442
-
443
377
  if (iconDiff) {
444
378
  diff.push(iconDiff);
445
- } // Permissions
446
-
379
+ }
447
380
 
381
+ // Permissions
448
382
  const permissionsDiff = getPermissionsDiff({
449
383
  previousValue: oldConfig.permissions,
450
384
  nextValue: newConfig.permissions
451
385
  });
452
-
453
386
  if (permissionsDiff) {
454
387
  diff.push(permissionsDiff);
455
- } // Main menu link
456
-
388
+ }
457
389
 
390
+ // Main menu link
458
391
  const mainMenuDiff = getMainMenuLinkDiff({
459
392
  previousValue: oldConfig.mainMenuLink,
460
393
  nextValue: newConfig.mainMenuLink
461
394
  });
462
-
463
395
  if (mainMenuDiff) {
464
396
  diff.push(mainMenuDiff);
465
- } // Submenu links
466
-
397
+ }
467
398
 
399
+ // Submenu links
468
400
  const submenuDiff = getSubmenuLinksDiff({
469
401
  previousValue: oldConfig.submenuLinks,
470
402
  nextValue: newConfig.submenuLinks
471
403
  });
472
-
473
404
  if (submenuDiff) {
474
405
  diff.push(submenuDiff);
475
406
  }
476
-
477
407
  return diff.join('\n');
478
408
  };
479
409
 
480
410
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
481
-
482
411
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
483
412
  var CreateCustomApplicationFromCli = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "mutation", name: { kind: "Name", value: "CreateCustomApplicationFromCli" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "organizationId" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "data" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "CustomApplicationDraftDataInput" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "createCustomApplication" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "organizationId" }, value: { kind: "Variable", name: { kind: "Name", value: "organizationId" } } }, { kind: "Argument", name: { kind: "Name", value: "data" }, value: { kind: "Variable", name: { kind: "Name", value: "data" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }] } }], loc: { start: 0, end: 201, source: { body: "mutation CreateCustomApplicationFromCli(\n $organizationId: String!\n $data: CustomApplicationDraftDataInput!\n) {\n createCustomApplication(organizationId: $organizationId, data: $data) {\n id\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
484
413
  var FetchCustomApplicationFromCli = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchCustomApplicationFromCli" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "entryPointUriPath" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "organizationExtensionForCustomApplication" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "entryPointUriPath" }, value: { kind: "Variable", name: { kind: "Name", value: "entryPointUriPath" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "organizationId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "application" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "entryPointUriPath" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "description" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "url" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "icon" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "permissions" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "oAuthScopes" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "mainMenuLink" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "defaultLabel" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "permissions" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "labelAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "submenuLinks" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "uriPath" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "defaultLabel" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "permissions" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "labelAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }] } }] } }] } }], loc: { start: 0, end: 647, source: { body: "query FetchCustomApplicationFromCli($entryPointUriPath: String!) {\n organizationExtensionForCustomApplication(\n entryPointUriPath: $entryPointUriPath\n ) {\n organizationId\n application {\n id\n entryPointUriPath\n name\n description\n url\n icon\n permissions {\n name\n oAuthScopes\n }\n mainMenuLink {\n defaultLabel\n permissions\n labelAllLocales {\n locale\n value\n }\n }\n submenuLinks {\n uriPath\n defaultLabel\n permissions\n labelAllLocales {\n locale\n value\n }\n }\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
485
414
  var FetchMyOrganizationsFromCli = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchMyOrganizationsFromCli" }, variableDefinitions: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "myOrganizations" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "total" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "results" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }] } }] } }] } }], loc: { start: 0, end: 112, source: { body: "query FetchMyOrganizationsFromCli {\n myOrganizations {\n total\n results {\n id\n name\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
486
415
  var UpdateCustomApplicationFromCli = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "mutation", name: { kind: "Name", value: "UpdateCustomApplicationFromCli" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "organizationId" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "data" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "CustomApplicationDraftDataInput" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "applicationId" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "ID" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "updateCustomApplication" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "organizationId" }, value: { kind: "Variable", name: { kind: "Name", value: "organizationId" } } }, { kind: "Argument", name: { kind: "Name", value: "data" }, value: { kind: "Variable", name: { kind: "Name", value: "data" } } }, { kind: "Argument", name: { kind: "Name", value: "applicationId" }, value: { kind: "Variable", name: { kind: "Name", value: "applicationId" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }] } }], loc: { start: 0, end: 268, source: { body: "mutation UpdateCustomApplicationFromCli(\n $organizationId: String!\n $data: CustomApplicationDraftDataInput!\n $applicationId: ID!\n) {\n updateCustomApplication(\n organizationId: $organizationId\n data: $data\n applicationId: $applicationId\n ) {\n id\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
487
416
  const credentialsStorage$1 = new credentialsStorage$2.CredentialsStorage();
488
- const client = new graphqlRequest.GraphQLClient('', // <-- Set on demand
417
+ const client = new graphqlRequest.GraphQLClient('',
418
+ // <-- Set on demand
489
419
  {
490
420
  headers: {
491
421
  Accept: 'application/json',
@@ -493,46 +423,39 @@ const client = new graphqlRequest.GraphQLClient('', // <-- Set on demand
493
423
  'x-user-agent': credentialsStorage$2.userAgent
494
424
  }
495
425
  });
496
-
497
426
  async function requestWithTokenRetry(document, requestOptions) {
498
427
  let retryCount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
499
428
  const token = credentialsStorage$1.getToken(requestOptions.mcApiUrl);
500
429
  client.setEndpoint("".concat(requestOptions.mcApiUrl, "/graphql"));
501
430
  client.setHeaders(requestOptions.headers);
502
-
503
431
  if (token) {
504
432
  client.setHeader('x-mc-cli-access-token', token);
505
433
  }
506
-
507
434
  try {
508
- const result = await client.rawRequest(graphql.print(document), requestOptions.variables); // In case a new session token is returned from the server, save it.
435
+ const result = await client.rawRequest(graphql.print(document), requestOptions.variables);
509
436
 
437
+ // In case a new session token is returned from the server, save it.
510
438
  const refreshedSessionToken = result.headers.get('x-refreshed-session-token');
511
-
512
439
  if (refreshedSessionToken) {
513
440
  console.log(chalk__default["default"].green('Session token refreshed.'));
514
441
  console.log();
515
- const refreshedSessionTokenExpiresAt = result.headers.get('x-refreshed-session-token-expires-at'); // Store the updated access token.
516
-
442
+ const refreshedSessionTokenExpiresAt = result.headers.get('x-refreshed-session-token-expires-at');
443
+ // Store the updated access token.
517
444
  credentialsStorage$1.setToken(requestOptions.mcApiUrl, {
518
445
  token: refreshedSessionToken,
519
446
  expiresAt: Number(refreshedSessionTokenExpiresAt)
520
447
  });
521
448
  }
522
-
523
449
  return result.data;
524
450
  } catch (error) {
525
451
  if (error instanceof graphqlRequest.ClientError) {
526
452
  // If it's an unauthorized error, retry the request to force the token to be refreshed.
527
453
  if (retryCount === 0 && error.response.errors && error.response.errors.length > 0) {
528
454
  var _context;
529
-
530
455
  const isUnauthorizedError = _someInstanceProperty__default["default"](_context = error.response.errors).call(_context, graphqlError => {
531
456
  var _graphqlError$extensi;
532
-
533
457
  return ((_graphqlError$extensi = graphqlError.extensions) === null || _graphqlError$extensi === void 0 ? void 0 : _graphqlError$extensi.code) === 'UNAUTHENTICATED';
534
458
  });
535
-
536
459
  if (isUnauthorizedError) {
537
460
  console.log(chalk__default["default"].yellow('Expired or invalid session token, attempting to retry the request with a refreshed token...'));
538
461
  return requestWithTokenRetry(document, _objectSpread(_objectSpread({}, requestOptions), {}, {
@@ -543,14 +466,12 @@ async function requestWithTokenRetry(document, requestOptions) {
543
466
  }
544
467
  }
545
468
  }
546
-
547
469
  throw error;
548
470
  }
549
471
  }
550
-
551
472
  const fetchCustomApplication = async _ref => {
552
473
  let mcApiUrl = _ref.mcApiUrl,
553
- entryPointUriPath = _ref.entryPointUriPath;
474
+ entryPointUriPath = _ref.entryPointUriPath;
554
475
  const customAppData = await requestWithTokenRetry(FetchCustomApplicationFromCli, {
555
476
  variables: {
556
477
  entryPointUriPath
@@ -562,12 +483,11 @@ const fetchCustomApplication = async _ref => {
562
483
  });
563
484
  return customAppData.organizationExtensionForCustomApplication;
564
485
  };
565
-
566
486
  const updateCustomApplication = async _ref2 => {
567
487
  let mcApiUrl = _ref2.mcApiUrl,
568
- applicationId = _ref2.applicationId,
569
- organizationId = _ref2.organizationId,
570
- data = _ref2.data;
488
+ applicationId = _ref2.applicationId,
489
+ organizationId = _ref2.organizationId,
490
+ data = _ref2.data;
571
491
  const updatedCustomAppsData = await requestWithTokenRetry(UpdateCustomApplicationFromCli, {
572
492
  variables: {
573
493
  organizationId,
@@ -581,11 +501,10 @@ const updateCustomApplication = async _ref2 => {
581
501
  });
582
502
  return updatedCustomAppsData.updateCustomApplication;
583
503
  };
584
-
585
504
  const createCustomApplication = async _ref3 => {
586
505
  let mcApiUrl = _ref3.mcApiUrl,
587
- organizationId = _ref3.organizationId,
588
- data = _ref3.data;
506
+ organizationId = _ref3.organizationId,
507
+ data = _ref3.data;
589
508
  const createdCustomAppData = await requestWithTokenRetry(CreateCustomApplicationFromCli, {
590
509
  variables: {
591
510
  organizationId,
@@ -598,7 +517,6 @@ const createCustomApplication = async _ref3 => {
598
517
  });
599
518
  return createdCustomAppData.createCustomApplication;
600
519
  };
601
-
602
520
  const fetchUserOrganizations = async _ref4 => {
603
521
  let mcApiUrl = _ref4.mcApiUrl;
604
522
  const userOrganizations = await requestWithTokenRetry(FetchMyOrganizationsFromCli, {
@@ -611,97 +529,76 @@ const fetchUserOrganizations = async _ref4 => {
611
529
  };
612
530
 
613
531
  const credentialsStorage = new credentialsStorage$2.CredentialsStorage();
614
-
615
532
  const getMcUrlLink = (mcApiUrl, organizationId, applicationId) => {
616
533
  var _context, _context2;
617
-
618
534
  const mcUrl = mcApiUrl.replace('mc-api', 'mc');
619
-
620
535
  const customAppLink = _concatInstanceProperty__default["default"](_context = _concatInstanceProperty__default["default"](_context2 = "".concat(mcUrl, "/account/organizations/")).call(_context2, organizationId, "/custom-applications/owned/")).call(_context, applicationId);
621
-
622
536
  return customAppLink;
623
537
  };
624
-
625
538
  async function run(options) {
626
539
  var _context5;
627
-
628
540
  const applicationConfig$1 = applicationConfig.processConfig();
629
541
  const localCustomAppData = applicationConfig$1.data;
630
542
  const mcApiUrl = applicationConfig$1.env.mcApiUrl;
631
543
  console.log("Using Merchant Center environment \"".concat(chalk__default["default"].green(mcApiUrl), "\"."));
632
544
  console.log();
633
545
  const isSessionValid = credentialsStorage.isSessionValid(mcApiUrl);
634
-
635
546
  if (!isSessionValid) {
636
547
  throw new Error("You don't have a valid session. Please, run the \"mc-scripts login\" command to authenticate yourself.");
637
548
  }
638
-
639
549
  const fetchedCustomApplication = await fetchCustomApplication({
640
550
  mcApiUrl,
641
551
  entryPointUriPath: localCustomAppData.entryPointUriPath
642
552
  });
643
-
644
553
  if (!fetchedCustomApplication) {
645
554
  var _context4;
646
-
647
555
  const userOrganizations = await fetchUserOrganizations({
648
556
  mcApiUrl
649
557
  });
650
558
  let organizationId, organizationName;
651
-
652
559
  if (userOrganizations.total === 0) {
653
560
  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.");
654
561
  }
655
-
656
562
  if (userOrganizations.total === 1) {
657
563
  const _userOrganizations$re = _slicedToArray(userOrganizations.results, 1),
658
- organization = _userOrganizations$re[0];
659
-
564
+ organization = _userOrganizations$re[0];
660
565
  organizationId = organization.id;
661
566
  organizationName = organization.name;
662
567
  } else {
663
568
  var _context3;
664
-
665
569
  const organizationChoices = _mapInstanceProperty__default["default"](_context3 = userOrganizations.results).call(_context3, organization => ({
666
570
  title: organization.name,
667
571
  value: organization.id
668
572
  }));
669
-
670
573
  const _await$prompts = await prompts__default["default"]({
671
- type: 'select',
672
- name: 'organizationId',
673
- message: 'Select an Organization',
674
- choices: organizationChoices,
675
- initial: 0
676
- }),
677
- selectedOrganizationId = _await$prompts.organizationId;
678
-
574
+ type: 'select',
575
+ name: 'organizationId',
576
+ message: 'Select an Organization',
577
+ choices: organizationChoices,
578
+ initial: 0
579
+ }),
580
+ selectedOrganizationId = _await$prompts.organizationId;
679
581
  if (!selectedOrganizationId) {
680
582
  throw new Error("No Organization selected, aborting.");
681
583
  }
682
-
683
584
  organizationId = selectedOrganizationId;
684
585
  organizationName = _findInstanceProperty__default["default"](organizationChoices).call(organizationChoices, _ref => {
685
586
  let value = _ref.value;
686
587
  return value === organizationId;
687
588
  }).title;
688
589
  }
689
-
690
590
  const _await$prompts2 = await prompts__default["default"]({
691
- type: 'text',
692
- name: 'confirmation',
693
- message: _filterInstanceProperty__default["default"](_context4 = ["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(_context4, Boolean).join('\n'),
694
- initial: 'yes'
695
- }),
696
- confirmation = _await$prompts2.confirmation;
697
-
591
+ type: 'text',
592
+ name: 'confirmation',
593
+ message: _filterInstanceProperty__default["default"](_context4 = ["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(_context4, Boolean).join('\n'),
594
+ initial: 'yes'
595
+ }),
596
+ confirmation = _await$prompts2.confirmation;
698
597
  if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
699
598
  console.log(chalk__default["default"].red('Aborted.'));
700
599
  return;
701
600
  }
702
-
703
601
  const data = omit__default["default"](localCustomAppData, ['id']);
704
-
705
602
  if (options.dryRun) {
706
603
  console.log();
707
604
  console.log("The following payload would be used to create a new Custom Application.");
@@ -709,54 +606,46 @@ async function run(options) {
709
606
  console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
710
607
  return;
711
608
  }
712
-
713
609
  const createdCustomApplication = await createCustomApplication({
714
610
  mcApiUrl,
715
611
  organizationId,
716
612
  data
717
- }); // This check is technically not necessary, as the `graphql-request` client
613
+ });
614
+
615
+ // This check is technically not necessary, as the `graphql-request` client
718
616
  // throws an error in case of GraphQL errors.
719
617
  // However, the generated TypeScript data related to the GraphQL query has the
720
618
  // field typed as optional, thus having an extra check for type correctness.
721
-
722
619
  if (!createdCustomApplication) {
723
620
  throw new Error('Failed to create the Custom Application.');
724
621
  }
725
-
726
622
  const customAppLink = getMcUrlLink(mcApiUrl, organizationId, createdCustomApplication.id);
727
623
  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), "\".")));
728
624
  console.log("You can inspect the Custom Application data in the Merchant Center at \"".concat(chalk__default["default"].gray(customAppLink), "\"."));
729
625
  return;
730
626
  }
731
-
732
627
  const customAppLink = getMcUrlLink(mcApiUrl, fetchedCustomApplication.organizationId, fetchedCustomApplication.application.id);
733
628
  const configDiff = getConfigDiff(fetchedCustomApplication.application, localCustomAppData);
734
-
735
629
  if (!configDiff) {
736
630
  console.log(chalk__default["default"].green("Custom Application up-to-date."));
737
631
  console.log("You can inspect the Custom Application data in the Merchant Center at \"".concat(chalk__default["default"].gray(customAppLink), "\"."));
738
632
  return;
739
633
  }
740
-
741
634
  console.log('Changes detected:');
742
635
  console.log(configDiff);
743
636
  console.log();
744
-
745
637
  const _await$prompts3 = await prompts__default["default"]({
746
- type: 'text',
747
- name: 'confirmation',
748
- message: _filterInstanceProperty__default["default"](_context5 = ["You are about to update the Custom Application \"".concat(chalk__default["default"].green(localCustomAppData.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(_context5, Boolean).join('\n'),
749
- initial: 'yes'
750
- }),
751
- confirmation = _await$prompts3.confirmation;
752
-
638
+ type: 'text',
639
+ name: 'confirmation',
640
+ message: _filterInstanceProperty__default["default"](_context5 = ["You are about to update the Custom Application \"".concat(chalk__default["default"].green(localCustomAppData.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(_context5, Boolean).join('\n'),
641
+ initial: 'yes'
642
+ }),
643
+ confirmation = _await$prompts3.confirmation;
753
644
  if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
754
645
  console.log(chalk__default["default"].red('Aborted.'));
755
646
  return;
756
647
  }
757
-
758
648
  const data = omit__default["default"](localCustomAppData, ['id']);
759
-
760
649
  if (options.dryRun) {
761
650
  console.log();
762
651
  console.log("The following payload would be used to update the Custom Application \"".concat(chalk__default["default"].green(data.entryPointUriPath), "\"."));
@@ -764,7 +653,6 @@ async function run(options) {
764
653
  console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
765
654
  return;
766
655
  }
767
-
768
656
  await updateCustomApplication({
769
657
  mcApiUrl,
770
658
  organizationId: fetchedCustomApplication.organizationId,