@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) commercetools GmbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# @commercetools-frontend/mc-scripts
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://www.npmjs.com/package/@commercetools-frontend/mc-scripts"><img src="https://badgen.net/npm/v/@commercetools-frontend/mc-scripts" alt="Latest release (latest dist-tag)" /></a> <a href="https://www.npmjs.com/package/@commercetools-frontend/mc-scripts"><img src="https://badgen.net/npm/v/@commercetools-frontend/mc-scripts/next" alt="Latest release (next dist-tag)" /></a> <a href="https://bundlephobia.com/result?p=@commercetools-frontend/mc-scripts"><img src="https://badgen.net/bundlephobia/minzip/@commercetools-frontend/mc-scripts" alt="Minified + GZipped size" /></a> <a href="https://github.com/commercetools/merchant-center-application-kit/blob/main/LICENSE"><img src="https://badgen.net/github/license/commercetools/merchant-center-application-kit" alt="GitHub license" /></a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
Check out the [documentation](https://docs.commercetools.com/merchant-center-customizations/api-reference/cli) for more information.
|
package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export * from "../../dist/declarations/src/application-runtime.js";
|
|
2
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWVyY2V0b29scy1mcm9udGVuZC1tYy1zY3JpcHRzLWFwcGxpY2F0aW9uLXJ1bnRpbWUuY2pzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9kaXN0L2RlY2xhcmF0aW9ucy9zcmMvYXBwbGljYXRpb24tcnVudGltZS5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=
|
package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.dev.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
// Dynamically inject webpack `publicPath`, for resolving assets locations.
|
|
5
|
+
// https://webpack.js.org/guides/public-path/#on-the-fly
|
|
6
|
+
// https://webpack.js.org/configuration/output/#output-publicpath
|
|
7
|
+
if (process.env.NODE_ENV !== 'test') __webpack_public_path__ = `${window.app.cdnUrl.replace(/\/$/, '')}/`;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
if (process.env.NODE_ENV === "production") {
|
|
4
|
+
module.exports = require("./commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js");
|
|
5
|
+
} else {
|
|
6
|
+
module.exports = require("./commercetools-frontend-mc-scripts-application-runtime.cjs.dev.js");
|
|
7
|
+
}
|
package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
// Dynamically inject webpack `publicPath`, for resolving assets locations.
|
|
5
|
+
// https://webpack.js.org/guides/public-path/#on-the-fly
|
|
6
|
+
// https://webpack.js.org/configuration/output/#output-publicpath
|
|
7
|
+
__webpack_public_path__ = `${window.app.cdnUrl.replace(/\/$/, '')}/`;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// Dynamically inject webpack `publicPath`, for resolving assets locations.
|
|
3
|
+
// https://webpack.js.org/guides/public-path/#on-the-fly
|
|
4
|
+
// https://webpack.js.org/configuration/output/#output-publicpath
|
|
5
|
+
if (process.env.NODE_ENV !== 'test') __webpack_public_path__ = `${window.app.cdnUrl.replace(/\/$/, '')}/`;
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export * from "../../dist/declarations/src/cli.js";
|
|
2
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWVyY2V0b29scy1mcm9udGVuZC1tYy1zY3JpcHRzLWNsaS5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL2Rpc3QvZGVjbGFyYXRpb25zL3NyYy9jbGkuZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
6
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
7
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
8
|
+
var fs = require('fs');
|
|
9
|
+
var path = require('path');
|
|
10
|
+
var commander = require('commander');
|
|
11
|
+
var dotenv = require('dotenv');
|
|
12
|
+
var dotenvExpand = require('dotenv-expand');
|
|
13
|
+
var _package = require('../../dist/package-7e170dc4.cjs.dev.js');
|
|
14
|
+
var doesFileExist = require('../../dist/does-file-exist-eb86baca.cjs.dev.js');
|
|
15
|
+
require('node:fs');
|
|
16
|
+
|
|
17
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
18
|
+
|
|
19
|
+
var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
|
|
20
|
+
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
21
|
+
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
22
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
23
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
24
|
+
var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
|
|
25
|
+
var dotenvExpand__default = /*#__PURE__*/_interopDefault(dotenvExpand);
|
|
26
|
+
|
|
27
|
+
commander.program.name('mc-scripts').description('CLI to develop and build Merchant Center customizations.').version(_package.pkgJson.version).option('-e, --env <path...>',
|
|
28
|
+
// Variadic option. It allows multiple `--env` options to be provided.
|
|
29
|
+
`(optional) Parses the file path as a dotenv file and adds the variables to the environment. Multiple flags are allowed.`);
|
|
30
|
+
|
|
31
|
+
// Makes the script crash on unhandled rejections instead of silently
|
|
32
|
+
// ignoring them. In the future, promise rejections that are not handled will
|
|
33
|
+
// terminate the Node.js process with a non-zero exit code.
|
|
34
|
+
process.on('unhandledRejection', err => {
|
|
35
|
+
throw err;
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// Get the current directory where the CLI is executed from. Usually this is the application folder.
|
|
39
|
+
const applicationDirectory = fs__default["default"].realpathSync(process.cwd());
|
|
40
|
+
async function run() {
|
|
41
|
+
// Command: start
|
|
42
|
+
commander.program.command('start').alias('dev').description('Starts the application in development mode using Webpack Dev Server.').action(async () => {
|
|
43
|
+
const globalOptions = commander.program.opts();
|
|
44
|
+
|
|
45
|
+
// Load dotenv files into the process environment.
|
|
46
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
47
|
+
loadDotEnvFiles(globalOptions);
|
|
48
|
+
|
|
49
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
50
|
+
process.env.BABEL_ENV = 'development';
|
|
51
|
+
process.env.NODE_ENV = 'development';
|
|
52
|
+
const shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
|
|
53
|
+
if (shouldUseExperimentalBundler) {
|
|
54
|
+
console.log('Experimental Vite bundler enabled! 🚀');
|
|
55
|
+
console.log('');
|
|
56
|
+
}
|
|
57
|
+
const startCommand = shouldUseExperimentalBundler ? await Promise.resolve().then(function () { return require('../../dist/start-vite-068e9f73.cjs.dev.js'); }) : await Promise.resolve().then(function () { return require('../../dist/start-1d677ad8.cjs.dev.js'); });
|
|
58
|
+
await startCommand.default();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Command: build
|
|
62
|
+
commander.program.command('build').description('Bundles the application in production mode. Outputs a "public" folder.').option('--build-only', '(optional) If defined, the command only creates the production bundles without compiling the "index.html".', false).action(async options => {
|
|
63
|
+
const globalOptions = commander.program.opts();
|
|
64
|
+
// Load dotenv files into the process environment.
|
|
65
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
66
|
+
loadDotEnvFiles(globalOptions);
|
|
67
|
+
|
|
68
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
69
|
+
process.env.BABEL_ENV = 'production';
|
|
70
|
+
process.env.NODE_ENV = 'production';
|
|
71
|
+
const shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
|
|
72
|
+
if (shouldUseExperimentalBundler) {
|
|
73
|
+
console.log('Experimental Vite bundler enabled! 🚀');
|
|
74
|
+
console.log('');
|
|
75
|
+
}
|
|
76
|
+
const buildCommand = shouldUseExperimentalBundler ? await Promise.resolve().then(function () { return require('../../dist/build-vite-16b1a575.cjs.dev.js'); }) : await Promise.resolve().then(function () { return require('../../dist/build-988fc0f7.cjs.dev.js'); });
|
|
77
|
+
await buildCommand.default();
|
|
78
|
+
const shouldAlsoCompile = !options.buildOnly;
|
|
79
|
+
if (shouldAlsoCompile) {
|
|
80
|
+
console.log('');
|
|
81
|
+
const compileHtmlCommand = await Promise.resolve().then(function () { return require('../../dist/compile-html-f4ac88cc.cjs.dev.js'); });
|
|
82
|
+
await compileHtmlCommand.default({
|
|
83
|
+
printSecurityHeaders: false
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Command: compile-html
|
|
89
|
+
commander.program.command('compile-html').description('Compiles "index.html.template" file into a "index.html" with all the required runtime configuration. The security headers are also compiled and injected into the "index.html".').option('--transformer <path>', '(optional) The path to a JS module that can be used to generate a configuration for a specific cloud provider (e.g. Vercel, Netlify).').option('--print-security-headers', '(optional) If defined, the compiled security headers are printed to stdout.', false).action(async options => {
|
|
90
|
+
const globalOptions = commander.program.opts();
|
|
91
|
+
|
|
92
|
+
// Load dotenv files into the process environment.
|
|
93
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
94
|
+
loadDotEnvFiles(globalOptions);
|
|
95
|
+
|
|
96
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
97
|
+
process.env.NODE_ENV = 'production';
|
|
98
|
+
const compileHtmlCommand = await Promise.resolve().then(function () { return require('../../dist/compile-html-f4ac88cc.cjs.dev.js'); });
|
|
99
|
+
await compileHtmlCommand.default(options);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// Command: serve
|
|
103
|
+
commander.program.command('serve').description('Serves previously built and compiled application from the "public" folder.').action(async () => {
|
|
104
|
+
const globalOptions = commander.program.opts();
|
|
105
|
+
|
|
106
|
+
// Load dotenv files into the process environment.
|
|
107
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
108
|
+
loadDotEnvFiles(globalOptions);
|
|
109
|
+
|
|
110
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
111
|
+
process.env.NODE_ENV = 'production';
|
|
112
|
+
const serveCommand = await Promise.resolve().then(function () { return require('../../dist/serve-50d33f0b.cjs.dev.js'); });
|
|
113
|
+
await serveCommand.default();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Command: login
|
|
117
|
+
commander.program.command('login').description('Log in to your Merchant Center account through the CLI, using the cloud environment information from the Merchant Center customization config file. An API token is generated and stored in a configuration file for the related cloud environment, and valid for 36 hours.').action(async () => {
|
|
118
|
+
const globalOptions = commander.program.opts();
|
|
119
|
+
|
|
120
|
+
// Load dotenv files into the process environment.
|
|
121
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
122
|
+
loadDotEnvFiles(globalOptions);
|
|
123
|
+
|
|
124
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
125
|
+
process.env.NODE_ENV = 'production';
|
|
126
|
+
const loginCommand = await Promise.resolve().then(function () { return require('../../dist/login-817a5a26.cjs.dev.js'); });
|
|
127
|
+
await loginCommand.default();
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// Command: config:sync
|
|
131
|
+
commander.program.command('config:sync').description('Synchronizes the local Merchant Center customization config with the Merchant Center. A new Merchant Center customization will be created if none existed, otherwise it will be updated.').option('--dry-run', '(optional) Executes the command but does not send any mutation request.', false).action(async options => {
|
|
132
|
+
const globalOptions = commander.program.opts();
|
|
133
|
+
|
|
134
|
+
// Load dotenv files into the process environment.
|
|
135
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
136
|
+
loadDotEnvFiles(globalOptions);
|
|
137
|
+
|
|
138
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
139
|
+
process.env.NODE_ENV = 'production';
|
|
140
|
+
const configSyncCommand = await Promise.resolve().then(function () { return require('../../dist/config-sync-70a16916.cjs.dev.js'); });
|
|
141
|
+
await configSyncCommand.default(options);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// Command: deployment-previews:set
|
|
145
|
+
commander.program.command('deployment-previews:set').description('Creates or updates a deployment preview for the Custom Application.').option('--alias <deployment-preview-alias>', "(optional) Alias to be used for the deployment preview. If you don't provide an alias, the command will prompt you for it.").option('--url <deployment-preview-url>', "(optional) URL to be used for the deployment preview. If you don't provide a URL, the command will prompt you for it.").option('--dry-run', '(optional) Executes the command but does not send any mutation request.', false).action(async options => {
|
|
146
|
+
const globalOptions = commander.program.opts();
|
|
147
|
+
|
|
148
|
+
// Load dotenv files into the process environment.
|
|
149
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
150
|
+
loadDotEnvFiles(globalOptions);
|
|
151
|
+
|
|
152
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
153
|
+
process.env.NODE_ENV = 'production';
|
|
154
|
+
const deploymentsSetCommand = await Promise.resolve().then(function () { return require('../../dist/deployment-previews-set-37aef990.cjs.dev.js'); });
|
|
155
|
+
await deploymentsSetCommand.default(options);
|
|
156
|
+
});
|
|
157
|
+
commander.program.parse();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Load dotenv files into the process environment.
|
|
161
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
162
|
+
// Inspired also by https://create-react-app.dev/docs/adding-custom-environment-variables/#what-other-env-files-can-be-used
|
|
163
|
+
function loadDotEnvFiles(globalOptions) {
|
|
164
|
+
var _context;
|
|
165
|
+
const environment = process.env.MC_APP_ENV || process.env.NODE_ENV;
|
|
166
|
+
const dotenvFiles = [];
|
|
167
|
+
|
|
168
|
+
// Custom dotenv files specified by the `--env` option takes precedence.
|
|
169
|
+
if (typeof globalOptions.env === 'string') {
|
|
170
|
+
dotenvFiles.push(globalOptions.env);
|
|
171
|
+
} else if (_Array$isArray__default["default"](globalOptions.env)) {
|
|
172
|
+
// Multiple `--env` options are allowed.
|
|
173
|
+
dotenvFiles.push(...globalOptions.env);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
|
|
177
|
+
dotenvFiles.push(..._filterInstanceProperty__default["default"](_context = [`.env.${environment}.local`,
|
|
178
|
+
// Don't include `.env.local` for `test` environment
|
|
179
|
+
// since normally you expect tests to produce the same
|
|
180
|
+
// results for everyone
|
|
181
|
+
process.env.NODE_ENV !== 'test' && `.env.local`, `.env.${environment}`, '.env']).call(_context, Boolean));
|
|
182
|
+
|
|
183
|
+
// Load environment variables from .env* files. Suppress warnings using silent
|
|
184
|
+
// if this file is missing. dotenv will never modify any environment variables
|
|
185
|
+
// that have already been set. Variable expansion is supported in .env files.
|
|
186
|
+
// https://github.com/motdotla/dotenv
|
|
187
|
+
// https://github.com/motdotla/dotenv-expand
|
|
188
|
+
_forEachInstanceProperty__default["default"](dotenvFiles).call(dotenvFiles, dotenvFile => {
|
|
189
|
+
const dotenvFilePath = path__default["default"].resolve(path__default["default"].join(applicationDirectory, dotenvFile));
|
|
190
|
+
if (doesFileExist.doesFileExist(dotenvFilePath)) {
|
|
191
|
+
dotenvExpand__default["default"].expand(dotenv__default["default"].config({
|
|
192
|
+
path: dotenvFilePath
|
|
193
|
+
}));
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
exports.loadDotEnvFiles = loadDotEnvFiles;
|
|
199
|
+
exports.run = run;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
6
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
7
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
8
|
+
var fs = require('fs');
|
|
9
|
+
var path = require('path');
|
|
10
|
+
var commander = require('commander');
|
|
11
|
+
var dotenv = require('dotenv');
|
|
12
|
+
var dotenvExpand = require('dotenv-expand');
|
|
13
|
+
var _package = require('../../dist/package-940b0a2a.cjs.prod.js');
|
|
14
|
+
var doesFileExist = require('../../dist/does-file-exist-be53305d.cjs.prod.js');
|
|
15
|
+
require('node:fs');
|
|
16
|
+
|
|
17
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
18
|
+
|
|
19
|
+
var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
|
|
20
|
+
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
21
|
+
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
22
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
23
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
24
|
+
var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
|
|
25
|
+
var dotenvExpand__default = /*#__PURE__*/_interopDefault(dotenvExpand);
|
|
26
|
+
|
|
27
|
+
commander.program.name('mc-scripts').description('CLI to develop and build Merchant Center customizations.').version(_package.pkgJson.version).option('-e, --env <path...>',
|
|
28
|
+
// Variadic option. It allows multiple `--env` options to be provided.
|
|
29
|
+
`(optional) Parses the file path as a dotenv file and adds the variables to the environment. Multiple flags are allowed.`);
|
|
30
|
+
|
|
31
|
+
// Makes the script crash on unhandled rejections instead of silently
|
|
32
|
+
// ignoring them. In the future, promise rejections that are not handled will
|
|
33
|
+
// terminate the Node.js process with a non-zero exit code.
|
|
34
|
+
process.on('unhandledRejection', err => {
|
|
35
|
+
throw err;
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// Get the current directory where the CLI is executed from. Usually this is the application folder.
|
|
39
|
+
const applicationDirectory = fs__default["default"].realpathSync(process.cwd());
|
|
40
|
+
async function run() {
|
|
41
|
+
// Command: start
|
|
42
|
+
commander.program.command('start').alias('dev').description('Starts the application in development mode using Webpack Dev Server.').action(async () => {
|
|
43
|
+
const globalOptions = commander.program.opts();
|
|
44
|
+
|
|
45
|
+
// Load dotenv files into the process environment.
|
|
46
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
47
|
+
loadDotEnvFiles(globalOptions);
|
|
48
|
+
|
|
49
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
50
|
+
process.env.BABEL_ENV = 'development';
|
|
51
|
+
process.env.NODE_ENV = 'development';
|
|
52
|
+
const shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
|
|
53
|
+
if (shouldUseExperimentalBundler) {
|
|
54
|
+
console.log('Experimental Vite bundler enabled! 🚀');
|
|
55
|
+
console.log('');
|
|
56
|
+
}
|
|
57
|
+
const startCommand = shouldUseExperimentalBundler ? await Promise.resolve().then(function () { return require('../../dist/start-vite-29078b3a.cjs.prod.js'); }) : await Promise.resolve().then(function () { return require('../../dist/start-f56cb5f7.cjs.prod.js'); });
|
|
58
|
+
await startCommand.default();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Command: build
|
|
62
|
+
commander.program.command('build').description('Bundles the application in production mode. Outputs a "public" folder.').option('--build-only', '(optional) If defined, the command only creates the production bundles without compiling the "index.html".', false).action(async options => {
|
|
63
|
+
const globalOptions = commander.program.opts();
|
|
64
|
+
// Load dotenv files into the process environment.
|
|
65
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
66
|
+
loadDotEnvFiles(globalOptions);
|
|
67
|
+
|
|
68
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
69
|
+
process.env.BABEL_ENV = 'production';
|
|
70
|
+
process.env.NODE_ENV = 'production';
|
|
71
|
+
const shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
|
|
72
|
+
if (shouldUseExperimentalBundler) {
|
|
73
|
+
console.log('Experimental Vite bundler enabled! 🚀');
|
|
74
|
+
console.log('');
|
|
75
|
+
}
|
|
76
|
+
const buildCommand = shouldUseExperimentalBundler ? await Promise.resolve().then(function () { return require('../../dist/build-vite-5d317720.cjs.prod.js'); }) : await Promise.resolve().then(function () { return require('../../dist/build-521f3f9f.cjs.prod.js'); });
|
|
77
|
+
await buildCommand.default();
|
|
78
|
+
const shouldAlsoCompile = !options.buildOnly;
|
|
79
|
+
if (shouldAlsoCompile) {
|
|
80
|
+
console.log('');
|
|
81
|
+
const compileHtmlCommand = await Promise.resolve().then(function () { return require('../../dist/compile-html-50fd05ec.cjs.prod.js'); });
|
|
82
|
+
await compileHtmlCommand.default({
|
|
83
|
+
printSecurityHeaders: false
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Command: compile-html
|
|
89
|
+
commander.program.command('compile-html').description('Compiles "index.html.template" file into a "index.html" with all the required runtime configuration. The security headers are also compiled and injected into the "index.html".').option('--transformer <path>', '(optional) The path to a JS module that can be used to generate a configuration for a specific cloud provider (e.g. Vercel, Netlify).').option('--print-security-headers', '(optional) If defined, the compiled security headers are printed to stdout.', false).action(async options => {
|
|
90
|
+
const globalOptions = commander.program.opts();
|
|
91
|
+
|
|
92
|
+
// Load dotenv files into the process environment.
|
|
93
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
94
|
+
loadDotEnvFiles(globalOptions);
|
|
95
|
+
|
|
96
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
97
|
+
process.env.NODE_ENV = 'production';
|
|
98
|
+
const compileHtmlCommand = await Promise.resolve().then(function () { return require('../../dist/compile-html-50fd05ec.cjs.prod.js'); });
|
|
99
|
+
await compileHtmlCommand.default(options);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// Command: serve
|
|
103
|
+
commander.program.command('serve').description('Serves previously built and compiled application from the "public" folder.').action(async () => {
|
|
104
|
+
const globalOptions = commander.program.opts();
|
|
105
|
+
|
|
106
|
+
// Load dotenv files into the process environment.
|
|
107
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
108
|
+
loadDotEnvFiles(globalOptions);
|
|
109
|
+
|
|
110
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
111
|
+
process.env.NODE_ENV = 'production';
|
|
112
|
+
const serveCommand = await Promise.resolve().then(function () { return require('../../dist/serve-8a506da6.cjs.prod.js'); });
|
|
113
|
+
await serveCommand.default();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Command: login
|
|
117
|
+
commander.program.command('login').description('Log in to your Merchant Center account through the CLI, using the cloud environment information from the Merchant Center customization config file. An API token is generated and stored in a configuration file for the related cloud environment, and valid for 36 hours.').action(async () => {
|
|
118
|
+
const globalOptions = commander.program.opts();
|
|
119
|
+
|
|
120
|
+
// Load dotenv files into the process environment.
|
|
121
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
122
|
+
loadDotEnvFiles(globalOptions);
|
|
123
|
+
|
|
124
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
125
|
+
process.env.NODE_ENV = 'production';
|
|
126
|
+
const loginCommand = await Promise.resolve().then(function () { return require('../../dist/login-85c25393.cjs.prod.js'); });
|
|
127
|
+
await loginCommand.default();
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// Command: config:sync
|
|
131
|
+
commander.program.command('config:sync').description('Synchronizes the local Merchant Center customization config with the Merchant Center. A new Merchant Center customization will be created if none existed, otherwise it will be updated.').option('--dry-run', '(optional) Executes the command but does not send any mutation request.', false).action(async options => {
|
|
132
|
+
const globalOptions = commander.program.opts();
|
|
133
|
+
|
|
134
|
+
// Load dotenv files into the process environment.
|
|
135
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
136
|
+
loadDotEnvFiles(globalOptions);
|
|
137
|
+
|
|
138
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
139
|
+
process.env.NODE_ENV = 'production';
|
|
140
|
+
const configSyncCommand = await Promise.resolve().then(function () { return require('../../dist/config-sync-72c20d80.cjs.prod.js'); });
|
|
141
|
+
await configSyncCommand.default(options);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// Command: deployment-previews:set
|
|
145
|
+
commander.program.command('deployment-previews:set').description('Creates or updates a deployment preview for the Custom Application.').option('--alias <deployment-preview-alias>', "(optional) Alias to be used for the deployment preview. If you don't provide an alias, the command will prompt you for it.").option('--url <deployment-preview-url>', "(optional) URL to be used for the deployment preview. If you don't provide a URL, the command will prompt you for it.").option('--dry-run', '(optional) Executes the command but does not send any mutation request.', false).action(async options => {
|
|
146
|
+
const globalOptions = commander.program.opts();
|
|
147
|
+
|
|
148
|
+
// Load dotenv files into the process environment.
|
|
149
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
150
|
+
loadDotEnvFiles(globalOptions);
|
|
151
|
+
|
|
152
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
153
|
+
process.env.NODE_ENV = 'production';
|
|
154
|
+
const deploymentsSetCommand = await Promise.resolve().then(function () { return require('../../dist/deployment-previews-set-17e8ed48.cjs.prod.js'); });
|
|
155
|
+
await deploymentsSetCommand.default(options);
|
|
156
|
+
});
|
|
157
|
+
commander.program.parse();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Load dotenv files into the process environment.
|
|
161
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
162
|
+
// Inspired also by https://create-react-app.dev/docs/adding-custom-environment-variables/#what-other-env-files-can-be-used
|
|
163
|
+
function loadDotEnvFiles(globalOptions) {
|
|
164
|
+
var _context;
|
|
165
|
+
const environment = process.env.MC_APP_ENV || "production";
|
|
166
|
+
const dotenvFiles = [];
|
|
167
|
+
|
|
168
|
+
// Custom dotenv files specified by the `--env` option takes precedence.
|
|
169
|
+
if (typeof globalOptions.env === 'string') {
|
|
170
|
+
dotenvFiles.push(globalOptions.env);
|
|
171
|
+
} else if (_Array$isArray__default["default"](globalOptions.env)) {
|
|
172
|
+
// Multiple `--env` options are allowed.
|
|
173
|
+
dotenvFiles.push(...globalOptions.env);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
|
|
177
|
+
dotenvFiles.push(..._filterInstanceProperty__default["default"](_context = [`.env.${environment}.local`,
|
|
178
|
+
// Don't include `.env.local` for `test` environment
|
|
179
|
+
// since normally you expect tests to produce the same
|
|
180
|
+
// results for everyone
|
|
181
|
+
`.env.local`, `.env.${environment}`, '.env']).call(_context, Boolean));
|
|
182
|
+
|
|
183
|
+
// Load environment variables from .env* files. Suppress warnings using silent
|
|
184
|
+
// if this file is missing. dotenv will never modify any environment variables
|
|
185
|
+
// that have already been set. Variable expansion is supported in .env files.
|
|
186
|
+
// https://github.com/motdotla/dotenv
|
|
187
|
+
// https://github.com/motdotla/dotenv-expand
|
|
188
|
+
_forEachInstanceProperty__default["default"](dotenvFiles).call(dotenvFiles, dotenvFile => {
|
|
189
|
+
const dotenvFilePath = path__default["default"].resolve(path__default["default"].join(applicationDirectory, dotenvFile));
|
|
190
|
+
if (doesFileExist.doesFileExist(dotenvFilePath)) {
|
|
191
|
+
dotenvExpand__default["default"].expand(dotenv__default["default"].config({
|
|
192
|
+
path: dotenvFilePath
|
|
193
|
+
}));
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
exports.loadDotEnvFiles = loadDotEnvFiles;
|
|
199
|
+
exports.run = run;
|