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