@commercetools-frontend/mc-scripts 21.7.0 → 21.9.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/LICENSE +1 -1
- package/README.md +1 -42
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.d.ts +1 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.dev.js +7 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.js +7 -0
- package/{build/config/application-runtime.js → application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js} +2 -2
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.esm.js +5 -0
- package/application-runtime/package.json +4 -0
- package/bin/cli.js +1 -1
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.d.ts +1 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +361 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.js +7 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +361 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +345 -0
- package/cli/package.json +4 -0
- package/config/create-webpack-config-for-development.js +7 -1
- package/config/create-webpack-config-for-production.js +7 -1
- package/config/vendors-to-transpile.js +5 -1
- package/dist/build-5357ad26.cjs.prod.js +224 -0
- package/dist/build-9b6d7eee.cjs.dev.js +224 -0
- package/dist/build-c483e87f.esm.js +209 -0
- package/dist/build-vite-3b82522e.cjs.dev.js +151 -0
- package/dist/build-vite-93abdc95.esm.js +139 -0
- package/dist/build-vite-b7cd993a.cjs.prod.js +151 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.d.ts +1 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +30 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.js +7 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +30 -0
- package/dist/commercetools-frontend-mc-scripts.esm.js +22 -0
- package/dist/compile-html-4361a0b3.esm.js +77 -0
- package/dist/compile-html-d6331c35.cjs.prod.js +87 -0
- package/dist/compile-html-d9e731aa.cjs.dev.js +87 -0
- package/dist/config-sync-6b31d972.esm.js +840 -0
- package/dist/config-sync-a478bc0f.cjs.dev.js +864 -0
- package/dist/config-sync-f07734e4.cjs.prod.js +859 -0
- package/{build/config/create-postcss-config.js → dist/create-postcss-config-04243dea.esm.js} +27 -25
- package/dist/create-postcss-config-760e2dc5.cjs.dev.js +90 -0
- package/dist/create-postcss-config-ddc3abee.cjs.prod.js +90 -0
- package/dist/create-webpack-config-for-development-76fdab59.cjs.prod.js +419 -0
- package/{build/config/create-webpack-config-for-development.js → dist/create-webpack-config-for-development-d93ae4b2.esm.js} +94 -57
- package/dist/create-webpack-config-for-development-dfd1c174.cjs.dev.js +419 -0
- package/{build/config/create-webpack-config-for-production.js → dist/create-webpack-config-for-production-9290479a.esm.js} +120 -54
- package/dist/create-webpack-config-for-production-bc8c1f37.cjs.dev.js +469 -0
- package/dist/create-webpack-config-for-production-d652ad1a.cjs.prod.js +469 -0
- package/dist/declarations/src/application-runtime.d.ts +1 -0
- package/dist/declarations/src/cli.d.ts +4 -0
- package/dist/declarations/src/commands/build-vite.d.ts +2 -0
- package/dist/declarations/src/commands/build.d.ts +2 -0
- package/dist/declarations/src/commands/compile-html.d.ts +3 -0
- package/dist/declarations/src/commands/config-sync.d.ts +3 -0
- package/dist/declarations/src/commands/login.d.ts +2 -0
- package/dist/declarations/src/commands/serve.d.ts +2 -0
- package/dist/declarations/src/commands/start-vite.d.ts +2 -0
- package/dist/declarations/src/commands/start.d.ts +2 -0
- package/dist/declarations/src/config/create-postcss-config.d.ts +4 -0
- package/dist/declarations/src/config/create-webpack-config-for-development.d.ts +10 -0
- package/dist/declarations/src/config/create-webpack-config-for-production.d.ts +10 -0
- package/dist/declarations/src/config/has-jsx-runtime.d.ts +2 -0
- package/dist/declarations/src/config/moment-locales.d.ts +2 -0
- package/dist/declarations/src/config/paths.d.ts +12 -0
- package/dist/declarations/src/config/vendors-to-transpile.d.ts +2 -0
- package/dist/declarations/src/config/webpack-dev-server.config.d.ts +6 -0
- package/dist/declarations/src/deprecated-entry-points.d.ts +7 -0
- package/dist/declarations/src/generated/core.d.ts +710 -0
- package/dist/declarations/src/generated/settings.d.ts +2485 -0
- package/dist/declarations/src/index.d.ts +3 -0
- package/dist/declarations/src/postcss.d.ts +1 -0
- package/dist/declarations/src/types.d.ts +82 -0
- package/dist/declarations/src/utils/auth.d.ts +6 -0
- package/dist/declarations/src/utils/credentials-storage.d.ts +11 -0
- package/dist/declarations/src/utils/get-config-diff.d.ts +3 -0
- package/dist/declarations/src/utils/graphql-requests.d.ts +80 -0
- package/dist/declarations/src/utils/user-agent.d.ts +2 -0
- package/dist/declarations/src/version.d.ts +2 -0
- 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/declarations/src/webpack-plugins/final-stats-writer-plugin.d.ts +12 -0
- package/dist/declarations/src/webpack-plugins/local-html-webpack-plugin.d.ts +5 -0
- package/dist/declarations/src/webpack.d.ts +2 -0
- package/dist/has-jsx-runtime-0b03b72e.cjs.prod.js +17 -0
- package/dist/has-jsx-runtime-3d4bb633.cjs.dev.js +17 -0
- package/{build/config/has-jsx-runtime.js → dist/has-jsx-runtime-8314226e.esm.js} +1 -3
- package/dist/login-7b7ae27e.esm.js +155 -0
- package/dist/login-b13f26e7.cjs.dev.js +165 -0
- package/dist/login-c11fb977.cjs.prod.js +165 -0
- package/dist/package-4b4fcf02.cjs.prod.js +139 -0
- package/dist/package-4c3e3fb7.cjs.dev.js +139 -0
- package/dist/package-8e6305bd.esm.js +137 -0
- package/dist/paths-16823f56.cjs.dev.js +55 -0
- package/dist/paths-76b66e74.cjs.prod.js +55 -0
- package/dist/paths-ed23d5a1.esm.js +46 -0
- package/dist/serve-12de323b.cjs.dev.js +70 -0
- package/dist/serve-784f4fcd.cjs.prod.js +70 -0
- package/dist/serve-d6b437b1.esm.js +62 -0
- package/dist/start-1b7dad90.cjs.prod.js +209 -0
- package/dist/start-45ca01f2.cjs.dev.js +209 -0
- package/dist/start-600d06a3.esm.js +194 -0
- package/dist/start-vite-22de08dc.cjs.dev.js +151 -0
- package/dist/start-vite-dc046cba.esm.js +138 -0
- package/dist/start-vite-fe13330b.cjs.prod.js +151 -0
- package/dist/user-agent-5f8ec93d.cjs.prod.js +106 -0
- package/dist/user-agent-ca628320.esm.js +94 -0
- package/dist/user-agent-ee57c98a.cjs.dev.js +106 -0
- package/dist/vendors-to-transpile-367e0ba8.cjs.prod.js +5 -0
- package/dist/vendors-to-transpile-68e03526.esm.js +3 -0
- package/dist/vendors-to-transpile-b51af5d3.cjs.dev.js +5 -0
- 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 +56 -50
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.d.ts +1 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +14 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.js +7 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +14 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +6 -0
- package/postcss/package.json +4 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.d.ts +1 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +51 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.js +7 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +51 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +42 -0
- package/webpack/package.json +4 -0
- package/build/bin/cli.js +0 -264
- package/build/commands/build-vite.js +0 -91
- package/build/commands/build.js +0 -140
- package/build/commands/compile-html.js +0 -53
- package/build/commands/config-sync.js +0 -176
- package/build/commands/login.js +0 -60
- package/build/commands/serve.js +0 -37
- package/build/commands/start-vite.js +0 -138
- package/build/commands/start.js +0 -108
- package/build/config/paths.js +0 -38
- package/build/config/vendors-to-transpile.js +0 -3
- package/build/config/webpack-dev-server.config.js +0 -69
- package/build/index.js +0 -16
- package/build/utils/auth.js +0 -34
- package/build/utils/auth.spec.js +0 -61
- package/build/utils/create-custom-application.settings.graphql +0 -8
- package/build/utils/credentials-storage.js +0 -72
- package/build/utils/credentials-storage.spec.js +0 -69
- package/build/utils/fetch-custom-application.settings.graphql +0 -36
- package/build/utils/fetch-user-organizations.core.graphql +0 -9
- package/build/utils/get-config-diff.js +0 -308
- package/build/utils/get-config-diff.spec.js +0 -285
- package/build/utils/graphql-requests.js +0 -105
- package/build/utils/graphql-requests.spec.js +0 -159
- package/build/utils/require-graphql.js +0 -15
- package/build/utils/update-custom-application.settings.graphql +0 -13
- package/build/utils/user-agent.js +0 -15
- package/build/webpack-plugins/final-stats-writer-plugin.js +0 -50
- package/build/webpack-plugins/local-html-webpack-plugin.js +0 -38
|
@@ -0,0 +1,864 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
4
|
+
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
5
|
+
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
6
|
+
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
7
|
+
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
8
|
+
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
9
|
+
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
10
|
+
var omit = require('lodash/omit');
|
|
11
|
+
var prompts = require('prompts');
|
|
12
|
+
var chalk = require('chalk');
|
|
13
|
+
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
14
|
+
var userAgent = require('./user-agent-ee57c98a.cjs.dev.js');
|
|
15
|
+
var graphqlRequest = require('graphql-request');
|
|
16
|
+
var constants = require('@commercetools-frontend/constants');
|
|
17
|
+
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
18
|
+
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
19
|
+
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
20
|
+
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
21
|
+
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
22
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
23
|
+
var _repeatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/repeat');
|
|
24
|
+
var _Set = require('@babel/runtime-corejs3/core-js-stable/set');
|
|
25
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
26
|
+
var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
27
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
28
|
+
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
29
|
+
require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
30
|
+
require('@babel/runtime-corejs3/helpers/createClass');
|
|
31
|
+
require('@babel/runtime-corejs3/core-js-stable/date/now');
|
|
32
|
+
require('fs');
|
|
33
|
+
require('path');
|
|
34
|
+
require('os');
|
|
35
|
+
require('@commercetools/http-user-agent');
|
|
36
|
+
require('./package-4c3e3fb7.cjs.dev.js');
|
|
37
|
+
|
|
38
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
39
|
+
|
|
40
|
+
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefault(_regeneratorRuntime);
|
|
41
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
42
|
+
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
43
|
+
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
44
|
+
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
45
|
+
var omit__default = /*#__PURE__*/_interopDefault(omit);
|
|
46
|
+
var prompts__default = /*#__PURE__*/_interopDefault(prompts);
|
|
47
|
+
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
48
|
+
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
49
|
+
var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
|
|
50
|
+
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
51
|
+
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
52
|
+
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
53
|
+
var _repeatInstanceProperty__default = /*#__PURE__*/_interopDefault(_repeatInstanceProperty);
|
|
54
|
+
var _Set__default = /*#__PURE__*/_interopDefault(_Set);
|
|
55
|
+
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
56
|
+
var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
|
|
57
|
+
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
58
|
+
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
59
|
+
|
|
60
|
+
var FetchCustomApplicationFromCli = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchCustomApplicationFromCli" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "entryPointUriPath" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "organizationExtensionForCustomApplication" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "entryPointUriPath" }, value: { kind: "Variable", name: { kind: "Name", value: "entryPointUriPath" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "organizationId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "application" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "entryPointUriPath" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "description" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "url" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "icon" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "permissions" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "oAuthScopes" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "mainMenuLink" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "defaultLabel" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "permissions" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "labelAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "submenuLinks" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "uriPath" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "defaultLabel" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "permissions" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "labelAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }] } }] } }] } }], loc: { start: 0, end: 647, source: { body: "query FetchCustomApplicationFromCli($entryPointUriPath: String!) {\n organizationExtensionForCustomApplication(\n entryPointUriPath: $entryPointUriPath\n ) {\n organizationId\n application {\n id\n entryPointUriPath\n name\n description\n url\n icon\n permissions {\n name\n oAuthScopes\n }\n mainMenuLink {\n defaultLabel\n permissions\n labelAllLocales {\n locale\n value\n }\n }\n submenuLinks {\n uriPath\n defaultLabel\n permissions\n labelAllLocales {\n locale\n value\n }\n }\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
61
|
+
var UpdateCustomApplicationFromCli = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "mutation", name: { kind: "Name", value: "UpdateCustomApplicationFromCli" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "organizationId" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "data" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "CustomApplicationDraftDataInput" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "applicationId" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "ID" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "updateCustomApplication" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "organizationId" }, value: { kind: "Variable", name: { kind: "Name", value: "organizationId" } } }, { kind: "Argument", name: { kind: "Name", value: "data" }, value: { kind: "Variable", name: { kind: "Name", value: "data" } } }, { kind: "Argument", name: { kind: "Name", value: "applicationId" }, value: { kind: "Variable", name: { kind: "Name", value: "applicationId" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }] } }], loc: { start: 0, end: 268, source: { body: "mutation UpdateCustomApplicationFromCli(\n $organizationId: String!\n $data: CustomApplicationDraftDataInput!\n $applicationId: ID!\n) {\n updateCustomApplication(\n organizationId: $organizationId\n data: $data\n applicationId: $applicationId\n ) {\n id\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
62
|
+
var CreateCustomApplicationFromCli = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "mutation", name: { kind: "Name", value: "CreateCustomApplicationFromCli" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "organizationId" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "data" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "CustomApplicationDraftDataInput" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "createCustomApplication" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "organizationId" }, value: { kind: "Variable", name: { kind: "Name", value: "organizationId" } } }, { kind: "Argument", name: { kind: "Name", value: "data" }, value: { kind: "Variable", name: { kind: "Name", value: "data" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }] } }], loc: { start: 0, end: 201, source: { body: "mutation CreateCustomApplicationFromCli(\n $organizationId: String!\n $data: CustomApplicationDraftDataInput!\n) {\n createCustomApplication(organizationId: $organizationId, data: $data) {\n id\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
63
|
+
var FetchMyOrganizationsFromCli = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchMyOrganizationsFromCli" }, variableDefinitions: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "myOrganizations" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "total" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "results" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }] } }] } }] } }], loc: { start: 0, end: 112, source: { body: "query FetchMyOrganizationsFromCli {\n myOrganizations {\n total\n results {\n id\n name\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
64
|
+
|
|
65
|
+
var graphQLClient = function graphQLClient(url, token) {
|
|
66
|
+
var target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : constants.GRAPHQL_TARGETS.SETTINGS_SERVICE;
|
|
67
|
+
return new graphqlRequest.GraphQLClient("".concat(url, "/graphql"), {
|
|
68
|
+
headers: {
|
|
69
|
+
Accept: 'application/json',
|
|
70
|
+
'Content-Type': 'application/json',
|
|
71
|
+
'x-graphql-target': target,
|
|
72
|
+
'x-mc-cli-access-token': token,
|
|
73
|
+
'x-user-agent': userAgent.userAgent
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
var fetchCustomApplication = /*#__PURE__*/function () {
|
|
79
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(_ref) {
|
|
80
|
+
var mcApiUrl, token, entryPointUriPath, variables, customAppData;
|
|
81
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
82
|
+
while (1) {
|
|
83
|
+
switch (_context.prev = _context.next) {
|
|
84
|
+
case 0:
|
|
85
|
+
mcApiUrl = _ref.mcApiUrl, token = _ref.token, entryPointUriPath = _ref.entryPointUriPath;
|
|
86
|
+
variables = {
|
|
87
|
+
entryPointUriPath: entryPointUriPath
|
|
88
|
+
};
|
|
89
|
+
_context.next = 4;
|
|
90
|
+
return graphQLClient(mcApiUrl, token).request(FetchCustomApplicationFromCli, variables);
|
|
91
|
+
|
|
92
|
+
case 4:
|
|
93
|
+
customAppData = _context.sent;
|
|
94
|
+
return _context.abrupt("return", customAppData.organizationExtensionForCustomApplication);
|
|
95
|
+
|
|
96
|
+
case 6:
|
|
97
|
+
case "end":
|
|
98
|
+
return _context.stop();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}, _callee);
|
|
102
|
+
}));
|
|
103
|
+
|
|
104
|
+
return function fetchCustomApplication(_x) {
|
|
105
|
+
return _ref2.apply(this, arguments);
|
|
106
|
+
};
|
|
107
|
+
}();
|
|
108
|
+
|
|
109
|
+
var updateCustomApplication = /*#__PURE__*/function () {
|
|
110
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(_ref3) {
|
|
111
|
+
var mcApiUrl, token, applicationId, organizationId, data, variables, updatedCustomAppsData;
|
|
112
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
|
|
113
|
+
while (1) {
|
|
114
|
+
switch (_context2.prev = _context2.next) {
|
|
115
|
+
case 0:
|
|
116
|
+
mcApiUrl = _ref3.mcApiUrl, token = _ref3.token, applicationId = _ref3.applicationId, organizationId = _ref3.organizationId, data = _ref3.data;
|
|
117
|
+
variables = {
|
|
118
|
+
organizationId: organizationId,
|
|
119
|
+
applicationId: applicationId,
|
|
120
|
+
data: data
|
|
121
|
+
};
|
|
122
|
+
_context2.next = 4;
|
|
123
|
+
return graphQLClient(mcApiUrl, token).request(UpdateCustomApplicationFromCli, variables);
|
|
124
|
+
|
|
125
|
+
case 4:
|
|
126
|
+
updatedCustomAppsData = _context2.sent;
|
|
127
|
+
return _context2.abrupt("return", updatedCustomAppsData.updateCustomApplication);
|
|
128
|
+
|
|
129
|
+
case 6:
|
|
130
|
+
case "end":
|
|
131
|
+
return _context2.stop();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}, _callee2);
|
|
135
|
+
}));
|
|
136
|
+
|
|
137
|
+
return function updateCustomApplication(_x2) {
|
|
138
|
+
return _ref4.apply(this, arguments);
|
|
139
|
+
};
|
|
140
|
+
}();
|
|
141
|
+
|
|
142
|
+
var createCustomApplication = /*#__PURE__*/function () {
|
|
143
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(_ref5) {
|
|
144
|
+
var mcApiUrl, token, organizationId, data, variables, createdCustomAppData;
|
|
145
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context3) {
|
|
146
|
+
while (1) {
|
|
147
|
+
switch (_context3.prev = _context3.next) {
|
|
148
|
+
case 0:
|
|
149
|
+
mcApiUrl = _ref5.mcApiUrl, token = _ref5.token, organizationId = _ref5.organizationId, data = _ref5.data;
|
|
150
|
+
variables = {
|
|
151
|
+
organizationId: organizationId,
|
|
152
|
+
data: data
|
|
153
|
+
};
|
|
154
|
+
_context3.next = 4;
|
|
155
|
+
return graphQLClient(mcApiUrl, token).request(CreateCustomApplicationFromCli, variables);
|
|
156
|
+
|
|
157
|
+
case 4:
|
|
158
|
+
createdCustomAppData = _context3.sent;
|
|
159
|
+
return _context3.abrupt("return", createdCustomAppData.createCustomApplication);
|
|
160
|
+
|
|
161
|
+
case 6:
|
|
162
|
+
case "end":
|
|
163
|
+
return _context3.stop();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}, _callee3);
|
|
167
|
+
}));
|
|
168
|
+
|
|
169
|
+
return function createCustomApplication(_x3) {
|
|
170
|
+
return _ref6.apply(this, arguments);
|
|
171
|
+
};
|
|
172
|
+
}();
|
|
173
|
+
|
|
174
|
+
var fetchUserOrganizations = /*#__PURE__*/function () {
|
|
175
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(_ref7) {
|
|
176
|
+
var mcApiUrl, token, userOrganizations;
|
|
177
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context4) {
|
|
178
|
+
while (1) {
|
|
179
|
+
switch (_context4.prev = _context4.next) {
|
|
180
|
+
case 0:
|
|
181
|
+
mcApiUrl = _ref7.mcApiUrl, token = _ref7.token;
|
|
182
|
+
_context4.next = 3;
|
|
183
|
+
return graphQLClient(mcApiUrl, token, constants.GRAPHQL_TARGETS.ADMINISTRATION_SERVICE).request(FetchMyOrganizationsFromCli);
|
|
184
|
+
|
|
185
|
+
case 3:
|
|
186
|
+
userOrganizations = _context4.sent;
|
|
187
|
+
return _context4.abrupt("return", userOrganizations.myOrganizations);
|
|
188
|
+
|
|
189
|
+
case 5:
|
|
190
|
+
case "end":
|
|
191
|
+
return _context4.stop();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}, _callee4);
|
|
195
|
+
}));
|
|
196
|
+
|
|
197
|
+
return function fetchUserOrganizations(_x4) {
|
|
198
|
+
return _ref8.apply(this, arguments);
|
|
199
|
+
};
|
|
200
|
+
}();
|
|
201
|
+
|
|
202
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
203
|
+
|
|
204
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context20, _context21; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context20 = ownKeys(Object(source), !0)).call(_context20, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context21 = ownKeys(Object(source))).call(_context21, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
205
|
+
// Since not all terminal supports colors, to make things more consistent for testing purposes,
|
|
206
|
+
// during tests the color used is appended before the string instead of coloring it.
|
|
207
|
+
var isTest = process.env.NODE_ENV === 'test';
|
|
208
|
+
|
|
209
|
+
var red = function red(str) {
|
|
210
|
+
if (isTest) return "<color-red>".concat(str, "</color-red>");
|
|
211
|
+
return chalk__default["default"].red(str);
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
var green = function green(str) {
|
|
215
|
+
if (isTest) return "<color-green>".concat(str, "</color-green>");
|
|
216
|
+
return chalk__default["default"].green(str);
|
|
217
|
+
}; // Two spaces are used for indentation.
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
var indent = function indent(indentLevel) {
|
|
221
|
+
var _context;
|
|
222
|
+
|
|
223
|
+
return _repeatInstanceProperty__default["default"](_context = ' ').call(_context, indentLevel);
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
var getStringDiff = function getStringDiff(_ref) {
|
|
227
|
+
var previousValue = _ref.previousValue,
|
|
228
|
+
nextValue = _ref.nextValue,
|
|
229
|
+
label = _ref.label,
|
|
230
|
+
_ref$indentLevel = _ref.indentLevel,
|
|
231
|
+
indentLevel = _ref$indentLevel === void 0 ? 0 : _ref$indentLevel;
|
|
232
|
+
|
|
233
|
+
if (!previousValue && nextValue) {
|
|
234
|
+
var _context2, _context3;
|
|
235
|
+
|
|
236
|
+
return _concatInstanceProperty__default["default"](_context2 = _concatInstanceProperty__default["default"](_context3 = "".concat(indent(indentLevel))).call(_context3, label, " added: ")).call(_context2, green(nextValue));
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (previousValue && !nextValue) {
|
|
240
|
+
var _context4, _context5;
|
|
241
|
+
|
|
242
|
+
return _concatInstanceProperty__default["default"](_context4 = _concatInstanceProperty__default["default"](_context5 = "".concat(indent(indentLevel))).call(_context5, label, " removed: ")).call(_context4, red(previousValue));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (previousValue && nextValue && previousValue !== nextValue) {
|
|
246
|
+
var _context6, _context7, _context8;
|
|
247
|
+
|
|
248
|
+
return _concatInstanceProperty__default["default"](_context6 = _concatInstanceProperty__default["default"](_context7 = _concatInstanceProperty__default["default"](_context8 = "".concat(indent(indentLevel))).call(_context8, label, " changed: ")).call(_context7, red(previousValue), " => ")).call(_context6, green(nextValue));
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return null;
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
// NOTE: this assumes that the array values are scalar values (not objects).
|
|
255
|
+
var getArrayDiff = function getArrayDiff(_ref2) {
|
|
256
|
+
var previousValue = _ref2.previousValue,
|
|
257
|
+
nextValue = _ref2.nextValue,
|
|
258
|
+
label = _ref2.label,
|
|
259
|
+
_ref2$indentLevel = _ref2.indentLevel,
|
|
260
|
+
indentLevel = _ref2$indentLevel === void 0 ? 0 : _ref2$indentLevel;
|
|
261
|
+
var oldArraySet = new _Set__default["default"](previousValue);
|
|
262
|
+
var arrayDiff = [];
|
|
263
|
+
nextValue === null || nextValue === void 0 ? void 0 : _forEachInstanceProperty__default["default"](nextValue).call(nextValue, function (item) {
|
|
264
|
+
if (oldArraySet.has(item)) {
|
|
265
|
+
oldArraySet.delete(item);
|
|
266
|
+
} else {
|
|
267
|
+
arrayDiff.push(getStringDiff({
|
|
268
|
+
nextValue: item,
|
|
269
|
+
label: label,
|
|
270
|
+
indentLevel: indentLevel
|
|
271
|
+
}));
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
_forEachInstanceProperty__default["default"](oldArraySet).call(oldArraySet, function (item) {
|
|
276
|
+
arrayDiff.push(getStringDiff({
|
|
277
|
+
previousValue: item,
|
|
278
|
+
label: label,
|
|
279
|
+
indentLevel: indentLevel
|
|
280
|
+
}));
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
return arrayDiff.join('\n');
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
var getPermissionsDiff = function getPermissionsDiff(_ref3) {
|
|
287
|
+
var _context11;
|
|
288
|
+
|
|
289
|
+
var previousValue = _ref3.previousValue,
|
|
290
|
+
nextValue = _ref3.nextValue;
|
|
291
|
+
var permissionDiff = ['permissions changed'];
|
|
292
|
+
|
|
293
|
+
var mappedOldPermissions = _reduceInstanceProperty__default["default"](previousValue).call(previousValue, function (previousPermission, _ref4) {
|
|
294
|
+
var name = _ref4.name,
|
|
295
|
+
oAuthScopes = _ref4.oAuthScopes;
|
|
296
|
+
return _objectSpread(_objectSpread({}, previousPermission), {}, _defineProperty({}, name, oAuthScopes));
|
|
297
|
+
}, {});
|
|
298
|
+
|
|
299
|
+
var indentLevel = 1;
|
|
300
|
+
|
|
301
|
+
_forEachInstanceProperty__default["default"](nextValue).call(nextValue, function (newPermission) {
|
|
302
|
+
var _context9;
|
|
303
|
+
|
|
304
|
+
var currentDiff = [_concatInstanceProperty__default["default"](_context9 = "".concat(indent(indentLevel), "\"")).call(_context9, newPermission.name, "\" changed")]; // if the permission name is not in the old config, it means it is a new addition.
|
|
305
|
+
|
|
306
|
+
if (!mappedOldPermissions[newPermission.name]) {
|
|
307
|
+
var _context10;
|
|
308
|
+
|
|
309
|
+
permissionDiff.push(_concatInstanceProperty__default["default"](_context10 = "".concat(indent(indentLevel), "\"")).call(_context10, green(newPermission.name), "\" was added"));
|
|
310
|
+
} // if permission name is in the old config, now we check if there was a change
|
|
311
|
+
else {
|
|
312
|
+
currentDiff.push(getArrayDiff({
|
|
313
|
+
previousValue: mappedOldPermissions[newPermission.name],
|
|
314
|
+
nextValue: newPermission.oAuthScopes,
|
|
315
|
+
label: 'oauth scope',
|
|
316
|
+
indentLevel: 2
|
|
317
|
+
}));
|
|
318
|
+
delete mappedOldPermissions[newPermission.name];
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
_filterInstanceProperty__default["default"](currentDiff).call(currentDiff, Boolean).length > 1 && permissionDiff.push(currentDiff.join('\n'));
|
|
322
|
+
}); // if there are old permissions left, it means they were deleted in the new Permissions.
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
_forEachInstanceProperty__default["default"](_context11 = _Object$keys__default["default"](mappedOldPermissions)).call(_context11, function (oldPermissionName) {
|
|
326
|
+
var _context12;
|
|
327
|
+
|
|
328
|
+
permissionDiff.push(_concatInstanceProperty__default["default"](_context12 = "".concat(indent(indentLevel), "\"")).call(_context12, red(oldPermissionName), "\" was removed"));
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
if (permissionDiff.length > 1) return permissionDiff.join('\n');
|
|
332
|
+
return null;
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
var getLabelAllLocalesDiff = function getLabelAllLocalesDiff(_ref5) {
|
|
336
|
+
var _context16;
|
|
337
|
+
|
|
338
|
+
var _ref5$previousValue = _ref5.previousValue,
|
|
339
|
+
previousValue = _ref5$previousValue === void 0 ? [] : _ref5$previousValue,
|
|
340
|
+
_ref5$nextValue = _ref5.nextValue,
|
|
341
|
+
nextValue = _ref5$nextValue === void 0 ? [] : _ref5$nextValue,
|
|
342
|
+
_ref5$indentLevel = _ref5.indentLevel,
|
|
343
|
+
indentLevel = _ref5$indentLevel === void 0 ? 0 : _ref5$indentLevel;
|
|
344
|
+
var labelAllLocalesDiff = ["".concat(indent(indentLevel - 1), "labelAllLocales changed")];
|
|
345
|
+
|
|
346
|
+
var mappedOldLabelAllLocales = _reduceInstanceProperty__default["default"](previousValue).call(previousValue, function (previousLabelAllLocale, _ref6) {
|
|
347
|
+
var locale = _ref6.locale,
|
|
348
|
+
value = _ref6.value;
|
|
349
|
+
return _objectSpread(_objectSpread({}, previousLabelAllLocale), {}, _defineProperty({}, locale, value));
|
|
350
|
+
}, {});
|
|
351
|
+
|
|
352
|
+
_forEachInstanceProperty__default["default"](nextValue).call(nextValue, function (newLabelAllLocale) {
|
|
353
|
+
if (newLabelAllLocale.locale in mappedOldLabelAllLocales) {
|
|
354
|
+
var oldLocaleValue = mappedOldLabelAllLocales[newLabelAllLocale.locale];
|
|
355
|
+
|
|
356
|
+
if (oldLocaleValue !== newLabelAllLocale.value) {
|
|
357
|
+
var _context13, _context14, _context15;
|
|
358
|
+
|
|
359
|
+
labelAllLocalesDiff.push(_concatInstanceProperty__default["default"](_context13 = _concatInstanceProperty__default["default"](_context14 = _concatInstanceProperty__default["default"](_context15 = "".concat(indent(indentLevel), "locale \"")).call(_context15, newLabelAllLocale.locale, "\" changed: ")).call(_context14, red(oldLocaleValue), " => ")).call(_context13, green(newLabelAllLocale.value)));
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
delete mappedOldLabelAllLocales[newLabelAllLocale.locale];
|
|
363
|
+
} else {
|
|
364
|
+
var localeDiff = getStringDiff({
|
|
365
|
+
nextValue: newLabelAllLocale.locale,
|
|
366
|
+
label: 'locale',
|
|
367
|
+
indentLevel: indentLevel
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
if (localeDiff) {
|
|
371
|
+
labelAllLocalesDiff.push(localeDiff);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
_forEachInstanceProperty__default["default"](_context16 = _Object$keys__default["default"](mappedOldLabelAllLocales)).call(_context16, function (key) {
|
|
377
|
+
var localeDiff = getStringDiff({
|
|
378
|
+
previousValue: key,
|
|
379
|
+
label: 'locale',
|
|
380
|
+
indentLevel: indentLevel
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
if (localeDiff) {
|
|
384
|
+
labelAllLocalesDiff.push(localeDiff);
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
if (labelAllLocalesDiff.length > 1) return labelAllLocalesDiff.join('\n');
|
|
389
|
+
return null;
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
var getMainMenuLinkDiff = function getMainMenuLinkDiff(_ref7) {
|
|
393
|
+
var previousValue = _ref7.previousValue,
|
|
394
|
+
nextValue = _ref7.nextValue;
|
|
395
|
+
var mainMenuLinkDiff = ['mainMenuLink changed'];
|
|
396
|
+
var menuDiff = getStringDiff({
|
|
397
|
+
previousValue: previousValue.defaultLabel,
|
|
398
|
+
nextValue: nextValue.defaultLabel,
|
|
399
|
+
label: 'defaultLabel',
|
|
400
|
+
indentLevel: 1
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
if (menuDiff) {
|
|
404
|
+
mainMenuLinkDiff.push(menuDiff);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
var mainMenuLinkPermissionsDiff = getArrayDiff({
|
|
408
|
+
previousValue: previousValue.permissions,
|
|
409
|
+
nextValue: nextValue.permissions,
|
|
410
|
+
label: 'applied permission',
|
|
411
|
+
indentLevel: 2
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
if (mainMenuLinkPermissionsDiff.length > 0) {
|
|
415
|
+
mainMenuLinkDiff.push("".concat(indent(1), "permissions changed"));
|
|
416
|
+
mainMenuLinkDiff.push(mainMenuLinkPermissionsDiff);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
var menuLabelsDiff = getLabelAllLocalesDiff({
|
|
420
|
+
previousValue: previousValue.labelAllLocales,
|
|
421
|
+
nextValue: nextValue.labelAllLocales,
|
|
422
|
+
indentLevel: 2
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
if (menuLabelsDiff) {
|
|
426
|
+
mainMenuLinkDiff.push(menuLabelsDiff);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
var filteredMainMenuLinkDiff = _filterInstanceProperty__default["default"](mainMenuLinkDiff).call(mainMenuLinkDiff, Boolean);
|
|
430
|
+
|
|
431
|
+
if (filteredMainMenuLinkDiff.length > 1) return filteredMainMenuLinkDiff.join('\n');
|
|
432
|
+
return null;
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
var getSubmenuLinksDiff = function getSubmenuLinksDiff(_ref8) {
|
|
436
|
+
var _context19;
|
|
437
|
+
|
|
438
|
+
var previousValue = _ref8.previousValue,
|
|
439
|
+
nextValue = _ref8.nextValue;
|
|
440
|
+
var submenuLinksDiff = ['submenuLink changed'];
|
|
441
|
+
|
|
442
|
+
var mappedSubmenuLinks = _reduceInstanceProperty__default["default"](previousValue).call(previousValue, function (previousSubmenuLink, currentSubmenuLink) {
|
|
443
|
+
return _objectSpread(_objectSpread({}, previousSubmenuLink), {}, _defineProperty({}, currentSubmenuLink.uriPath, currentSubmenuLink));
|
|
444
|
+
}, {});
|
|
445
|
+
|
|
446
|
+
_forEachInstanceProperty__default["default"](nextValue).call(nextValue, function (newSubmenuLink) {
|
|
447
|
+
var oldSubMenuLink = mappedSubmenuLinks[newSubmenuLink.uriPath];
|
|
448
|
+
|
|
449
|
+
if (newSubmenuLink.uriPath in mappedSubmenuLinks) {
|
|
450
|
+
var _context17, _context18;
|
|
451
|
+
|
|
452
|
+
var submenuLinkDiff = [_concatInstanceProperty__default["default"](_context17 = "".concat(indent(1), "menu link \"")).call(_context17, newSubmenuLink.uriPath, "\" changed")];
|
|
453
|
+
|
|
454
|
+
_forEachInstanceProperty__default["default"](_context18 = _Object$keys__default["default"](mappedSubmenuLinks[newSubmenuLink.uriPath])).call(_context18, function (key) {
|
|
455
|
+
switch (key) {
|
|
456
|
+
case 'defaultLabel':
|
|
457
|
+
{
|
|
458
|
+
var labelDiff = getStringDiff({
|
|
459
|
+
previousValue: oldSubMenuLink.defaultLabel,
|
|
460
|
+
nextValue: newSubmenuLink.defaultLabel,
|
|
461
|
+
label: 'defaultLabel',
|
|
462
|
+
indentLevel: 2
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
if (labelDiff) {
|
|
466
|
+
submenuLinkDiff.push(labelDiff);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
break;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
case 'permissions':
|
|
473
|
+
{
|
|
474
|
+
var submenuLinkPermissionsDiff = getArrayDiff({
|
|
475
|
+
previousValue: oldSubMenuLink.permissions,
|
|
476
|
+
nextValue: newSubmenuLink.permissions,
|
|
477
|
+
label: 'applied permission',
|
|
478
|
+
indentLevel: 3
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
if (submenuLinkPermissionsDiff.length > 0) {
|
|
482
|
+
submenuLinkDiff.push("".concat(indent(2), "permissions changed"));
|
|
483
|
+
submenuLinkDiff.push(submenuLinkPermissionsDiff);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
break;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
case 'labelAllLocales':
|
|
490
|
+
{
|
|
491
|
+
var labelsDiff = getLabelAllLocalesDiff({
|
|
492
|
+
previousValue: oldSubMenuLink.labelAllLocales,
|
|
493
|
+
nextValue: newSubmenuLink.labelAllLocales,
|
|
494
|
+
indentLevel: 3
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
if (labelsDiff) {
|
|
498
|
+
submenuLinkDiff.push(labelsDiff);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
break;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
delete mappedSubmenuLinks[newSubmenuLink.uriPath];
|
|
507
|
+
|
|
508
|
+
var filteredSubmenuLinksDiff = _filterInstanceProperty__default["default"](submenuLinkDiff).call(submenuLinkDiff, Boolean);
|
|
509
|
+
|
|
510
|
+
if (filteredSubmenuLinksDiff.length > 1) {
|
|
511
|
+
submenuLinksDiff.push(filteredSubmenuLinksDiff.join('\n'));
|
|
512
|
+
}
|
|
513
|
+
} else {
|
|
514
|
+
var linksDiff = getStringDiff({
|
|
515
|
+
nextValue: newSubmenuLink.uriPath,
|
|
516
|
+
label: 'menu link',
|
|
517
|
+
indentLevel: 1
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
if (linksDiff) {
|
|
521
|
+
submenuLinksDiff.push(linksDiff);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
_forEachInstanceProperty__default["default"](_context19 = _Object$keys__default["default"](mappedSubmenuLinks)).call(_context19, function (key) {
|
|
527
|
+
var linksDiff = getStringDiff({
|
|
528
|
+
previousValue: key,
|
|
529
|
+
label: 'menu link',
|
|
530
|
+
indentLevel: 1
|
|
531
|
+
});
|
|
532
|
+
if (linksDiff) submenuLinksDiff.push(linksDiff);
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
if (submenuLinksDiff.length > 1) return submenuLinksDiff.join('\n');
|
|
536
|
+
return null;
|
|
537
|
+
}; // Compute diff changes of the Custom Application config.
|
|
538
|
+
// NOTE: Only known keys are evaluated.
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
var getConfigDiff = function getConfigDiff(oldConfig, newConfig) {
|
|
542
|
+
var diff = []; // Name
|
|
543
|
+
|
|
544
|
+
var nameDiff = getStringDiff({
|
|
545
|
+
previousValue: oldConfig.name,
|
|
546
|
+
nextValue: newConfig.name,
|
|
547
|
+
label: 'name'
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
if (nameDiff) {
|
|
551
|
+
diff.push(nameDiff);
|
|
552
|
+
} // Description
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
var descriptionDiff = getStringDiff({
|
|
556
|
+
previousValue: oldConfig.description,
|
|
557
|
+
nextValue: newConfig.description,
|
|
558
|
+
label: 'description'
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
if (descriptionDiff) {
|
|
562
|
+
diff.push(descriptionDiff);
|
|
563
|
+
} // URL
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
var urlDiff = getStringDiff({
|
|
567
|
+
previousValue: oldConfig.url,
|
|
568
|
+
nextValue: newConfig.url,
|
|
569
|
+
label: 'url'
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
if (urlDiff) {
|
|
573
|
+
diff.push(urlDiff);
|
|
574
|
+
} // Icon
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
var iconDiff = getStringDiff({
|
|
578
|
+
previousValue: oldConfig.icon,
|
|
579
|
+
nextValue: newConfig.icon,
|
|
580
|
+
label: 'icon'
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
if (iconDiff) {
|
|
584
|
+
diff.push(iconDiff);
|
|
585
|
+
} // Permissions
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
var permissionsDiff = getPermissionsDiff({
|
|
589
|
+
previousValue: oldConfig.permissions,
|
|
590
|
+
nextValue: newConfig.permissions
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
if (permissionsDiff) {
|
|
594
|
+
diff.push(permissionsDiff);
|
|
595
|
+
} // Main menu link
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
var mainMenuDiff = getMainMenuLinkDiff({
|
|
599
|
+
previousValue: oldConfig.mainMenuLink,
|
|
600
|
+
nextValue: newConfig.mainMenuLink
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
if (mainMenuDiff) {
|
|
604
|
+
diff.push(mainMenuDiff);
|
|
605
|
+
} // Submenu links
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
var submenuDiff = getSubmenuLinksDiff({
|
|
609
|
+
previousValue: oldConfig.submenuLinks,
|
|
610
|
+
nextValue: newConfig.submenuLinks
|
|
611
|
+
});
|
|
612
|
+
|
|
613
|
+
if (submenuDiff) {
|
|
614
|
+
diff.push(submenuDiff);
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
return diff.join('\n');
|
|
618
|
+
};
|
|
619
|
+
|
|
620
|
+
var credentialsStorage = new userAgent.CredentialsStorage();
|
|
621
|
+
|
|
622
|
+
var getMcUrlLink = function getMcUrlLink(mcApiUrl, organizationId, applicationId) {
|
|
623
|
+
var _context, _context2;
|
|
624
|
+
|
|
625
|
+
var mcUrl = mcApiUrl.replace('mc-api', 'mc');
|
|
626
|
+
|
|
627
|
+
var customAppLink = _concatInstanceProperty__default["default"](_context = _concatInstanceProperty__default["default"](_context2 = "".concat(mcUrl, "/account/organizations/")).call(_context2, organizationId, "/custom-applications/owned/")).call(_context, applicationId);
|
|
628
|
+
|
|
629
|
+
return customAppLink;
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
function run(_x) {
|
|
633
|
+
return _run.apply(this, arguments);
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
function _run() {
|
|
637
|
+
_run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(options) {
|
|
638
|
+
var _context6;
|
|
639
|
+
|
|
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;
|
|
641
|
+
|
|
642
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context7) {
|
|
643
|
+
while (1) {
|
|
644
|
+
switch (_context7.prev = _context7.next) {
|
|
645
|
+
case 0:
|
|
646
|
+
applicationConfig$1 = applicationConfig.processConfig();
|
|
647
|
+
localCustomAppData = applicationConfig$1.data;
|
|
648
|
+
mcApiUrl = applicationConfig$1.env.mcApiUrl;
|
|
649
|
+
token = credentialsStorage.getToken(mcApiUrl);
|
|
650
|
+
|
|
651
|
+
if (token) {
|
|
652
|
+
_context7.next = 6;
|
|
653
|
+
break;
|
|
654
|
+
}
|
|
655
|
+
|
|
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."));
|
|
657
|
+
|
|
658
|
+
case 6:
|
|
659
|
+
_context7.next = 8;
|
|
660
|
+
return fetchCustomApplication({
|
|
661
|
+
mcApiUrl: mcApiUrl,
|
|
662
|
+
token: token,
|
|
663
|
+
entryPointUriPath: localCustomAppData.entryPointUriPath
|
|
664
|
+
});
|
|
665
|
+
|
|
666
|
+
case 8:
|
|
667
|
+
fetchedCustomApplication = _context7.sent;
|
|
668
|
+
|
|
669
|
+
if (fetchedCustomApplication) {
|
|
670
|
+
_context7.next = 51;
|
|
671
|
+
break;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
_context7.next = 12;
|
|
675
|
+
return fetchUserOrganizations({
|
|
676
|
+
mcApiUrl: mcApiUrl,
|
|
677
|
+
token: token
|
|
678
|
+
});
|
|
679
|
+
|
|
680
|
+
case 12:
|
|
681
|
+
userOrganizations = _context7.sent;
|
|
682
|
+
|
|
683
|
+
if (!(userOrganizations.total === 0)) {
|
|
684
|
+
_context7.next = 15;
|
|
685
|
+
break;
|
|
686
|
+
}
|
|
687
|
+
|
|
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.");
|
|
689
|
+
|
|
690
|
+
case 15:
|
|
691
|
+
if (!(userOrganizations.total === 1)) {
|
|
692
|
+
_context7.next = 21;
|
|
693
|
+
break;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
_userOrganizations$re = _slicedToArray(userOrganizations.results, 1), organization = _userOrganizations$re[0];
|
|
697
|
+
organizationId = organization.id;
|
|
698
|
+
organizationName = organization.name;
|
|
699
|
+
_context7.next = 30;
|
|
700
|
+
break;
|
|
701
|
+
|
|
702
|
+
case 21:
|
|
703
|
+
organizationChoices = _mapInstanceProperty__default["default"](_context3 = userOrganizations.results).call(_context3, function (organization) {
|
|
704
|
+
return {
|
|
705
|
+
title: organization.name,
|
|
706
|
+
value: organization.id
|
|
707
|
+
};
|
|
708
|
+
});
|
|
709
|
+
_context7.next = 24;
|
|
710
|
+
return prompts__default["default"]({
|
|
711
|
+
type: 'select',
|
|
712
|
+
name: 'organizationId',
|
|
713
|
+
message: 'Select Organization',
|
|
714
|
+
choices: organizationChoices,
|
|
715
|
+
initial: 0
|
|
716
|
+
});
|
|
717
|
+
|
|
718
|
+
case 24:
|
|
719
|
+
_yield$prompts = _context7.sent;
|
|
720
|
+
selectedOrganizationId = _yield$prompts.organizationId;
|
|
721
|
+
|
|
722
|
+
if (selectedOrganizationId) {
|
|
723
|
+
_context7.next = 28;
|
|
724
|
+
break;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
throw new Error("No Organization selected, aborting.");
|
|
728
|
+
|
|
729
|
+
case 28:
|
|
730
|
+
organizationId = selectedOrganizationId;
|
|
731
|
+
organizationName = _findInstanceProperty__default["default"](organizationChoices).call(organizationChoices, function (_ref) {
|
|
732
|
+
var value = _ref.value;
|
|
733
|
+
return value === organizationId;
|
|
734
|
+
}).title;
|
|
735
|
+
|
|
736
|
+
case 30:
|
|
737
|
+
_context7.next = 32;
|
|
738
|
+
return prompts__default["default"]({
|
|
739
|
+
type: 'text',
|
|
740
|
+
name: 'confirmation',
|
|
741
|
+
message: _concatInstanceProperty__default["default"](_context4 = "You are about to create a new Custom Application in the \"".concat(organizationName, "\" organization for the ")).call(_context4, mcApiUrl, " environment. Are you sure you want to proceed?"),
|
|
742
|
+
initial: 'yes'
|
|
743
|
+
});
|
|
744
|
+
|
|
745
|
+
case 32:
|
|
746
|
+
_yield$prompts2 = _context7.sent;
|
|
747
|
+
_confirmation = _yield$prompts2.confirmation;
|
|
748
|
+
|
|
749
|
+
if (!(!_confirmation || _confirmation.toLowerCase().charAt(0) !== 'y')) {
|
|
750
|
+
_context7.next = 37;
|
|
751
|
+
break;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
console.log(chalk__default["default"].red('Aborted.'));
|
|
755
|
+
return _context7.abrupt("return");
|
|
756
|
+
|
|
757
|
+
case 37:
|
|
758
|
+
_data = omit__default["default"](localCustomAppData, ['id']);
|
|
759
|
+
|
|
760
|
+
if (!options.dryRun) {
|
|
761
|
+
_context7.next = 43;
|
|
762
|
+
break;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
console.log(chalk__default["default"].gray('DRY RUN mode'));
|
|
766
|
+
console.log("A new Custom Application would be created for the Organization ".concat(organizationName, " with the following payload:"));
|
|
767
|
+
console.log(_JSON$stringify__default["default"](_data));
|
|
768
|
+
return _context7.abrupt("return");
|
|
769
|
+
|
|
770
|
+
case 43:
|
|
771
|
+
_context7.next = 45;
|
|
772
|
+
return createCustomApplication({
|
|
773
|
+
mcApiUrl: mcApiUrl,
|
|
774
|
+
token: token,
|
|
775
|
+
organizationId: organizationId,
|
|
776
|
+
data: _data
|
|
777
|
+
});
|
|
778
|
+
|
|
779
|
+
case 45:
|
|
780
|
+
createdCustomApplication = _context7.sent;
|
|
781
|
+
|
|
782
|
+
if (createdCustomApplication) {
|
|
783
|
+
_context7.next = 48;
|
|
784
|
+
break;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
throw new Error('Failed to create the Custom Application.');
|
|
788
|
+
|
|
789
|
+
case 48:
|
|
790
|
+
_customAppLink = getMcUrlLink(mcApiUrl, organizationId, createdCustomApplication.id);
|
|
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, ".")));
|
|
792
|
+
return _context7.abrupt("return");
|
|
793
|
+
|
|
794
|
+
case 51:
|
|
795
|
+
customAppLink = getMcUrlLink(mcApiUrl, fetchedCustomApplication.organizationId, fetchedCustomApplication.application.id);
|
|
796
|
+
configDiff = getConfigDiff(fetchedCustomApplication.application, localCustomAppData);
|
|
797
|
+
|
|
798
|
+
if (configDiff) {
|
|
799
|
+
_context7.next = 56;
|
|
800
|
+
break;
|
|
801
|
+
}
|
|
802
|
+
|
|
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, ".")));
|
|
804
|
+
return _context7.abrupt("return");
|
|
805
|
+
|
|
806
|
+
case 56:
|
|
807
|
+
console.log(configDiff);
|
|
808
|
+
_context7.next = 59;
|
|
809
|
+
return prompts__default["default"]({
|
|
810
|
+
type: 'text',
|
|
811
|
+
name: 'confirmation',
|
|
812
|
+
message: _concatInstanceProperty__default["default"](_context6 = "You are about to update the Custom Application \"".concat(localCustomAppData.entryPointUriPath, "\" with the changes above, in the ")).call(_context6, mcApiUrl, " environment. Are you sure you want to proceed?"),
|
|
813
|
+
initial: 'yes'
|
|
814
|
+
});
|
|
815
|
+
|
|
816
|
+
case 59:
|
|
817
|
+
_yield$prompts3 = _context7.sent;
|
|
818
|
+
confirmation = _yield$prompts3.confirmation;
|
|
819
|
+
|
|
820
|
+
if (!(!confirmation || confirmation.toLowerCase().charAt(0) !== 'y')) {
|
|
821
|
+
_context7.next = 64;
|
|
822
|
+
break;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
console.log(chalk__default["default"].red('Aborted.'));
|
|
826
|
+
return _context7.abrupt("return");
|
|
827
|
+
|
|
828
|
+
case 64:
|
|
829
|
+
data = omit__default["default"](localCustomAppData, ['id']);
|
|
830
|
+
|
|
831
|
+
if (!options.dryRun) {
|
|
832
|
+
_context7.next = 70;
|
|
833
|
+
break;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
console.log(chalk__default["default"].gray('DRY RUN mode'));
|
|
837
|
+
console.log("The Custom Application ".concat(data.name, " would be updated with the following payload:"));
|
|
838
|
+
console.log(_JSON$stringify__default["default"](data));
|
|
839
|
+
return _context7.abrupt("return");
|
|
840
|
+
|
|
841
|
+
case 70:
|
|
842
|
+
_context7.next = 72;
|
|
843
|
+
return updateCustomApplication({
|
|
844
|
+
mcApiUrl: mcApiUrl,
|
|
845
|
+
token: token,
|
|
846
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
847
|
+
data: omit__default["default"](localCustomAppData, ['id']),
|
|
848
|
+
applicationId: fetchedCustomApplication.application.id
|
|
849
|
+
});
|
|
850
|
+
|
|
851
|
+
case 72:
|
|
852
|
+
console.log(chalk__default["default"].green("Custom Application updated.\nYou can see the Custom Application data in the Merchant Center at ".concat(customAppLink, ".")));
|
|
853
|
+
|
|
854
|
+
case 73:
|
|
855
|
+
case "end":
|
|
856
|
+
return _context7.stop();
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
}, _callee);
|
|
860
|
+
}));
|
|
861
|
+
return _run.apply(this, arguments);
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
exports["default"] = run;
|