@commercetools-frontend/mc-scripts 0.0.0-CRAFT-1791-20251006162610
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/LICENSE +21 -0
- package/README.md +7 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.d.ts +2 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.dev.js +7 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.js +7 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js +7 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.esm.js +5 -0
- package/application-runtime/package.json +4 -0
- package/bin/cli.js +8 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.d.ts +2 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +199 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.js +7 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +199 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +184 -0
- package/cli/package.json +4 -0
- package/config/create-webpack-config-for-development.js +8 -0
- package/config/create-webpack-config-for-production.js +8 -0
- package/config/vendors-to-transpile.js +6 -0
- package/dist/build-2a0a18bd.esm.js +155 -0
- package/dist/build-521f3f9f.cjs.prod.js +169 -0
- package/dist/build-988fc0f7.cjs.dev.js +169 -0
- package/dist/build-vite-16b1a575.cjs.dev.js +238 -0
- package/dist/build-vite-59e1f185.esm.js +208 -0
- package/dist/build-vite-5d317720.cjs.prod.js +238 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.d.ts +2 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +29 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.js +7 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +29 -0
- package/dist/commercetools-frontend-mc-scripts.esm.js +21 -0
- package/dist/compile-html-025cd493.esm.js +34 -0
- package/dist/compile-html-50fd05ec.cjs.prod.js +42 -0
- package/dist/compile-html-f4ac88cc.cjs.dev.js +42 -0
- package/dist/config-sync-70a16916.cjs.dev.js +852 -0
- package/dist/config-sync-72c20d80.cjs.prod.js +846 -0
- package/dist/config-sync-bc895390.esm.js +830 -0
- package/dist/create-postcss-config-cb7be312.cjs.dev.js +81 -0
- package/dist/create-postcss-config-dde0ccf1.esm.js +75 -0
- package/dist/create-postcss-config-edca0c33.cjs.prod.js +81 -0
- package/dist/create-webpack-config-for-development-1aed1cc0.cjs.prod.js +465 -0
- package/dist/create-webpack-config-for-development-a95f3634.esm.js +440 -0
- package/dist/create-webpack-config-for-development-d003697b.cjs.dev.js +465 -0
- package/dist/create-webpack-config-for-production-15fbe7db.cjs.dev.js +523 -0
- package/dist/create-webpack-config-for-production-764c482f.cjs.prod.js +523 -0
- package/dist/create-webpack-config-for-production-9f42c336.esm.js +493 -0
- package/dist/credentials-storage-66c1e51f.cjs.prod.js +95 -0
- package/dist/credentials-storage-d001f726.esm.js +83 -0
- package/dist/credentials-storage-e7884d17.cjs.dev.js +95 -0
- package/dist/declarations/src/application-runtime.d.ts +1 -0
- package/dist/declarations/src/cli.d.ts +4 -0
- package/dist/declarations/src/config/create-postcss-config.d.ts +4 -0
- package/dist/declarations/src/config/create-webpack-config-for-development.d.ts +10 -0
- package/dist/declarations/src/config/create-webpack-config-for-production.d.ts +10 -0
- package/dist/declarations/src/config/vendors-to-transpile.d.ts +2 -0
- package/dist/declarations/src/deprecated-entry-points.d.ts +7 -0
- package/dist/declarations/src/index.d.ts +3 -0
- package/dist/declarations/src/postcss.d.ts +1 -0
- package/dist/declarations/src/types.d.ts +94 -0
- package/dist/declarations/src/version.d.ts +2 -0
- package/dist/declarations/src/webpack-loaders/i18n-message-compilation-loader.d.ts +3 -0
- package/dist/declarations/src/webpack.d.ts +2 -0
- package/dist/deployment-previews-set-17e8ed48.cjs.prod.js +202 -0
- package/dist/deployment-previews-set-3648972f.esm.js +191 -0
- package/dist/deployment-previews-set-37aef990.cjs.dev.js +202 -0
- package/dist/does-file-exist-32618334.esm.js +12 -0
- package/dist/does-file-exist-be53305d.cjs.prod.js +18 -0
- package/dist/does-file-exist-eb86baca.cjs.dev.js +18 -0
- package/dist/graphql-requests-6a47ad5b.esm.js +247 -0
- package/dist/graphql-requests-779b867b.cjs.dev.js +270 -0
- package/dist/graphql-requests-8086eba7.cjs.prod.js +270 -0
- package/dist/has-jsx-runtime-aa5d21ee.cjs.dev.js +15 -0
- package/dist/has-jsx-runtime-c3202df5.cjs.prod.js +15 -0
- package/dist/has-jsx-runtime-e3ecb09b.esm.js +13 -0
- package/dist/i18n-message-complilation-21d3b0aa.esm.js +15 -0
- package/dist/i18n-message-complilation-7311cb29.cjs.dev.js +23 -0
- package/dist/i18n-message-complilation-7762da61.cjs.prod.js +23 -0
- package/dist/login-0a728449.esm.js +229 -0
- package/dist/login-817a5a26.cjs.dev.js +270 -0
- package/dist/login-85c25393.cjs.prod.js +270 -0
- package/dist/optimizations-7789145e.cjs.dev.js +85 -0
- package/dist/optimizations-bf991634.esm.js +67 -0
- package/dist/optimizations-fb93514f.cjs.prod.js +85 -0
- package/dist/package-7e170dc4.cjs.dev.js +160 -0
- package/dist/package-940b0a2a.cjs.prod.js +160 -0
- package/dist/package-99e547a7.esm.js +158 -0
- package/dist/paths-39f22b8b.esm.js +36 -0
- package/dist/paths-7768b440.cjs.prod.js +44 -0
- package/dist/paths-b76fc753.cjs.dev.js +44 -0
- package/dist/serve-1036c2de.esm.js +55 -0
- package/dist/serve-50d33f0b.cjs.dev.js +64 -0
- package/dist/serve-8a506da6.cjs.prod.js +64 -0
- package/dist/start-1d677ad8.cjs.dev.js +177 -0
- package/dist/start-2a7ae03d.esm.js +164 -0
- package/dist/start-f56cb5f7.cjs.prod.js +177 -0
- package/dist/start-vite-068e9f73.cjs.dev.js +128 -0
- package/dist/start-vite-29078b3a.cjs.prod.js +128 -0
- package/dist/start-vite-7d1161e8.esm.js +116 -0
- package/dist/vendors-to-transpile-04a49d40.cjs.prod.js +5 -0
- package/dist/vendors-to-transpile-6ab4ea06.cjs.dev.js +5 -0
- package/dist/vendors-to-transpile-7dc84a72.esm.js +3 -0
- package/dist/vite-plugin-svgr-4034a834.cjs.prod.js +151 -0
- package/dist/vite-plugin-svgr-7d06f400.cjs.dev.js +151 -0
- package/dist/vite-plugin-svgr-de6ee7da.esm.js +125 -0
- package/package.json +156 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.d.ts +2 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +12 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.js +7 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +12 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +4 -0
- package/postcss/package.json +4 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.d.ts +2 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +57 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.js +7 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +57 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +48 -0
- package/webpack/package.json +4 -0
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.d.ts +3 -0
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.dev.js +30 -0
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.js +7 -0
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.prod.js +30 -0
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.esm.js +26 -0
- package/webpack-loaders/i18n-message-compilation-loader/package.json +4 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var createHttpUserAgent = require('@commercetools/http-user-agent');
|
|
4
|
+
var _package = require('./package-7e170dc4.cjs.dev.js');
|
|
5
|
+
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
6
|
+
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
7
|
+
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
8
|
+
var _Date$now = require('@babel/runtime-corejs3/core-js-stable/date/now');
|
|
9
|
+
var fs = require('node:fs');
|
|
10
|
+
var os = require('node:os');
|
|
11
|
+
var path = require('node:path');
|
|
12
|
+
var doesFileExist = require('./does-file-exist-eb86baca.cjs.dev.js');
|
|
13
|
+
|
|
14
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
15
|
+
|
|
16
|
+
var createHttpUserAgent__default = /*#__PURE__*/_interopDefault(createHttpUserAgent);
|
|
17
|
+
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
18
|
+
var _Date$now__default = /*#__PURE__*/_interopDefault(_Date$now);
|
|
19
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
20
|
+
var os__default = /*#__PURE__*/_interopDefault(os);
|
|
21
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
22
|
+
|
|
23
|
+
const userAgent = createHttpUserAgent__default["default"]({
|
|
24
|
+
name: 'graphql-request',
|
|
25
|
+
libraryName: 'mc-scripts',
|
|
26
|
+
libraryVersion: _package.pkgJson.version,
|
|
27
|
+
contactUrl: 'https://git.io/fjuyC',
|
|
28
|
+
// points to the appkit repo issues
|
|
29
|
+
contactEmail: 'support@commercetools.com'
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
let CredentialsStorage = /*#__PURE__*/function () {
|
|
33
|
+
function CredentialsStorage() {
|
|
34
|
+
_classCallCheck(this, CredentialsStorage);
|
|
35
|
+
this.credentialsFilePath = void 0;
|
|
36
|
+
const homedir = os__default["default"].homedir();
|
|
37
|
+
const credentialsFolderPath = path__default["default"].join(homedir, `.commercetools`);
|
|
38
|
+
this.credentialsFilePath = path__default["default"].join(credentialsFolderPath, 'mc-credentials.json');
|
|
39
|
+
|
|
40
|
+
// Ensure the credentials file is present
|
|
41
|
+
if (!doesFileExist.doesFileExist(this.credentialsFilePath)) {
|
|
42
|
+
fs__default["default"].mkdirSync(credentialsFolderPath, {
|
|
43
|
+
recursive: true
|
|
44
|
+
});
|
|
45
|
+
// Initialize with an empty object
|
|
46
|
+
this._writeCredentials();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return _createClass(CredentialsStorage, [{
|
|
50
|
+
key: "_writeCredentials",
|
|
51
|
+
value: function _writeCredentials(credentials) {
|
|
52
|
+
fs__default["default"].writeFileSync(this.credentialsFilePath, _JSON$stringify__default["default"](credentials || {}, null, 2), {
|
|
53
|
+
encoding: 'utf8'
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}, {
|
|
57
|
+
key: "_loadCredentials",
|
|
58
|
+
value: function _loadCredentials() {
|
|
59
|
+
const data = fs__default["default"].readFileSync(this.credentialsFilePath, {
|
|
60
|
+
encoding: 'utf8'
|
|
61
|
+
});
|
|
62
|
+
return JSON.parse(data);
|
|
63
|
+
}
|
|
64
|
+
}, {
|
|
65
|
+
key: "getToken",
|
|
66
|
+
value: function getToken(environmentKey) {
|
|
67
|
+
const allCredentials = this._loadCredentials();
|
|
68
|
+
if (!this.isSessionValid(environmentKey)) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
return allCredentials[environmentKey].token;
|
|
72
|
+
}
|
|
73
|
+
}, {
|
|
74
|
+
key: "setToken",
|
|
75
|
+
value: function setToken(environmentKey, credentials) {
|
|
76
|
+
const allCredentials = this._loadCredentials();
|
|
77
|
+
allCredentials[environmentKey] = credentials;
|
|
78
|
+
this._writeCredentials(allCredentials);
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
81
|
+
key: "isSessionValid",
|
|
82
|
+
value: function isSessionValid(environmentKey) {
|
|
83
|
+
const allCredentials = this._loadCredentials();
|
|
84
|
+
const credentials = allCredentials[environmentKey];
|
|
85
|
+
if (!credentials) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
const now = Math.floor(_Date$now__default["default"]() / 1000);
|
|
89
|
+
return now < credentials.expiresAt;
|
|
90
|
+
}
|
|
91
|
+
}]);
|
|
92
|
+
}();
|
|
93
|
+
|
|
94
|
+
exports.CredentialsStorage = CredentialsStorage;
|
|
95
|
+
exports.userAgent = userAgent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Config } from 'postcss-load-config';
|
|
2
|
+
import type { TPostcssConfigOptions } from "../types.js";
|
|
3
|
+
declare function createPostcssConfig({ postcssImportPaths, postcssCustomMediaPaths, postcssCustomPropertiesPaths, }?: TPostcssConfigOptions): Config;
|
|
4
|
+
export default createPostcssConfig;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Configuration } from 'webpack';
|
|
2
|
+
import type { TWebpackConfigOptions } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* This is a factory function to create the default webpack config
|
|
5
|
+
* for a MC Application in `development` mode.
|
|
6
|
+
* The function requires the file path to the related application
|
|
7
|
+
* "entry point".
|
|
8
|
+
*/
|
|
9
|
+
declare function createWebpackConfigForDevelopment(options?: TWebpackConfigOptions<'development'>): Configuration;
|
|
10
|
+
export default createWebpackConfigForDevelopment;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Configuration } from 'webpack';
|
|
2
|
+
import type { TWebpackConfigOptions } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* This is a factory function to create the default webpack config
|
|
5
|
+
* for a MC Application in `production` mode.
|
|
6
|
+
* The function requires the file path to the related application
|
|
7
|
+
* "entry point".
|
|
8
|
+
*/
|
|
9
|
+
declare function createWebpackConfigForProduction(options?: TWebpackConfigOptions<'production'>): Configuration;
|
|
10
|
+
export default createWebpackConfigForProduction;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Config } from 'postcss-load-config';
|
|
2
|
+
import type { Configuration } from 'webpack';
|
|
3
|
+
import type { TWebpackConfigOptions, TPostcssConfigOptions } from "./types.js";
|
|
4
|
+
declare function createWebpackConfigForDevelopment(options?: TWebpackConfigOptions<'development'>): Configuration;
|
|
5
|
+
declare function createWebpackConfigForProduction(options?: TWebpackConfigOptions<'production'>): Configuration;
|
|
6
|
+
declare function createPostcssConfig(options?: TPostcssConfigOptions): Config;
|
|
7
|
+
export { createWebpackConfigForDevelopment, createWebpackConfigForProduction, createPostcssConfig, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as createPostcssConfig } from "./config/create-postcss-config.js";
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export type TCliGlobalOptions = {
|
|
2
|
+
env?: string[];
|
|
3
|
+
};
|
|
4
|
+
export type TCliCommandBuildOptions = {
|
|
5
|
+
buildOnly: boolean;
|
|
6
|
+
};
|
|
7
|
+
export type TCliCommandCompileHtmlOptions = {
|
|
8
|
+
transformer?: string;
|
|
9
|
+
printSecurityHeaders: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type TCliCommandConfigSyncOptions = {
|
|
12
|
+
dryRun: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type TCliCommandSetDeploymentPreviewOptions = {
|
|
15
|
+
alias?: string;
|
|
16
|
+
url?: string;
|
|
17
|
+
dryRun?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export type TMcCliAuthToken = {
|
|
20
|
+
token: string;
|
|
21
|
+
expiresAt: number;
|
|
22
|
+
};
|
|
23
|
+
export type TMcCliCredentialsStorage = Record<string, TMcCliAuthToken>;
|
|
24
|
+
/**
|
|
25
|
+
* Configuration options to extend the default configuration
|
|
26
|
+
*/
|
|
27
|
+
export type TPostcssConfigOptions = {
|
|
28
|
+
/**
|
|
29
|
+
* A list of paths where to look for files used by the `@import` statements.
|
|
30
|
+
*/
|
|
31
|
+
postcssImportPaths?: string[];
|
|
32
|
+
/**
|
|
33
|
+
* A list of paths where to look for files with custom media queries.
|
|
34
|
+
*/
|
|
35
|
+
postcssCustomMediaPaths?: string[];
|
|
36
|
+
/**
|
|
37
|
+
* A list of paths where to look for files with custom properties.
|
|
38
|
+
*/
|
|
39
|
+
postcssCustomPropertiesPaths?: string[];
|
|
40
|
+
};
|
|
41
|
+
export type TWebpackConfigMode = 'development' | 'production';
|
|
42
|
+
export type TWebpackConfigToggleFlagsForDevelopment = {
|
|
43
|
+
/**
|
|
44
|
+
* Allow to disable index.html generation in case it's not necessary (e.g. for Storybook)
|
|
45
|
+
*/
|
|
46
|
+
generateIndexHtml?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Some environemnts do not require `core-js` and can hence disable
|
|
49
|
+
* it explicitely. This will disable `core-js` for `preset-env` and the
|
|
50
|
+
* `plugin-transform-runtime`.
|
|
51
|
+
*/
|
|
52
|
+
disableCoreJs?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Pre-parse default `formatjs` messages into AST
|
|
55
|
+
*/
|
|
56
|
+
i18nAst?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Remove default `formatjs` messages from bundles.
|
|
59
|
+
*/
|
|
60
|
+
i18nRemoveDefaultMessage?: boolean;
|
|
61
|
+
};
|
|
62
|
+
export type TWebpackConfigToggleFlagsForProduction = TWebpackConfigToggleFlagsForDevelopment & {
|
|
63
|
+
/**
|
|
64
|
+
* Allow to disable CSS extraction in case it's not necessary (e.g. for Storybook)
|
|
65
|
+
*/
|
|
66
|
+
enableExtractCss?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Some plugins spawn workers to speed up the build. However this can cause trouble on
|
|
69
|
+
* certain machines local and CI. This flag set to limit or disable any parallelism.
|
|
70
|
+
* Options:
|
|
71
|
+
* `true` to default to the machines number of CPUs
|
|
72
|
+
* `false` to disable any paralelism
|
|
73
|
+
* `int` for a specific number of CPUs
|
|
74
|
+
*/
|
|
75
|
+
parallelism: true;
|
|
76
|
+
};
|
|
77
|
+
export type TWebpackConfigOptions<ConfigMode extends TWebpackConfigMode> = {
|
|
78
|
+
/**
|
|
79
|
+
* The absolute path to the application entry point file.
|
|
80
|
+
*/
|
|
81
|
+
entryPoint?: string;
|
|
82
|
+
/**
|
|
83
|
+
* A list of folders where Webpack should look for source files.
|
|
84
|
+
*/
|
|
85
|
+
sourceFolders?: string[];
|
|
86
|
+
/**
|
|
87
|
+
* Options related to Postcss plugins. See `createPostcssConfig` function.
|
|
88
|
+
*/
|
|
89
|
+
postcssOptions?: TPostcssConfigOptions;
|
|
90
|
+
/**
|
|
91
|
+
* Options to enable/disable certain functionalities of the Webpack config.
|
|
92
|
+
*/
|
|
93
|
+
toggleFlags?: ConfigMode extends 'development' ? TWebpackConfigToggleFlagsForDevelopment : ConfigMode extends 'production' ? TWebpackConfigToggleFlagsForProduction : never;
|
|
94
|
+
};
|
|
@@ -0,0 +1,202 @@
|
|
|
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 _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
6
|
+
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
7
|
+
var chalk = require('chalk');
|
|
8
|
+
var prompts = require('prompts');
|
|
9
|
+
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
10
|
+
var credentialsStorage$1 = require('./credentials-storage-66c1e51f.cjs.prod.js');
|
|
11
|
+
var graphqlRequests = require('./graphql-requests-8086eba7.cjs.prod.js');
|
|
12
|
+
require('@commercetools/http-user-agent');
|
|
13
|
+
require('./package-940b0a2a.cjs.prod.js');
|
|
14
|
+
require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
15
|
+
require('@babel/runtime-corejs3/helpers/createClass');
|
|
16
|
+
require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
17
|
+
require('@babel/runtime-corejs3/core-js-stable/date/now');
|
|
18
|
+
require('node:fs');
|
|
19
|
+
require('node:os');
|
|
20
|
+
require('node:path');
|
|
21
|
+
require('./does-file-exist-be53305d.cjs.prod.js');
|
|
22
|
+
require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
23
|
+
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
24
|
+
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
25
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
26
|
+
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
27
|
+
require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
28
|
+
require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
29
|
+
require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
30
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
31
|
+
require('graphql');
|
|
32
|
+
require('graphql-request');
|
|
33
|
+
require('@commercetools-frontend/constants');
|
|
34
|
+
|
|
35
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
36
|
+
|
|
37
|
+
var _URL__default = /*#__PURE__*/_interopDefault(_URL);
|
|
38
|
+
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
39
|
+
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
40
|
+
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
41
|
+
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
42
|
+
var prompts__default = /*#__PURE__*/_interopDefault(prompts);
|
|
43
|
+
|
|
44
|
+
const credentialsStorage = new credentialsStorage$1.CredentialsStorage();
|
|
45
|
+
const validateUrl = function () {
|
|
46
|
+
let url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
47
|
+
try {
|
|
48
|
+
var _context;
|
|
49
|
+
const urlSchema = new _URL__default["default"](url);
|
|
50
|
+
return _includesInstanceProperty__default["default"](_context = ['http:', 'https:']).call(_context, urlSchema.protocol);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const validateAlias = function () {
|
|
56
|
+
let alias = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
57
|
+
try {
|
|
58
|
+
new _URL__default["default"](`https://${alias}.commercetools.com/`);
|
|
59
|
+
return true;
|
|
60
|
+
} catch (error) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const getMcUrlLink = _ref => {
|
|
65
|
+
let mcApiUrl = _ref.mcApiUrl,
|
|
66
|
+
organizationId = _ref.organizationId,
|
|
67
|
+
customEntityId = _ref.customEntityId,
|
|
68
|
+
isCustomView = _ref.isCustomView;
|
|
69
|
+
const mcUrl = mcApiUrl.replace('mc-api', 'mc');
|
|
70
|
+
const customEntityLink = `${mcUrl}/account/organizations/${organizationId}/custom-${isCustomView ? 'views' : 'applications'}/owned/${customEntityId}/deployment-previews`;
|
|
71
|
+
return customEntityLink;
|
|
72
|
+
};
|
|
73
|
+
const isCustomViewData = data => data.entryPointUriPath === undefined;
|
|
74
|
+
async function setDeploymentPreview(_ref2) {
|
|
75
|
+
var _context3;
|
|
76
|
+
let mcApiUrl = _ref2.mcApiUrl,
|
|
77
|
+
applicationId = _ref2.applicationId,
|
|
78
|
+
applicationIdentifier = _ref2.applicationIdentifier,
|
|
79
|
+
localCustomEntityData = _ref2.localCustomEntityData,
|
|
80
|
+
isCustomView = _ref2.isCustomView,
|
|
81
|
+
options = _ref2.options;
|
|
82
|
+
/*
|
|
83
|
+
1. Check if the Custom Application exists in the Merchant Center.
|
|
84
|
+
2. Ask for the alias and URL of the deployment preview.
|
|
85
|
+
3. Check whether it exists a deployment preview with the same alias.
|
|
86
|
+
4. If it exists, ask for confirmation to update it.
|
|
87
|
+
5. If it doesn't exist, ask for confirmation to create it.
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
const fetchedCustomApplication = await graphqlRequests.fetchCustomApplication({
|
|
91
|
+
mcApiUrl,
|
|
92
|
+
entryPointUriPath: localCustomEntityData.entryPointUriPath,
|
|
93
|
+
applicationIdentifier
|
|
94
|
+
});
|
|
95
|
+
if (!fetchedCustomApplication) {
|
|
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.`);
|
|
97
|
+
}
|
|
98
|
+
let deploymentAlias = options.alias;
|
|
99
|
+
// If the alias was not provided as an argument to the script, let's ask for it.
|
|
100
|
+
if (!deploymentAlias) {
|
|
101
|
+
var _context2;
|
|
102
|
+
const _await$prompts = await prompts__default["default"]({
|
|
103
|
+
type: 'text',
|
|
104
|
+
name: 'alias',
|
|
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'),
|
|
106
|
+
validate: value => validateAlias(value)
|
|
107
|
+
}),
|
|
108
|
+
alias = _await$prompts.alias;
|
|
109
|
+
deploymentAlias = alias;
|
|
110
|
+
}
|
|
111
|
+
const existingDeploymentPreview = _findInstanceProperty__default["default"](_context3 = fetchedCustomApplication.application.deployments).call(_context3, deployment => deployment.alias === deploymentAlias);
|
|
112
|
+
if (!options.alias && !options.url && existingDeploymentPreview) {
|
|
113
|
+
var _context4;
|
|
114
|
+
const _await$prompts2 = await prompts__default["default"]({
|
|
115
|
+
type: 'confirm',
|
|
116
|
+
name: 'aliasOverrideConfirmation',
|
|
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'),
|
|
118
|
+
initial: false
|
|
119
|
+
}),
|
|
120
|
+
aliasOverrideConfirmation = _await$prompts2.aliasOverrideConfirmation;
|
|
121
|
+
if (!aliasOverrideConfirmation) {
|
|
122
|
+
console.log(chalk__default["default"].red('Aborted.'));
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
let deploymentUrl = options.url;
|
|
127
|
+
if (!deploymentUrl) {
|
|
128
|
+
var _context5;
|
|
129
|
+
const _await$prompts3 = await prompts__default["default"]({
|
|
130
|
+
type: 'text',
|
|
131
|
+
name: 'url',
|
|
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'),
|
|
133
|
+
validate: value => validateUrl(value)
|
|
134
|
+
}),
|
|
135
|
+
url = _await$prompts3.url;
|
|
136
|
+
deploymentUrl = url;
|
|
137
|
+
}
|
|
138
|
+
if (options.dryRun) {
|
|
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`);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const mcDeploymentPreviewsLink = getMcUrlLink({
|
|
144
|
+
mcApiUrl,
|
|
145
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
146
|
+
customEntityId: fetchedCustomApplication.application.id,
|
|
147
|
+
isCustomView
|
|
148
|
+
});
|
|
149
|
+
if (existingDeploymentPreview) {
|
|
150
|
+
await graphqlRequests.updateCustomApplicationDeploymentPreview({
|
|
151
|
+
mcApiUrl,
|
|
152
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
153
|
+
applicationIdentifier,
|
|
154
|
+
deploymentId: existingDeploymentPreview.id,
|
|
155
|
+
data: {
|
|
156
|
+
url: deploymentUrl
|
|
157
|
+
}
|
|
158
|
+
});
|
|
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}`));
|
|
161
|
+
} else {
|
|
162
|
+
await graphqlRequests.createCustomApplicationDeploymentPreview({
|
|
163
|
+
mcApiUrl,
|
|
164
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
165
|
+
applicationIdentifier,
|
|
166
|
+
applicationId,
|
|
167
|
+
data: {
|
|
168
|
+
alias: deploymentAlias,
|
|
169
|
+
url: deploymentUrl
|
|
170
|
+
}
|
|
171
|
+
});
|
|
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}`));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
async function run(options) {
|
|
177
|
+
const applicationConfig$1 = await applicationConfig.processConfig();
|
|
178
|
+
const localCustomEntityData = applicationConfig$1.data;
|
|
179
|
+
const _applicationConfig$en = applicationConfig$1.env,
|
|
180
|
+
mcApiUrl = _applicationConfig$en.mcApiUrl,
|
|
181
|
+
applicationIdentifier = _applicationConfig$en.applicationIdentifier;
|
|
182
|
+
const isCustomView = isCustomViewData(localCustomEntityData);
|
|
183
|
+
console.log(`Using Merchant Center environment "${chalk__default["default"].green(mcApiUrl)}".`);
|
|
184
|
+
console.log();
|
|
185
|
+
const isSessionValid = credentialsStorage.isSessionValid(mcApiUrl);
|
|
186
|
+
if (!isSessionValid) {
|
|
187
|
+
throw new Error(`You don't have a valid session. Please, run the "mc-scripts login" command to authenticate yourself.`);
|
|
188
|
+
}
|
|
189
|
+
if (isCustomView) {
|
|
190
|
+
throw new Error('Deployments previews are not supported for Custom Views.');
|
|
191
|
+
}
|
|
192
|
+
await setDeploymentPreview({
|
|
193
|
+
mcApiUrl,
|
|
194
|
+
applicationId: localCustomEntityData.id,
|
|
195
|
+
applicationIdentifier,
|
|
196
|
+
localCustomEntityData,
|
|
197
|
+
isCustomView,
|
|
198
|
+
options
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
exports["default"] = run;
|
|
@@ -0,0 +1,191 @@
|
|
|
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 _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
4
|
+
import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import prompts from 'prompts';
|
|
7
|
+
import { processConfig } from '@commercetools-frontend/application-config';
|
|
8
|
+
import { C as CredentialsStorage } from './credentials-storage-d001f726.esm.js';
|
|
9
|
+
import { f as fetchCustomApplication, g as updateCustomApplicationDeploymentPreview, h as createCustomApplicationDeploymentPreview } from './graphql-requests-6a47ad5b.esm.js';
|
|
10
|
+
import '@commercetools/http-user-agent';
|
|
11
|
+
import './package-99e547a7.esm.js';
|
|
12
|
+
import '@babel/runtime-corejs3/helpers/classCallCheck';
|
|
13
|
+
import '@babel/runtime-corejs3/helpers/createClass';
|
|
14
|
+
import '@babel/runtime-corejs3/core-js-stable/json/stringify';
|
|
15
|
+
import '@babel/runtime-corejs3/core-js-stable/date/now';
|
|
16
|
+
import 'node:fs';
|
|
17
|
+
import 'node:os';
|
|
18
|
+
import 'node:path';
|
|
19
|
+
import './does-file-exist-32618334.esm.js';
|
|
20
|
+
import '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
21
|
+
import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
|
|
22
|
+
import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
|
|
23
|
+
import '@babel/runtime-corejs3/core-js-stable/instance/for-each';
|
|
24
|
+
import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
|
|
25
|
+
import '@babel/runtime-corejs3/core-js-stable/object/define-properties';
|
|
26
|
+
import '@babel/runtime-corejs3/core-js-stable/object/define-property';
|
|
27
|
+
import '@babel/runtime-corejs3/helpers/defineProperty';
|
|
28
|
+
import '@babel/runtime-corejs3/core-js-stable/instance/some';
|
|
29
|
+
import 'graphql';
|
|
30
|
+
import 'graphql-request';
|
|
31
|
+
import '@commercetools-frontend/constants';
|
|
32
|
+
|
|
33
|
+
const credentialsStorage = new CredentialsStorage();
|
|
34
|
+
const validateUrl = function () {
|
|
35
|
+
let url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
36
|
+
try {
|
|
37
|
+
var _context;
|
|
38
|
+
const urlSchema = new _URL(url);
|
|
39
|
+
return _includesInstanceProperty(_context = ['http:', 'https:']).call(_context, urlSchema.protocol);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const validateAlias = function () {
|
|
45
|
+
let alias = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
46
|
+
try {
|
|
47
|
+
new _URL(`https://${alias}.commercetools.com/`);
|
|
48
|
+
return true;
|
|
49
|
+
} catch (error) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const getMcUrlLink = _ref => {
|
|
54
|
+
let mcApiUrl = _ref.mcApiUrl,
|
|
55
|
+
organizationId = _ref.organizationId,
|
|
56
|
+
customEntityId = _ref.customEntityId,
|
|
57
|
+
isCustomView = _ref.isCustomView;
|
|
58
|
+
const mcUrl = mcApiUrl.replace('mc-api', 'mc');
|
|
59
|
+
const customEntityLink = `${mcUrl}/account/organizations/${organizationId}/custom-${isCustomView ? 'views' : 'applications'}/owned/${customEntityId}/deployment-previews`;
|
|
60
|
+
return customEntityLink;
|
|
61
|
+
};
|
|
62
|
+
const isCustomViewData = data => data.entryPointUriPath === undefined;
|
|
63
|
+
async function setDeploymentPreview(_ref2) {
|
|
64
|
+
var _context3;
|
|
65
|
+
let mcApiUrl = _ref2.mcApiUrl,
|
|
66
|
+
applicationId = _ref2.applicationId,
|
|
67
|
+
applicationIdentifier = _ref2.applicationIdentifier,
|
|
68
|
+
localCustomEntityData = _ref2.localCustomEntityData,
|
|
69
|
+
isCustomView = _ref2.isCustomView,
|
|
70
|
+
options = _ref2.options;
|
|
71
|
+
/*
|
|
72
|
+
1. Check if the Custom Application exists in the Merchant Center.
|
|
73
|
+
2. Ask for the alias and URL of the deployment preview.
|
|
74
|
+
3. Check whether it exists a deployment preview with the same alias.
|
|
75
|
+
4. If it exists, ask for confirmation to update it.
|
|
76
|
+
5. If it doesn't exist, ask for confirmation to create it.
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
const fetchedCustomApplication = await fetchCustomApplication({
|
|
80
|
+
mcApiUrl,
|
|
81
|
+
entryPointUriPath: localCustomEntityData.entryPointUriPath,
|
|
82
|
+
applicationIdentifier
|
|
83
|
+
});
|
|
84
|
+
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.`);
|
|
86
|
+
}
|
|
87
|
+
let deploymentAlias = options.alias;
|
|
88
|
+
// If the alias was not provided as an argument to the script, let's ask for it.
|
|
89
|
+
if (!deploymentAlias) {
|
|
90
|
+
var _context2;
|
|
91
|
+
const _await$prompts = await prompts({
|
|
92
|
+
type: 'text',
|
|
93
|
+
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'),
|
|
95
|
+
validate: value => validateAlias(value)
|
|
96
|
+
}),
|
|
97
|
+
alias = _await$prompts.alias;
|
|
98
|
+
deploymentAlias = alias;
|
|
99
|
+
}
|
|
100
|
+
const existingDeploymentPreview = _findInstanceProperty(_context3 = fetchedCustomApplication.application.deployments).call(_context3, deployment => deployment.alias === deploymentAlias);
|
|
101
|
+
if (!options.alias && !options.url && existingDeploymentPreview) {
|
|
102
|
+
var _context4;
|
|
103
|
+
const _await$prompts2 = await prompts({
|
|
104
|
+
type: 'confirm',
|
|
105
|
+
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'),
|
|
107
|
+
initial: false
|
|
108
|
+
}),
|
|
109
|
+
aliasOverrideConfirmation = _await$prompts2.aliasOverrideConfirmation;
|
|
110
|
+
if (!aliasOverrideConfirmation) {
|
|
111
|
+
console.log(chalk.red('Aborted.'));
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
let deploymentUrl = options.url;
|
|
116
|
+
if (!deploymentUrl) {
|
|
117
|
+
var _context5;
|
|
118
|
+
const _await$prompts3 = await prompts({
|
|
119
|
+
type: 'text',
|
|
120
|
+
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'),
|
|
122
|
+
validate: value => validateUrl(value)
|
|
123
|
+
}),
|
|
124
|
+
url = _await$prompts3.url;
|
|
125
|
+
deploymentUrl = url;
|
|
126
|
+
}
|
|
127
|
+
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
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const mcDeploymentPreviewsLink = getMcUrlLink({
|
|
133
|
+
mcApiUrl,
|
|
134
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
135
|
+
customEntityId: fetchedCustomApplication.application.id,
|
|
136
|
+
isCustomView
|
|
137
|
+
});
|
|
138
|
+
if (existingDeploymentPreview) {
|
|
139
|
+
await updateCustomApplicationDeploymentPreview({
|
|
140
|
+
mcApiUrl,
|
|
141
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
142
|
+
applicationIdentifier,
|
|
143
|
+
deploymentId: existingDeploymentPreview.id,
|
|
144
|
+
data: {
|
|
145
|
+
url: deploymentUrl
|
|
146
|
+
}
|
|
147
|
+
});
|
|
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}`));
|
|
150
|
+
} else {
|
|
151
|
+
await createCustomApplicationDeploymentPreview({
|
|
152
|
+
mcApiUrl,
|
|
153
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
154
|
+
applicationIdentifier,
|
|
155
|
+
applicationId,
|
|
156
|
+
data: {
|
|
157
|
+
alias: deploymentAlias,
|
|
158
|
+
url: deploymentUrl
|
|
159
|
+
}
|
|
160
|
+
});
|
|
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}`));
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
async function run(options) {
|
|
166
|
+
const applicationConfig = await processConfig();
|
|
167
|
+
const localCustomEntityData = applicationConfig.data;
|
|
168
|
+
const _applicationConfig$en = applicationConfig.env,
|
|
169
|
+
mcApiUrl = _applicationConfig$en.mcApiUrl,
|
|
170
|
+
applicationIdentifier = _applicationConfig$en.applicationIdentifier;
|
|
171
|
+
const isCustomView = isCustomViewData(localCustomEntityData);
|
|
172
|
+
console.log(`Using Merchant Center environment "${chalk.green(mcApiUrl)}".`);
|
|
173
|
+
console.log();
|
|
174
|
+
const isSessionValid = credentialsStorage.isSessionValid(mcApiUrl);
|
|
175
|
+
if (!isSessionValid) {
|
|
176
|
+
throw new Error(`You don't have a valid session. Please, run the "mc-scripts login" command to authenticate yourself.`);
|
|
177
|
+
}
|
|
178
|
+
if (isCustomView) {
|
|
179
|
+
throw new Error('Deployments previews are not supported for Custom Views.');
|
|
180
|
+
}
|
|
181
|
+
await setDeploymentPreview({
|
|
182
|
+
mcApiUrl,
|
|
183
|
+
applicationId: localCustomEntityData.id,
|
|
184
|
+
applicationIdentifier,
|
|
185
|
+
localCustomEntityData,
|
|
186
|
+
isCustomView,
|
|
187
|
+
options
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export { run as default };
|