@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-cbb5c559.cjs.dev.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-eb86baca.cjs.dev.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-d8b1f4c0.cjs.dev.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-da194989.cjs.dev.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; }
|
|
@@ -538,7 +519,6 @@ const getCustomViewConfigDiff = (oldConfig, newConfig) => {
|
|
|
538
519
|
return diff.join('\n');
|
|
539
520
|
};
|
|
540
521
|
|
|
541
|
-
const credentialsStorage = new credentialsStorage$1.CredentialsStorage();
|
|
542
522
|
const getMcUrlLink = _ref => {
|
|
543
523
|
let mcApiUrl = _ref.mcApiUrl,
|
|
544
524
|
organizationId = _ref.organizationId,
|
|
@@ -549,307 +529,202 @@ const getMcUrlLink = _ref => {
|
|
|
549
529
|
return customEntityLink;
|
|
550
530
|
};
|
|
551
531
|
const isCustomViewData = data => data.entryPointUriPath === undefined;
|
|
552
|
-
async function
|
|
553
|
-
var _context3;
|
|
532
|
+
async function performCreateCustomApplication(_ref2) {
|
|
554
533
|
let mcApiUrl = _ref2.mcApiUrl,
|
|
534
|
+
organizationId = _ref2.organizationId,
|
|
535
|
+
organizationName = _ref2.organizationName,
|
|
555
536
|
localCustomEntityData = _ref2.localCustomEntityData,
|
|
556
537
|
applicationIdentifier = _ref2.applicationIdentifier,
|
|
557
|
-
|
|
558
|
-
|
|
538
|
+
dryRun = _ref2.dryRun;
|
|
539
|
+
console.log(`Creating Custom Application in organization "${chalk__default["default"].green(organizationName)}"...`);
|
|
540
|
+
const data = omit__default["default"](localCustomEntityData, ['id']);
|
|
541
|
+
if (dryRun) {
|
|
542
|
+
console.log();
|
|
543
|
+
console.log('Dry run - would create Custom Application with:');
|
|
544
|
+
console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
|
|
545
|
+
return null;
|
|
546
|
+
}
|
|
547
|
+
const createdCustomApplication = await graphqlRequests.createCustomApplication({
|
|
559
548
|
mcApiUrl,
|
|
560
|
-
|
|
549
|
+
organizationId,
|
|
550
|
+
data,
|
|
561
551
|
applicationIdentifier
|
|
562
552
|
});
|
|
563
|
-
if (!
|
|
564
|
-
|
|
565
|
-
const userOrganizations = await graphqlRequests.fetchUserOrganizations({
|
|
566
|
-
mcApiUrl,
|
|
567
|
-
applicationIdentifier
|
|
568
|
-
});
|
|
569
|
-
let organizationId, organizationName;
|
|
570
|
-
if (userOrganizations.total === 0) {
|
|
571
|
-
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.`);
|
|
572
|
-
}
|
|
573
|
-
if (userOrganizations.total === 1) {
|
|
574
|
-
const _userOrganizations$re = _slicedToArray(userOrganizations.results, 1),
|
|
575
|
-
organization = _userOrganizations$re[0];
|
|
576
|
-
organizationId = organization.id;
|
|
577
|
-
organizationName = organization.name;
|
|
578
|
-
} else {
|
|
579
|
-
var _context;
|
|
580
|
-
const organizationChoices = _mapInstanceProperty__default["default"](_context = userOrganizations.results).call(_context, organization => ({
|
|
581
|
-
title: organization.name,
|
|
582
|
-
value: organization.id
|
|
583
|
-
}));
|
|
584
|
-
const _await$prompts = await prompts__default["default"]({
|
|
585
|
-
type: 'select',
|
|
586
|
-
name: 'organizationId',
|
|
587
|
-
message: 'Select an Organization',
|
|
588
|
-
choices: organizationChoices,
|
|
589
|
-
initial: 0
|
|
590
|
-
}),
|
|
591
|
-
selectedOrganizationId = _await$prompts.organizationId;
|
|
592
|
-
if (!selectedOrganizationId) {
|
|
593
|
-
throw new Error(`No Organization selected, aborting.`);
|
|
594
|
-
}
|
|
595
|
-
organizationId = selectedOrganizationId;
|
|
596
|
-
organizationName = _findInstanceProperty__default["default"](organizationChoices).call(organizationChoices, _ref3 => {
|
|
597
|
-
let value = _ref3.value;
|
|
598
|
-
return value === organizationId;
|
|
599
|
-
}).title;
|
|
600
|
-
}
|
|
601
|
-
const _await$prompts2 = await prompts__default["default"]({
|
|
602
|
-
type: 'text',
|
|
603
|
-
name: 'confirmation',
|
|
604
|
-
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'),
|
|
605
|
-
initial: 'yes'
|
|
606
|
-
}),
|
|
607
|
-
confirmation = _await$prompts2.confirmation;
|
|
608
|
-
if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
|
|
609
|
-
console.log(chalk__default["default"].red('Aborted.'));
|
|
610
|
-
return;
|
|
611
|
-
}
|
|
612
|
-
const data = omit__default["default"](localCustomEntityData, ['id']);
|
|
613
|
-
if (options.dryRun) {
|
|
614
|
-
console.log();
|
|
615
|
-
console.log(`The following payload would be used to create a new Custom Application.`);
|
|
616
|
-
console.log();
|
|
617
|
-
console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
|
|
618
|
-
return;
|
|
619
|
-
}
|
|
620
|
-
const createdCustomApplication = await graphqlRequests.createCustomApplication({
|
|
621
|
-
mcApiUrl,
|
|
622
|
-
organizationId,
|
|
623
|
-
data,
|
|
624
|
-
applicationIdentifier
|
|
625
|
-
});
|
|
626
|
-
|
|
627
|
-
// This check is technically not necessary, as the `graphql-request` client
|
|
628
|
-
// throws an error in case of GraphQL errors.
|
|
629
|
-
// However, the generated TypeScript data related to the GraphQL query has the
|
|
630
|
-
// field typed as optional, thus having an extra check for type correctness.
|
|
631
|
-
if (!createdCustomApplication) {
|
|
632
|
-
throw new Error('Failed to create the Custom Application.');
|
|
633
|
-
}
|
|
634
|
-
const customAppLink = getMcUrlLink({
|
|
635
|
-
mcApiUrl,
|
|
636
|
-
organizationId,
|
|
637
|
-
customEntityId: createdCustomApplication.id
|
|
638
|
-
});
|
|
639
|
-
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)}".`));
|
|
640
|
-
console.log(`You can inspect the Custom Application data in the Merchant Center at "${chalk__default["default"].gray(customAppLink)}".`);
|
|
641
|
-
return;
|
|
553
|
+
if (!createdCustomApplication) {
|
|
554
|
+
throw new Error('Failed to create the Custom Application.');
|
|
642
555
|
}
|
|
643
556
|
const customAppLink = getMcUrlLink({
|
|
644
557
|
mcApiUrl,
|
|
645
|
-
organizationId
|
|
646
|
-
customEntityId:
|
|
647
|
-
});
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
initial: 'yes'
|
|
662
|
-
}),
|
|
663
|
-
confirmation = _await$prompts3.confirmation;
|
|
664
|
-
if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
|
|
665
|
-
console.log(chalk__default["default"].red('Aborted.'));
|
|
666
|
-
return;
|
|
667
|
-
}
|
|
558
|
+
organizationId,
|
|
559
|
+
customEntityId: createdCustomApplication.id
|
|
560
|
+
});
|
|
561
|
+
console.log(chalk__default["default"].green('Custom Application created successfully.'));
|
|
562
|
+
console.log(`ID: ${chalk__default["default"].cyan(createdCustomApplication.id)}`);
|
|
563
|
+
console.log(`Please update the "env.production.applicationId" field in your local Custom Application config file with the ID above.`);
|
|
564
|
+
console.log(`URL: ${chalk__default["default"].gray(customAppLink)}`);
|
|
565
|
+
return createdCustomApplication.id;
|
|
566
|
+
}
|
|
567
|
+
async function performUpdateCustomApplication(_ref3) {
|
|
568
|
+
let mcApiUrl = _ref3.mcApiUrl,
|
|
569
|
+
organizationId = _ref3.organizationId,
|
|
570
|
+
applicationId = _ref3.applicationId,
|
|
571
|
+
localCustomEntityData = _ref3.localCustomEntityData,
|
|
572
|
+
applicationIdentifier = _ref3.applicationIdentifier,
|
|
573
|
+
dryRun = _ref3.dryRun;
|
|
668
574
|
const data = omit__default["default"](localCustomEntityData, ['id']);
|
|
669
|
-
if (
|
|
670
|
-
console.log();
|
|
671
|
-
console.log(`The following payload would be used to update the Custom Application "${chalk__default["default"].green(data.entryPointUriPath)}".`);
|
|
575
|
+
if (dryRun) {
|
|
672
576
|
console.log();
|
|
577
|
+
console.log(`Dry run - would update Custom Application "${chalk__default["default"].green(data.entryPointUriPath)}" with:`);
|
|
673
578
|
console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
|
|
674
579
|
return;
|
|
675
580
|
}
|
|
581
|
+
console.log('Updating Custom Application...');
|
|
676
582
|
await graphqlRequests.updateCustomApplication({
|
|
677
583
|
mcApiUrl,
|
|
678
|
-
organizationId
|
|
679
|
-
data
|
|
680
|
-
applicationId
|
|
584
|
+
organizationId,
|
|
585
|
+
data,
|
|
586
|
+
applicationId,
|
|
681
587
|
applicationIdentifier
|
|
682
588
|
});
|
|
683
|
-
|
|
684
|
-
|
|
589
|
+
const customAppLink = getMcUrlLink({
|
|
590
|
+
mcApiUrl,
|
|
591
|
+
organizationId,
|
|
592
|
+
customEntityId: applicationId
|
|
593
|
+
});
|
|
594
|
+
console.log(chalk__default["default"].green('Custom Application updated successfully.'));
|
|
595
|
+
console.log(`URL: ${chalk__default["default"].gray(customAppLink)}`);
|
|
685
596
|
}
|
|
686
|
-
async function
|
|
687
|
-
var _context6;
|
|
597
|
+
async function performCreateCustomView(_ref4) {
|
|
688
598
|
let mcApiUrl = _ref4.mcApiUrl,
|
|
599
|
+
organizationId = _ref4.organizationId,
|
|
600
|
+
organizationName = _ref4.organizationName,
|
|
689
601
|
localCustomEntityData = _ref4.localCustomEntityData,
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
const
|
|
602
|
+
applicationIdentifier = _ref4.applicationIdentifier,
|
|
603
|
+
dryRun = _ref4.dryRun;
|
|
604
|
+
console.log(`Creating Custom View in organization "${chalk__default["default"].green(organizationName)}"...`);
|
|
605
|
+
const data = omit__default["default"](localCustomEntityData, ['id']);
|
|
606
|
+
if (dryRun) {
|
|
607
|
+
console.log();
|
|
608
|
+
console.log('Dry run - would create Custom View with:');
|
|
609
|
+
console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
|
|
610
|
+
return null;
|
|
611
|
+
}
|
|
612
|
+
const createdCustomView = await graphqlRequests.createCustomView({
|
|
694
613
|
mcApiUrl,
|
|
695
|
-
|
|
614
|
+
organizationId,
|
|
615
|
+
data,
|
|
696
616
|
applicationIdentifier
|
|
697
617
|
});
|
|
698
|
-
if (!
|
|
699
|
-
|
|
700
|
-
const userOrganizations = await graphqlRequests.fetchUserOrganizations({
|
|
701
|
-
mcApiUrl,
|
|
702
|
-
customViewId,
|
|
703
|
-
applicationIdentifier
|
|
704
|
-
});
|
|
705
|
-
let organizationId, organizationName;
|
|
706
|
-
if (userOrganizations.total === 0) {
|
|
707
|
-
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.`);
|
|
708
|
-
}
|
|
709
|
-
if (userOrganizations.total === 1) {
|
|
710
|
-
const _userOrganizations$re2 = _slicedToArray(userOrganizations.results, 1),
|
|
711
|
-
organization = _userOrganizations$re2[0];
|
|
712
|
-
organizationId = organization.id;
|
|
713
|
-
organizationName = organization.name;
|
|
714
|
-
} else {
|
|
715
|
-
var _context4;
|
|
716
|
-
const organizationChoices = _mapInstanceProperty__default["default"](_context4 = userOrganizations.results).call(_context4, organization => ({
|
|
717
|
-
title: organization.name,
|
|
718
|
-
value: organization.id
|
|
719
|
-
}));
|
|
720
|
-
const _await$prompts4 = await prompts__default["default"]({
|
|
721
|
-
type: 'select',
|
|
722
|
-
name: 'organizationId',
|
|
723
|
-
message: 'Select an Organization',
|
|
724
|
-
choices: organizationChoices,
|
|
725
|
-
initial: 0
|
|
726
|
-
}),
|
|
727
|
-
selectedOrganizationId = _await$prompts4.organizationId;
|
|
728
|
-
if (!selectedOrganizationId) {
|
|
729
|
-
throw new Error(`No Organization selected, aborting.`);
|
|
730
|
-
}
|
|
731
|
-
organizationId = selectedOrganizationId;
|
|
732
|
-
organizationName = _findInstanceProperty__default["default"](organizationChoices).call(organizationChoices, _ref5 => {
|
|
733
|
-
let value = _ref5.value;
|
|
734
|
-
return value === organizationId;
|
|
735
|
-
}).title;
|
|
736
|
-
}
|
|
737
|
-
const _await$prompts5 = await prompts__default["default"]({
|
|
738
|
-
type: 'text',
|
|
739
|
-
name: 'confirmation',
|
|
740
|
-
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'),
|
|
741
|
-
initial: 'yes'
|
|
742
|
-
}),
|
|
743
|
-
confirmation = _await$prompts5.confirmation;
|
|
744
|
-
if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
|
|
745
|
-
console.log(chalk__default["default"].red('Aborted.'));
|
|
746
|
-
return;
|
|
747
|
-
}
|
|
748
|
-
const data = omit__default["default"](localCustomEntityData, ['id']);
|
|
749
|
-
if (options.dryRun) {
|
|
750
|
-
console.log();
|
|
751
|
-
console.log(`The following payload would be used to create a new Custom View.`);
|
|
752
|
-
console.log();
|
|
753
|
-
console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
|
|
754
|
-
return;
|
|
755
|
-
}
|
|
756
|
-
const createdCustomView = await graphqlRequests.createCustomView({
|
|
757
|
-
mcApiUrl,
|
|
758
|
-
organizationId,
|
|
759
|
-
data,
|
|
760
|
-
applicationIdentifier
|
|
761
|
-
});
|
|
762
|
-
|
|
763
|
-
// This check is technically not necessary, as the `graphql-request` client
|
|
764
|
-
// throws an error in case of GraphQL errors.
|
|
765
|
-
// However, the generated TypeScript data related to the GraphQL query has the
|
|
766
|
-
// field typed as optional, thus having an extra check for type correctness.
|
|
767
|
-
if (!createdCustomView) {
|
|
768
|
-
throw new Error('Failed to create the Custom View.');
|
|
769
|
-
}
|
|
770
|
-
const customViewLink = getMcUrlLink({
|
|
771
|
-
mcApiUrl,
|
|
772
|
-
organizationId,
|
|
773
|
-
customEntityId: createdCustomView.id,
|
|
774
|
-
isCustomView: true
|
|
775
|
-
});
|
|
776
|
-
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)}".`));
|
|
777
|
-
console.log(`You can inspect the Custom View data in the Merchant Center at "${chalk__default["default"].gray(customViewLink)}".`);
|
|
778
|
-
return;
|
|
618
|
+
if (!createdCustomView) {
|
|
619
|
+
throw new Error('Failed to create the Custom View.');
|
|
779
620
|
}
|
|
780
621
|
const customViewLink = getMcUrlLink({
|
|
781
622
|
mcApiUrl,
|
|
782
|
-
organizationId
|
|
783
|
-
customEntityId:
|
|
623
|
+
organizationId,
|
|
624
|
+
customEntityId: createdCustomView.id,
|
|
784
625
|
isCustomView: true
|
|
785
626
|
});
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
initial: 'yes'
|
|
800
|
-
}),
|
|
801
|
-
confirmation = _await$prompts6.confirmation;
|
|
802
|
-
if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
|
|
803
|
-
console.log(chalk__default["default"].red('Aborted.'));
|
|
804
|
-
return;
|
|
805
|
-
}
|
|
627
|
+
console.log(chalk__default["default"].green('Custom View created successfully.'));
|
|
628
|
+
console.log(`ID: ${chalk__default["default"].cyan(createdCustomView.id)}`);
|
|
629
|
+
console.log(`Please update the "env.production.customViewId" field in your local Custom View config file with the ID above.`);
|
|
630
|
+
console.log(`URL: ${chalk__default["default"].gray(customViewLink)}`);
|
|
631
|
+
return createdCustomView.id;
|
|
632
|
+
}
|
|
633
|
+
async function performUpdateCustomView(_ref5) {
|
|
634
|
+
let mcApiUrl = _ref5.mcApiUrl,
|
|
635
|
+
organizationId = _ref5.organizationId,
|
|
636
|
+
customViewId = _ref5.customViewId,
|
|
637
|
+
localCustomEntityData = _ref5.localCustomEntityData,
|
|
638
|
+
applicationIdentifier = _ref5.applicationIdentifier,
|
|
639
|
+
dryRun = _ref5.dryRun;
|
|
806
640
|
const data = omit__default["default"](localCustomEntityData, ['id']);
|
|
807
|
-
if (
|
|
808
|
-
console.log();
|
|
809
|
-
console.log(`The following payload would be used to update the Custom View "${chalk__default["default"].green(data.defaultLabel)}".`);
|
|
641
|
+
if (dryRun) {
|
|
810
642
|
console.log();
|
|
643
|
+
console.log(`Dry run - would update Custom View "${chalk__default["default"].green(data.defaultLabel)}" with:`);
|
|
811
644
|
console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
|
|
812
645
|
return;
|
|
813
646
|
}
|
|
647
|
+
console.log('Updating Custom View...');
|
|
814
648
|
await graphqlRequests.updateCustomView({
|
|
815
649
|
mcApiUrl,
|
|
816
|
-
organizationId
|
|
817
|
-
data
|
|
818
|
-
customViewId
|
|
650
|
+
organizationId,
|
|
651
|
+
data,
|
|
652
|
+
customViewId,
|
|
819
653
|
applicationIdentifier
|
|
820
654
|
});
|
|
821
|
-
|
|
822
|
-
|
|
655
|
+
const customViewLink = getMcUrlLink({
|
|
656
|
+
mcApiUrl,
|
|
657
|
+
organizationId,
|
|
658
|
+
customEntityId: customViewId,
|
|
659
|
+
isCustomView: true
|
|
660
|
+
});
|
|
661
|
+
console.log(chalk__default["default"].green('Custom View updated successfully.'));
|
|
662
|
+
console.log(`URL: ${chalk__default["default"].gray(customViewLink)}`);
|
|
823
663
|
}
|
|
824
|
-
async function
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
if (!
|
|
835
|
-
|
|
664
|
+
async function checkCustomApplicationStatus(_ref6) {
|
|
665
|
+
let mcApiUrl = _ref6.mcApiUrl,
|
|
666
|
+
entryPointUriPath = _ref6.entryPointUriPath,
|
|
667
|
+
applicationIdentifier = _ref6.applicationIdentifier,
|
|
668
|
+
localCustomEntityData = _ref6.localCustomEntityData;
|
|
669
|
+
const fetchedCustomApplication = await graphqlRequests.fetchCustomApplication({
|
|
670
|
+
mcApiUrl,
|
|
671
|
+
entryPointUriPath,
|
|
672
|
+
applicationIdentifier
|
|
673
|
+
});
|
|
674
|
+
if (!fetchedCustomApplication) {
|
|
675
|
+
return {
|
|
676
|
+
exists: false
|
|
677
|
+
};
|
|
836
678
|
}
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
679
|
+
const configDiff = getCustomApplicationConfigDiff(fetchedCustomApplication.application, localCustomEntityData);
|
|
680
|
+
const customAppLink = getMcUrlLink({
|
|
681
|
+
mcApiUrl,
|
|
682
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
683
|
+
customEntityId: fetchedCustomApplication.application.id
|
|
684
|
+
});
|
|
685
|
+
return {
|
|
686
|
+
exists: true,
|
|
687
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
688
|
+
applicationId: fetchedCustomApplication.application.id,
|
|
689
|
+
configDiff,
|
|
690
|
+
link: customAppLink
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
async function checkCustomViewStatus(_ref7) {
|
|
694
|
+
let mcApiUrl = _ref7.mcApiUrl,
|
|
695
|
+
customViewId = _ref7.customViewId,
|
|
696
|
+
applicationIdentifier = _ref7.applicationIdentifier,
|
|
697
|
+
localCustomEntityData = _ref7.localCustomEntityData;
|
|
698
|
+
const fetchedCustomView = await graphqlRequests.fetchCustomView({
|
|
699
|
+
mcApiUrl,
|
|
700
|
+
customViewId,
|
|
701
|
+
applicationIdentifier
|
|
702
|
+
});
|
|
703
|
+
if (!fetchedCustomView) {
|
|
704
|
+
return {
|
|
705
|
+
exists: false
|
|
706
|
+
};
|
|
852
707
|
}
|
|
708
|
+
const configDiff = getCustomViewConfigDiff(fetchedCustomView.customView, localCustomEntityData);
|
|
709
|
+
const customViewLink = getMcUrlLink({
|
|
710
|
+
mcApiUrl,
|
|
711
|
+
organizationId: fetchedCustomView.organizationId,
|
|
712
|
+
customEntityId: fetchedCustomView?.customView?.id || '',
|
|
713
|
+
isCustomView: true
|
|
714
|
+
});
|
|
715
|
+
return {
|
|
716
|
+
exists: true,
|
|
717
|
+
organizationId: fetchedCustomView.organizationId,
|
|
718
|
+
customViewId: fetchedCustomView?.customView?.id || '',
|
|
719
|
+
configDiff,
|
|
720
|
+
link: customViewLink
|
|
721
|
+
};
|
|
853
722
|
}
|
|
854
723
|
|
|
855
|
-
exports
|
|
724
|
+
exports.checkCustomApplicationStatus = checkCustomApplicationStatus;
|
|
725
|
+
exports.checkCustomViewStatus = checkCustomViewStatus;
|
|
726
|
+
exports.isCustomViewData = isCustomViewData;
|
|
727
|
+
exports.performCreateCustomApplication = performCreateCustomApplication;
|
|
728
|
+
exports.performCreateCustomView = performCreateCustomView;
|
|
729
|
+
exports.performUpdateCustomApplication = performUpdateCustomApplication;
|
|
730
|
+
exports.performUpdateCustomView = performUpdateCustomView;
|