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