@commercetools-frontend/mc-scripts 22.28.0 → 22.30.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/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +20 -5
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +20 -5
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +20 -5
- package/dist/{build-e34b99e8.cjs.prod.js → build-9cec9200.cjs.prod.js} +4 -5
- package/dist/{build-5fa51b8c.esm.js → build-da3b32c2.esm.js} +4 -5
- package/dist/{build-999eabc6.cjs.dev.js → build-f3afcd49.cjs.dev.js} +4 -5
- package/dist/{build-vite-0ec1e9cf.cjs.dev.js → build-vite-87662f4d.cjs.dev.js} +16 -11
- package/dist/{build-vite-5d0fa021.esm.js → build-vite-b19a39fb.esm.js} +16 -11
- package/dist/{build-vite-acf05a1a.cjs.prod.js → build-vite-c7ccff49.cjs.prod.js} +16 -11
- 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/{config-sync-3aaa3f5d.cjs.dev.js → config-sync-1382d742.cjs.dev.js} +21 -208
- package/dist/{config-sync-97ba72f5.cjs.prod.js → config-sync-5630eaf3.cjs.prod.js} +21 -208
- package/dist/{config-sync-cabd5374.esm.js → config-sync-994c65af.esm.js} +12 -198
- package/dist/{create-postcss-config-0323c669.esm.js → create-postcss-config-80fcacc8.esm.js} +1 -1
- package/dist/{create-postcss-config-5d1737f0.cjs.dev.js → create-postcss-config-a77dddc9.cjs.dev.js} +1 -1
- package/dist/{create-postcss-config-069ef9c3.cjs.prod.js → create-postcss-config-c9d6c97d.cjs.prod.js} +1 -1
- package/dist/{create-webpack-config-for-development-e7733a1b.cjs.prod.js → create-webpack-config-for-development-0afc61bd.cjs.prod.js} +1 -1
- package/dist/{create-webpack-config-for-development-43c88bf6.esm.js → create-webpack-config-for-development-12426c95.esm.js} +1 -1
- package/dist/{create-webpack-config-for-development-4690f4cf.cjs.dev.js → create-webpack-config-for-development-744f2450.cjs.dev.js} +1 -1
- package/dist/{create-webpack-config-for-production-778d2b5e.cjs.dev.js → create-webpack-config-for-production-a416f4e0.cjs.dev.js} +2 -2
- package/dist/{create-webpack-config-for-production-cbf22a83.cjs.prod.js → create-webpack-config-for-production-ec594cb8.cjs.prod.js} +2 -2
- package/dist/{create-webpack-config-for-production-28d51113.esm.js → create-webpack-config-for-production-fa398fe5.esm.js} +2 -2
- package/dist/{credentials-storage-8b9ddb0b.cjs.dev.js → credentials-storage-1552e722.cjs.dev.js} +1 -1
- package/dist/{credentials-storage-0fb8f4a6.cjs.prod.js → credentials-storage-44ff9622.cjs.prod.js} +1 -1
- package/dist/{credentials-storage-f4e08e09.esm.js → credentials-storage-cb50e964.esm.js} +1 -1
- package/dist/declarations/src/commands/deployment-previews-set.d.ts +3 -0
- package/dist/declarations/src/generated/settings.d.ts +45 -0
- package/dist/declarations/src/types.d.ts +5 -0
- package/dist/declarations/src/utils/graphql-requests.d.ts +41 -2
- package/dist/declarations/src/utils/i18n-message-complilation.d.ts +4 -0
- package/dist/deployment-previews-set-9433ec82.esm.js +197 -0
- package/dist/deployment-previews-set-d6e7505a.cjs.prod.js +209 -0
- package/dist/deployment-previews-set-f538d323.cjs.dev.js +209 -0
- package/dist/graphql-requests-2a72a4f1.cjs.dev.js +269 -0
- package/dist/graphql-requests-c92192aa.esm.js +246 -0
- package/dist/graphql-requests-cbebcbb8.cjs.prod.js +269 -0
- package/dist/i18n-message-complilation-393d344a.cjs.prod.js +23 -0
- package/dist/i18n-message-complilation-3f80e8d6.cjs.dev.js +23 -0
- package/dist/i18n-message-complilation-8aec9d1b.esm.js +15 -0
- package/dist/{login-bd94d195.cjs.dev.js → login-532a3a88.cjs.dev.js} +2 -2
- package/dist/{login-9ee301cd.cjs.prod.js → login-958fbc54.cjs.prod.js} +2 -2
- package/dist/{login-90029738.esm.js → login-b5ed7cfc.esm.js} +2 -2
- package/dist/{package-50be39f9.esm.js → package-16f29309.esm.js} +12 -12
- package/dist/{package-1bf866e8.cjs.dev.js → package-218d42f5.cjs.prod.js} +12 -12
- package/dist/{package-d977cdc9.cjs.prod.js → package-dc01b1e0.cjs.dev.js} +12 -12
- package/dist/{start-4671c540.esm.js → start-04208901.esm.js} +3 -3
- package/dist/{start-54be934f.cjs.dev.js → start-c51f7ab5.cjs.dev.js} +3 -3
- package/dist/{start-a0031945.cjs.prod.js → start-fb1cc1c8.cjs.prod.js} +3 -3
- package/package.json +12 -12
- 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 +4 -4
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +4 -4
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +4 -4
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.dev.js +12 -2
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.prod.js +12 -2
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.esm.js +12 -2
- package/dist/declarations/src/utils/get-i18n-message-format.d.ts +0 -3
- package/dist/get-i18n-message-format-3e59a0d7.cjs.prod.js +0 -15
- package/dist/get-i18n-message-format-44a20fa2.cjs.dev.js +0 -15
- package/dist/get-i18n-message-format-58852baf.esm.js +0 -9
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import _URL from '@babel/runtime-corejs3/core-js-stable/url';
|
|
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
|
+
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
5
|
+
import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
import prompts from 'prompts';
|
|
8
|
+
import { processConfig } from '@commercetools-frontend/application-config';
|
|
9
|
+
import { C as CredentialsStorage } from './credentials-storage-cb50e964.esm.js';
|
|
10
|
+
import { f as fetchCustomApplication, g as updateCustomApplicationDeploymentPreview, h as createCustomApplicationDeploymentPreview } from './graphql-requests-c92192aa.esm.js';
|
|
11
|
+
import '@commercetools/http-user-agent';
|
|
12
|
+
import './package-16f29309.esm.js';
|
|
13
|
+
import '@babel/runtime-corejs3/helpers/classCallCheck';
|
|
14
|
+
import '@babel/runtime-corejs3/helpers/createClass';
|
|
15
|
+
import '@babel/runtime-corejs3/core-js-stable/json/stringify';
|
|
16
|
+
import '@babel/runtime-corejs3/core-js-stable/date/now';
|
|
17
|
+
import 'fs';
|
|
18
|
+
import 'os';
|
|
19
|
+
import 'path';
|
|
20
|
+
import './does-file-exist-32618334.esm.js';
|
|
21
|
+
import 'node:fs';
|
|
22
|
+
import '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
23
|
+
import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
|
|
24
|
+
import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
|
|
25
|
+
import '@babel/runtime-corejs3/core-js-stable/instance/for-each';
|
|
26
|
+
import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
|
|
27
|
+
import '@babel/runtime-corejs3/core-js-stable/object/define-properties';
|
|
28
|
+
import '@babel/runtime-corejs3/core-js-stable/object/define-property';
|
|
29
|
+
import '@babel/runtime-corejs3/helpers/defineProperty';
|
|
30
|
+
import '@babel/runtime-corejs3/core-js-stable/instance/some';
|
|
31
|
+
import 'graphql';
|
|
32
|
+
import 'graphql-request';
|
|
33
|
+
import '@commercetools-frontend/constants';
|
|
34
|
+
|
|
35
|
+
const credentialsStorage = new CredentialsStorage();
|
|
36
|
+
const validateUrl = function () {
|
|
37
|
+
let url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
38
|
+
try {
|
|
39
|
+
var _context;
|
|
40
|
+
const urlSchema = new _URL(url);
|
|
41
|
+
return _includesInstanceProperty(_context = ['http:', 'https:']).call(_context, urlSchema.protocol);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const validateAlias = function () {
|
|
47
|
+
let alias = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
48
|
+
try {
|
|
49
|
+
new _URL("https://".concat(alias, ".commercetools.com/"));
|
|
50
|
+
return true;
|
|
51
|
+
} catch (error) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const getMcUrlLink = _ref => {
|
|
56
|
+
var _context2, _context3, _context4;
|
|
57
|
+
let mcApiUrl = _ref.mcApiUrl,
|
|
58
|
+
organizationId = _ref.organizationId,
|
|
59
|
+
customEntityId = _ref.customEntityId,
|
|
60
|
+
isCustomView = _ref.isCustomView;
|
|
61
|
+
const mcUrl = mcApiUrl.replace('mc-api', 'mc');
|
|
62
|
+
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");
|
|
63
|
+
return customEntityLink;
|
|
64
|
+
};
|
|
65
|
+
const isCustomViewData = data => data.entryPointUriPath === undefined;
|
|
66
|
+
async function setDeploymentPreview(_ref2) {
|
|
67
|
+
var _context6;
|
|
68
|
+
let mcApiUrl = _ref2.mcApiUrl,
|
|
69
|
+
applicationId = _ref2.applicationId,
|
|
70
|
+
applicationIdentifier = _ref2.applicationIdentifier,
|
|
71
|
+
localCustomEntityData = _ref2.localCustomEntityData,
|
|
72
|
+
isCustomView = _ref2.isCustomView,
|
|
73
|
+
options = _ref2.options;
|
|
74
|
+
/*
|
|
75
|
+
1. Check if the Custom Application exists in the Merchant Center.
|
|
76
|
+
2. Ask for the alias and URL of the deployment preview.
|
|
77
|
+
3. Check whether it exists a deployment preview with the same alias.
|
|
78
|
+
4. If it exists, ask for confirmation to update it.
|
|
79
|
+
5. If it doesn't exist, ask for confirmation to create it.
|
|
80
|
+
*/
|
|
81
|
+
|
|
82
|
+
const fetchedCustomApplication = await fetchCustomApplication({
|
|
83
|
+
mcApiUrl,
|
|
84
|
+
entryPointUriPath: localCustomEntityData.entryPointUriPath,
|
|
85
|
+
applicationIdentifier
|
|
86
|
+
});
|
|
87
|
+
if (!fetchedCustomApplication) {
|
|
88
|
+
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."));
|
|
89
|
+
}
|
|
90
|
+
let deploymentAlias = options.alias;
|
|
91
|
+
// If the alias was not provided as an argument to the script, let's ask for it.
|
|
92
|
+
if (!deploymentAlias) {
|
|
93
|
+
var _context5;
|
|
94
|
+
const _await$prompts = await prompts({
|
|
95
|
+
type: 'text',
|
|
96
|
+
name: 'alias',
|
|
97
|
+
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'),
|
|
98
|
+
validate: value => validateAlias(value)
|
|
99
|
+
}),
|
|
100
|
+
alias = _await$prompts.alias;
|
|
101
|
+
deploymentAlias = alias;
|
|
102
|
+
}
|
|
103
|
+
const existingDeploymentPreview = _findInstanceProperty(_context6 = fetchedCustomApplication.application.deployments).call(_context6, deployment => deployment.alias === deploymentAlias);
|
|
104
|
+
if (!options.alias && !options.url && existingDeploymentPreview) {
|
|
105
|
+
var _context7;
|
|
106
|
+
const _await$prompts2 = await prompts({
|
|
107
|
+
type: 'confirm',
|
|
108
|
+
name: 'aliasOverrideConfirmation',
|
|
109
|
+
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'),
|
|
110
|
+
initial: false
|
|
111
|
+
}),
|
|
112
|
+
aliasOverrideConfirmation = _await$prompts2.aliasOverrideConfirmation;
|
|
113
|
+
if (!aliasOverrideConfirmation) {
|
|
114
|
+
console.log(chalk.red('Aborted.'));
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
let deploymentUrl = options.url;
|
|
119
|
+
if (!deploymentUrl) {
|
|
120
|
+
var _context8;
|
|
121
|
+
const _await$prompts3 = await prompts({
|
|
122
|
+
type: 'text',
|
|
123
|
+
name: 'url',
|
|
124
|
+
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'),
|
|
125
|
+
validate: value => validateUrl(value)
|
|
126
|
+
}),
|
|
127
|
+
url = _await$prompts3.url;
|
|
128
|
+
deploymentUrl = url;
|
|
129
|
+
}
|
|
130
|
+
if (options.dryRun) {
|
|
131
|
+
var _context9, _context10;
|
|
132
|
+
const message = existingDeploymentPreview ? _concatInstanceProperty(_context9 = "The existing deployment preview with alias \"".concat(deploymentAlias, "\" would have been updated with this url: \"")).call(_context9, deploymentUrl, "\".") : _concatInstanceProperty(_context10 = "A new deployment preview with alias \"".concat(deploymentAlias, "\" would have been created with this url: \"")).call(_context10, deploymentUrl, "\".");
|
|
133
|
+
console.log("\n".concat(message, "\n"));
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const mcDeploymentPreviewsLink = getMcUrlLink({
|
|
137
|
+
mcApiUrl,
|
|
138
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
139
|
+
customEntityId: fetchedCustomApplication.application.id,
|
|
140
|
+
isCustomView
|
|
141
|
+
});
|
|
142
|
+
if (existingDeploymentPreview) {
|
|
143
|
+
var _context11;
|
|
144
|
+
await updateCustomApplicationDeploymentPreview({
|
|
145
|
+
mcApiUrl,
|
|
146
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
147
|
+
applicationIdentifier,
|
|
148
|
+
deploymentId: existingDeploymentPreview.id,
|
|
149
|
+
data: {
|
|
150
|
+
url: deploymentUrl
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
console.log(chalk.green(_concatInstanceProperty(_context11 = "Deployment preview with alias \"".concat(deploymentAlias, "\" updated successfully with URL \"")).call(_context11, deploymentUrl, "\".")));
|
|
154
|
+
console.log(chalk.green("You can access the deployment previews at: ".concat(mcDeploymentPreviewsLink)));
|
|
155
|
+
} else {
|
|
156
|
+
var _context12;
|
|
157
|
+
await createCustomApplicationDeploymentPreview({
|
|
158
|
+
mcApiUrl,
|
|
159
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
160
|
+
applicationIdentifier,
|
|
161
|
+
applicationId,
|
|
162
|
+
data: {
|
|
163
|
+
alias: deploymentAlias,
|
|
164
|
+
url: deploymentUrl
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
console.log(chalk.green(_concatInstanceProperty(_context12 = "Deployment preview with alias \"".concat(deploymentAlias, "\" created successfully with URL \"")).call(_context12, deploymentUrl, "\".")));
|
|
168
|
+
console.log(chalk.green("You can access the deployment previews at: ".concat(mcDeploymentPreviewsLink)));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
async function run(options) {
|
|
172
|
+
const applicationConfig = processConfig();
|
|
173
|
+
const localCustomEntityData = applicationConfig.data;
|
|
174
|
+
const _applicationConfig$en = applicationConfig.env,
|
|
175
|
+
mcApiUrl = _applicationConfig$en.mcApiUrl,
|
|
176
|
+
applicationIdentifier = _applicationConfig$en.applicationIdentifier;
|
|
177
|
+
const isCustomView = isCustomViewData(localCustomEntityData);
|
|
178
|
+
console.log("Using Merchant Center environment \"".concat(chalk.green(mcApiUrl), "\"."));
|
|
179
|
+
console.log();
|
|
180
|
+
const isSessionValid = credentialsStorage.isSessionValid(mcApiUrl);
|
|
181
|
+
if (!isSessionValid) {
|
|
182
|
+
throw new Error("You don't have a valid session. Please, run the \"mc-scripts login\" command to authenticate yourself.");
|
|
183
|
+
}
|
|
184
|
+
if (isCustomView) {
|
|
185
|
+
throw new Error('Deployments previews are not supported for Custom Views.');
|
|
186
|
+
}
|
|
187
|
+
await setDeploymentPreview({
|
|
188
|
+
mcApiUrl,
|
|
189
|
+
applicationId: localCustomEntityData.id,
|
|
190
|
+
applicationIdentifier,
|
|
191
|
+
localCustomEntityData,
|
|
192
|
+
isCustomView,
|
|
193
|
+
options
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export { run as default };
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _URL = require('@babel/runtime-corejs3/core-js-stable/url');
|
|
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
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
7
|
+
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
8
|
+
var chalk = require('chalk');
|
|
9
|
+
var prompts = require('prompts');
|
|
10
|
+
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
11
|
+
var credentialsStorage$1 = require('./credentials-storage-44ff9622.cjs.prod.js');
|
|
12
|
+
var graphqlRequests = require('./graphql-requests-cbebcbb8.cjs.prod.js');
|
|
13
|
+
require('@commercetools/http-user-agent');
|
|
14
|
+
require('./package-218d42f5.cjs.prod.js');
|
|
15
|
+
require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
16
|
+
require('@babel/runtime-corejs3/helpers/createClass');
|
|
17
|
+
require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
18
|
+
require('@babel/runtime-corejs3/core-js-stable/date/now');
|
|
19
|
+
require('fs');
|
|
20
|
+
require('os');
|
|
21
|
+
require('path');
|
|
22
|
+
require('./does-file-exist-be53305d.cjs.prod.js');
|
|
23
|
+
require('node:fs');
|
|
24
|
+
require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
25
|
+
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
26
|
+
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
27
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
28
|
+
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
29
|
+
require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
30
|
+
require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
31
|
+
require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
32
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
33
|
+
require('graphql');
|
|
34
|
+
require('graphql-request');
|
|
35
|
+
require('@commercetools-frontend/constants');
|
|
36
|
+
|
|
37
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
38
|
+
|
|
39
|
+
var _URL__default = /*#__PURE__*/_interopDefault(_URL);
|
|
40
|
+
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
41
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
42
|
+
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
43
|
+
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
44
|
+
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
45
|
+
var prompts__default = /*#__PURE__*/_interopDefault(prompts);
|
|
46
|
+
|
|
47
|
+
const credentialsStorage = new credentialsStorage$1.CredentialsStorage();
|
|
48
|
+
const validateUrl = function () {
|
|
49
|
+
let url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
50
|
+
try {
|
|
51
|
+
var _context;
|
|
52
|
+
const urlSchema = new _URL__default["default"](url);
|
|
53
|
+
return _includesInstanceProperty__default["default"](_context = ['http:', 'https:']).call(_context, urlSchema.protocol);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const validateAlias = function () {
|
|
59
|
+
let alias = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
60
|
+
try {
|
|
61
|
+
new _URL__default["default"]("https://".concat(alias, ".commercetools.com/"));
|
|
62
|
+
return true;
|
|
63
|
+
} catch (error) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const getMcUrlLink = _ref => {
|
|
68
|
+
var _context2, _context3, _context4;
|
|
69
|
+
let mcApiUrl = _ref.mcApiUrl,
|
|
70
|
+
organizationId = _ref.organizationId,
|
|
71
|
+
customEntityId = _ref.customEntityId,
|
|
72
|
+
isCustomView = _ref.isCustomView;
|
|
73
|
+
const mcUrl = mcApiUrl.replace('mc-api', 'mc');
|
|
74
|
+
const customEntityLink = _concatInstanceProperty__default["default"](_context2 = _concatInstanceProperty__default["default"](_context3 = _concatInstanceProperty__default["default"](_context4 = "".concat(mcUrl, "/account/organizations/")).call(_context4, organizationId, "/custom-")).call(_context3, isCustomView ? 'views' : 'applications', "/owned/")).call(_context2, customEntityId, "/deployment-previews");
|
|
75
|
+
return customEntityLink;
|
|
76
|
+
};
|
|
77
|
+
const isCustomViewData = data => data.entryPointUriPath === undefined;
|
|
78
|
+
async function setDeploymentPreview(_ref2) {
|
|
79
|
+
var _context6;
|
|
80
|
+
let mcApiUrl = _ref2.mcApiUrl,
|
|
81
|
+
applicationId = _ref2.applicationId,
|
|
82
|
+
applicationIdentifier = _ref2.applicationIdentifier,
|
|
83
|
+
localCustomEntityData = _ref2.localCustomEntityData,
|
|
84
|
+
isCustomView = _ref2.isCustomView,
|
|
85
|
+
options = _ref2.options;
|
|
86
|
+
/*
|
|
87
|
+
1. Check if the Custom Application exists in the Merchant Center.
|
|
88
|
+
2. Ask for the alias and URL of the deployment preview.
|
|
89
|
+
3. Check whether it exists a deployment preview with the same alias.
|
|
90
|
+
4. If it exists, ask for confirmation to update it.
|
|
91
|
+
5. If it doesn't exist, ask for confirmation to create it.
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
const fetchedCustomApplication = await graphqlRequests.fetchCustomApplication({
|
|
95
|
+
mcApiUrl,
|
|
96
|
+
entryPointUriPath: localCustomEntityData.entryPointUriPath,
|
|
97
|
+
applicationIdentifier
|
|
98
|
+
});
|
|
99
|
+
if (!fetchedCustomApplication) {
|
|
100
|
+
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."));
|
|
101
|
+
}
|
|
102
|
+
let deploymentAlias = options.alias;
|
|
103
|
+
// If the alias was not provided as an argument to the script, let's ask for it.
|
|
104
|
+
if (!deploymentAlias) {
|
|
105
|
+
var _context5;
|
|
106
|
+
const _await$prompts = await prompts__default["default"]({
|
|
107
|
+
type: 'text',
|
|
108
|
+
name: 'alias',
|
|
109
|
+
message: _filterInstanceProperty__default["default"](_context5 = ["Enter the alias for the deployment preview", options.dryRun && chalk__default["default"].gray('Using "--dry-run", no deployment preview will be created.')]).call(_context5, Boolean).join('\n'),
|
|
110
|
+
validate: value => validateAlias(value)
|
|
111
|
+
}),
|
|
112
|
+
alias = _await$prompts.alias;
|
|
113
|
+
deploymentAlias = alias;
|
|
114
|
+
}
|
|
115
|
+
const existingDeploymentPreview = _findInstanceProperty__default["default"](_context6 = fetchedCustomApplication.application.deployments).call(_context6, deployment => deployment.alias === deploymentAlias);
|
|
116
|
+
if (!options.alias && !options.url && existingDeploymentPreview) {
|
|
117
|
+
var _context7;
|
|
118
|
+
const _await$prompts2 = await prompts__default["default"]({
|
|
119
|
+
type: 'confirm',
|
|
120
|
+
name: 'aliasOverrideConfirmation',
|
|
121
|
+
message: _filterInstanceProperty__default["default"](_context7 = ["The alias \"".concat(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(_context7, Boolean).join('\n'),
|
|
122
|
+
initial: false
|
|
123
|
+
}),
|
|
124
|
+
aliasOverrideConfirmation = _await$prompts2.aliasOverrideConfirmation;
|
|
125
|
+
if (!aliasOverrideConfirmation) {
|
|
126
|
+
console.log(chalk__default["default"].red('Aborted.'));
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
let deploymentUrl = options.url;
|
|
131
|
+
if (!deploymentUrl) {
|
|
132
|
+
var _context8;
|
|
133
|
+
const _await$prompts3 = await prompts__default["default"]({
|
|
134
|
+
type: 'text',
|
|
135
|
+
name: 'url',
|
|
136
|
+
message: _filterInstanceProperty__default["default"](_context8 = ["Enter the URL for the deployment preview", options.dryRun && chalk__default["default"].gray('Using "--dry-run", no deployment preview will be created.')]).call(_context8, Boolean).join('\n'),
|
|
137
|
+
validate: value => validateUrl(value)
|
|
138
|
+
}),
|
|
139
|
+
url = _await$prompts3.url;
|
|
140
|
+
deploymentUrl = url;
|
|
141
|
+
}
|
|
142
|
+
if (options.dryRun) {
|
|
143
|
+
var _context9, _context10;
|
|
144
|
+
const message = existingDeploymentPreview ? _concatInstanceProperty__default["default"](_context9 = "The existing deployment preview with alias \"".concat(deploymentAlias, "\" would have been updated with this url: \"")).call(_context9, deploymentUrl, "\".") : _concatInstanceProperty__default["default"](_context10 = "A new deployment preview with alias \"".concat(deploymentAlias, "\" would have been created with this url: \"")).call(_context10, deploymentUrl, "\".");
|
|
145
|
+
console.log("\n".concat(message, "\n"));
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const mcDeploymentPreviewsLink = getMcUrlLink({
|
|
149
|
+
mcApiUrl,
|
|
150
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
151
|
+
customEntityId: fetchedCustomApplication.application.id,
|
|
152
|
+
isCustomView
|
|
153
|
+
});
|
|
154
|
+
if (existingDeploymentPreview) {
|
|
155
|
+
var _context11;
|
|
156
|
+
await graphqlRequests.updateCustomApplicationDeploymentPreview({
|
|
157
|
+
mcApiUrl,
|
|
158
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
159
|
+
applicationIdentifier,
|
|
160
|
+
deploymentId: existingDeploymentPreview.id,
|
|
161
|
+
data: {
|
|
162
|
+
url: deploymentUrl
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
console.log(chalk__default["default"].green(_concatInstanceProperty__default["default"](_context11 = "Deployment preview with alias \"".concat(deploymentAlias, "\" updated successfully with URL \"")).call(_context11, deploymentUrl, "\".")));
|
|
166
|
+
console.log(chalk__default["default"].green("You can access the deployment previews at: ".concat(mcDeploymentPreviewsLink)));
|
|
167
|
+
} else {
|
|
168
|
+
var _context12;
|
|
169
|
+
await graphqlRequests.createCustomApplicationDeploymentPreview({
|
|
170
|
+
mcApiUrl,
|
|
171
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
172
|
+
applicationIdentifier,
|
|
173
|
+
applicationId,
|
|
174
|
+
data: {
|
|
175
|
+
alias: deploymentAlias,
|
|
176
|
+
url: deploymentUrl
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
console.log(chalk__default["default"].green(_concatInstanceProperty__default["default"](_context12 = "Deployment preview with alias \"".concat(deploymentAlias, "\" created successfully with URL \"")).call(_context12, deploymentUrl, "\".")));
|
|
180
|
+
console.log(chalk__default["default"].green("You can access the deployment previews at: ".concat(mcDeploymentPreviewsLink)));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async function run(options) {
|
|
184
|
+
const applicationConfig$1 = applicationConfig.processConfig();
|
|
185
|
+
const localCustomEntityData = applicationConfig$1.data;
|
|
186
|
+
const _applicationConfig$en = applicationConfig$1.env,
|
|
187
|
+
mcApiUrl = _applicationConfig$en.mcApiUrl,
|
|
188
|
+
applicationIdentifier = _applicationConfig$en.applicationIdentifier;
|
|
189
|
+
const isCustomView = isCustomViewData(localCustomEntityData);
|
|
190
|
+
console.log("Using Merchant Center environment \"".concat(chalk__default["default"].green(mcApiUrl), "\"."));
|
|
191
|
+
console.log();
|
|
192
|
+
const isSessionValid = credentialsStorage.isSessionValid(mcApiUrl);
|
|
193
|
+
if (!isSessionValid) {
|
|
194
|
+
throw new Error("You don't have a valid session. Please, run the \"mc-scripts login\" command to authenticate yourself.");
|
|
195
|
+
}
|
|
196
|
+
if (isCustomView) {
|
|
197
|
+
throw new Error('Deployments previews are not supported for Custom Views.');
|
|
198
|
+
}
|
|
199
|
+
await setDeploymentPreview({
|
|
200
|
+
mcApiUrl,
|
|
201
|
+
applicationId: localCustomEntityData.id,
|
|
202
|
+
applicationIdentifier,
|
|
203
|
+
localCustomEntityData,
|
|
204
|
+
isCustomView,
|
|
205
|
+
options
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
exports["default"] = run;
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _URL = require('@babel/runtime-corejs3/core-js-stable/url');
|
|
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
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
7
|
+
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
8
|
+
var chalk = require('chalk');
|
|
9
|
+
var prompts = require('prompts');
|
|
10
|
+
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
11
|
+
var credentialsStorage$1 = require('./credentials-storage-1552e722.cjs.dev.js');
|
|
12
|
+
var graphqlRequests = require('./graphql-requests-2a72a4f1.cjs.dev.js');
|
|
13
|
+
require('@commercetools/http-user-agent');
|
|
14
|
+
require('./package-dc01b1e0.cjs.dev.js');
|
|
15
|
+
require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
16
|
+
require('@babel/runtime-corejs3/helpers/createClass');
|
|
17
|
+
require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
18
|
+
require('@babel/runtime-corejs3/core-js-stable/date/now');
|
|
19
|
+
require('fs');
|
|
20
|
+
require('os');
|
|
21
|
+
require('path');
|
|
22
|
+
require('./does-file-exist-eb86baca.cjs.dev.js');
|
|
23
|
+
require('node:fs');
|
|
24
|
+
require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
25
|
+
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
26
|
+
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
27
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
28
|
+
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
29
|
+
require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
30
|
+
require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
31
|
+
require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
32
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
33
|
+
require('graphql');
|
|
34
|
+
require('graphql-request');
|
|
35
|
+
require('@commercetools-frontend/constants');
|
|
36
|
+
|
|
37
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
38
|
+
|
|
39
|
+
var _URL__default = /*#__PURE__*/_interopDefault(_URL);
|
|
40
|
+
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
41
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
42
|
+
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
43
|
+
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
44
|
+
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
45
|
+
var prompts__default = /*#__PURE__*/_interopDefault(prompts);
|
|
46
|
+
|
|
47
|
+
const credentialsStorage = new credentialsStorage$1.CredentialsStorage();
|
|
48
|
+
const validateUrl = function () {
|
|
49
|
+
let url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
50
|
+
try {
|
|
51
|
+
var _context;
|
|
52
|
+
const urlSchema = new _URL__default["default"](url);
|
|
53
|
+
return _includesInstanceProperty__default["default"](_context = ['http:', 'https:']).call(_context, urlSchema.protocol);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const validateAlias = function () {
|
|
59
|
+
let alias = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
60
|
+
try {
|
|
61
|
+
new _URL__default["default"]("https://".concat(alias, ".commercetools.com/"));
|
|
62
|
+
return true;
|
|
63
|
+
} catch (error) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const getMcUrlLink = _ref => {
|
|
68
|
+
var _context2, _context3, _context4;
|
|
69
|
+
let mcApiUrl = _ref.mcApiUrl,
|
|
70
|
+
organizationId = _ref.organizationId,
|
|
71
|
+
customEntityId = _ref.customEntityId,
|
|
72
|
+
isCustomView = _ref.isCustomView;
|
|
73
|
+
const mcUrl = mcApiUrl.replace('mc-api', 'mc');
|
|
74
|
+
const customEntityLink = _concatInstanceProperty__default["default"](_context2 = _concatInstanceProperty__default["default"](_context3 = _concatInstanceProperty__default["default"](_context4 = "".concat(mcUrl, "/account/organizations/")).call(_context4, organizationId, "/custom-")).call(_context3, isCustomView ? 'views' : 'applications', "/owned/")).call(_context2, customEntityId, "/deployment-previews");
|
|
75
|
+
return customEntityLink;
|
|
76
|
+
};
|
|
77
|
+
const isCustomViewData = data => data.entryPointUriPath === undefined;
|
|
78
|
+
async function setDeploymentPreview(_ref2) {
|
|
79
|
+
var _context6;
|
|
80
|
+
let mcApiUrl = _ref2.mcApiUrl,
|
|
81
|
+
applicationId = _ref2.applicationId,
|
|
82
|
+
applicationIdentifier = _ref2.applicationIdentifier,
|
|
83
|
+
localCustomEntityData = _ref2.localCustomEntityData,
|
|
84
|
+
isCustomView = _ref2.isCustomView,
|
|
85
|
+
options = _ref2.options;
|
|
86
|
+
/*
|
|
87
|
+
1. Check if the Custom Application exists in the Merchant Center.
|
|
88
|
+
2. Ask for the alias and URL of the deployment preview.
|
|
89
|
+
3. Check whether it exists a deployment preview with the same alias.
|
|
90
|
+
4. If it exists, ask for confirmation to update it.
|
|
91
|
+
5. If it doesn't exist, ask for confirmation to create it.
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
const fetchedCustomApplication = await graphqlRequests.fetchCustomApplication({
|
|
95
|
+
mcApiUrl,
|
|
96
|
+
entryPointUriPath: localCustomEntityData.entryPointUriPath,
|
|
97
|
+
applicationIdentifier
|
|
98
|
+
});
|
|
99
|
+
if (!fetchedCustomApplication) {
|
|
100
|
+
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."));
|
|
101
|
+
}
|
|
102
|
+
let deploymentAlias = options.alias;
|
|
103
|
+
// If the alias was not provided as an argument to the script, let's ask for it.
|
|
104
|
+
if (!deploymentAlias) {
|
|
105
|
+
var _context5;
|
|
106
|
+
const _await$prompts = await prompts__default["default"]({
|
|
107
|
+
type: 'text',
|
|
108
|
+
name: 'alias',
|
|
109
|
+
message: _filterInstanceProperty__default["default"](_context5 = ["Enter the alias for the deployment preview", options.dryRun && chalk__default["default"].gray('Using "--dry-run", no deployment preview will be created.')]).call(_context5, Boolean).join('\n'),
|
|
110
|
+
validate: value => validateAlias(value)
|
|
111
|
+
}),
|
|
112
|
+
alias = _await$prompts.alias;
|
|
113
|
+
deploymentAlias = alias;
|
|
114
|
+
}
|
|
115
|
+
const existingDeploymentPreview = _findInstanceProperty__default["default"](_context6 = fetchedCustomApplication.application.deployments).call(_context6, deployment => deployment.alias === deploymentAlias);
|
|
116
|
+
if (!options.alias && !options.url && existingDeploymentPreview) {
|
|
117
|
+
var _context7;
|
|
118
|
+
const _await$prompts2 = await prompts__default["default"]({
|
|
119
|
+
type: 'confirm',
|
|
120
|
+
name: 'aliasOverrideConfirmation',
|
|
121
|
+
message: _filterInstanceProperty__default["default"](_context7 = ["The alias \"".concat(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(_context7, Boolean).join('\n'),
|
|
122
|
+
initial: false
|
|
123
|
+
}),
|
|
124
|
+
aliasOverrideConfirmation = _await$prompts2.aliasOverrideConfirmation;
|
|
125
|
+
if (!aliasOverrideConfirmation) {
|
|
126
|
+
console.log(chalk__default["default"].red('Aborted.'));
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
let deploymentUrl = options.url;
|
|
131
|
+
if (!deploymentUrl) {
|
|
132
|
+
var _context8;
|
|
133
|
+
const _await$prompts3 = await prompts__default["default"]({
|
|
134
|
+
type: 'text',
|
|
135
|
+
name: 'url',
|
|
136
|
+
message: _filterInstanceProperty__default["default"](_context8 = ["Enter the URL for the deployment preview", options.dryRun && chalk__default["default"].gray('Using "--dry-run", no deployment preview will be created.')]).call(_context8, Boolean).join('\n'),
|
|
137
|
+
validate: value => validateUrl(value)
|
|
138
|
+
}),
|
|
139
|
+
url = _await$prompts3.url;
|
|
140
|
+
deploymentUrl = url;
|
|
141
|
+
}
|
|
142
|
+
if (options.dryRun) {
|
|
143
|
+
var _context9, _context10;
|
|
144
|
+
const message = existingDeploymentPreview ? _concatInstanceProperty__default["default"](_context9 = "The existing deployment preview with alias \"".concat(deploymentAlias, "\" would have been updated with this url: \"")).call(_context9, deploymentUrl, "\".") : _concatInstanceProperty__default["default"](_context10 = "A new deployment preview with alias \"".concat(deploymentAlias, "\" would have been created with this url: \"")).call(_context10, deploymentUrl, "\".");
|
|
145
|
+
console.log("\n".concat(message, "\n"));
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const mcDeploymentPreviewsLink = getMcUrlLink({
|
|
149
|
+
mcApiUrl,
|
|
150
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
151
|
+
customEntityId: fetchedCustomApplication.application.id,
|
|
152
|
+
isCustomView
|
|
153
|
+
});
|
|
154
|
+
if (existingDeploymentPreview) {
|
|
155
|
+
var _context11;
|
|
156
|
+
await graphqlRequests.updateCustomApplicationDeploymentPreview({
|
|
157
|
+
mcApiUrl,
|
|
158
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
159
|
+
applicationIdentifier,
|
|
160
|
+
deploymentId: existingDeploymentPreview.id,
|
|
161
|
+
data: {
|
|
162
|
+
url: deploymentUrl
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
console.log(chalk__default["default"].green(_concatInstanceProperty__default["default"](_context11 = "Deployment preview with alias \"".concat(deploymentAlias, "\" updated successfully with URL \"")).call(_context11, deploymentUrl, "\".")));
|
|
166
|
+
console.log(chalk__default["default"].green("You can access the deployment previews at: ".concat(mcDeploymentPreviewsLink)));
|
|
167
|
+
} else {
|
|
168
|
+
var _context12;
|
|
169
|
+
await graphqlRequests.createCustomApplicationDeploymentPreview({
|
|
170
|
+
mcApiUrl,
|
|
171
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
172
|
+
applicationIdentifier,
|
|
173
|
+
applicationId,
|
|
174
|
+
data: {
|
|
175
|
+
alias: deploymentAlias,
|
|
176
|
+
url: deploymentUrl
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
console.log(chalk__default["default"].green(_concatInstanceProperty__default["default"](_context12 = "Deployment preview with alias \"".concat(deploymentAlias, "\" created successfully with URL \"")).call(_context12, deploymentUrl, "\".")));
|
|
180
|
+
console.log(chalk__default["default"].green("You can access the deployment previews at: ".concat(mcDeploymentPreviewsLink)));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async function run(options) {
|
|
184
|
+
const applicationConfig$1 = applicationConfig.processConfig();
|
|
185
|
+
const localCustomEntityData = applicationConfig$1.data;
|
|
186
|
+
const _applicationConfig$en = applicationConfig$1.env,
|
|
187
|
+
mcApiUrl = _applicationConfig$en.mcApiUrl,
|
|
188
|
+
applicationIdentifier = _applicationConfig$en.applicationIdentifier;
|
|
189
|
+
const isCustomView = isCustomViewData(localCustomEntityData);
|
|
190
|
+
console.log("Using Merchant Center environment \"".concat(chalk__default["default"].green(mcApiUrl), "\"."));
|
|
191
|
+
console.log();
|
|
192
|
+
const isSessionValid = credentialsStorage.isSessionValid(mcApiUrl);
|
|
193
|
+
if (!isSessionValid) {
|
|
194
|
+
throw new Error("You don't have a valid session. Please, run the \"mc-scripts login\" command to authenticate yourself.");
|
|
195
|
+
}
|
|
196
|
+
if (isCustomView) {
|
|
197
|
+
throw new Error('Deployments previews are not supported for Custom Views.');
|
|
198
|
+
}
|
|
199
|
+
await setDeploymentPreview({
|
|
200
|
+
mcApiUrl,
|
|
201
|
+
applicationId: localCustomEntityData.id,
|
|
202
|
+
applicationIdentifier,
|
|
203
|
+
localCustomEntityData,
|
|
204
|
+
isCustomView,
|
|
205
|
+
options
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
exports["default"] = run;
|