@commercetools-frontend/mc-scripts 25.1.0 → 25.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +20 -7
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +20 -7
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +20 -7
- package/dist/{build-ec10df64.cjs.prod.js → build-182a099c.cjs.prod.js} +3 -3
- package/dist/{build-dbcd0936.esm.js → build-220a1658.esm.js} +3 -3
- package/dist/{build-0a5986d1.cjs.dev.js → build-519d246d.cjs.dev.js} +3 -3
- package/dist/{build-vite-16b1a575.cjs.dev.js → build-vite-837e7c94.cjs.dev.js} +56 -34
- package/dist/{build-vite-59e1f185.esm.js → build-vite-8cae71a0.esm.js} +53 -15
- package/dist/{build-vite-5d317720.cjs.prod.js → build-vite-b007241b.cjs.prod.js} +56 -34
- 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-0b96d430.esm.js +255 -0
- package/dist/config-sync-b3072939.cjs.prod.js +265 -0
- package/dist/config-sync-ci-4a09aa00.cjs.prod.js +305 -0
- package/dist/config-sync-ci-85e3fec2.esm.js +294 -0
- package/dist/config-sync-ci-eadb8bfc.cjs.dev.js +305 -0
- package/dist/config-sync-f8fca39f.cjs.dev.js +265 -0
- package/dist/{config-sync-ce05c66c.cjs.prod.js → config-sync-helpers-11fc328f.cjs.prod.js} +162 -287
- package/dist/{config-sync-dbb43993.cjs.dev.js → config-sync-helpers-dab59ed9.cjs.dev.js} +162 -287
- package/dist/{config-sync-e7f53a98.esm.js → config-sync-helpers-fe6ea729.esm.js} +154 -283
- package/dist/{create-postcss-config-91c09596.cjs.prod.js → create-postcss-config-56b74a34.cjs.prod.js} +1 -1
- package/dist/{create-postcss-config-381b636b.cjs.dev.js → create-postcss-config-78879a12.cjs.dev.js} +1 -1
- package/dist/{create-postcss-config-0a86560d.esm.js → create-postcss-config-95f9bf62.esm.js} +1 -1
- package/dist/{create-webpack-config-for-development-37677a49.cjs.prod.js → create-webpack-config-for-development-3eb1b365.cjs.prod.js} +2 -2
- package/dist/{create-webpack-config-for-development-488742b2.cjs.dev.js → create-webpack-config-for-development-62b89920.cjs.dev.js} +2 -2
- package/dist/{create-webpack-config-for-development-df3f7f7f.esm.js → create-webpack-config-for-development-a28736fa.esm.js} +2 -2
- package/dist/{create-webpack-config-for-production-e22f78d2.esm.js → create-webpack-config-for-production-21ea561f.esm.js} +2 -2
- package/dist/{create-webpack-config-for-production-aad64e2a.cjs.prod.js → create-webpack-config-for-production-3b6599db.cjs.prod.js} +2 -2
- package/dist/{create-webpack-config-for-production-46d817cc.cjs.dev.js → create-webpack-config-for-production-e5ed8805.cjs.dev.js} +2 -2
- package/dist/{credentials-storage-0b89aa0e.cjs.prod.js → credentials-storage-6d592cd6.cjs.prod.js} +20 -2
- package/dist/{credentials-storage-cbb5c559.cjs.dev.js → credentials-storage-c4c5980e.cjs.dev.js} +20 -2
- package/dist/{credentials-storage-4464313c.esm.js → credentials-storage-fcc77fb6.esm.js} +20 -2
- package/dist/declarations/src/types.d.ts +4 -0
- package/dist/{deployment-previews-set-bbef95d2.esm.js → deployment-previews-set-7d49e7df.esm.js} +3 -3
- package/dist/{deployment-previews-set-4edd48db.cjs.dev.js → deployment-previews-set-8d6a1e99.cjs.dev.js} +3 -3
- package/dist/{deployment-previews-set-636fb1a3.cjs.prod.js → deployment-previews-set-f8ce3db7.cjs.prod.js} +3 -3
- package/dist/{graphql-requests-0a6eeb3a.cjs.prod.js → graphql-requests-b57fca4c.cjs.prod.js} +2 -2
- package/dist/{graphql-requests-14074b2b.esm.js → graphql-requests-d2fa2ca7.esm.js} +3 -3
- package/dist/{graphql-requests-23f7ddb1.cjs.dev.js → graphql-requests-da194989.cjs.dev.js} +2 -2
- package/dist/{login-54ebae96.cjs.prod.js → login-9774c9cc.cjs.prod.js} +130 -11
- package/dist/{login-1b222f33.esm.js → login-abb38213.esm.js} +127 -10
- package/dist/{login-a6fd5fbf.cjs.dev.js → login-f4550251.cjs.dev.js} +130 -11
- package/dist/{package-e1f7242c.cjs.prod.js → package-0eebca1b.cjs.dev.js} +20 -10
- package/dist/{package-a34835d9.esm.js → package-9e6910b8.esm.js} +20 -10
- package/dist/{package-d8b1f4c0.cjs.dev.js → package-b9298ce3.cjs.prod.js} +20 -10
- package/dist/{start-890895df.esm.js → start-109f9462.esm.js} +3 -3
- package/dist/{start-37ec4a7e.cjs.dev.js → start-7765f44c.cjs.dev.js} +3 -3
- package/dist/{start-0be8a294.cjs.prod.js → start-e014127c.cjs.prod.js} +3 -3
- package/package.json +20 -10
- 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
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
4
|
-
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
5
|
-
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
6
|
-
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
7
3
|
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
8
4
|
var chalk = require('chalk');
|
|
9
5
|
var omit = require('lodash/omit');
|
|
10
|
-
var prompts = require('prompts');
|
|
11
|
-
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
12
|
-
var credentialsStorage$1 = require('./credentials-storage-0b89aa0e.cjs.prod.js');
|
|
13
6
|
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
14
7
|
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
15
8
|
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
@@ -21,31 +14,17 @@ var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
|
|
|
21
14
|
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
22
15
|
var _bindInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/bind');
|
|
23
16
|
var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
17
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
24
18
|
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
25
|
-
var
|
|
26
|
-
require('@
|
|
27
|
-
require('
|
|
28
|
-
require('@babel/runtime-corejs3/core-js-stable/date/now');
|
|
29
|
-
require('node:fs');
|
|
30
|
-
require('node:os');
|
|
31
|
-
require('node:path');
|
|
32
|
-
require('./does-file-exist-be53305d.cjs.prod.js');
|
|
33
|
-
require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
34
|
-
require('graphql');
|
|
35
|
-
require('graphql-request');
|
|
36
|
-
require('@commercetools-frontend/constants');
|
|
37
|
-
require('@commercetools/http-user-agent');
|
|
38
|
-
require('./package-e1f7242c.cjs.prod.js');
|
|
19
|
+
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
20
|
+
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
21
|
+
var graphqlRequests = require('./graphql-requests-b57fca4c.cjs.prod.js');
|
|
39
22
|
|
|
40
23
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
41
24
|
|
|
42
|
-
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
43
|
-
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
44
|
-
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
45
25
|
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
46
26
|
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
47
27
|
var omit__default = /*#__PURE__*/_interopDefault(omit);
|
|
48
|
-
var prompts__default = /*#__PURE__*/_interopDefault(prompts);
|
|
49
28
|
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
50
29
|
var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
|
|
51
30
|
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
@@ -56,7 +35,9 @@ var _Set__default = /*#__PURE__*/_interopDefault(_Set);
|
|
|
56
35
|
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
57
36
|
var _bindInstanceProperty__default = /*#__PURE__*/_interopDefault(_bindInstanceProperty);
|
|
58
37
|
var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
|
|
38
|
+
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
59
39
|
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
40
|
+
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
60
41
|
|
|
61
42
|
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
62
43
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context9, _context0; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context9 = ownKeys(Object(t), !0)).call(_context9, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context0 = ownKeys(Object(t))).call(_context0, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
@@ -532,7 +513,6 @@ const getCustomViewConfigDiff = (oldConfig, newConfig) => {
|
|
|
532
513
|
return diff.join('\n');
|
|
533
514
|
};
|
|
534
515
|
|
|
535
|
-
const credentialsStorage = new credentialsStorage$1.CredentialsStorage();
|
|
536
516
|
const getMcUrlLink = _ref => {
|
|
537
517
|
let mcApiUrl = _ref.mcApiUrl,
|
|
538
518
|
organizationId = _ref.organizationId,
|
|
@@ -543,307 +523,202 @@ const getMcUrlLink = _ref => {
|
|
|
543
523
|
return customEntityLink;
|
|
544
524
|
};
|
|
545
525
|
const isCustomViewData = data => data.entryPointUriPath === undefined;
|
|
546
|
-
async function
|
|
547
|
-
var _context3;
|
|
526
|
+
async function performCreateCustomApplication(_ref2) {
|
|
548
527
|
let mcApiUrl = _ref2.mcApiUrl,
|
|
528
|
+
organizationId = _ref2.organizationId,
|
|
529
|
+
organizationName = _ref2.organizationName,
|
|
549
530
|
localCustomEntityData = _ref2.localCustomEntityData,
|
|
550
531
|
applicationIdentifier = _ref2.applicationIdentifier,
|
|
551
|
-
|
|
552
|
-
|
|
532
|
+
dryRun = _ref2.dryRun;
|
|
533
|
+
console.log(`Creating Custom Application in organization "${chalk__default["default"].green(organizationName)}"...`);
|
|
534
|
+
const data = omit__default["default"](localCustomEntityData, ['id']);
|
|
535
|
+
if (dryRun) {
|
|
536
|
+
console.log();
|
|
537
|
+
console.log('Dry run - would create Custom Application with:');
|
|
538
|
+
console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
|
|
539
|
+
return null;
|
|
540
|
+
}
|
|
541
|
+
const createdCustomApplication = await graphqlRequests.createCustomApplication({
|
|
553
542
|
mcApiUrl,
|
|
554
|
-
|
|
543
|
+
organizationId,
|
|
544
|
+
data,
|
|
555
545
|
applicationIdentifier
|
|
556
546
|
});
|
|
557
|
-
if (!
|
|
558
|
-
|
|
559
|
-
const userOrganizations = await graphqlRequests.fetchUserOrganizations({
|
|
560
|
-
mcApiUrl,
|
|
561
|
-
applicationIdentifier
|
|
562
|
-
});
|
|
563
|
-
let organizationId, organizationName;
|
|
564
|
-
if (userOrganizations.total === 0) {
|
|
565
|
-
throw new Error(`It seems you are not an admin of any Organization. Please make sure to be part of the Administrators team of the Organization you want the Custom Application to be configured to.`);
|
|
566
|
-
}
|
|
567
|
-
if (userOrganizations.total === 1) {
|
|
568
|
-
const _userOrganizations$re = _slicedToArray(userOrganizations.results, 1),
|
|
569
|
-
organization = _userOrganizations$re[0];
|
|
570
|
-
organizationId = organization.id;
|
|
571
|
-
organizationName = organization.name;
|
|
572
|
-
} else {
|
|
573
|
-
var _context;
|
|
574
|
-
const organizationChoices = _mapInstanceProperty__default["default"](_context = userOrganizations.results).call(_context, organization => ({
|
|
575
|
-
title: organization.name,
|
|
576
|
-
value: organization.id
|
|
577
|
-
}));
|
|
578
|
-
const _await$prompts = await prompts__default["default"]({
|
|
579
|
-
type: 'select',
|
|
580
|
-
name: 'organizationId',
|
|
581
|
-
message: 'Select an Organization',
|
|
582
|
-
choices: organizationChoices,
|
|
583
|
-
initial: 0
|
|
584
|
-
}),
|
|
585
|
-
selectedOrganizationId = _await$prompts.organizationId;
|
|
586
|
-
if (!selectedOrganizationId) {
|
|
587
|
-
throw new Error(`No Organization selected, aborting.`);
|
|
588
|
-
}
|
|
589
|
-
organizationId = selectedOrganizationId;
|
|
590
|
-
organizationName = _findInstanceProperty__default["default"](organizationChoices).call(organizationChoices, _ref3 => {
|
|
591
|
-
let value = _ref3.value;
|
|
592
|
-
return value === organizationId;
|
|
593
|
-
}).title;
|
|
594
|
-
}
|
|
595
|
-
const _await$prompts2 = await prompts__default["default"]({
|
|
596
|
-
type: 'text',
|
|
597
|
-
name: 'confirmation',
|
|
598
|
-
message: _filterInstanceProperty__default["default"](_context2 = [`You are about to create a new Custom Application in the "${chalk__default["default"].green(organizationName)}" organization. Are you sure you want to proceed?`, options.dryRun && chalk__default["default"].gray('Using "--dry-run", no data will be created.')]).call(_context2, Boolean).join('\n'),
|
|
599
|
-
initial: 'yes'
|
|
600
|
-
}),
|
|
601
|
-
confirmation = _await$prompts2.confirmation;
|
|
602
|
-
if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
|
|
603
|
-
console.log(chalk__default["default"].red('Aborted.'));
|
|
604
|
-
return;
|
|
605
|
-
}
|
|
606
|
-
const data = omit__default["default"](localCustomEntityData, ['id']);
|
|
607
|
-
if (options.dryRun) {
|
|
608
|
-
console.log();
|
|
609
|
-
console.log(`The following payload would be used to create a new Custom Application.`);
|
|
610
|
-
console.log();
|
|
611
|
-
console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
|
|
612
|
-
return;
|
|
613
|
-
}
|
|
614
|
-
const createdCustomApplication = await graphqlRequests.createCustomApplication({
|
|
615
|
-
mcApiUrl,
|
|
616
|
-
organizationId,
|
|
617
|
-
data,
|
|
618
|
-
applicationIdentifier
|
|
619
|
-
});
|
|
620
|
-
|
|
621
|
-
// This check is technically not necessary, as the `graphql-request` client
|
|
622
|
-
// throws an error in case of GraphQL errors.
|
|
623
|
-
// However, the generated TypeScript data related to the GraphQL query has the
|
|
624
|
-
// field typed as optional, thus having an extra check for type correctness.
|
|
625
|
-
if (!createdCustomApplication) {
|
|
626
|
-
throw new Error('Failed to create the Custom Application.');
|
|
627
|
-
}
|
|
628
|
-
const customAppLink = getMcUrlLink({
|
|
629
|
-
mcApiUrl,
|
|
630
|
-
organizationId,
|
|
631
|
-
customEntityId: createdCustomApplication.id
|
|
632
|
-
});
|
|
633
|
-
console.log(chalk__default["default"].green(`Custom Application created.\nPlease update the "env.production.applicationId" field in your local Custom Application config file with the following value: "${chalk__default["default"].green(createdCustomApplication.id)}".`));
|
|
634
|
-
console.log(`You can inspect the Custom Application data in the Merchant Center at "${chalk__default["default"].gray(customAppLink)}".`);
|
|
635
|
-
return;
|
|
547
|
+
if (!createdCustomApplication) {
|
|
548
|
+
throw new Error('Failed to create the Custom Application.');
|
|
636
549
|
}
|
|
637
550
|
const customAppLink = getMcUrlLink({
|
|
638
551
|
mcApiUrl,
|
|
639
|
-
organizationId
|
|
640
|
-
customEntityId:
|
|
641
|
-
});
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
initial: 'yes'
|
|
656
|
-
}),
|
|
657
|
-
confirmation = _await$prompts3.confirmation;
|
|
658
|
-
if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
|
|
659
|
-
console.log(chalk__default["default"].red('Aborted.'));
|
|
660
|
-
return;
|
|
661
|
-
}
|
|
552
|
+
organizationId,
|
|
553
|
+
customEntityId: createdCustomApplication.id
|
|
554
|
+
});
|
|
555
|
+
console.log(chalk__default["default"].green('Custom Application created successfully.'));
|
|
556
|
+
console.log(`ID: ${chalk__default["default"].cyan(createdCustomApplication.id)}`);
|
|
557
|
+
console.log(`Please update the "env.production.applicationId" field in your local Custom Application config file with the ID above.`);
|
|
558
|
+
console.log(`URL: ${chalk__default["default"].gray(customAppLink)}`);
|
|
559
|
+
return createdCustomApplication.id;
|
|
560
|
+
}
|
|
561
|
+
async function performUpdateCustomApplication(_ref3) {
|
|
562
|
+
let mcApiUrl = _ref3.mcApiUrl,
|
|
563
|
+
organizationId = _ref3.organizationId,
|
|
564
|
+
applicationId = _ref3.applicationId,
|
|
565
|
+
localCustomEntityData = _ref3.localCustomEntityData,
|
|
566
|
+
applicationIdentifier = _ref3.applicationIdentifier,
|
|
567
|
+
dryRun = _ref3.dryRun;
|
|
662
568
|
const data = omit__default["default"](localCustomEntityData, ['id']);
|
|
663
|
-
if (
|
|
664
|
-
console.log();
|
|
665
|
-
console.log(`The following payload would be used to update the Custom Application "${chalk__default["default"].green(data.entryPointUriPath)}".`);
|
|
569
|
+
if (dryRun) {
|
|
666
570
|
console.log();
|
|
571
|
+
console.log(`Dry run - would update Custom Application "${chalk__default["default"].green(data.entryPointUriPath)}" with:`);
|
|
667
572
|
console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
|
|
668
573
|
return;
|
|
669
574
|
}
|
|
575
|
+
console.log('Updating Custom Application...');
|
|
670
576
|
await graphqlRequests.updateCustomApplication({
|
|
671
577
|
mcApiUrl,
|
|
672
|
-
organizationId
|
|
673
|
-
data
|
|
674
|
-
applicationId
|
|
578
|
+
organizationId,
|
|
579
|
+
data,
|
|
580
|
+
applicationId,
|
|
675
581
|
applicationIdentifier
|
|
676
582
|
});
|
|
677
|
-
|
|
678
|
-
|
|
583
|
+
const customAppLink = getMcUrlLink({
|
|
584
|
+
mcApiUrl,
|
|
585
|
+
organizationId,
|
|
586
|
+
customEntityId: applicationId
|
|
587
|
+
});
|
|
588
|
+
console.log(chalk__default["default"].green('Custom Application updated successfully.'));
|
|
589
|
+
console.log(`URL: ${chalk__default["default"].gray(customAppLink)}`);
|
|
679
590
|
}
|
|
680
|
-
async function
|
|
681
|
-
var _context6;
|
|
591
|
+
async function performCreateCustomView(_ref4) {
|
|
682
592
|
let mcApiUrl = _ref4.mcApiUrl,
|
|
593
|
+
organizationId = _ref4.organizationId,
|
|
594
|
+
organizationName = _ref4.organizationName,
|
|
683
595
|
localCustomEntityData = _ref4.localCustomEntityData,
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
const
|
|
596
|
+
applicationIdentifier = _ref4.applicationIdentifier,
|
|
597
|
+
dryRun = _ref4.dryRun;
|
|
598
|
+
console.log(`Creating Custom View in organization "${chalk__default["default"].green(organizationName)}"...`);
|
|
599
|
+
const data = omit__default["default"](localCustomEntityData, ['id']);
|
|
600
|
+
if (dryRun) {
|
|
601
|
+
console.log();
|
|
602
|
+
console.log('Dry run - would create Custom View with:');
|
|
603
|
+
console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
|
|
604
|
+
return null;
|
|
605
|
+
}
|
|
606
|
+
const createdCustomView = await graphqlRequests.createCustomView({
|
|
688
607
|
mcApiUrl,
|
|
689
|
-
|
|
608
|
+
organizationId,
|
|
609
|
+
data,
|
|
690
610
|
applicationIdentifier
|
|
691
611
|
});
|
|
692
|
-
if (!
|
|
693
|
-
|
|
694
|
-
const userOrganizations = await graphqlRequests.fetchUserOrganizations({
|
|
695
|
-
mcApiUrl,
|
|
696
|
-
customViewId,
|
|
697
|
-
applicationIdentifier
|
|
698
|
-
});
|
|
699
|
-
let organizationId, organizationName;
|
|
700
|
-
if (userOrganizations.total === 0) {
|
|
701
|
-
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.`);
|
|
702
|
-
}
|
|
703
|
-
if (userOrganizations.total === 1) {
|
|
704
|
-
const _userOrganizations$re2 = _slicedToArray(userOrganizations.results, 1),
|
|
705
|
-
organization = _userOrganizations$re2[0];
|
|
706
|
-
organizationId = organization.id;
|
|
707
|
-
organizationName = organization.name;
|
|
708
|
-
} else {
|
|
709
|
-
var _context4;
|
|
710
|
-
const organizationChoices = _mapInstanceProperty__default["default"](_context4 = userOrganizations.results).call(_context4, organization => ({
|
|
711
|
-
title: organization.name,
|
|
712
|
-
value: organization.id
|
|
713
|
-
}));
|
|
714
|
-
const _await$prompts4 = await prompts__default["default"]({
|
|
715
|
-
type: 'select',
|
|
716
|
-
name: 'organizationId',
|
|
717
|
-
message: 'Select an Organization',
|
|
718
|
-
choices: organizationChoices,
|
|
719
|
-
initial: 0
|
|
720
|
-
}),
|
|
721
|
-
selectedOrganizationId = _await$prompts4.organizationId;
|
|
722
|
-
if (!selectedOrganizationId) {
|
|
723
|
-
throw new Error(`No Organization selected, aborting.`);
|
|
724
|
-
}
|
|
725
|
-
organizationId = selectedOrganizationId;
|
|
726
|
-
organizationName = _findInstanceProperty__default["default"](organizationChoices).call(organizationChoices, _ref5 => {
|
|
727
|
-
let value = _ref5.value;
|
|
728
|
-
return value === organizationId;
|
|
729
|
-
}).title;
|
|
730
|
-
}
|
|
731
|
-
const _await$prompts5 = await prompts__default["default"]({
|
|
732
|
-
type: 'text',
|
|
733
|
-
name: 'confirmation',
|
|
734
|
-
message: _filterInstanceProperty__default["default"](_context5 = [`You are about to create a new Custom View in the "${chalk__default["default"].green(organizationName)}" organization. Are you sure you want to proceed?`, options.dryRun && chalk__default["default"].gray('Using "--dry-run", no data will be created.')]).call(_context5, Boolean).join('\n'),
|
|
735
|
-
initial: 'yes'
|
|
736
|
-
}),
|
|
737
|
-
confirmation = _await$prompts5.confirmation;
|
|
738
|
-
if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
|
|
739
|
-
console.log(chalk__default["default"].red('Aborted.'));
|
|
740
|
-
return;
|
|
741
|
-
}
|
|
742
|
-
const data = omit__default["default"](localCustomEntityData, ['id']);
|
|
743
|
-
if (options.dryRun) {
|
|
744
|
-
console.log();
|
|
745
|
-
console.log(`The following payload would be used to create a new Custom View.`);
|
|
746
|
-
console.log();
|
|
747
|
-
console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
|
|
748
|
-
return;
|
|
749
|
-
}
|
|
750
|
-
const createdCustomView = await graphqlRequests.createCustomView({
|
|
751
|
-
mcApiUrl,
|
|
752
|
-
organizationId,
|
|
753
|
-
data,
|
|
754
|
-
applicationIdentifier
|
|
755
|
-
});
|
|
756
|
-
|
|
757
|
-
// This check is technically not necessary, as the `graphql-request` client
|
|
758
|
-
// throws an error in case of GraphQL errors.
|
|
759
|
-
// However, the generated TypeScript data related to the GraphQL query has the
|
|
760
|
-
// field typed as optional, thus having an extra check for type correctness.
|
|
761
|
-
if (!createdCustomView) {
|
|
762
|
-
throw new Error('Failed to create the Custom View.');
|
|
763
|
-
}
|
|
764
|
-
const customViewLink = getMcUrlLink({
|
|
765
|
-
mcApiUrl,
|
|
766
|
-
organizationId,
|
|
767
|
-
customEntityId: createdCustomView.id,
|
|
768
|
-
isCustomView: true
|
|
769
|
-
});
|
|
770
|
-
console.log(chalk__default["default"].green(`Custom View created.\nPlease update the "env.production.customViewId" field in your local Custom View config file with the following value: "${chalk__default["default"].green(createdCustomView.id)}".`));
|
|
771
|
-
console.log(`You can inspect the Custom View data in the Merchant Center at "${chalk__default["default"].gray(customViewLink)}".`);
|
|
772
|
-
return;
|
|
612
|
+
if (!createdCustomView) {
|
|
613
|
+
throw new Error('Failed to create the Custom View.');
|
|
773
614
|
}
|
|
774
615
|
const customViewLink = getMcUrlLink({
|
|
775
616
|
mcApiUrl,
|
|
776
|
-
organizationId
|
|
777
|
-
customEntityId:
|
|
617
|
+
organizationId,
|
|
618
|
+
customEntityId: createdCustomView.id,
|
|
778
619
|
isCustomView: true
|
|
779
620
|
});
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
initial: 'yes'
|
|
794
|
-
}),
|
|
795
|
-
confirmation = _await$prompts6.confirmation;
|
|
796
|
-
if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
|
|
797
|
-
console.log(chalk__default["default"].red('Aborted.'));
|
|
798
|
-
return;
|
|
799
|
-
}
|
|
621
|
+
console.log(chalk__default["default"].green('Custom View created successfully.'));
|
|
622
|
+
console.log(`ID: ${chalk__default["default"].cyan(createdCustomView.id)}`);
|
|
623
|
+
console.log(`Please update the "env.production.customViewId" field in your local Custom View config file with the ID above.`);
|
|
624
|
+
console.log(`URL: ${chalk__default["default"].gray(customViewLink)}`);
|
|
625
|
+
return createdCustomView.id;
|
|
626
|
+
}
|
|
627
|
+
async function performUpdateCustomView(_ref5) {
|
|
628
|
+
let mcApiUrl = _ref5.mcApiUrl,
|
|
629
|
+
organizationId = _ref5.organizationId,
|
|
630
|
+
customViewId = _ref5.customViewId,
|
|
631
|
+
localCustomEntityData = _ref5.localCustomEntityData,
|
|
632
|
+
applicationIdentifier = _ref5.applicationIdentifier,
|
|
633
|
+
dryRun = _ref5.dryRun;
|
|
800
634
|
const data = omit__default["default"](localCustomEntityData, ['id']);
|
|
801
|
-
if (
|
|
802
|
-
console.log();
|
|
803
|
-
console.log(`The following payload would be used to update the Custom View "${chalk__default["default"].green(data.defaultLabel)}".`);
|
|
635
|
+
if (dryRun) {
|
|
804
636
|
console.log();
|
|
637
|
+
console.log(`Dry run - would update Custom View "${chalk__default["default"].green(data.defaultLabel)}" with:`);
|
|
805
638
|
console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
|
|
806
639
|
return;
|
|
807
640
|
}
|
|
641
|
+
console.log('Updating Custom View...');
|
|
808
642
|
await graphqlRequests.updateCustomView({
|
|
809
643
|
mcApiUrl,
|
|
810
|
-
organizationId
|
|
811
|
-
data
|
|
812
|
-
customViewId
|
|
644
|
+
organizationId,
|
|
645
|
+
data,
|
|
646
|
+
customViewId,
|
|
813
647
|
applicationIdentifier
|
|
814
648
|
});
|
|
815
|
-
|
|
816
|
-
|
|
649
|
+
const customViewLink = getMcUrlLink({
|
|
650
|
+
mcApiUrl,
|
|
651
|
+
organizationId,
|
|
652
|
+
customEntityId: customViewId,
|
|
653
|
+
isCustomView: true
|
|
654
|
+
});
|
|
655
|
+
console.log(chalk__default["default"].green('Custom View updated successfully.'));
|
|
656
|
+
console.log(`URL: ${chalk__default["default"].gray(customViewLink)}`);
|
|
817
657
|
}
|
|
818
|
-
async function
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
if (!
|
|
829
|
-
|
|
658
|
+
async function checkCustomApplicationStatus(_ref6) {
|
|
659
|
+
let mcApiUrl = _ref6.mcApiUrl,
|
|
660
|
+
entryPointUriPath = _ref6.entryPointUriPath,
|
|
661
|
+
applicationIdentifier = _ref6.applicationIdentifier,
|
|
662
|
+
localCustomEntityData = _ref6.localCustomEntityData;
|
|
663
|
+
const fetchedCustomApplication = await graphqlRequests.fetchCustomApplication({
|
|
664
|
+
mcApiUrl,
|
|
665
|
+
entryPointUriPath,
|
|
666
|
+
applicationIdentifier
|
|
667
|
+
});
|
|
668
|
+
if (!fetchedCustomApplication) {
|
|
669
|
+
return {
|
|
670
|
+
exists: false
|
|
671
|
+
};
|
|
830
672
|
}
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
673
|
+
const configDiff = getCustomApplicationConfigDiff(fetchedCustomApplication.application, localCustomEntityData);
|
|
674
|
+
const customAppLink = getMcUrlLink({
|
|
675
|
+
mcApiUrl,
|
|
676
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
677
|
+
customEntityId: fetchedCustomApplication.application.id
|
|
678
|
+
});
|
|
679
|
+
return {
|
|
680
|
+
exists: true,
|
|
681
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
682
|
+
applicationId: fetchedCustomApplication.application.id,
|
|
683
|
+
configDiff,
|
|
684
|
+
link: customAppLink
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
async function checkCustomViewStatus(_ref7) {
|
|
688
|
+
let mcApiUrl = _ref7.mcApiUrl,
|
|
689
|
+
customViewId = _ref7.customViewId,
|
|
690
|
+
applicationIdentifier = _ref7.applicationIdentifier,
|
|
691
|
+
localCustomEntityData = _ref7.localCustomEntityData;
|
|
692
|
+
const fetchedCustomView = await graphqlRequests.fetchCustomView({
|
|
693
|
+
mcApiUrl,
|
|
694
|
+
customViewId,
|
|
695
|
+
applicationIdentifier
|
|
696
|
+
});
|
|
697
|
+
if (!fetchedCustomView) {
|
|
698
|
+
return {
|
|
699
|
+
exists: false
|
|
700
|
+
};
|
|
846
701
|
}
|
|
702
|
+
const configDiff = getCustomViewConfigDiff(fetchedCustomView.customView, localCustomEntityData);
|
|
703
|
+
const customViewLink = getMcUrlLink({
|
|
704
|
+
mcApiUrl,
|
|
705
|
+
organizationId: fetchedCustomView.organizationId,
|
|
706
|
+
customEntityId: fetchedCustomView?.customView?.id || '',
|
|
707
|
+
isCustomView: true
|
|
708
|
+
});
|
|
709
|
+
return {
|
|
710
|
+
exists: true,
|
|
711
|
+
organizationId: fetchedCustomView.organizationId,
|
|
712
|
+
customViewId: fetchedCustomView?.customView?.id || '',
|
|
713
|
+
configDiff,
|
|
714
|
+
link: customViewLink
|
|
715
|
+
};
|
|
847
716
|
}
|
|
848
717
|
|
|
849
|
-
exports
|
|
718
|
+
exports.checkCustomApplicationStatus = checkCustomApplicationStatus;
|
|
719
|
+
exports.checkCustomViewStatus = checkCustomViewStatus;
|
|
720
|
+
exports.isCustomViewData = isCustomViewData;
|
|
721
|
+
exports.performCreateCustomApplication = performCreateCustomApplication;
|
|
722
|
+
exports.performCreateCustomView = performCreateCustomView;
|
|
723
|
+
exports.performUpdateCustomApplication = performUpdateCustomApplication;
|
|
724
|
+
exports.performUpdateCustomView = performUpdateCustomView;
|