@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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _Promise = require('@babel/runtime-corejs3/core-js-stable/promise');
|
|
4
4
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
5
5
|
var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
|
|
6
|
-
var
|
|
6
|
+
var _bindInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/bind');
|
|
7
7
|
var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
|
|
8
8
|
var _flatMapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat-map');
|
|
9
9
|
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
@@ -12,11 +12,11 @@ var crypto = require('node:crypto');
|
|
|
12
12
|
var process = require('node:process');
|
|
13
13
|
var chalk = require('chalk');
|
|
14
14
|
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
15
|
-
var _package = require('./package-
|
|
15
|
+
var _package = require('./package-e1f7242c.cjs.prod.js');
|
|
16
16
|
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
17
17
|
var http = require('node:http');
|
|
18
18
|
var jwtDecode = require('jwt-decode');
|
|
19
|
-
var credentialsStorage$1 = require('./credentials-storage-
|
|
19
|
+
var credentialsStorage$1 = require('./credentials-storage-0b89aa0e.cjs.prod.js');
|
|
20
20
|
require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
21
21
|
require('@babel/runtime-corejs3/helpers/createClass');
|
|
22
22
|
require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
@@ -49,7 +49,7 @@ function _interopNamespace(e) {
|
|
|
49
49
|
var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
|
|
50
50
|
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
51
51
|
var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
|
|
52
|
-
var
|
|
52
|
+
var _bindInstanceProperty__default = /*#__PURE__*/_interopDefault(_bindInstanceProperty);
|
|
53
53
|
var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
|
|
54
54
|
var _flatMapInstanceProperty__default = /*#__PURE__*/_interopDefault(_flatMapInstanceProperty);
|
|
55
55
|
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
@@ -64,8 +64,8 @@ var jwtDecode__default = /*#__PURE__*/_interopDefault(jwtDecode);
|
|
|
64
64
|
function createAuthCallbackServer(options) {
|
|
65
65
|
const server = http__default["default"].createServer(async (request, response) => {
|
|
66
66
|
try {
|
|
67
|
-
var
|
|
68
|
-
if ((
|
|
67
|
+
var _context, _context2;
|
|
68
|
+
if (((_context = request.url) == null ? void 0 : _bindInstanceProperty__default["default"](_context2 = Function.call).call(_context2, _includesInstanceProperty__default["default"](_context), _context))?.(`/${options.clientIdentifier}/oidc/callback`)) {
|
|
69
69
|
const incomingUrl = new _URL__default["default"](request.url, 'http://localhost');
|
|
70
70
|
const sessionToken = incomingUrl.searchParams.get('sessionToken');
|
|
71
71
|
const requestedState = incomingUrl.searchParams.get('state');
|
|
@@ -73,7 +73,7 @@ function createAuthCallbackServer(options) {
|
|
|
73
73
|
throw new Error('Invalid authentication flow (missing sessionToken)');
|
|
74
74
|
}
|
|
75
75
|
const decodedSessionToken = jwtDecode__default["default"](sessionToken);
|
|
76
|
-
if (
|
|
76
|
+
if (decodedSessionToken?.nonce !== options.nonce) {
|
|
77
77
|
throw new Error('Invalid authentication flow (nonce mismatch)');
|
|
78
78
|
}
|
|
79
79
|
if (requestedState !== options.state) {
|
|
@@ -96,7 +96,7 @@ function createAuthCallbackServer(options) {
|
|
|
96
96
|
response.end(error.message);
|
|
97
97
|
} else {
|
|
98
98
|
console.error(error);
|
|
99
|
-
response.end(
|
|
99
|
+
response.end(`Invalid authentication flow.`);
|
|
100
100
|
}
|
|
101
101
|
server.close(() => {
|
|
102
102
|
process.exit();
|
|
@@ -108,14 +108,14 @@ function createAuthCallbackServer(options) {
|
|
|
108
108
|
|
|
109
109
|
const credentialsStorage = new credentialsStorage$1.CredentialsStorage();
|
|
110
110
|
const port = 3001;
|
|
111
|
-
const clientIdentifier =
|
|
111
|
+
const clientIdentifier = `mc-scripts-${_package.pkgJson.version}`;
|
|
112
112
|
const isServerError = error => {
|
|
113
113
|
return error instanceof Error && 'code' in error;
|
|
114
114
|
};
|
|
115
115
|
const startServer = server => new _Promise__default["default"]((resolve, reject) => {
|
|
116
116
|
server.listen(port, 'localhost').on('listening', resolve).on('error', error => {
|
|
117
117
|
if (isServerError(error) && error.code === 'EADDRINUSE') {
|
|
118
|
-
return reject(new Error(
|
|
118
|
+
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.`, {
|
|
119
119
|
cause: error
|
|
120
120
|
}));
|
|
121
121
|
}
|
|
@@ -151,9 +151,8 @@ const resolveProjectKey = async options => {
|
|
|
151
151
|
return process__default["default"].env.CTP_PROJECT_KEY;
|
|
152
152
|
}
|
|
153
153
|
try {
|
|
154
|
-
var _applicationConfig$en;
|
|
155
154
|
const applicationConfig$1 = await applicationConfig.processConfig();
|
|
156
|
-
return
|
|
155
|
+
return applicationConfig$1.env.__DEVELOPMENT__?.oidc?.initialProjectKey;
|
|
157
156
|
} catch (error) {
|
|
158
157
|
// It's ok if there's not application config file or if it does not contain the initialProjectKey
|
|
159
158
|
return;
|
|
@@ -162,10 +161,10 @@ const resolveProjectKey = async options => {
|
|
|
162
161
|
const mapOAuthScopesToClaims = scopes => {
|
|
163
162
|
return _mapInstanceProperty__default["default"](scopes).call(scopes, scope => {
|
|
164
163
|
if (_startsWithInstanceProperty__default["default"](scope).call(scope, 'view_')) {
|
|
165
|
-
return
|
|
164
|
+
return `view:${scope}`;
|
|
166
165
|
}
|
|
167
166
|
if (_startsWithInstanceProperty__default["default"](scope).call(scope, 'manage_')) {
|
|
168
|
-
return
|
|
167
|
+
return `manage:${scope}`;
|
|
169
168
|
}
|
|
170
169
|
return scope;
|
|
171
170
|
});
|
|
@@ -173,12 +172,10 @@ const mapOAuthScopesToClaims = scopes => {
|
|
|
173
172
|
const mapAdditionalOAuthScopesToClaims = (name, scopes) => {
|
|
174
173
|
return _mapInstanceProperty__default["default"](scopes).call(scopes, scope => {
|
|
175
174
|
if (_startsWithInstanceProperty__default["default"](scope).call(scope, 'view_')) {
|
|
176
|
-
|
|
177
|
-
return _concatInstanceProperty__default["default"](_context = "view/".concat(name, ":")).call(_context, scope);
|
|
175
|
+
return `view/${name}:${scope}`;
|
|
178
176
|
}
|
|
179
177
|
if (_startsWithInstanceProperty__default["default"](scope).call(scope, 'manage_')) {
|
|
180
|
-
|
|
181
|
-
return _concatInstanceProperty__default["default"](_context2 = "manage/".concat(name, ":")).call(_context2, scope);
|
|
178
|
+
return `manage/${name}:${scope}`;
|
|
182
179
|
}
|
|
183
180
|
return scope;
|
|
184
181
|
});
|
|
@@ -190,15 +187,15 @@ const resolveOAuthScopes = async options => {
|
|
|
190
187
|
|
|
191
188
|
// We first check whether the user has set the CTP_OAUTH_SCOPES environment variable
|
|
192
189
|
if (process__default["default"].env.CTP_OAUTH_SCOPES) {
|
|
193
|
-
var
|
|
194
|
-
return mapOAuthScopesToClaims((
|
|
190
|
+
var _context, _context2;
|
|
191
|
+
return mapOAuthScopesToClaims(((_context = process__default["default"].env.CTP_OAUTH_SCOPES?.split(',')) == null ? void 0 : _bindInstanceProperty__default["default"](_context2 = Function.call).call(_context2, _mapInstanceProperty__default["default"](_context), _context))?.(scope => _trimInstanceProperty__default["default"](scope).call(scope)) ?? []);
|
|
195
192
|
}
|
|
196
193
|
try {
|
|
197
|
-
var
|
|
194
|
+
var _context3, _context4, _context5, _context6;
|
|
198
195
|
const applicationConfig$1 = await applicationConfig.processConfig();
|
|
199
|
-
const configuredOAuthScopes =
|
|
200
|
-
const configuredAdditionalOAuthScopes =
|
|
201
|
-
return [...mapOAuthScopesToClaims(
|
|
196
|
+
const configuredOAuthScopes = applicationConfig$1.env.__DEVELOPMENT__?.oidc?.oAuthScopes;
|
|
197
|
+
const configuredAdditionalOAuthScopes = applicationConfig$1.env.__DEVELOPMENT__?.oidc?.additionalOAuthScopes;
|
|
198
|
+
return [...mapOAuthScopesToClaims(configuredOAuthScopes?.view ?? []), ...mapOAuthScopesToClaims(configuredOAuthScopes?.manage ?? []), ...(((_context3 = configuredAdditionalOAuthScopes) == null ? void 0 : _bindInstanceProperty__default["default"](_context4 = Function.call).call(_context4, _flatMapInstanceProperty__default["default"](_context3), _context3))?.(scope => mapAdditionalOAuthScopesToClaims(scope.name, scope.view)) ?? []), ...(((_context5 = configuredAdditionalOAuthScopes) == null ? void 0 : _bindInstanceProperty__default["default"](_context6 = Function.call).call(_context6, _flatMapInstanceProperty__default["default"](_context5), _context5))?.(scope => mapAdditionalOAuthScopesToClaims(scope.name, scope.manage)) ?? [])];
|
|
202
199
|
} catch (error) {
|
|
203
200
|
// It's ok if there's not application config file or if it does not contain the initialProjectKey
|
|
204
201
|
return [];
|
|
@@ -213,17 +210,17 @@ async function run(options) {
|
|
|
213
210
|
if (!mcApiUrl) {
|
|
214
211
|
throw new Error('No Merchant Center API URL found. Aborting.');
|
|
215
212
|
}
|
|
216
|
-
console.log(
|
|
213
|
+
console.log(`Using Merchant Center environment "${chalk__default["default"].green(mcApiUrl)}".`);
|
|
217
214
|
console.log();
|
|
218
215
|
if (!options.force && credentialsStorage.isSessionValid(mcApiUrl)) {
|
|
219
|
-
console.log(
|
|
216
|
+
console.log(`You already have a valid session.`);
|
|
220
217
|
return;
|
|
221
218
|
}
|
|
222
219
|
const projectKey = await resolveProjectKey(options);
|
|
223
220
|
const oauthScopes = await resolveOAuthScopes(options);
|
|
224
221
|
const scopes = ['openid'];
|
|
225
222
|
if (projectKey) {
|
|
226
|
-
scopes.push(
|
|
223
|
+
scopes.push(`project_key:${projectKey}`);
|
|
227
224
|
_forEachInstanceProperty__default["default"](oauthScopes).call(oauthScopes, scope => {
|
|
228
225
|
scopes.push(scope);
|
|
229
226
|
});
|
|
@@ -233,7 +230,7 @@ async function run(options) {
|
|
|
233
230
|
const authUrl = new _URL__default["default"]('/login/authorize', mcApiUrl);
|
|
234
231
|
authUrl.searchParams.set('response_type', 'id_token');
|
|
235
232
|
authUrl.searchParams.set('response_mode', 'query');
|
|
236
|
-
authUrl.searchParams.set('client_id',
|
|
233
|
+
authUrl.searchParams.set('client_id', `__local:${clientIdentifier}`);
|
|
237
234
|
authUrl.searchParams.set('scope', scopes.join(' '));
|
|
238
235
|
authUrl.searchParams.set('state', state);
|
|
239
236
|
authUrl.searchParams.set('nonce', nonce);
|
|
@@ -244,13 +241,13 @@ async function run(options) {
|
|
|
244
241
|
onSuccess: tokenContext => {
|
|
245
242
|
credentialsStorage.setToken(mcApiUrl, tokenContext);
|
|
246
243
|
console.log();
|
|
247
|
-
console.log(chalk__default["default"].green(
|
|
244
|
+
console.log(chalk__default["default"].green(`Login successful.`));
|
|
248
245
|
console.log();
|
|
249
246
|
}
|
|
250
247
|
});
|
|
251
248
|
await startServer(server);
|
|
252
|
-
console.log(
|
|
253
|
-
console.log(
|
|
249
|
+
console.log(`Initiating the OIDC authentication flow, opening the login page in your browser...`);
|
|
250
|
+
console.log(` ${authUrl}`);
|
|
254
251
|
console.log();
|
|
255
252
|
const open = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('open')); });
|
|
256
253
|
await open.default(authUrl.toString());
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _Promise = require('@babel/runtime-corejs3/core-js-stable/promise');
|
|
4
4
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
5
5
|
var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
|
|
6
|
-
var
|
|
6
|
+
var _bindInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/bind');
|
|
7
7
|
var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
|
|
8
8
|
var _flatMapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/flat-map');
|
|
9
9
|
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
@@ -12,11 +12,11 @@ var crypto = require('node:crypto');
|
|
|
12
12
|
var process = require('node:process');
|
|
13
13
|
var chalk = require('chalk');
|
|
14
14
|
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
15
|
-
var _package = require('./package-
|
|
15
|
+
var _package = require('./package-d8b1f4c0.cjs.dev.js');
|
|
16
16
|
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
17
17
|
var http = require('node:http');
|
|
18
18
|
var jwtDecode = require('jwt-decode');
|
|
19
|
-
var credentialsStorage$1 = require('./credentials-storage-
|
|
19
|
+
var credentialsStorage$1 = require('./credentials-storage-cbb5c559.cjs.dev.js');
|
|
20
20
|
require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
21
21
|
require('@babel/runtime-corejs3/helpers/createClass');
|
|
22
22
|
require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
@@ -49,7 +49,7 @@ function _interopNamespace(e) {
|
|
|
49
49
|
var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
|
|
50
50
|
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
51
51
|
var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
|
|
52
|
-
var
|
|
52
|
+
var _bindInstanceProperty__default = /*#__PURE__*/_interopDefault(_bindInstanceProperty);
|
|
53
53
|
var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
|
|
54
54
|
var _flatMapInstanceProperty__default = /*#__PURE__*/_interopDefault(_flatMapInstanceProperty);
|
|
55
55
|
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
@@ -64,8 +64,8 @@ var jwtDecode__default = /*#__PURE__*/_interopDefault(jwtDecode);
|
|
|
64
64
|
function createAuthCallbackServer(options) {
|
|
65
65
|
const server = http__default["default"].createServer(async (request, response) => {
|
|
66
66
|
try {
|
|
67
|
-
var
|
|
68
|
-
if ((
|
|
67
|
+
var _context, _context2;
|
|
68
|
+
if (((_context = request.url) == null ? void 0 : _bindInstanceProperty__default["default"](_context2 = Function.call).call(_context2, _includesInstanceProperty__default["default"](_context), _context))?.(`/${options.clientIdentifier}/oidc/callback`)) {
|
|
69
69
|
const incomingUrl = new _URL__default["default"](request.url, 'http://localhost');
|
|
70
70
|
const sessionToken = incomingUrl.searchParams.get('sessionToken');
|
|
71
71
|
const requestedState = incomingUrl.searchParams.get('state');
|
|
@@ -73,7 +73,7 @@ function createAuthCallbackServer(options) {
|
|
|
73
73
|
throw new Error('Invalid authentication flow (missing sessionToken)');
|
|
74
74
|
}
|
|
75
75
|
const decodedSessionToken = jwtDecode__default["default"](sessionToken);
|
|
76
|
-
if (
|
|
76
|
+
if (decodedSessionToken?.nonce !== options.nonce) {
|
|
77
77
|
throw new Error('Invalid authentication flow (nonce mismatch)');
|
|
78
78
|
}
|
|
79
79
|
if (requestedState !== options.state) {
|
|
@@ -96,7 +96,7 @@ function createAuthCallbackServer(options) {
|
|
|
96
96
|
response.end(error.message);
|
|
97
97
|
} else {
|
|
98
98
|
console.error(error);
|
|
99
|
-
response.end(
|
|
99
|
+
response.end(`Invalid authentication flow.`);
|
|
100
100
|
}
|
|
101
101
|
server.close(() => {
|
|
102
102
|
process.exit();
|
|
@@ -108,14 +108,14 @@ function createAuthCallbackServer(options) {
|
|
|
108
108
|
|
|
109
109
|
const credentialsStorage = new credentialsStorage$1.CredentialsStorage();
|
|
110
110
|
const port = 3001;
|
|
111
|
-
const clientIdentifier =
|
|
111
|
+
const clientIdentifier = `mc-scripts-${_package.pkgJson.version}`;
|
|
112
112
|
const isServerError = error => {
|
|
113
113
|
return error instanceof Error && 'code' in error;
|
|
114
114
|
};
|
|
115
115
|
const startServer = server => new _Promise__default["default"]((resolve, reject) => {
|
|
116
116
|
server.listen(port, 'localhost').on('listening', resolve).on('error', error => {
|
|
117
117
|
if (isServerError(error) && error.code === 'EADDRINUSE') {
|
|
118
|
-
return reject(new Error(
|
|
118
|
+
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.`, {
|
|
119
119
|
cause: error
|
|
120
120
|
}));
|
|
121
121
|
}
|
|
@@ -151,9 +151,8 @@ const resolveProjectKey = async options => {
|
|
|
151
151
|
return process__default["default"].env.CTP_PROJECT_KEY;
|
|
152
152
|
}
|
|
153
153
|
try {
|
|
154
|
-
var _applicationConfig$en;
|
|
155
154
|
const applicationConfig$1 = await applicationConfig.processConfig();
|
|
156
|
-
return
|
|
155
|
+
return applicationConfig$1.env.__DEVELOPMENT__?.oidc?.initialProjectKey;
|
|
157
156
|
} catch (error) {
|
|
158
157
|
// It's ok if there's not application config file or if it does not contain the initialProjectKey
|
|
159
158
|
return;
|
|
@@ -162,10 +161,10 @@ const resolveProjectKey = async options => {
|
|
|
162
161
|
const mapOAuthScopesToClaims = scopes => {
|
|
163
162
|
return _mapInstanceProperty__default["default"](scopes).call(scopes, scope => {
|
|
164
163
|
if (_startsWithInstanceProperty__default["default"](scope).call(scope, 'view_')) {
|
|
165
|
-
return
|
|
164
|
+
return `view:${scope}`;
|
|
166
165
|
}
|
|
167
166
|
if (_startsWithInstanceProperty__default["default"](scope).call(scope, 'manage_')) {
|
|
168
|
-
return
|
|
167
|
+
return `manage:${scope}`;
|
|
169
168
|
}
|
|
170
169
|
return scope;
|
|
171
170
|
});
|
|
@@ -173,12 +172,10 @@ const mapOAuthScopesToClaims = scopes => {
|
|
|
173
172
|
const mapAdditionalOAuthScopesToClaims = (name, scopes) => {
|
|
174
173
|
return _mapInstanceProperty__default["default"](scopes).call(scopes, scope => {
|
|
175
174
|
if (_startsWithInstanceProperty__default["default"](scope).call(scope, 'view_')) {
|
|
176
|
-
|
|
177
|
-
return _concatInstanceProperty__default["default"](_context = "view/".concat(name, ":")).call(_context, scope);
|
|
175
|
+
return `view/${name}:${scope}`;
|
|
178
176
|
}
|
|
179
177
|
if (_startsWithInstanceProperty__default["default"](scope).call(scope, 'manage_')) {
|
|
180
|
-
|
|
181
|
-
return _concatInstanceProperty__default["default"](_context2 = "manage/".concat(name, ":")).call(_context2, scope);
|
|
178
|
+
return `manage/${name}:${scope}`;
|
|
182
179
|
}
|
|
183
180
|
return scope;
|
|
184
181
|
});
|
|
@@ -190,15 +187,15 @@ const resolveOAuthScopes = async options => {
|
|
|
190
187
|
|
|
191
188
|
// We first check whether the user has set the CTP_OAUTH_SCOPES environment variable
|
|
192
189
|
if (process__default["default"].env.CTP_OAUTH_SCOPES) {
|
|
193
|
-
var
|
|
194
|
-
return mapOAuthScopesToClaims((
|
|
190
|
+
var _context, _context2;
|
|
191
|
+
return mapOAuthScopesToClaims(((_context = process__default["default"].env.CTP_OAUTH_SCOPES?.split(',')) == null ? void 0 : _bindInstanceProperty__default["default"](_context2 = Function.call).call(_context2, _mapInstanceProperty__default["default"](_context), _context))?.(scope => _trimInstanceProperty__default["default"](scope).call(scope)) ?? []);
|
|
195
192
|
}
|
|
196
193
|
try {
|
|
197
|
-
var
|
|
194
|
+
var _context3, _context4, _context5, _context6;
|
|
198
195
|
const applicationConfig$1 = await applicationConfig.processConfig();
|
|
199
|
-
const configuredOAuthScopes =
|
|
200
|
-
const configuredAdditionalOAuthScopes =
|
|
201
|
-
return [...mapOAuthScopesToClaims(
|
|
196
|
+
const configuredOAuthScopes = applicationConfig$1.env.__DEVELOPMENT__?.oidc?.oAuthScopes;
|
|
197
|
+
const configuredAdditionalOAuthScopes = applicationConfig$1.env.__DEVELOPMENT__?.oidc?.additionalOAuthScopes;
|
|
198
|
+
return [...mapOAuthScopesToClaims(configuredOAuthScopes?.view ?? []), ...mapOAuthScopesToClaims(configuredOAuthScopes?.manage ?? []), ...(((_context3 = configuredAdditionalOAuthScopes) == null ? void 0 : _bindInstanceProperty__default["default"](_context4 = Function.call).call(_context4, _flatMapInstanceProperty__default["default"](_context3), _context3))?.(scope => mapAdditionalOAuthScopesToClaims(scope.name, scope.view)) ?? []), ...(((_context5 = configuredAdditionalOAuthScopes) == null ? void 0 : _bindInstanceProperty__default["default"](_context6 = Function.call).call(_context6, _flatMapInstanceProperty__default["default"](_context5), _context5))?.(scope => mapAdditionalOAuthScopesToClaims(scope.name, scope.manage)) ?? [])];
|
|
202
199
|
} catch (error) {
|
|
203
200
|
// It's ok if there's not application config file or if it does not contain the initialProjectKey
|
|
204
201
|
return [];
|
|
@@ -213,17 +210,17 @@ async function run(options) {
|
|
|
213
210
|
if (!mcApiUrl) {
|
|
214
211
|
throw new Error('No Merchant Center API URL found. Aborting.');
|
|
215
212
|
}
|
|
216
|
-
console.log(
|
|
213
|
+
console.log(`Using Merchant Center environment "${chalk__default["default"].green(mcApiUrl)}".`);
|
|
217
214
|
console.log();
|
|
218
215
|
if (!options.force && credentialsStorage.isSessionValid(mcApiUrl)) {
|
|
219
|
-
console.log(
|
|
216
|
+
console.log(`You already have a valid session.`);
|
|
220
217
|
return;
|
|
221
218
|
}
|
|
222
219
|
const projectKey = await resolveProjectKey(options);
|
|
223
220
|
const oauthScopes = await resolveOAuthScopes(options);
|
|
224
221
|
const scopes = ['openid'];
|
|
225
222
|
if (projectKey) {
|
|
226
|
-
scopes.push(
|
|
223
|
+
scopes.push(`project_key:${projectKey}`);
|
|
227
224
|
_forEachInstanceProperty__default["default"](oauthScopes).call(oauthScopes, scope => {
|
|
228
225
|
scopes.push(scope);
|
|
229
226
|
});
|
|
@@ -233,7 +230,7 @@ async function run(options) {
|
|
|
233
230
|
const authUrl = new _URL__default["default"]('/login/authorize', mcApiUrl);
|
|
234
231
|
authUrl.searchParams.set('response_type', 'id_token');
|
|
235
232
|
authUrl.searchParams.set('response_mode', 'query');
|
|
236
|
-
authUrl.searchParams.set('client_id',
|
|
233
|
+
authUrl.searchParams.set('client_id', `__local:${clientIdentifier}`);
|
|
237
234
|
authUrl.searchParams.set('scope', scopes.join(' '));
|
|
238
235
|
authUrl.searchParams.set('state', state);
|
|
239
236
|
authUrl.searchParams.set('nonce', nonce);
|
|
@@ -244,13 +241,13 @@ async function run(options) {
|
|
|
244
241
|
onSuccess: tokenContext => {
|
|
245
242
|
credentialsStorage.setToken(mcApiUrl, tokenContext);
|
|
246
243
|
console.log();
|
|
247
|
-
console.log(chalk__default["default"].green(
|
|
244
|
+
console.log(chalk__default["default"].green(`Login successful.`));
|
|
248
245
|
console.log();
|
|
249
246
|
}
|
|
250
247
|
});
|
|
251
248
|
await startServer(server);
|
|
252
|
-
console.log(
|
|
253
|
-
console.log(
|
|
249
|
+
console.log(`Initiating the OIDC authentication flow, opening the login page in your browser...`);
|
|
250
|
+
console.log(` ${authUrl}`);
|
|
254
251
|
console.log();
|
|
255
252
|
const open = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('open')); });
|
|
256
253
|
await open.default(authUrl.toString());
|
|
@@ -6,7 +6,6 @@ var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/ins
|
|
|
6
6
|
var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
|
|
7
7
|
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
8
8
|
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
9
|
-
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
10
9
|
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
11
10
|
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
12
11
|
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
@@ -22,7 +21,6 @@ var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInsta
|
|
|
22
21
|
var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
|
|
23
22
|
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
24
23
|
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
25
|
-
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
26
24
|
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
27
25
|
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
28
26
|
var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
|
|
@@ -33,7 +31,7 @@ var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defin
|
|
|
33
31
|
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
34
32
|
|
|
35
33
|
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
36
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
34
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
37
35
|
|
|
38
36
|
// Dependencies to be split/grouped into separate chunks.
|
|
39
37
|
// This is useful to reduce the main bundle size and have more
|
|
@@ -53,8 +51,7 @@ const removeNonExistantDependencies = (manualChunks, appDependencies) => {
|
|
|
53
51
|
if (existingVendors.length > 0) {
|
|
54
52
|
chunkGroups[chunkName] = existingVendors;
|
|
55
53
|
} else {
|
|
56
|
-
|
|
57
|
-
console.log(chalk__default["default"].yellow(_concatInstanceProperty__default["default"](_context2 = "\nFiltering out chunk \"".concat(chunkName, "\" because its configured dependencies does not exist in the application: ")).call(_context2, vendors, "\n")));
|
|
54
|
+
console.log(chalk__default["default"].yellow(`\nFiltering out chunk "${chunkName}" because its configured dependencies does not exist in the application: ${vendors}\n`));
|
|
58
55
|
}
|
|
59
56
|
return chunkGroups;
|
|
60
57
|
}, {});
|
|
@@ -67,15 +64,15 @@ function getViteCacheGroups(appDependencies) {
|
|
|
67
64
|
|
|
68
65
|
// Reference: https://webpack.js.org/plugins/split-chunks-plugin/
|
|
69
66
|
function getWepbackCacheGroups(appDependencies) {
|
|
70
|
-
var
|
|
67
|
+
var _context2;
|
|
71
68
|
const filteredDependencies = removeNonExistantDependencies(manualChunks, _Object$keys__default["default"](appDependencies));
|
|
72
|
-
const result = _reduceInstanceProperty__default["default"](
|
|
69
|
+
const result = _reduceInstanceProperty__default["default"](_context2 = _Object$entries__default["default"](filteredDependencies)).call(_context2, (previousChunks, _ref3) => {
|
|
73
70
|
let _ref4 = _slicedToArray(_ref3, 2),
|
|
74
71
|
chunkName = _ref4[0],
|
|
75
72
|
vendors = _ref4[1];
|
|
76
73
|
return _objectSpread(_objectSpread({}, previousChunks), {}, {
|
|
77
74
|
[chunkName]: {
|
|
78
|
-
test: new RegExp(
|
|
75
|
+
test: new RegExp(`[\\/]node_modules[\\/](${vendors.join('|')})[\\/]`),
|
|
79
76
|
name: chunkName,
|
|
80
77
|
chunks: 'all'
|
|
81
78
|
}
|
|
@@ -4,7 +4,6 @@ import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/insta
|
|
|
4
4
|
import _Object$entries from '@babel/runtime-corejs3/core-js-stable/object/entries';
|
|
5
5
|
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
6
6
|
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
7
|
-
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
8
7
|
import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
9
8
|
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
|
|
10
9
|
import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
|
|
@@ -15,7 +14,7 @@ import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object
|
|
|
15
14
|
import chalk from 'chalk';
|
|
16
15
|
|
|
17
16
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
18
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
17
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
19
18
|
|
|
20
19
|
// Dependencies to be split/grouped into separate chunks.
|
|
21
20
|
// This is useful to reduce the main bundle size and have more
|
|
@@ -35,8 +34,7 @@ const removeNonExistantDependencies = (manualChunks, appDependencies) => {
|
|
|
35
34
|
if (existingVendors.length > 0) {
|
|
36
35
|
chunkGroups[chunkName] = existingVendors;
|
|
37
36
|
} else {
|
|
38
|
-
|
|
39
|
-
console.log(chalk.yellow(_concatInstanceProperty(_context2 = "\nFiltering out chunk \"".concat(chunkName, "\" because its configured dependencies does not exist in the application: ")).call(_context2, vendors, "\n")));
|
|
37
|
+
console.log(chalk.yellow(`\nFiltering out chunk "${chunkName}" because its configured dependencies does not exist in the application: ${vendors}\n`));
|
|
40
38
|
}
|
|
41
39
|
return chunkGroups;
|
|
42
40
|
}, {});
|
|
@@ -49,15 +47,15 @@ function getViteCacheGroups(appDependencies) {
|
|
|
49
47
|
|
|
50
48
|
// Reference: https://webpack.js.org/plugins/split-chunks-plugin/
|
|
51
49
|
function getWepbackCacheGroups(appDependencies) {
|
|
52
|
-
var
|
|
50
|
+
var _context2;
|
|
53
51
|
const filteredDependencies = removeNonExistantDependencies(manualChunks, _Object$keys(appDependencies));
|
|
54
|
-
const result = _reduceInstanceProperty(
|
|
52
|
+
const result = _reduceInstanceProperty(_context2 = _Object$entries(filteredDependencies)).call(_context2, (previousChunks, _ref3) => {
|
|
55
53
|
let _ref4 = _slicedToArray(_ref3, 2),
|
|
56
54
|
chunkName = _ref4[0],
|
|
57
55
|
vendors = _ref4[1];
|
|
58
56
|
return _objectSpread(_objectSpread({}, previousChunks), {}, {
|
|
59
57
|
[chunkName]: {
|
|
60
|
-
test: new RegExp(
|
|
58
|
+
test: new RegExp(`[\\/]node_modules[\\/](${vendors.join('|')})[\\/]`),
|
|
61
59
|
name: chunkName,
|
|
62
60
|
chunks: 'all'
|
|
63
61
|
}
|
|
@@ -6,7 +6,6 @@ var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/ins
|
|
|
6
6
|
var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
|
|
7
7
|
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
8
8
|
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
9
|
-
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
10
9
|
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
11
10
|
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
12
11
|
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
@@ -22,7 +21,6 @@ var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInsta
|
|
|
22
21
|
var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
|
|
23
22
|
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
24
23
|
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
25
|
-
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
26
24
|
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
27
25
|
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
28
26
|
var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
|
|
@@ -33,7 +31,7 @@ var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defin
|
|
|
33
31
|
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
34
32
|
|
|
35
33
|
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
36
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
34
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
37
35
|
|
|
38
36
|
// Dependencies to be split/grouped into separate chunks.
|
|
39
37
|
// This is useful to reduce the main bundle size and have more
|
|
@@ -53,8 +51,7 @@ const removeNonExistantDependencies = (manualChunks, appDependencies) => {
|
|
|
53
51
|
if (existingVendors.length > 0) {
|
|
54
52
|
chunkGroups[chunkName] = existingVendors;
|
|
55
53
|
} else {
|
|
56
|
-
|
|
57
|
-
console.log(chalk__default["default"].yellow(_concatInstanceProperty__default["default"](_context2 = "\nFiltering out chunk \"".concat(chunkName, "\" because its configured dependencies does not exist in the application: ")).call(_context2, vendors, "\n")));
|
|
54
|
+
console.log(chalk__default["default"].yellow(`\nFiltering out chunk "${chunkName}" because its configured dependencies does not exist in the application: ${vendors}\n`));
|
|
58
55
|
}
|
|
59
56
|
return chunkGroups;
|
|
60
57
|
}, {});
|
|
@@ -67,15 +64,15 @@ function getViteCacheGroups(appDependencies) {
|
|
|
67
64
|
|
|
68
65
|
// Reference: https://webpack.js.org/plugins/split-chunks-plugin/
|
|
69
66
|
function getWepbackCacheGroups(appDependencies) {
|
|
70
|
-
var
|
|
67
|
+
var _context2;
|
|
71
68
|
const filteredDependencies = removeNonExistantDependencies(manualChunks, _Object$keys__default["default"](appDependencies));
|
|
72
|
-
const result = _reduceInstanceProperty__default["default"](
|
|
69
|
+
const result = _reduceInstanceProperty__default["default"](_context2 = _Object$entries__default["default"](filteredDependencies)).call(_context2, (previousChunks, _ref3) => {
|
|
73
70
|
let _ref4 = _slicedToArray(_ref3, 2),
|
|
74
71
|
chunkName = _ref4[0],
|
|
75
72
|
vendors = _ref4[1];
|
|
76
73
|
return _objectSpread(_objectSpread({}, previousChunks), {}, {
|
|
77
74
|
[chunkName]: {
|
|
78
|
-
test: new RegExp(
|
|
75
|
+
test: new RegExp(`[\\/]node_modules[\\/](${vendors.join('|')})[\\/]`),
|
|
79
76
|
name: chunkName,
|
|
80
77
|
chunks: 'all'
|
|
81
78
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var pkgJson = {
|
|
2
2
|
name: "@commercetools-frontend/mc-scripts",
|
|
3
|
-
version: "
|
|
3
|
+
version: "25.1.0",
|
|
4
4
|
description: "Configuration and scripts for developing a MC application",
|
|
5
5
|
bugs: "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
6
6
|
repository: {
|
|
@@ -61,13 +61,13 @@ var pkgJson = {
|
|
|
61
61
|
"@babel/plugin-proposal-do-expressions": "^7.22.5",
|
|
62
62
|
"@babel/runtime": "^7.22.15",
|
|
63
63
|
"@babel/runtime-corejs3": "^7.22.15",
|
|
64
|
-
"@commercetools-frontend/application-components": "
|
|
65
|
-
"@commercetools-frontend/application-config": "
|
|
66
|
-
"@commercetools-frontend/assets": "
|
|
67
|
-
"@commercetools-frontend/babel-preset-mc-app": "
|
|
68
|
-
"@commercetools-frontend/constants": "
|
|
69
|
-
"@commercetools-frontend/mc-dev-authentication": "
|
|
70
|
-
"@commercetools-frontend/mc-html-template": "
|
|
64
|
+
"@commercetools-frontend/application-components": "25.1.0",
|
|
65
|
+
"@commercetools-frontend/application-config": "25.1.0",
|
|
66
|
+
"@commercetools-frontend/assets": "25.1.0",
|
|
67
|
+
"@commercetools-frontend/babel-preset-mc-app": "25.1.0",
|
|
68
|
+
"@commercetools-frontend/constants": "25.1.0",
|
|
69
|
+
"@commercetools-frontend/mc-dev-authentication": "25.1.0",
|
|
70
|
+
"@commercetools-frontend/mc-html-template": "25.1.0",
|
|
71
71
|
"@commercetools/http-user-agent": "3.0.0",
|
|
72
72
|
"@emotion/babel-plugin": "^11.13.5",
|
|
73
73
|
"@formatjs/cli-lib": "^6.3.8",
|
|
@@ -85,7 +85,7 @@ var pkgJson = {
|
|
|
85
85
|
autoprefixer: "^10.4.15",
|
|
86
86
|
"babel-loader": "8.4.1",
|
|
87
87
|
"babel-plugin-formatjs": "^10.5.25",
|
|
88
|
-
browserslist: "^4.
|
|
88
|
+
browserslist: "^4.28.1",
|
|
89
89
|
chalk: "4.1.2",
|
|
90
90
|
commander: "^13.1.0",
|
|
91
91
|
"core-js": "^3.32.2",
|
|
@@ -139,14 +139,12 @@ var pkgJson = {
|
|
|
139
139
|
"@tsconfig/node22": "^22.0.0",
|
|
140
140
|
"@types/fs-extra": "^11.0.1",
|
|
141
141
|
"@types/lodash": "^4.14.198",
|
|
142
|
-
"@types/mock-fs": "^4.13.4",
|
|
143
142
|
"@types/moment-locales-webpack-plugin": "^1.2.3",
|
|
144
143
|
"@types/node-fetch": "2.6.13",
|
|
145
144
|
"@types/prettier": "2.7.3",
|
|
146
145
|
"@types/serve-handler": "^6.1.1",
|
|
147
146
|
"jest-mock": "29.7.0",
|
|
148
147
|
memfs: "^4.8.2",
|
|
149
|
-
"mock-fs": "^5.4.1",
|
|
150
148
|
msw: "^1.3.5",
|
|
151
149
|
rimraf: "6.0.1"
|
|
152
150
|
},
|