@commercetools-frontend/mc-scripts 21.8.0 → 21.10.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 +34 -21
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +34 -21
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +34 -21
- package/dist/{build-8582b673.esm.js → build-4b9ac48f.esm.js} +3 -3
- package/dist/{build-97278377.cjs.dev.js → build-83e7cede.cjs.dev.js} +3 -3
- package/dist/{build-9395925a.cjs.prod.js → build-f523f508.cjs.prod.js} +3 -3
- package/dist/{build-vite-6c987a60.cjs.dev.js → build-vite-3b82522e.cjs.dev.js} +44 -2
- package/dist/{build-vite-a9602b19.esm.js → build-vite-93abdc95.esm.js} +44 -2
- package/dist/{build-vite-76d44332.cjs.prod.js → build-vite-b7cd993a.cjs.prod.js} +44 -2
- 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/{compile-html-4832f8c5.esm.js → compile-html-4361a0b3.esm.js} +18 -24
- package/dist/{compile-html-7654b5e6.cjs.prod.js → compile-html-d6331c35.cjs.prod.js} +18 -24
- package/dist/{compile-html-0c588a89.cjs.dev.js → compile-html-d9e731aa.cjs.dev.js} +18 -24
- package/dist/{config-sync-62824317.cjs.prod.js → config-sync-a3170b54.cjs.prod.js} +46 -74
- package/dist/{config-sync-d52e73f6.cjs.dev.js → config-sync-ec048923.cjs.dev.js} +46 -74
- package/dist/{config-sync-20bc05e8.esm.js → config-sync-f97789c5.esm.js} +46 -74
- package/dist/{create-postcss-config-8ea16440.cjs.prod.js → create-postcss-config-0c0236bf.cjs.prod.js} +1 -1
- package/dist/{create-postcss-config-4cbe10ab.cjs.dev.js → create-postcss-config-2a0d05b2.cjs.dev.js} +1 -1
- package/dist/{create-postcss-config-c1aa3525.esm.js → create-postcss-config-d2bf4c66.esm.js} +1 -1
- package/dist/{create-webpack-config-for-development-a5e73092.cjs.prod.js → create-webpack-config-for-development-1da79732.cjs.prod.js} +5 -4
- package/dist/{create-webpack-config-for-development-e2735e02.cjs.dev.js → create-webpack-config-for-development-47d59cb3.cjs.dev.js} +5 -4
- package/dist/{create-webpack-config-for-development-8a8b84d6.esm.js → create-webpack-config-for-development-a546d54f.esm.js} +5 -4
- package/dist/{create-webpack-config-for-production-4e7b56c0.cjs.prod.js → create-webpack-config-for-production-3fd4683d.cjs.prod.js} +5 -4
- package/dist/{create-webpack-config-for-production-7dc669e5.esm.js → create-webpack-config-for-production-8d1ce439.esm.js} +5 -4
- package/dist/{create-webpack-config-for-production-d9bf281c.cjs.dev.js → create-webpack-config-for-production-db313b50.cjs.dev.js} +5 -4
- package/dist/declarations/src/commands/compile-html.d.ts +1 -1
- package/dist/declarations/src/commands/config-sync.d.ts +1 -1
- package/dist/declarations/src/config/moment-locales.d.ts +2 -0
- package/dist/declarations/src/generated/settings.d.ts +110 -8
- package/dist/declarations/src/types.d.ts +3 -3
- package/dist/declarations/src/vite-plugins/vite-plugin-custom-application.d.ts +4 -0
- package/dist/declarations/src/vite-plugins/vite-plugin-dynamic-base-assets-globals.d.ts +3 -0
- package/dist/declarations/src/vite-plugins/vite-plugin-svgr.d.ts +3 -0
- package/dist/{login-7d94659e.esm.js → login-0f875277.esm.js} +2 -2
- package/dist/{login-779552b7.cjs.dev.js → login-47ddbfc2.cjs.dev.js} +2 -2
- package/dist/{login-706ccc9a.cjs.prod.js → login-a99bba7b.cjs.prod.js} +2 -2
- package/dist/{package-aaf61bf0.cjs.dev.js → package-430e0951.cjs.prod.js} +25 -21
- package/dist/{package-b5c040f3.cjs.prod.js → package-7d0afacb.cjs.dev.js} +25 -21
- package/dist/{package-a98de907.esm.js → package-b2f3ad5a.esm.js} +25 -21
- package/dist/{start-e3ccd672.cjs.prod.js → start-5ba2b72f.cjs.prod.js} +3 -3
- package/dist/{start-2b953ab0.cjs.dev.js → start-bfb77660.cjs.dev.js} +3 -3
- package/dist/{start-e924bd5d.esm.js → start-f401e82c.esm.js} +3 -3
- package/dist/{start-vite-737bacca.cjs.dev.js → start-vite-22de08dc.cjs.dev.js} +7 -5
- package/dist/{start-vite-ec5d40b5.esm.js → start-vite-dc046cba.esm.js} +7 -5
- package/dist/{start-vite-b0f58ae4.cjs.prod.js → start-vite-fe13330b.cjs.prod.js} +7 -5
- package/dist/{user-agent-d18809af.cjs.prod.js → user-agent-837f1c7f.cjs.prod.js} +1 -1
- package/dist/{user-agent-8044acd6.esm.js → user-agent-b737c3ac.esm.js} +1 -1
- package/dist/{user-agent-5da1830b.cjs.dev.js → user-agent-f4549ad1.cjs.dev.js} +1 -1
- package/dist/vite-plugin-svgr-4205f2b5.cjs.dev.js +110 -0
- package/dist/vite-plugin-svgr-eb8524fa.esm.js +85 -0
- package/dist/vite-plugin-svgr-f3bbedbe.cjs.prod.js +110 -0
- package/package.json +25 -21
- 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
|
@@ -11,7 +11,7 @@ var omit = require('lodash/omit');
|
|
|
11
11
|
var prompts = require('prompts');
|
|
12
12
|
var chalk = require('chalk');
|
|
13
13
|
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
14
|
-
var userAgent = require('./user-agent-
|
|
14
|
+
var userAgent = require('./user-agent-837f1c7f.cjs.prod.js');
|
|
15
15
|
var graphqlRequest = require('graphql-request');
|
|
16
16
|
var constants = require('@commercetools-frontend/constants');
|
|
17
17
|
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
@@ -33,7 +33,7 @@ require('fs');
|
|
|
33
33
|
require('path');
|
|
34
34
|
require('os');
|
|
35
35
|
require('@commercetools/http-user-agent');
|
|
36
|
-
require('./package-
|
|
36
|
+
require('./package-430e0951.cjs.prod.js');
|
|
37
37
|
|
|
38
38
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
39
39
|
|
|
@@ -624,112 +624,84 @@ var getMcUrlLink = function getMcUrlLink(mcApiUrl, organizationId, applicationId
|
|
|
624
624
|
return customAppLink;
|
|
625
625
|
};
|
|
626
626
|
|
|
627
|
-
function run() {
|
|
627
|
+
function run(_x) {
|
|
628
628
|
return _run.apply(this, arguments);
|
|
629
629
|
}
|
|
630
630
|
|
|
631
631
|
function _run() {
|
|
632
|
-
_run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
|
|
632
|
+
_run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(options) {
|
|
633
633
|
var _context6;
|
|
634
634
|
|
|
635
|
-
var
|
|
636
|
-
applicationConfig$1,
|
|
637
|
-
localCustomAppData,
|
|
638
|
-
mcApiUrl,
|
|
639
|
-
token,
|
|
640
|
-
fetchedCustomApplication,
|
|
641
|
-
_context4,
|
|
642
|
-
_context5,
|
|
643
|
-
userOrganizations,
|
|
644
|
-
organizationId,
|
|
645
|
-
organizationName,
|
|
646
|
-
_userOrganizations$re,
|
|
647
|
-
organization,
|
|
648
|
-
_context3,
|
|
649
|
-
organizationChoices,
|
|
650
|
-
_yield$prompts,
|
|
651
|
-
selectedOrganizationId,
|
|
652
|
-
_yield$prompts2,
|
|
653
|
-
_confirmation,
|
|
654
|
-
_data,
|
|
655
|
-
createdCustomApplication,
|
|
656
|
-
_customAppLink,
|
|
657
|
-
customAppLink,
|
|
658
|
-
configDiff,
|
|
659
|
-
_yield$prompts3,
|
|
660
|
-
confirmation,
|
|
661
|
-
data,
|
|
662
|
-
_args = arguments;
|
|
635
|
+
var applicationConfig$1, localCustomAppData, mcApiUrl, token, fetchedCustomApplication, _context4, _context5, userOrganizations, organizationId, organizationName, _userOrganizations$re, organization, _context3, organizationChoices, _yield$prompts, selectedOrganizationId, _yield$prompts2, _confirmation, _data, createdCustomApplication, _customAppLink, customAppLink, configDiff, _yield$prompts3, confirmation, data;
|
|
663
636
|
|
|
664
637
|
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context7) {
|
|
665
638
|
while (1) {
|
|
666
639
|
switch (_context7.prev = _context7.next) {
|
|
667
640
|
case 0:
|
|
668
|
-
options = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
|
|
669
641
|
applicationConfig$1 = applicationConfig.processConfig();
|
|
670
642
|
localCustomAppData = applicationConfig$1.data;
|
|
671
643
|
mcApiUrl = applicationConfig$1.env.mcApiUrl;
|
|
672
644
|
token = credentialsStorage.getToken(mcApiUrl);
|
|
673
645
|
|
|
674
646
|
if (token) {
|
|
675
|
-
_context7.next =
|
|
647
|
+
_context7.next = 6;
|
|
676
648
|
break;
|
|
677
649
|
}
|
|
678
650
|
|
|
679
651
|
throw new Error("You don't have a valid session for the ".concat(mcApiUrl, " environment. Please, run the \"mc-scripts login\" command to authenticate yourself."));
|
|
680
652
|
|
|
681
|
-
case
|
|
682
|
-
_context7.next =
|
|
653
|
+
case 6:
|
|
654
|
+
_context7.next = 8;
|
|
683
655
|
return fetchCustomApplication({
|
|
684
656
|
mcApiUrl: mcApiUrl,
|
|
685
657
|
token: token,
|
|
686
658
|
entryPointUriPath: localCustomAppData.entryPointUriPath
|
|
687
659
|
});
|
|
688
660
|
|
|
689
|
-
case
|
|
661
|
+
case 8:
|
|
690
662
|
fetchedCustomApplication = _context7.sent;
|
|
691
663
|
|
|
692
664
|
if (fetchedCustomApplication) {
|
|
693
|
-
_context7.next =
|
|
665
|
+
_context7.next = 51;
|
|
694
666
|
break;
|
|
695
667
|
}
|
|
696
668
|
|
|
697
|
-
_context7.next =
|
|
669
|
+
_context7.next = 12;
|
|
698
670
|
return fetchUserOrganizations({
|
|
699
671
|
mcApiUrl: mcApiUrl,
|
|
700
672
|
token: token
|
|
701
673
|
});
|
|
702
674
|
|
|
703
|
-
case
|
|
675
|
+
case 12:
|
|
704
676
|
userOrganizations = _context7.sent;
|
|
705
677
|
|
|
706
678
|
if (!(userOrganizations.total === 0)) {
|
|
707
|
-
_context7.next =
|
|
679
|
+
_context7.next = 15;
|
|
708
680
|
break;
|
|
709
681
|
}
|
|
710
682
|
|
|
711
683
|
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.");
|
|
712
684
|
|
|
713
|
-
case
|
|
685
|
+
case 15:
|
|
714
686
|
if (!(userOrganizations.total === 1)) {
|
|
715
|
-
_context7.next =
|
|
687
|
+
_context7.next = 21;
|
|
716
688
|
break;
|
|
717
689
|
}
|
|
718
690
|
|
|
719
691
|
_userOrganizations$re = _slicedToArray(userOrganizations.results, 1), organization = _userOrganizations$re[0];
|
|
720
692
|
organizationId = organization.id;
|
|
721
693
|
organizationName = organization.name;
|
|
722
|
-
_context7.next =
|
|
694
|
+
_context7.next = 30;
|
|
723
695
|
break;
|
|
724
696
|
|
|
725
|
-
case
|
|
697
|
+
case 21:
|
|
726
698
|
organizationChoices = _mapInstanceProperty__default["default"](_context3 = userOrganizations.results).call(_context3, function (organization) {
|
|
727
699
|
return {
|
|
728
700
|
title: organization.name,
|
|
729
701
|
value: organization.id
|
|
730
702
|
};
|
|
731
703
|
});
|
|
732
|
-
_context7.next =
|
|
704
|
+
_context7.next = 24;
|
|
733
705
|
return prompts__default["default"]({
|
|
734
706
|
type: 'select',
|
|
735
707
|
name: 'organizationId',
|
|
@@ -738,26 +710,26 @@ function _run() {
|
|
|
738
710
|
initial: 0
|
|
739
711
|
});
|
|
740
712
|
|
|
741
|
-
case
|
|
713
|
+
case 24:
|
|
742
714
|
_yield$prompts = _context7.sent;
|
|
743
715
|
selectedOrganizationId = _yield$prompts.organizationId;
|
|
744
716
|
|
|
745
717
|
if (selectedOrganizationId) {
|
|
746
|
-
_context7.next =
|
|
718
|
+
_context7.next = 28;
|
|
747
719
|
break;
|
|
748
720
|
}
|
|
749
721
|
|
|
750
722
|
throw new Error("No Organization selected, aborting.");
|
|
751
723
|
|
|
752
|
-
case
|
|
724
|
+
case 28:
|
|
753
725
|
organizationId = selectedOrganizationId;
|
|
754
726
|
organizationName = _findInstanceProperty__default["default"](organizationChoices).call(organizationChoices, function (_ref) {
|
|
755
727
|
var value = _ref.value;
|
|
756
728
|
return value === organizationId;
|
|
757
729
|
}).title;
|
|
758
730
|
|
|
759
|
-
case
|
|
760
|
-
_context7.next =
|
|
731
|
+
case 30:
|
|
732
|
+
_context7.next = 32;
|
|
761
733
|
return prompts__default["default"]({
|
|
762
734
|
type: 'text',
|
|
763
735
|
name: 'confirmation',
|
|
@@ -765,23 +737,23 @@ function _run() {
|
|
|
765
737
|
initial: 'yes'
|
|
766
738
|
});
|
|
767
739
|
|
|
768
|
-
case
|
|
740
|
+
case 32:
|
|
769
741
|
_yield$prompts2 = _context7.sent;
|
|
770
742
|
_confirmation = _yield$prompts2.confirmation;
|
|
771
743
|
|
|
772
744
|
if (!(!_confirmation || _confirmation.toLowerCase().charAt(0) !== 'y')) {
|
|
773
|
-
_context7.next =
|
|
745
|
+
_context7.next = 37;
|
|
774
746
|
break;
|
|
775
747
|
}
|
|
776
748
|
|
|
777
749
|
console.log(chalk__default["default"].red('Aborted.'));
|
|
778
750
|
return _context7.abrupt("return");
|
|
779
751
|
|
|
780
|
-
case
|
|
752
|
+
case 37:
|
|
781
753
|
_data = omit__default["default"](localCustomAppData, ['id']);
|
|
782
754
|
|
|
783
|
-
if (!options
|
|
784
|
-
_context7.next =
|
|
755
|
+
if (!options.dryRun) {
|
|
756
|
+
_context7.next = 43;
|
|
785
757
|
break;
|
|
786
758
|
}
|
|
787
759
|
|
|
@@ -790,8 +762,8 @@ function _run() {
|
|
|
790
762
|
console.log(_JSON$stringify__default["default"](_data));
|
|
791
763
|
return _context7.abrupt("return");
|
|
792
764
|
|
|
793
|
-
case
|
|
794
|
-
_context7.next =
|
|
765
|
+
case 43:
|
|
766
|
+
_context7.next = 45;
|
|
795
767
|
return createCustomApplication({
|
|
796
768
|
mcApiUrl: mcApiUrl,
|
|
797
769
|
token: token,
|
|
@@ -799,36 +771,36 @@ function _run() {
|
|
|
799
771
|
data: _data
|
|
800
772
|
});
|
|
801
773
|
|
|
802
|
-
case
|
|
774
|
+
case 45:
|
|
803
775
|
createdCustomApplication = _context7.sent;
|
|
804
776
|
|
|
805
777
|
if (createdCustomApplication) {
|
|
806
|
-
_context7.next =
|
|
778
|
+
_context7.next = 48;
|
|
807
779
|
break;
|
|
808
780
|
}
|
|
809
781
|
|
|
810
782
|
throw new Error('Failed to create the Custom Application.');
|
|
811
783
|
|
|
812
|
-
case
|
|
784
|
+
case 48:
|
|
813
785
|
_customAppLink = getMcUrlLink(mcApiUrl, organizationId, createdCustomApplication.id);
|
|
814
786
|
console.log(chalk__default["default"].green(_concatInstanceProperty__default["default"](_context5 = "Custom Application created.\nThe \"applicationId\" in your local Custom Application config file should be updated with the application ID: ".concat(createdCustomApplication.id, ".\nYou can see the Custom Application data in the Merchant Center at ")).call(_context5, _customAppLink, ".")));
|
|
815
787
|
return _context7.abrupt("return");
|
|
816
788
|
|
|
817
|
-
case
|
|
789
|
+
case 51:
|
|
818
790
|
customAppLink = getMcUrlLink(mcApiUrl, fetchedCustomApplication.organizationId, fetchedCustomApplication.application.id);
|
|
819
791
|
configDiff = getConfigDiff(fetchedCustomApplication.application, localCustomAppData);
|
|
820
792
|
|
|
821
793
|
if (configDiff) {
|
|
822
|
-
_context7.next =
|
|
794
|
+
_context7.next = 56;
|
|
823
795
|
break;
|
|
824
796
|
}
|
|
825
797
|
|
|
826
798
|
console.log(chalk__default["default"].green("Custom Application is already up to date.\nYou can see the Custom Application data in the Merchant Center at ".concat(customAppLink, ".")));
|
|
827
799
|
return _context7.abrupt("return");
|
|
828
800
|
|
|
829
|
-
case
|
|
801
|
+
case 56:
|
|
830
802
|
console.log(configDiff);
|
|
831
|
-
_context7.next =
|
|
803
|
+
_context7.next = 59;
|
|
832
804
|
return prompts__default["default"]({
|
|
833
805
|
type: 'text',
|
|
834
806
|
name: 'confirmation',
|
|
@@ -836,23 +808,23 @@ function _run() {
|
|
|
836
808
|
initial: 'yes'
|
|
837
809
|
});
|
|
838
810
|
|
|
839
|
-
case
|
|
811
|
+
case 59:
|
|
840
812
|
_yield$prompts3 = _context7.sent;
|
|
841
813
|
confirmation = _yield$prompts3.confirmation;
|
|
842
814
|
|
|
843
815
|
if (!(!confirmation || confirmation.toLowerCase().charAt(0) !== 'y')) {
|
|
844
|
-
_context7.next =
|
|
816
|
+
_context7.next = 64;
|
|
845
817
|
break;
|
|
846
818
|
}
|
|
847
819
|
|
|
848
820
|
console.log(chalk__default["default"].red('Aborted.'));
|
|
849
821
|
return _context7.abrupt("return");
|
|
850
822
|
|
|
851
|
-
case
|
|
823
|
+
case 64:
|
|
852
824
|
data = omit__default["default"](localCustomAppData, ['id']);
|
|
853
825
|
|
|
854
|
-
if (!options
|
|
855
|
-
_context7.next =
|
|
826
|
+
if (!options.dryRun) {
|
|
827
|
+
_context7.next = 70;
|
|
856
828
|
break;
|
|
857
829
|
}
|
|
858
830
|
|
|
@@ -861,8 +833,8 @@ function _run() {
|
|
|
861
833
|
console.log(_JSON$stringify__default["default"](data));
|
|
862
834
|
return _context7.abrupt("return");
|
|
863
835
|
|
|
864
|
-
case
|
|
865
|
-
_context7.next =
|
|
836
|
+
case 70:
|
|
837
|
+
_context7.next = 72;
|
|
866
838
|
return updateCustomApplication({
|
|
867
839
|
mcApiUrl: mcApiUrl,
|
|
868
840
|
token: token,
|
|
@@ -871,10 +843,10 @@ function _run() {
|
|
|
871
843
|
applicationId: fetchedCustomApplication.application.id
|
|
872
844
|
});
|
|
873
845
|
|
|
874
|
-
case
|
|
846
|
+
case 72:
|
|
875
847
|
console.log(chalk__default["default"].green("Custom Application updated.\nYou can see the Custom Application data in the Merchant Center at ".concat(customAppLink, ".")));
|
|
876
848
|
|
|
877
|
-
case
|
|
849
|
+
case 73:
|
|
878
850
|
case "end":
|
|
879
851
|
return _context7.stop();
|
|
880
852
|
}
|
|
@@ -11,7 +11,7 @@ var omit = require('lodash/omit');
|
|
|
11
11
|
var prompts = require('prompts');
|
|
12
12
|
var chalk = require('chalk');
|
|
13
13
|
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
14
|
-
var userAgent = require('./user-agent-
|
|
14
|
+
var userAgent = require('./user-agent-f4549ad1.cjs.dev.js');
|
|
15
15
|
var graphqlRequest = require('graphql-request');
|
|
16
16
|
var constants = require('@commercetools-frontend/constants');
|
|
17
17
|
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
@@ -33,7 +33,7 @@ require('fs');
|
|
|
33
33
|
require('path');
|
|
34
34
|
require('os');
|
|
35
35
|
require('@commercetools/http-user-agent');
|
|
36
|
-
require('./package-
|
|
36
|
+
require('./package-7d0afacb.cjs.dev.js');
|
|
37
37
|
|
|
38
38
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
39
39
|
|
|
@@ -629,112 +629,84 @@ var getMcUrlLink = function getMcUrlLink(mcApiUrl, organizationId, applicationId
|
|
|
629
629
|
return customAppLink;
|
|
630
630
|
};
|
|
631
631
|
|
|
632
|
-
function run() {
|
|
632
|
+
function run(_x) {
|
|
633
633
|
return _run.apply(this, arguments);
|
|
634
634
|
}
|
|
635
635
|
|
|
636
636
|
function _run() {
|
|
637
|
-
_run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
|
|
637
|
+
_run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(options) {
|
|
638
638
|
var _context6;
|
|
639
639
|
|
|
640
|
-
var
|
|
641
|
-
applicationConfig$1,
|
|
642
|
-
localCustomAppData,
|
|
643
|
-
mcApiUrl,
|
|
644
|
-
token,
|
|
645
|
-
fetchedCustomApplication,
|
|
646
|
-
_context4,
|
|
647
|
-
_context5,
|
|
648
|
-
userOrganizations,
|
|
649
|
-
organizationId,
|
|
650
|
-
organizationName,
|
|
651
|
-
_userOrganizations$re,
|
|
652
|
-
organization,
|
|
653
|
-
_context3,
|
|
654
|
-
organizationChoices,
|
|
655
|
-
_yield$prompts,
|
|
656
|
-
selectedOrganizationId,
|
|
657
|
-
_yield$prompts2,
|
|
658
|
-
_confirmation,
|
|
659
|
-
_data,
|
|
660
|
-
createdCustomApplication,
|
|
661
|
-
_customAppLink,
|
|
662
|
-
customAppLink,
|
|
663
|
-
configDiff,
|
|
664
|
-
_yield$prompts3,
|
|
665
|
-
confirmation,
|
|
666
|
-
data,
|
|
667
|
-
_args = arguments;
|
|
640
|
+
var applicationConfig$1, localCustomAppData, mcApiUrl, token, fetchedCustomApplication, _context4, _context5, userOrganizations, organizationId, organizationName, _userOrganizations$re, organization, _context3, organizationChoices, _yield$prompts, selectedOrganizationId, _yield$prompts2, _confirmation, _data, createdCustomApplication, _customAppLink, customAppLink, configDiff, _yield$prompts3, confirmation, data;
|
|
668
641
|
|
|
669
642
|
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context7) {
|
|
670
643
|
while (1) {
|
|
671
644
|
switch (_context7.prev = _context7.next) {
|
|
672
645
|
case 0:
|
|
673
|
-
options = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
|
|
674
646
|
applicationConfig$1 = applicationConfig.processConfig();
|
|
675
647
|
localCustomAppData = applicationConfig$1.data;
|
|
676
648
|
mcApiUrl = applicationConfig$1.env.mcApiUrl;
|
|
677
649
|
token = credentialsStorage.getToken(mcApiUrl);
|
|
678
650
|
|
|
679
651
|
if (token) {
|
|
680
|
-
_context7.next =
|
|
652
|
+
_context7.next = 6;
|
|
681
653
|
break;
|
|
682
654
|
}
|
|
683
655
|
|
|
684
656
|
throw new Error("You don't have a valid session for the ".concat(mcApiUrl, " environment. Please, run the \"mc-scripts login\" command to authenticate yourself."));
|
|
685
657
|
|
|
686
|
-
case
|
|
687
|
-
_context7.next =
|
|
658
|
+
case 6:
|
|
659
|
+
_context7.next = 8;
|
|
688
660
|
return fetchCustomApplication({
|
|
689
661
|
mcApiUrl: mcApiUrl,
|
|
690
662
|
token: token,
|
|
691
663
|
entryPointUriPath: localCustomAppData.entryPointUriPath
|
|
692
664
|
});
|
|
693
665
|
|
|
694
|
-
case
|
|
666
|
+
case 8:
|
|
695
667
|
fetchedCustomApplication = _context7.sent;
|
|
696
668
|
|
|
697
669
|
if (fetchedCustomApplication) {
|
|
698
|
-
_context7.next =
|
|
670
|
+
_context7.next = 51;
|
|
699
671
|
break;
|
|
700
672
|
}
|
|
701
673
|
|
|
702
|
-
_context7.next =
|
|
674
|
+
_context7.next = 12;
|
|
703
675
|
return fetchUserOrganizations({
|
|
704
676
|
mcApiUrl: mcApiUrl,
|
|
705
677
|
token: token
|
|
706
678
|
});
|
|
707
679
|
|
|
708
|
-
case
|
|
680
|
+
case 12:
|
|
709
681
|
userOrganizations = _context7.sent;
|
|
710
682
|
|
|
711
683
|
if (!(userOrganizations.total === 0)) {
|
|
712
|
-
_context7.next =
|
|
684
|
+
_context7.next = 15;
|
|
713
685
|
break;
|
|
714
686
|
}
|
|
715
687
|
|
|
716
688
|
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.");
|
|
717
689
|
|
|
718
|
-
case
|
|
690
|
+
case 15:
|
|
719
691
|
if (!(userOrganizations.total === 1)) {
|
|
720
|
-
_context7.next =
|
|
692
|
+
_context7.next = 21;
|
|
721
693
|
break;
|
|
722
694
|
}
|
|
723
695
|
|
|
724
696
|
_userOrganizations$re = _slicedToArray(userOrganizations.results, 1), organization = _userOrganizations$re[0];
|
|
725
697
|
organizationId = organization.id;
|
|
726
698
|
organizationName = organization.name;
|
|
727
|
-
_context7.next =
|
|
699
|
+
_context7.next = 30;
|
|
728
700
|
break;
|
|
729
701
|
|
|
730
|
-
case
|
|
702
|
+
case 21:
|
|
731
703
|
organizationChoices = _mapInstanceProperty__default["default"](_context3 = userOrganizations.results).call(_context3, function (organization) {
|
|
732
704
|
return {
|
|
733
705
|
title: organization.name,
|
|
734
706
|
value: organization.id
|
|
735
707
|
};
|
|
736
708
|
});
|
|
737
|
-
_context7.next =
|
|
709
|
+
_context7.next = 24;
|
|
738
710
|
return prompts__default["default"]({
|
|
739
711
|
type: 'select',
|
|
740
712
|
name: 'organizationId',
|
|
@@ -743,26 +715,26 @@ function _run() {
|
|
|
743
715
|
initial: 0
|
|
744
716
|
});
|
|
745
717
|
|
|
746
|
-
case
|
|
718
|
+
case 24:
|
|
747
719
|
_yield$prompts = _context7.sent;
|
|
748
720
|
selectedOrganizationId = _yield$prompts.organizationId;
|
|
749
721
|
|
|
750
722
|
if (selectedOrganizationId) {
|
|
751
|
-
_context7.next =
|
|
723
|
+
_context7.next = 28;
|
|
752
724
|
break;
|
|
753
725
|
}
|
|
754
726
|
|
|
755
727
|
throw new Error("No Organization selected, aborting.");
|
|
756
728
|
|
|
757
|
-
case
|
|
729
|
+
case 28:
|
|
758
730
|
organizationId = selectedOrganizationId;
|
|
759
731
|
organizationName = _findInstanceProperty__default["default"](organizationChoices).call(organizationChoices, function (_ref) {
|
|
760
732
|
var value = _ref.value;
|
|
761
733
|
return value === organizationId;
|
|
762
734
|
}).title;
|
|
763
735
|
|
|
764
|
-
case
|
|
765
|
-
_context7.next =
|
|
736
|
+
case 30:
|
|
737
|
+
_context7.next = 32;
|
|
766
738
|
return prompts__default["default"]({
|
|
767
739
|
type: 'text',
|
|
768
740
|
name: 'confirmation',
|
|
@@ -770,23 +742,23 @@ function _run() {
|
|
|
770
742
|
initial: 'yes'
|
|
771
743
|
});
|
|
772
744
|
|
|
773
|
-
case
|
|
745
|
+
case 32:
|
|
774
746
|
_yield$prompts2 = _context7.sent;
|
|
775
747
|
_confirmation = _yield$prompts2.confirmation;
|
|
776
748
|
|
|
777
749
|
if (!(!_confirmation || _confirmation.toLowerCase().charAt(0) !== 'y')) {
|
|
778
|
-
_context7.next =
|
|
750
|
+
_context7.next = 37;
|
|
779
751
|
break;
|
|
780
752
|
}
|
|
781
753
|
|
|
782
754
|
console.log(chalk__default["default"].red('Aborted.'));
|
|
783
755
|
return _context7.abrupt("return");
|
|
784
756
|
|
|
785
|
-
case
|
|
757
|
+
case 37:
|
|
786
758
|
_data = omit__default["default"](localCustomAppData, ['id']);
|
|
787
759
|
|
|
788
|
-
if (!options
|
|
789
|
-
_context7.next =
|
|
760
|
+
if (!options.dryRun) {
|
|
761
|
+
_context7.next = 43;
|
|
790
762
|
break;
|
|
791
763
|
}
|
|
792
764
|
|
|
@@ -795,8 +767,8 @@ function _run() {
|
|
|
795
767
|
console.log(_JSON$stringify__default["default"](_data));
|
|
796
768
|
return _context7.abrupt("return");
|
|
797
769
|
|
|
798
|
-
case
|
|
799
|
-
_context7.next =
|
|
770
|
+
case 43:
|
|
771
|
+
_context7.next = 45;
|
|
800
772
|
return createCustomApplication({
|
|
801
773
|
mcApiUrl: mcApiUrl,
|
|
802
774
|
token: token,
|
|
@@ -804,36 +776,36 @@ function _run() {
|
|
|
804
776
|
data: _data
|
|
805
777
|
});
|
|
806
778
|
|
|
807
|
-
case
|
|
779
|
+
case 45:
|
|
808
780
|
createdCustomApplication = _context7.sent;
|
|
809
781
|
|
|
810
782
|
if (createdCustomApplication) {
|
|
811
|
-
_context7.next =
|
|
783
|
+
_context7.next = 48;
|
|
812
784
|
break;
|
|
813
785
|
}
|
|
814
786
|
|
|
815
787
|
throw new Error('Failed to create the Custom Application.');
|
|
816
788
|
|
|
817
|
-
case
|
|
789
|
+
case 48:
|
|
818
790
|
_customAppLink = getMcUrlLink(mcApiUrl, organizationId, createdCustomApplication.id);
|
|
819
791
|
console.log(chalk__default["default"].green(_concatInstanceProperty__default["default"](_context5 = "Custom Application created.\nThe \"applicationId\" in your local Custom Application config file should be updated with the application ID: ".concat(createdCustomApplication.id, ".\nYou can see the Custom Application data in the Merchant Center at ")).call(_context5, _customAppLink, ".")));
|
|
820
792
|
return _context7.abrupt("return");
|
|
821
793
|
|
|
822
|
-
case
|
|
794
|
+
case 51:
|
|
823
795
|
customAppLink = getMcUrlLink(mcApiUrl, fetchedCustomApplication.organizationId, fetchedCustomApplication.application.id);
|
|
824
796
|
configDiff = getConfigDiff(fetchedCustomApplication.application, localCustomAppData);
|
|
825
797
|
|
|
826
798
|
if (configDiff) {
|
|
827
|
-
_context7.next =
|
|
799
|
+
_context7.next = 56;
|
|
828
800
|
break;
|
|
829
801
|
}
|
|
830
802
|
|
|
831
803
|
console.log(chalk__default["default"].green("Custom Application is already up to date.\nYou can see the Custom Application data in the Merchant Center at ".concat(customAppLink, ".")));
|
|
832
804
|
return _context7.abrupt("return");
|
|
833
805
|
|
|
834
|
-
case
|
|
806
|
+
case 56:
|
|
835
807
|
console.log(configDiff);
|
|
836
|
-
_context7.next =
|
|
808
|
+
_context7.next = 59;
|
|
837
809
|
return prompts__default["default"]({
|
|
838
810
|
type: 'text',
|
|
839
811
|
name: 'confirmation',
|
|
@@ -841,23 +813,23 @@ function _run() {
|
|
|
841
813
|
initial: 'yes'
|
|
842
814
|
});
|
|
843
815
|
|
|
844
|
-
case
|
|
816
|
+
case 59:
|
|
845
817
|
_yield$prompts3 = _context7.sent;
|
|
846
818
|
confirmation = _yield$prompts3.confirmation;
|
|
847
819
|
|
|
848
820
|
if (!(!confirmation || confirmation.toLowerCase().charAt(0) !== 'y')) {
|
|
849
|
-
_context7.next =
|
|
821
|
+
_context7.next = 64;
|
|
850
822
|
break;
|
|
851
823
|
}
|
|
852
824
|
|
|
853
825
|
console.log(chalk__default["default"].red('Aborted.'));
|
|
854
826
|
return _context7.abrupt("return");
|
|
855
827
|
|
|
856
|
-
case
|
|
828
|
+
case 64:
|
|
857
829
|
data = omit__default["default"](localCustomAppData, ['id']);
|
|
858
830
|
|
|
859
|
-
if (!options
|
|
860
|
-
_context7.next =
|
|
831
|
+
if (!options.dryRun) {
|
|
832
|
+
_context7.next = 70;
|
|
861
833
|
break;
|
|
862
834
|
}
|
|
863
835
|
|
|
@@ -866,8 +838,8 @@ function _run() {
|
|
|
866
838
|
console.log(_JSON$stringify__default["default"](data));
|
|
867
839
|
return _context7.abrupt("return");
|
|
868
840
|
|
|
869
|
-
case
|
|
870
|
-
_context7.next =
|
|
841
|
+
case 70:
|
|
842
|
+
_context7.next = 72;
|
|
871
843
|
return updateCustomApplication({
|
|
872
844
|
mcApiUrl: mcApiUrl,
|
|
873
845
|
token: token,
|
|
@@ -876,10 +848,10 @@ function _run() {
|
|
|
876
848
|
applicationId: fetchedCustomApplication.application.id
|
|
877
849
|
});
|
|
878
850
|
|
|
879
|
-
case
|
|
851
|
+
case 72:
|
|
880
852
|
console.log(chalk__default["default"].green("Custom Application updated.\nYou can see the Custom Application data in the Merchant Center at ".concat(customAppLink, ".")));
|
|
881
853
|
|
|
882
|
-
case
|
|
854
|
+
case 73:
|
|
883
855
|
case "end":
|
|
884
856
|
return _context7.stop();
|
|
885
857
|
}
|