@commercetools-frontend/mc-scripts 21.18.1 → 21.20.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/bin/cli.js +6 -1
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +318 -295
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +318 -295
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +317 -294
- package/dist/{build-c0e3f847.cjs.dev.js → build-906c169d.cjs.dev.js} +3 -3
- package/dist/{build-d21fc12e.esm.js → build-9c026044.esm.js} +3 -3
- package/dist/{build-354fcf2d.cjs.prod.js → build-b85b0adc.cjs.prod.js} +3 -3
- package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +1 -1
- package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +1 -1
- package/dist/commercetools-frontend-mc-scripts.esm.js +1 -1
- package/dist/{config-sync-5b074ed2.cjs.prod.js → config-sync-66d9c329.cjs.prod.js} +259 -137
- package/dist/{config-sync-2cf31a74.esm.js → config-sync-74df6d7e.esm.js} +255 -134
- package/dist/{config-sync-00f9d9be.cjs.dev.js → config-sync-8c78e00f.cjs.dev.js} +259 -137
- package/dist/{create-postcss-config-6b8ce565.esm.js → create-postcss-config-49c1fa47.esm.js} +1 -1
- package/dist/{create-postcss-config-6fff386d.cjs.dev.js → create-postcss-config-504f403c.cjs.dev.js} +1 -1
- package/dist/{create-postcss-config-1c93aee1.cjs.prod.js → create-postcss-config-e5d0a014.cjs.prod.js} +1 -1
- package/dist/{create-webpack-config-for-development-d52e3465.esm.js → create-webpack-config-for-development-48070631.esm.js} +1 -1
- package/dist/{create-webpack-config-for-development-7862d60b.cjs.prod.js → create-webpack-config-for-development-d60154cd.cjs.prod.js} +1 -1
- package/dist/{create-webpack-config-for-development-b09b0c5f.cjs.dev.js → create-webpack-config-for-development-e2a1c9bd.cjs.dev.js} +1 -1
- package/dist/{create-webpack-config-for-production-642c8695.cjs.prod.js → create-webpack-config-for-production-4c6c88bc.cjs.prod.js} +1 -1
- package/dist/{create-webpack-config-for-production-f692f390.cjs.dev.js → create-webpack-config-for-production-4ff45d93.cjs.dev.js} +1 -1
- package/dist/{create-webpack-config-for-production-32fd7b33.esm.js → create-webpack-config-for-production-c1e33f04.esm.js} +1 -1
- package/dist/declarations/src/cli.d.ts +1 -1
- package/dist/declarations/src/utils/graphql-requests.d.ts +4 -8
- package/dist/{login-24c4e83f.cjs.dev.js → login-168d82ef.cjs.dev.js} +17 -15
- package/dist/{login-705e0aa5.esm.js → login-7c781cf9.esm.js} +17 -15
- package/dist/{login-cd846c46.cjs.prod.js → login-e2768354.cjs.prod.js} +17 -15
- package/dist/{package-d914093b.cjs.dev.js → package-713de877.cjs.prod.js} +9 -8
- package/dist/{package-a6b90eee.esm.js → package-e0652585.esm.js} +9 -8
- package/dist/{package-b9ca3199.cjs.prod.js → package-e58e78de.cjs.dev.js} +9 -8
- package/dist/{start-90c560c2.cjs.dev.js → start-0a65e60b.cjs.dev.js} +3 -3
- package/dist/{start-433fd866.cjs.prod.js → start-20dc99b7.cjs.prod.js} +3 -3
- package/dist/{start-a6d5a899.esm.js → start-2ea7f237.esm.js} +3 -3
- package/dist/{user-agent-937f5fbc.cjs.prod.js → user-agent-21343cd2.cjs.prod.js} +1 -1
- package/dist/{user-agent-813349ad.cjs.dev.js → user-agent-6e93036e.cjs.dev.js} +1 -1
- package/dist/{user-agent-d6f319c7.esm.js → user-agent-cb16c720.esm.js} +1 -1
- package/package.json +9 -8
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +2 -2
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +2 -2
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +2 -2
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +4 -4
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +4 -4
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +4 -4
package/bin/cli.js
CHANGED
|
@@ -4,23 +4,23 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
|
|
6
6
|
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
7
|
+
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
7
8
|
var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
8
9
|
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
9
10
|
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
10
|
-
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
11
11
|
var fs = require('fs');
|
|
12
12
|
var path = require('path');
|
|
13
13
|
var cac = require('cac');
|
|
14
14
|
var dotenv = require('dotenv');
|
|
15
15
|
var dotenvExpand = require('dotenv-expand');
|
|
16
|
-
var _package = require('../../dist/package-
|
|
16
|
+
var _package = require('../../dist/package-e58e78de.cjs.dev.js');
|
|
17
17
|
|
|
18
18
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
19
19
|
|
|
20
|
+
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefault(_regeneratorRuntime);
|
|
20
21
|
var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
|
|
21
22
|
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
22
23
|
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
23
|
-
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefault(_regeneratorRuntime);
|
|
24
24
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
25
25
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
26
26
|
var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
|
|
@@ -36,301 +36,324 @@ process.on('unhandledRejection', function (err) {
|
|
|
36
36
|
|
|
37
37
|
var applicationDirectory = fs__default["default"].realpathSync(process.cwd());
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
cli.command('').usage('\n\n Develop and build Custom Applications.').action(function () {
|
|
43
|
-
cli.outputHelp();
|
|
44
|
-
}); // Command: start
|
|
45
|
-
|
|
46
|
-
var usageStart = 'Starts the application in development mode using Webpack Dev Server.';
|
|
47
|
-
cli.command('start', usageStart).usage("\n\n ".concat(usageStart)).alias('dev').action( /*#__PURE__*/function () {
|
|
48
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(options) {
|
|
49
|
-
var shouldUseExperimentalBundler, startCommand;
|
|
50
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
51
|
-
while (1) {
|
|
52
|
-
switch (_context.prev = _context.next) {
|
|
53
|
-
case 0:
|
|
54
|
-
// Load dotenv files into the process environment.
|
|
55
|
-
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
56
|
-
loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
|
|
57
|
-
|
|
58
|
-
process.env.BABEL_ENV = 'development';
|
|
59
|
-
process.env.NODE_ENV = 'development';
|
|
60
|
-
shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
|
|
61
|
-
|
|
62
|
-
if (shouldUseExperimentalBundler) {
|
|
63
|
-
console.log('Experimental Vite bundler enabled! 🚀');
|
|
64
|
-
console.log('');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (!shouldUseExperimentalBundler) {
|
|
68
|
-
_context.next = 11;
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
_context.next = 8;
|
|
73
|
-
return Promise.resolve().then(function () { return require('../../dist/start-vite-22de08dc.cjs.dev.js'); });
|
|
74
|
-
|
|
75
|
-
case 8:
|
|
76
|
-
_context.t0 = _context.sent;
|
|
77
|
-
_context.next = 14;
|
|
78
|
-
break;
|
|
79
|
-
|
|
80
|
-
case 11:
|
|
81
|
-
_context.next = 13;
|
|
82
|
-
return Promise.resolve().then(function () { return require('../../dist/start-90c560c2.cjs.dev.js'); });
|
|
83
|
-
|
|
84
|
-
case 13:
|
|
85
|
-
_context.t0 = _context.sent;
|
|
86
|
-
|
|
87
|
-
case 14:
|
|
88
|
-
startCommand = _context.t0;
|
|
89
|
-
_context.next = 17;
|
|
90
|
-
return startCommand.default();
|
|
91
|
-
|
|
92
|
-
case 17:
|
|
93
|
-
case "end":
|
|
94
|
-
return _context.stop();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}, _callee);
|
|
98
|
-
}));
|
|
99
|
-
|
|
100
|
-
return function (_x) {
|
|
101
|
-
return _ref.apply(this, arguments);
|
|
102
|
-
};
|
|
103
|
-
}()); // Command: build
|
|
104
|
-
|
|
105
|
-
var usageBuild = 'Bundles the application in production mode. Outputs a "public" folder.';
|
|
106
|
-
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".', {
|
|
107
|
-
default: false
|
|
108
|
-
}).action( /*#__PURE__*/function () {
|
|
109
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(options) {
|
|
110
|
-
var shouldUseExperimentalBundler, buildCommand, shouldAlsoCompile, compileHtmlCommand;
|
|
111
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
|
|
112
|
-
while (1) {
|
|
113
|
-
switch (_context2.prev = _context2.next) {
|
|
114
|
-
case 0:
|
|
115
|
-
// Load dotenv files into the process environment.
|
|
116
|
-
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
117
|
-
loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
|
|
118
|
-
|
|
119
|
-
process.env.BABEL_ENV = 'production';
|
|
120
|
-
process.env.NODE_ENV = 'production';
|
|
121
|
-
shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
|
|
122
|
-
|
|
123
|
-
if (shouldUseExperimentalBundler) {
|
|
124
|
-
console.log('Experimental Vite bundler enabled! 🚀');
|
|
125
|
-
console.log('');
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (!shouldUseExperimentalBundler) {
|
|
129
|
-
_context2.next = 11;
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
_context2.next = 8;
|
|
134
|
-
return Promise.resolve().then(function () { return require('../../dist/build-vite-3b82522e.cjs.dev.js'); });
|
|
135
|
-
|
|
136
|
-
case 8:
|
|
137
|
-
_context2.t0 = _context2.sent;
|
|
138
|
-
_context2.next = 14;
|
|
139
|
-
break;
|
|
140
|
-
|
|
141
|
-
case 11:
|
|
142
|
-
_context2.next = 13;
|
|
143
|
-
return Promise.resolve().then(function () { return require('../../dist/build-c0e3f847.cjs.dev.js'); });
|
|
144
|
-
|
|
145
|
-
case 13:
|
|
146
|
-
_context2.t0 = _context2.sent;
|
|
147
|
-
|
|
148
|
-
case 14:
|
|
149
|
-
buildCommand = _context2.t0;
|
|
150
|
-
_context2.next = 17;
|
|
151
|
-
return buildCommand.default();
|
|
152
|
-
|
|
153
|
-
case 17:
|
|
154
|
-
shouldAlsoCompile = !options.buildOnly;
|
|
155
|
-
|
|
156
|
-
if (!shouldAlsoCompile) {
|
|
157
|
-
_context2.next = 25;
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
console.log('');
|
|
162
|
-
_context2.next = 22;
|
|
163
|
-
return Promise.resolve().then(function () { return require('../../dist/compile-html-d9e731aa.cjs.dev.js'); });
|
|
164
|
-
|
|
165
|
-
case 22:
|
|
166
|
-
compileHtmlCommand = _context2.sent;
|
|
167
|
-
_context2.next = 25;
|
|
168
|
-
return compileHtmlCommand.default({
|
|
169
|
-
printSecurityHeaders: false
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
case 25:
|
|
173
|
-
case "end":
|
|
174
|
-
return _context2.stop();
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}, _callee2);
|
|
178
|
-
}));
|
|
179
|
-
|
|
180
|
-
return function (_x2) {
|
|
181
|
-
return _ref2.apply(this, arguments);
|
|
182
|
-
};
|
|
183
|
-
}()); // Command: compile-html
|
|
184
|
-
|
|
185
|
-
var 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".';
|
|
186
|
-
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.', {
|
|
187
|
-
default: false
|
|
188
|
-
}).action( /*#__PURE__*/function () {
|
|
189
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(options) {
|
|
190
|
-
var compileHtmlCommand;
|
|
191
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context3) {
|
|
192
|
-
while (1) {
|
|
193
|
-
switch (_context3.prev = _context3.next) {
|
|
194
|
-
case 0:
|
|
195
|
-
// Load dotenv files into the process environment.
|
|
196
|
-
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
197
|
-
loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
|
|
198
|
-
|
|
199
|
-
process.env.NODE_ENV = 'production';
|
|
200
|
-
_context3.next = 4;
|
|
201
|
-
return Promise.resolve().then(function () { return require('../../dist/compile-html-d9e731aa.cjs.dev.js'); });
|
|
202
|
-
|
|
203
|
-
case 4:
|
|
204
|
-
compileHtmlCommand = _context3.sent;
|
|
205
|
-
_context3.next = 7;
|
|
206
|
-
return compileHtmlCommand.default(options);
|
|
207
|
-
|
|
208
|
-
case 7:
|
|
209
|
-
case "end":
|
|
210
|
-
return _context3.stop();
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}, _callee3);
|
|
214
|
-
}));
|
|
215
|
-
|
|
216
|
-
return function (_x3) {
|
|
217
|
-
return _ref3.apply(this, arguments);
|
|
218
|
-
};
|
|
219
|
-
}()); // Command: serve
|
|
220
|
-
|
|
221
|
-
var usageServe = 'Serves previously built and compiled application from the "public" folder.';
|
|
222
|
-
cli.command('serve', usageServe).usage("\n\n ".concat(usageServe)).action( /*#__PURE__*/function () {
|
|
223
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(options) {
|
|
224
|
-
var serveCommand;
|
|
225
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context4) {
|
|
226
|
-
while (1) {
|
|
227
|
-
switch (_context4.prev = _context4.next) {
|
|
228
|
-
case 0:
|
|
229
|
-
// Load dotenv files into the process environment.
|
|
230
|
-
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
231
|
-
loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
|
|
232
|
-
|
|
233
|
-
process.env.NODE_ENV = 'production';
|
|
234
|
-
_context4.next = 4;
|
|
235
|
-
return Promise.resolve().then(function () { return require('../../dist/serve-12de323b.cjs.dev.js'); });
|
|
236
|
-
|
|
237
|
-
case 4:
|
|
238
|
-
serveCommand = _context4.sent;
|
|
239
|
-
_context4.next = 7;
|
|
240
|
-
return serveCommand.default();
|
|
241
|
-
|
|
242
|
-
case 7:
|
|
243
|
-
case "end":
|
|
244
|
-
return _context4.stop();
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}, _callee4);
|
|
248
|
-
}));
|
|
249
|
-
|
|
250
|
-
return function (_x4) {
|
|
251
|
-
return _ref4.apply(this, arguments);
|
|
252
|
-
};
|
|
253
|
-
}()); // Command: login
|
|
254
|
-
|
|
255
|
-
var 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.';
|
|
256
|
-
cli.command('login', usageLogin).usage("\n\n ".concat(usageLogin)).action( /*#__PURE__*/function () {
|
|
257
|
-
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee5(options) {
|
|
258
|
-
var loginCommand;
|
|
259
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee5$(_context5) {
|
|
260
|
-
while (1) {
|
|
261
|
-
switch (_context5.prev = _context5.next) {
|
|
262
|
-
case 0:
|
|
263
|
-
// Load dotenv files into the process environment.
|
|
264
|
-
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
265
|
-
loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
|
|
266
|
-
|
|
267
|
-
process.env.NODE_ENV = 'production';
|
|
268
|
-
_context5.next = 4;
|
|
269
|
-
return Promise.resolve().then(function () { return require('../../dist/login-24c4e83f.cjs.dev.js'); });
|
|
270
|
-
|
|
271
|
-
case 4:
|
|
272
|
-
loginCommand = _context5.sent;
|
|
273
|
-
_context5.next = 7;
|
|
274
|
-
return loginCommand.default();
|
|
275
|
-
|
|
276
|
-
case 7:
|
|
277
|
-
case "end":
|
|
278
|
-
return _context5.stop();
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}, _callee5);
|
|
282
|
-
}));
|
|
283
|
-
|
|
284
|
-
return function (_x5) {
|
|
285
|
-
return _ref5.apply(this, arguments);
|
|
286
|
-
};
|
|
287
|
-
}()); // Command: config:sync
|
|
288
|
-
|
|
289
|
-
var 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.';
|
|
290
|
-
cli.command('config:sync', usageConfigSync).usage("\n\n ".concat(usageConfigSync)).option('--dry-run', '(optional) Executes the command but does not send any mutation request.', {
|
|
291
|
-
default: false
|
|
292
|
-
}).action( /*#__PURE__*/function () {
|
|
293
|
-
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee6(options) {
|
|
294
|
-
var configSyncCommand;
|
|
295
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee6$(_context6) {
|
|
296
|
-
while (1) {
|
|
297
|
-
switch (_context6.prev = _context6.next) {
|
|
298
|
-
case 0:
|
|
299
|
-
// Load dotenv files into the process environment.
|
|
300
|
-
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
301
|
-
loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
|
|
302
|
-
|
|
303
|
-
process.env.NODE_ENV = 'production';
|
|
304
|
-
_context6.next = 4;
|
|
305
|
-
return Promise.resolve().then(function () { return require('../../dist/config-sync-00f9d9be.cjs.dev.js'); });
|
|
306
|
-
|
|
307
|
-
case 4:
|
|
308
|
-
configSyncCommand = _context6.sent;
|
|
309
|
-
_context6.next = 7;
|
|
310
|
-
return configSyncCommand.default(options);
|
|
311
|
-
|
|
312
|
-
case 7:
|
|
313
|
-
case "end":
|
|
314
|
-
return _context6.stop();
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}, _callee6);
|
|
318
|
-
}));
|
|
319
|
-
|
|
320
|
-
return function (_x6) {
|
|
321
|
-
return _ref6.apply(this, arguments);
|
|
322
|
-
};
|
|
323
|
-
}());
|
|
324
|
-
cli.help();
|
|
325
|
-
cli.version(_package.pkgJson.version);
|
|
326
|
-
cli.parse();
|
|
327
|
-
}; // Load dotenv files into the process environment.
|
|
39
|
+
function run() {
|
|
40
|
+
return _run.apply(this, arguments);
|
|
41
|
+
} // Load dotenv files into the process environment.
|
|
328
42
|
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
329
43
|
// Inspired also by https://create-react-app.dev/docs/adding-custom-environment-variables/#what-other-env-files-can-be-used
|
|
330
44
|
|
|
331
45
|
|
|
46
|
+
function _run() {
|
|
47
|
+
_run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee7() {
|
|
48
|
+
var usageStart, usageBuild, usageCompileHtml, usageServe, usageLogin, usageConfigSync;
|
|
49
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee7$(_context8) {
|
|
50
|
+
while (1) {
|
|
51
|
+
switch (_context8.prev = _context8.next) {
|
|
52
|
+
case 0:
|
|
53
|
+
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
|
|
54
|
+
|
|
55
|
+
cli.command('').usage('\n\n Develop and build Custom Applications.').action(function () {
|
|
56
|
+
cli.outputHelp();
|
|
57
|
+
}); // Command: start
|
|
58
|
+
|
|
59
|
+
usageStart = 'Starts the application in development mode using Webpack Dev Server.';
|
|
60
|
+
cli.command('start', usageStart).usage("\n\n ".concat(usageStart)).alias('dev').action( /*#__PURE__*/function () {
|
|
61
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(options) {
|
|
62
|
+
var shouldUseExperimentalBundler, startCommand;
|
|
63
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context2) {
|
|
64
|
+
while (1) {
|
|
65
|
+
switch (_context2.prev = _context2.next) {
|
|
66
|
+
case 0:
|
|
67
|
+
// Load dotenv files into the process environment.
|
|
68
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
69
|
+
loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
|
|
70
|
+
|
|
71
|
+
process.env.BABEL_ENV = 'development';
|
|
72
|
+
process.env.NODE_ENV = 'development';
|
|
73
|
+
shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
|
|
74
|
+
|
|
75
|
+
if (shouldUseExperimentalBundler) {
|
|
76
|
+
console.log('Experimental Vite bundler enabled! 🚀');
|
|
77
|
+
console.log('');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (!shouldUseExperimentalBundler) {
|
|
81
|
+
_context2.next = 11;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
_context2.next = 8;
|
|
86
|
+
return Promise.resolve().then(function () { return require('../../dist/start-vite-22de08dc.cjs.dev.js'); });
|
|
87
|
+
|
|
88
|
+
case 8:
|
|
89
|
+
_context2.t0 = _context2.sent;
|
|
90
|
+
_context2.next = 14;
|
|
91
|
+
break;
|
|
92
|
+
|
|
93
|
+
case 11:
|
|
94
|
+
_context2.next = 13;
|
|
95
|
+
return Promise.resolve().then(function () { return require('../../dist/start-0a65e60b.cjs.dev.js'); });
|
|
96
|
+
|
|
97
|
+
case 13:
|
|
98
|
+
_context2.t0 = _context2.sent;
|
|
99
|
+
|
|
100
|
+
case 14:
|
|
101
|
+
startCommand = _context2.t0;
|
|
102
|
+
_context2.next = 17;
|
|
103
|
+
return startCommand.default();
|
|
104
|
+
|
|
105
|
+
case 17:
|
|
106
|
+
case "end":
|
|
107
|
+
return _context2.stop();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}, _callee);
|
|
111
|
+
}));
|
|
112
|
+
|
|
113
|
+
return function (_x) {
|
|
114
|
+
return _ref.apply(this, arguments);
|
|
115
|
+
};
|
|
116
|
+
}()); // Command: build
|
|
117
|
+
|
|
118
|
+
usageBuild = 'Bundles the application in production mode. Outputs a "public" folder.';
|
|
119
|
+
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".', {
|
|
120
|
+
default: false
|
|
121
|
+
}).action( /*#__PURE__*/function () {
|
|
122
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(options) {
|
|
123
|
+
var shouldUseExperimentalBundler, buildCommand, shouldAlsoCompile, compileHtmlCommand;
|
|
124
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context3) {
|
|
125
|
+
while (1) {
|
|
126
|
+
switch (_context3.prev = _context3.next) {
|
|
127
|
+
case 0:
|
|
128
|
+
// Load dotenv files into the process environment.
|
|
129
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
130
|
+
loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
|
|
131
|
+
|
|
132
|
+
process.env.BABEL_ENV = 'production';
|
|
133
|
+
process.env.NODE_ENV = 'production';
|
|
134
|
+
shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
|
|
135
|
+
|
|
136
|
+
if (shouldUseExperimentalBundler) {
|
|
137
|
+
console.log('Experimental Vite bundler enabled! 🚀');
|
|
138
|
+
console.log('');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (!shouldUseExperimentalBundler) {
|
|
142
|
+
_context3.next = 11;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
_context3.next = 8;
|
|
147
|
+
return Promise.resolve().then(function () { return require('../../dist/build-vite-3b82522e.cjs.dev.js'); });
|
|
148
|
+
|
|
149
|
+
case 8:
|
|
150
|
+
_context3.t0 = _context3.sent;
|
|
151
|
+
_context3.next = 14;
|
|
152
|
+
break;
|
|
153
|
+
|
|
154
|
+
case 11:
|
|
155
|
+
_context3.next = 13;
|
|
156
|
+
return Promise.resolve().then(function () { return require('../../dist/build-906c169d.cjs.dev.js'); });
|
|
157
|
+
|
|
158
|
+
case 13:
|
|
159
|
+
_context3.t0 = _context3.sent;
|
|
160
|
+
|
|
161
|
+
case 14:
|
|
162
|
+
buildCommand = _context3.t0;
|
|
163
|
+
_context3.next = 17;
|
|
164
|
+
return buildCommand.default();
|
|
165
|
+
|
|
166
|
+
case 17:
|
|
167
|
+
shouldAlsoCompile = !options.buildOnly;
|
|
168
|
+
|
|
169
|
+
if (!shouldAlsoCompile) {
|
|
170
|
+
_context3.next = 25;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
console.log('');
|
|
175
|
+
_context3.next = 22;
|
|
176
|
+
return Promise.resolve().then(function () { return require('../../dist/compile-html-d9e731aa.cjs.dev.js'); });
|
|
177
|
+
|
|
178
|
+
case 22:
|
|
179
|
+
compileHtmlCommand = _context3.sent;
|
|
180
|
+
_context3.next = 25;
|
|
181
|
+
return compileHtmlCommand.default({
|
|
182
|
+
printSecurityHeaders: false
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
case 25:
|
|
186
|
+
case "end":
|
|
187
|
+
return _context3.stop();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}, _callee2);
|
|
191
|
+
}));
|
|
192
|
+
|
|
193
|
+
return function (_x2) {
|
|
194
|
+
return _ref2.apply(this, arguments);
|
|
195
|
+
};
|
|
196
|
+
}()); // Command: compile-html
|
|
197
|
+
|
|
198
|
+
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".';
|
|
199
|
+
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.', {
|
|
200
|
+
default: false
|
|
201
|
+
}).action( /*#__PURE__*/function () {
|
|
202
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(options) {
|
|
203
|
+
var compileHtmlCommand;
|
|
204
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context4) {
|
|
205
|
+
while (1) {
|
|
206
|
+
switch (_context4.prev = _context4.next) {
|
|
207
|
+
case 0:
|
|
208
|
+
// Load dotenv files into the process environment.
|
|
209
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
210
|
+
loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
|
|
211
|
+
|
|
212
|
+
process.env.NODE_ENV = 'production';
|
|
213
|
+
_context4.next = 4;
|
|
214
|
+
return Promise.resolve().then(function () { return require('../../dist/compile-html-d9e731aa.cjs.dev.js'); });
|
|
215
|
+
|
|
216
|
+
case 4:
|
|
217
|
+
compileHtmlCommand = _context4.sent;
|
|
218
|
+
_context4.next = 7;
|
|
219
|
+
return compileHtmlCommand.default(options);
|
|
220
|
+
|
|
221
|
+
case 7:
|
|
222
|
+
case "end":
|
|
223
|
+
return _context4.stop();
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}, _callee3);
|
|
227
|
+
}));
|
|
228
|
+
|
|
229
|
+
return function (_x3) {
|
|
230
|
+
return _ref3.apply(this, arguments);
|
|
231
|
+
};
|
|
232
|
+
}()); // Command: serve
|
|
233
|
+
|
|
234
|
+
usageServe = 'Serves previously built and compiled application from the "public" folder.';
|
|
235
|
+
cli.command('serve', usageServe).usage("\n\n ".concat(usageServe)).action( /*#__PURE__*/function () {
|
|
236
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(options) {
|
|
237
|
+
var serveCommand;
|
|
238
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context5) {
|
|
239
|
+
while (1) {
|
|
240
|
+
switch (_context5.prev = _context5.next) {
|
|
241
|
+
case 0:
|
|
242
|
+
// Load dotenv files into the process environment.
|
|
243
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
244
|
+
loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
|
|
245
|
+
|
|
246
|
+
process.env.NODE_ENV = 'production';
|
|
247
|
+
_context5.next = 4;
|
|
248
|
+
return Promise.resolve().then(function () { return require('../../dist/serve-12de323b.cjs.dev.js'); });
|
|
249
|
+
|
|
250
|
+
case 4:
|
|
251
|
+
serveCommand = _context5.sent;
|
|
252
|
+
_context5.next = 7;
|
|
253
|
+
return serveCommand.default();
|
|
254
|
+
|
|
255
|
+
case 7:
|
|
256
|
+
case "end":
|
|
257
|
+
return _context5.stop();
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}, _callee4);
|
|
261
|
+
}));
|
|
262
|
+
|
|
263
|
+
return function (_x4) {
|
|
264
|
+
return _ref4.apply(this, arguments);
|
|
265
|
+
};
|
|
266
|
+
}()); // Command: login
|
|
267
|
+
|
|
268
|
+
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.';
|
|
269
|
+
cli.command('login', usageLogin).usage("\n\n ".concat(usageLogin)).action( /*#__PURE__*/function () {
|
|
270
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee5(options) {
|
|
271
|
+
var loginCommand;
|
|
272
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee5$(_context6) {
|
|
273
|
+
while (1) {
|
|
274
|
+
switch (_context6.prev = _context6.next) {
|
|
275
|
+
case 0:
|
|
276
|
+
// Load dotenv files into the process environment.
|
|
277
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
278
|
+
loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
|
|
279
|
+
|
|
280
|
+
process.env.NODE_ENV = 'production';
|
|
281
|
+
_context6.next = 4;
|
|
282
|
+
return Promise.resolve().then(function () { return require('../../dist/login-168d82ef.cjs.dev.js'); });
|
|
283
|
+
|
|
284
|
+
case 4:
|
|
285
|
+
loginCommand = _context6.sent;
|
|
286
|
+
_context6.next = 7;
|
|
287
|
+
return loginCommand.default();
|
|
288
|
+
|
|
289
|
+
case 7:
|
|
290
|
+
case "end":
|
|
291
|
+
return _context6.stop();
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}, _callee5);
|
|
295
|
+
}));
|
|
296
|
+
|
|
297
|
+
return function (_x5) {
|
|
298
|
+
return _ref5.apply(this, arguments);
|
|
299
|
+
};
|
|
300
|
+
}()); // Command: config:sync
|
|
301
|
+
|
|
302
|
+
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.';
|
|
303
|
+
cli.command('config:sync', usageConfigSync).usage("\n\n ".concat(usageConfigSync)).option('--dry-run', '(optional) Executes the command but does not send any mutation request.', {
|
|
304
|
+
default: false
|
|
305
|
+
}).action( /*#__PURE__*/function () {
|
|
306
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee6(options) {
|
|
307
|
+
var configSyncCommand;
|
|
308
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee6$(_context7) {
|
|
309
|
+
while (1) {
|
|
310
|
+
switch (_context7.prev = _context7.next) {
|
|
311
|
+
case 0:
|
|
312
|
+
// Load dotenv files into the process environment.
|
|
313
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
314
|
+
loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
|
|
315
|
+
|
|
316
|
+
process.env.NODE_ENV = 'production';
|
|
317
|
+
_context7.next = 4;
|
|
318
|
+
return Promise.resolve().then(function () { return require('../../dist/config-sync-8c78e00f.cjs.dev.js'); });
|
|
319
|
+
|
|
320
|
+
case 4:
|
|
321
|
+
configSyncCommand = _context7.sent;
|
|
322
|
+
_context7.next = 7;
|
|
323
|
+
return configSyncCommand.default(options);
|
|
324
|
+
|
|
325
|
+
case 7:
|
|
326
|
+
case "end":
|
|
327
|
+
return _context7.stop();
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}, _callee6);
|
|
331
|
+
}));
|
|
332
|
+
|
|
333
|
+
return function (_x6) {
|
|
334
|
+
return _ref6.apply(this, arguments);
|
|
335
|
+
};
|
|
336
|
+
}());
|
|
337
|
+
cli.help();
|
|
338
|
+
cli.version(_package.pkgJson.version);
|
|
339
|
+
cli.parse(process.argv, {
|
|
340
|
+
run: false
|
|
341
|
+
});
|
|
342
|
+
_context8.next = 19;
|
|
343
|
+
return cli.runMatchedCommand();
|
|
344
|
+
|
|
345
|
+
case 19:
|
|
346
|
+
case "end":
|
|
347
|
+
return _context8.stop();
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}, _callee7);
|
|
351
|
+
}));
|
|
352
|
+
return _run.apply(this, arguments);
|
|
353
|
+
}
|
|
354
|
+
|
|
332
355
|
function loadDotEnvFiles(globalOptions) {
|
|
333
|
-
var
|
|
356
|
+
var _context;
|
|
334
357
|
|
|
335
358
|
var environment = process.env.MC_APP_ENV || process.env.NODE_ENV;
|
|
336
359
|
var dotenvFiles = []; // Custom dotenv files specified by the `--env` option takes precedence.
|
|
@@ -343,10 +366,10 @@ function loadDotEnvFiles(globalOptions) {
|
|
|
343
366
|
} // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
|
|
344
367
|
|
|
345
368
|
|
|
346
|
-
dotenvFiles.push.apply(dotenvFiles, _toConsumableArray(_filterInstanceProperty__default["default"](
|
|
369
|
+
dotenvFiles.push.apply(dotenvFiles, _toConsumableArray(_filterInstanceProperty__default["default"](_context = [".env.".concat(environment, ".local"), // Don't include `.env.local` for `test` environment
|
|
347
370
|
// since normally you expect tests to produce the same
|
|
348
371
|
// results for everyone
|
|
349
|
-
process.env.NODE_ENV !== 'test' && ".env.local", ".env.".concat(environment), '.env']).call(
|
|
372
|
+
process.env.NODE_ENV !== 'test' && ".env.local", ".env.".concat(environment), '.env']).call(_context, Boolean))); // Load environment variables from .env* files. Suppress warnings using silent
|
|
350
373
|
// if this file is missing. dotenv will never modify any environment variables
|
|
351
374
|
// that have already been set. Variable expansion is supported in .env files.
|
|
352
375
|
// https://github.com/motdotla/dotenv
|