@commercetools-frontend/mc-scripts 24.13.0 → 25.1.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/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.dev.js +1 -1
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js +1 -1
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.esm.js +1 -1
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +14 -13
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +14 -13
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +14 -13
- package/dist/{build-f737874d.cjs.dev.js → build-0a5986d1.cjs.dev.js} +7 -7
- package/dist/{build-85028596.esm.js → build-dbcd0936.esm.js} +7 -7
- package/dist/{build-136a1b89.cjs.prod.js → build-ec10df64.cjs.prod.js} +7 -7
- package/dist/{build-vite-e26f6c9f.cjs.dev.js → build-vite-16b1a575.cjs.dev.js} +8 -9
- package/dist/{build-vite-85211835.esm.js → build-vite-59e1f185.esm.js} +8 -9
- package/dist/{build-vite-4a6c90c2.cjs.prod.js → build-vite-5d317720.cjs.prod.js} +8 -9
- 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-adfef598.esm.js → compile-html-025cd493.esm.js} +2 -4
- package/dist/{compile-html-b80f9651.cjs.prod.js → compile-html-50fd05ec.cjs.prod.js} +2 -5
- package/dist/{compile-html-8679f721.cjs.dev.js → compile-html-f4ac88cc.cjs.dev.js} +2 -5
- package/dist/{config-sync-c2f0d0d2.cjs.prod.js → config-sync-ce05c66c.cjs.prod.js} +70 -78
- package/dist/{config-sync-a6d29e7e.cjs.dev.js → config-sync-dbb43993.cjs.dev.js} +72 -80
- package/dist/{config-sync-ca738e38.esm.js → config-sync-e7f53a98.esm.js} +71 -79
- package/dist/{create-postcss-config-2a12c11b.esm.js → create-postcss-config-0a86560d.esm.js} +1 -1
- package/dist/{create-postcss-config-7ea95e6f.cjs.dev.js → create-postcss-config-381b636b.cjs.dev.js} +1 -1
- package/dist/{create-postcss-config-43a47b87.cjs.prod.js → create-postcss-config-91c09596.cjs.prod.js} +1 -1
- package/dist/{create-webpack-config-for-development-01784333.cjs.prod.js → create-webpack-config-for-development-37677a49.cjs.prod.js} +6 -6
- package/dist/{create-webpack-config-for-development-09988fe4.cjs.dev.js → create-webpack-config-for-development-488742b2.cjs.dev.js} +6 -6
- package/dist/{create-webpack-config-for-development-ca57ea56.esm.js → create-webpack-config-for-development-df3f7f7f.esm.js} +6 -6
- package/dist/{create-webpack-config-for-production-d1699ee5.cjs.dev.js → create-webpack-config-for-production-46d817cc.cjs.dev.js} +7 -7
- package/dist/{create-webpack-config-for-production-58d046e9.cjs.prod.js → create-webpack-config-for-production-aad64e2a.cjs.prod.js} +7 -7
- package/dist/{create-webpack-config-for-production-7b4166fc.esm.js → create-webpack-config-for-production-e22f78d2.esm.js} +7 -7
- package/dist/{credentials-storage-381abf27.cjs.prod.js → credentials-storage-0b89aa0e.cjs.prod.js} +1 -1
- package/dist/{credentials-storage-7285d7b4.esm.js → credentials-storage-4464313c.esm.js} +1 -1
- package/dist/{credentials-storage-de220814.cjs.dev.js → credentials-storage-cbb5c559.cjs.dev.js} +1 -1
- package/dist/{deployment-previews-set-6baa8fc7.cjs.dev.js → deployment-previews-set-4edd48db.cjs.dev.js} +22 -28
- package/dist/{deployment-previews-set-86ea8608.cjs.prod.js → deployment-previews-set-636fb1a3.cjs.prod.js} +22 -28
- package/dist/{deployment-previews-set-8b33d390.esm.js → deployment-previews-set-bbef95d2.esm.js} +22 -27
- package/dist/{graphql-requests-73d961d9.cjs.dev.js → graphql-requests-0a6eeb3a.cjs.prod.js} +5 -8
- package/dist/{graphql-requests-b6ca7894.esm.js → graphql-requests-14074b2b.esm.js} +5 -8
- package/dist/{graphql-requests-4ff022ec.cjs.prod.js → graphql-requests-23f7ddb1.cjs.dev.js} +5 -8
- package/dist/{i18n-message-complilation-8aec9d1b.esm.js → i18n-message-complilation-21d3b0aa.esm.js} +1 -1
- package/dist/{i18n-message-complilation-3f80e8d6.cjs.dev.js → i18n-message-complilation-7311cb29.cjs.dev.js} +1 -1
- package/dist/{i18n-message-complilation-393d344a.cjs.prod.js → i18n-message-complilation-7762da61.cjs.prod.js} +1 -1
- package/dist/{login-5c212340.esm.js → login-1b222f33.esm.js} +27 -30
- package/dist/{login-b4e3433c.cjs.prod.js → login-54ebae96.cjs.prod.js} +28 -31
- package/dist/{login-856475d9.cjs.dev.js → login-a6fd5fbf.cjs.dev.js} +28 -31
- package/dist/{optimizations-ea21b802.cjs.prod.js → optimizations-7789145e.cjs.dev.js} +5 -8
- package/dist/{optimizations-ea71a24a.esm.js → optimizations-bf991634.esm.js} +5 -7
- package/dist/{optimizations-ebbeaf88.cjs.dev.js → optimizations-fb93514f.cjs.prod.js} +5 -8
- package/dist/{package-85c56dad.esm.js → package-a34835d9.esm.js} +9 -11
- package/dist/{package-36c179b4.cjs.prod.js → package-d8b1f4c0.cjs.dev.js} +9 -11
- package/dist/{package-483f057b.cjs.dev.js → package-e1f7242c.cjs.prod.js} +9 -11
- package/dist/{paths-7bf7e88e.esm.js → paths-39f22b8b.esm.js} +4 -9
- package/dist/{paths-af1a725a.cjs.prod.js → paths-7768b440.cjs.prod.js} +4 -10
- package/dist/{paths-ec3e3a7d.cjs.dev.js → paths-b76fc753.cjs.dev.js} +4 -10
- package/dist/{serve-04a03d5f.cjs.dev.js → serve-38456e1b.cjs.dev.js} +7 -6
- package/dist/{serve-fb1a0f5a.esm.js → serve-be1f9439.esm.js} +6 -6
- package/dist/{serve-2a863026.cjs.prod.js → serve-cc4a766d.cjs.prod.js} +7 -6
- package/dist/{start-33cc9cbb.cjs.prod.js → start-0be8a294.cjs.prod.js} +8 -9
- package/dist/{start-e28d1fec.cjs.dev.js → start-37ec4a7e.cjs.dev.js} +8 -9
- package/dist/{start-654d09ae.esm.js → start-890895df.esm.js} +8 -9
- package/dist/{start-vite-eea72ba9.cjs.dev.js → start-vite-068e9f73.cjs.dev.js} +3 -4
- package/dist/{start-vite-d548c121.cjs.prod.js → start-vite-29078b3a.cjs.prod.js} +3 -4
- package/dist/{start-vite-d649d1f3.esm.js → start-vite-7d1161e8.esm.js} +3 -4
- package/dist/{vite-plugin-svgr-53ef97c7.cjs.dev.js → vite-plugin-svgr-4034a834.cjs.prod.js} +4 -4
- package/dist/{vite-plugin-svgr-5de1cad9.cjs.prod.js → vite-plugin-svgr-7d06f400.cjs.dev.js} +4 -4
- package/dist/{vite-plugin-svgr-22c8d518.esm.js → vite-plugin-svgr-de6ee7da.esm.js} +4 -4
- package/package.json +9 -11
- 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 +6 -6
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +6 -6
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +6 -6
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.dev.js +1 -1
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.prod.js +1 -1
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.esm.js +1 -1
package/dist/{deployment-previews-set-8b33d390.esm.js → deployment-previews-set-bbef95d2.esm.js}
RENAMED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import _URL from '@babel/runtime-corejs3/core-js-stable/url';
|
|
2
2
|
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
3
|
-
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
4
3
|
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
5
4
|
import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
|
|
6
5
|
import chalk from 'chalk';
|
|
7
6
|
import prompts from 'prompts';
|
|
8
7
|
import { processConfig } from '@commercetools-frontend/application-config';
|
|
9
|
-
import { C as CredentialsStorage } from './credentials-storage-
|
|
10
|
-
import { f as fetchCustomApplication, g as updateCustomApplicationDeploymentPreview, h as createCustomApplicationDeploymentPreview } from './graphql-requests-
|
|
8
|
+
import { C as CredentialsStorage } from './credentials-storage-4464313c.esm.js';
|
|
9
|
+
import { f as fetchCustomApplication, g as updateCustomApplicationDeploymentPreview, h as createCustomApplicationDeploymentPreview } from './graphql-requests-14074b2b.esm.js';
|
|
11
10
|
import '@babel/runtime-corejs3/helpers/classCallCheck';
|
|
12
11
|
import '@babel/runtime-corejs3/helpers/createClass';
|
|
13
12
|
import '@babel/runtime-corejs3/core-js-stable/json/stringify';
|
|
@@ -29,7 +28,7 @@ import 'graphql';
|
|
|
29
28
|
import 'graphql-request';
|
|
30
29
|
import '@commercetools-frontend/constants';
|
|
31
30
|
import '@commercetools/http-user-agent';
|
|
32
|
-
import './package-
|
|
31
|
+
import './package-a34835d9.esm.js';
|
|
33
32
|
|
|
34
33
|
const credentialsStorage = new CredentialsStorage();
|
|
35
34
|
const validateUrl = function () {
|
|
@@ -45,25 +44,24 @@ const validateUrl = function () {
|
|
|
45
44
|
const validateAlias = function () {
|
|
46
45
|
let alias = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
47
46
|
try {
|
|
48
|
-
new _URL(
|
|
47
|
+
new _URL(`https://${alias}.commercetools.com/`);
|
|
49
48
|
return true;
|
|
50
49
|
} catch (error) {
|
|
51
50
|
return false;
|
|
52
51
|
}
|
|
53
52
|
};
|
|
54
53
|
const getMcUrlLink = _ref => {
|
|
55
|
-
var _context2, _context3, _context4;
|
|
56
54
|
let mcApiUrl = _ref.mcApiUrl,
|
|
57
55
|
organizationId = _ref.organizationId,
|
|
58
56
|
customEntityId = _ref.customEntityId,
|
|
59
57
|
isCustomView = _ref.isCustomView;
|
|
60
58
|
const mcUrl = mcApiUrl.replace('mc-api', 'mc');
|
|
61
|
-
const customEntityLink =
|
|
59
|
+
const customEntityLink = `${mcUrl}/account/organizations/${organizationId}/custom-${isCustomView ? 'views' : 'applications'}/owned/${customEntityId}/deployment-previews`;
|
|
62
60
|
return customEntityLink;
|
|
63
61
|
};
|
|
64
62
|
const isCustomViewData = data => data.entryPointUriPath === undefined;
|
|
65
63
|
async function setDeploymentPreview(_ref2) {
|
|
66
|
-
var
|
|
64
|
+
var _context3;
|
|
67
65
|
let mcApiUrl = _ref2.mcApiUrl,
|
|
68
66
|
applicationId = _ref2.applicationId,
|
|
69
67
|
applicationIdentifier = _ref2.applicationIdentifier,
|
|
@@ -84,28 +82,28 @@ async function setDeploymentPreview(_ref2) {
|
|
|
84
82
|
applicationIdentifier
|
|
85
83
|
});
|
|
86
84
|
if (!fetchedCustomApplication) {
|
|
87
|
-
throw new Error(
|
|
85
|
+
throw new Error(`The Custom Application "${applicationIdentifier}" does not exist in the Merchant Center. Please create a Custom Application first before configuring deployment previews.`);
|
|
88
86
|
}
|
|
89
87
|
let deploymentAlias = options.alias;
|
|
90
88
|
// If the alias was not provided as an argument to the script, let's ask for it.
|
|
91
89
|
if (!deploymentAlias) {
|
|
92
|
-
var
|
|
90
|
+
var _context2;
|
|
93
91
|
const _await$prompts = await prompts({
|
|
94
92
|
type: 'text',
|
|
95
93
|
name: 'alias',
|
|
96
|
-
message: _filterInstanceProperty(
|
|
94
|
+
message: _filterInstanceProperty(_context2 = [`Enter the alias for the deployment preview`, options.dryRun && chalk.gray('Using "--dry-run", no deployment preview will be created.')]).call(_context2, Boolean).join('\n'),
|
|
97
95
|
validate: value => validateAlias(value)
|
|
98
96
|
}),
|
|
99
97
|
alias = _await$prompts.alias;
|
|
100
98
|
deploymentAlias = alias;
|
|
101
99
|
}
|
|
102
|
-
const existingDeploymentPreview = _findInstanceProperty(
|
|
100
|
+
const existingDeploymentPreview = _findInstanceProperty(_context3 = fetchedCustomApplication.application.deployments).call(_context3, deployment => deployment.alias === deploymentAlias);
|
|
103
101
|
if (!options.alias && !options.url && existingDeploymentPreview) {
|
|
104
|
-
var
|
|
102
|
+
var _context4;
|
|
105
103
|
const _await$prompts2 = await prompts({
|
|
106
104
|
type: 'confirm',
|
|
107
105
|
name: 'aliasOverrideConfirmation',
|
|
108
|
-
message: _filterInstanceProperty(
|
|
106
|
+
message: _filterInstanceProperty(_context4 = [`The alias "${chalk.green(deploymentAlias)}" already exists. Do you want to proceed and update the URL?`, options.dryRun && chalk.gray('Using "--dry-run", no deployment preview will be created.')]).call(_context4, Boolean).join('\n'),
|
|
109
107
|
initial: false
|
|
110
108
|
}),
|
|
111
109
|
aliasOverrideConfirmation = _await$prompts2.aliasOverrideConfirmation;
|
|
@@ -116,20 +114,19 @@ async function setDeploymentPreview(_ref2) {
|
|
|
116
114
|
}
|
|
117
115
|
let deploymentUrl = options.url;
|
|
118
116
|
if (!deploymentUrl) {
|
|
119
|
-
var
|
|
117
|
+
var _context5;
|
|
120
118
|
const _await$prompts3 = await prompts({
|
|
121
119
|
type: 'text',
|
|
122
120
|
name: 'url',
|
|
123
|
-
message: _filterInstanceProperty(
|
|
121
|
+
message: _filterInstanceProperty(_context5 = [`Enter the URL for the deployment preview`, options.dryRun && chalk.gray('Using "--dry-run", no deployment preview will be created.')]).call(_context5, Boolean).join('\n'),
|
|
124
122
|
validate: value => validateUrl(value)
|
|
125
123
|
}),
|
|
126
124
|
url = _await$prompts3.url;
|
|
127
125
|
deploymentUrl = url;
|
|
128
126
|
}
|
|
129
127
|
if (options.dryRun) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
console.log("\n".concat(message, "\n"));
|
|
128
|
+
const message = existingDeploymentPreview ? `The existing deployment preview with alias "${deploymentAlias}" would have been updated with this url: "${deploymentUrl}".` : `A new deployment preview with alias "${deploymentAlias}" would have been created with this url: "${deploymentUrl}".`;
|
|
129
|
+
console.log(`\n${message}\n`);
|
|
133
130
|
return;
|
|
134
131
|
}
|
|
135
132
|
const mcDeploymentPreviewsLink = getMcUrlLink({
|
|
@@ -139,7 +136,6 @@ async function setDeploymentPreview(_ref2) {
|
|
|
139
136
|
isCustomView
|
|
140
137
|
});
|
|
141
138
|
if (existingDeploymentPreview) {
|
|
142
|
-
var _context1;
|
|
143
139
|
await updateCustomApplicationDeploymentPreview({
|
|
144
140
|
mcApiUrl,
|
|
145
141
|
organizationId: fetchedCustomApplication.organizationId,
|
|
@@ -149,10 +145,9 @@ async function setDeploymentPreview(_ref2) {
|
|
|
149
145
|
url: deploymentUrl
|
|
150
146
|
}
|
|
151
147
|
});
|
|
152
|
-
console.log(chalk.green(
|
|
153
|
-
console.log(chalk.green(
|
|
148
|
+
console.log(chalk.green(`Deployment preview with alias "${deploymentAlias}" updated successfully with URL "${deploymentUrl}".`));
|
|
149
|
+
console.log(chalk.green(`You can access the deployment previews at: ${mcDeploymentPreviewsLink}`));
|
|
154
150
|
} else {
|
|
155
|
-
var _context10;
|
|
156
151
|
await createCustomApplicationDeploymentPreview({
|
|
157
152
|
mcApiUrl,
|
|
158
153
|
organizationId: fetchedCustomApplication.organizationId,
|
|
@@ -163,8 +158,8 @@ async function setDeploymentPreview(_ref2) {
|
|
|
163
158
|
url: deploymentUrl
|
|
164
159
|
}
|
|
165
160
|
});
|
|
166
|
-
console.log(chalk.green(
|
|
167
|
-
console.log(chalk.green(
|
|
161
|
+
console.log(chalk.green(`Deployment preview with alias "${deploymentAlias}" created successfully with URL "${deploymentUrl}".`));
|
|
162
|
+
console.log(chalk.green(`You can access the deployment previews at: ${mcDeploymentPreviewsLink}`));
|
|
168
163
|
}
|
|
169
164
|
}
|
|
170
165
|
async function run(options) {
|
|
@@ -174,11 +169,11 @@ async function run(options) {
|
|
|
174
169
|
mcApiUrl = _applicationConfig$en.mcApiUrl,
|
|
175
170
|
applicationIdentifier = _applicationConfig$en.applicationIdentifier;
|
|
176
171
|
const isCustomView = isCustomViewData(localCustomEntityData);
|
|
177
|
-
console.log(
|
|
172
|
+
console.log(`Using Merchant Center environment "${chalk.green(mcApiUrl)}".`);
|
|
178
173
|
console.log();
|
|
179
174
|
const isSessionValid = credentialsStorage.isSessionValid(mcApiUrl);
|
|
180
175
|
if (!isSessionValid) {
|
|
181
|
-
throw new Error(
|
|
176
|
+
throw new Error(`You don't have a valid session. Please, run the "mc-scripts login" command to authenticate yourself.`);
|
|
182
177
|
}
|
|
183
178
|
if (isCustomView) {
|
|
184
179
|
throw new Error('Deployments previews are not supported for Custom Views.');
|
|
@@ -14,9 +14,9 @@ var chalk = require('chalk');
|
|
|
14
14
|
var graphql = require('graphql');
|
|
15
15
|
var graphqlRequest = require('graphql-request');
|
|
16
16
|
var constants = require('@commercetools-frontend/constants');
|
|
17
|
-
var credentialsStorage$1 = require('./credentials-storage-
|
|
17
|
+
var credentialsStorage$1 = require('./credentials-storage-0b89aa0e.cjs.prod.js');
|
|
18
18
|
var createHttpUserAgent = require('@commercetools/http-user-agent');
|
|
19
|
-
var _package = require('./package-
|
|
19
|
+
var _package = require('./package-e1f7242c.cjs.prod.js');
|
|
20
20
|
|
|
21
21
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
22
22
|
|
|
@@ -57,9 +57,9 @@ async function requestWithTokenRetry(document, requestOptions) {
|
|
|
57
57
|
let retryCount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
58
58
|
const token = credentialsStorage.getToken(requestOptions.mcApiUrl);
|
|
59
59
|
const tokenHeader = {
|
|
60
|
-
[constants.SUPPORTED_HEADERS.AUTHORIZATION]:
|
|
60
|
+
[constants.SUPPORTED_HEADERS.AUTHORIZATION]: `Bearer ${token}`
|
|
61
61
|
};
|
|
62
|
-
const client = new graphqlRequest.GraphQLClient(
|
|
62
|
+
const client = new graphqlRequest.GraphQLClient(`${requestOptions.mcApiUrl}/graphql`, {
|
|
63
63
|
headers: _objectSpread(_objectSpread({
|
|
64
64
|
Accept: 'application/json',
|
|
65
65
|
'Content-Type': 'application/json',
|
|
@@ -87,10 +87,7 @@ async function requestWithTokenRetry(document, requestOptions) {
|
|
|
87
87
|
// If it's an unauthorized error, retry the request to force the token to be refreshed.
|
|
88
88
|
if (retryCount === 0 && error.response.errors && error.response.errors.length > 0) {
|
|
89
89
|
var _context;
|
|
90
|
-
const isUnauthorizedError = _someInstanceProperty__default["default"](_context = error.response.errors).call(_context, graphqlError =>
|
|
91
|
-
var _graphqlError$extensi;
|
|
92
|
-
return ((_graphqlError$extensi = graphqlError.extensions) === null || _graphqlError$extensi === void 0 ? void 0 : _graphqlError$extensi.code) === 'UNAUTHENTICATED';
|
|
93
|
-
});
|
|
90
|
+
const isUnauthorizedError = _someInstanceProperty__default["default"](_context = error.response.errors).call(_context, graphqlError => graphqlError.extensions?.code === 'UNAUTHENTICATED');
|
|
94
91
|
if (isUnauthorizedError) {
|
|
95
92
|
console.log(chalk__default["default"].yellow('Expired or invalid session token, attempting to retry the request with a refreshed token...'));
|
|
96
93
|
return requestWithTokenRetry(document, _objectSpread(_objectSpread({}, requestOptions), {}, {
|
|
@@ -12,9 +12,9 @@ import chalk from 'chalk';
|
|
|
12
12
|
import { print } from 'graphql';
|
|
13
13
|
import { GraphQLClient, ClientError } from 'graphql-request';
|
|
14
14
|
import { GRAPHQL_TARGETS, SUPPORTED_HEADERS } from '@commercetools-frontend/constants';
|
|
15
|
-
import { C as CredentialsStorage } from './credentials-storage-
|
|
15
|
+
import { C as CredentialsStorage } from './credentials-storage-4464313c.esm.js';
|
|
16
16
|
import createHttpUserAgent from '@commercetools/http-user-agent';
|
|
17
|
-
import { p as pkgJson } from './package-
|
|
17
|
+
import { p as pkgJson } from './package-a34835d9.esm.js';
|
|
18
18
|
|
|
19
19
|
const userAgent = createHttpUserAgent({
|
|
20
20
|
name: 'graphql-request',
|
|
@@ -41,9 +41,9 @@ async function requestWithTokenRetry(document, requestOptions) {
|
|
|
41
41
|
let retryCount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
42
42
|
const token = credentialsStorage.getToken(requestOptions.mcApiUrl);
|
|
43
43
|
const tokenHeader = {
|
|
44
|
-
[SUPPORTED_HEADERS.AUTHORIZATION]:
|
|
44
|
+
[SUPPORTED_HEADERS.AUTHORIZATION]: `Bearer ${token}`
|
|
45
45
|
};
|
|
46
|
-
const client = new GraphQLClient(
|
|
46
|
+
const client = new GraphQLClient(`${requestOptions.mcApiUrl}/graphql`, {
|
|
47
47
|
headers: _objectSpread(_objectSpread({
|
|
48
48
|
Accept: 'application/json',
|
|
49
49
|
'Content-Type': 'application/json',
|
|
@@ -71,10 +71,7 @@ async function requestWithTokenRetry(document, requestOptions) {
|
|
|
71
71
|
// If it's an unauthorized error, retry the request to force the token to be refreshed.
|
|
72
72
|
if (retryCount === 0 && error.response.errors && error.response.errors.length > 0) {
|
|
73
73
|
var _context;
|
|
74
|
-
const isUnauthorizedError = _someInstanceProperty(_context = error.response.errors).call(_context, graphqlError =>
|
|
75
|
-
var _graphqlError$extensi;
|
|
76
|
-
return ((_graphqlError$extensi = graphqlError.extensions) === null || _graphqlError$extensi === void 0 ? void 0 : _graphqlError$extensi.code) === 'UNAUTHENTICATED';
|
|
77
|
-
});
|
|
74
|
+
const isUnauthorizedError = _someInstanceProperty(_context = error.response.errors).call(_context, graphqlError => graphqlError.extensions?.code === 'UNAUTHENTICATED');
|
|
78
75
|
if (isUnauthorizedError) {
|
|
79
76
|
console.log(chalk.yellow('Expired or invalid session token, attempting to retry the request with a refreshed token...'));
|
|
80
77
|
return requestWithTokenRetry(document, _objectSpread(_objectSpread({}, requestOptions), {}, {
|
|
@@ -14,9 +14,9 @@ var chalk = require('chalk');
|
|
|
14
14
|
var graphql = require('graphql');
|
|
15
15
|
var graphqlRequest = require('graphql-request');
|
|
16
16
|
var constants = require('@commercetools-frontend/constants');
|
|
17
|
-
var credentialsStorage$1 = require('./credentials-storage-
|
|
17
|
+
var credentialsStorage$1 = require('./credentials-storage-cbb5c559.cjs.dev.js');
|
|
18
18
|
var createHttpUserAgent = require('@commercetools/http-user-agent');
|
|
19
|
-
var _package = require('./package-
|
|
19
|
+
var _package = require('./package-d8b1f4c0.cjs.dev.js');
|
|
20
20
|
|
|
21
21
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
22
22
|
|
|
@@ -57,9 +57,9 @@ async function requestWithTokenRetry(document, requestOptions) {
|
|
|
57
57
|
let retryCount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
58
58
|
const token = credentialsStorage.getToken(requestOptions.mcApiUrl);
|
|
59
59
|
const tokenHeader = {
|
|
60
|
-
[constants.SUPPORTED_HEADERS.AUTHORIZATION]:
|
|
60
|
+
[constants.SUPPORTED_HEADERS.AUTHORIZATION]: `Bearer ${token}`
|
|
61
61
|
};
|
|
62
|
-
const client = new graphqlRequest.GraphQLClient(
|
|
62
|
+
const client = new graphqlRequest.GraphQLClient(`${requestOptions.mcApiUrl}/graphql`, {
|
|
63
63
|
headers: _objectSpread(_objectSpread({
|
|
64
64
|
Accept: 'application/json',
|
|
65
65
|
'Content-Type': 'application/json',
|
|
@@ -87,10 +87,7 @@ async function requestWithTokenRetry(document, requestOptions) {
|
|
|
87
87
|
// If it's an unauthorized error, retry the request to force the token to be refreshed.
|
|
88
88
|
if (retryCount === 0 && error.response.errors && error.response.errors.length > 0) {
|
|
89
89
|
var _context;
|
|
90
|
-
const isUnauthorizedError = _someInstanceProperty__default["default"](_context = error.response.errors).call(_context, graphqlError =>
|
|
91
|
-
var _graphqlError$extensi;
|
|
92
|
-
return ((_graphqlError$extensi = graphqlError.extensions) === null || _graphqlError$extensi === void 0 ? void 0 : _graphqlError$extensi.code) === 'UNAUTHENTICATED';
|
|
93
|
-
});
|
|
90
|
+
const isUnauthorizedError = _someInstanceProperty__default["default"](_context = error.response.errors).call(_context, graphqlError => graphqlError.extensions?.code === 'UNAUTHENTICATED');
|
|
94
91
|
if (isUnauthorizedError) {
|
|
95
92
|
console.log(chalk__default["default"].yellow('Expired or invalid session token, attempting to retry the request with a refreshed token...'));
|
|
96
93
|
return requestWithTokenRetry(document, _objectSpread(_objectSpread({}, requestOptions), {}, {
|
package/dist/{i18n-message-complilation-8aec9d1b.esm.js → i18n-message-complilation-21d3b0aa.esm.js}
RENAMED
|
@@ -8,7 +8,7 @@ function getI18nMessageFormat(source) {
|
|
|
8
8
|
}
|
|
9
9
|
function handleMessageCompilationError(fileIdentifier, error, warnFunction) {
|
|
10
10
|
if (!process.env.CI) {
|
|
11
|
-
warnFunction(new Error(
|
|
11
|
+
warnFunction(new Error(`[i18n message compilation] Message compilation on ${fileIdentifier} has failed.\n` + `Consider setting the environmental variable ${chalk.yellow('DISABLE_I18N_MESSAGE_COMPILATION')} to true to disable the message loader or resolve the issues on the messages file.\n` + `${error instanceof Error ? `Error: ${error.message}` : ''}`));
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -15,7 +15,7 @@ function getI18nMessageFormat(source) {
|
|
|
15
15
|
}
|
|
16
16
|
function handleMessageCompilationError(fileIdentifier, error, warnFunction) {
|
|
17
17
|
if (!process.env.CI) {
|
|
18
|
-
warnFunction(new Error(
|
|
18
|
+
warnFunction(new Error(`[i18n message compilation] Message compilation on ${fileIdentifier} has failed.\n` + `Consider setting the environmental variable ${chalk__default["default"].yellow('DISABLE_I18N_MESSAGE_COMPILATION')} to true to disable the message loader or resolve the issues on the messages file.\n` + `${error instanceof Error ? `Error: ${error.message}` : ''}`));
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -15,7 +15,7 @@ function getI18nMessageFormat(source) {
|
|
|
15
15
|
}
|
|
16
16
|
function handleMessageCompilationError(fileIdentifier, error, warnFunction) {
|
|
17
17
|
if (!process.env.CI) {
|
|
18
|
-
warnFunction(new Error(
|
|
18
|
+
warnFunction(new Error(`[i18n message compilation] Message compilation on ${fileIdentifier} has failed.\n` + `Consider setting the environmental variable ${chalk__default["default"].yellow('DISABLE_I18N_MESSAGE_COMPILATION')} to true to disable the message loader or resolve the issues on the messages file.\n` + `${error instanceof Error ? `Error: ${error.message}` : ''}`));
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _Promise from '@babel/runtime-corejs3/core-js-stable/promise';
|
|
2
2
|
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
3
3
|
import _startsWithInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/starts-with';
|
|
4
|
-
import
|
|
4
|
+
import _bindInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/bind';
|
|
5
5
|
import _trimInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/trim';
|
|
6
6
|
import _flatMapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/flat-map';
|
|
7
7
|
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
|
|
@@ -10,11 +10,11 @@ import crypto from 'node:crypto';
|
|
|
10
10
|
import process, { exit } from 'node:process';
|
|
11
11
|
import chalk from 'chalk';
|
|
12
12
|
import { processConfig } from '@commercetools-frontend/application-config';
|
|
13
|
-
import { p as pkgJson } from './package-
|
|
13
|
+
import { p as pkgJson } from './package-a34835d9.esm.js';
|
|
14
14
|
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
15
15
|
import http from 'node:http';
|
|
16
16
|
import jwtDecode from 'jwt-decode';
|
|
17
|
-
import { C as CredentialsStorage } from './credentials-storage-
|
|
17
|
+
import { C as CredentialsStorage } from './credentials-storage-4464313c.esm.js';
|
|
18
18
|
import '@babel/runtime-corejs3/helpers/classCallCheck';
|
|
19
19
|
import '@babel/runtime-corejs3/helpers/createClass';
|
|
20
20
|
import '@babel/runtime-corejs3/core-js-stable/json/stringify';
|
|
@@ -27,8 +27,8 @@ import './does-file-exist-32618334.esm.js';
|
|
|
27
27
|
function createAuthCallbackServer(options) {
|
|
28
28
|
const server = http.createServer(async (request, response) => {
|
|
29
29
|
try {
|
|
30
|
-
var
|
|
31
|
-
if ((
|
|
30
|
+
var _context, _context2;
|
|
31
|
+
if (((_context = request.url) == null ? void 0 : _bindInstanceProperty(_context2 = Function.call).call(_context2, _includesInstanceProperty(_context), _context))?.(`/${options.clientIdentifier}/oidc/callback`)) {
|
|
32
32
|
const incomingUrl = new _URL(request.url, 'http://localhost');
|
|
33
33
|
const sessionToken = incomingUrl.searchParams.get('sessionToken');
|
|
34
34
|
const requestedState = incomingUrl.searchParams.get('state');
|
|
@@ -36,7 +36,7 @@ function createAuthCallbackServer(options) {
|
|
|
36
36
|
throw new Error('Invalid authentication flow (missing sessionToken)');
|
|
37
37
|
}
|
|
38
38
|
const decodedSessionToken = jwtDecode(sessionToken);
|
|
39
|
-
if (
|
|
39
|
+
if (decodedSessionToken?.nonce !== options.nonce) {
|
|
40
40
|
throw new Error('Invalid authentication flow (nonce mismatch)');
|
|
41
41
|
}
|
|
42
42
|
if (requestedState !== options.state) {
|
|
@@ -59,7 +59,7 @@ function createAuthCallbackServer(options) {
|
|
|
59
59
|
response.end(error.message);
|
|
60
60
|
} else {
|
|
61
61
|
console.error(error);
|
|
62
|
-
response.end(
|
|
62
|
+
response.end(`Invalid authentication flow.`);
|
|
63
63
|
}
|
|
64
64
|
server.close(() => {
|
|
65
65
|
exit();
|
|
@@ -71,14 +71,14 @@ function createAuthCallbackServer(options) {
|
|
|
71
71
|
|
|
72
72
|
const credentialsStorage = new CredentialsStorage();
|
|
73
73
|
const port = 3001;
|
|
74
|
-
const clientIdentifier =
|
|
74
|
+
const clientIdentifier = `mc-scripts-${pkgJson.version}`;
|
|
75
75
|
const isServerError = error => {
|
|
76
76
|
return error instanceof Error && 'code' in error;
|
|
77
77
|
};
|
|
78
78
|
const startServer = server => new _Promise((resolve, reject) => {
|
|
79
79
|
server.listen(port, 'localhost').on('listening', resolve).on('error', error => {
|
|
80
80
|
if (isServerError(error) && error.code === 'EADDRINUSE') {
|
|
81
|
-
return reject(new Error(
|
|
81
|
+
return reject(new Error(`The address "localhost:${port}" is already in use. Are you running a Merchant Center application in other process? Please stop that and try again.`, {
|
|
82
82
|
cause: error
|
|
83
83
|
}));
|
|
84
84
|
}
|
|
@@ -114,9 +114,8 @@ const resolveProjectKey = async options => {
|
|
|
114
114
|
return process.env.CTP_PROJECT_KEY;
|
|
115
115
|
}
|
|
116
116
|
try {
|
|
117
|
-
var _applicationConfig$en;
|
|
118
117
|
const applicationConfig = await processConfig();
|
|
119
|
-
return
|
|
118
|
+
return applicationConfig.env.__DEVELOPMENT__?.oidc?.initialProjectKey;
|
|
120
119
|
} catch (error) {
|
|
121
120
|
// It's ok if there's not application config file or if it does not contain the initialProjectKey
|
|
122
121
|
return;
|
|
@@ -125,10 +124,10 @@ const resolveProjectKey = async options => {
|
|
|
125
124
|
const mapOAuthScopesToClaims = scopes => {
|
|
126
125
|
return _mapInstanceProperty(scopes).call(scopes, scope => {
|
|
127
126
|
if (_startsWithInstanceProperty(scope).call(scope, 'view_')) {
|
|
128
|
-
return
|
|
127
|
+
return `view:${scope}`;
|
|
129
128
|
}
|
|
130
129
|
if (_startsWithInstanceProperty(scope).call(scope, 'manage_')) {
|
|
131
|
-
return
|
|
130
|
+
return `manage:${scope}`;
|
|
132
131
|
}
|
|
133
132
|
return scope;
|
|
134
133
|
});
|
|
@@ -136,12 +135,10 @@ const mapOAuthScopesToClaims = scopes => {
|
|
|
136
135
|
const mapAdditionalOAuthScopesToClaims = (name, scopes) => {
|
|
137
136
|
return _mapInstanceProperty(scopes).call(scopes, scope => {
|
|
138
137
|
if (_startsWithInstanceProperty(scope).call(scope, 'view_')) {
|
|
139
|
-
|
|
140
|
-
return _concatInstanceProperty(_context = "view/".concat(name, ":")).call(_context, scope);
|
|
138
|
+
return `view/${name}:${scope}`;
|
|
141
139
|
}
|
|
142
140
|
if (_startsWithInstanceProperty(scope).call(scope, 'manage_')) {
|
|
143
|
-
|
|
144
|
-
return _concatInstanceProperty(_context2 = "manage/".concat(name, ":")).call(_context2, scope);
|
|
141
|
+
return `manage/${name}:${scope}`;
|
|
145
142
|
}
|
|
146
143
|
return scope;
|
|
147
144
|
});
|
|
@@ -153,15 +150,15 @@ const resolveOAuthScopes = async options => {
|
|
|
153
150
|
|
|
154
151
|
// We first check whether the user has set the CTP_OAUTH_SCOPES environment variable
|
|
155
152
|
if (process.env.CTP_OAUTH_SCOPES) {
|
|
156
|
-
var
|
|
157
|
-
return mapOAuthScopesToClaims((
|
|
153
|
+
var _context, _context2;
|
|
154
|
+
return mapOAuthScopesToClaims(((_context = process.env.CTP_OAUTH_SCOPES?.split(',')) == null ? void 0 : _bindInstanceProperty(_context2 = Function.call).call(_context2, _mapInstanceProperty(_context), _context))?.(scope => _trimInstanceProperty(scope).call(scope)) ?? []);
|
|
158
155
|
}
|
|
159
156
|
try {
|
|
160
|
-
var
|
|
157
|
+
var _context3, _context4, _context5, _context6;
|
|
161
158
|
const applicationConfig = await processConfig();
|
|
162
|
-
const configuredOAuthScopes =
|
|
163
|
-
const configuredAdditionalOAuthScopes =
|
|
164
|
-
return [...mapOAuthScopesToClaims(
|
|
159
|
+
const configuredOAuthScopes = applicationConfig.env.__DEVELOPMENT__?.oidc?.oAuthScopes;
|
|
160
|
+
const configuredAdditionalOAuthScopes = applicationConfig.env.__DEVELOPMENT__?.oidc?.additionalOAuthScopes;
|
|
161
|
+
return [...mapOAuthScopesToClaims(configuredOAuthScopes?.view ?? []), ...mapOAuthScopesToClaims(configuredOAuthScopes?.manage ?? []), ...(((_context3 = configuredAdditionalOAuthScopes) == null ? void 0 : _bindInstanceProperty(_context4 = Function.call).call(_context4, _flatMapInstanceProperty(_context3), _context3))?.(scope => mapAdditionalOAuthScopesToClaims(scope.name, scope.view)) ?? []), ...(((_context5 = configuredAdditionalOAuthScopes) == null ? void 0 : _bindInstanceProperty(_context6 = Function.call).call(_context6, _flatMapInstanceProperty(_context5), _context5))?.(scope => mapAdditionalOAuthScopesToClaims(scope.name, scope.manage)) ?? [])];
|
|
165
162
|
} catch (error) {
|
|
166
163
|
// It's ok if there's not application config file or if it does not contain the initialProjectKey
|
|
167
164
|
return [];
|
|
@@ -176,17 +173,17 @@ async function run(options) {
|
|
|
176
173
|
if (!mcApiUrl) {
|
|
177
174
|
throw new Error('No Merchant Center API URL found. Aborting.');
|
|
178
175
|
}
|
|
179
|
-
console.log(
|
|
176
|
+
console.log(`Using Merchant Center environment "${chalk.green(mcApiUrl)}".`);
|
|
180
177
|
console.log();
|
|
181
178
|
if (!options.force && credentialsStorage.isSessionValid(mcApiUrl)) {
|
|
182
|
-
console.log(
|
|
179
|
+
console.log(`You already have a valid session.`);
|
|
183
180
|
return;
|
|
184
181
|
}
|
|
185
182
|
const projectKey = await resolveProjectKey(options);
|
|
186
183
|
const oauthScopes = await resolveOAuthScopes(options);
|
|
187
184
|
const scopes = ['openid'];
|
|
188
185
|
if (projectKey) {
|
|
189
|
-
scopes.push(
|
|
186
|
+
scopes.push(`project_key:${projectKey}`);
|
|
190
187
|
_forEachInstanceProperty(oauthScopes).call(oauthScopes, scope => {
|
|
191
188
|
scopes.push(scope);
|
|
192
189
|
});
|
|
@@ -196,7 +193,7 @@ async function run(options) {
|
|
|
196
193
|
const authUrl = new _URL('/login/authorize', mcApiUrl);
|
|
197
194
|
authUrl.searchParams.set('response_type', 'id_token');
|
|
198
195
|
authUrl.searchParams.set('response_mode', 'query');
|
|
199
|
-
authUrl.searchParams.set('client_id',
|
|
196
|
+
authUrl.searchParams.set('client_id', `__local:${clientIdentifier}`);
|
|
200
197
|
authUrl.searchParams.set('scope', scopes.join(' '));
|
|
201
198
|
authUrl.searchParams.set('state', state);
|
|
202
199
|
authUrl.searchParams.set('nonce', nonce);
|
|
@@ -207,13 +204,13 @@ async function run(options) {
|
|
|
207
204
|
onSuccess: tokenContext => {
|
|
208
205
|
credentialsStorage.setToken(mcApiUrl, tokenContext);
|
|
209
206
|
console.log();
|
|
210
|
-
console.log(chalk.green(
|
|
207
|
+
console.log(chalk.green(`Login successful.`));
|
|
211
208
|
console.log();
|
|
212
209
|
}
|
|
213
210
|
});
|
|
214
211
|
await startServer(server);
|
|
215
|
-
console.log(
|
|
216
|
-
console.log(
|
|
212
|
+
console.log(`Initiating the OIDC authentication flow, opening the login page in your browser...`);
|
|
213
|
+
console.log(` ${authUrl}`);
|
|
217
214
|
console.log();
|
|
218
215
|
const open = await import('open');
|
|
219
216
|
await open.default(authUrl.toString());
|