@commercetools-frontend/mc-scripts 22.2.1 → 22.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +51 -41
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +51 -41
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +51 -41
- package/dist/{build-72d9896f.esm.js → build-8227e71d.esm.js} +22 -31
- package/dist/{build-4773d61a.cjs.dev.js → build-a888cacd.cjs.dev.js} +22 -31
- package/dist/{build-0ef080b9.cjs.prod.js → build-a9f085a0.cjs.prod.js} +22 -31
- package/dist/{build-vite-2dc2b366.cjs.prod.js → build-vite-1ba28dd8.cjs.prod.js} +18 -19
- package/dist/{build-vite-290aaf04.esm.js → build-vite-9de4820c.esm.js} +18 -19
- package/dist/{build-vite-b5c7ac91.cjs.dev.js → build-vite-e7a6315c.cjs.dev.js} +18 -19
- package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +2 -3
- package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +2 -3
- package/dist/commercetools-frontend-mc-scripts.esm.js +2 -3
- package/dist/{compile-html-41195e35.cjs.dev.js → compile-html-079067bd.cjs.prod.js} +1 -7
- package/dist/{compile-html-5abd78aa.cjs.prod.js → compile-html-3ff2fed0.cjs.dev.js} +1 -7
- package/dist/{compile-html-f9de842c.esm.js → compile-html-606b302e.esm.js} +1 -7
- package/dist/{config-sync-8e8e18a9.cjs.prod.js → config-sync-058dca05.cjs.prod.js} +81 -193
- package/dist/{config-sync-c914ca7a.cjs.dev.js → config-sync-866d8c22.cjs.dev.js} +83 -194
- package/dist/{config-sync-54299066.esm.js → config-sync-dc5a68ed.esm.js} +83 -194
- package/dist/{create-postcss-config-f39f54b5.esm.js → create-postcss-config-9d266de4.esm.js} +9 -13
- package/dist/{create-postcss-config-a0659cf5.cjs.dev.js → create-postcss-config-a29e83fc.cjs.dev.js} +9 -13
- package/dist/{create-postcss-config-6277233e.cjs.prod.js → create-postcss-config-d4f8ca51.cjs.prod.js} +9 -13
- package/dist/{create-webpack-config-for-development-629a8982.cjs.prod.js → create-webpack-config-for-development-02fa9041.cjs.prod.js} +46 -37
- package/dist/{create-webpack-config-for-development-9539f804.esm.js → create-webpack-config-for-development-17376d1f.esm.js} +46 -37
- package/dist/{create-webpack-config-for-development-9aa85081.cjs.dev.js → create-webpack-config-for-development-ac4ad0b2.cjs.dev.js} +46 -37
- package/dist/{create-webpack-config-for-production-84e2db7d.cjs.prod.js → create-webpack-config-for-production-190c7797.cjs.prod.js} +37 -32
- package/dist/{create-webpack-config-for-production-4476fc5f.esm.js → create-webpack-config-for-production-25d7c593.esm.js} +37 -32
- package/dist/{create-webpack-config-for-production-0fac47e1.cjs.dev.js → create-webpack-config-for-production-c1ec1058.cjs.dev.js} +37 -32
- package/dist/{credentials-storage-5939dd35.esm.js → credentials-storage-5a3b88be.esm.js} +3 -15
- package/dist/{credentials-storage-da0754c9.cjs.dev.js → credentials-storage-5d3da1c0.cjs.prod.js} +3 -15
- package/dist/{credentials-storage-fc0c59c3.cjs.prod.js → credentials-storage-6c51d561.cjs.dev.js} +3 -15
- package/dist/declarations/src/generated/settings.d.ts +90 -1172
- package/dist/{has-jsx-runtime-0b03b72e.cjs.prod.js → has-jsx-runtime-aa5d21ee.cjs.dev.js} +0 -2
- package/dist/{has-jsx-runtime-3d4bb633.cjs.dev.js → has-jsx-runtime-c3202df5.cjs.prod.js} +0 -2
- package/dist/{has-jsx-runtime-8314226e.esm.js → has-jsx-runtime-e3ecb09b.esm.js} +0 -2
- package/dist/{login-9f821336.cjs.dev.js → login-0dc4f62a.cjs.prod.js} +12 -23
- package/dist/{login-d1c2268a.esm.js → login-1b051481.esm.js} +12 -23
- package/dist/{login-f747390f.cjs.prod.js → login-9f35d543.cjs.dev.js} +12 -23
- package/dist/{package-83202e32.cjs.prod.js → package-46d27f5f.cjs.dev.js} +15 -13
- package/dist/{package-e6713e98.esm.js → package-4fcd2667.esm.js} +15 -13
- package/dist/{package-cc5b8665.cjs.dev.js → package-6ee0354d.cjs.prod.js} +15 -13
- package/dist/{paths-284c77fb.cjs.prod.js → paths-854af5ef.cjs.prod.js} +8 -12
- package/dist/{paths-db35ac0f.cjs.dev.js → paths-d1febc82.cjs.dev.js} +8 -12
- package/dist/{paths-55c5d5a2.esm.js → paths-ded20ae1.esm.js} +8 -12
- package/dist/{serve-b8063204.cjs.dev.js → serve-12571b42.cjs.prod.js} +1 -2
- package/dist/{serve-660e2ee0.esm.js → serve-65b5a149.esm.js} +1 -2
- package/dist/{serve-41077dad.cjs.prod.js → serve-7339c495.cjs.dev.js} +1 -2
- package/dist/{start-33fd6d70.cjs.dev.js → start-216f84b7.cjs.dev.js} +26 -34
- package/dist/{start-93205b87.esm.js → start-4a922c4f.esm.js} +26 -34
- package/dist/{start-f93c62f9.cjs.prod.js → start-b2e2dab7.cjs.prod.js} +26 -34
- package/dist/{start-vite-8f03b0df.cjs.dev.js → start-vite-3966d625.cjs.dev.js} +18 -17
- package/dist/{start-vite-324af14d.cjs.prod.js → start-vite-5c78605b.cjs.prod.js} +18 -17
- package/dist/{start-vite-7d10ae71.esm.js → start-vite-cf0213a1.esm.js} +18 -17
- package/dist/{vite-plugin-svgr-f17db78a.esm.js → vite-plugin-svgr-5c953fe7.esm.js} +1 -6
- package/dist/{vite-plugin-svgr-fdb37ccf.cjs.dev.js → vite-plugin-svgr-5eb1c511.cjs.dev.js} +1 -6
- package/dist/{vite-plugin-svgr-9a4e7f77.cjs.prod.js → vite-plugin-svgr-a732f8df.cjs.prod.js} +1 -6
- package/package.json +31 -17
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +2 -2
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +2 -2
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +2 -2
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +6 -6
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +6 -6
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +6 -6
|
@@ -10,7 +10,7 @@ var path = require('path');
|
|
|
10
10
|
var cac = require('cac');
|
|
11
11
|
var dotenv = require('dotenv');
|
|
12
12
|
var dotenvExpand = require('dotenv-expand');
|
|
13
|
-
var _package = require('../../dist/package-
|
|
13
|
+
var _package = require('../../dist/package-46d27f5f.cjs.dev.js');
|
|
14
14
|
|
|
15
15
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
16
16
|
|
|
@@ -22,117 +22,126 @@ var path__default = /*#__PURE__*/_interopDefault(path);
|
|
|
22
22
|
var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
|
|
23
23
|
var dotenvExpand__default = /*#__PURE__*/_interopDefault(dotenvExpand);
|
|
24
24
|
|
|
25
|
-
const cli = cac.cac('mc-scripts');
|
|
25
|
+
const cli = cac.cac('mc-scripts');
|
|
26
|
+
|
|
27
|
+
// Makes the script crash on unhandled rejections instead of silently
|
|
26
28
|
// ignoring them. In the future, promise rejections that are not handled will
|
|
27
29
|
// terminate the Node.js process with a non-zero exit code.
|
|
28
|
-
|
|
29
30
|
process.on('unhandledRejection', err => {
|
|
30
31
|
throw err;
|
|
31
|
-
});
|
|
32
|
+
});
|
|
32
33
|
|
|
34
|
+
// Get the current directory where the CLI is executed from. Usually this is the application folder.
|
|
33
35
|
const applicationDirectory = fs__default["default"].realpathSync(process.cwd());
|
|
34
|
-
|
|
35
36
|
async function run() {
|
|
36
|
-
cli.option('--env <path>', "(optional) Parses the file path as a dotenv file and adds the variables to the environment. Multiple flags are allowed.");
|
|
37
|
+
cli.option('--env <path>', "(optional) Parses the file path as a dotenv file and adds the variables to the environment. Multiple flags are allowed.");
|
|
37
38
|
|
|
39
|
+
// Default command
|
|
38
40
|
cli.command('').usage('\n\n Develop and build Custom Applications.').action(() => {
|
|
39
41
|
cli.outputHelp();
|
|
40
|
-
});
|
|
42
|
+
});
|
|
41
43
|
|
|
44
|
+
// Command: start
|
|
42
45
|
const usageStart = 'Starts the application in development mode using Webpack Dev Server.';
|
|
43
46
|
cli.command('start', usageStart).usage("\n\n ".concat(usageStart)).alias('dev').action(async options => {
|
|
44
47
|
// Load dotenv files into the process environment.
|
|
45
48
|
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
46
|
-
loadDotEnvFiles(options);
|
|
49
|
+
loadDotEnvFiles(options);
|
|
47
50
|
|
|
51
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
48
52
|
process.env.BABEL_ENV = 'development';
|
|
49
53
|
process.env.NODE_ENV = 'development';
|
|
50
54
|
const shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
|
|
51
|
-
|
|
52
55
|
if (shouldUseExperimentalBundler) {
|
|
53
56
|
console.log('Experimental Vite bundler enabled! 🚀');
|
|
54
57
|
console.log('');
|
|
55
58
|
}
|
|
56
|
-
|
|
57
|
-
const startCommand = shouldUseExperimentalBundler ? await Promise.resolve().then(function () { return require('../../dist/start-vite-8f03b0df.cjs.dev.js'); }) : await Promise.resolve().then(function () { return require('../../dist/start-33fd6d70.cjs.dev.js'); });
|
|
59
|
+
const startCommand = shouldUseExperimentalBundler ? await Promise.resolve().then(function () { return require('../../dist/start-vite-3966d625.cjs.dev.js'); }) : await Promise.resolve().then(function () { return require('../../dist/start-216f84b7.cjs.dev.js'); });
|
|
58
60
|
await startCommand.default();
|
|
59
|
-
});
|
|
61
|
+
});
|
|
60
62
|
|
|
63
|
+
// Command: build
|
|
61
64
|
const usageBuild = 'Bundles the application in production mode. Outputs a "public" folder.';
|
|
62
65
|
cli.command('build', usageBuild).usage("\n\n ".concat(usageBuild)).option('--build-only', '(optional) If defined, the command only creates the production bundles without compiling the "index.html".', {
|
|
63
66
|
default: false
|
|
64
67
|
}).action(async options => {
|
|
65
68
|
// Load dotenv files into the process environment.
|
|
66
69
|
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
67
|
-
loadDotEnvFiles(options);
|
|
70
|
+
loadDotEnvFiles(options);
|
|
68
71
|
|
|
72
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
69
73
|
process.env.BABEL_ENV = 'production';
|
|
70
74
|
process.env.NODE_ENV = 'production';
|
|
71
75
|
const shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
|
|
72
|
-
|
|
73
76
|
if (shouldUseExperimentalBundler) {
|
|
74
77
|
console.log('Experimental Vite bundler enabled! 🚀');
|
|
75
78
|
console.log('');
|
|
76
79
|
}
|
|
77
|
-
|
|
78
|
-
const buildCommand = shouldUseExperimentalBundler ? await Promise.resolve().then(function () { return require('../../dist/build-vite-b5c7ac91.cjs.dev.js'); }) : await Promise.resolve().then(function () { return require('../../dist/build-4773d61a.cjs.dev.js'); });
|
|
80
|
+
const buildCommand = shouldUseExperimentalBundler ? await Promise.resolve().then(function () { return require('../../dist/build-vite-e7a6315c.cjs.dev.js'); }) : await Promise.resolve().then(function () { return require('../../dist/build-a888cacd.cjs.dev.js'); });
|
|
79
81
|
await buildCommand.default();
|
|
80
82
|
const shouldAlsoCompile = !options.buildOnly;
|
|
81
|
-
|
|
82
83
|
if (shouldAlsoCompile) {
|
|
83
84
|
console.log('');
|
|
84
|
-
const compileHtmlCommand = await Promise.resolve().then(function () { return require('../../dist/compile-html-
|
|
85
|
+
const compileHtmlCommand = await Promise.resolve().then(function () { return require('../../dist/compile-html-3ff2fed0.cjs.dev.js'); });
|
|
85
86
|
await compileHtmlCommand.default({
|
|
86
87
|
printSecurityHeaders: false
|
|
87
88
|
});
|
|
88
89
|
}
|
|
89
|
-
});
|
|
90
|
+
});
|
|
90
91
|
|
|
92
|
+
// Command: compile-html
|
|
91
93
|
const usageCompileHtml = '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".';
|
|
92
94
|
cli.command('compile-html', usageCompileHtml).usage("\n\n ".concat(usageCompileHtml)).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.', {
|
|
93
95
|
default: false
|
|
94
96
|
}).action(async options => {
|
|
95
97
|
// Load dotenv files into the process environment.
|
|
96
98
|
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
97
|
-
loadDotEnvFiles(options);
|
|
99
|
+
loadDotEnvFiles(options);
|
|
98
100
|
|
|
101
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
99
102
|
process.env.NODE_ENV = 'production';
|
|
100
|
-
const compileHtmlCommand = await Promise.resolve().then(function () { return require('../../dist/compile-html-
|
|
103
|
+
const compileHtmlCommand = await Promise.resolve().then(function () { return require('../../dist/compile-html-3ff2fed0.cjs.dev.js'); });
|
|
101
104
|
await compileHtmlCommand.default(options);
|
|
102
|
-
});
|
|
105
|
+
});
|
|
103
106
|
|
|
107
|
+
// Command: serve
|
|
104
108
|
const usageServe = 'Serves previously built and compiled application from the "public" folder.';
|
|
105
109
|
cli.command('serve', usageServe).usage("\n\n ".concat(usageServe)).action(async options => {
|
|
106
110
|
// Load dotenv files into the process environment.
|
|
107
111
|
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
108
|
-
loadDotEnvFiles(options);
|
|
112
|
+
loadDotEnvFiles(options);
|
|
109
113
|
|
|
114
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
110
115
|
process.env.NODE_ENV = 'production';
|
|
111
|
-
const serveCommand = await Promise.resolve().then(function () { return require('../../dist/serve-
|
|
116
|
+
const serveCommand = await Promise.resolve().then(function () { return require('../../dist/serve-7339c495.cjs.dev.js'); });
|
|
112
117
|
await serveCommand.default();
|
|
113
|
-
});
|
|
118
|
+
});
|
|
114
119
|
|
|
120
|
+
// Command: login
|
|
115
121
|
const usageLogin = '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.';
|
|
116
122
|
cli.command('login', usageLogin).usage("\n\n ".concat(usageLogin)).action(async options => {
|
|
117
123
|
// Load dotenv files into the process environment.
|
|
118
124
|
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
119
|
-
loadDotEnvFiles(options);
|
|
125
|
+
loadDotEnvFiles(options);
|
|
120
126
|
|
|
127
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
121
128
|
process.env.NODE_ENV = 'production';
|
|
122
|
-
const loginCommand = await Promise.resolve().then(function () { return require('../../dist/login-
|
|
129
|
+
const loginCommand = await Promise.resolve().then(function () { return require('../../dist/login-9f35d543.cjs.dev.js'); });
|
|
123
130
|
await loginCommand.default();
|
|
124
|
-
});
|
|
131
|
+
});
|
|
125
132
|
|
|
133
|
+
// Command: config:sync
|
|
126
134
|
const usageConfigSync = '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.';
|
|
127
135
|
cli.command('config:sync', usageConfigSync).usage("\n\n ".concat(usageConfigSync)).option('--dry-run', '(optional) Executes the command but does not send any mutation request.', {
|
|
128
136
|
default: false
|
|
129
137
|
}).action(async options => {
|
|
130
138
|
// Load dotenv files into the process environment.
|
|
131
139
|
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
132
|
-
loadDotEnvFiles(options);
|
|
140
|
+
loadDotEnvFiles(options);
|
|
133
141
|
|
|
142
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
134
143
|
process.env.NODE_ENV = 'production';
|
|
135
|
-
const configSyncCommand = await Promise.resolve().then(function () { return require('../../dist/config-sync-
|
|
144
|
+
const configSyncCommand = await Promise.resolve().then(function () { return require('../../dist/config-sync-866d8c22.cjs.dev.js'); });
|
|
136
145
|
await configSyncCommand.default(options);
|
|
137
146
|
});
|
|
138
147
|
cli.help();
|
|
@@ -141,37 +150,38 @@ async function run() {
|
|
|
141
150
|
run: false
|
|
142
151
|
});
|
|
143
152
|
await cli.runMatchedCommand();
|
|
144
|
-
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Load dotenv files into the process environment.
|
|
145
156
|
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
146
157
|
// Inspired also by https://create-react-app.dev/docs/adding-custom-environment-variables/#what-other-env-files-can-be-used
|
|
147
|
-
|
|
148
|
-
|
|
149
158
|
function loadDotEnvFiles(globalOptions) {
|
|
150
159
|
var _context;
|
|
151
|
-
|
|
152
160
|
const environment = process.env.MC_APP_ENV || process.env.NODE_ENV;
|
|
153
|
-
const dotenvFiles = [];
|
|
161
|
+
const dotenvFiles = [];
|
|
154
162
|
|
|
163
|
+
// Custom dotenv files specified by the `--env` option takes precedence.
|
|
155
164
|
if (typeof globalOptions.env === 'string') {
|
|
156
165
|
dotenvFiles.push(globalOptions.env);
|
|
157
166
|
} else if (_Array$isArray__default["default"](globalOptions.env)) {
|
|
158
167
|
// Multiple `--env` options are allowed.
|
|
159
168
|
dotenvFiles.push(...globalOptions.env);
|
|
160
|
-
}
|
|
161
|
-
|
|
169
|
+
}
|
|
162
170
|
|
|
163
|
-
|
|
171
|
+
// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
|
|
172
|
+
dotenvFiles.push(..._filterInstanceProperty__default["default"](_context = [".env.".concat(environment, ".local"),
|
|
173
|
+
// Don't include `.env.local` for `test` environment
|
|
164
174
|
// since normally you expect tests to produce the same
|
|
165
175
|
// results for everyone
|
|
166
|
-
process.env.NODE_ENV !== 'test' && ".env.local", ".env.".concat(environment), '.env']).call(_context, Boolean));
|
|
176
|
+
process.env.NODE_ENV !== 'test' && ".env.local", ".env.".concat(environment), '.env']).call(_context, Boolean));
|
|
177
|
+
|
|
178
|
+
// Load environment variables from .env* files. Suppress warnings using silent
|
|
167
179
|
// if this file is missing. dotenv will never modify any environment variables
|
|
168
180
|
// that have already been set. Variable expansion is supported in .env files.
|
|
169
181
|
// https://github.com/motdotla/dotenv
|
|
170
182
|
// https://github.com/motdotla/dotenv-expand
|
|
171
|
-
|
|
172
183
|
_forEachInstanceProperty__default["default"](dotenvFiles).call(dotenvFiles, dotenvFile => {
|
|
173
184
|
const dotenvFilePath = path__default["default"].resolve(path__default["default"].join(applicationDirectory, dotenvFile));
|
|
174
|
-
|
|
175
185
|
if (fs__default["default"].existsSync(dotenvFilePath)) {
|
|
176
186
|
dotenvExpand__default["default"].expand(dotenv__default["default"].config({
|
|
177
187
|
path: dotenvFilePath
|
|
@@ -10,7 +10,7 @@ var path = require('path');
|
|
|
10
10
|
var cac = require('cac');
|
|
11
11
|
var dotenv = require('dotenv');
|
|
12
12
|
var dotenvExpand = require('dotenv-expand');
|
|
13
|
-
var _package = require('../../dist/package-
|
|
13
|
+
var _package = require('../../dist/package-6ee0354d.cjs.prod.js');
|
|
14
14
|
|
|
15
15
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
16
16
|
|
|
@@ -22,117 +22,126 @@ var path__default = /*#__PURE__*/_interopDefault(path);
|
|
|
22
22
|
var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
|
|
23
23
|
var dotenvExpand__default = /*#__PURE__*/_interopDefault(dotenvExpand);
|
|
24
24
|
|
|
25
|
-
const cli = cac.cac('mc-scripts');
|
|
25
|
+
const cli = cac.cac('mc-scripts');
|
|
26
|
+
|
|
27
|
+
// Makes the script crash on unhandled rejections instead of silently
|
|
26
28
|
// ignoring them. In the future, promise rejections that are not handled will
|
|
27
29
|
// terminate the Node.js process with a non-zero exit code.
|
|
28
|
-
|
|
29
30
|
process.on('unhandledRejection', err => {
|
|
30
31
|
throw err;
|
|
31
|
-
});
|
|
32
|
+
});
|
|
32
33
|
|
|
34
|
+
// Get the current directory where the CLI is executed from. Usually this is the application folder.
|
|
33
35
|
const applicationDirectory = fs__default["default"].realpathSync(process.cwd());
|
|
34
|
-
|
|
35
36
|
async function run() {
|
|
36
|
-
cli.option('--env <path>', "(optional) Parses the file path as a dotenv file and adds the variables to the environment. Multiple flags are allowed.");
|
|
37
|
+
cli.option('--env <path>', "(optional) Parses the file path as a dotenv file and adds the variables to the environment. Multiple flags are allowed.");
|
|
37
38
|
|
|
39
|
+
// Default command
|
|
38
40
|
cli.command('').usage('\n\n Develop and build Custom Applications.').action(() => {
|
|
39
41
|
cli.outputHelp();
|
|
40
|
-
});
|
|
42
|
+
});
|
|
41
43
|
|
|
44
|
+
// Command: start
|
|
42
45
|
const usageStart = 'Starts the application in development mode using Webpack Dev Server.';
|
|
43
46
|
cli.command('start', usageStart).usage("\n\n ".concat(usageStart)).alias('dev').action(async options => {
|
|
44
47
|
// Load dotenv files into the process environment.
|
|
45
48
|
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
46
|
-
loadDotEnvFiles(options);
|
|
49
|
+
loadDotEnvFiles(options);
|
|
47
50
|
|
|
51
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
48
52
|
process.env.BABEL_ENV = 'development';
|
|
49
53
|
process.env.NODE_ENV = 'development';
|
|
50
54
|
const shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
|
|
51
|
-
|
|
52
55
|
if (shouldUseExperimentalBundler) {
|
|
53
56
|
console.log('Experimental Vite bundler enabled! 🚀');
|
|
54
57
|
console.log('');
|
|
55
58
|
}
|
|
56
|
-
|
|
57
|
-
const startCommand = shouldUseExperimentalBundler ? await Promise.resolve().then(function () { return require('../../dist/start-vite-324af14d.cjs.prod.js'); }) : await Promise.resolve().then(function () { return require('../../dist/start-f93c62f9.cjs.prod.js'); });
|
|
59
|
+
const startCommand = shouldUseExperimentalBundler ? await Promise.resolve().then(function () { return require('../../dist/start-vite-5c78605b.cjs.prod.js'); }) : await Promise.resolve().then(function () { return require('../../dist/start-b2e2dab7.cjs.prod.js'); });
|
|
58
60
|
await startCommand.default();
|
|
59
|
-
});
|
|
61
|
+
});
|
|
60
62
|
|
|
63
|
+
// Command: build
|
|
61
64
|
const usageBuild = 'Bundles the application in production mode. Outputs a "public" folder.';
|
|
62
65
|
cli.command('build', usageBuild).usage("\n\n ".concat(usageBuild)).option('--build-only', '(optional) If defined, the command only creates the production bundles without compiling the "index.html".', {
|
|
63
66
|
default: false
|
|
64
67
|
}).action(async options => {
|
|
65
68
|
// Load dotenv files into the process environment.
|
|
66
69
|
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
67
|
-
loadDotEnvFiles(options);
|
|
70
|
+
loadDotEnvFiles(options);
|
|
68
71
|
|
|
72
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
69
73
|
process.env.BABEL_ENV = 'production';
|
|
70
74
|
process.env.NODE_ENV = 'production';
|
|
71
75
|
const shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
|
|
72
|
-
|
|
73
76
|
if (shouldUseExperimentalBundler) {
|
|
74
77
|
console.log('Experimental Vite bundler enabled! 🚀');
|
|
75
78
|
console.log('');
|
|
76
79
|
}
|
|
77
|
-
|
|
78
|
-
const buildCommand = shouldUseExperimentalBundler ? await Promise.resolve().then(function () { return require('../../dist/build-vite-2dc2b366.cjs.prod.js'); }) : await Promise.resolve().then(function () { return require('../../dist/build-0ef080b9.cjs.prod.js'); });
|
|
80
|
+
const buildCommand = shouldUseExperimentalBundler ? await Promise.resolve().then(function () { return require('../../dist/build-vite-1ba28dd8.cjs.prod.js'); }) : await Promise.resolve().then(function () { return require('../../dist/build-a9f085a0.cjs.prod.js'); });
|
|
79
81
|
await buildCommand.default();
|
|
80
82
|
const shouldAlsoCompile = !options.buildOnly;
|
|
81
|
-
|
|
82
83
|
if (shouldAlsoCompile) {
|
|
83
84
|
console.log('');
|
|
84
|
-
const compileHtmlCommand = await Promise.resolve().then(function () { return require('../../dist/compile-html-
|
|
85
|
+
const compileHtmlCommand = await Promise.resolve().then(function () { return require('../../dist/compile-html-079067bd.cjs.prod.js'); });
|
|
85
86
|
await compileHtmlCommand.default({
|
|
86
87
|
printSecurityHeaders: false
|
|
87
88
|
});
|
|
88
89
|
}
|
|
89
|
-
});
|
|
90
|
+
});
|
|
90
91
|
|
|
92
|
+
// Command: compile-html
|
|
91
93
|
const usageCompileHtml = '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".';
|
|
92
94
|
cli.command('compile-html', usageCompileHtml).usage("\n\n ".concat(usageCompileHtml)).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.', {
|
|
93
95
|
default: false
|
|
94
96
|
}).action(async options => {
|
|
95
97
|
// Load dotenv files into the process environment.
|
|
96
98
|
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
97
|
-
loadDotEnvFiles(options);
|
|
99
|
+
loadDotEnvFiles(options);
|
|
98
100
|
|
|
101
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
99
102
|
process.env.NODE_ENV = 'production';
|
|
100
|
-
const compileHtmlCommand = await Promise.resolve().then(function () { return require('../../dist/compile-html-
|
|
103
|
+
const compileHtmlCommand = await Promise.resolve().then(function () { return require('../../dist/compile-html-079067bd.cjs.prod.js'); });
|
|
101
104
|
await compileHtmlCommand.default(options);
|
|
102
|
-
});
|
|
105
|
+
});
|
|
103
106
|
|
|
107
|
+
// Command: serve
|
|
104
108
|
const usageServe = 'Serves previously built and compiled application from the "public" folder.';
|
|
105
109
|
cli.command('serve', usageServe).usage("\n\n ".concat(usageServe)).action(async options => {
|
|
106
110
|
// Load dotenv files into the process environment.
|
|
107
111
|
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
108
|
-
loadDotEnvFiles(options);
|
|
112
|
+
loadDotEnvFiles(options);
|
|
109
113
|
|
|
114
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
110
115
|
process.env.NODE_ENV = 'production';
|
|
111
|
-
const serveCommand = await Promise.resolve().then(function () { return require('../../dist/serve-
|
|
116
|
+
const serveCommand = await Promise.resolve().then(function () { return require('../../dist/serve-12571b42.cjs.prod.js'); });
|
|
112
117
|
await serveCommand.default();
|
|
113
|
-
});
|
|
118
|
+
});
|
|
114
119
|
|
|
120
|
+
// Command: login
|
|
115
121
|
const usageLogin = '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.';
|
|
116
122
|
cli.command('login', usageLogin).usage("\n\n ".concat(usageLogin)).action(async options => {
|
|
117
123
|
// Load dotenv files into the process environment.
|
|
118
124
|
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
119
|
-
loadDotEnvFiles(options);
|
|
125
|
+
loadDotEnvFiles(options);
|
|
120
126
|
|
|
127
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
121
128
|
process.env.NODE_ENV = 'production';
|
|
122
|
-
const loginCommand = await Promise.resolve().then(function () { return require('../../dist/login-
|
|
129
|
+
const loginCommand = await Promise.resolve().then(function () { return require('../../dist/login-0dc4f62a.cjs.prod.js'); });
|
|
123
130
|
await loginCommand.default();
|
|
124
|
-
});
|
|
131
|
+
});
|
|
125
132
|
|
|
133
|
+
// Command: config:sync
|
|
126
134
|
const usageConfigSync = '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.';
|
|
127
135
|
cli.command('config:sync', usageConfigSync).usage("\n\n ".concat(usageConfigSync)).option('--dry-run', '(optional) Executes the command but does not send any mutation request.', {
|
|
128
136
|
default: false
|
|
129
137
|
}).action(async options => {
|
|
130
138
|
// Load dotenv files into the process environment.
|
|
131
139
|
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
132
|
-
loadDotEnvFiles(options);
|
|
140
|
+
loadDotEnvFiles(options);
|
|
133
141
|
|
|
142
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
134
143
|
process.env.NODE_ENV = 'production';
|
|
135
|
-
const configSyncCommand = await Promise.resolve().then(function () { return require('../../dist/config-sync-
|
|
144
|
+
const configSyncCommand = await Promise.resolve().then(function () { return require('../../dist/config-sync-058dca05.cjs.prod.js'); });
|
|
136
145
|
await configSyncCommand.default(options);
|
|
137
146
|
});
|
|
138
147
|
cli.help();
|
|
@@ -141,37 +150,38 @@ async function run() {
|
|
|
141
150
|
run: false
|
|
142
151
|
});
|
|
143
152
|
await cli.runMatchedCommand();
|
|
144
|
-
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Load dotenv files into the process environment.
|
|
145
156
|
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
146
157
|
// Inspired also by https://create-react-app.dev/docs/adding-custom-environment-variables/#what-other-env-files-can-be-used
|
|
147
|
-
|
|
148
|
-
|
|
149
158
|
function loadDotEnvFiles(globalOptions) {
|
|
150
159
|
var _context;
|
|
151
|
-
|
|
152
160
|
const environment = process.env.MC_APP_ENV || "production";
|
|
153
|
-
const dotenvFiles = [];
|
|
161
|
+
const dotenvFiles = [];
|
|
154
162
|
|
|
163
|
+
// Custom dotenv files specified by the `--env` option takes precedence.
|
|
155
164
|
if (typeof globalOptions.env === 'string') {
|
|
156
165
|
dotenvFiles.push(globalOptions.env);
|
|
157
166
|
} else if (_Array$isArray__default["default"](globalOptions.env)) {
|
|
158
167
|
// Multiple `--env` options are allowed.
|
|
159
168
|
dotenvFiles.push(...globalOptions.env);
|
|
160
|
-
}
|
|
161
|
-
|
|
169
|
+
}
|
|
162
170
|
|
|
163
|
-
|
|
171
|
+
// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
|
|
172
|
+
dotenvFiles.push(..._filterInstanceProperty__default["default"](_context = [".env.".concat(environment, ".local"),
|
|
173
|
+
// Don't include `.env.local` for `test` environment
|
|
164
174
|
// since normally you expect tests to produce the same
|
|
165
175
|
// results for everyone
|
|
166
|
-
".env.local", ".env.".concat(environment), '.env']).call(_context, Boolean));
|
|
176
|
+
".env.local", ".env.".concat(environment), '.env']).call(_context, Boolean));
|
|
177
|
+
|
|
178
|
+
// Load environment variables from .env* files. Suppress warnings using silent
|
|
167
179
|
// if this file is missing. dotenv will never modify any environment variables
|
|
168
180
|
// that have already been set. Variable expansion is supported in .env files.
|
|
169
181
|
// https://github.com/motdotla/dotenv
|
|
170
182
|
// https://github.com/motdotla/dotenv-expand
|
|
171
|
-
|
|
172
183
|
_forEachInstanceProperty__default["default"](dotenvFiles).call(dotenvFiles, dotenvFile => {
|
|
173
184
|
const dotenvFilePath = path__default["default"].resolve(path__default["default"].join(applicationDirectory, dotenvFile));
|
|
174
|
-
|
|
175
185
|
if (fs__default["default"].existsSync(dotenvFilePath)) {
|
|
176
186
|
dotenvExpand__default["default"].expand(dotenv__default["default"].config({
|
|
177
187
|
path: dotenvFilePath
|
|
@@ -6,119 +6,128 @@ import path from 'path';
|
|
|
6
6
|
import { cac } from 'cac';
|
|
7
7
|
import dotenv from 'dotenv';
|
|
8
8
|
import dotenvExpand from 'dotenv-expand';
|
|
9
|
-
import { p as pkgJson } from '../../dist/package-
|
|
9
|
+
import { p as pkgJson } from '../../dist/package-4fcd2667.esm.js';
|
|
10
10
|
|
|
11
|
-
const cli = cac('mc-scripts');
|
|
11
|
+
const cli = cac('mc-scripts');
|
|
12
|
+
|
|
13
|
+
// Makes the script crash on unhandled rejections instead of silently
|
|
12
14
|
// ignoring them. In the future, promise rejections that are not handled will
|
|
13
15
|
// terminate the Node.js process with a non-zero exit code.
|
|
14
|
-
|
|
15
16
|
process.on('unhandledRejection', err => {
|
|
16
17
|
throw err;
|
|
17
|
-
});
|
|
18
|
+
});
|
|
18
19
|
|
|
20
|
+
// Get the current directory where the CLI is executed from. Usually this is the application folder.
|
|
19
21
|
const applicationDirectory = fs.realpathSync(process.cwd());
|
|
20
|
-
|
|
21
22
|
async function run() {
|
|
22
|
-
cli.option('--env <path>', "(optional) Parses the file path as a dotenv file and adds the variables to the environment. Multiple flags are allowed.");
|
|
23
|
+
cli.option('--env <path>', "(optional) Parses the file path as a dotenv file and adds the variables to the environment. Multiple flags are allowed.");
|
|
23
24
|
|
|
25
|
+
// Default command
|
|
24
26
|
cli.command('').usage('\n\n Develop and build Custom Applications.').action(() => {
|
|
25
27
|
cli.outputHelp();
|
|
26
|
-
});
|
|
28
|
+
});
|
|
27
29
|
|
|
30
|
+
// Command: start
|
|
28
31
|
const usageStart = 'Starts the application in development mode using Webpack Dev Server.';
|
|
29
32
|
cli.command('start', usageStart).usage("\n\n ".concat(usageStart)).alias('dev').action(async options => {
|
|
30
33
|
// Load dotenv files into the process environment.
|
|
31
34
|
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
32
|
-
loadDotEnvFiles(options);
|
|
35
|
+
loadDotEnvFiles(options);
|
|
33
36
|
|
|
37
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
34
38
|
process.env.BABEL_ENV = 'development';
|
|
35
39
|
process.env.NODE_ENV = 'development';
|
|
36
40
|
const shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
|
|
37
|
-
|
|
38
41
|
if (shouldUseExperimentalBundler) {
|
|
39
42
|
console.log('Experimental Vite bundler enabled! 🚀');
|
|
40
43
|
console.log('');
|
|
41
44
|
}
|
|
42
|
-
|
|
43
|
-
const startCommand = shouldUseExperimentalBundler ? await import('../../dist/start-vite-7d10ae71.esm.js') : await import('../../dist/start-93205b87.esm.js');
|
|
45
|
+
const startCommand = shouldUseExperimentalBundler ? await import('../../dist/start-vite-cf0213a1.esm.js') : await import('../../dist/start-4a922c4f.esm.js');
|
|
44
46
|
await startCommand.default();
|
|
45
|
-
});
|
|
47
|
+
});
|
|
46
48
|
|
|
49
|
+
// Command: build
|
|
47
50
|
const usageBuild = 'Bundles the application in production mode. Outputs a "public" folder.';
|
|
48
51
|
cli.command('build', usageBuild).usage("\n\n ".concat(usageBuild)).option('--build-only', '(optional) If defined, the command only creates the production bundles without compiling the "index.html".', {
|
|
49
52
|
default: false
|
|
50
53
|
}).action(async options => {
|
|
51
54
|
// Load dotenv files into the process environment.
|
|
52
55
|
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
53
|
-
loadDotEnvFiles(options);
|
|
56
|
+
loadDotEnvFiles(options);
|
|
54
57
|
|
|
58
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
55
59
|
process.env.BABEL_ENV = 'production';
|
|
56
60
|
process.env.NODE_ENV = 'production';
|
|
57
61
|
const shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
|
|
58
|
-
|
|
59
62
|
if (shouldUseExperimentalBundler) {
|
|
60
63
|
console.log('Experimental Vite bundler enabled! 🚀');
|
|
61
64
|
console.log('');
|
|
62
65
|
}
|
|
63
|
-
|
|
64
|
-
const buildCommand = shouldUseExperimentalBundler ? await import('../../dist/build-vite-290aaf04.esm.js') : await import('../../dist/build-72d9896f.esm.js');
|
|
66
|
+
const buildCommand = shouldUseExperimentalBundler ? await import('../../dist/build-vite-9de4820c.esm.js') : await import('../../dist/build-8227e71d.esm.js');
|
|
65
67
|
await buildCommand.default();
|
|
66
68
|
const shouldAlsoCompile = !options.buildOnly;
|
|
67
|
-
|
|
68
69
|
if (shouldAlsoCompile) {
|
|
69
70
|
console.log('');
|
|
70
|
-
const compileHtmlCommand = await import('../../dist/compile-html-
|
|
71
|
+
const compileHtmlCommand = await import('../../dist/compile-html-606b302e.esm.js');
|
|
71
72
|
await compileHtmlCommand.default({
|
|
72
73
|
printSecurityHeaders: false
|
|
73
74
|
});
|
|
74
75
|
}
|
|
75
|
-
});
|
|
76
|
+
});
|
|
76
77
|
|
|
78
|
+
// Command: compile-html
|
|
77
79
|
const usageCompileHtml = '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".';
|
|
78
80
|
cli.command('compile-html', usageCompileHtml).usage("\n\n ".concat(usageCompileHtml)).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.', {
|
|
79
81
|
default: false
|
|
80
82
|
}).action(async options => {
|
|
81
83
|
// Load dotenv files into the process environment.
|
|
82
84
|
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
83
|
-
loadDotEnvFiles(options);
|
|
85
|
+
loadDotEnvFiles(options);
|
|
84
86
|
|
|
87
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
85
88
|
process.env.NODE_ENV = 'production';
|
|
86
|
-
const compileHtmlCommand = await import('../../dist/compile-html-
|
|
89
|
+
const compileHtmlCommand = await import('../../dist/compile-html-606b302e.esm.js');
|
|
87
90
|
await compileHtmlCommand.default(options);
|
|
88
|
-
});
|
|
91
|
+
});
|
|
89
92
|
|
|
93
|
+
// Command: serve
|
|
90
94
|
const usageServe = 'Serves previously built and compiled application from the "public" folder.';
|
|
91
95
|
cli.command('serve', usageServe).usage("\n\n ".concat(usageServe)).action(async options => {
|
|
92
96
|
// Load dotenv files into the process environment.
|
|
93
97
|
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
94
|
-
loadDotEnvFiles(options);
|
|
98
|
+
loadDotEnvFiles(options);
|
|
95
99
|
|
|
100
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
96
101
|
process.env.NODE_ENV = 'production';
|
|
97
|
-
const serveCommand = await import('../../dist/serve-
|
|
102
|
+
const serveCommand = await import('../../dist/serve-65b5a149.esm.js');
|
|
98
103
|
await serveCommand.default();
|
|
99
|
-
});
|
|
104
|
+
});
|
|
100
105
|
|
|
106
|
+
// Command: login
|
|
101
107
|
const usageLogin = '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.';
|
|
102
108
|
cli.command('login', usageLogin).usage("\n\n ".concat(usageLogin)).action(async options => {
|
|
103
109
|
// Load dotenv files into the process environment.
|
|
104
110
|
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
105
|
-
loadDotEnvFiles(options);
|
|
111
|
+
loadDotEnvFiles(options);
|
|
106
112
|
|
|
113
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
107
114
|
process.env.NODE_ENV = 'production';
|
|
108
|
-
const loginCommand = await import('../../dist/login-
|
|
115
|
+
const loginCommand = await import('../../dist/login-1b051481.esm.js');
|
|
109
116
|
await loginCommand.default();
|
|
110
|
-
});
|
|
117
|
+
});
|
|
111
118
|
|
|
119
|
+
// Command: config:sync
|
|
112
120
|
const usageConfigSync = '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.';
|
|
113
121
|
cli.command('config:sync', usageConfigSync).usage("\n\n ".concat(usageConfigSync)).option('--dry-run', '(optional) Executes the command but does not send any mutation request.', {
|
|
114
122
|
default: false
|
|
115
123
|
}).action(async options => {
|
|
116
124
|
// Load dotenv files into the process environment.
|
|
117
125
|
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
118
|
-
loadDotEnvFiles(options);
|
|
126
|
+
loadDotEnvFiles(options);
|
|
119
127
|
|
|
128
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
120
129
|
process.env.NODE_ENV = 'production';
|
|
121
|
-
const configSyncCommand = await import('../../dist/config-sync-
|
|
130
|
+
const configSyncCommand = await import('../../dist/config-sync-dc5a68ed.esm.js');
|
|
122
131
|
await configSyncCommand.default(options);
|
|
123
132
|
});
|
|
124
133
|
cli.help();
|
|
@@ -127,37 +136,38 @@ async function run() {
|
|
|
127
136
|
run: false
|
|
128
137
|
});
|
|
129
138
|
await cli.runMatchedCommand();
|
|
130
|
-
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Load dotenv files into the process environment.
|
|
131
142
|
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
132
143
|
// Inspired also by https://create-react-app.dev/docs/adding-custom-environment-variables/#what-other-env-files-can-be-used
|
|
133
|
-
|
|
134
|
-
|
|
135
144
|
function loadDotEnvFiles(globalOptions) {
|
|
136
145
|
var _context;
|
|
137
|
-
|
|
138
146
|
const environment = process.env.MC_APP_ENV || process.env.NODE_ENV;
|
|
139
|
-
const dotenvFiles = [];
|
|
147
|
+
const dotenvFiles = [];
|
|
140
148
|
|
|
149
|
+
// Custom dotenv files specified by the `--env` option takes precedence.
|
|
141
150
|
if (typeof globalOptions.env === 'string') {
|
|
142
151
|
dotenvFiles.push(globalOptions.env);
|
|
143
152
|
} else if (_Array$isArray(globalOptions.env)) {
|
|
144
153
|
// Multiple `--env` options are allowed.
|
|
145
154
|
dotenvFiles.push(...globalOptions.env);
|
|
146
|
-
}
|
|
147
|
-
|
|
155
|
+
}
|
|
148
156
|
|
|
149
|
-
|
|
157
|
+
// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
|
|
158
|
+
dotenvFiles.push(..._filterInstanceProperty(_context = [".env.".concat(environment, ".local"),
|
|
159
|
+
// Don't include `.env.local` for `test` environment
|
|
150
160
|
// since normally you expect tests to produce the same
|
|
151
161
|
// results for everyone
|
|
152
|
-
process.env.NODE_ENV !== 'test' && ".env.local", ".env.".concat(environment), '.env']).call(_context, Boolean));
|
|
162
|
+
process.env.NODE_ENV !== 'test' && ".env.local", ".env.".concat(environment), '.env']).call(_context, Boolean));
|
|
163
|
+
|
|
164
|
+
// Load environment variables from .env* files. Suppress warnings using silent
|
|
153
165
|
// if this file is missing. dotenv will never modify any environment variables
|
|
154
166
|
// that have already been set. Variable expansion is supported in .env files.
|
|
155
167
|
// https://github.com/motdotla/dotenv
|
|
156
168
|
// https://github.com/motdotla/dotenv-expand
|
|
157
|
-
|
|
158
169
|
_forEachInstanceProperty(dotenvFiles).call(dotenvFiles, dotenvFile => {
|
|
159
170
|
const dotenvFilePath = path.resolve(path.join(applicationDirectory, dotenvFile));
|
|
160
|
-
|
|
161
171
|
if (fs.existsSync(dotenvFilePath)) {
|
|
162
172
|
dotenvExpand.expand(dotenv.config({
|
|
163
173
|
path: dotenvFilePath
|