@commercetools-frontend/mc-scripts 21.5.0 → 21.8.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/LICENSE +1 -1
- package/README.md +1 -42
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.d.ts +1 -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/{build/config/application-runtime.js → application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js} +2 -2
- 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 +1 -1
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.d.ts +1 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +354 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.js +7 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +354 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +338 -0
- package/cli/package.json +4 -0
- package/config/create-webpack-config-for-development.js +7 -1
- package/config/create-webpack-config-for-production.js +7 -1
- package/config/vendors-to-transpile.js +5 -1
- package/dist/build-8582b673.esm.js +209 -0
- package/dist/build-9395925a.cjs.prod.js +224 -0
- package/dist/build-97278377.cjs.dev.js +224 -0
- package/dist/build-vite-6c987a60.cjs.dev.js +109 -0
- package/dist/build-vite-76d44332.cjs.prod.js +109 -0
- package/dist/build-vite-a9602b19.esm.js +97 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.d.ts +1 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +30 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.js +7 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +30 -0
- package/dist/commercetools-frontend-mc-scripts.esm.js +22 -0
- package/dist/compile-html-0c588a89.cjs.dev.js +93 -0
- package/dist/compile-html-4832f8c5.esm.js +83 -0
- package/dist/compile-html-7654b5e6.cjs.prod.js +93 -0
- package/dist/config-sync-20bc05e8.esm.js +868 -0
- package/dist/config-sync-62824317.cjs.prod.js +887 -0
- package/dist/config-sync-d52e73f6.cjs.dev.js +892 -0
- package/dist/create-postcss-config-4cbe10ab.cjs.dev.js +90 -0
- package/dist/create-postcss-config-8ea16440.cjs.prod.js +90 -0
- package/{build/config/create-postcss-config.js → dist/create-postcss-config-c1aa3525.esm.js} +27 -25
- package/{build/config/create-webpack-config-for-development.js → dist/create-webpack-config-for-development-8a8b84d6.esm.js} +92 -56
- package/dist/create-webpack-config-for-development-a5e73092.cjs.prod.js +418 -0
- package/dist/create-webpack-config-for-development-e2735e02.cjs.dev.js +418 -0
- package/dist/create-webpack-config-for-production-4e7b56c0.cjs.prod.js +468 -0
- package/{build/config/create-webpack-config-for-production.js → dist/create-webpack-config-for-production-7dc669e5.esm.js} +117 -52
- package/dist/create-webpack-config-for-production-d9bf281c.cjs.dev.js +468 -0
- package/dist/declarations/src/application-runtime.d.ts +1 -0
- package/dist/declarations/src/cli.d.ts +4 -0
- package/dist/declarations/src/commands/build-vite.d.ts +2 -0
- package/dist/declarations/src/commands/build.d.ts +2 -0
- package/dist/declarations/src/commands/compile-html.d.ts +3 -0
- package/dist/declarations/src/commands/config-sync.d.ts +3 -0
- package/dist/declarations/src/commands/login.d.ts +2 -0
- package/dist/declarations/src/commands/serve.d.ts +2 -0
- package/dist/declarations/src/commands/start-vite.d.ts +2 -0
- package/dist/declarations/src/commands/start.d.ts +2 -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/has-jsx-runtime.d.ts +2 -0
- package/dist/declarations/src/config/paths.d.ts +12 -0
- package/dist/declarations/src/config/vendors-to-transpile.d.ts +2 -0
- package/dist/declarations/src/config/webpack-dev-server.config.d.ts +6 -0
- package/dist/declarations/src/deprecated-entry-points.d.ts +7 -0
- package/dist/declarations/src/generated/core.d.ts +710 -0
- package/dist/declarations/src/generated/settings.d.ts +2383 -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 +82 -0
- package/dist/declarations/src/utils/auth.d.ts +6 -0
- package/dist/declarations/src/utils/credentials-storage.d.ts +11 -0
- package/dist/declarations/src/utils/get-config-diff.d.ts +3 -0
- package/dist/declarations/src/utils/graphql-requests.d.ts +80 -0
- package/dist/declarations/src/utils/user-agent.d.ts +2 -0
- package/dist/declarations/src/version.d.ts +2 -0
- package/dist/declarations/src/webpack-plugins/final-stats-writer-plugin.d.ts +12 -0
- package/dist/declarations/src/webpack-plugins/local-html-webpack-plugin.d.ts +5 -0
- package/dist/declarations/src/webpack.d.ts +2 -0
- package/dist/has-jsx-runtime-0b03b72e.cjs.prod.js +17 -0
- package/dist/has-jsx-runtime-3d4bb633.cjs.dev.js +17 -0
- package/{build/config/has-jsx-runtime.js → dist/has-jsx-runtime-8314226e.esm.js} +1 -3
- package/dist/login-706ccc9a.cjs.prod.js +165 -0
- package/dist/login-779552b7.cjs.dev.js +165 -0
- package/dist/login-7d94659e.esm.js +155 -0
- package/dist/package-a98de907.esm.js +133 -0
- package/dist/package-aaf61bf0.cjs.dev.js +135 -0
- package/dist/package-b5c040f3.cjs.prod.js +135 -0
- package/dist/paths-16823f56.cjs.dev.js +55 -0
- package/dist/paths-76b66e74.cjs.prod.js +55 -0
- package/dist/paths-ed23d5a1.esm.js +46 -0
- package/dist/serve-12de323b.cjs.dev.js +70 -0
- package/dist/serve-784f4fcd.cjs.prod.js +70 -0
- package/dist/serve-d6b437b1.esm.js +62 -0
- package/dist/start-2b953ab0.cjs.dev.js +209 -0
- package/dist/start-e3ccd672.cjs.prod.js +209 -0
- package/dist/start-e924bd5d.esm.js +194 -0
- package/dist/start-vite-737bacca.cjs.dev.js +149 -0
- package/dist/start-vite-b0f58ae4.cjs.prod.js +149 -0
- package/dist/start-vite-ec5d40b5.esm.js +136 -0
- package/dist/user-agent-5da1830b.cjs.dev.js +106 -0
- package/dist/user-agent-8044acd6.esm.js +94 -0
- package/dist/user-agent-d18809af.cjs.prod.js +106 -0
- package/dist/vendors-to-transpile-367e0ba8.cjs.prod.js +5 -0
- package/dist/vendors-to-transpile-68e03526.esm.js +3 -0
- package/dist/vendors-to-transpile-b51af5d3.cjs.dev.js +5 -0
- package/package.json +50 -48
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.d.ts +1 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +14 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.js +7 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +14 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +6 -0
- package/postcss/package.json +4 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.d.ts +1 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +51 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.js +7 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +51 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +42 -0
- package/webpack/package.json +4 -0
- package/build/bin/cli.js +0 -260
- package/build/commands/build-vite.js +0 -95
- package/build/commands/build.js +0 -140
- package/build/commands/compile-html.js +0 -53
- package/build/commands/config-sync.js +0 -171
- package/build/commands/login.js +0 -60
- package/build/commands/serve.js +0 -37
- package/build/commands/start-vite.js +0 -142
- package/build/commands/start.js +0 -108
- package/build/config/paths.js +0 -38
- package/build/config/vendors-to-transpile.js +0 -3
- package/build/config/webpack-dev-server.config.js +0 -71
- package/build/index.js +0 -16
- package/build/utils/auth.js +0 -34
- package/build/utils/auth.spec.js +0 -61
- package/build/utils/create-custom-application.settings.graphql +0 -8
- package/build/utils/credentials-storage.js +0 -72
- package/build/utils/credentials-storage.spec.js +0 -69
- package/build/utils/fetch-custom-application.settings.graphql +0 -35
- package/build/utils/fetch-user-organizations.core.graphql +0 -9
- package/build/utils/graphql-requests.js +0 -105
- package/build/utils/graphql-requests.spec.js +0 -159
- package/build/utils/require-graphql.js +0 -15
- package/build/utils/update-application-id-in-custom-application-config.js +0 -60
- package/build/utils/update-custom-application.settings.graphql +0 -13
- package/build/utils/user-agent.js +0 -15
- package/build/webpack-plugins/final-stats-writer-plugin.js +0 -50
- package/build/webpack-plugins/local-html-webpack-plugin.js +0 -38
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -4,45 +4,4 @@
|
|
|
4
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
5
|
</p>
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## Install
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
$ npm install --save @commercetools-frontend/mc-scripts
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Usage
|
|
16
|
-
|
|
17
|
-
The CLI provides some commands. See https://docs.commercetools.com/custom-applications/development/available-scripts.
|
|
18
|
-
|
|
19
|
-
## Using dotenv files (`.env`)
|
|
20
|
-
|
|
21
|
-
Now the `mc-scripts` CLI has the dotenv features built-in.
|
|
22
|
-
|
|
23
|
-
By default, the following dotenv files are loaded according to the current environment values specified on each command: `process.MC_APP_ENV` or `process.NODE_ENV`. The priority of how the files are merged and overwritten goes from top to bottom (highest defined variable overrides lower).
|
|
24
|
-
|
|
25
|
-
- `.env.development.local`, `.env.test.local`, `.env.production.local`: Local overrides of environment-specific settings.
|
|
26
|
-
- `.env.development`, `.env.test`, `.env.production`: Environment-specific settings.
|
|
27
|
-
- `.env.local`: Local overrides. **This file is loaded for all environments except test.**
|
|
28
|
-
- `.env`
|
|
29
|
-
|
|
30
|
-
Please refer to the [dotenv documentation](https://github.com/motdotla/dotenv) for more details.
|
|
31
|
-
|
|
32
|
-
Furthermore, you can pass additional dotenv files by using the following option:
|
|
33
|
-
|
|
34
|
-
- `--env <path>`: Parses the file path as a dotenv file and adds the variables to the environment. Multiple flags are allowed.
|
|
35
|
-
|
|
36
|
-
These files will take higher priority over the standard environment dotenv files.
|
|
37
|
-
|
|
38
|
-
## API usage
|
|
39
|
-
|
|
40
|
-
The package exports some functions to configure Webpack:
|
|
41
|
-
|
|
42
|
-
```js
|
|
43
|
-
const {
|
|
44
|
-
createWebpackConfigForDevelopment,
|
|
45
|
-
createWebpackConfigForProduction,
|
|
46
|
-
vendorsToCompile,
|
|
47
|
-
} = require('@commercetools-frontend/mc-scripts');
|
|
48
|
-
```
|
|
7
|
+
Check out the [documentation](https://docs.commercetools.com/custom-applications/api-reference/cli) for more information.
|
package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../dist/declarations/src/application-runtime";
|
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__ = "".concat(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
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
// Dynamically inject webpack `publicPath`, for resolving assets locations.
|
|
5
5
|
// https://webpack.js.org/guides/public-path/#on-the-fly
|
|
6
6
|
// https://webpack.js.org/configuration/output/#output-publicpath
|
|
7
|
-
|
|
7
|
+
__webpack_public_path__ = "".concat(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__ = "".concat(window.app.cdnUrl.replace(/\/$/, ''), "/");
|
package/bin/cli.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../dist/declarations/src/cli";
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
|
|
6
|
+
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
7
|
+
var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
8
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
9
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
10
|
+
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
11
|
+
var fs = require('fs');
|
|
12
|
+
var path = require('path');
|
|
13
|
+
var cac = require('cac');
|
|
14
|
+
var dotenv = require('dotenv');
|
|
15
|
+
var dotenvExpand = require('dotenv-expand');
|
|
16
|
+
var _package = require('../../dist/package-aaf61bf0.cjs.dev.js');
|
|
17
|
+
|
|
18
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
19
|
+
|
|
20
|
+
var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
|
|
21
|
+
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
22
|
+
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
23
|
+
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefault(_regeneratorRuntime);
|
|
24
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
25
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
26
|
+
var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
|
|
27
|
+
var dotenvExpand__default = /*#__PURE__*/_interopDefault(dotenvExpand);
|
|
28
|
+
|
|
29
|
+
var cli = cac.cac('mc-scripts'); // Makes the script crash on unhandled rejections instead of silently
|
|
30
|
+
// ignoring them. In the future, promise rejections that are not handled will
|
|
31
|
+
// terminate the Node.js process with a non-zero exit code.
|
|
32
|
+
|
|
33
|
+
process.on('unhandledRejection', function (err) {
|
|
34
|
+
throw err;
|
|
35
|
+
}); // Get the current directory where the CLI is executed from. Usually this is the application folder.
|
|
36
|
+
|
|
37
|
+
var applicationDirectory = fs__default["default"].realpathSync(process.cwd());
|
|
38
|
+
|
|
39
|
+
var run = function run() {
|
|
40
|
+
cli.help();
|
|
41
|
+
cli.version(_package.pkgJson.version);
|
|
42
|
+
cli.option('--env <path>', "(optional) Parses the file path as a dotenv file and adds the variables to the environment. Multiple flags are allowed."); // Default command
|
|
43
|
+
|
|
44
|
+
cli.command('').action(function () {
|
|
45
|
+
cli.outputHelp();
|
|
46
|
+
}); // Command: start
|
|
47
|
+
|
|
48
|
+
cli.command('start', 'Starts the application in development mode using Webpack Dev Server.').alias('dev').action( /*#__PURE__*/function () {
|
|
49
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(options) {
|
|
50
|
+
var shouldUseExperimentalBundler, startCommand;
|
|
51
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
52
|
+
while (1) {
|
|
53
|
+
switch (_context.prev = _context.next) {
|
|
54
|
+
case 0:
|
|
55
|
+
// Load dotenv files into the process environment.
|
|
56
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
57
|
+
loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
|
|
58
|
+
|
|
59
|
+
process.env.BABEL_ENV = 'development';
|
|
60
|
+
process.env.NODE_ENV = 'development';
|
|
61
|
+
shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
|
|
62
|
+
|
|
63
|
+
if (shouldUseExperimentalBundler) {
|
|
64
|
+
console.log('Experimental Vite bundler enabled! 🚀');
|
|
65
|
+
console.log('');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (!shouldUseExperimentalBundler) {
|
|
69
|
+
_context.next = 11;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
_context.next = 8;
|
|
74
|
+
return Promise.resolve().then(function () { return require('../../dist/start-vite-737bacca.cjs.dev.js'); });
|
|
75
|
+
|
|
76
|
+
case 8:
|
|
77
|
+
_context.t0 = _context.sent;
|
|
78
|
+
_context.next = 14;
|
|
79
|
+
break;
|
|
80
|
+
|
|
81
|
+
case 11:
|
|
82
|
+
_context.next = 13;
|
|
83
|
+
return Promise.resolve().then(function () { return require('../../dist/start-2b953ab0.cjs.dev.js'); });
|
|
84
|
+
|
|
85
|
+
case 13:
|
|
86
|
+
_context.t0 = _context.sent;
|
|
87
|
+
|
|
88
|
+
case 14:
|
|
89
|
+
startCommand = _context.t0;
|
|
90
|
+
_context.next = 17;
|
|
91
|
+
return startCommand.default();
|
|
92
|
+
|
|
93
|
+
case 17:
|
|
94
|
+
case "end":
|
|
95
|
+
return _context.stop();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}, _callee);
|
|
99
|
+
}));
|
|
100
|
+
|
|
101
|
+
return function (_x) {
|
|
102
|
+
return _ref.apply(this, arguments);
|
|
103
|
+
};
|
|
104
|
+
}()); // Command: build
|
|
105
|
+
|
|
106
|
+
cli.command('build', '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".').action( /*#__PURE__*/function () {
|
|
107
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(options) {
|
|
108
|
+
var shouldUseExperimentalBundler, buildCommand, shouldAlsoCompile, compileHtmlCommand;
|
|
109
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
|
|
110
|
+
while (1) {
|
|
111
|
+
switch (_context2.prev = _context2.next) {
|
|
112
|
+
case 0:
|
|
113
|
+
// Load dotenv files into the process environment.
|
|
114
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
115
|
+
loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
|
|
116
|
+
|
|
117
|
+
process.env.BABEL_ENV = 'production';
|
|
118
|
+
process.env.NODE_ENV = 'production';
|
|
119
|
+
shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
|
|
120
|
+
|
|
121
|
+
if (shouldUseExperimentalBundler) {
|
|
122
|
+
console.log('Experimental Vite bundler enabled! 🚀');
|
|
123
|
+
console.warn('NOTE that the "cdnURL" value is not supported at the moment when using Vite.');
|
|
124
|
+
console.log('');
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (!shouldUseExperimentalBundler) {
|
|
128
|
+
_context2.next = 11;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
_context2.next = 8;
|
|
133
|
+
return Promise.resolve().then(function () { return require('../../dist/build-vite-6c987a60.cjs.dev.js'); });
|
|
134
|
+
|
|
135
|
+
case 8:
|
|
136
|
+
_context2.t0 = _context2.sent;
|
|
137
|
+
_context2.next = 14;
|
|
138
|
+
break;
|
|
139
|
+
|
|
140
|
+
case 11:
|
|
141
|
+
_context2.next = 13;
|
|
142
|
+
return Promise.resolve().then(function () { return require('../../dist/build-97278377.cjs.dev.js'); });
|
|
143
|
+
|
|
144
|
+
case 13:
|
|
145
|
+
_context2.t0 = _context2.sent;
|
|
146
|
+
|
|
147
|
+
case 14:
|
|
148
|
+
buildCommand = _context2.t0;
|
|
149
|
+
_context2.next = 17;
|
|
150
|
+
return buildCommand.default();
|
|
151
|
+
|
|
152
|
+
case 17:
|
|
153
|
+
shouldAlsoCompile = !options['build-only'];
|
|
154
|
+
|
|
155
|
+
if (!shouldAlsoCompile) {
|
|
156
|
+
_context2.next = 25;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
console.log('');
|
|
161
|
+
_context2.next = 22;
|
|
162
|
+
return Promise.resolve().then(function () { return require('../../dist/compile-html-0c588a89.cjs.dev.js'); });
|
|
163
|
+
|
|
164
|
+
case 22:
|
|
165
|
+
compileHtmlCommand = _context2.sent;
|
|
166
|
+
_context2.next = 25;
|
|
167
|
+
return compileHtmlCommand.default();
|
|
168
|
+
|
|
169
|
+
case 25:
|
|
170
|
+
case "end":
|
|
171
|
+
return _context2.stop();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}, _callee2);
|
|
175
|
+
}));
|
|
176
|
+
|
|
177
|
+
return function (_x2) {
|
|
178
|
+
return _ref2.apply(this, arguments);
|
|
179
|
+
};
|
|
180
|
+
}()); // Command: compile-html
|
|
181
|
+
|
|
182
|
+
cli.command('compile-html', '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.').action( /*#__PURE__*/function () {
|
|
183
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(options) {
|
|
184
|
+
var compileHtmlCommand;
|
|
185
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context3) {
|
|
186
|
+
while (1) {
|
|
187
|
+
switch (_context3.prev = _context3.next) {
|
|
188
|
+
case 0:
|
|
189
|
+
// Load dotenv files into the process environment.
|
|
190
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
191
|
+
loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
|
|
192
|
+
|
|
193
|
+
process.env.NODE_ENV = 'production';
|
|
194
|
+
_context3.next = 4;
|
|
195
|
+
return Promise.resolve().then(function () { return require('../../dist/compile-html-0c588a89.cjs.dev.js'); });
|
|
196
|
+
|
|
197
|
+
case 4:
|
|
198
|
+
compileHtmlCommand = _context3.sent;
|
|
199
|
+
_context3.next = 7;
|
|
200
|
+
return compileHtmlCommand.default(options);
|
|
201
|
+
|
|
202
|
+
case 7:
|
|
203
|
+
case "end":
|
|
204
|
+
return _context3.stop();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}, _callee3);
|
|
208
|
+
}));
|
|
209
|
+
|
|
210
|
+
return function (_x3) {
|
|
211
|
+
return _ref3.apply(this, arguments);
|
|
212
|
+
};
|
|
213
|
+
}()); // Command: serve
|
|
214
|
+
|
|
215
|
+
cli.command('serve', 'Serves previously built and compiled application from the "public" folder.').action( /*#__PURE__*/function () {
|
|
216
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(options) {
|
|
217
|
+
var serveCommand;
|
|
218
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context4) {
|
|
219
|
+
while (1) {
|
|
220
|
+
switch (_context4.prev = _context4.next) {
|
|
221
|
+
case 0:
|
|
222
|
+
// Load dotenv files into the process environment.
|
|
223
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
224
|
+
loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
|
|
225
|
+
|
|
226
|
+
process.env.NODE_ENV = 'production';
|
|
227
|
+
_context4.next = 4;
|
|
228
|
+
return Promise.resolve().then(function () { return require('../../dist/serve-12de323b.cjs.dev.js'); });
|
|
229
|
+
|
|
230
|
+
case 4:
|
|
231
|
+
serveCommand = _context4.sent;
|
|
232
|
+
_context4.next = 7;
|
|
233
|
+
return serveCommand.default();
|
|
234
|
+
|
|
235
|
+
case 7:
|
|
236
|
+
case "end":
|
|
237
|
+
return _context4.stop();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}, _callee4);
|
|
241
|
+
}));
|
|
242
|
+
|
|
243
|
+
return function (_x4) {
|
|
244
|
+
return _ref4.apply(this, arguments);
|
|
245
|
+
};
|
|
246
|
+
}()); // Command: login
|
|
247
|
+
|
|
248
|
+
cli.command('login', 'Log in to your Merchant Center account through the CLI, using the cloud environment information from the Custom Application config file. An API token is generated and stored in a configuration file for the related cloud environment, and valid for 36 hours.').action( /*#__PURE__*/function () {
|
|
249
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee5(options) {
|
|
250
|
+
var loginCommand;
|
|
251
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee5$(_context5) {
|
|
252
|
+
while (1) {
|
|
253
|
+
switch (_context5.prev = _context5.next) {
|
|
254
|
+
case 0:
|
|
255
|
+
// Load dotenv files into the process environment.
|
|
256
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
257
|
+
loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
|
|
258
|
+
|
|
259
|
+
process.env.NODE_ENV = 'production';
|
|
260
|
+
_context5.next = 4;
|
|
261
|
+
return Promise.resolve().then(function () { return require('../../dist/login-779552b7.cjs.dev.js'); });
|
|
262
|
+
|
|
263
|
+
case 4:
|
|
264
|
+
loginCommand = _context5.sent;
|
|
265
|
+
_context5.next = 7;
|
|
266
|
+
return loginCommand.default();
|
|
267
|
+
|
|
268
|
+
case 7:
|
|
269
|
+
case "end":
|
|
270
|
+
return _context5.stop();
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}, _callee5);
|
|
274
|
+
}));
|
|
275
|
+
|
|
276
|
+
return function (_x5) {
|
|
277
|
+
return _ref5.apply(this, arguments);
|
|
278
|
+
};
|
|
279
|
+
}()); // Command: config:sync
|
|
280
|
+
|
|
281
|
+
cli.command('config:sync', 'Synchronizes the local Custom Application config with the Merchant Center. A new Custom Application 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.').action( /*#__PURE__*/function () {
|
|
282
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee6(options) {
|
|
283
|
+
var configSyncCommand;
|
|
284
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee6$(_context6) {
|
|
285
|
+
while (1) {
|
|
286
|
+
switch (_context6.prev = _context6.next) {
|
|
287
|
+
case 0:
|
|
288
|
+
// Load dotenv files into the process environment.
|
|
289
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
290
|
+
loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
|
|
291
|
+
|
|
292
|
+
process.env.NODE_ENV = 'production';
|
|
293
|
+
_context6.next = 4;
|
|
294
|
+
return Promise.resolve().then(function () { return require('../../dist/config-sync-d52e73f6.cjs.dev.js'); });
|
|
295
|
+
|
|
296
|
+
case 4:
|
|
297
|
+
configSyncCommand = _context6.sent;
|
|
298
|
+
_context6.next = 7;
|
|
299
|
+
return configSyncCommand.default(options);
|
|
300
|
+
|
|
301
|
+
case 7:
|
|
302
|
+
case "end":
|
|
303
|
+
return _context6.stop();
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}, _callee6);
|
|
307
|
+
}));
|
|
308
|
+
|
|
309
|
+
return function (_x6) {
|
|
310
|
+
return _ref6.apply(this, arguments);
|
|
311
|
+
};
|
|
312
|
+
}());
|
|
313
|
+
cli.parse();
|
|
314
|
+
}; // Load dotenv files into the process environment.
|
|
315
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
316
|
+
// Inspired also by https://create-react-app.dev/docs/adding-custom-environment-variables/#what-other-env-files-can-be-used
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
function loadDotEnvFiles(globalOptions) {
|
|
320
|
+
var _context7;
|
|
321
|
+
|
|
322
|
+
var environment = process.env.MC_APP_ENV || process.env.NODE_ENV;
|
|
323
|
+
var dotenvFiles = []; // Custom dotenv files specified by the `--env` option takes precedence.
|
|
324
|
+
|
|
325
|
+
if (typeof globalOptions.env === 'string') {
|
|
326
|
+
dotenvFiles.push(globalOptions.env);
|
|
327
|
+
} else if (_Array$isArray__default["default"](globalOptions.env)) {
|
|
328
|
+
// Multiple `--env` options are allowed.
|
|
329
|
+
dotenvFiles.push.apply(dotenvFiles, _toConsumableArray(globalOptions.env));
|
|
330
|
+
} // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
dotenvFiles.push.apply(dotenvFiles, _toConsumableArray(_filterInstanceProperty__default["default"](_context7 = [".env.".concat(environment, ".local"), // Don't include `.env.local` for `test` environment
|
|
334
|
+
// since normally you expect tests to produce the same
|
|
335
|
+
// results for everyone
|
|
336
|
+
process.env.NODE_ENV !== 'test' && ".env.local", ".env.".concat(environment), '.env']).call(_context7, Boolean))); // Load environment variables from .env* files. Suppress warnings using silent
|
|
337
|
+
// if this file is missing. dotenv will never modify any environment variables
|
|
338
|
+
// that have already been set. Variable expansion is supported in .env files.
|
|
339
|
+
// https://github.com/motdotla/dotenv
|
|
340
|
+
// https://github.com/motdotla/dotenv-expand
|
|
341
|
+
|
|
342
|
+
_forEachInstanceProperty__default["default"](dotenvFiles).call(dotenvFiles, function (dotenvFile) {
|
|
343
|
+
var dotenvFilePath = path__default["default"].resolve(path__default["default"].join(applicationDirectory, dotenvFile));
|
|
344
|
+
|
|
345
|
+
if (fs__default["default"].existsSync(dotenvFilePath)) {
|
|
346
|
+
dotenvExpand__default["default"].expand(dotenv__default["default"].config({
|
|
347
|
+
path: dotenvFilePath
|
|
348
|
+
}));
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
exports.loadDotEnvFiles = loadDotEnvFiles;
|
|
354
|
+
exports.run = run;
|