@commercetools-frontend/mc-scripts 24.10.0 → 24.12.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.
Files changed (76) hide show
  1. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.dev.js +1 -1
  2. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js +1 -1
  3. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.esm.js +1 -1
  4. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +13 -14
  5. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +13 -14
  6. package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +13 -14
  7. package/dist/{build-c91d680c.esm.js → build-1c7d82ef.esm.js} +7 -7
  8. package/dist/{build-bd986bac.cjs.dev.js → build-895fb1d2.cjs.dev.js} +7 -7
  9. package/dist/{build-9c26fe58.cjs.prod.js → build-be24f6d9.cjs.prod.js} +7 -7
  10. package/dist/{build-vite-5d317720.cjs.prod.js → build-vite-4a6c90c2.cjs.prod.js} +9 -8
  11. package/dist/{build-vite-59e1f185.esm.js → build-vite-85211835.esm.js} +9 -8
  12. package/dist/{build-vite-16b1a575.cjs.dev.js → build-vite-e26f6c9f.cjs.dev.js} +9 -8
  13. package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +1 -1
  14. package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +1 -1
  15. package/dist/commercetools-frontend-mc-scripts.esm.js +1 -1
  16. package/dist/{compile-html-f4ac88cc.cjs.dev.js → compile-html-8679f721.cjs.dev.js} +5 -2
  17. package/dist/{compile-html-025cd493.esm.js → compile-html-adfef598.esm.js} +4 -2
  18. package/dist/{compile-html-50fd05ec.cjs.prod.js → compile-html-b80f9651.cjs.prod.js} +5 -2
  19. package/dist/{config-sync-d57260cc.esm.js → config-sync-78ccf97c.esm.js} +79 -69
  20. package/dist/{config-sync-200c5df5.cjs.prod.js → config-sync-e32e3fa6.cjs.prod.js} +78 -67
  21. package/dist/{config-sync-6977827c.cjs.dev.js → config-sync-ffddb604.cjs.dev.js} +80 -69
  22. package/dist/{create-postcss-config-fe3387fa.cjs.prod.js → create-postcss-config-2d574316.cjs.prod.js} +1 -1
  23. package/dist/{create-postcss-config-152ced99.esm.js → create-postcss-config-3887c44a.esm.js} +1 -1
  24. package/dist/{create-postcss-config-fd3dee79.cjs.dev.js → create-postcss-config-a47547b4.cjs.dev.js} +1 -1
  25. package/dist/{create-webpack-config-for-development-527a632e.cjs.prod.js → create-webpack-config-for-development-03c59e8e.cjs.prod.js} +9 -7
  26. package/dist/{create-webpack-config-for-development-48e5e9d0.esm.js → create-webpack-config-for-development-2c20b570.esm.js} +9 -7
  27. package/dist/{create-webpack-config-for-development-049a78d6.cjs.dev.js → create-webpack-config-for-development-99b8871e.cjs.dev.js} +9 -7
  28. package/dist/{create-webpack-config-for-production-9452f0ea.cjs.dev.js → create-webpack-config-for-production-28456828.cjs.dev.js} +7 -7
  29. package/dist/{create-webpack-config-for-production-5ef997a2.cjs.prod.js → create-webpack-config-for-production-59e18392.cjs.prod.js} +7 -7
  30. package/dist/{create-webpack-config-for-production-991b35ad.esm.js → create-webpack-config-for-production-94bc1e6d.esm.js} +7 -7
  31. package/dist/{credentials-storage-0b89aa0e.cjs.prod.js → credentials-storage-381abf27.cjs.prod.js} +1 -1
  32. package/dist/{credentials-storage-4464313c.esm.js → credentials-storage-7285d7b4.esm.js} +1 -1
  33. package/dist/{credentials-storage-cbb5c559.cjs.dev.js → credentials-storage-de220814.cjs.dev.js} +1 -1
  34. package/dist/{deployment-previews-set-93927f50.cjs.prod.js → deployment-previews-set-117c5626.cjs.prod.js} +28 -22
  35. package/dist/{deployment-previews-set-b9ebe08f.cjs.dev.js → deployment-previews-set-1e263b53.cjs.dev.js} +28 -22
  36. package/dist/{deployment-previews-set-178cacbc.esm.js → deployment-previews-set-a243363b.esm.js} +27 -22
  37. package/dist/{graphql-requests-6043a20b.esm.js → graphql-requests-54b9815d.esm.js} +8 -5
  38. package/dist/{graphql-requests-c5ecf40e.cjs.prod.js → graphql-requests-b4c8c047.cjs.dev.js} +8 -5
  39. package/dist/{graphql-requests-5527b635.cjs.dev.js → graphql-requests-b89caeb1.cjs.prod.js} +8 -5
  40. package/dist/{i18n-message-complilation-7311cb29.cjs.dev.js → i18n-message-complilation-393d344a.cjs.prod.js} +1 -1
  41. package/dist/{i18n-message-complilation-7762da61.cjs.prod.js → i18n-message-complilation-3f80e8d6.cjs.dev.js} +1 -1
  42. package/dist/{i18n-message-complilation-21d3b0aa.esm.js → i18n-message-complilation-8aec9d1b.esm.js} +1 -1
  43. package/dist/{login-2c875e0b.esm.js → login-0223db92.esm.js} +32 -23
  44. package/dist/{login-d7cb2619.cjs.dev.js → login-935abd52.cjs.dev.js} +35 -23
  45. package/dist/{login-73e9f04f.cjs.prod.js → login-bf7607cf.cjs.prod.js} +35 -23
  46. package/dist/{optimizations-fb93514f.cjs.prod.js → optimizations-ea21b802.cjs.prod.js} +8 -5
  47. package/dist/{optimizations-bf991634.esm.js → optimizations-ea71a24a.esm.js} +7 -5
  48. package/dist/{optimizations-7789145e.cjs.dev.js → optimizations-ebbeaf88.cjs.dev.js} +8 -5
  49. package/dist/{package-6a5c0475.esm.js → package-31f38f64.esm.js} +10 -10
  50. package/dist/{package-0d7eef40.cjs.dev.js → package-ad6a5026.cjs.prod.js} +10 -10
  51. package/dist/{package-c32ced1c.cjs.prod.js → package-dc76e3fe.cjs.dev.js} +10 -10
  52. package/dist/{paths-39f22b8b.esm.js → paths-7bf7e88e.esm.js} +9 -4
  53. package/dist/{paths-7768b440.cjs.prod.js → paths-af1a725a.cjs.prod.js} +10 -4
  54. package/dist/{paths-b76fc753.cjs.dev.js → paths-ec3e3a7d.cjs.dev.js} +10 -4
  55. package/dist/{serve-50d33f0b.cjs.dev.js → serve-04a03d5f.cjs.dev.js} +6 -4
  56. package/dist/{serve-8a506da6.cjs.prod.js → serve-2a863026.cjs.prod.js} +6 -4
  57. package/dist/{serve-1036c2de.esm.js → serve-fb1a0f5a.esm.js} +6 -4
  58. package/dist/{start-296a8335.cjs.prod.js → start-3a301547.cjs.prod.js} +9 -8
  59. package/dist/{start-f7aed0ed.esm.js → start-57d1d14c.esm.js} +9 -8
  60. package/dist/{start-66ec8479.cjs.dev.js → start-7e607d2a.cjs.dev.js} +9 -8
  61. package/dist/{start-vite-29078b3a.cjs.prod.js → start-vite-d548c121.cjs.prod.js} +4 -3
  62. package/dist/{start-vite-7d1161e8.esm.js → start-vite-d649d1f3.esm.js} +4 -3
  63. package/dist/{start-vite-068e9f73.cjs.dev.js → start-vite-eea72ba9.cjs.dev.js} +4 -3
  64. package/dist/{vite-plugin-svgr-de6ee7da.esm.js → vite-plugin-svgr-22c8d518.esm.js} +4 -4
  65. package/dist/{vite-plugin-svgr-4034a834.cjs.prod.js → vite-plugin-svgr-53ef97c7.cjs.dev.js} +4 -4
  66. package/dist/{vite-plugin-svgr-7d06f400.cjs.dev.js → vite-plugin-svgr-5de1cad9.cjs.prod.js} +4 -4
  67. package/package.json +10 -10
  68. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +2 -2
  69. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +2 -2
  70. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +2 -2
  71. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +6 -6
  72. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +6 -6
  73. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +6 -6
  74. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.dev.js +1 -1
  75. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.prod.js +1 -1
  76. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.esm.js +1 -1
@@ -1,12 +1,13 @@
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';
3
4
  import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
4
5
  import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
5
6
  import chalk from 'chalk';
6
7
  import prompts from 'prompts';
7
8
  import { processConfig } from '@commercetools-frontend/application-config';
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-6043a20b.esm.js';
9
+ import { C as CredentialsStorage } from './credentials-storage-7285d7b4.esm.js';
10
+ import { f as fetchCustomApplication, g as updateCustomApplicationDeploymentPreview, h as createCustomApplicationDeploymentPreview } from './graphql-requests-54b9815d.esm.js';
10
11
  import '@babel/runtime-corejs3/helpers/classCallCheck';
11
12
  import '@babel/runtime-corejs3/helpers/createClass';
12
13
  import '@babel/runtime-corejs3/core-js-stable/json/stringify';
@@ -28,7 +29,7 @@ import 'graphql';
28
29
  import 'graphql-request';
29
30
  import '@commercetools-frontend/constants';
30
31
  import '@commercetools/http-user-agent';
31
- import './package-6a5c0475.esm.js';
32
+ import './package-31f38f64.esm.js';
32
33
 
33
34
  const credentialsStorage = new CredentialsStorage();
34
35
  const validateUrl = function () {
@@ -44,24 +45,25 @@ const validateUrl = function () {
44
45
  const validateAlias = function () {
45
46
  let alias = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
46
47
  try {
47
- new _URL(`https://${alias}.commercetools.com/`);
48
+ new _URL("https://".concat(alias, ".commercetools.com/"));
48
49
  return true;
49
50
  } catch (error) {
50
51
  return false;
51
52
  }
52
53
  };
53
54
  const getMcUrlLink = _ref => {
55
+ var _context2, _context3, _context4;
54
56
  let mcApiUrl = _ref.mcApiUrl,
55
57
  organizationId = _ref.organizationId,
56
58
  customEntityId = _ref.customEntityId,
57
59
  isCustomView = _ref.isCustomView;
58
60
  const mcUrl = mcApiUrl.replace('mc-api', 'mc');
59
- const customEntityLink = `${mcUrl}/account/organizations/${organizationId}/custom-${isCustomView ? 'views' : 'applications'}/owned/${customEntityId}/deployment-previews`;
61
+ const customEntityLink = _concatInstanceProperty(_context2 = _concatInstanceProperty(_context3 = _concatInstanceProperty(_context4 = "".concat(mcUrl, "/account/organizations/")).call(_context4, organizationId, "/custom-")).call(_context3, isCustomView ? 'views' : 'applications', "/owned/")).call(_context2, customEntityId, "/deployment-previews");
60
62
  return customEntityLink;
61
63
  };
62
64
  const isCustomViewData = data => data.entryPointUriPath === undefined;
63
65
  async function setDeploymentPreview(_ref2) {
64
- var _context3;
66
+ var _context6;
65
67
  let mcApiUrl = _ref2.mcApiUrl,
66
68
  applicationId = _ref2.applicationId,
67
69
  applicationIdentifier = _ref2.applicationIdentifier,
@@ -82,28 +84,28 @@ async function setDeploymentPreview(_ref2) {
82
84
  applicationIdentifier
83
85
  });
84
86
  if (!fetchedCustomApplication) {
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.`);
87
+ throw new Error("The Custom Application \"".concat(applicationIdentifier, "\" does not exist in the Merchant Center. Please create a Custom Application first before configuring deployment previews."));
86
88
  }
87
89
  let deploymentAlias = options.alias;
88
90
  // If the alias was not provided as an argument to the script, let's ask for it.
89
91
  if (!deploymentAlias) {
90
- var _context2;
92
+ var _context5;
91
93
  const _await$prompts = await prompts({
92
94
  type: 'text',
93
95
  name: 'alias',
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'),
96
+ message: _filterInstanceProperty(_context5 = ["Enter the alias for the deployment preview", options.dryRun && chalk.gray('Using "--dry-run", no deployment preview will be created.')]).call(_context5, Boolean).join('\n'),
95
97
  validate: value => validateAlias(value)
96
98
  }),
97
99
  alias = _await$prompts.alias;
98
100
  deploymentAlias = alias;
99
101
  }
100
- const existingDeploymentPreview = _findInstanceProperty(_context3 = fetchedCustomApplication.application.deployments).call(_context3, deployment => deployment.alias === deploymentAlias);
102
+ const existingDeploymentPreview = _findInstanceProperty(_context6 = fetchedCustomApplication.application.deployments).call(_context6, deployment => deployment.alias === deploymentAlias);
101
103
  if (!options.alias && !options.url && existingDeploymentPreview) {
102
- var _context4;
104
+ var _context7;
103
105
  const _await$prompts2 = await prompts({
104
106
  type: 'confirm',
105
107
  name: 'aliasOverrideConfirmation',
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'),
108
+ message: _filterInstanceProperty(_context7 = ["The alias \"".concat(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(_context7, Boolean).join('\n'),
107
109
  initial: false
108
110
  }),
109
111
  aliasOverrideConfirmation = _await$prompts2.aliasOverrideConfirmation;
@@ -114,19 +116,20 @@ async function setDeploymentPreview(_ref2) {
114
116
  }
115
117
  let deploymentUrl = options.url;
116
118
  if (!deploymentUrl) {
117
- var _context5;
119
+ var _context8;
118
120
  const _await$prompts3 = await prompts({
119
121
  type: 'text',
120
122
  name: 'url',
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'),
123
+ message: _filterInstanceProperty(_context8 = ["Enter the URL for the deployment preview", options.dryRun && chalk.gray('Using "--dry-run", no deployment preview will be created.')]).call(_context8, Boolean).join('\n'),
122
124
  validate: value => validateUrl(value)
123
125
  }),
124
126
  url = _await$prompts3.url;
125
127
  deploymentUrl = url;
126
128
  }
127
129
  if (options.dryRun) {
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`);
130
+ var _context9, _context0;
131
+ const message = existingDeploymentPreview ? _concatInstanceProperty(_context9 = "The existing deployment preview with alias \"".concat(deploymentAlias, "\" would have been updated with this url: \"")).call(_context9, deploymentUrl, "\".") : _concatInstanceProperty(_context0 = "A new deployment preview with alias \"".concat(deploymentAlias, "\" would have been created with this url: \"")).call(_context0, deploymentUrl, "\".");
132
+ console.log("\n".concat(message, "\n"));
130
133
  return;
131
134
  }
132
135
  const mcDeploymentPreviewsLink = getMcUrlLink({
@@ -136,6 +139,7 @@ async function setDeploymentPreview(_ref2) {
136
139
  isCustomView
137
140
  });
138
141
  if (existingDeploymentPreview) {
142
+ var _context1;
139
143
  await updateCustomApplicationDeploymentPreview({
140
144
  mcApiUrl,
141
145
  organizationId: fetchedCustomApplication.organizationId,
@@ -145,9 +149,10 @@ async function setDeploymentPreview(_ref2) {
145
149
  url: deploymentUrl
146
150
  }
147
151
  });
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}`));
152
+ console.log(chalk.green(_concatInstanceProperty(_context1 = "Deployment preview with alias \"".concat(deploymentAlias, "\" updated successfully with URL \"")).call(_context1, deploymentUrl, "\".")));
153
+ console.log(chalk.green("You can access the deployment previews at: ".concat(mcDeploymentPreviewsLink)));
150
154
  } else {
155
+ var _context10;
151
156
  await createCustomApplicationDeploymentPreview({
152
157
  mcApiUrl,
153
158
  organizationId: fetchedCustomApplication.organizationId,
@@ -158,8 +163,8 @@ async function setDeploymentPreview(_ref2) {
158
163
  url: deploymentUrl
159
164
  }
160
165
  });
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}`));
166
+ console.log(chalk.green(_concatInstanceProperty(_context10 = "Deployment preview with alias \"".concat(deploymentAlias, "\" created successfully with URL \"")).call(_context10, deploymentUrl, "\".")));
167
+ console.log(chalk.green("You can access the deployment previews at: ".concat(mcDeploymentPreviewsLink)));
163
168
  }
164
169
  }
165
170
  async function run(options) {
@@ -169,11 +174,11 @@ async function run(options) {
169
174
  mcApiUrl = _applicationConfig$en.mcApiUrl,
170
175
  applicationIdentifier = _applicationConfig$en.applicationIdentifier;
171
176
  const isCustomView = isCustomViewData(localCustomEntityData);
172
- console.log(`Using Merchant Center environment "${chalk.green(mcApiUrl)}".`);
177
+ console.log("Using Merchant Center environment \"".concat(chalk.green(mcApiUrl), "\"."));
173
178
  console.log();
174
179
  const isSessionValid = credentialsStorage.isSessionValid(mcApiUrl);
175
180
  if (!isSessionValid) {
176
- throw new Error(`You don't have a valid session. Please, run the "mc-scripts login" command to authenticate yourself.`);
181
+ throw new Error("You don't have a valid session. Please, run the \"mc-scripts login\" command to authenticate yourself.");
177
182
  }
178
183
  if (isCustomView) {
179
184
  throw new Error('Deployments previews are not supported for Custom Views.');
@@ -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-4464313c.esm.js';
15
+ import { C as CredentialsStorage } from './credentials-storage-7285d7b4.esm.js';
16
16
  import createHttpUserAgent from '@commercetools/http-user-agent';
17
- import { p as pkgJson } from './package-6a5c0475.esm.js';
17
+ import { p as pkgJson } from './package-31f38f64.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]: `Bearer ${token}`
44
+ [SUPPORTED_HEADERS.AUTHORIZATION]: "Bearer ".concat(token)
45
45
  };
46
- const client = new GraphQLClient(`${requestOptions.mcApiUrl}/graphql`, {
46
+ const client = new GraphQLClient("".concat(requestOptions.mcApiUrl, "/graphql"), {
47
47
  headers: _objectSpread(_objectSpread({
48
48
  Accept: 'application/json',
49
49
  'Content-Type': 'application/json',
@@ -71,7 +71,10 @@ 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 => graphqlError.extensions?.code === 'UNAUTHENTICATED');
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
+ });
75
78
  if (isUnauthorizedError) {
76
79
  console.log(chalk.yellow('Expired or invalid session token, attempting to retry the request with a refreshed token...'));
77
80
  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-0b89aa0e.cjs.prod.js');
17
+ var credentialsStorage$1 = require('./credentials-storage-de220814.cjs.dev.js');
18
18
  var createHttpUserAgent = require('@commercetools/http-user-agent');
19
- var _package = require('./package-c32ced1c.cjs.prod.js');
19
+ var _package = require('./package-dc76e3fe.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]: `Bearer ${token}`
60
+ [constants.SUPPORTED_HEADERS.AUTHORIZATION]: "Bearer ".concat(token)
61
61
  };
62
- const client = new graphqlRequest.GraphQLClient(`${requestOptions.mcApiUrl}/graphql`, {
62
+ const client = new graphqlRequest.GraphQLClient("".concat(requestOptions.mcApiUrl, "/graphql"), {
63
63
  headers: _objectSpread(_objectSpread({
64
64
  Accept: 'application/json',
65
65
  'Content-Type': 'application/json',
@@ -87,7 +87,10 @@ 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 => graphqlError.extensions?.code === 'UNAUTHENTICATED');
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
+ });
91
94
  if (isUnauthorizedError) {
92
95
  console.log(chalk__default["default"].yellow('Expired or invalid session token, attempting to retry the request with a refreshed token...'));
93
96
  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-cbb5c559.cjs.dev.js');
17
+ var credentialsStorage$1 = require('./credentials-storage-381abf27.cjs.prod.js');
18
18
  var createHttpUserAgent = require('@commercetools/http-user-agent');
19
- var _package = require('./package-0d7eef40.cjs.dev.js');
19
+ var _package = require('./package-ad6a5026.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]: `Bearer ${token}`
60
+ [constants.SUPPORTED_HEADERS.AUTHORIZATION]: "Bearer ".concat(token)
61
61
  };
62
- const client = new graphqlRequest.GraphQLClient(`${requestOptions.mcApiUrl}/graphql`, {
62
+ const client = new graphqlRequest.GraphQLClient("".concat(requestOptions.mcApiUrl, "/graphql"), {
63
63
  headers: _objectSpread(_objectSpread({
64
64
  Accept: 'application/json',
65
65
  'Content-Type': 'application/json',
@@ -87,7 +87,10 @@ 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 => graphqlError.extensions?.code === 'UNAUTHENTICATED');
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
+ });
91
94
  if (isUnauthorizedError) {
92
95
  console.log(chalk__default["default"].yellow('Expired or invalid session token, attempting to retry the request with a refreshed token...'));
93
96
  return requestWithTokenRetry(document, _objectSpread(_objectSpread({}, requestOptions), {}, {
@@ -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(`[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}` : ''}`));
18
+ warnFunction(new Error("[i18n message compilation] Message compilation on ".concat(fileIdentifier, " has failed.\n") + "Consider setting the environmental variable ".concat(chalk__default["default"].yellow('DISABLE_I18N_MESSAGE_COMPILATION'), " to true to disable the message loader or resolve the issues on the messages file.\n") + "".concat(error instanceof Error ? "Error: ".concat(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(`[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}` : ''}`));
18
+ warnFunction(new Error("[i18n message compilation] Message compilation on ".concat(fileIdentifier, " has failed.\n") + "Consider setting the environmental variable ".concat(chalk__default["default"].yellow('DISABLE_I18N_MESSAGE_COMPILATION'), " to true to disable the message loader or resolve the issues on the messages file.\n") + "".concat(error instanceof Error ? "Error: ".concat(error.message) : '')));
19
19
  }
20
20
  }
21
21
 
@@ -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(`[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}` : ''}`));
11
+ warnFunction(new Error("[i18n message compilation] Message compilation on ".concat(fileIdentifier, " has failed.\n") + "Consider setting the environmental variable ".concat(chalk.yellow('DISABLE_I18N_MESSAGE_COMPILATION'), " to true to disable the message loader or resolve the issues on the messages file.\n") + "".concat(error instanceof Error ? "Error: ".concat(error.message) : '')));
12
12
  }
13
13
  }
14
14
 
@@ -1,17 +1,20 @@
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 _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
4
5
  import _trimInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/trim';
6
+ import _flatMapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/flat-map';
5
7
  import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
6
8
  import _URL from '@babel/runtime-corejs3/core-js-stable/url';
7
9
  import crypto from 'node:crypto';
8
10
  import process, { exit } from 'node:process';
9
11
  import chalk from 'chalk';
10
12
  import { processConfig } from '@commercetools-frontend/application-config';
11
- import { p as pkgJson } from './package-6a5c0475.esm.js';
13
+ import { p as pkgJson } from './package-31f38f64.esm.js';
14
+ import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
12
15
  import http from 'node:http';
13
16
  import jwtDecode from 'jwt-decode';
14
- import { C as CredentialsStorage } from './credentials-storage-4464313c.esm.js';
17
+ import { C as CredentialsStorage } from './credentials-storage-7285d7b4.esm.js';
15
18
  import '@babel/runtime-corejs3/helpers/classCallCheck';
16
19
  import '@babel/runtime-corejs3/helpers/createClass';
17
20
  import '@babel/runtime-corejs3/core-js-stable/json/stringify';
@@ -24,7 +27,8 @@ import './does-file-exist-32618334.esm.js';
24
27
  function createAuthCallbackServer(options) {
25
28
  const server = http.createServer(async (request, response) => {
26
29
  try {
27
- if (request.url?.includes(`/${options.clientIdentifier}/oidc/callback`)) {
30
+ var _request$url;
31
+ if ((_request$url = request.url) !== null && _request$url !== void 0 && _includesInstanceProperty(_request$url).call(_request$url, "/".concat(options.clientIdentifier, "/oidc/callback"))) {
28
32
  const incomingUrl = new _URL(request.url, 'http://localhost');
29
33
  const sessionToken = incomingUrl.searchParams.get('sessionToken');
30
34
  const requestedState = incomingUrl.searchParams.get('state');
@@ -32,7 +36,7 @@ function createAuthCallbackServer(options) {
32
36
  throw new Error('Invalid authentication flow (missing sessionToken)');
33
37
  }
34
38
  const decodedSessionToken = jwtDecode(sessionToken);
35
- if (decodedSessionToken?.nonce !== options.nonce) {
39
+ if ((decodedSessionToken === null || decodedSessionToken === void 0 ? void 0 : decodedSessionToken.nonce) !== options.nonce) {
36
40
  throw new Error('Invalid authentication flow (nonce mismatch)');
37
41
  }
38
42
  if (requestedState !== options.state) {
@@ -55,7 +59,7 @@ function createAuthCallbackServer(options) {
55
59
  response.end(error.message);
56
60
  } else {
57
61
  console.error(error);
58
- response.end(`Invalid authentication flow.`);
62
+ response.end("Invalid authentication flow.");
59
63
  }
60
64
  server.close(() => {
61
65
  exit();
@@ -67,14 +71,14 @@ function createAuthCallbackServer(options) {
67
71
 
68
72
  const credentialsStorage = new CredentialsStorage();
69
73
  const port = 3001;
70
- const clientIdentifier = `mc-scripts-${pkgJson.version}`;
74
+ const clientIdentifier = "mc-scripts-".concat(pkgJson.version);
71
75
  const isServerError = error => {
72
76
  return error instanceof Error && 'code' in error;
73
77
  };
74
78
  const startServer = server => new _Promise((resolve, reject) => {
75
79
  server.listen(port, 'localhost').on('listening', resolve).on('error', error => {
76
80
  if (isServerError(error) && error.code === 'EADDRINUSE') {
77
- 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.`, {
81
+ return reject(new Error("The address \"localhost:".concat(port, "\" is already in use. Are you running a Merchant Center application in other process? Please stop that and try again."), {
78
82
  cause: error
79
83
  }));
80
84
  }
@@ -110,8 +114,9 @@ const resolveProjectKey = async options => {
110
114
  return process.env.CTP_PROJECT_KEY;
111
115
  }
112
116
  try {
117
+ var _applicationConfig$en;
113
118
  const applicationConfig = await processConfig();
114
- return applicationConfig.env.__DEVELOPMENT__?.oidc?.initialProjectKey;
119
+ return (_applicationConfig$en = applicationConfig.env.__DEVELOPMENT__) === null || _applicationConfig$en === void 0 || (_applicationConfig$en = _applicationConfig$en.oidc) === null || _applicationConfig$en === void 0 ? void 0 : _applicationConfig$en.initialProjectKey;
115
120
  } catch (error) {
116
121
  // It's ok if there's not application config file or if it does not contain the initialProjectKey
117
122
  return;
@@ -120,10 +125,10 @@ const resolveProjectKey = async options => {
120
125
  const mapOAuthScopesToClaims = scopes => {
121
126
  return _mapInstanceProperty(scopes).call(scopes, scope => {
122
127
  if (_startsWithInstanceProperty(scope).call(scope, 'view_')) {
123
- return `view:${scope}`;
128
+ return "view:".concat(scope);
124
129
  }
125
130
  if (_startsWithInstanceProperty(scope).call(scope, 'manage_')) {
126
- return `manage:${scope}`;
131
+ return "manage:".concat(scope);
127
132
  }
128
133
  return scope;
129
134
  });
@@ -131,10 +136,12 @@ const mapOAuthScopesToClaims = scopes => {
131
136
  const mapAdditionalOAuthScopesToClaims = (name, scopes) => {
132
137
  return _mapInstanceProperty(scopes).call(scopes, scope => {
133
138
  if (_startsWithInstanceProperty(scope).call(scope, 'view_')) {
134
- return `view/${name}:${scope}`;
139
+ var _context;
140
+ return _concatInstanceProperty(_context = "view/".concat(name, ":")).call(_context, scope);
135
141
  }
136
142
  if (_startsWithInstanceProperty(scope).call(scope, 'manage_')) {
137
- return `manage/${name}:${scope}`;
143
+ var _context2;
144
+ return _concatInstanceProperty(_context2 = "manage/".concat(name, ":")).call(_context2, scope);
138
145
  }
139
146
  return scope;
140
147
  });
@@ -146,13 +153,15 @@ const resolveOAuthScopes = async options => {
146
153
 
147
154
  // We first check whether the user has set the CTP_OAUTH_SCOPES environment variable
148
155
  if (process.env.CTP_OAUTH_SCOPES) {
149
- return mapOAuthScopesToClaims(process.env.CTP_OAUTH_SCOPES?.split(',').map(scope => _trimInstanceProperty(scope).call(scope)) ?? []);
156
+ var _process$env$CTP_OAUT, _process$env$CTP_OAUT2, _context3;
157
+ return mapOAuthScopesToClaims((_process$env$CTP_OAUT = (_process$env$CTP_OAUT2 = process.env.CTP_OAUTH_SCOPES) === null || _process$env$CTP_OAUT2 === void 0 ? void 0 : _mapInstanceProperty(_context3 = _process$env$CTP_OAUT2.split(',')).call(_context3, scope => _trimInstanceProperty(scope).call(scope))) !== null && _process$env$CTP_OAUT !== void 0 ? _process$env$CTP_OAUT : []);
150
158
  }
151
159
  try {
160
+ var _applicationConfig$en2, _applicationConfig$en3, _configuredOAuthScope, _configuredOAuthScope2, _configuredAdditional, _configuredAdditional2;
152
161
  const applicationConfig = await processConfig();
153
- const configuredOAuthScopes = applicationConfig.env.__DEVELOPMENT__?.oidc?.oAuthScopes;
154
- const configuredAdditionalOAuthScopes = applicationConfig.env.__DEVELOPMENT__?.oidc?.additionalOAuthScopes;
155
- return [...mapOAuthScopesToClaims(configuredOAuthScopes?.view ?? []), ...mapOAuthScopesToClaims(configuredOAuthScopes?.manage ?? []), ...(configuredAdditionalOAuthScopes?.flatMap(scope => mapAdditionalOAuthScopesToClaims(scope.name, scope.view)) ?? []), ...(configuredAdditionalOAuthScopes?.flatMap(scope => mapAdditionalOAuthScopesToClaims(scope.name, scope.manage)) ?? [])];
162
+ const configuredOAuthScopes = (_applicationConfig$en2 = applicationConfig.env.__DEVELOPMENT__) === null || _applicationConfig$en2 === void 0 || (_applicationConfig$en2 = _applicationConfig$en2.oidc) === null || _applicationConfig$en2 === void 0 ? void 0 : _applicationConfig$en2.oAuthScopes;
163
+ const configuredAdditionalOAuthScopes = (_applicationConfig$en3 = applicationConfig.env.__DEVELOPMENT__) === null || _applicationConfig$en3 === void 0 || (_applicationConfig$en3 = _applicationConfig$en3.oidc) === null || _applicationConfig$en3 === void 0 ? void 0 : _applicationConfig$en3.additionalOAuthScopes;
164
+ return [...mapOAuthScopesToClaims((_configuredOAuthScope = configuredOAuthScopes === null || configuredOAuthScopes === void 0 ? void 0 : configuredOAuthScopes.view) !== null && _configuredOAuthScope !== void 0 ? _configuredOAuthScope : []), ...mapOAuthScopesToClaims((_configuredOAuthScope2 = configuredOAuthScopes === null || configuredOAuthScopes === void 0 ? void 0 : configuredOAuthScopes.manage) !== null && _configuredOAuthScope2 !== void 0 ? _configuredOAuthScope2 : []), ...((_configuredAdditional = configuredAdditionalOAuthScopes === null || configuredAdditionalOAuthScopes === void 0 ? void 0 : _flatMapInstanceProperty(configuredAdditionalOAuthScopes).call(configuredAdditionalOAuthScopes, scope => mapAdditionalOAuthScopesToClaims(scope.name, scope.view))) !== null && _configuredAdditional !== void 0 ? _configuredAdditional : []), ...((_configuredAdditional2 = configuredAdditionalOAuthScopes === null || configuredAdditionalOAuthScopes === void 0 ? void 0 : _flatMapInstanceProperty(configuredAdditionalOAuthScopes).call(configuredAdditionalOAuthScopes, scope => mapAdditionalOAuthScopesToClaims(scope.name, scope.manage))) !== null && _configuredAdditional2 !== void 0 ? _configuredAdditional2 : [])];
156
165
  } catch (error) {
157
166
  // It's ok if there's not application config file or if it does not contain the initialProjectKey
158
167
  return [];
@@ -167,17 +176,17 @@ async function run(options) {
167
176
  if (!mcApiUrl) {
168
177
  throw new Error('No Merchant Center API URL found. Aborting.');
169
178
  }
170
- console.log(`Using Merchant Center environment "${chalk.green(mcApiUrl)}".`);
179
+ console.log("Using Merchant Center environment \"".concat(chalk.green(mcApiUrl), "\"."));
171
180
  console.log();
172
181
  if (!options.force && credentialsStorage.isSessionValid(mcApiUrl)) {
173
- console.log(`You already have a valid session.`);
182
+ console.log("You already have a valid session.");
174
183
  return;
175
184
  }
176
185
  const projectKey = await resolveProjectKey(options);
177
186
  const oauthScopes = await resolveOAuthScopes(options);
178
187
  const scopes = ['openid'];
179
188
  if (projectKey) {
180
- scopes.push(`project_key:${projectKey}`);
189
+ scopes.push("project_key:".concat(projectKey));
181
190
  _forEachInstanceProperty(oauthScopes).call(oauthScopes, scope => {
182
191
  scopes.push(scope);
183
192
  });
@@ -187,7 +196,7 @@ async function run(options) {
187
196
  const authUrl = new _URL('/login/authorize', mcApiUrl);
188
197
  authUrl.searchParams.set('response_type', 'id_token');
189
198
  authUrl.searchParams.set('response_mode', 'query');
190
- authUrl.searchParams.set('client_id', `__local:${clientIdentifier}`);
199
+ authUrl.searchParams.set('client_id', "__local:".concat(clientIdentifier));
191
200
  authUrl.searchParams.set('scope', scopes.join(' '));
192
201
  authUrl.searchParams.set('state', state);
193
202
  authUrl.searchParams.set('nonce', nonce);
@@ -198,13 +207,13 @@ async function run(options) {
198
207
  onSuccess: tokenContext => {
199
208
  credentialsStorage.setToken(mcApiUrl, tokenContext);
200
209
  console.log();
201
- console.log(chalk.green(`Login successful.`));
210
+ console.log(chalk.green("Login successful."));
202
211
  console.log();
203
212
  }
204
213
  });
205
214
  await startServer(server);
206
- console.log(`Initiating the OIDC authentication flow, opening the login page in your browser...`);
207
- console.log(` ${authUrl}`);
215
+ console.log("Initiating the OIDC authentication flow, opening the login page in your browser...");
216
+ console.log(" ".concat(authUrl));
208
217
  console.log();
209
218
  const open = await import('open');
210
219
  await open.default(authUrl.toString());