@commercetools-frontend/mc-scripts 22.11.0 → 22.13.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 +5 -5
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +5 -5
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +5 -5
- package/dist/{build-32837342.cjs.prod.js → build-5bfca7c8.cjs.prod.js} +3 -3
- package/dist/{build-5c91b773.cjs.dev.js → build-9bd2f410.cjs.dev.js} +3 -3
- package/dist/{build-fcc2b53e.esm.js → build-c99a4685.esm.js} +3 -3
- package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +1 -1
- package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +1 -1
- package/dist/commercetools-frontend-mc-scripts.esm.js +1 -1
- package/dist/{config-sync-dc8c5825.cjs.dev.js → config-sync-52f1daf8.cjs.dev.js} +417 -62
- package/dist/{config-sync-1b9901fd.esm.js → config-sync-aa114b0b.esm.js} +417 -62
- package/dist/{config-sync-cb6355ee.cjs.prod.js → config-sync-bef101a0.cjs.prod.js} +417 -62
- package/dist/{create-postcss-config-83bf7e4e.cjs.prod.js → create-postcss-config-1fd98922.cjs.prod.js} +1 -1
- package/dist/{create-postcss-config-cb5f7725.esm.js → create-postcss-config-354ba07a.esm.js} +1 -1
- package/dist/{create-postcss-config-e77490e3.cjs.dev.js → create-postcss-config-843c2974.cjs.dev.js} +1 -1
- package/dist/{create-webpack-config-for-development-db0db557.esm.js → create-webpack-config-for-development-3b40205e.esm.js} +1 -1
- package/dist/{create-webpack-config-for-development-50b8a7e7.cjs.dev.js → create-webpack-config-for-development-8f11a518.cjs.dev.js} +1 -1
- package/dist/{create-webpack-config-for-development-4d3956ab.cjs.prod.js → create-webpack-config-for-development-90aa6ec0.cjs.prod.js} +1 -1
- package/dist/{create-webpack-config-for-production-78307ac6.cjs.prod.js → create-webpack-config-for-production-2716c37e.cjs.prod.js} +1 -1
- package/dist/{create-webpack-config-for-production-421bdf70.cjs.dev.js → create-webpack-config-for-production-cacd3a52.cjs.dev.js} +1 -1
- package/dist/{create-webpack-config-for-production-c1e7bfaa.esm.js → create-webpack-config-for-production-e57dacb7.esm.js} +1 -1
- package/dist/{credentials-storage-39492166.esm.js → credentials-storage-001c09fb.esm.js} +1 -1
- package/dist/{credentials-storage-6c8f8a6a.cjs.prod.js → credentials-storage-252b2ead.cjs.prod.js} +1 -1
- package/dist/{credentials-storage-2a0046c3.cjs.dev.js → credentials-storage-e637c260.cjs.dev.js} +1 -1
- package/dist/declarations/src/generated/settings.d.ts +114 -1
- package/dist/declarations/src/utils/get-config-diff.d.ts +3 -3
- package/dist/declarations/src/utils/graphql-requests.d.ts +56 -3
- package/dist/{login-256c8d6b.cjs.prod.js → login-506d2457.cjs.prod.js} +2 -2
- package/dist/{login-d0ac94e2.cjs.dev.js → login-67e038da.cjs.dev.js} +2 -2
- package/dist/{login-cf3d1b7f.esm.js → login-f7a8221b.esm.js} +2 -2
- package/dist/{package-afdd385b.esm.js → package-53e602ff.esm.js} +9 -8
- package/dist/{package-582f21e6.cjs.prod.js → package-933e64f5.cjs.dev.js} +9 -8
- package/dist/{package-9f63548c.cjs.dev.js → package-db6d1141.cjs.prod.js} +9 -8
- package/dist/{start-3021daa5.esm.js → start-18591a38.esm.js} +3 -3
- package/dist/{start-7dc2bd3d.cjs.prod.js → start-19554dc8.cjs.prod.js} +3 -3
- package/dist/{start-860d7653.cjs.dev.js → start-6b8d264b.cjs.dev.js} +3 -3
- package/package.json +9 -8
- 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 +4 -4
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +4 -4
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +4 -4
|
@@ -10,7 +10,7 @@ var chalk = require('chalk');
|
|
|
10
10
|
var omit = require('lodash/omit');
|
|
11
11
|
var prompts = require('prompts');
|
|
12
12
|
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
13
|
-
var credentialsStorage$2 = require('./credentials-storage-
|
|
13
|
+
var credentialsStorage$2 = require('./credentials-storage-e637c260.cjs.dev.js');
|
|
14
14
|
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
15
15
|
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
16
16
|
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
@@ -27,7 +27,7 @@ var graphql = require('graphql');
|
|
|
27
27
|
var graphqlRequest = require('graphql-request');
|
|
28
28
|
var constants = require('@commercetools-frontend/constants');
|
|
29
29
|
require('@commercetools/http-user-agent');
|
|
30
|
-
require('./package-
|
|
30
|
+
require('./package-933e64f5.cjs.dev.js');
|
|
31
31
|
require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
32
32
|
require('@babel/runtime-corejs3/helpers/createClass');
|
|
33
33
|
require('@babel/runtime-corejs3/core-js-stable/date/now');
|
|
@@ -58,7 +58,7 @@ var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
|
58
58
|
var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
|
|
59
59
|
|
|
60
60
|
function ownKeys$1(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; }
|
|
61
|
-
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
61
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context21, _context22; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context21 = ownKeys$1(Object(t), !0)).call(_context21, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context22 = ownKeys$1(Object(t))).call(_context22, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
62
62
|
|
|
63
63
|
// Since not all terminal supports colors, to make things more consistent for testing purposes,
|
|
64
64
|
// during tests the color used is appended before the string instead of coloring it.
|
|
@@ -217,9 +217,47 @@ const getLabelAllLocalesDiff = _ref5 => {
|
|
|
217
217
|
if (labelAllLocalesDiff.length > 1) return labelAllLocalesDiff.join('\n');
|
|
218
218
|
return null;
|
|
219
219
|
};
|
|
220
|
-
const
|
|
220
|
+
const getTypeSettingsDiff = _ref7 => {
|
|
221
|
+
var _context17;
|
|
221
222
|
let previousValue = _ref7.previousValue,
|
|
222
223
|
nextValue = _ref7.nextValue;
|
|
224
|
+
const nonNullablePreviousValue = previousValue || {};
|
|
225
|
+
const nonNullableNextValue = nextValue || {};
|
|
226
|
+
const indentLevel = 1;
|
|
227
|
+
const typeSettingsDiff = ["".concat(indent(indentLevel - 1), "type settings changed")];
|
|
228
|
+
_forEachInstanceProperty__default["default"](_context17 = _Object$keys__default["default"](nonNullablePreviousValue)).call(_context17, key => {
|
|
229
|
+
const typeSettingDiff = getStringDiff({
|
|
230
|
+
previousValue: nonNullablePreviousValue[key],
|
|
231
|
+
nextValue: nonNullableNextValue[key],
|
|
232
|
+
label: key,
|
|
233
|
+
indentLevel
|
|
234
|
+
});
|
|
235
|
+
if (typeSettingDiff) {
|
|
236
|
+
typeSettingsDiff.push(typeSettingDiff);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
if (typeSettingsDiff.length > 1) return typeSettingsDiff.join('\n');
|
|
240
|
+
return null;
|
|
241
|
+
};
|
|
242
|
+
const getLocatorsDiff = _ref8 => {
|
|
243
|
+
let previousValue = _ref8.previousValue,
|
|
244
|
+
nextValue = _ref8.nextValue;
|
|
245
|
+
const diff = [];
|
|
246
|
+
const locatorsDiff = getArrayDiff({
|
|
247
|
+
previousValue: previousValue,
|
|
248
|
+
nextValue: nextValue,
|
|
249
|
+
label: 'locators',
|
|
250
|
+
indentLevel: 1
|
|
251
|
+
});
|
|
252
|
+
if (locatorsDiff) {
|
|
253
|
+
diff.push('locators changed');
|
|
254
|
+
diff.push(locatorsDiff);
|
|
255
|
+
}
|
|
256
|
+
return diff.join('\n');
|
|
257
|
+
};
|
|
258
|
+
const getMainMenuLinkDiff = _ref9 => {
|
|
259
|
+
let previousValue = _ref9.previousValue,
|
|
260
|
+
nextValue = _ref9.nextValue;
|
|
223
261
|
const mainMenuLinkDiff = ['mainMenuLink changed'];
|
|
224
262
|
const menuDiff = getStringDiff({
|
|
225
263
|
previousValue: previousValue.defaultLabel,
|
|
@@ -252,10 +290,10 @@ const getMainMenuLinkDiff = _ref7 => {
|
|
|
252
290
|
if (filteredMainMenuLinkDiff.length > 1) return filteredMainMenuLinkDiff.join('\n');
|
|
253
291
|
return null;
|
|
254
292
|
};
|
|
255
|
-
const getSubmenuLinksDiff =
|
|
256
|
-
var
|
|
257
|
-
let previousValue =
|
|
258
|
-
nextValue =
|
|
293
|
+
const getSubmenuLinksDiff = _ref10 => {
|
|
294
|
+
var _context20;
|
|
295
|
+
let previousValue = _ref10.previousValue,
|
|
296
|
+
nextValue = _ref10.nextValue;
|
|
259
297
|
const submenuLinksDiff = ['submenuLink changed'];
|
|
260
298
|
const mappedSubmenuLinks = _reduceInstanceProperty__default["default"](previousValue).call(previousValue, (previousSubmenuLink, currentSubmenuLink) => _objectSpread$1(_objectSpread$1({}, previousSubmenuLink), {}, {
|
|
261
299
|
[currentSubmenuLink.uriPath]: currentSubmenuLink
|
|
@@ -263,9 +301,9 @@ const getSubmenuLinksDiff = _ref8 => {
|
|
|
263
301
|
_forEachInstanceProperty__default["default"](nextValue).call(nextValue, newSubmenuLink => {
|
|
264
302
|
const oldSubMenuLink = mappedSubmenuLinks[newSubmenuLink.uriPath];
|
|
265
303
|
if (newSubmenuLink.uriPath in mappedSubmenuLinks) {
|
|
266
|
-
var
|
|
267
|
-
const submenuLinkDiff = [_concatInstanceProperty__default["default"](
|
|
268
|
-
_forEachInstanceProperty__default["default"](
|
|
304
|
+
var _context18, _context19;
|
|
305
|
+
const submenuLinkDiff = [_concatInstanceProperty__default["default"](_context18 = "".concat(indent(1), "menu link \"")).call(_context18, newSubmenuLink.uriPath, "\" changed")];
|
|
306
|
+
_forEachInstanceProperty__default["default"](_context19 = _Object$keys__default["default"](mappedSubmenuLinks[newSubmenuLink.uriPath])).call(_context19, key => {
|
|
269
307
|
switch (key) {
|
|
270
308
|
case 'defaultLabel':
|
|
271
309
|
{
|
|
@@ -324,7 +362,7 @@ const getSubmenuLinksDiff = _ref8 => {
|
|
|
324
362
|
}
|
|
325
363
|
}
|
|
326
364
|
});
|
|
327
|
-
_forEachInstanceProperty__default["default"](
|
|
365
|
+
_forEachInstanceProperty__default["default"](_context20 = _Object$keys__default["default"](mappedSubmenuLinks)).call(_context20, key => {
|
|
328
366
|
const linksDiff = getStringDiff({
|
|
329
367
|
previousValue: key,
|
|
330
368
|
label: 'menu link',
|
|
@@ -338,7 +376,7 @@ const getSubmenuLinksDiff = _ref8 => {
|
|
|
338
376
|
|
|
339
377
|
// Compute diff changes of the Custom Application config.
|
|
340
378
|
// NOTE: Only known keys are evaluated.
|
|
341
|
-
const
|
|
379
|
+
const getCustomApplicationConfigDiff = (oldConfig, newConfig) => {
|
|
342
380
|
const diff = [];
|
|
343
381
|
|
|
344
382
|
// Name
|
|
@@ -413,12 +451,99 @@ const getConfigDiff = (oldConfig, newConfig) => {
|
|
|
413
451
|
return diff.join('\n');
|
|
414
452
|
};
|
|
415
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
|
+
|
|
416
538
|
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; }
|
|
417
539
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
418
540
|
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 } } } };
|
|
541
|
+
var CreateCustomViewFromCli = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "mutation", name: { kind: "Name", value: "CreateCustomViewFromCli" }, 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: "CustomViewDraftDataInput" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "createCustomView" }, 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: 180, source: { body: "mutation CreateCustomViewFromCli(\n $organizationId: String!\n $data: CustomViewDraftDataInput!\n) {\n createCustomView(organizationId: $organizationId, data: $data) {\n id\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
419
542
|
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 } } } };
|
|
543
|
+
var FetchCustomViewFromCli = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchCustomViewFromCli" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "customViewId" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "organizationExtensionForCustomView" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "customViewId" }, value: { kind: "Variable", name: { kind: "Name", value: "customViewId" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "organizationId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "customView" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "defaultLabel" }, 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: "url" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "type" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "typeSettings" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "size" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "locators" }, 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: [] }] } }] } }] } }] } }], loc: { start: 0, end: 399, source: { body: "query FetchCustomViewFromCli($customViewId: String!) {\n organizationExtensionForCustomView(customViewId: $customViewId) {\n organizationId\n customView {\n id\n defaultLabel\n labelAllLocales {\n locale\n value\n }\n url\n type\n typeSettings {\n size\n }\n locators\n permissions {\n name\n oAuthScopes\n }\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
420
544
|
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 } } } };
|
|
421
545
|
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 } } } };
|
|
546
|
+
var UpdateCustomViewFromCli = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "mutation", name: { kind: "Name", value: "UpdateCustomViewFromCli" }, 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: "CustomViewDraftDataInput" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "customViewId" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "updateCustomView" }, 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: "customViewId" }, value: { kind: "Variable", name: { kind: "Name", value: "customViewId" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }] } }], loc: { start: 0, end: 248, source: { body: "mutation UpdateCustomViewFromCli(\n $organizationId: String!\n $data: CustomViewDraftDataInput!\n $customViewId: String!\n) {\n updateCustomView(\n organizationId: $organizationId\n data: $data\n customViewId: $customViewId\n ) {\n id\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
422
547
|
const credentialsStorage$1 = new credentialsStorage$2.CredentialsStorage();
|
|
423
548
|
async function requestWithTokenRetry(document, requestOptions) {
|
|
424
549
|
let retryCount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
@@ -486,12 +611,29 @@ const fetchCustomApplication = async _ref => {
|
|
|
486
611
|
});
|
|
487
612
|
return customAppData.organizationExtensionForCustomApplication;
|
|
488
613
|
};
|
|
489
|
-
const
|
|
614
|
+
const fetchCustomView = async _ref2 => {
|
|
490
615
|
let mcApiUrl = _ref2.mcApiUrl,
|
|
491
|
-
|
|
492
|
-
organizationId = _ref2.organizationId,
|
|
493
|
-
data = _ref2.data,
|
|
616
|
+
customViewId = _ref2.customViewId,
|
|
494
617
|
applicationIdentifier = _ref2.applicationIdentifier;
|
|
618
|
+
const customViewData = await requestWithTokenRetry(FetchCustomViewFromCli, {
|
|
619
|
+
variables: {
|
|
620
|
+
customViewId
|
|
621
|
+
},
|
|
622
|
+
mcApiUrl,
|
|
623
|
+
headers: {
|
|
624
|
+
'x-custom-view-id': customViewId,
|
|
625
|
+
'x-application-id': applicationIdentifier,
|
|
626
|
+
'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
return customViewData.organizationExtensionForCustomView;
|
|
630
|
+
};
|
|
631
|
+
const updateCustomApplication = async _ref3 => {
|
|
632
|
+
let mcApiUrl = _ref3.mcApiUrl,
|
|
633
|
+
applicationId = _ref3.applicationId,
|
|
634
|
+
organizationId = _ref3.organizationId,
|
|
635
|
+
data = _ref3.data,
|
|
636
|
+
applicationIdentifier = _ref3.applicationIdentifier;
|
|
495
637
|
const updatedCustomAppsData = await requestWithTokenRetry(UpdateCustomApplicationFromCli, {
|
|
496
638
|
variables: {
|
|
497
639
|
organizationId,
|
|
@@ -506,11 +648,32 @@ const updateCustomApplication = async _ref2 => {
|
|
|
506
648
|
});
|
|
507
649
|
return updatedCustomAppsData.updateCustomApplication;
|
|
508
650
|
};
|
|
509
|
-
const
|
|
510
|
-
let mcApiUrl =
|
|
511
|
-
organizationId =
|
|
512
|
-
data =
|
|
513
|
-
|
|
651
|
+
const updateCustomView = async _ref4 => {
|
|
652
|
+
let mcApiUrl = _ref4.mcApiUrl,
|
|
653
|
+
organizationId = _ref4.organizationId,
|
|
654
|
+
data = _ref4.data,
|
|
655
|
+
customViewId = _ref4.customViewId,
|
|
656
|
+
applicationIdentifier = _ref4.applicationIdentifier;
|
|
657
|
+
const updatedCustomViewData = await requestWithTokenRetry(UpdateCustomViewFromCli, {
|
|
658
|
+
variables: {
|
|
659
|
+
organizationId,
|
|
660
|
+
customViewId,
|
|
661
|
+
data
|
|
662
|
+
},
|
|
663
|
+
mcApiUrl,
|
|
664
|
+
headers: {
|
|
665
|
+
'x-custom-view-id': customViewId,
|
|
666
|
+
'x-application-id': applicationIdentifier,
|
|
667
|
+
'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
|
|
668
|
+
}
|
|
669
|
+
});
|
|
670
|
+
return updatedCustomViewData.updateCustomView;
|
|
671
|
+
};
|
|
672
|
+
const createCustomApplication = async _ref5 => {
|
|
673
|
+
let mcApiUrl = _ref5.mcApiUrl,
|
|
674
|
+
organizationId = _ref5.organizationId,
|
|
675
|
+
data = _ref5.data,
|
|
676
|
+
applicationIdentifier = _ref5.applicationIdentifier;
|
|
514
677
|
const createdCustomAppData = await requestWithTokenRetry(CreateCustomApplicationFromCli, {
|
|
515
678
|
variables: {
|
|
516
679
|
organizationId,
|
|
@@ -524,50 +687,66 @@ const createCustomApplication = async _ref3 => {
|
|
|
524
687
|
});
|
|
525
688
|
return createdCustomAppData.createCustomApplication;
|
|
526
689
|
};
|
|
527
|
-
const
|
|
528
|
-
let mcApiUrl =
|
|
529
|
-
|
|
530
|
-
|
|
690
|
+
const createCustomView = async _ref6 => {
|
|
691
|
+
let mcApiUrl = _ref6.mcApiUrl,
|
|
692
|
+
organizationId = _ref6.organizationId,
|
|
693
|
+
data = _ref6.data,
|
|
694
|
+
applicationIdentifier = _ref6.applicationIdentifier;
|
|
695
|
+
const createdCustomViewData = await requestWithTokenRetry(CreateCustomViewFromCli, {
|
|
696
|
+
variables: {
|
|
697
|
+
organizationId,
|
|
698
|
+
data
|
|
699
|
+
},
|
|
531
700
|
mcApiUrl,
|
|
532
701
|
headers: {
|
|
533
702
|
'x-application-id': applicationIdentifier,
|
|
534
|
-
'x-graphql-target': constants.GRAPHQL_TARGETS.
|
|
703
|
+
'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
|
|
535
704
|
}
|
|
536
705
|
});
|
|
706
|
+
return createdCustomViewData.createCustomView;
|
|
707
|
+
};
|
|
708
|
+
const fetchUserOrganizations = async _ref7 => {
|
|
709
|
+
let mcApiUrl = _ref7.mcApiUrl,
|
|
710
|
+
applicationIdentifier = _ref7.applicationIdentifier,
|
|
711
|
+
customViewId = _ref7.customViewId;
|
|
712
|
+
const userOrganizations = await requestWithTokenRetry(FetchMyOrganizationsFromCli, {
|
|
713
|
+
mcApiUrl,
|
|
714
|
+
headers: _objectSpread(_objectSpread({
|
|
715
|
+
'x-application-id': applicationIdentifier
|
|
716
|
+
}, customViewId && {
|
|
717
|
+
'x-custom-view-id': customViewId
|
|
718
|
+
}), {}, {
|
|
719
|
+
'x-graphql-target': constants.GRAPHQL_TARGETS.ADMINISTRATION_SERVICE
|
|
720
|
+
})
|
|
721
|
+
});
|
|
537
722
|
return userOrganizations.myOrganizations;
|
|
538
723
|
};
|
|
539
724
|
|
|
540
725
|
const credentialsStorage = new credentialsStorage$2.CredentialsStorage();
|
|
541
|
-
const getMcUrlLink =
|
|
542
|
-
var _context, _context2;
|
|
726
|
+
const getMcUrlLink = _ref => {
|
|
727
|
+
var _context, _context2, _context3;
|
|
728
|
+
let mcApiUrl = _ref.mcApiUrl,
|
|
729
|
+
organizationId = _ref.organizationId,
|
|
730
|
+
customEntityId = _ref.customEntityId,
|
|
731
|
+
isCustomView = _ref.isCustomView;
|
|
543
732
|
const mcUrl = mcApiUrl.replace('mc-api', 'mc');
|
|
544
|
-
const
|
|
545
|
-
return
|
|
733
|
+
const customEntityLink = _concatInstanceProperty__default["default"](_context = _concatInstanceProperty__default["default"](_context2 = _concatInstanceProperty__default["default"](_context3 = "".concat(mcUrl, "/account/organizations/")).call(_context3, organizationId, "/custom-")).call(_context2, isCustomView ? 'views' : 'applications', "/owned/")).call(_context, customEntityId);
|
|
734
|
+
return customEntityLink;
|
|
546
735
|
};
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
customViewId = _applicationConfig$en.customViewId;
|
|
555
|
-
if (customViewId) {
|
|
556
|
-
throw new Error("Syncing the configuration for Custom Views is not supported at the moment.");
|
|
557
|
-
}
|
|
558
|
-
console.log("Using Merchant Center environment \"".concat(chalk__default["default"].green(mcApiUrl), "\"."));
|
|
559
|
-
console.log();
|
|
560
|
-
const isSessionValid = credentialsStorage.isSessionValid(mcApiUrl);
|
|
561
|
-
if (!isSessionValid) {
|
|
562
|
-
throw new Error("You don't have a valid session. Please, run the \"mc-scripts login\" command to authenticate yourself.");
|
|
563
|
-
}
|
|
736
|
+
const isCustomViewData = data => data.entryPointUriPath === undefined;
|
|
737
|
+
async function createOrUpdateCustomApplication(_ref2) {
|
|
738
|
+
var _context6;
|
|
739
|
+
let mcApiUrl = _ref2.mcApiUrl,
|
|
740
|
+
localCustomEntityData = _ref2.localCustomEntityData,
|
|
741
|
+
applicationIdentifier = _ref2.applicationIdentifier,
|
|
742
|
+
options = _ref2.options;
|
|
564
743
|
const fetchedCustomApplication = await fetchCustomApplication({
|
|
565
744
|
mcApiUrl,
|
|
566
|
-
entryPointUriPath:
|
|
745
|
+
entryPointUriPath: localCustomEntityData.entryPointUriPath,
|
|
567
746
|
applicationIdentifier
|
|
568
747
|
});
|
|
569
748
|
if (!fetchedCustomApplication) {
|
|
570
|
-
var
|
|
749
|
+
var _context5;
|
|
571
750
|
const userOrganizations = await fetchUserOrganizations({
|
|
572
751
|
mcApiUrl,
|
|
573
752
|
applicationIdentifier
|
|
@@ -582,8 +761,8 @@ async function run(options) {
|
|
|
582
761
|
organizationId = organization.id;
|
|
583
762
|
organizationName = organization.name;
|
|
584
763
|
} else {
|
|
585
|
-
var
|
|
586
|
-
const organizationChoices = _mapInstanceProperty__default["default"](
|
|
764
|
+
var _context4;
|
|
765
|
+
const organizationChoices = _mapInstanceProperty__default["default"](_context4 = userOrganizations.results).call(_context4, organization => ({
|
|
587
766
|
title: organization.name,
|
|
588
767
|
value: organization.id
|
|
589
768
|
}));
|
|
@@ -599,15 +778,15 @@ async function run(options) {
|
|
|
599
778
|
throw new Error("No Organization selected, aborting.");
|
|
600
779
|
}
|
|
601
780
|
organizationId = selectedOrganizationId;
|
|
602
|
-
organizationName = _findInstanceProperty__default["default"](organizationChoices).call(organizationChoices,
|
|
603
|
-
let value =
|
|
781
|
+
organizationName = _findInstanceProperty__default["default"](organizationChoices).call(organizationChoices, _ref3 => {
|
|
782
|
+
let value = _ref3.value;
|
|
604
783
|
return value === organizationId;
|
|
605
784
|
}).title;
|
|
606
785
|
}
|
|
607
786
|
const _await$prompts2 = await prompts__default["default"]({
|
|
608
787
|
type: 'text',
|
|
609
788
|
name: 'confirmation',
|
|
610
|
-
message: _filterInstanceProperty__default["default"](
|
|
789
|
+
message: _filterInstanceProperty__default["default"](_context5 = ["You are about to create a new Custom Application in the \"".concat(chalk__default["default"].green(organizationName), "\" organization. Are you sure you want to proceed?"), options.dryRun && chalk__default["default"].gray('Using "--dry-run", no data will be created.')]).call(_context5, Boolean).join('\n'),
|
|
611
790
|
initial: 'yes'
|
|
612
791
|
}),
|
|
613
792
|
confirmation = _await$prompts2.confirmation;
|
|
@@ -615,7 +794,7 @@ async function run(options) {
|
|
|
615
794
|
console.log(chalk__default["default"].red('Aborted.'));
|
|
616
795
|
return;
|
|
617
796
|
}
|
|
618
|
-
const data = omit__default["default"](
|
|
797
|
+
const data = omit__default["default"](localCustomEntityData, ['id']);
|
|
619
798
|
if (options.dryRun) {
|
|
620
799
|
console.log();
|
|
621
800
|
console.log("The following payload would be used to create a new Custom Application.");
|
|
@@ -637,13 +816,21 @@ async function run(options) {
|
|
|
637
816
|
if (!createdCustomApplication) {
|
|
638
817
|
throw new Error('Failed to create the Custom Application.');
|
|
639
818
|
}
|
|
640
|
-
const customAppLink = getMcUrlLink(
|
|
819
|
+
const customAppLink = getMcUrlLink({
|
|
820
|
+
mcApiUrl,
|
|
821
|
+
organizationId,
|
|
822
|
+
customEntityId: createdCustomApplication.id
|
|
823
|
+
});
|
|
641
824
|
console.log(chalk__default["default"].green("Custom Application created.\nPlease update the \"env.production.applicationId\" field in your local Custom Application config file with the following value: \"".concat(chalk__default["default"].green(createdCustomApplication.id), "\".")));
|
|
642
825
|
console.log("You can inspect the Custom Application data in the Merchant Center at \"".concat(chalk__default["default"].gray(customAppLink), "\"."));
|
|
643
826
|
return;
|
|
644
827
|
}
|
|
645
|
-
const customAppLink = getMcUrlLink(
|
|
646
|
-
|
|
828
|
+
const customAppLink = getMcUrlLink({
|
|
829
|
+
mcApiUrl,
|
|
830
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
831
|
+
customEntityId: fetchedCustomApplication.application.id
|
|
832
|
+
});
|
|
833
|
+
const configDiff = getCustomApplicationConfigDiff(fetchedCustomApplication.application, localCustomEntityData);
|
|
647
834
|
if (!configDiff) {
|
|
648
835
|
console.log(chalk__default["default"].green("Custom Application up-to-date."));
|
|
649
836
|
console.log("You can inspect the Custom Application data in the Merchant Center at \"".concat(chalk__default["default"].gray(customAppLink), "\"."));
|
|
@@ -655,7 +842,7 @@ async function run(options) {
|
|
|
655
842
|
const _await$prompts3 = await prompts__default["default"]({
|
|
656
843
|
type: 'text',
|
|
657
844
|
name: 'confirmation',
|
|
658
|
-
message: _filterInstanceProperty__default["default"](
|
|
845
|
+
message: _filterInstanceProperty__default["default"](_context6 = ["You are about to update the Custom Application \"".concat(chalk__default["default"].green(localCustomEntityData.entryPointUriPath), "\" with the changes above. Are you sure you want to proceed?"), options.dryRun && chalk__default["default"].gray('Using "--dry-run", no data will be updated.')]).call(_context6, Boolean).join('\n'),
|
|
659
846
|
initial: 'yes'
|
|
660
847
|
}),
|
|
661
848
|
confirmation = _await$prompts3.confirmation;
|
|
@@ -663,7 +850,7 @@ async function run(options) {
|
|
|
663
850
|
console.log(chalk__default["default"].red('Aborted.'));
|
|
664
851
|
return;
|
|
665
852
|
}
|
|
666
|
-
const data = omit__default["default"](
|
|
853
|
+
const data = omit__default["default"](localCustomEntityData, ['id']);
|
|
667
854
|
if (options.dryRun) {
|
|
668
855
|
console.log();
|
|
669
856
|
console.log("The following payload would be used to update the Custom Application \"".concat(chalk__default["default"].green(data.entryPointUriPath), "\"."));
|
|
@@ -674,12 +861,180 @@ async function run(options) {
|
|
|
674
861
|
await updateCustomApplication({
|
|
675
862
|
mcApiUrl,
|
|
676
863
|
organizationId: fetchedCustomApplication.organizationId,
|
|
677
|
-
data: omit__default["default"](
|
|
864
|
+
data: omit__default["default"](localCustomEntityData, ['id']),
|
|
678
865
|
applicationId: fetchedCustomApplication.application.id,
|
|
679
866
|
applicationIdentifier
|
|
680
867
|
});
|
|
681
868
|
console.log(chalk__default["default"].green("Custom Application updated."));
|
|
682
869
|
console.log("You can inspect the Custom Application data in the Merchant Center at \"".concat(chalk__default["default"].gray(customAppLink), "\"."));
|
|
683
870
|
}
|
|
871
|
+
async function createOrUpdateCustomView(_ref4) {
|
|
872
|
+
var _fetchedCustomView$cu, _context9, _fetchedCustomView$cu2;
|
|
873
|
+
let mcApiUrl = _ref4.mcApiUrl,
|
|
874
|
+
localCustomEntityData = _ref4.localCustomEntityData,
|
|
875
|
+
customViewId = _ref4.customViewId,
|
|
876
|
+
options = _ref4.options,
|
|
877
|
+
applicationIdentifier = _ref4.applicationIdentifier;
|
|
878
|
+
const fetchedCustomView = await fetchCustomView({
|
|
879
|
+
mcApiUrl,
|
|
880
|
+
customViewId,
|
|
881
|
+
applicationIdentifier
|
|
882
|
+
});
|
|
883
|
+
if (!fetchedCustomView) {
|
|
884
|
+
var _context8;
|
|
885
|
+
const userOrganizations = await fetchUserOrganizations({
|
|
886
|
+
mcApiUrl,
|
|
887
|
+
customViewId,
|
|
888
|
+
applicationIdentifier
|
|
889
|
+
});
|
|
890
|
+
let organizationId, organizationName;
|
|
891
|
+
if (userOrganizations.total === 0) {
|
|
892
|
+
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.");
|
|
893
|
+
}
|
|
894
|
+
if (userOrganizations.total === 1) {
|
|
895
|
+
const _userOrganizations$re2 = _slicedToArray(userOrganizations.results, 1),
|
|
896
|
+
organization = _userOrganizations$re2[0];
|
|
897
|
+
organizationId = organization.id;
|
|
898
|
+
organizationName = organization.name;
|
|
899
|
+
} else {
|
|
900
|
+
var _context7;
|
|
901
|
+
const organizationChoices = _mapInstanceProperty__default["default"](_context7 = userOrganizations.results).call(_context7, organization => ({
|
|
902
|
+
title: organization.name,
|
|
903
|
+
value: organization.id
|
|
904
|
+
}));
|
|
905
|
+
const _await$prompts4 = await prompts__default["default"]({
|
|
906
|
+
type: 'select',
|
|
907
|
+
name: 'organizationId',
|
|
908
|
+
message: 'Select an Organization',
|
|
909
|
+
choices: organizationChoices,
|
|
910
|
+
initial: 0
|
|
911
|
+
}),
|
|
912
|
+
selectedOrganizationId = _await$prompts4.organizationId;
|
|
913
|
+
if (!selectedOrganizationId) {
|
|
914
|
+
throw new Error("No Organization selected, aborting.");
|
|
915
|
+
}
|
|
916
|
+
organizationId = selectedOrganizationId;
|
|
917
|
+
organizationName = _findInstanceProperty__default["default"](organizationChoices).call(organizationChoices, _ref5 => {
|
|
918
|
+
let value = _ref5.value;
|
|
919
|
+
return value === organizationId;
|
|
920
|
+
}).title;
|
|
921
|
+
}
|
|
922
|
+
const _await$prompts5 = await prompts__default["default"]({
|
|
923
|
+
type: 'text',
|
|
924
|
+
name: 'confirmation',
|
|
925
|
+
message: _filterInstanceProperty__default["default"](_context8 = ["You are about to create a new Custom View in the \"".concat(chalk__default["default"].green(organizationName), "\" organization. Are you sure you want to proceed?"), options.dryRun && chalk__default["default"].gray('Using "--dry-run", no data will be created.')]).call(_context8, Boolean).join('\n'),
|
|
926
|
+
initial: 'yes'
|
|
927
|
+
}),
|
|
928
|
+
confirmation = _await$prompts5.confirmation;
|
|
929
|
+
if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
|
|
930
|
+
console.log(chalk__default["default"].red('Aborted.'));
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
const data = omit__default["default"](localCustomEntityData, ['id']);
|
|
934
|
+
if (options.dryRun) {
|
|
935
|
+
console.log();
|
|
936
|
+
console.log("The following payload would be used to create a new Custom View.");
|
|
937
|
+
console.log();
|
|
938
|
+
console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
|
|
939
|
+
return;
|
|
940
|
+
}
|
|
941
|
+
const createdCustomView = await createCustomView({
|
|
942
|
+
mcApiUrl,
|
|
943
|
+
organizationId,
|
|
944
|
+
data,
|
|
945
|
+
applicationIdentifier
|
|
946
|
+
});
|
|
947
|
+
|
|
948
|
+
// This check is technically not necessary, as the `graphql-request` client
|
|
949
|
+
// throws an error in case of GraphQL errors.
|
|
950
|
+
// However, the generated TypeScript data related to the GraphQL query has the
|
|
951
|
+
// field typed as optional, thus having an extra check for type correctness.
|
|
952
|
+
if (!createdCustomView) {
|
|
953
|
+
throw new Error('Failed to create the Custom View.');
|
|
954
|
+
}
|
|
955
|
+
const customViewLink = getMcUrlLink({
|
|
956
|
+
mcApiUrl,
|
|
957
|
+
organizationId,
|
|
958
|
+
customEntityId: createdCustomView.id,
|
|
959
|
+
isCustomView: true
|
|
960
|
+
});
|
|
961
|
+
console.log(chalk__default["default"].green("Custom View created.\nPlease update the \"env.production.customViewId\" field in your local Custom View config file with the following value: \"".concat(chalk__default["default"].green(createdCustomView.id), "\".")));
|
|
962
|
+
console.log("You can inspect the Custom View data in the Merchant Center at \"".concat(chalk__default["default"].gray(customViewLink), "\"."));
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
965
|
+
const customViewLink = getMcUrlLink({
|
|
966
|
+
mcApiUrl,
|
|
967
|
+
organizationId: fetchedCustomView.organizationId,
|
|
968
|
+
customEntityId: (fetchedCustomView === null || fetchedCustomView === void 0 || (_fetchedCustomView$cu = fetchedCustomView.customView) === null || _fetchedCustomView$cu === void 0 ? void 0 : _fetchedCustomView$cu.id) || '',
|
|
969
|
+
isCustomView: true
|
|
970
|
+
});
|
|
971
|
+
const configDiff = getCustomViewConfigDiff(fetchedCustomView.customView, localCustomEntityData);
|
|
972
|
+
if (!configDiff) {
|
|
973
|
+
console.log(chalk__default["default"].green("Custom View up-to-date."));
|
|
974
|
+
console.log("You can inspect the Custom View data in the Merchant Center at \"".concat(chalk__default["default"].gray(customViewLink), "\"."));
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
console.log('Changes detected:');
|
|
978
|
+
console.log(configDiff);
|
|
979
|
+
console.log();
|
|
980
|
+
const _await$prompts6 = await prompts__default["default"]({
|
|
981
|
+
type: 'text',
|
|
982
|
+
name: 'confirmation',
|
|
983
|
+
message: _filterInstanceProperty__default["default"](_context9 = ["You are about to update the Custom View \"".concat(chalk__default["default"].green(localCustomEntityData.defaultLabel), "\" with the changes above. Are you sure you want to proceed?"), options.dryRun && chalk__default["default"].gray('Using "--dry-run", no data will be updated.')]).call(_context9, Boolean).join('\n'),
|
|
984
|
+
initial: 'yes'
|
|
985
|
+
}),
|
|
986
|
+
confirmation = _await$prompts6.confirmation;
|
|
987
|
+
if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
|
|
988
|
+
console.log(chalk__default["default"].red('Aborted.'));
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
991
|
+
const data = omit__default["default"](localCustomEntityData, ['id']);
|
|
992
|
+
if (options.dryRun) {
|
|
993
|
+
console.log();
|
|
994
|
+
console.log("The following payload would be used to update the Custom View \"".concat(chalk__default["default"].green(data.defaultLabel), "\"."));
|
|
995
|
+
console.log();
|
|
996
|
+
console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
|
|
997
|
+
return;
|
|
998
|
+
}
|
|
999
|
+
await updateCustomView({
|
|
1000
|
+
mcApiUrl,
|
|
1001
|
+
organizationId: fetchedCustomView.organizationId,
|
|
1002
|
+
data: omit__default["default"](localCustomEntityData, ['id']),
|
|
1003
|
+
customViewId: (fetchedCustomView === null || fetchedCustomView === void 0 || (_fetchedCustomView$cu2 = fetchedCustomView.customView) === null || _fetchedCustomView$cu2 === void 0 ? void 0 : _fetchedCustomView$cu2.id) || '',
|
|
1004
|
+
applicationIdentifier
|
|
1005
|
+
});
|
|
1006
|
+
console.log(chalk__default["default"].green("Custom View updated."));
|
|
1007
|
+
console.log("You can inspect the Custom View data in the Merchant Center at \"".concat(chalk__default["default"].gray(customViewLink), "\"."));
|
|
1008
|
+
}
|
|
1009
|
+
async function run(options) {
|
|
1010
|
+
const applicationConfig$1 = applicationConfig.processConfig();
|
|
1011
|
+
const localCustomEntityData = applicationConfig$1.data;
|
|
1012
|
+
const _applicationConfig$en = applicationConfig$1.env,
|
|
1013
|
+
mcApiUrl = _applicationConfig$en.mcApiUrl,
|
|
1014
|
+
applicationIdentifier = _applicationConfig$en.applicationIdentifier,
|
|
1015
|
+
customViewId = _applicationConfig$en.customViewId;
|
|
1016
|
+
console.log("Using Merchant Center environment \"".concat(chalk__default["default"].green(mcApiUrl), "\"."));
|
|
1017
|
+
console.log();
|
|
1018
|
+
const isSessionValid = credentialsStorage.isSessionValid(mcApiUrl);
|
|
1019
|
+
if (!isSessionValid) {
|
|
1020
|
+
throw new Error("You don't have a valid session. Please, run the \"mc-scripts login\" command to authenticate yourself.");
|
|
1021
|
+
}
|
|
1022
|
+
if (isCustomViewData(localCustomEntityData)) {
|
|
1023
|
+
createOrUpdateCustomView({
|
|
1024
|
+
mcApiUrl,
|
|
1025
|
+
localCustomEntityData,
|
|
1026
|
+
applicationIdentifier,
|
|
1027
|
+
customViewId: customViewId || localCustomEntityData.id,
|
|
1028
|
+
options
|
|
1029
|
+
});
|
|
1030
|
+
} else {
|
|
1031
|
+
createOrUpdateCustomApplication({
|
|
1032
|
+
mcApiUrl,
|
|
1033
|
+
localCustomEntityData,
|
|
1034
|
+
applicationIdentifier,
|
|
1035
|
+
options
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
684
1039
|
|
|
685
1040
|
exports["default"] = run;
|