@commercetools-frontend/mc-scripts 0.0.0-CRAFT-1791-20251006162610
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.
- package/LICENSE +21 -0
- package/README.md +7 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.d.ts +2 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.dev.js +7 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.js +7 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js +7 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.esm.js +5 -0
- package/application-runtime/package.json +4 -0
- package/bin/cli.js +8 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.d.ts +2 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +199 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.js +7 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +199 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +184 -0
- package/cli/package.json +4 -0
- package/config/create-webpack-config-for-development.js +8 -0
- package/config/create-webpack-config-for-production.js +8 -0
- package/config/vendors-to-transpile.js +6 -0
- package/dist/build-2a0a18bd.esm.js +155 -0
- package/dist/build-521f3f9f.cjs.prod.js +169 -0
- package/dist/build-988fc0f7.cjs.dev.js +169 -0
- package/dist/build-vite-16b1a575.cjs.dev.js +238 -0
- package/dist/build-vite-59e1f185.esm.js +208 -0
- package/dist/build-vite-5d317720.cjs.prod.js +238 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.d.ts +2 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +29 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.js +7 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +29 -0
- package/dist/commercetools-frontend-mc-scripts.esm.js +21 -0
- package/dist/compile-html-025cd493.esm.js +34 -0
- package/dist/compile-html-50fd05ec.cjs.prod.js +42 -0
- package/dist/compile-html-f4ac88cc.cjs.dev.js +42 -0
- package/dist/config-sync-70a16916.cjs.dev.js +852 -0
- package/dist/config-sync-72c20d80.cjs.prod.js +846 -0
- package/dist/config-sync-bc895390.esm.js +830 -0
- package/dist/create-postcss-config-cb7be312.cjs.dev.js +81 -0
- package/dist/create-postcss-config-dde0ccf1.esm.js +75 -0
- package/dist/create-postcss-config-edca0c33.cjs.prod.js +81 -0
- package/dist/create-webpack-config-for-development-1aed1cc0.cjs.prod.js +465 -0
- package/dist/create-webpack-config-for-development-a95f3634.esm.js +440 -0
- package/dist/create-webpack-config-for-development-d003697b.cjs.dev.js +465 -0
- package/dist/create-webpack-config-for-production-15fbe7db.cjs.dev.js +523 -0
- package/dist/create-webpack-config-for-production-764c482f.cjs.prod.js +523 -0
- package/dist/create-webpack-config-for-production-9f42c336.esm.js +493 -0
- package/dist/credentials-storage-66c1e51f.cjs.prod.js +95 -0
- package/dist/credentials-storage-d001f726.esm.js +83 -0
- package/dist/credentials-storage-e7884d17.cjs.dev.js +95 -0
- package/dist/declarations/src/application-runtime.d.ts +1 -0
- package/dist/declarations/src/cli.d.ts +4 -0
- package/dist/declarations/src/config/create-postcss-config.d.ts +4 -0
- package/dist/declarations/src/config/create-webpack-config-for-development.d.ts +10 -0
- package/dist/declarations/src/config/create-webpack-config-for-production.d.ts +10 -0
- package/dist/declarations/src/config/vendors-to-transpile.d.ts +2 -0
- package/dist/declarations/src/deprecated-entry-points.d.ts +7 -0
- package/dist/declarations/src/index.d.ts +3 -0
- package/dist/declarations/src/postcss.d.ts +1 -0
- package/dist/declarations/src/types.d.ts +94 -0
- package/dist/declarations/src/version.d.ts +2 -0
- package/dist/declarations/src/webpack-loaders/i18n-message-compilation-loader.d.ts +3 -0
- package/dist/declarations/src/webpack.d.ts +2 -0
- package/dist/deployment-previews-set-17e8ed48.cjs.prod.js +202 -0
- package/dist/deployment-previews-set-3648972f.esm.js +191 -0
- package/dist/deployment-previews-set-37aef990.cjs.dev.js +202 -0
- package/dist/does-file-exist-32618334.esm.js +12 -0
- package/dist/does-file-exist-be53305d.cjs.prod.js +18 -0
- package/dist/does-file-exist-eb86baca.cjs.dev.js +18 -0
- package/dist/graphql-requests-6a47ad5b.esm.js +247 -0
- package/dist/graphql-requests-779b867b.cjs.dev.js +270 -0
- package/dist/graphql-requests-8086eba7.cjs.prod.js +270 -0
- package/dist/has-jsx-runtime-aa5d21ee.cjs.dev.js +15 -0
- package/dist/has-jsx-runtime-c3202df5.cjs.prod.js +15 -0
- package/dist/has-jsx-runtime-e3ecb09b.esm.js +13 -0
- package/dist/i18n-message-complilation-21d3b0aa.esm.js +15 -0
- package/dist/i18n-message-complilation-7311cb29.cjs.dev.js +23 -0
- package/dist/i18n-message-complilation-7762da61.cjs.prod.js +23 -0
- package/dist/login-0a728449.esm.js +229 -0
- package/dist/login-817a5a26.cjs.dev.js +270 -0
- package/dist/login-85c25393.cjs.prod.js +270 -0
- package/dist/optimizations-7789145e.cjs.dev.js +85 -0
- package/dist/optimizations-bf991634.esm.js +67 -0
- package/dist/optimizations-fb93514f.cjs.prod.js +85 -0
- package/dist/package-7e170dc4.cjs.dev.js +160 -0
- package/dist/package-940b0a2a.cjs.prod.js +160 -0
- package/dist/package-99e547a7.esm.js +158 -0
- package/dist/paths-39f22b8b.esm.js +36 -0
- package/dist/paths-7768b440.cjs.prod.js +44 -0
- package/dist/paths-b76fc753.cjs.dev.js +44 -0
- package/dist/serve-1036c2de.esm.js +55 -0
- package/dist/serve-50d33f0b.cjs.dev.js +64 -0
- package/dist/serve-8a506da6.cjs.prod.js +64 -0
- package/dist/start-1d677ad8.cjs.dev.js +177 -0
- package/dist/start-2a7ae03d.esm.js +164 -0
- package/dist/start-f56cb5f7.cjs.prod.js +177 -0
- package/dist/start-vite-068e9f73.cjs.dev.js +128 -0
- package/dist/start-vite-29078b3a.cjs.prod.js +128 -0
- package/dist/start-vite-7d1161e8.esm.js +116 -0
- package/dist/vendors-to-transpile-04a49d40.cjs.prod.js +5 -0
- package/dist/vendors-to-transpile-6ab4ea06.cjs.dev.js +5 -0
- package/dist/vendors-to-transpile-7dc84a72.esm.js +3 -0
- package/dist/vite-plugin-svgr-4034a834.cjs.prod.js +151 -0
- package/dist/vite-plugin-svgr-7d06f400.cjs.dev.js +151 -0
- package/dist/vite-plugin-svgr-de6ee7da.esm.js +125 -0
- package/package.json +156 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.d.ts +2 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +12 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.js +7 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +12 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +4 -0
- package/postcss/package.json +4 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.d.ts +2 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +57 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.js +7 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +57 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +48 -0
- package/webpack/package.json +4 -0
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.d.ts +3 -0
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.dev.js +30 -0
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.js +7 -0
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.prod.js +30 -0
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.esm.js +26 -0
- package/webpack-loaders/i18n-message-compilation-loader/package.json +4 -0
|
@@ -0,0 +1,852 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
4
|
+
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
5
|
+
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
6
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
7
|
+
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
8
|
+
var chalk = require('chalk');
|
|
9
|
+
var omit = require('lodash/omit');
|
|
10
|
+
var prompts = require('prompts');
|
|
11
|
+
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
12
|
+
var credentialsStorage$1 = require('./credentials-storage-e7884d17.cjs.dev.js');
|
|
13
|
+
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
14
|
+
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
15
|
+
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
16
|
+
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
17
|
+
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
18
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
19
|
+
var _repeatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/repeat');
|
|
20
|
+
var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
|
|
21
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
22
|
+
var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
23
|
+
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
24
|
+
var graphqlRequests = require('./graphql-requests-779b867b.cjs.dev.js');
|
|
25
|
+
require('@commercetools/http-user-agent');
|
|
26
|
+
require('./package-7e170dc4.cjs.dev.js');
|
|
27
|
+
require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
28
|
+
require('@babel/runtime-corejs3/helpers/createClass');
|
|
29
|
+
require('@babel/runtime-corejs3/core-js-stable/date/now');
|
|
30
|
+
require('node:fs');
|
|
31
|
+
require('node:os');
|
|
32
|
+
require('node:path');
|
|
33
|
+
require('./does-file-exist-eb86baca.cjs.dev.js');
|
|
34
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
35
|
+
require('graphql');
|
|
36
|
+
require('graphql-request');
|
|
37
|
+
require('@commercetools-frontend/constants');
|
|
38
|
+
|
|
39
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
40
|
+
|
|
41
|
+
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
42
|
+
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
43
|
+
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
44
|
+
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
45
|
+
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
46
|
+
var omit__default = /*#__PURE__*/_interopDefault(omit);
|
|
47
|
+
var prompts__default = /*#__PURE__*/_interopDefault(prompts);
|
|
48
|
+
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
49
|
+
var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
|
|
50
|
+
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
51
|
+
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
52
|
+
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
53
|
+
var _repeatInstanceProperty__default = /*#__PURE__*/_interopDefault(_repeatInstanceProperty);
|
|
54
|
+
var _Set__default = /*#__PURE__*/_interopDefault(_Set);
|
|
55
|
+
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
56
|
+
var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
|
|
57
|
+
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
58
|
+
|
|
59
|
+
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; }
|
|
60
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context7, _context8; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context7 = ownKeys(Object(t), !0)).call(_context7, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context8 = ownKeys(Object(t))).call(_context8, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
61
|
+
|
|
62
|
+
// Since not all terminal supports colors, to make things more consistent for testing purposes,
|
|
63
|
+
// during tests the color used is appended before the string instead of coloring it.
|
|
64
|
+
const isTest = process.env.NODE_ENV === 'test';
|
|
65
|
+
const red = str => {
|
|
66
|
+
if (isTest) return `<color-red>${str}</color-red>`;
|
|
67
|
+
return chalk__default["default"].red(str);
|
|
68
|
+
};
|
|
69
|
+
const green = str => {
|
|
70
|
+
if (isTest) return `<color-green>${str}</color-green>`;
|
|
71
|
+
return chalk__default["default"].green(str);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// Two spaces are used for indentation.
|
|
75
|
+
const indent = indentLevel => {
|
|
76
|
+
var _context;
|
|
77
|
+
return _repeatInstanceProperty__default["default"](_context = ' ').call(_context, indentLevel);
|
|
78
|
+
};
|
|
79
|
+
const getStringDiff = _ref => {
|
|
80
|
+
let previousValue = _ref.previousValue,
|
|
81
|
+
nextValue = _ref.nextValue,
|
|
82
|
+
label = _ref.label,
|
|
83
|
+
_ref$indentLevel = _ref.indentLevel,
|
|
84
|
+
indentLevel = _ref$indentLevel === void 0 ? 0 : _ref$indentLevel;
|
|
85
|
+
if (!previousValue && nextValue) {
|
|
86
|
+
return `${indent(indentLevel)}${label} added: ${green(nextValue)}`;
|
|
87
|
+
}
|
|
88
|
+
if (previousValue && !nextValue) {
|
|
89
|
+
return `${indent(indentLevel)}${label} removed: ${red(previousValue)}`;
|
|
90
|
+
}
|
|
91
|
+
if (previousValue && nextValue && previousValue !== nextValue) {
|
|
92
|
+
return `${indent(indentLevel)}${label} changed: ${red(previousValue)} => ${green(nextValue)}`;
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
};
|
|
96
|
+
// NOTE: this assumes that the array values are scalar values (not objects).
|
|
97
|
+
const getArrayDiff = _ref2 => {
|
|
98
|
+
let previousValue = _ref2.previousValue,
|
|
99
|
+
nextValue = _ref2.nextValue,
|
|
100
|
+
label = _ref2.label,
|
|
101
|
+
_ref2$indentLevel = _ref2.indentLevel,
|
|
102
|
+
indentLevel = _ref2$indentLevel === void 0 ? 0 : _ref2$indentLevel;
|
|
103
|
+
const oldArraySet = new _Set__default["default"](previousValue);
|
|
104
|
+
const arrayDiff = [];
|
|
105
|
+
nextValue?.forEach(item => {
|
|
106
|
+
if (oldArraySet.has(item)) {
|
|
107
|
+
oldArraySet.delete(item);
|
|
108
|
+
} else {
|
|
109
|
+
arrayDiff.push(getStringDiff({
|
|
110
|
+
nextValue: item,
|
|
111
|
+
label,
|
|
112
|
+
indentLevel
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
_forEachInstanceProperty__default["default"](oldArraySet).call(oldArraySet, item => {
|
|
117
|
+
arrayDiff.push(getStringDiff({
|
|
118
|
+
previousValue: item,
|
|
119
|
+
label,
|
|
120
|
+
indentLevel
|
|
121
|
+
}));
|
|
122
|
+
});
|
|
123
|
+
return arrayDiff.join('\n');
|
|
124
|
+
};
|
|
125
|
+
const getPermissionsDiff = _ref3 => {
|
|
126
|
+
var _context2;
|
|
127
|
+
let previousValue = _ref3.previousValue,
|
|
128
|
+
nextValue = _ref3.nextValue;
|
|
129
|
+
const permissionDiff = ['permissions changed'];
|
|
130
|
+
const mappedOldPermissions = _reduceInstanceProperty__default["default"](previousValue).call(previousValue, (previousPermission, _ref4) => {
|
|
131
|
+
let name = _ref4.name,
|
|
132
|
+
oAuthScopes = _ref4.oAuthScopes;
|
|
133
|
+
return _objectSpread(_objectSpread({}, previousPermission), {}, {
|
|
134
|
+
[name]: oAuthScopes
|
|
135
|
+
});
|
|
136
|
+
}, {});
|
|
137
|
+
const indentLevel = 1;
|
|
138
|
+
_forEachInstanceProperty__default["default"](nextValue).call(nextValue, newPermission => {
|
|
139
|
+
const currentDiff = [`${indent(indentLevel)}"${newPermission.name}" changed`];
|
|
140
|
+
// if the permission name is not in the old config, it means it is a new addition.
|
|
141
|
+
if (!mappedOldPermissions[newPermission.name]) {
|
|
142
|
+
permissionDiff.push(`${indent(indentLevel)}"${green(newPermission.name)}" was added`);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// if permission name is in the old config, now we check if there was a change
|
|
146
|
+
else {
|
|
147
|
+
currentDiff.push(getArrayDiff({
|
|
148
|
+
previousValue: mappedOldPermissions[newPermission.name],
|
|
149
|
+
nextValue: newPermission.oAuthScopes,
|
|
150
|
+
label: 'oauth scope',
|
|
151
|
+
indentLevel: 2
|
|
152
|
+
}));
|
|
153
|
+
delete mappedOldPermissions[newPermission.name];
|
|
154
|
+
}
|
|
155
|
+
_filterInstanceProperty__default["default"](currentDiff).call(currentDiff, Boolean).length > 1 && permissionDiff.push(currentDiff.join('\n'));
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// if there are old permissions left, it means they were deleted in the new Permissions.
|
|
159
|
+
_forEachInstanceProperty__default["default"](_context2 = _Object$keys__default["default"](mappedOldPermissions)).call(_context2, oldPermissionName => {
|
|
160
|
+
permissionDiff.push(`${indent(indentLevel)}"${red(oldPermissionName)}" was removed`);
|
|
161
|
+
});
|
|
162
|
+
if (permissionDiff.length > 1) return permissionDiff.join('\n');
|
|
163
|
+
return null;
|
|
164
|
+
};
|
|
165
|
+
const getLabelAllLocalesDiff = _ref5 => {
|
|
166
|
+
var _context3;
|
|
167
|
+
let _ref5$previousValue = _ref5.previousValue,
|
|
168
|
+
previousValue = _ref5$previousValue === void 0 ? [] : _ref5$previousValue,
|
|
169
|
+
_ref5$nextValue = _ref5.nextValue,
|
|
170
|
+
nextValue = _ref5$nextValue === void 0 ? [] : _ref5$nextValue,
|
|
171
|
+
_ref5$indentLevel = _ref5.indentLevel,
|
|
172
|
+
indentLevel = _ref5$indentLevel === void 0 ? 0 : _ref5$indentLevel;
|
|
173
|
+
const labelAllLocalesDiff = [`${indent(indentLevel - 1)}labelAllLocales changed`];
|
|
174
|
+
const mappedOldLabelAllLocales = _reduceInstanceProperty__default["default"](previousValue).call(previousValue, (previousLabelAllLocale, _ref6) => {
|
|
175
|
+
let locale = _ref6.locale,
|
|
176
|
+
value = _ref6.value;
|
|
177
|
+
return _objectSpread(_objectSpread({}, previousLabelAllLocale), {}, {
|
|
178
|
+
[locale]: value
|
|
179
|
+
});
|
|
180
|
+
}, {});
|
|
181
|
+
_forEachInstanceProperty__default["default"](nextValue).call(nextValue, newLabelAllLocale => {
|
|
182
|
+
if (newLabelAllLocale.locale in mappedOldLabelAllLocales) {
|
|
183
|
+
const oldLocaleValue = mappedOldLabelAllLocales[newLabelAllLocale.locale];
|
|
184
|
+
if (oldLocaleValue !== newLabelAllLocale.value) {
|
|
185
|
+
labelAllLocalesDiff.push(`${indent(indentLevel)}locale "${newLabelAllLocale.locale}" changed: ${red(oldLocaleValue)} => ${green(newLabelAllLocale.value)}`);
|
|
186
|
+
}
|
|
187
|
+
delete mappedOldLabelAllLocales[newLabelAllLocale.locale];
|
|
188
|
+
} else {
|
|
189
|
+
const localeDiff = getStringDiff({
|
|
190
|
+
nextValue: newLabelAllLocale.locale,
|
|
191
|
+
label: 'locale',
|
|
192
|
+
indentLevel
|
|
193
|
+
});
|
|
194
|
+
if (localeDiff) {
|
|
195
|
+
labelAllLocalesDiff.push(localeDiff);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
_forEachInstanceProperty__default["default"](_context3 = _Object$keys__default["default"](mappedOldLabelAllLocales)).call(_context3, key => {
|
|
200
|
+
const localeDiff = getStringDiff({
|
|
201
|
+
previousValue: key,
|
|
202
|
+
label: 'locale',
|
|
203
|
+
indentLevel
|
|
204
|
+
});
|
|
205
|
+
if (localeDiff) {
|
|
206
|
+
labelAllLocalesDiff.push(localeDiff);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
if (labelAllLocalesDiff.length > 1) return labelAllLocalesDiff.join('\n');
|
|
210
|
+
return null;
|
|
211
|
+
};
|
|
212
|
+
const getTypeSettingsDiff = _ref7 => {
|
|
213
|
+
var _context4;
|
|
214
|
+
let previousValue = _ref7.previousValue,
|
|
215
|
+
nextValue = _ref7.nextValue;
|
|
216
|
+
const nonNullablePreviousValue = previousValue || {};
|
|
217
|
+
const nonNullableNextValue = nextValue || {};
|
|
218
|
+
const indentLevel = 1;
|
|
219
|
+
const typeSettingsDiff = [`${indent(indentLevel - 1)}type settings changed`];
|
|
220
|
+
_forEachInstanceProperty__default["default"](_context4 = _Object$keys__default["default"](nonNullablePreviousValue)).call(_context4, key => {
|
|
221
|
+
const typeSettingDiff = getStringDiff({
|
|
222
|
+
previousValue: nonNullablePreviousValue[key],
|
|
223
|
+
nextValue: nonNullableNextValue[key],
|
|
224
|
+
label: key,
|
|
225
|
+
indentLevel
|
|
226
|
+
});
|
|
227
|
+
if (typeSettingDiff) {
|
|
228
|
+
typeSettingsDiff.push(typeSettingDiff);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
if (typeSettingsDiff.length > 1) return typeSettingsDiff.join('\n');
|
|
232
|
+
return null;
|
|
233
|
+
};
|
|
234
|
+
const getLocatorsDiff = _ref8 => {
|
|
235
|
+
let previousValue = _ref8.previousValue,
|
|
236
|
+
nextValue = _ref8.nextValue;
|
|
237
|
+
const diff = [];
|
|
238
|
+
const locatorsDiff = getArrayDiff({
|
|
239
|
+
previousValue: previousValue,
|
|
240
|
+
nextValue: nextValue,
|
|
241
|
+
label: 'locators',
|
|
242
|
+
indentLevel: 1
|
|
243
|
+
});
|
|
244
|
+
if (locatorsDiff) {
|
|
245
|
+
diff.push('locators changed');
|
|
246
|
+
diff.push(locatorsDiff);
|
|
247
|
+
}
|
|
248
|
+
return diff.join('\n');
|
|
249
|
+
};
|
|
250
|
+
const getMainMenuLinkDiff = _ref9 => {
|
|
251
|
+
let previousValue = _ref9.previousValue,
|
|
252
|
+
nextValue = _ref9.nextValue;
|
|
253
|
+
const mainMenuLinkDiff = ['mainMenuLink changed'];
|
|
254
|
+
const menuDiff = getStringDiff({
|
|
255
|
+
previousValue: previousValue.defaultLabel,
|
|
256
|
+
nextValue: nextValue.defaultLabel,
|
|
257
|
+
label: 'defaultLabel',
|
|
258
|
+
indentLevel: 1
|
|
259
|
+
});
|
|
260
|
+
if (menuDiff) {
|
|
261
|
+
mainMenuLinkDiff.push(menuDiff);
|
|
262
|
+
}
|
|
263
|
+
const mainMenuLinkPermissionsDiff = getArrayDiff({
|
|
264
|
+
previousValue: previousValue.permissions,
|
|
265
|
+
nextValue: nextValue.permissions,
|
|
266
|
+
label: 'applied permission',
|
|
267
|
+
indentLevel: 2
|
|
268
|
+
});
|
|
269
|
+
if (mainMenuLinkPermissionsDiff.length > 0) {
|
|
270
|
+
mainMenuLinkDiff.push(`${indent(1)}permissions changed`);
|
|
271
|
+
mainMenuLinkDiff.push(mainMenuLinkPermissionsDiff);
|
|
272
|
+
}
|
|
273
|
+
const menuLabelsDiff = getLabelAllLocalesDiff({
|
|
274
|
+
previousValue: previousValue.labelAllLocales,
|
|
275
|
+
nextValue: nextValue.labelAllLocales,
|
|
276
|
+
indentLevel: 2
|
|
277
|
+
});
|
|
278
|
+
if (menuLabelsDiff) {
|
|
279
|
+
mainMenuLinkDiff.push(menuLabelsDiff);
|
|
280
|
+
}
|
|
281
|
+
const filteredMainMenuLinkDiff = _filterInstanceProperty__default["default"](mainMenuLinkDiff).call(mainMenuLinkDiff, Boolean);
|
|
282
|
+
if (filteredMainMenuLinkDiff.length > 1) return filteredMainMenuLinkDiff.join('\n');
|
|
283
|
+
return null;
|
|
284
|
+
};
|
|
285
|
+
const getSubmenuLinksDiff = _ref0 => {
|
|
286
|
+
var _context6;
|
|
287
|
+
let previousValue = _ref0.previousValue,
|
|
288
|
+
nextValue = _ref0.nextValue;
|
|
289
|
+
const submenuLinksDiff = ['submenuLink changed'];
|
|
290
|
+
const mappedSubmenuLinks = _reduceInstanceProperty__default["default"](previousValue).call(previousValue, (previousSubmenuLink, currentSubmenuLink) => _objectSpread(_objectSpread({}, previousSubmenuLink), {}, {
|
|
291
|
+
[currentSubmenuLink.uriPath]: currentSubmenuLink
|
|
292
|
+
}), {});
|
|
293
|
+
const getOrder = value => _mapInstanceProperty__default["default"](value).call(value, link => link.uriPath).join(', ');
|
|
294
|
+
const previousOrder = getOrder(previousValue);
|
|
295
|
+
const newOrder = getOrder(nextValue);
|
|
296
|
+
if (previousOrder !== newOrder) {
|
|
297
|
+
submenuLinksDiff.push(`${indent(1)}submenu order changed`);
|
|
298
|
+
submenuLinksDiff.push(`${indent(2)}previous order: [${previousOrder}]`);
|
|
299
|
+
submenuLinksDiff.push(`${indent(2)}new order: [${newOrder}]`);
|
|
300
|
+
}
|
|
301
|
+
_forEachInstanceProperty__default["default"](nextValue).call(nextValue, newSubmenuLink => {
|
|
302
|
+
const oldSubMenuLink = mappedSubmenuLinks[newSubmenuLink.uriPath];
|
|
303
|
+
if (newSubmenuLink.uriPath in mappedSubmenuLinks) {
|
|
304
|
+
var _context5;
|
|
305
|
+
const submenuLinkDiff = [`${indent(1)}menu link "${newSubmenuLink.uriPath}" changed`];
|
|
306
|
+
_forEachInstanceProperty__default["default"](_context5 = _Object$keys__default["default"](mappedSubmenuLinks[newSubmenuLink.uriPath])).call(_context5, key => {
|
|
307
|
+
switch (key) {
|
|
308
|
+
case 'defaultLabel':
|
|
309
|
+
{
|
|
310
|
+
const labelDiff = getStringDiff({
|
|
311
|
+
previousValue: oldSubMenuLink.defaultLabel,
|
|
312
|
+
nextValue: newSubmenuLink.defaultLabel,
|
|
313
|
+
label: 'defaultLabel',
|
|
314
|
+
indentLevel: 2
|
|
315
|
+
});
|
|
316
|
+
if (labelDiff) {
|
|
317
|
+
submenuLinkDiff.push(labelDiff);
|
|
318
|
+
}
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
case 'permissions':
|
|
322
|
+
{
|
|
323
|
+
const submenuLinkPermissionsDiff = getArrayDiff({
|
|
324
|
+
previousValue: oldSubMenuLink.permissions,
|
|
325
|
+
nextValue: newSubmenuLink.permissions,
|
|
326
|
+
label: 'applied permission',
|
|
327
|
+
indentLevel: 3
|
|
328
|
+
});
|
|
329
|
+
if (submenuLinkPermissionsDiff.length > 0) {
|
|
330
|
+
submenuLinkDiff.push(`${indent(2)}permissions changed`);
|
|
331
|
+
submenuLinkDiff.push(submenuLinkPermissionsDiff);
|
|
332
|
+
}
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
case 'labelAllLocales':
|
|
336
|
+
{
|
|
337
|
+
const labelsDiff = getLabelAllLocalesDiff({
|
|
338
|
+
previousValue: oldSubMenuLink.labelAllLocales,
|
|
339
|
+
nextValue: newSubmenuLink.labelAllLocales,
|
|
340
|
+
indentLevel: 3
|
|
341
|
+
});
|
|
342
|
+
if (labelsDiff) {
|
|
343
|
+
submenuLinkDiff.push(labelsDiff);
|
|
344
|
+
}
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
delete mappedSubmenuLinks[newSubmenuLink.uriPath];
|
|
350
|
+
const filteredSubmenuLinksDiff = _filterInstanceProperty__default["default"](submenuLinkDiff).call(submenuLinkDiff, Boolean);
|
|
351
|
+
if (filteredSubmenuLinksDiff.length > 1) {
|
|
352
|
+
submenuLinksDiff.push(filteredSubmenuLinksDiff.join('\n'));
|
|
353
|
+
}
|
|
354
|
+
} else {
|
|
355
|
+
const linksDiff = getStringDiff({
|
|
356
|
+
nextValue: newSubmenuLink.uriPath,
|
|
357
|
+
label: 'menu link',
|
|
358
|
+
indentLevel: 1
|
|
359
|
+
});
|
|
360
|
+
if (linksDiff) {
|
|
361
|
+
submenuLinksDiff.push(linksDiff);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
_forEachInstanceProperty__default["default"](_context6 = _Object$keys__default["default"](mappedSubmenuLinks)).call(_context6, key => {
|
|
366
|
+
const linksDiff = getStringDiff({
|
|
367
|
+
previousValue: key,
|
|
368
|
+
label: 'menu link',
|
|
369
|
+
indentLevel: 1
|
|
370
|
+
});
|
|
371
|
+
if (linksDiff) submenuLinksDiff.push(linksDiff);
|
|
372
|
+
});
|
|
373
|
+
if (submenuLinksDiff.length > 1) return submenuLinksDiff.join('\n');
|
|
374
|
+
return null;
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
// Compute diff changes of the Custom Application config.
|
|
378
|
+
// NOTE: Only known keys are evaluated.
|
|
379
|
+
const getCustomApplicationConfigDiff = (oldConfig, newConfig) => {
|
|
380
|
+
const diff = [];
|
|
381
|
+
|
|
382
|
+
// Name
|
|
383
|
+
const nameDiff = getStringDiff({
|
|
384
|
+
previousValue: oldConfig.name,
|
|
385
|
+
nextValue: newConfig.name,
|
|
386
|
+
label: 'name'
|
|
387
|
+
});
|
|
388
|
+
if (nameDiff) {
|
|
389
|
+
diff.push(nameDiff);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// Description
|
|
393
|
+
const descriptionDiff = getStringDiff({
|
|
394
|
+
previousValue: oldConfig.description,
|
|
395
|
+
nextValue: newConfig.description,
|
|
396
|
+
label: 'description'
|
|
397
|
+
});
|
|
398
|
+
if (descriptionDiff) {
|
|
399
|
+
diff.push(descriptionDiff);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// URL
|
|
403
|
+
const urlDiff = getStringDiff({
|
|
404
|
+
previousValue: oldConfig.url,
|
|
405
|
+
nextValue: newConfig.url,
|
|
406
|
+
label: 'url'
|
|
407
|
+
});
|
|
408
|
+
if (urlDiff) {
|
|
409
|
+
diff.push(urlDiff);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// Icon
|
|
413
|
+
const iconDiff = getStringDiff({
|
|
414
|
+
// This icon stored in the database has already been sanitized.
|
|
415
|
+
previousValue: oldConfig.icon,
|
|
416
|
+
// Sanitize the raw icon as-if it was stored in the database,
|
|
417
|
+
// to ensure the data can be safely compared.
|
|
418
|
+
nextValue: applicationConfig.sanitizeSvg(newConfig.icon),
|
|
419
|
+
label: 'icon'
|
|
420
|
+
});
|
|
421
|
+
if (iconDiff) {
|
|
422
|
+
diff.push(iconDiff);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// Permissions
|
|
426
|
+
const permissionsDiff = getPermissionsDiff({
|
|
427
|
+
previousValue: oldConfig.permissions,
|
|
428
|
+
nextValue: newConfig.permissions
|
|
429
|
+
});
|
|
430
|
+
if (permissionsDiff) {
|
|
431
|
+
diff.push(permissionsDiff);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// Main menu link
|
|
435
|
+
const mainMenuDiff = getMainMenuLinkDiff({
|
|
436
|
+
previousValue: oldConfig.mainMenuLink,
|
|
437
|
+
nextValue: newConfig.mainMenuLink
|
|
438
|
+
});
|
|
439
|
+
if (mainMenuDiff) {
|
|
440
|
+
diff.push(mainMenuDiff);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// Submenu links
|
|
444
|
+
const submenuDiff = getSubmenuLinksDiff({
|
|
445
|
+
previousValue: oldConfig.submenuLinks,
|
|
446
|
+
nextValue: newConfig.submenuLinks
|
|
447
|
+
});
|
|
448
|
+
if (submenuDiff) {
|
|
449
|
+
diff.push(submenuDiff);
|
|
450
|
+
}
|
|
451
|
+
return diff.join('\n');
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
// Compute diff changes of the Custom View config.
|
|
455
|
+
// NOTE: Only known keys are evaluated.
|
|
456
|
+
const getCustomViewConfigDiff = (oldConfig, newConfig) => {
|
|
457
|
+
const diff = [];
|
|
458
|
+
|
|
459
|
+
// Default Label
|
|
460
|
+
const defaultLabelDiff = getStringDiff({
|
|
461
|
+
previousValue: oldConfig.defaultLabel,
|
|
462
|
+
nextValue: newConfig.defaultLabel,
|
|
463
|
+
label: 'defaultLabel'
|
|
464
|
+
});
|
|
465
|
+
if (defaultLabelDiff) {
|
|
466
|
+
diff.push(defaultLabelDiff);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// Description
|
|
470
|
+
const descriptionDiff = getStringDiff({
|
|
471
|
+
previousValue: oldConfig.description,
|
|
472
|
+
nextValue: newConfig.description,
|
|
473
|
+
label: 'description'
|
|
474
|
+
});
|
|
475
|
+
if (descriptionDiff) {
|
|
476
|
+
diff.push(descriptionDiff);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// URL
|
|
480
|
+
const urlDiff = getStringDiff({
|
|
481
|
+
previousValue: oldConfig.url,
|
|
482
|
+
nextValue: newConfig.url,
|
|
483
|
+
label: 'url'
|
|
484
|
+
});
|
|
485
|
+
if (urlDiff) {
|
|
486
|
+
diff.push(urlDiff);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// Type
|
|
490
|
+
const typeDiff = getStringDiff({
|
|
491
|
+
previousValue: oldConfig.type,
|
|
492
|
+
nextValue: newConfig.type,
|
|
493
|
+
label: 'type'
|
|
494
|
+
});
|
|
495
|
+
if (typeDiff) {
|
|
496
|
+
diff.push(typeDiff);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// Permissions
|
|
500
|
+
const permissionsDiff = getPermissionsDiff({
|
|
501
|
+
previousValue: oldConfig.permissions,
|
|
502
|
+
nextValue: newConfig.permissions
|
|
503
|
+
});
|
|
504
|
+
if (permissionsDiff) {
|
|
505
|
+
diff.push(permissionsDiff);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// Label All Locales
|
|
509
|
+
const labelsDiff = getLabelAllLocalesDiff({
|
|
510
|
+
previousValue: oldConfig.labelAllLocales,
|
|
511
|
+
nextValue: newConfig.labelAllLocales,
|
|
512
|
+
indentLevel: 1
|
|
513
|
+
});
|
|
514
|
+
if (labelsDiff) {
|
|
515
|
+
diff.push(labelsDiff);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
// Type settings
|
|
519
|
+
const typeSettingsDiff = getTypeSettingsDiff({
|
|
520
|
+
previousValue: oldConfig.typeSettings,
|
|
521
|
+
nextValue: newConfig.typeSettings
|
|
522
|
+
});
|
|
523
|
+
if (typeSettingsDiff) {
|
|
524
|
+
diff.push(typeSettingsDiff);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
// Locators
|
|
528
|
+
const locatorsDiff = getLocatorsDiff({
|
|
529
|
+
previousValue: oldConfig.locators,
|
|
530
|
+
nextValue: newConfig.locators
|
|
531
|
+
});
|
|
532
|
+
if (locatorsDiff) {
|
|
533
|
+
diff.push(locatorsDiff);
|
|
534
|
+
}
|
|
535
|
+
return diff.join('\n');
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
const credentialsStorage = new credentialsStorage$1.CredentialsStorage();
|
|
539
|
+
const getMcUrlLink = _ref => {
|
|
540
|
+
let mcApiUrl = _ref.mcApiUrl,
|
|
541
|
+
organizationId = _ref.organizationId,
|
|
542
|
+
customEntityId = _ref.customEntityId,
|
|
543
|
+
isCustomView = _ref.isCustomView;
|
|
544
|
+
const mcUrl = mcApiUrl.replace('mc-api', 'mc');
|
|
545
|
+
const customEntityLink = `${mcUrl}/account/organizations/${organizationId}/custom-${isCustomView ? 'views' : 'applications'}/owned/${customEntityId}`;
|
|
546
|
+
return customEntityLink;
|
|
547
|
+
};
|
|
548
|
+
const isCustomViewData = data => data.entryPointUriPath === undefined;
|
|
549
|
+
async function createOrUpdateCustomApplication(_ref2) {
|
|
550
|
+
var _context3;
|
|
551
|
+
let mcApiUrl = _ref2.mcApiUrl,
|
|
552
|
+
localCustomEntityData = _ref2.localCustomEntityData,
|
|
553
|
+
applicationIdentifier = _ref2.applicationIdentifier,
|
|
554
|
+
options = _ref2.options;
|
|
555
|
+
const fetchedCustomApplication = await graphqlRequests.fetchCustomApplication({
|
|
556
|
+
mcApiUrl,
|
|
557
|
+
entryPointUriPath: localCustomEntityData.entryPointUriPath,
|
|
558
|
+
applicationIdentifier
|
|
559
|
+
});
|
|
560
|
+
if (!fetchedCustomApplication) {
|
|
561
|
+
var _context2;
|
|
562
|
+
const userOrganizations = await graphqlRequests.fetchUserOrganizations({
|
|
563
|
+
mcApiUrl,
|
|
564
|
+
applicationIdentifier
|
|
565
|
+
});
|
|
566
|
+
let organizationId, organizationName;
|
|
567
|
+
if (userOrganizations.total === 0) {
|
|
568
|
+
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.`);
|
|
569
|
+
}
|
|
570
|
+
if (userOrganizations.total === 1) {
|
|
571
|
+
const _userOrganizations$re = _slicedToArray(userOrganizations.results, 1),
|
|
572
|
+
organization = _userOrganizations$re[0];
|
|
573
|
+
organizationId = organization.id;
|
|
574
|
+
organizationName = organization.name;
|
|
575
|
+
} else {
|
|
576
|
+
var _context;
|
|
577
|
+
const organizationChoices = _mapInstanceProperty__default["default"](_context = userOrganizations.results).call(_context, organization => ({
|
|
578
|
+
title: organization.name,
|
|
579
|
+
value: organization.id
|
|
580
|
+
}));
|
|
581
|
+
const _await$prompts = await prompts__default["default"]({
|
|
582
|
+
type: 'select',
|
|
583
|
+
name: 'organizationId',
|
|
584
|
+
message: 'Select an Organization',
|
|
585
|
+
choices: organizationChoices,
|
|
586
|
+
initial: 0
|
|
587
|
+
}),
|
|
588
|
+
selectedOrganizationId = _await$prompts.organizationId;
|
|
589
|
+
if (!selectedOrganizationId) {
|
|
590
|
+
throw new Error(`No Organization selected, aborting.`);
|
|
591
|
+
}
|
|
592
|
+
organizationId = selectedOrganizationId;
|
|
593
|
+
organizationName = _findInstanceProperty__default["default"](organizationChoices).call(organizationChoices, _ref3 => {
|
|
594
|
+
let value = _ref3.value;
|
|
595
|
+
return value === organizationId;
|
|
596
|
+
}).title;
|
|
597
|
+
}
|
|
598
|
+
const _await$prompts2 = await prompts__default["default"]({
|
|
599
|
+
type: 'text',
|
|
600
|
+
name: 'confirmation',
|
|
601
|
+
message: _filterInstanceProperty__default["default"](_context2 = [`You are about to create a new Custom Application in the "${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(_context2, Boolean).join('\n'),
|
|
602
|
+
initial: 'yes'
|
|
603
|
+
}),
|
|
604
|
+
confirmation = _await$prompts2.confirmation;
|
|
605
|
+
if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
|
|
606
|
+
console.log(chalk__default["default"].red('Aborted.'));
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
const data = omit__default["default"](localCustomEntityData, ['id']);
|
|
610
|
+
if (options.dryRun) {
|
|
611
|
+
console.log();
|
|
612
|
+
console.log(`The following payload would be used to create a new Custom Application.`);
|
|
613
|
+
console.log();
|
|
614
|
+
console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
const createdCustomApplication = await graphqlRequests.createCustomApplication({
|
|
618
|
+
mcApiUrl,
|
|
619
|
+
organizationId,
|
|
620
|
+
data,
|
|
621
|
+
applicationIdentifier
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
// This check is technically not necessary, as the `graphql-request` client
|
|
625
|
+
// throws an error in case of GraphQL errors.
|
|
626
|
+
// However, the generated TypeScript data related to the GraphQL query has the
|
|
627
|
+
// field typed as optional, thus having an extra check for type correctness.
|
|
628
|
+
if (!createdCustomApplication) {
|
|
629
|
+
throw new Error('Failed to create the Custom Application.');
|
|
630
|
+
}
|
|
631
|
+
const customAppLink = getMcUrlLink({
|
|
632
|
+
mcApiUrl,
|
|
633
|
+
organizationId,
|
|
634
|
+
customEntityId: createdCustomApplication.id
|
|
635
|
+
});
|
|
636
|
+
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: "${chalk__default["default"].green(createdCustomApplication.id)}".`));
|
|
637
|
+
console.log(`You can inspect the Custom Application data in the Merchant Center at "${chalk__default["default"].gray(customAppLink)}".`);
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
const customAppLink = getMcUrlLink({
|
|
641
|
+
mcApiUrl,
|
|
642
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
643
|
+
customEntityId: fetchedCustomApplication.application.id
|
|
644
|
+
});
|
|
645
|
+
const configDiff = getCustomApplicationConfigDiff(fetchedCustomApplication.application, localCustomEntityData);
|
|
646
|
+
if (!configDiff) {
|
|
647
|
+
console.log(chalk__default["default"].green(`Custom Application up-to-date.`));
|
|
648
|
+
console.log(`You can inspect the Custom Application data in the Merchant Center at "${chalk__default["default"].gray(customAppLink)}".`);
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
console.log('Changes detected:');
|
|
652
|
+
console.log(configDiff);
|
|
653
|
+
console.log();
|
|
654
|
+
const _await$prompts3 = await prompts__default["default"]({
|
|
655
|
+
type: 'text',
|
|
656
|
+
name: 'confirmation',
|
|
657
|
+
message: _filterInstanceProperty__default["default"](_context3 = [`You are about to update the Custom Application "${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(_context3, Boolean).join('\n'),
|
|
658
|
+
initial: 'yes'
|
|
659
|
+
}),
|
|
660
|
+
confirmation = _await$prompts3.confirmation;
|
|
661
|
+
if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
|
|
662
|
+
console.log(chalk__default["default"].red('Aborted.'));
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
const data = omit__default["default"](localCustomEntityData, ['id']);
|
|
666
|
+
if (options.dryRun) {
|
|
667
|
+
console.log();
|
|
668
|
+
console.log(`The following payload would be used to update the Custom Application "${chalk__default["default"].green(data.entryPointUriPath)}".`);
|
|
669
|
+
console.log();
|
|
670
|
+
console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
await graphqlRequests.updateCustomApplication({
|
|
674
|
+
mcApiUrl,
|
|
675
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
676
|
+
data: omit__default["default"](localCustomEntityData, ['id']),
|
|
677
|
+
applicationId: fetchedCustomApplication.application.id,
|
|
678
|
+
applicationIdentifier
|
|
679
|
+
});
|
|
680
|
+
console.log(chalk__default["default"].green(`Custom Application updated.`));
|
|
681
|
+
console.log(`You can inspect the Custom Application data in the Merchant Center at "${chalk__default["default"].gray(customAppLink)}".`);
|
|
682
|
+
}
|
|
683
|
+
async function createOrUpdateCustomView(_ref4) {
|
|
684
|
+
var _context6;
|
|
685
|
+
let mcApiUrl = _ref4.mcApiUrl,
|
|
686
|
+
localCustomEntityData = _ref4.localCustomEntityData,
|
|
687
|
+
customViewId = _ref4.customViewId,
|
|
688
|
+
options = _ref4.options,
|
|
689
|
+
applicationIdentifier = _ref4.applicationIdentifier;
|
|
690
|
+
const fetchedCustomView = await graphqlRequests.fetchCustomView({
|
|
691
|
+
mcApiUrl,
|
|
692
|
+
customViewId,
|
|
693
|
+
applicationIdentifier
|
|
694
|
+
});
|
|
695
|
+
if (!fetchedCustomView) {
|
|
696
|
+
var _context5;
|
|
697
|
+
const userOrganizations = await graphqlRequests.fetchUserOrganizations({
|
|
698
|
+
mcApiUrl,
|
|
699
|
+
customViewId,
|
|
700
|
+
applicationIdentifier
|
|
701
|
+
});
|
|
702
|
+
let organizationId, organizationName;
|
|
703
|
+
if (userOrganizations.total === 0) {
|
|
704
|
+
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.`);
|
|
705
|
+
}
|
|
706
|
+
if (userOrganizations.total === 1) {
|
|
707
|
+
const _userOrganizations$re2 = _slicedToArray(userOrganizations.results, 1),
|
|
708
|
+
organization = _userOrganizations$re2[0];
|
|
709
|
+
organizationId = organization.id;
|
|
710
|
+
organizationName = organization.name;
|
|
711
|
+
} else {
|
|
712
|
+
var _context4;
|
|
713
|
+
const organizationChoices = _mapInstanceProperty__default["default"](_context4 = userOrganizations.results).call(_context4, organization => ({
|
|
714
|
+
title: organization.name,
|
|
715
|
+
value: organization.id
|
|
716
|
+
}));
|
|
717
|
+
const _await$prompts4 = await prompts__default["default"]({
|
|
718
|
+
type: 'select',
|
|
719
|
+
name: 'organizationId',
|
|
720
|
+
message: 'Select an Organization',
|
|
721
|
+
choices: organizationChoices,
|
|
722
|
+
initial: 0
|
|
723
|
+
}),
|
|
724
|
+
selectedOrganizationId = _await$prompts4.organizationId;
|
|
725
|
+
if (!selectedOrganizationId) {
|
|
726
|
+
throw new Error(`No Organization selected, aborting.`);
|
|
727
|
+
}
|
|
728
|
+
organizationId = selectedOrganizationId;
|
|
729
|
+
organizationName = _findInstanceProperty__default["default"](organizationChoices).call(organizationChoices, _ref5 => {
|
|
730
|
+
let value = _ref5.value;
|
|
731
|
+
return value === organizationId;
|
|
732
|
+
}).title;
|
|
733
|
+
}
|
|
734
|
+
const _await$prompts5 = await prompts__default["default"]({
|
|
735
|
+
type: 'text',
|
|
736
|
+
name: 'confirmation',
|
|
737
|
+
message: _filterInstanceProperty__default["default"](_context5 = [`You are about to create a new Custom View in the "${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'),
|
|
738
|
+
initial: 'yes'
|
|
739
|
+
}),
|
|
740
|
+
confirmation = _await$prompts5.confirmation;
|
|
741
|
+
if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
|
|
742
|
+
console.log(chalk__default["default"].red('Aborted.'));
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
const data = omit__default["default"](localCustomEntityData, ['id']);
|
|
746
|
+
if (options.dryRun) {
|
|
747
|
+
console.log();
|
|
748
|
+
console.log(`The following payload would be used to create a new Custom View.`);
|
|
749
|
+
console.log();
|
|
750
|
+
console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
const createdCustomView = await graphqlRequests.createCustomView({
|
|
754
|
+
mcApiUrl,
|
|
755
|
+
organizationId,
|
|
756
|
+
data,
|
|
757
|
+
applicationIdentifier
|
|
758
|
+
});
|
|
759
|
+
|
|
760
|
+
// This check is technically not necessary, as the `graphql-request` client
|
|
761
|
+
// throws an error in case of GraphQL errors.
|
|
762
|
+
// However, the generated TypeScript data related to the GraphQL query has the
|
|
763
|
+
// field typed as optional, thus having an extra check for type correctness.
|
|
764
|
+
if (!createdCustomView) {
|
|
765
|
+
throw new Error('Failed to create the Custom View.');
|
|
766
|
+
}
|
|
767
|
+
const customViewLink = getMcUrlLink({
|
|
768
|
+
mcApiUrl,
|
|
769
|
+
organizationId,
|
|
770
|
+
customEntityId: createdCustomView.id,
|
|
771
|
+
isCustomView: true
|
|
772
|
+
});
|
|
773
|
+
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: "${chalk__default["default"].green(createdCustomView.id)}".`));
|
|
774
|
+
console.log(`You can inspect the Custom View data in the Merchant Center at "${chalk__default["default"].gray(customViewLink)}".`);
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
const customViewLink = getMcUrlLink({
|
|
778
|
+
mcApiUrl,
|
|
779
|
+
organizationId: fetchedCustomView.organizationId,
|
|
780
|
+
customEntityId: fetchedCustomView?.customView?.id || '',
|
|
781
|
+
isCustomView: true
|
|
782
|
+
});
|
|
783
|
+
const configDiff = getCustomViewConfigDiff(fetchedCustomView.customView, localCustomEntityData);
|
|
784
|
+
if (!configDiff) {
|
|
785
|
+
console.log(chalk__default["default"].green(`Custom View up-to-date.`));
|
|
786
|
+
console.log(`You can inspect the Custom View data in the Merchant Center at "${chalk__default["default"].gray(customViewLink)}".`);
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
console.log('Changes detected:');
|
|
790
|
+
console.log(configDiff);
|
|
791
|
+
console.log();
|
|
792
|
+
const _await$prompts6 = await prompts__default["default"]({
|
|
793
|
+
type: 'text',
|
|
794
|
+
name: 'confirmation',
|
|
795
|
+
message: _filterInstanceProperty__default["default"](_context6 = [`You are about to update the Custom View "${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(_context6, Boolean).join('\n'),
|
|
796
|
+
initial: 'yes'
|
|
797
|
+
}),
|
|
798
|
+
confirmation = _await$prompts6.confirmation;
|
|
799
|
+
if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
|
|
800
|
+
console.log(chalk__default["default"].red('Aborted.'));
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
803
|
+
const data = omit__default["default"](localCustomEntityData, ['id']);
|
|
804
|
+
if (options.dryRun) {
|
|
805
|
+
console.log();
|
|
806
|
+
console.log(`The following payload would be used to update the Custom View "${chalk__default["default"].green(data.defaultLabel)}".`);
|
|
807
|
+
console.log();
|
|
808
|
+
console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
811
|
+
await graphqlRequests.updateCustomView({
|
|
812
|
+
mcApiUrl,
|
|
813
|
+
organizationId: fetchedCustomView.organizationId,
|
|
814
|
+
data: omit__default["default"](localCustomEntityData, ['id']),
|
|
815
|
+
customViewId: fetchedCustomView?.customView?.id || '',
|
|
816
|
+
applicationIdentifier
|
|
817
|
+
});
|
|
818
|
+
console.log(chalk__default["default"].green(`Custom View updated.`));
|
|
819
|
+
console.log(`You can inspect the Custom View data in the Merchant Center at "${chalk__default["default"].gray(customViewLink)}".`);
|
|
820
|
+
}
|
|
821
|
+
async function run(options) {
|
|
822
|
+
const applicationConfig$1 = await applicationConfig.processConfig();
|
|
823
|
+
const localCustomEntityData = applicationConfig$1.data;
|
|
824
|
+
const _applicationConfig$en = applicationConfig$1.env,
|
|
825
|
+
mcApiUrl = _applicationConfig$en.mcApiUrl,
|
|
826
|
+
applicationIdentifier = _applicationConfig$en.applicationIdentifier,
|
|
827
|
+
customViewId = _applicationConfig$en.customViewId;
|
|
828
|
+
console.log(`Using Merchant Center environment "${chalk__default["default"].green(mcApiUrl)}".`);
|
|
829
|
+
console.log();
|
|
830
|
+
const isSessionValid = credentialsStorage.isSessionValid(mcApiUrl);
|
|
831
|
+
if (!isSessionValid) {
|
|
832
|
+
throw new Error(`You don't have a valid session. Please, run the "mc-scripts login" command to authenticate yourself.`);
|
|
833
|
+
}
|
|
834
|
+
if (isCustomViewData(localCustomEntityData)) {
|
|
835
|
+
createOrUpdateCustomView({
|
|
836
|
+
mcApiUrl,
|
|
837
|
+
localCustomEntityData,
|
|
838
|
+
applicationIdentifier,
|
|
839
|
+
customViewId: customViewId || localCustomEntityData.id,
|
|
840
|
+
options
|
|
841
|
+
});
|
|
842
|
+
} else {
|
|
843
|
+
createOrUpdateCustomApplication({
|
|
844
|
+
mcApiUrl,
|
|
845
|
+
localCustomEntityData,
|
|
846
|
+
applicationIdentifier,
|
|
847
|
+
options
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
exports["default"] = run;
|