@commercetools-frontend/mc-scripts 25.0.0 → 25.2.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 +28 -14
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +28 -14
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +28 -14
- package/dist/{build-50f29fb0.cjs.prod.js → build-182a099c.cjs.prod.js} +7 -7
- package/dist/{build-0b4c6b04.esm.js → build-220a1658.esm.js} +7 -7
- package/dist/{build-1baf8a00.cjs.dev.js → build-519d246d.cjs.dev.js} +7 -7
- package/dist/{build-vite-e26f6c9f.cjs.dev.js → build-vite-837e7c94.cjs.dev.js} +64 -43
- package/dist/{build-vite-85211835.esm.js → build-vite-8cae71a0.esm.js} +61 -24
- package/dist/{build-vite-4a6c90c2.cjs.prod.js → build-vite-b007241b.cjs.prod.js} +64 -43
- 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-0b96d430.esm.js +255 -0
- package/dist/config-sync-b3072939.cjs.prod.js +265 -0
- package/dist/config-sync-ci-4a09aa00.cjs.prod.js +305 -0
- package/dist/config-sync-ci-85e3fec2.esm.js +294 -0
- package/dist/config-sync-ci-eadb8bfc.cjs.dev.js +305 -0
- package/dist/config-sync-f8fca39f.cjs.dev.js +265 -0
- package/dist/{config-sync-87ba9f28.cjs.prod.js → config-sync-helpers-11fc328f.cjs.prod.js} +193 -326
- package/dist/{config-sync-27ca0c93.cjs.dev.js → config-sync-helpers-dab59ed9.cjs.dev.js} +195 -328
- package/dist/{config-sync-ff4b1e5b.esm.js → config-sync-helpers-fe6ea729.esm.js} +186 -323
- package/dist/{create-postcss-config-34bab342.cjs.prod.js → create-postcss-config-56b74a34.cjs.prod.js} +1 -1
- package/dist/{create-postcss-config-0e833724.cjs.dev.js → create-postcss-config-78879a12.cjs.dev.js} +1 -1
- package/dist/{create-postcss-config-e6dfba3f.esm.js → create-postcss-config-95f9bf62.esm.js} +1 -1
- package/dist/{create-webpack-config-for-development-fe0945ce.cjs.prod.js → create-webpack-config-for-development-3eb1b365.cjs.prod.js} +7 -7
- package/dist/{create-webpack-config-for-development-2ac1d86f.cjs.dev.js → create-webpack-config-for-development-62b89920.cjs.dev.js} +7 -7
- package/dist/{create-webpack-config-for-development-be2722d6.esm.js → create-webpack-config-for-development-a28736fa.esm.js} +7 -7
- package/dist/{create-webpack-config-for-production-66c77849.esm.js → create-webpack-config-for-production-21ea561f.esm.js} +8 -8
- package/dist/{create-webpack-config-for-production-2200e554.cjs.prod.js → create-webpack-config-for-production-3b6599db.cjs.prod.js} +8 -8
- package/dist/{create-webpack-config-for-production-d2c41a9d.cjs.dev.js → create-webpack-config-for-production-e5ed8805.cjs.dev.js} +8 -8
- package/dist/{credentials-storage-381abf27.cjs.prod.js → credentials-storage-6d592cd6.cjs.prod.js} +21 -3
- package/dist/{credentials-storage-de220814.cjs.dev.js → credentials-storage-c4c5980e.cjs.dev.js} +21 -3
- package/dist/{credentials-storage-7285d7b4.esm.js → credentials-storage-fcc77fb6.esm.js} +21 -3
- package/dist/declarations/src/types.d.ts +4 -0
- package/dist/{deployment-previews-set-7f9fbfe5.esm.js → deployment-previews-set-7d49e7df.esm.js} +22 -27
- package/dist/{deployment-previews-set-3697be5e.cjs.dev.js → deployment-previews-set-8d6a1e99.cjs.dev.js} +22 -28
- package/dist/{deployment-previews-set-e92403f7.cjs.prod.js → deployment-previews-set-f8ce3db7.cjs.prod.js} +22 -28
- package/dist/{graphql-requests-bab5fcc3.cjs.dev.js → graphql-requests-b57fca4c.cjs.prod.js} +5 -8
- package/dist/{graphql-requests-d8bc2292.esm.js → graphql-requests-d2fa2ca7.esm.js} +6 -9
- package/dist/{graphql-requests-8ef89149.cjs.prod.js → graphql-requests-da194989.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-5fd67aac.cjs.prod.js → login-9774c9cc.cjs.prod.js} +154 -38
- package/dist/login-abb38213.esm.js +337 -0
- package/dist/{login-9fac9eee.cjs.dev.js → login-f4550251.cjs.dev.js} +154 -38
- 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-ff04bcf7.cjs.dev.js → package-0eebca1b.cjs.dev.js} +21 -11
- package/dist/{package-4bdd2ccf.esm.js → package-9e6910b8.esm.js} +21 -11
- package/dist/{package-428d5001.cjs.prod.js → package-b9298ce3.cjs.prod.js} +21 -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-643a55bb.esm.js → start-109f9462.esm.js} +8 -9
- package/dist/{start-47ea5e04.cjs.dev.js → start-7765f44c.cjs.dev.js} +8 -9
- package/dist/{start-84cdf12b.cjs.prod.js → start-e014127c.cjs.prod.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 +21 -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/login-9ee43381.esm.js +0 -223
package/dist/{deployment-previews-set-7f9fbfe5.esm.js → deployment-previews-set-7d49e7df.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 {
|
|
8
|
+
import { C as CredentialsStorage } from './credentials-storage-fcc77fb6.esm.js';
|
|
9
|
+
import { d as fetchCustomApplication, g as updateCustomApplicationDeploymentPreview, h as createCustomApplicationDeploymentPreview } from './graphql-requests-d2fa2ca7.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-9e6910b8.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.');
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var _URL = require('@babel/runtime-corejs3/core-js-stable/url');
|
|
4
4
|
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
5
|
-
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
6
5
|
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
7
6
|
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
8
7
|
var chalk = require('chalk');
|
|
9
8
|
var prompts = require('prompts');
|
|
10
9
|
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
11
|
-
var credentialsStorage$1 = require('./credentials-storage-
|
|
12
|
-
var graphqlRequests = require('./graphql-requests-
|
|
10
|
+
var credentialsStorage$1 = require('./credentials-storage-c4c5980e.cjs.dev.js');
|
|
11
|
+
var graphqlRequests = require('./graphql-requests-da194989.cjs.dev.js');
|
|
13
12
|
require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
14
13
|
require('@babel/runtime-corejs3/helpers/createClass');
|
|
15
14
|
require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
@@ -31,13 +30,12 @@ require('graphql');
|
|
|
31
30
|
require('graphql-request');
|
|
32
31
|
require('@commercetools-frontend/constants');
|
|
33
32
|
require('@commercetools/http-user-agent');
|
|
34
|
-
require('./package-
|
|
33
|
+
require('./package-0eebca1b.cjs.dev.js');
|
|
35
34
|
|
|
36
35
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
37
36
|
|
|
38
37
|
var _URL__default = /*#__PURE__*/_interopDefault(_URL);
|
|
39
38
|
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
40
|
-
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
41
39
|
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
42
40
|
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
43
41
|
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
@@ -57,25 +55,24 @@ const validateUrl = function () {
|
|
|
57
55
|
const validateAlias = function () {
|
|
58
56
|
let alias = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
59
57
|
try {
|
|
60
|
-
new _URL__default["default"](
|
|
58
|
+
new _URL__default["default"](`https://${alias}.commercetools.com/`);
|
|
61
59
|
return true;
|
|
62
60
|
} catch (error) {
|
|
63
61
|
return false;
|
|
64
62
|
}
|
|
65
63
|
};
|
|
66
64
|
const getMcUrlLink = _ref => {
|
|
67
|
-
var _context2, _context3, _context4;
|
|
68
65
|
let mcApiUrl = _ref.mcApiUrl,
|
|
69
66
|
organizationId = _ref.organizationId,
|
|
70
67
|
customEntityId = _ref.customEntityId,
|
|
71
68
|
isCustomView = _ref.isCustomView;
|
|
72
69
|
const mcUrl = mcApiUrl.replace('mc-api', 'mc');
|
|
73
|
-
const customEntityLink =
|
|
70
|
+
const customEntityLink = `${mcUrl}/account/organizations/${organizationId}/custom-${isCustomView ? 'views' : 'applications'}/owned/${customEntityId}/deployment-previews`;
|
|
74
71
|
return customEntityLink;
|
|
75
72
|
};
|
|
76
73
|
const isCustomViewData = data => data.entryPointUriPath === undefined;
|
|
77
74
|
async function setDeploymentPreview(_ref2) {
|
|
78
|
-
var
|
|
75
|
+
var _context3;
|
|
79
76
|
let mcApiUrl = _ref2.mcApiUrl,
|
|
80
77
|
applicationId = _ref2.applicationId,
|
|
81
78
|
applicationIdentifier = _ref2.applicationIdentifier,
|
|
@@ -96,28 +93,28 @@ async function setDeploymentPreview(_ref2) {
|
|
|
96
93
|
applicationIdentifier
|
|
97
94
|
});
|
|
98
95
|
if (!fetchedCustomApplication) {
|
|
99
|
-
throw new Error(
|
|
96
|
+
throw new Error(`The Custom Application "${applicationIdentifier}" does not exist in the Merchant Center. Please create a Custom Application first before configuring deployment previews.`);
|
|
100
97
|
}
|
|
101
98
|
let deploymentAlias = options.alias;
|
|
102
99
|
// If the alias was not provided as an argument to the script, let's ask for it.
|
|
103
100
|
if (!deploymentAlias) {
|
|
104
|
-
var
|
|
101
|
+
var _context2;
|
|
105
102
|
const _await$prompts = await prompts__default["default"]({
|
|
106
103
|
type: 'text',
|
|
107
104
|
name: 'alias',
|
|
108
|
-
message: _filterInstanceProperty__default["default"](
|
|
105
|
+
message: _filterInstanceProperty__default["default"](_context2 = [`Enter the alias for the deployment preview`, options.dryRun && chalk__default["default"].gray('Using "--dry-run", no deployment preview will be created.')]).call(_context2, Boolean).join('\n'),
|
|
109
106
|
validate: value => validateAlias(value)
|
|
110
107
|
}),
|
|
111
108
|
alias = _await$prompts.alias;
|
|
112
109
|
deploymentAlias = alias;
|
|
113
110
|
}
|
|
114
|
-
const existingDeploymentPreview = _findInstanceProperty__default["default"](
|
|
111
|
+
const existingDeploymentPreview = _findInstanceProperty__default["default"](_context3 = fetchedCustomApplication.application.deployments).call(_context3, deployment => deployment.alias === deploymentAlias);
|
|
115
112
|
if (!options.alias && !options.url && existingDeploymentPreview) {
|
|
116
|
-
var
|
|
113
|
+
var _context4;
|
|
117
114
|
const _await$prompts2 = await prompts__default["default"]({
|
|
118
115
|
type: 'confirm',
|
|
119
116
|
name: 'aliasOverrideConfirmation',
|
|
120
|
-
message: _filterInstanceProperty__default["default"](
|
|
117
|
+
message: _filterInstanceProperty__default["default"](_context4 = [`The alias "${chalk__default["default"].green(deploymentAlias)}" already exists. Do you want to proceed and update the URL?`, options.dryRun && chalk__default["default"].gray('Using "--dry-run", no deployment preview will be created.')]).call(_context4, Boolean).join('\n'),
|
|
121
118
|
initial: false
|
|
122
119
|
}),
|
|
123
120
|
aliasOverrideConfirmation = _await$prompts2.aliasOverrideConfirmation;
|
|
@@ -128,20 +125,19 @@ async function setDeploymentPreview(_ref2) {
|
|
|
128
125
|
}
|
|
129
126
|
let deploymentUrl = options.url;
|
|
130
127
|
if (!deploymentUrl) {
|
|
131
|
-
var
|
|
128
|
+
var _context5;
|
|
132
129
|
const _await$prompts3 = await prompts__default["default"]({
|
|
133
130
|
type: 'text',
|
|
134
131
|
name: 'url',
|
|
135
|
-
message: _filterInstanceProperty__default["default"](
|
|
132
|
+
message: _filterInstanceProperty__default["default"](_context5 = [`Enter the URL for the deployment preview`, options.dryRun && chalk__default["default"].gray('Using "--dry-run", no deployment preview will be created.')]).call(_context5, Boolean).join('\n'),
|
|
136
133
|
validate: value => validateUrl(value)
|
|
137
134
|
}),
|
|
138
135
|
url = _await$prompts3.url;
|
|
139
136
|
deploymentUrl = url;
|
|
140
137
|
}
|
|
141
138
|
if (options.dryRun) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
console.log("\n".concat(message, "\n"));
|
|
139
|
+
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}".`;
|
|
140
|
+
console.log(`\n${message}\n`);
|
|
145
141
|
return;
|
|
146
142
|
}
|
|
147
143
|
const mcDeploymentPreviewsLink = getMcUrlLink({
|
|
@@ -151,7 +147,6 @@ async function setDeploymentPreview(_ref2) {
|
|
|
151
147
|
isCustomView
|
|
152
148
|
});
|
|
153
149
|
if (existingDeploymentPreview) {
|
|
154
|
-
var _context1;
|
|
155
150
|
await graphqlRequests.updateCustomApplicationDeploymentPreview({
|
|
156
151
|
mcApiUrl,
|
|
157
152
|
organizationId: fetchedCustomApplication.organizationId,
|
|
@@ -161,10 +156,9 @@ async function setDeploymentPreview(_ref2) {
|
|
|
161
156
|
url: deploymentUrl
|
|
162
157
|
}
|
|
163
158
|
});
|
|
164
|
-
console.log(chalk__default["default"].green(
|
|
165
|
-
console.log(chalk__default["default"].green(
|
|
159
|
+
console.log(chalk__default["default"].green(`Deployment preview with alias "${deploymentAlias}" updated successfully with URL "${deploymentUrl}".`));
|
|
160
|
+
console.log(chalk__default["default"].green(`You can access the deployment previews at: ${mcDeploymentPreviewsLink}`));
|
|
166
161
|
} else {
|
|
167
|
-
var _context10;
|
|
168
162
|
await graphqlRequests.createCustomApplicationDeploymentPreview({
|
|
169
163
|
mcApiUrl,
|
|
170
164
|
organizationId: fetchedCustomApplication.organizationId,
|
|
@@ -175,8 +169,8 @@ async function setDeploymentPreview(_ref2) {
|
|
|
175
169
|
url: deploymentUrl
|
|
176
170
|
}
|
|
177
171
|
});
|
|
178
|
-
console.log(chalk__default["default"].green(
|
|
179
|
-
console.log(chalk__default["default"].green(
|
|
172
|
+
console.log(chalk__default["default"].green(`Deployment preview with alias "${deploymentAlias}" created successfully with URL "${deploymentUrl}".`));
|
|
173
|
+
console.log(chalk__default["default"].green(`You can access the deployment previews at: ${mcDeploymentPreviewsLink}`));
|
|
180
174
|
}
|
|
181
175
|
}
|
|
182
176
|
async function run(options) {
|
|
@@ -186,11 +180,11 @@ async function run(options) {
|
|
|
186
180
|
mcApiUrl = _applicationConfig$en.mcApiUrl,
|
|
187
181
|
applicationIdentifier = _applicationConfig$en.applicationIdentifier;
|
|
188
182
|
const isCustomView = isCustomViewData(localCustomEntityData);
|
|
189
|
-
console.log(
|
|
183
|
+
console.log(`Using Merchant Center environment "${chalk__default["default"].green(mcApiUrl)}".`);
|
|
190
184
|
console.log();
|
|
191
185
|
const isSessionValid = credentialsStorage.isSessionValid(mcApiUrl);
|
|
192
186
|
if (!isSessionValid) {
|
|
193
|
-
throw new Error(
|
|
187
|
+
throw new Error(`You don't have a valid session. Please, run the "mc-scripts login" command to authenticate yourself.`);
|
|
194
188
|
}
|
|
195
189
|
if (isCustomView) {
|
|
196
190
|
throw new Error('Deployments previews are not supported for Custom Views.');
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var _URL = require('@babel/runtime-corejs3/core-js-stable/url');
|
|
4
4
|
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
5
|
-
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
6
5
|
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
7
6
|
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
8
7
|
var chalk = require('chalk');
|
|
9
8
|
var prompts = require('prompts');
|
|
10
9
|
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
11
|
-
var credentialsStorage$1 = require('./credentials-storage-
|
|
12
|
-
var graphqlRequests = require('./graphql-requests-
|
|
10
|
+
var credentialsStorage$1 = require('./credentials-storage-6d592cd6.cjs.prod.js');
|
|
11
|
+
var graphqlRequests = require('./graphql-requests-b57fca4c.cjs.prod.js');
|
|
13
12
|
require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
14
13
|
require('@babel/runtime-corejs3/helpers/createClass');
|
|
15
14
|
require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
@@ -31,13 +30,12 @@ require('graphql');
|
|
|
31
30
|
require('graphql-request');
|
|
32
31
|
require('@commercetools-frontend/constants');
|
|
33
32
|
require('@commercetools/http-user-agent');
|
|
34
|
-
require('./package-
|
|
33
|
+
require('./package-b9298ce3.cjs.prod.js');
|
|
35
34
|
|
|
36
35
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
37
36
|
|
|
38
37
|
var _URL__default = /*#__PURE__*/_interopDefault(_URL);
|
|
39
38
|
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
40
|
-
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
41
39
|
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
42
40
|
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
43
41
|
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
@@ -57,25 +55,24 @@ const validateUrl = function () {
|
|
|
57
55
|
const validateAlias = function () {
|
|
58
56
|
let alias = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
59
57
|
try {
|
|
60
|
-
new _URL__default["default"](
|
|
58
|
+
new _URL__default["default"](`https://${alias}.commercetools.com/`);
|
|
61
59
|
return true;
|
|
62
60
|
} catch (error) {
|
|
63
61
|
return false;
|
|
64
62
|
}
|
|
65
63
|
};
|
|
66
64
|
const getMcUrlLink = _ref => {
|
|
67
|
-
var _context2, _context3, _context4;
|
|
68
65
|
let mcApiUrl = _ref.mcApiUrl,
|
|
69
66
|
organizationId = _ref.organizationId,
|
|
70
67
|
customEntityId = _ref.customEntityId,
|
|
71
68
|
isCustomView = _ref.isCustomView;
|
|
72
69
|
const mcUrl = mcApiUrl.replace('mc-api', 'mc');
|
|
73
|
-
const customEntityLink =
|
|
70
|
+
const customEntityLink = `${mcUrl}/account/organizations/${organizationId}/custom-${isCustomView ? 'views' : 'applications'}/owned/${customEntityId}/deployment-previews`;
|
|
74
71
|
return customEntityLink;
|
|
75
72
|
};
|
|
76
73
|
const isCustomViewData = data => data.entryPointUriPath === undefined;
|
|
77
74
|
async function setDeploymentPreview(_ref2) {
|
|
78
|
-
var
|
|
75
|
+
var _context3;
|
|
79
76
|
let mcApiUrl = _ref2.mcApiUrl,
|
|
80
77
|
applicationId = _ref2.applicationId,
|
|
81
78
|
applicationIdentifier = _ref2.applicationIdentifier,
|
|
@@ -96,28 +93,28 @@ async function setDeploymentPreview(_ref2) {
|
|
|
96
93
|
applicationIdentifier
|
|
97
94
|
});
|
|
98
95
|
if (!fetchedCustomApplication) {
|
|
99
|
-
throw new Error(
|
|
96
|
+
throw new Error(`The Custom Application "${applicationIdentifier}" does not exist in the Merchant Center. Please create a Custom Application first before configuring deployment previews.`);
|
|
100
97
|
}
|
|
101
98
|
let deploymentAlias = options.alias;
|
|
102
99
|
// If the alias was not provided as an argument to the script, let's ask for it.
|
|
103
100
|
if (!deploymentAlias) {
|
|
104
|
-
var
|
|
101
|
+
var _context2;
|
|
105
102
|
const _await$prompts = await prompts__default["default"]({
|
|
106
103
|
type: 'text',
|
|
107
104
|
name: 'alias',
|
|
108
|
-
message: _filterInstanceProperty__default["default"](
|
|
105
|
+
message: _filterInstanceProperty__default["default"](_context2 = [`Enter the alias for the deployment preview`, options.dryRun && chalk__default["default"].gray('Using "--dry-run", no deployment preview will be created.')]).call(_context2, Boolean).join('\n'),
|
|
109
106
|
validate: value => validateAlias(value)
|
|
110
107
|
}),
|
|
111
108
|
alias = _await$prompts.alias;
|
|
112
109
|
deploymentAlias = alias;
|
|
113
110
|
}
|
|
114
|
-
const existingDeploymentPreview = _findInstanceProperty__default["default"](
|
|
111
|
+
const existingDeploymentPreview = _findInstanceProperty__default["default"](_context3 = fetchedCustomApplication.application.deployments).call(_context3, deployment => deployment.alias === deploymentAlias);
|
|
115
112
|
if (!options.alias && !options.url && existingDeploymentPreview) {
|
|
116
|
-
var
|
|
113
|
+
var _context4;
|
|
117
114
|
const _await$prompts2 = await prompts__default["default"]({
|
|
118
115
|
type: 'confirm',
|
|
119
116
|
name: 'aliasOverrideConfirmation',
|
|
120
|
-
message: _filterInstanceProperty__default["default"](
|
|
117
|
+
message: _filterInstanceProperty__default["default"](_context4 = [`The alias "${chalk__default["default"].green(deploymentAlias)}" already exists. Do you want to proceed and update the URL?`, options.dryRun && chalk__default["default"].gray('Using "--dry-run", no deployment preview will be created.')]).call(_context4, Boolean).join('\n'),
|
|
121
118
|
initial: false
|
|
122
119
|
}),
|
|
123
120
|
aliasOverrideConfirmation = _await$prompts2.aliasOverrideConfirmation;
|
|
@@ -128,20 +125,19 @@ async function setDeploymentPreview(_ref2) {
|
|
|
128
125
|
}
|
|
129
126
|
let deploymentUrl = options.url;
|
|
130
127
|
if (!deploymentUrl) {
|
|
131
|
-
var
|
|
128
|
+
var _context5;
|
|
132
129
|
const _await$prompts3 = await prompts__default["default"]({
|
|
133
130
|
type: 'text',
|
|
134
131
|
name: 'url',
|
|
135
|
-
message: _filterInstanceProperty__default["default"](
|
|
132
|
+
message: _filterInstanceProperty__default["default"](_context5 = [`Enter the URL for the deployment preview`, options.dryRun && chalk__default["default"].gray('Using "--dry-run", no deployment preview will be created.')]).call(_context5, Boolean).join('\n'),
|
|
136
133
|
validate: value => validateUrl(value)
|
|
137
134
|
}),
|
|
138
135
|
url = _await$prompts3.url;
|
|
139
136
|
deploymentUrl = url;
|
|
140
137
|
}
|
|
141
138
|
if (options.dryRun) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
console.log("\n".concat(message, "\n"));
|
|
139
|
+
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}".`;
|
|
140
|
+
console.log(`\n${message}\n`);
|
|
145
141
|
return;
|
|
146
142
|
}
|
|
147
143
|
const mcDeploymentPreviewsLink = getMcUrlLink({
|
|
@@ -151,7 +147,6 @@ async function setDeploymentPreview(_ref2) {
|
|
|
151
147
|
isCustomView
|
|
152
148
|
});
|
|
153
149
|
if (existingDeploymentPreview) {
|
|
154
|
-
var _context1;
|
|
155
150
|
await graphqlRequests.updateCustomApplicationDeploymentPreview({
|
|
156
151
|
mcApiUrl,
|
|
157
152
|
organizationId: fetchedCustomApplication.organizationId,
|
|
@@ -161,10 +156,9 @@ async function setDeploymentPreview(_ref2) {
|
|
|
161
156
|
url: deploymentUrl
|
|
162
157
|
}
|
|
163
158
|
});
|
|
164
|
-
console.log(chalk__default["default"].green(
|
|
165
|
-
console.log(chalk__default["default"].green(
|
|
159
|
+
console.log(chalk__default["default"].green(`Deployment preview with alias "${deploymentAlias}" updated successfully with URL "${deploymentUrl}".`));
|
|
160
|
+
console.log(chalk__default["default"].green(`You can access the deployment previews at: ${mcDeploymentPreviewsLink}`));
|
|
166
161
|
} else {
|
|
167
|
-
var _context10;
|
|
168
162
|
await graphqlRequests.createCustomApplicationDeploymentPreview({
|
|
169
163
|
mcApiUrl,
|
|
170
164
|
organizationId: fetchedCustomApplication.organizationId,
|
|
@@ -175,8 +169,8 @@ async function setDeploymentPreview(_ref2) {
|
|
|
175
169
|
url: deploymentUrl
|
|
176
170
|
}
|
|
177
171
|
});
|
|
178
|
-
console.log(chalk__default["default"].green(
|
|
179
|
-
console.log(chalk__default["default"].green(
|
|
172
|
+
console.log(chalk__default["default"].green(`Deployment preview with alias "${deploymentAlias}" created successfully with URL "${deploymentUrl}".`));
|
|
173
|
+
console.log(chalk__default["default"].green(`You can access the deployment previews at: ${mcDeploymentPreviewsLink}`));
|
|
180
174
|
}
|
|
181
175
|
}
|
|
182
176
|
async function run(options) {
|
|
@@ -186,11 +180,11 @@ async function run(options) {
|
|
|
186
180
|
mcApiUrl = _applicationConfig$en.mcApiUrl,
|
|
187
181
|
applicationIdentifier = _applicationConfig$en.applicationIdentifier;
|
|
188
182
|
const isCustomView = isCustomViewData(localCustomEntityData);
|
|
189
|
-
console.log(
|
|
183
|
+
console.log(`Using Merchant Center environment "${chalk__default["default"].green(mcApiUrl)}".`);
|
|
190
184
|
console.log();
|
|
191
185
|
const isSessionValid = credentialsStorage.isSessionValid(mcApiUrl);
|
|
192
186
|
if (!isSessionValid) {
|
|
193
|
-
throw new Error(
|
|
187
|
+
throw new Error(`You don't have a valid session. Please, run the "mc-scripts login" command to authenticate yourself.`);
|
|
194
188
|
}
|
|
195
189
|
if (isCustomView) {
|
|
196
190
|
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-6d592cd6.cjs.prod.js');
|
|
18
18
|
var createHttpUserAgent = require('@commercetools/http-user-agent');
|
|
19
|
-
var _package = require('./package-
|
|
19
|
+
var _package = require('./package-b9298ce3.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-fcc77fb6.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-9e6910b8.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), {}, {
|
|
@@ -255,4 +252,4 @@ const updateCustomApplicationDeploymentPreview = async _ref9 => {
|
|
|
255
252
|
return updatedDeploymentPreviewResult.updateCustomApplicationDeploymentPreview;
|
|
256
253
|
};
|
|
257
254
|
|
|
258
|
-
export {
|
|
255
|
+
export { createCustomView as a, updateCustomView as b, createCustomApplication as c, fetchCustomApplication as d, fetchCustomView as e, fetchUserOrganizations as f, updateCustomApplicationDeploymentPreview as g, createCustomApplicationDeploymentPreview as h, updateCustomApplication as u };
|
|
@@ -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-c4c5980e.cjs.dev.js');
|
|
18
18
|
var createHttpUserAgent = require('@commercetools/http-user-agent');
|
|
19
|
-
var _package = require('./package-
|
|
19
|
+
var _package = require('./package-0eebca1b.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), {}, {
|