@commercetools-frontend/mc-scripts 25.0.0 → 25.2.0

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