@commercetools-frontend/mc-scripts 22.10.0 → 22.12.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-b9c0d101.cjs.prod.js → build-489541f5.cjs.prod.js} +3 -3
- package/dist/{build-d572e4d0.cjs.dev.js → build-b80c68eb.cjs.dev.js} +3 -3
- package/dist/{build-f7d1a55f.esm.js → build-e93f0b16.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-29567764.esm.js → config-sync-818102f8.esm.js} +417 -62
- package/dist/{config-sync-6e678b3e.cjs.prod.js → config-sync-a70b8c52.cjs.prod.js} +417 -62
- package/dist/{config-sync-ea329157.cjs.dev.js → config-sync-b5447370.cjs.dev.js} +417 -62
- package/dist/{create-postcss-config-86ded5e8.cjs.prod.js → create-postcss-config-1fff4dde.cjs.prod.js} +1 -1
- package/dist/{create-postcss-config-b37cb672.esm.js → create-postcss-config-322d504d.esm.js} +1 -1
- package/dist/{create-postcss-config-7e54b9f6.cjs.dev.js → create-postcss-config-42216959.cjs.dev.js} +1 -1
- package/dist/{create-webpack-config-for-development-7fa2427e.cjs.prod.js → create-webpack-config-for-development-34d06566.cjs.prod.js} +1 -1
- package/dist/{create-webpack-config-for-development-223e9634.cjs.dev.js → create-webpack-config-for-development-bc2fb523.cjs.dev.js} +1 -1
- package/dist/{create-webpack-config-for-development-df81ac0d.esm.js → create-webpack-config-for-development-f7389c77.esm.js} +1 -1
- package/dist/{create-webpack-config-for-production-e904023a.cjs.dev.js → create-webpack-config-for-production-6c10ccef.cjs.dev.js} +1 -1
- package/dist/{create-webpack-config-for-production-c205723c.esm.js → create-webpack-config-for-production-6da42593.esm.js} +1 -1
- package/dist/{create-webpack-config-for-production-1f28a3a5.cjs.prod.js → create-webpack-config-for-production-c40b38c8.cjs.prod.js} +1 -1
- package/dist/{credentials-storage-fdc779bd.cjs.prod.js → credentials-storage-25682f8d.cjs.prod.js} +1 -1
- package/dist/{credentials-storage-ceebe3d6.esm.js → credentials-storage-43bb26bd.esm.js} +1 -1
- package/dist/{credentials-storage-c7246dd8.cjs.dev.js → credentials-storage-e10137cb.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-ebbcb16c.esm.js → login-28250cee.esm.js} +2 -2
- package/dist/{login-97f2f0c7.cjs.prod.js → login-c43556da.cjs.prod.js} +2 -2
- package/dist/{login-7ca0e49c.cjs.dev.js → login-d739ae8e.cjs.dev.js} +2 -2
- package/dist/{package-fa3883ad.esm.js → package-4cfa64b8.esm.js} +9 -8
- package/dist/{package-6d6a1a22.cjs.prod.js → package-e9928170.cjs.prod.js} +9 -8
- package/dist/{package-d0071548.cjs.dev.js → package-fb2173eb.cjs.dev.js} +9 -8
- package/dist/{start-be031d3b.esm.js → start-3250ff98.esm.js} +3 -3
- package/dist/{start-08be0010.cjs.dev.js → start-3dc562be.cjs.dev.js} +3 -3
- package/dist/{start-94fdabf0.cjs.prod.js → start-6eba0d48.cjs.prod.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
|
@@ -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-43bb26bd.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-4cfa64b8.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,7 +34,7 @@ import 'os';
|
|
|
34
34
|
import 'path';
|
|
35
35
|
|
|
36
36
|
function ownKeys$1(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
37
|
-
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
37
|
+
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(_context21 = ownKeys$1(Object(t), !0)).call(_context21, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context22 = ownKeys$1(Object(t))).call(_context22, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
38
38
|
|
|
39
39
|
// Since not all terminal supports colors, to make things more consistent for testing purposes,
|
|
40
40
|
// during tests the color used is appended before the string instead of coloring it.
|
|
@@ -193,9 +193,47 @@ const getLabelAllLocalesDiff = _ref5 => {
|
|
|
193
193
|
if (labelAllLocalesDiff.length > 1) return labelAllLocalesDiff.join('\n');
|
|
194
194
|
return null;
|
|
195
195
|
};
|
|
196
|
-
const
|
|
196
|
+
const getTypeSettingsDiff = _ref7 => {
|
|
197
|
+
var _context17;
|
|
197
198
|
let previousValue = _ref7.previousValue,
|
|
198
199
|
nextValue = _ref7.nextValue;
|
|
200
|
+
const nonNullablePreviousValue = previousValue || {};
|
|
201
|
+
const nonNullableNextValue = nextValue || {};
|
|
202
|
+
const indentLevel = 1;
|
|
203
|
+
const typeSettingsDiff = ["".concat(indent(indentLevel - 1), "type settings changed")];
|
|
204
|
+
_forEachInstanceProperty(_context17 = _Object$keys(nonNullablePreviousValue)).call(_context17, key => {
|
|
205
|
+
const typeSettingDiff = getStringDiff({
|
|
206
|
+
previousValue: nonNullablePreviousValue[key],
|
|
207
|
+
nextValue: nonNullableNextValue[key],
|
|
208
|
+
label: key,
|
|
209
|
+
indentLevel
|
|
210
|
+
});
|
|
211
|
+
if (typeSettingDiff) {
|
|
212
|
+
typeSettingsDiff.push(typeSettingDiff);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
if (typeSettingsDiff.length > 1) return typeSettingsDiff.join('\n');
|
|
216
|
+
return null;
|
|
217
|
+
};
|
|
218
|
+
const getLocatorsDiff = _ref8 => {
|
|
219
|
+
let previousValue = _ref8.previousValue,
|
|
220
|
+
nextValue = _ref8.nextValue;
|
|
221
|
+
const diff = [];
|
|
222
|
+
const locatorsDiff = getArrayDiff({
|
|
223
|
+
previousValue: previousValue,
|
|
224
|
+
nextValue: nextValue,
|
|
225
|
+
label: 'locators',
|
|
226
|
+
indentLevel: 1
|
|
227
|
+
});
|
|
228
|
+
if (locatorsDiff) {
|
|
229
|
+
diff.push('locators changed');
|
|
230
|
+
diff.push(locatorsDiff);
|
|
231
|
+
}
|
|
232
|
+
return diff.join('\n');
|
|
233
|
+
};
|
|
234
|
+
const getMainMenuLinkDiff = _ref9 => {
|
|
235
|
+
let previousValue = _ref9.previousValue,
|
|
236
|
+
nextValue = _ref9.nextValue;
|
|
199
237
|
const mainMenuLinkDiff = ['mainMenuLink changed'];
|
|
200
238
|
const menuDiff = getStringDiff({
|
|
201
239
|
previousValue: previousValue.defaultLabel,
|
|
@@ -228,10 +266,10 @@ const getMainMenuLinkDiff = _ref7 => {
|
|
|
228
266
|
if (filteredMainMenuLinkDiff.length > 1) return filteredMainMenuLinkDiff.join('\n');
|
|
229
267
|
return null;
|
|
230
268
|
};
|
|
231
|
-
const getSubmenuLinksDiff =
|
|
232
|
-
var
|
|
233
|
-
let previousValue =
|
|
234
|
-
nextValue =
|
|
269
|
+
const getSubmenuLinksDiff = _ref10 => {
|
|
270
|
+
var _context20;
|
|
271
|
+
let previousValue = _ref10.previousValue,
|
|
272
|
+
nextValue = _ref10.nextValue;
|
|
235
273
|
const submenuLinksDiff = ['submenuLink changed'];
|
|
236
274
|
const mappedSubmenuLinks = _reduceInstanceProperty(previousValue).call(previousValue, (previousSubmenuLink, currentSubmenuLink) => _objectSpread$1(_objectSpread$1({}, previousSubmenuLink), {}, {
|
|
237
275
|
[currentSubmenuLink.uriPath]: currentSubmenuLink
|
|
@@ -239,9 +277,9 @@ const getSubmenuLinksDiff = _ref8 => {
|
|
|
239
277
|
_forEachInstanceProperty(nextValue).call(nextValue, newSubmenuLink => {
|
|
240
278
|
const oldSubMenuLink = mappedSubmenuLinks[newSubmenuLink.uriPath];
|
|
241
279
|
if (newSubmenuLink.uriPath in mappedSubmenuLinks) {
|
|
242
|
-
var
|
|
243
|
-
const submenuLinkDiff = [_concatInstanceProperty(
|
|
244
|
-
_forEachInstanceProperty(
|
|
280
|
+
var _context18, _context19;
|
|
281
|
+
const submenuLinkDiff = [_concatInstanceProperty(_context18 = "".concat(indent(1), "menu link \"")).call(_context18, newSubmenuLink.uriPath, "\" changed")];
|
|
282
|
+
_forEachInstanceProperty(_context19 = _Object$keys(mappedSubmenuLinks[newSubmenuLink.uriPath])).call(_context19, key => {
|
|
245
283
|
switch (key) {
|
|
246
284
|
case 'defaultLabel':
|
|
247
285
|
{
|
|
@@ -300,7 +338,7 @@ const getSubmenuLinksDiff = _ref8 => {
|
|
|
300
338
|
}
|
|
301
339
|
}
|
|
302
340
|
});
|
|
303
|
-
_forEachInstanceProperty(
|
|
341
|
+
_forEachInstanceProperty(_context20 = _Object$keys(mappedSubmenuLinks)).call(_context20, key => {
|
|
304
342
|
const linksDiff = getStringDiff({
|
|
305
343
|
previousValue: key,
|
|
306
344
|
label: 'menu link',
|
|
@@ -314,7 +352,7 @@ const getSubmenuLinksDiff = _ref8 => {
|
|
|
314
352
|
|
|
315
353
|
// Compute diff changes of the Custom Application config.
|
|
316
354
|
// NOTE: Only known keys are evaluated.
|
|
317
|
-
const
|
|
355
|
+
const getCustomApplicationConfigDiff = (oldConfig, newConfig) => {
|
|
318
356
|
const diff = [];
|
|
319
357
|
|
|
320
358
|
// Name
|
|
@@ -389,12 +427,99 @@ const getConfigDiff = (oldConfig, newConfig) => {
|
|
|
389
427
|
return diff.join('\n');
|
|
390
428
|
};
|
|
391
429
|
|
|
430
|
+
// Compute diff changes of the Custom View config.
|
|
431
|
+
// NOTE: Only known keys are evaluated.
|
|
432
|
+
const getCustomViewConfigDiff = (oldConfig, newConfig) => {
|
|
433
|
+
const diff = [];
|
|
434
|
+
|
|
435
|
+
// Default Label
|
|
436
|
+
const defaultLabelDiff = getStringDiff({
|
|
437
|
+
previousValue: oldConfig.defaultLabel,
|
|
438
|
+
nextValue: newConfig.defaultLabel,
|
|
439
|
+
label: 'defaultLabel'
|
|
440
|
+
});
|
|
441
|
+
if (defaultLabelDiff) {
|
|
442
|
+
diff.push(defaultLabelDiff);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// Description
|
|
446
|
+
const descriptionDiff = getStringDiff({
|
|
447
|
+
previousValue: oldConfig.description,
|
|
448
|
+
nextValue: newConfig.description,
|
|
449
|
+
label: 'description'
|
|
450
|
+
});
|
|
451
|
+
if (descriptionDiff) {
|
|
452
|
+
diff.push(descriptionDiff);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// URL
|
|
456
|
+
const urlDiff = getStringDiff({
|
|
457
|
+
previousValue: oldConfig.url,
|
|
458
|
+
nextValue: newConfig.url,
|
|
459
|
+
label: 'url'
|
|
460
|
+
});
|
|
461
|
+
if (urlDiff) {
|
|
462
|
+
diff.push(urlDiff);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// Type
|
|
466
|
+
const typeDiff = getStringDiff({
|
|
467
|
+
previousValue: oldConfig.type,
|
|
468
|
+
nextValue: newConfig.type,
|
|
469
|
+
label: 'type'
|
|
470
|
+
});
|
|
471
|
+
if (typeDiff) {
|
|
472
|
+
diff.push(typeDiff);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
// Permissions
|
|
476
|
+
const permissionsDiff = getPermissionsDiff({
|
|
477
|
+
previousValue: oldConfig.permissions,
|
|
478
|
+
nextValue: newConfig.permissions
|
|
479
|
+
});
|
|
480
|
+
if (permissionsDiff) {
|
|
481
|
+
diff.push(permissionsDiff);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// Label All Locales
|
|
485
|
+
const labelsDiff = getLabelAllLocalesDiff({
|
|
486
|
+
previousValue: oldConfig.labelAllLocales,
|
|
487
|
+
nextValue: newConfig.labelAllLocales,
|
|
488
|
+
indentLevel: 1
|
|
489
|
+
});
|
|
490
|
+
if (labelsDiff) {
|
|
491
|
+
diff.push(labelsDiff);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
// Type settings
|
|
495
|
+
const typeSettingsDiff = getTypeSettingsDiff({
|
|
496
|
+
previousValue: oldConfig.typeSettings,
|
|
497
|
+
nextValue: newConfig.typeSettings
|
|
498
|
+
});
|
|
499
|
+
if (typeSettingsDiff) {
|
|
500
|
+
diff.push(typeSettingsDiff);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// Locators
|
|
504
|
+
const locatorsDiff = getLocatorsDiff({
|
|
505
|
+
previousValue: oldConfig.locators,
|
|
506
|
+
nextValue: newConfig.locators
|
|
507
|
+
});
|
|
508
|
+
if (locatorsDiff) {
|
|
509
|
+
diff.push(locatorsDiff);
|
|
510
|
+
}
|
|
511
|
+
return diff.join('\n');
|
|
512
|
+
};
|
|
513
|
+
|
|
392
514
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
393
515
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
394
516
|
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 } } } };
|
|
517
|
+
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 } } } };
|
|
395
518
|
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 } } } };
|
|
519
|
+
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 } } } };
|
|
396
520
|
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 } } } };
|
|
397
521
|
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 } } } };
|
|
522
|
+
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 } } } };
|
|
398
523
|
const credentialsStorage$1 = new CredentialsStorage();
|
|
399
524
|
async function requestWithTokenRetry(document, requestOptions) {
|
|
400
525
|
let retryCount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
@@ -462,12 +587,29 @@ const fetchCustomApplication = async _ref => {
|
|
|
462
587
|
});
|
|
463
588
|
return customAppData.organizationExtensionForCustomApplication;
|
|
464
589
|
};
|
|
465
|
-
const
|
|
590
|
+
const fetchCustomView = async _ref2 => {
|
|
466
591
|
let mcApiUrl = _ref2.mcApiUrl,
|
|
467
|
-
|
|
468
|
-
organizationId = _ref2.organizationId,
|
|
469
|
-
data = _ref2.data,
|
|
592
|
+
customViewId = _ref2.customViewId,
|
|
470
593
|
applicationIdentifier = _ref2.applicationIdentifier;
|
|
594
|
+
const customViewData = await requestWithTokenRetry(FetchCustomViewFromCli, {
|
|
595
|
+
variables: {
|
|
596
|
+
customViewId
|
|
597
|
+
},
|
|
598
|
+
mcApiUrl,
|
|
599
|
+
headers: {
|
|
600
|
+
'x-custom-view-id': customViewId,
|
|
601
|
+
'x-application-id': applicationIdentifier,
|
|
602
|
+
'x-graphql-target': GRAPHQL_TARGETS.SETTINGS_SERVICE
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
return customViewData.organizationExtensionForCustomView;
|
|
606
|
+
};
|
|
607
|
+
const updateCustomApplication = async _ref3 => {
|
|
608
|
+
let mcApiUrl = _ref3.mcApiUrl,
|
|
609
|
+
applicationId = _ref3.applicationId,
|
|
610
|
+
organizationId = _ref3.organizationId,
|
|
611
|
+
data = _ref3.data,
|
|
612
|
+
applicationIdentifier = _ref3.applicationIdentifier;
|
|
471
613
|
const updatedCustomAppsData = await requestWithTokenRetry(UpdateCustomApplicationFromCli, {
|
|
472
614
|
variables: {
|
|
473
615
|
organizationId,
|
|
@@ -482,11 +624,32 @@ const updateCustomApplication = async _ref2 => {
|
|
|
482
624
|
});
|
|
483
625
|
return updatedCustomAppsData.updateCustomApplication;
|
|
484
626
|
};
|
|
485
|
-
const
|
|
486
|
-
let mcApiUrl =
|
|
487
|
-
organizationId =
|
|
488
|
-
data =
|
|
489
|
-
|
|
627
|
+
const updateCustomView = async _ref4 => {
|
|
628
|
+
let mcApiUrl = _ref4.mcApiUrl,
|
|
629
|
+
organizationId = _ref4.organizationId,
|
|
630
|
+
data = _ref4.data,
|
|
631
|
+
customViewId = _ref4.customViewId,
|
|
632
|
+
applicationIdentifier = _ref4.applicationIdentifier;
|
|
633
|
+
const updatedCustomViewData = await requestWithTokenRetry(UpdateCustomViewFromCli, {
|
|
634
|
+
variables: {
|
|
635
|
+
organizationId,
|
|
636
|
+
customViewId,
|
|
637
|
+
data
|
|
638
|
+
},
|
|
639
|
+
mcApiUrl,
|
|
640
|
+
headers: {
|
|
641
|
+
'x-custom-view-id': customViewId,
|
|
642
|
+
'x-application-id': applicationIdentifier,
|
|
643
|
+
'x-graphql-target': GRAPHQL_TARGETS.SETTINGS_SERVICE
|
|
644
|
+
}
|
|
645
|
+
});
|
|
646
|
+
return updatedCustomViewData.updateCustomView;
|
|
647
|
+
};
|
|
648
|
+
const createCustomApplication = async _ref5 => {
|
|
649
|
+
let mcApiUrl = _ref5.mcApiUrl,
|
|
650
|
+
organizationId = _ref5.organizationId,
|
|
651
|
+
data = _ref5.data,
|
|
652
|
+
applicationIdentifier = _ref5.applicationIdentifier;
|
|
490
653
|
const createdCustomAppData = await requestWithTokenRetry(CreateCustomApplicationFromCli, {
|
|
491
654
|
variables: {
|
|
492
655
|
organizationId,
|
|
@@ -500,50 +663,66 @@ const createCustomApplication = async _ref3 => {
|
|
|
500
663
|
});
|
|
501
664
|
return createdCustomAppData.createCustomApplication;
|
|
502
665
|
};
|
|
503
|
-
const
|
|
504
|
-
let mcApiUrl =
|
|
505
|
-
|
|
506
|
-
|
|
666
|
+
const createCustomView = async _ref6 => {
|
|
667
|
+
let mcApiUrl = _ref6.mcApiUrl,
|
|
668
|
+
organizationId = _ref6.organizationId,
|
|
669
|
+
data = _ref6.data,
|
|
670
|
+
applicationIdentifier = _ref6.applicationIdentifier;
|
|
671
|
+
const createdCustomViewData = await requestWithTokenRetry(CreateCustomViewFromCli, {
|
|
672
|
+
variables: {
|
|
673
|
+
organizationId,
|
|
674
|
+
data
|
|
675
|
+
},
|
|
507
676
|
mcApiUrl,
|
|
508
677
|
headers: {
|
|
509
678
|
'x-application-id': applicationIdentifier,
|
|
510
|
-
'x-graphql-target': GRAPHQL_TARGETS.
|
|
679
|
+
'x-graphql-target': GRAPHQL_TARGETS.SETTINGS_SERVICE
|
|
511
680
|
}
|
|
512
681
|
});
|
|
682
|
+
return createdCustomViewData.createCustomView;
|
|
683
|
+
};
|
|
684
|
+
const fetchUserOrganizations = async _ref7 => {
|
|
685
|
+
let mcApiUrl = _ref7.mcApiUrl,
|
|
686
|
+
applicationIdentifier = _ref7.applicationIdentifier,
|
|
687
|
+
customViewId = _ref7.customViewId;
|
|
688
|
+
const userOrganizations = await requestWithTokenRetry(FetchMyOrganizationsFromCli, {
|
|
689
|
+
mcApiUrl,
|
|
690
|
+
headers: _objectSpread(_objectSpread({
|
|
691
|
+
'x-application-id': applicationIdentifier
|
|
692
|
+
}, customViewId && {
|
|
693
|
+
'x-custom-view-id': customViewId
|
|
694
|
+
}), {}, {
|
|
695
|
+
'x-graphql-target': GRAPHQL_TARGETS.ADMINISTRATION_SERVICE
|
|
696
|
+
})
|
|
697
|
+
});
|
|
513
698
|
return userOrganizations.myOrganizations;
|
|
514
699
|
};
|
|
515
700
|
|
|
516
701
|
const credentialsStorage = new CredentialsStorage();
|
|
517
|
-
const getMcUrlLink =
|
|
518
|
-
var _context, _context2;
|
|
702
|
+
const getMcUrlLink = _ref => {
|
|
703
|
+
var _context, _context2, _context3;
|
|
704
|
+
let mcApiUrl = _ref.mcApiUrl,
|
|
705
|
+
organizationId = _ref.organizationId,
|
|
706
|
+
customEntityId = _ref.customEntityId,
|
|
707
|
+
isCustomView = _ref.isCustomView;
|
|
519
708
|
const mcUrl = mcApiUrl.replace('mc-api', 'mc');
|
|
520
|
-
const
|
|
521
|
-
return
|
|
709
|
+
const customEntityLink = _concatInstanceProperty(_context = _concatInstanceProperty(_context2 = _concatInstanceProperty(_context3 = "".concat(mcUrl, "/account/organizations/")).call(_context3, organizationId, "/custom-")).call(_context2, isCustomView ? 'views' : 'applications', "/owned/")).call(_context, customEntityId);
|
|
710
|
+
return customEntityLink;
|
|
522
711
|
};
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
customViewId = _applicationConfig$en.customViewId;
|
|
531
|
-
if (customViewId) {
|
|
532
|
-
throw new Error("Syncing the configuration for Custom Views is not supported at the moment.");
|
|
533
|
-
}
|
|
534
|
-
console.log("Using Merchant Center environment \"".concat(chalk.green(mcApiUrl), "\"."));
|
|
535
|
-
console.log();
|
|
536
|
-
const isSessionValid = credentialsStorage.isSessionValid(mcApiUrl);
|
|
537
|
-
if (!isSessionValid) {
|
|
538
|
-
throw new Error("You don't have a valid session. Please, run the \"mc-scripts login\" command to authenticate yourself.");
|
|
539
|
-
}
|
|
712
|
+
const isCustomViewData = data => data.entryPointUriPath === undefined;
|
|
713
|
+
async function createOrUpdateCustomApplication(_ref2) {
|
|
714
|
+
var _context6;
|
|
715
|
+
let mcApiUrl = _ref2.mcApiUrl,
|
|
716
|
+
localCustomEntityData = _ref2.localCustomEntityData,
|
|
717
|
+
applicationIdentifier = _ref2.applicationIdentifier,
|
|
718
|
+
options = _ref2.options;
|
|
540
719
|
const fetchedCustomApplication = await fetchCustomApplication({
|
|
541
720
|
mcApiUrl,
|
|
542
|
-
entryPointUriPath:
|
|
721
|
+
entryPointUriPath: localCustomEntityData.entryPointUriPath,
|
|
543
722
|
applicationIdentifier
|
|
544
723
|
});
|
|
545
724
|
if (!fetchedCustomApplication) {
|
|
546
|
-
var
|
|
725
|
+
var _context5;
|
|
547
726
|
const userOrganizations = await fetchUserOrganizations({
|
|
548
727
|
mcApiUrl,
|
|
549
728
|
applicationIdentifier
|
|
@@ -558,8 +737,8 @@ async function run(options) {
|
|
|
558
737
|
organizationId = organization.id;
|
|
559
738
|
organizationName = organization.name;
|
|
560
739
|
} else {
|
|
561
|
-
var
|
|
562
|
-
const organizationChoices = _mapInstanceProperty(
|
|
740
|
+
var _context4;
|
|
741
|
+
const organizationChoices = _mapInstanceProperty(_context4 = userOrganizations.results).call(_context4, organization => ({
|
|
563
742
|
title: organization.name,
|
|
564
743
|
value: organization.id
|
|
565
744
|
}));
|
|
@@ -575,15 +754,15 @@ async function run(options) {
|
|
|
575
754
|
throw new Error("No Organization selected, aborting.");
|
|
576
755
|
}
|
|
577
756
|
organizationId = selectedOrganizationId;
|
|
578
|
-
organizationName = _findInstanceProperty(organizationChoices).call(organizationChoices,
|
|
579
|
-
let value =
|
|
757
|
+
organizationName = _findInstanceProperty(organizationChoices).call(organizationChoices, _ref3 => {
|
|
758
|
+
let value = _ref3.value;
|
|
580
759
|
return value === organizationId;
|
|
581
760
|
}).title;
|
|
582
761
|
}
|
|
583
762
|
const _await$prompts2 = await prompts({
|
|
584
763
|
type: 'text',
|
|
585
764
|
name: 'confirmation',
|
|
586
|
-
message: _filterInstanceProperty(
|
|
765
|
+
message: _filterInstanceProperty(_context5 = ["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(_context5, Boolean).join('\n'),
|
|
587
766
|
initial: 'yes'
|
|
588
767
|
}),
|
|
589
768
|
confirmation = _await$prompts2.confirmation;
|
|
@@ -591,7 +770,7 @@ async function run(options) {
|
|
|
591
770
|
console.log(chalk.red('Aborted.'));
|
|
592
771
|
return;
|
|
593
772
|
}
|
|
594
|
-
const data = omit(
|
|
773
|
+
const data = omit(localCustomEntityData, ['id']);
|
|
595
774
|
if (options.dryRun) {
|
|
596
775
|
console.log();
|
|
597
776
|
console.log("The following payload would be used to create a new Custom Application.");
|
|
@@ -613,13 +792,21 @@ async function run(options) {
|
|
|
613
792
|
if (!createdCustomApplication) {
|
|
614
793
|
throw new Error('Failed to create the Custom Application.');
|
|
615
794
|
}
|
|
616
|
-
const customAppLink = getMcUrlLink(
|
|
795
|
+
const customAppLink = getMcUrlLink({
|
|
796
|
+
mcApiUrl,
|
|
797
|
+
organizationId,
|
|
798
|
+
customEntityId: createdCustomApplication.id
|
|
799
|
+
});
|
|
617
800
|
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), "\".")));
|
|
618
801
|
console.log("You can inspect the Custom Application data in the Merchant Center at \"".concat(chalk.gray(customAppLink), "\"."));
|
|
619
802
|
return;
|
|
620
803
|
}
|
|
621
|
-
const customAppLink = getMcUrlLink(
|
|
622
|
-
|
|
804
|
+
const customAppLink = getMcUrlLink({
|
|
805
|
+
mcApiUrl,
|
|
806
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
807
|
+
customEntityId: fetchedCustomApplication.application.id
|
|
808
|
+
});
|
|
809
|
+
const configDiff = getCustomApplicationConfigDiff(fetchedCustomApplication.application, localCustomEntityData);
|
|
623
810
|
if (!configDiff) {
|
|
624
811
|
console.log(chalk.green("Custom Application up-to-date."));
|
|
625
812
|
console.log("You can inspect the Custom Application data in the Merchant Center at \"".concat(chalk.gray(customAppLink), "\"."));
|
|
@@ -631,7 +818,7 @@ async function run(options) {
|
|
|
631
818
|
const _await$prompts3 = await prompts({
|
|
632
819
|
type: 'text',
|
|
633
820
|
name: 'confirmation',
|
|
634
|
-
message: _filterInstanceProperty(
|
|
821
|
+
message: _filterInstanceProperty(_context6 = ["You are about to update the Custom Application \"".concat(chalk.green(localCustomEntityData.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(_context6, Boolean).join('\n'),
|
|
635
822
|
initial: 'yes'
|
|
636
823
|
}),
|
|
637
824
|
confirmation = _await$prompts3.confirmation;
|
|
@@ -639,7 +826,7 @@ async function run(options) {
|
|
|
639
826
|
console.log(chalk.red('Aborted.'));
|
|
640
827
|
return;
|
|
641
828
|
}
|
|
642
|
-
const data = omit(
|
|
829
|
+
const data = omit(localCustomEntityData, ['id']);
|
|
643
830
|
if (options.dryRun) {
|
|
644
831
|
console.log();
|
|
645
832
|
console.log("The following payload would be used to update the Custom Application \"".concat(chalk.green(data.entryPointUriPath), "\"."));
|
|
@@ -650,12 +837,180 @@ async function run(options) {
|
|
|
650
837
|
await updateCustomApplication({
|
|
651
838
|
mcApiUrl,
|
|
652
839
|
organizationId: fetchedCustomApplication.organizationId,
|
|
653
|
-
data: omit(
|
|
840
|
+
data: omit(localCustomEntityData, ['id']),
|
|
654
841
|
applicationId: fetchedCustomApplication.application.id,
|
|
655
842
|
applicationIdentifier
|
|
656
843
|
});
|
|
657
844
|
console.log(chalk.green("Custom Application updated."));
|
|
658
845
|
console.log("You can inspect the Custom Application data in the Merchant Center at \"".concat(chalk.gray(customAppLink), "\"."));
|
|
659
846
|
}
|
|
847
|
+
async function createOrUpdateCustomView(_ref4) {
|
|
848
|
+
var _fetchedCustomView$cu, _context9, _fetchedCustomView$cu2;
|
|
849
|
+
let mcApiUrl = _ref4.mcApiUrl,
|
|
850
|
+
localCustomEntityData = _ref4.localCustomEntityData,
|
|
851
|
+
customViewId = _ref4.customViewId,
|
|
852
|
+
options = _ref4.options,
|
|
853
|
+
applicationIdentifier = _ref4.applicationIdentifier;
|
|
854
|
+
const fetchedCustomView = await fetchCustomView({
|
|
855
|
+
mcApiUrl,
|
|
856
|
+
customViewId,
|
|
857
|
+
applicationIdentifier
|
|
858
|
+
});
|
|
859
|
+
if (!fetchedCustomView) {
|
|
860
|
+
var _context8;
|
|
861
|
+
const userOrganizations = await fetchUserOrganizations({
|
|
862
|
+
mcApiUrl,
|
|
863
|
+
customViewId,
|
|
864
|
+
applicationIdentifier
|
|
865
|
+
});
|
|
866
|
+
let organizationId, organizationName;
|
|
867
|
+
if (userOrganizations.total === 0) {
|
|
868
|
+
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.");
|
|
869
|
+
}
|
|
870
|
+
if (userOrganizations.total === 1) {
|
|
871
|
+
const _userOrganizations$re2 = _slicedToArray(userOrganizations.results, 1),
|
|
872
|
+
organization = _userOrganizations$re2[0];
|
|
873
|
+
organizationId = organization.id;
|
|
874
|
+
organizationName = organization.name;
|
|
875
|
+
} else {
|
|
876
|
+
var _context7;
|
|
877
|
+
const organizationChoices = _mapInstanceProperty(_context7 = userOrganizations.results).call(_context7, organization => ({
|
|
878
|
+
title: organization.name,
|
|
879
|
+
value: organization.id
|
|
880
|
+
}));
|
|
881
|
+
const _await$prompts4 = await prompts({
|
|
882
|
+
type: 'select',
|
|
883
|
+
name: 'organizationId',
|
|
884
|
+
message: 'Select an Organization',
|
|
885
|
+
choices: organizationChoices,
|
|
886
|
+
initial: 0
|
|
887
|
+
}),
|
|
888
|
+
selectedOrganizationId = _await$prompts4.organizationId;
|
|
889
|
+
if (!selectedOrganizationId) {
|
|
890
|
+
throw new Error("No Organization selected, aborting.");
|
|
891
|
+
}
|
|
892
|
+
organizationId = selectedOrganizationId;
|
|
893
|
+
organizationName = _findInstanceProperty(organizationChoices).call(organizationChoices, _ref5 => {
|
|
894
|
+
let value = _ref5.value;
|
|
895
|
+
return value === organizationId;
|
|
896
|
+
}).title;
|
|
897
|
+
}
|
|
898
|
+
const _await$prompts5 = await prompts({
|
|
899
|
+
type: 'text',
|
|
900
|
+
name: 'confirmation',
|
|
901
|
+
message: _filterInstanceProperty(_context8 = ["You are about to create a new Custom View 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(_context8, Boolean).join('\n'),
|
|
902
|
+
initial: 'yes'
|
|
903
|
+
}),
|
|
904
|
+
confirmation = _await$prompts5.confirmation;
|
|
905
|
+
if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
|
|
906
|
+
console.log(chalk.red('Aborted.'));
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
909
|
+
const data = omit(localCustomEntityData, ['id']);
|
|
910
|
+
if (options.dryRun) {
|
|
911
|
+
console.log();
|
|
912
|
+
console.log("The following payload would be used to create a new Custom View.");
|
|
913
|
+
console.log();
|
|
914
|
+
console.log(chalk.gray(_JSON$stringify(data, null, 2)));
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
const createdCustomView = await createCustomView({
|
|
918
|
+
mcApiUrl,
|
|
919
|
+
organizationId,
|
|
920
|
+
data,
|
|
921
|
+
applicationIdentifier
|
|
922
|
+
});
|
|
923
|
+
|
|
924
|
+
// This check is technically not necessary, as the `graphql-request` client
|
|
925
|
+
// throws an error in case of GraphQL errors.
|
|
926
|
+
// However, the generated TypeScript data related to the GraphQL query has the
|
|
927
|
+
// field typed as optional, thus having an extra check for type correctness.
|
|
928
|
+
if (!createdCustomView) {
|
|
929
|
+
throw new Error('Failed to create the Custom View.');
|
|
930
|
+
}
|
|
931
|
+
const customViewLink = getMcUrlLink({
|
|
932
|
+
mcApiUrl,
|
|
933
|
+
organizationId,
|
|
934
|
+
customEntityId: createdCustomView.id,
|
|
935
|
+
isCustomView: true
|
|
936
|
+
});
|
|
937
|
+
console.log(chalk.green("Custom View created.\nPlease update the \"env.production.customViewId\" field in your local Custom View config file with the following value: \"".concat(chalk.green(createdCustomView.id), "\".")));
|
|
938
|
+
console.log("You can inspect the Custom View data in the Merchant Center at \"".concat(chalk.gray(customViewLink), "\"."));
|
|
939
|
+
return;
|
|
940
|
+
}
|
|
941
|
+
const customViewLink = getMcUrlLink({
|
|
942
|
+
mcApiUrl,
|
|
943
|
+
organizationId: fetchedCustomView.organizationId,
|
|
944
|
+
customEntityId: (fetchedCustomView === null || fetchedCustomView === void 0 || (_fetchedCustomView$cu = fetchedCustomView.customView) === null || _fetchedCustomView$cu === void 0 ? void 0 : _fetchedCustomView$cu.id) || '',
|
|
945
|
+
isCustomView: true
|
|
946
|
+
});
|
|
947
|
+
const configDiff = getCustomViewConfigDiff(fetchedCustomView.customView, localCustomEntityData);
|
|
948
|
+
if (!configDiff) {
|
|
949
|
+
console.log(chalk.green("Custom View up-to-date."));
|
|
950
|
+
console.log("You can inspect the Custom View data in the Merchant Center at \"".concat(chalk.gray(customViewLink), "\"."));
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
953
|
+
console.log('Changes detected:');
|
|
954
|
+
console.log(configDiff);
|
|
955
|
+
console.log();
|
|
956
|
+
const _await$prompts6 = await prompts({
|
|
957
|
+
type: 'text',
|
|
958
|
+
name: 'confirmation',
|
|
959
|
+
message: _filterInstanceProperty(_context9 = ["You are about to update the Custom View \"".concat(chalk.green(localCustomEntityData.defaultLabel), "\" with the changes above. Are you sure you want to proceed?"), options.dryRun && chalk.gray('Using "--dry-run", no data will be updated.')]).call(_context9, Boolean).join('\n'),
|
|
960
|
+
initial: 'yes'
|
|
961
|
+
}),
|
|
962
|
+
confirmation = _await$prompts6.confirmation;
|
|
963
|
+
if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
|
|
964
|
+
console.log(chalk.red('Aborted.'));
|
|
965
|
+
return;
|
|
966
|
+
}
|
|
967
|
+
const data = omit(localCustomEntityData, ['id']);
|
|
968
|
+
if (options.dryRun) {
|
|
969
|
+
console.log();
|
|
970
|
+
console.log("The following payload would be used to update the Custom View \"".concat(chalk.green(data.defaultLabel), "\"."));
|
|
971
|
+
console.log();
|
|
972
|
+
console.log(chalk.gray(_JSON$stringify(data, null, 2)));
|
|
973
|
+
return;
|
|
974
|
+
}
|
|
975
|
+
await updateCustomView({
|
|
976
|
+
mcApiUrl,
|
|
977
|
+
organizationId: fetchedCustomView.organizationId,
|
|
978
|
+
data: omit(localCustomEntityData, ['id']),
|
|
979
|
+
customViewId: (fetchedCustomView === null || fetchedCustomView === void 0 || (_fetchedCustomView$cu2 = fetchedCustomView.customView) === null || _fetchedCustomView$cu2 === void 0 ? void 0 : _fetchedCustomView$cu2.id) || '',
|
|
980
|
+
applicationIdentifier
|
|
981
|
+
});
|
|
982
|
+
console.log(chalk.green("Custom View updated."));
|
|
983
|
+
console.log("You can inspect the Custom View data in the Merchant Center at \"".concat(chalk.gray(customViewLink), "\"."));
|
|
984
|
+
}
|
|
985
|
+
async function run(options) {
|
|
986
|
+
const applicationConfig = processConfig();
|
|
987
|
+
const localCustomEntityData = applicationConfig.data;
|
|
988
|
+
const _applicationConfig$en = applicationConfig.env,
|
|
989
|
+
mcApiUrl = _applicationConfig$en.mcApiUrl,
|
|
990
|
+
applicationIdentifier = _applicationConfig$en.applicationIdentifier,
|
|
991
|
+
customViewId = _applicationConfig$en.customViewId;
|
|
992
|
+
console.log("Using Merchant Center environment \"".concat(chalk.green(mcApiUrl), "\"."));
|
|
993
|
+
console.log();
|
|
994
|
+
const isSessionValid = credentialsStorage.isSessionValid(mcApiUrl);
|
|
995
|
+
if (!isSessionValid) {
|
|
996
|
+
throw new Error("You don't have a valid session. Please, run the \"mc-scripts login\" command to authenticate yourself.");
|
|
997
|
+
}
|
|
998
|
+
if (isCustomViewData(localCustomEntityData)) {
|
|
999
|
+
createOrUpdateCustomView({
|
|
1000
|
+
mcApiUrl,
|
|
1001
|
+
localCustomEntityData,
|
|
1002
|
+
applicationIdentifier,
|
|
1003
|
+
customViewId: customViewId || localCustomEntityData.id,
|
|
1004
|
+
options
|
|
1005
|
+
});
|
|
1006
|
+
} else {
|
|
1007
|
+
createOrUpdateCustomApplication({
|
|
1008
|
+
mcApiUrl,
|
|
1009
|
+
localCustomEntityData,
|
|
1010
|
+
applicationIdentifier,
|
|
1011
|
+
options
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
660
1015
|
|
|
661
1016
|
export { run as default };
|