@commercetools-frontend/mc-scripts 21.23.10 → 21.24.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.
Files changed (89) hide show
  1. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +120 -326
  2. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +120 -326
  3. package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +116 -321
  4. package/dist/build-980cf2c9.cjs.prod.js +170 -0
  5. package/dist/build-c9601b07.esm.js +156 -0
  6. package/dist/build-e8a49b56.cjs.dev.js +170 -0
  7. package/dist/build-vite-b531d3d3.esm.js +118 -0
  8. package/dist/build-vite-c40a55c3.cjs.dev.js +129 -0
  9. package/dist/build-vite-d17432ec.cjs.prod.js +129 -0
  10. package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +2 -2
  11. package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +2 -2
  12. package/dist/commercetools-frontend-mc-scripts.esm.js +2 -2
  13. package/dist/compile-html-41195e35.cjs.dev.js +49 -0
  14. package/dist/compile-html-5abd78aa.cjs.prod.js +49 -0
  15. package/dist/compile-html-f9de842c.esm.js +40 -0
  16. package/dist/config-sync-0ecc13b3.cjs.dev.js +783 -0
  17. package/dist/config-sync-4b1ddec3.esm.js +759 -0
  18. package/dist/config-sync-bb59a82d.cjs.prod.js +778 -0
  19. package/dist/{create-postcss-config-f65c7e31.cjs.dev.js → create-postcss-config-5cc679d5.cjs.dev.js} +9 -14
  20. package/dist/{create-postcss-config-06b2e5c2.esm.js → create-postcss-config-a0d4cffa.esm.js} +9 -13
  21. package/dist/{create-postcss-config-787d905f.cjs.prod.js → create-postcss-config-f94c07fd.cjs.prod.js} +9 -14
  22. package/dist/{create-webpack-config-for-development-fd365d6a.esm.js → create-webpack-config-for-development-95334073.esm.js} +21 -25
  23. package/dist/{create-webpack-config-for-development-d46ef148.cjs.dev.js → create-webpack-config-for-development-a53bab71.cjs.dev.js} +24 -28
  24. package/dist/{create-webpack-config-for-development-59faaed8.cjs.prod.js → create-webpack-config-for-development-c915ec0c.cjs.prod.js} +24 -28
  25. package/dist/{create-webpack-config-for-production-b28b3d33.esm.js → create-webpack-config-for-production-342485cd.esm.js} +18 -21
  26. package/dist/{create-webpack-config-for-production-1af3a454.cjs.prod.js → create-webpack-config-for-production-af6f3138.cjs.prod.js} +20 -23
  27. package/dist/{create-webpack-config-for-production-e12e3c30.cjs.dev.js → create-webpack-config-for-production-db45d9ab.cjs.dev.js} +20 -23
  28. package/dist/{user-agent-9a470e39.cjs.dev.js → credentials-storage-a37a8915.cjs.dev.js} +24 -24
  29. package/dist/{user-agent-6e8d0e0b.cjs.prod.js → credentials-storage-b803a804.cjs.prod.js} +24 -24
  30. package/dist/{user-agent-4b60934e.esm.js → credentials-storage-cb88e8fc.esm.js} +22 -22
  31. package/dist/declarations/src/deprecated-entry-points.d.ts +1 -1
  32. package/dist/login-35040a86.cjs.dev.js +93 -0
  33. package/dist/login-6e17747d.esm.js +84 -0
  34. package/dist/login-90736d7e.cjs.prod.js +93 -0
  35. package/dist/{package-a5454c97.esm.js → package-17f18481.esm.js} +17 -16
  36. package/dist/{package-e2d9b5e0.cjs.dev.js → package-c42dc2ac.cjs.dev.js} +17 -16
  37. package/dist/{package-808a31f1.cjs.prod.js → package-db15171f.cjs.prod.js} +17 -16
  38. package/dist/{paths-76b66e74.cjs.prod.js → paths-284c77fb.cjs.prod.js} +6 -8
  39. package/dist/{paths-ed23d5a1.esm.js → paths-55c5d5a2.esm.js} +6 -8
  40. package/dist/{paths-16823f56.cjs.dev.js → paths-db35ac0f.cjs.dev.js} +6 -8
  41. package/dist/serve-41077dad.cjs.prod.js +48 -0
  42. package/dist/serve-660e2ee0.esm.js +41 -0
  43. package/dist/serve-b8063204.cjs.dev.js +48 -0
  44. package/dist/start-0aa71e9a.esm.js +166 -0
  45. package/dist/start-2e7ec87c.cjs.dev.js +180 -0
  46. package/dist/start-c0ffe8d7.cjs.prod.js +180 -0
  47. package/dist/start-vite-324af14d.cjs.prod.js +119 -0
  48. package/dist/start-vite-7d10ae71.esm.js +107 -0
  49. package/dist/start-vite-8f03b0df.cjs.dev.js +119 -0
  50. package/dist/{vendors-to-transpile-367e0ba8.cjs.prod.js → vendors-to-transpile-04a49d40.cjs.prod.js} +1 -1
  51. package/dist/{vendors-to-transpile-b51af5d3.cjs.dev.js → vendors-to-transpile-6ab4ea06.cjs.dev.js} +1 -1
  52. package/dist/{vendors-to-transpile-68e03526.esm.js → vendors-to-transpile-7dc84a72.esm.js} +1 -1
  53. package/dist/vite-plugin-svgr-9a4e7f77.cjs.prod.js +79 -0
  54. package/dist/vite-plugin-svgr-f17db78a.esm.js +55 -0
  55. package/dist/vite-plugin-svgr-fdb37ccf.cjs.dev.js +79 -0
  56. package/package.json +17 -16
  57. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +2 -4
  58. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +2 -4
  59. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +2 -4
  60. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +12 -13
  61. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +12 -13
  62. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +12 -13
  63. package/dist/build-0e6d74d1.esm.js +0 -209
  64. package/dist/build-9074fc85.cjs.dev.js +0 -224
  65. package/dist/build-ae132901.cjs.prod.js +0 -224
  66. package/dist/build-vite-482a21b8.cjs.dev.js +0 -151
  67. package/dist/build-vite-cc68e3bf.esm.js +0 -139
  68. package/dist/build-vite-f095b68d.cjs.prod.js +0 -151
  69. package/dist/compile-html-4361a0b3.esm.js +0 -77
  70. package/dist/compile-html-d6331c35.cjs.prod.js +0 -87
  71. package/dist/compile-html-d9e731aa.cjs.dev.js +0 -87
  72. package/dist/config-sync-2a9945bc.cjs.dev.js +0 -989
  73. package/dist/config-sync-43a80f60.cjs.prod.js +0 -984
  74. package/dist/config-sync-c6c4d1cf.esm.js +0 -964
  75. package/dist/login-7f1cc8d0.cjs.prod.js +0 -167
  76. package/dist/login-d21a49e8.esm.js +0 -157
  77. package/dist/login-ed827138.cjs.dev.js +0 -167
  78. package/dist/serve-12de323b.cjs.dev.js +0 -70
  79. package/dist/serve-784f4fcd.cjs.prod.js +0 -70
  80. package/dist/serve-d6b437b1.esm.js +0 -62
  81. package/dist/start-10a4d95a.esm.js +0 -194
  82. package/dist/start-d021fa98.cjs.prod.js +0 -209
  83. package/dist/start-eea524f2.cjs.dev.js +0 -209
  84. package/dist/start-vite-57ec5175.cjs.dev.js +0 -146
  85. package/dist/start-vite-94c2db8c.esm.js +0 -133
  86. package/dist/start-vite-fc0b15d3.cjs.prod.js +0 -146
  87. package/dist/vite-plugin-svgr-4205f2b5.cjs.dev.js +0 -110
  88. package/dist/vite-plugin-svgr-eb8524fa.esm.js +0 -85
  89. package/dist/vite-plugin-svgr-f3bbedbe.cjs.prod.js +0 -110
@@ -1,6 +1,3 @@
1
- import _toConsumableArray from '@babel/runtime-corejs3/helpers/esm/toConsumableArray';
2
- import _asyncToGenerator from '@babel/runtime-corejs3/helpers/esm/asyncToGenerator';
3
- import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
4
1
  import _Array$isArray from '@babel/runtime-corejs3/core-js-stable/array/is-array';
5
2
  import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
6
3
  import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
@@ -9,359 +6,157 @@ import path from 'path';
9
6
  import { cac } from 'cac';
10
7
  import dotenv from 'dotenv';
11
8
  import dotenvExpand from 'dotenv-expand';
12
- import { p as pkgJson } from '../../dist/package-a5454c97.esm.js';
9
+ import { p as pkgJson } from '../../dist/package-17f18481.esm.js';
13
10
 
14
- var cli = cac('mc-scripts'); // Makes the script crash on unhandled rejections instead of silently
11
+ const cli = cac('mc-scripts'); // Makes the script crash on unhandled rejections instead of silently
15
12
  // ignoring them. In the future, promise rejections that are not handled will
16
13
  // terminate the Node.js process with a non-zero exit code.
17
14
 
18
- process.on('unhandledRejection', function (err) {
15
+ process.on('unhandledRejection', err => {
19
16
  throw err;
20
17
  }); // Get the current directory where the CLI is executed from. Usually this is the application folder.
21
18
 
22
- var applicationDirectory = fs.realpathSync(process.cwd());
19
+ const applicationDirectory = fs.realpathSync(process.cwd());
23
20
 
24
- function run() {
25
- return _run.apply(this, arguments);
26
- } // Load dotenv files into the process environment.
27
- // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
28
- // Inspired also by https://create-react-app.dev/docs/adding-custom-environment-variables/#what-other-env-files-can-be-used
29
-
30
-
31
- function _run() {
32
- _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
33
- var usageStart, usageBuild, usageCompileHtml, usageServe, usageLogin, usageConfigSync;
34
- return _regeneratorRuntime.wrap(function _callee7$(_context8) {
35
- while (1) {
36
- switch (_context8.prev = _context8.next) {
37
- case 0:
38
- 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
39
-
40
- cli.command('').usage('\n\n Develop and build Custom Applications.').action(function () {
41
- cli.outputHelp();
42
- }); // Command: start
43
-
44
- usageStart = 'Starts the application in development mode using Webpack Dev Server.';
45
- cli.command('start', usageStart).usage("\n\n ".concat(usageStart)).alias('dev').action( /*#__PURE__*/function () {
46
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
47
- var shouldUseExperimentalBundler, startCommand;
48
- return _regeneratorRuntime.wrap(function _callee$(_context2) {
49
- while (1) {
50
- switch (_context2.prev = _context2.next) {
51
- case 0:
52
- // Load dotenv files into the process environment.
53
- // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
54
- loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
55
-
56
- process.env.BABEL_ENV = 'development';
57
- process.env.NODE_ENV = 'development';
58
- shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
59
-
60
- if (shouldUseExperimentalBundler) {
61
- console.log('Experimental Vite bundler enabled! 🚀');
62
- console.log('');
63
- }
64
-
65
- if (!shouldUseExperimentalBundler) {
66
- _context2.next = 11;
67
- break;
68
- }
69
-
70
- _context2.next = 8;
71
- return import('../../dist/start-vite-94c2db8c.esm.js');
72
-
73
- case 8:
74
- _context2.t0 = _context2.sent;
75
- _context2.next = 14;
76
- break;
77
-
78
- case 11:
79
- _context2.next = 13;
80
- return import('../../dist/start-10a4d95a.esm.js');
81
-
82
- case 13:
83
- _context2.t0 = _context2.sent;
84
-
85
- case 14:
86
- startCommand = _context2.t0;
87
- _context2.next = 17;
88
- return startCommand.default();
89
-
90
- case 17:
91
- case "end":
92
- return _context2.stop();
93
- }
94
- }
95
- }, _callee);
96
- }));
97
-
98
- return function (_x) {
99
- return _ref.apply(this, arguments);
100
- };
101
- }()); // Command: build
102
-
103
- usageBuild = 'Bundles the application in production mode. Outputs a "public" folder.';
104
- 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".', {
105
- default: false
106
- }).action( /*#__PURE__*/function () {
107
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(options) {
108
- var shouldUseExperimentalBundler, buildCommand, shouldAlsoCompile, compileHtmlCommand;
109
- return _regeneratorRuntime.wrap(function _callee2$(_context3) {
110
- while (1) {
111
- switch (_context3.prev = _context3.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.log('');
124
- }
125
-
126
- if (!shouldUseExperimentalBundler) {
127
- _context3.next = 11;
128
- break;
129
- }
130
-
131
- _context3.next = 8;
132
- return import('../../dist/build-vite-cc68e3bf.esm.js');
133
-
134
- case 8:
135
- _context3.t0 = _context3.sent;
136
- _context3.next = 14;
137
- break;
138
-
139
- case 11:
140
- _context3.next = 13;
141
- return import('../../dist/build-0e6d74d1.esm.js');
142
-
143
- case 13:
144
- _context3.t0 = _context3.sent;
145
-
146
- case 14:
147
- buildCommand = _context3.t0;
148
- _context3.next = 17;
149
- return buildCommand.default();
150
-
151
- case 17:
152
- shouldAlsoCompile = !options.buildOnly;
21
+ 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."); // Default command
153
23
 
154
- if (!shouldAlsoCompile) {
155
- _context3.next = 25;
156
- break;
157
- }
24
+ cli.command('').usage('\n\n Develop and build Custom Applications.').action(() => {
25
+ cli.outputHelp();
26
+ }); // Command: start
158
27
 
159
- console.log('');
160
- _context3.next = 22;
161
- return import('../../dist/compile-html-4361a0b3.esm.js');
28
+ const usageStart = 'Starts the application in development mode using Webpack Dev Server.';
29
+ cli.command('start', usageStart).usage("\n\n ".concat(usageStart)).alias('dev').action(async options => {
30
+ // Load dotenv files into the process environment.
31
+ // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
32
+ loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
162
33
 
163
- case 22:
164
- compileHtmlCommand = _context3.sent;
165
- _context3.next = 25;
166
- return compileHtmlCommand.default({
167
- printSecurityHeaders: false
168
- });
34
+ process.env.BABEL_ENV = 'development';
35
+ process.env.NODE_ENV = 'development';
36
+ const shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
169
37
 
170
- case 25:
171
- case "end":
172
- return _context3.stop();
173
- }
174
- }
175
- }, _callee2);
176
- }));
177
-
178
- return function (_x2) {
179
- return _ref2.apply(this, arguments);
180
- };
181
- }()); // Command: compile-html
182
-
183
- 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".';
184
- 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.', {
185
- default: false
186
- }).action( /*#__PURE__*/function () {
187
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(options) {
188
- var compileHtmlCommand;
189
- return _regeneratorRuntime.wrap(function _callee3$(_context4) {
190
- while (1) {
191
- switch (_context4.prev = _context4.next) {
192
- case 0:
193
- // Load dotenv files into the process environment.
194
- // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
195
- loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
196
-
197
- process.env.NODE_ENV = 'production';
198
- _context4.next = 4;
199
- return import('../../dist/compile-html-4361a0b3.esm.js');
200
-
201
- case 4:
202
- compileHtmlCommand = _context4.sent;
203
- _context4.next = 7;
204
- return compileHtmlCommand.default(options);
205
-
206
- case 7:
207
- case "end":
208
- return _context4.stop();
209
- }
210
- }
211
- }, _callee3);
212
- }));
213
-
214
- return function (_x3) {
215
- return _ref3.apply(this, arguments);
216
- };
217
- }()); // Command: serve
218
-
219
- usageServe = 'Serves previously built and compiled application from the "public" folder.';
220
- cli.command('serve', usageServe).usage("\n\n ".concat(usageServe)).action( /*#__PURE__*/function () {
221
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(options) {
222
- var serveCommand;
223
- return _regeneratorRuntime.wrap(function _callee4$(_context5) {
224
- while (1) {
225
- switch (_context5.prev = _context5.next) {
226
- case 0:
227
- // Load dotenv files into the process environment.
228
- // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
229
- loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
230
-
231
- process.env.NODE_ENV = 'production';
232
- _context5.next = 4;
233
- return import('../../dist/serve-d6b437b1.esm.js');
234
-
235
- case 4:
236
- serveCommand = _context5.sent;
237
- _context5.next = 7;
238
- return serveCommand.default();
239
-
240
- case 7:
241
- case "end":
242
- return _context5.stop();
243
- }
244
- }
245
- }, _callee4);
246
- }));
247
-
248
- return function (_x4) {
249
- return _ref4.apply(this, arguments);
250
- };
251
- }()); // Command: login
252
-
253
- 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.';
254
- cli.command('login', usageLogin).usage("\n\n ".concat(usageLogin)).action( /*#__PURE__*/function () {
255
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(options) {
256
- var loginCommand;
257
- return _regeneratorRuntime.wrap(function _callee5$(_context6) {
258
- while (1) {
259
- switch (_context6.prev = _context6.next) {
260
- case 0:
261
- // Load dotenv files into the process environment.
262
- // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
263
- loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
264
-
265
- process.env.NODE_ENV = 'production';
266
- _context6.next = 4;
267
- return import('../../dist/login-d21a49e8.esm.js');
268
-
269
- case 4:
270
- loginCommand = _context6.sent;
271
- _context6.next = 7;
272
- return loginCommand.default();
273
-
274
- case 7:
275
- case "end":
276
- return _context6.stop();
277
- }
278
- }
279
- }, _callee5);
280
- }));
281
-
282
- return function (_x5) {
283
- return _ref5.apply(this, arguments);
284
- };
285
- }()); // Command: config:sync
286
-
287
- 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.';
288
- cli.command('config:sync', usageConfigSync).usage("\n\n ".concat(usageConfigSync)).option('--dry-run', '(optional) Executes the command but does not send any mutation request.', {
289
- default: false
290
- }).action( /*#__PURE__*/function () {
291
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(options) {
292
- var configSyncCommand;
293
- return _regeneratorRuntime.wrap(function _callee6$(_context7) {
294
- while (1) {
295
- switch (_context7.prev = _context7.next) {
296
- case 0:
297
- // Load dotenv files into the process environment.
298
- // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
299
- loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
300
-
301
- process.env.NODE_ENV = 'production';
302
- _context7.next = 4;
303
- return import('../../dist/config-sync-c6c4d1cf.esm.js');
38
+ if (shouldUseExperimentalBundler) {
39
+ console.log('Experimental Vite bundler enabled! 🚀');
40
+ console.log('');
41
+ }
304
42
 
305
- case 4:
306
- configSyncCommand = _context7.sent;
307
- _context7.next = 7;
308
- return configSyncCommand.default(options);
43
+ const startCommand = shouldUseExperimentalBundler ? await import('../../dist/start-vite-7d10ae71.esm.js') : await import('../../dist/start-0aa71e9a.esm.js');
44
+ await startCommand.default();
45
+ }); // Command: build
46
+
47
+ const usageBuild = 'Bundles the application in production mode. Outputs a "public" folder.';
48
+ 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
+ default: false
50
+ }).action(async options => {
51
+ // Load dotenv files into the process environment.
52
+ // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
53
+ loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
54
+
55
+ process.env.BABEL_ENV = 'production';
56
+ process.env.NODE_ENV = 'production';
57
+ const shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
58
+
59
+ if (shouldUseExperimentalBundler) {
60
+ console.log('Experimental Vite bundler enabled! 🚀');
61
+ console.log('');
62
+ }
309
63
 
310
- case 7:
311
- case "end":
312
- return _context7.stop();
313
- }
314
- }
315
- }, _callee6);
316
- }));
64
+ const buildCommand = shouldUseExperimentalBundler ? await import('../../dist/build-vite-b531d3d3.esm.js') : await import('../../dist/build-c9601b07.esm.js');
65
+ await buildCommand.default();
66
+ const shouldAlsoCompile = !options.buildOnly;
317
67
 
318
- return function (_x6) {
319
- return _ref6.apply(this, arguments);
320
- };
321
- }());
322
- cli.help();
323
- cli.version(pkgJson.version);
324
- cli.parse(process.argv, {
325
- run: false
326
- });
327
- _context8.next = 19;
328
- return cli.runMatchedCommand();
68
+ if (shouldAlsoCompile) {
69
+ console.log('');
70
+ const compileHtmlCommand = await import('../../dist/compile-html-f9de842c.esm.js');
71
+ await compileHtmlCommand.default({
72
+ printSecurityHeaders: false
73
+ });
74
+ }
75
+ }); // Command: compile-html
76
+
77
+ 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
+ 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
+ default: false
80
+ }).action(async options => {
81
+ // Load dotenv files into the process environment.
82
+ // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
83
+ loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
84
+
85
+ process.env.NODE_ENV = 'production';
86
+ const compileHtmlCommand = await import('../../dist/compile-html-f9de842c.esm.js');
87
+ await compileHtmlCommand.default(options);
88
+ }); // Command: serve
89
+
90
+ const usageServe = 'Serves previously built and compiled application from the "public" folder.';
91
+ cli.command('serve', usageServe).usage("\n\n ".concat(usageServe)).action(async options => {
92
+ // Load dotenv files into the process environment.
93
+ // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
94
+ loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
95
+
96
+ process.env.NODE_ENV = 'production';
97
+ const serveCommand = await import('../../dist/serve-660e2ee0.esm.js');
98
+ await serveCommand.default();
99
+ }); // Command: login
100
+
101
+ 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
+ cli.command('login', usageLogin).usage("\n\n ".concat(usageLogin)).action(async options => {
103
+ // Load dotenv files into the process environment.
104
+ // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
105
+ loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
106
+
107
+ process.env.NODE_ENV = 'production';
108
+ const loginCommand = await import('../../dist/login-6e17747d.esm.js');
109
+ await loginCommand.default();
110
+ }); // Command: config:sync
111
+
112
+ 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
+ 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
+ default: false
115
+ }).action(async options => {
116
+ // Load dotenv files into the process environment.
117
+ // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
118
+ loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
119
+
120
+ process.env.NODE_ENV = 'production';
121
+ const configSyncCommand = await import('../../dist/config-sync-4b1ddec3.esm.js');
122
+ await configSyncCommand.default(options);
123
+ });
124
+ cli.help();
125
+ cli.version(pkgJson.version);
126
+ cli.parse(process.argv, {
127
+ run: false
128
+ });
129
+ await cli.runMatchedCommand();
130
+ } // Load dotenv files into the process environment.
131
+ // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
132
+ // Inspired also by https://create-react-app.dev/docs/adding-custom-environment-variables/#what-other-env-files-can-be-used
329
133
 
330
- case 19:
331
- case "end":
332
- return _context8.stop();
333
- }
334
- }
335
- }, _callee7);
336
- }));
337
- return _run.apply(this, arguments);
338
- }
339
134
 
340
135
  function loadDotEnvFiles(globalOptions) {
341
136
  var _context;
342
137
 
343
- var environment = process.env.MC_APP_ENV || process.env.NODE_ENV;
344
- var dotenvFiles = []; // Custom dotenv files specified by the `--env` option takes precedence.
138
+ const environment = process.env.MC_APP_ENV || process.env.NODE_ENV;
139
+ const dotenvFiles = []; // Custom dotenv files specified by the `--env` option takes precedence.
345
140
 
346
141
  if (typeof globalOptions.env === 'string') {
347
142
  dotenvFiles.push(globalOptions.env);
348
143
  } else if (_Array$isArray(globalOptions.env)) {
349
144
  // Multiple `--env` options are allowed.
350
- dotenvFiles.push.apply(dotenvFiles, _toConsumableArray(globalOptions.env));
145
+ dotenvFiles.push(...globalOptions.env);
351
146
  } // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
352
147
 
353
148
 
354
- dotenvFiles.push.apply(dotenvFiles, _toConsumableArray(_filterInstanceProperty(_context = [".env.".concat(environment, ".local"), // Don't include `.env.local` for `test` environment
149
+ dotenvFiles.push(..._filterInstanceProperty(_context = [".env.".concat(environment, ".local"), // Don't include `.env.local` for `test` environment
355
150
  // since normally you expect tests to produce the same
356
151
  // results for everyone
357
- process.env.NODE_ENV !== 'test' && ".env.local", ".env.".concat(environment), '.env']).call(_context, Boolean))); // Load environment variables from .env* files. Suppress warnings using silent
152
+ process.env.NODE_ENV !== 'test' && ".env.local", ".env.".concat(environment), '.env']).call(_context, Boolean)); // Load environment variables from .env* files. Suppress warnings using silent
358
153
  // if this file is missing. dotenv will never modify any environment variables
359
154
  // that have already been set. Variable expansion is supported in .env files.
360
155
  // https://github.com/motdotla/dotenv
361
156
  // https://github.com/motdotla/dotenv-expand
362
157
 
363
- _forEachInstanceProperty(dotenvFiles).call(dotenvFiles, function (dotenvFile) {
364
- var dotenvFilePath = path.resolve(path.join(applicationDirectory, dotenvFile));
158
+ _forEachInstanceProperty(dotenvFiles).call(dotenvFiles, dotenvFile => {
159
+ const dotenvFilePath = path.resolve(path.join(applicationDirectory, dotenvFile));
365
160
 
366
161
  if (fs.existsSync(dotenvFilePath)) {
367
162
  dotenvExpand.expand(dotenv.config({
@@ -0,0 +1,170 @@
1
+ 'use strict';
2
+
3
+ var _Promise = require('@babel/runtime-corejs3/core-js-stable/promise');
4
+ var path = require('path');
5
+ var chalk = require('chalk');
6
+ var fs = require('fs-extra');
7
+ var checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
8
+ var FileSizeReporter = require('react-dev-utils/FileSizeReporter');
9
+ var formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
10
+ var printBuildError = require('react-dev-utils/printBuildError');
11
+ var webpack = require('webpack');
12
+ var assets = require('@commercetools-frontend/assets');
13
+ var createWebpackConfigForProduction = require('./create-webpack-config-for-production-af6f3138.cjs.prod.js');
14
+ var paths = require('./paths-284c77fb.cjs.prod.js');
15
+ require('@babel/runtime-corejs3/core-js-stable/object/keys');
16
+ require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
17
+ require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
18
+ require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
19
+ require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
20
+ require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
21
+ require('@babel/runtime-corejs3/core-js-stable/object/define-property');
22
+ require('@babel/runtime-corejs3/helpers/defineProperty');
23
+ require('@babel/runtime-corejs3/core-js-stable/instance/filter');
24
+ require('@babel/runtime-corejs3/core-js-stable/instance/map');
25
+ require('@babel/runtime-corejs3/core-js-stable/json/stringify');
26
+ require('@babel/runtime-corejs3/core-js-stable/instance/ends-with');
27
+ require('@babel/runtime-corejs3/core-js-stable/number/is-integer');
28
+ require('@babel/runtime-corejs3/core-js-stable/instance/concat');
29
+ require('css-minimizer-webpack-plugin');
30
+ require('html-webpack-plugin');
31
+ require('mini-css-extract-plugin');
32
+ require('moment-locales-webpack-plugin');
33
+ require('terser-webpack-plugin');
34
+ require('webpack-bundle-analyzer');
35
+ require('@babel/runtime-corejs3/helpers/classCallCheck');
36
+ require('@babel/runtime-corejs3/helpers/createClass');
37
+ require('@babel/runtime-corejs3/core-js-stable/instance/bind');
38
+ require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
39
+ require('@babel/runtime-corejs3/core-js-stable/object/assign');
40
+ require('fs');
41
+ require('./create-postcss-config-f94c07fd.cjs.prod.js');
42
+ require('@babel/runtime-corejs3/helpers/slicedToArray');
43
+ require('./package-db15171f.cjs.prod.js');
44
+ require('./has-jsx-runtime-0b03b72e.cjs.prod.js');
45
+ require('./vendors-to-transpile-04a49d40.cjs.prod.js');
46
+ require('@babel/runtime-corejs3/core-js-stable/instance/find');
47
+
48
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
49
+
50
+ var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
51
+ var path__default = /*#__PURE__*/_interopDefault(path);
52
+ var chalk__default = /*#__PURE__*/_interopDefault(chalk);
53
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
54
+ var checkRequiredFiles__default = /*#__PURE__*/_interopDefault(checkRequiredFiles);
55
+ var FileSizeReporter__default = /*#__PURE__*/_interopDefault(FileSizeReporter);
56
+ var formatWebpackMessages__default = /*#__PURE__*/_interopDefault(formatWebpackMessages);
57
+ var printBuildError__default = /*#__PURE__*/_interopDefault(printBuildError);
58
+ var webpack__default = /*#__PURE__*/_interopDefault(webpack);
59
+
60
+ const measureFileSizesBeforeBuild = FileSizeReporter__default["default"].measureFileSizesBeforeBuild;
61
+ const printFileSizesAfterBuild = FileSizeReporter__default["default"].printFileSizesAfterBuild; // These sizes are pretty large. We'll warn for bundles exceeding them.
62
+
63
+ const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
64
+ const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
65
+
66
+ async function run() {
67
+ const hasWebpackConfig = fs__default["default"].existsSync(paths.paths.appWebpackConfig); // Warn and crash if required files are missing
68
+
69
+ if (!checkRequiredFiles__default["default"]([])) {
70
+ process.exit(1);
71
+ } // First, read the current file sizes in build directory.
72
+ // This lets us display how much they changed later.
73
+
74
+
75
+ const previousFileSizes = await measureFileSizesBeforeBuild(paths.paths.appBuild); // Remove all content but keep the directory so that
76
+ // if you're in it, you don't end up in Trash
77
+
78
+ fs__default["default"].emptyDirSync(paths.paths.appBuild); // Copy default files
79
+
80
+ copyDefaultFiles();
81
+
82
+ try {
83
+ // Start the webpack build
84
+ const result = await build();
85
+
86
+ if (result.warnings.length) {
87
+ console.log(chalk__default["default"].yellow('Compiled with warnings.\n'));
88
+ console.log(result.warnings.join('\n\n'));
89
+ console.log("\nSearch for the ".concat(chalk__default["default"].underline(chalk__default["default"].yellow('keywords')), " to learn more about each warning."));
90
+ console.log("To ignore, add ".concat(chalk__default["default"].cyan('// eslint-disable-next-line'), " to the line before.\n"));
91
+ } else {
92
+ console.log(chalk__default["default"].green('Compiled successfully.\n'));
93
+ }
94
+
95
+ console.log('File sizes after gzip:\n');
96
+ printFileSizesAfterBuild(result.stats, previousFileSizes, paths.paths.appBuild, WARN_AFTER_BUNDLE_GZIP_SIZE, WARN_AFTER_CHUNK_GZIP_SIZE);
97
+ console.log();
98
+ } catch (error) {
99
+ if (error instanceof Error) {
100
+ printBuildError__default["default"](error);
101
+ }
102
+
103
+ throw new Error("Failed to compile");
104
+ } // Create the production build and print the deployment instructions.
105
+
106
+
107
+ async function build() {
108
+ console.log('Creating an optimized production build...');
109
+ const config = hasWebpackConfig ? require(paths.paths.appWebpackConfig) : createWebpackConfigForProduction.createWebpackConfigForProduction();
110
+ const compiler = webpack__default["default"](config);
111
+ return new _Promise__default["default"]((resolve, reject) => {
112
+ compiler.run((err, stats) => {
113
+ let messages;
114
+
115
+ if (err) {
116
+ if (!err.message) {
117
+ return reject(err);
118
+ }
119
+
120
+ let errMessage = err.message; // Add additional information for postcss errors
121
+
122
+ if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
123
+ errMessage += '\nCompileError: Begins at CSS selector ' + // @ts-ignore
124
+ err['postcssNode'].selector;
125
+ }
126
+
127
+ messages = formatWebpackMessages__default["default"]({
128
+ // @ts-ignore
129
+ errors: [errMessage],
130
+ warnings: []
131
+ });
132
+ } else {
133
+ messages = formatWebpackMessages__default["default"](stats === null || stats === void 0 ? void 0 : stats.toJson({
134
+ all: false,
135
+ warnings: true,
136
+ errors: true
137
+ }));
138
+ }
139
+
140
+ if (messages.errors.length) {
141
+ // Only keep the first error. Others are often indicative
142
+ // of the same problem, but confuse the reader with noise.
143
+ if (messages.errors.length > 1) {
144
+ messages.errors.length = 1;
145
+ }
146
+
147
+ return reject(new Error(messages.errors.join('\n\n')));
148
+ }
149
+
150
+ if (process.env.CI && (typeof process.env.CI !== 'string' || process.env.CI.toLowerCase() !== 'false') && messages.warnings.length) {
151
+ console.log(chalk__default["default"].yellow('\nTreating warnings as errors because process.env.CI = true.\n' + 'Most CI servers set it automatically.\n'));
152
+ return reject(new Error(messages.warnings.join('\n\n')));
153
+ }
154
+
155
+ return resolve({
156
+ stats: stats,
157
+ warnings: messages.warnings
158
+ });
159
+ });
160
+ });
161
+ }
162
+
163
+ function copyDefaultFiles() {
164
+ fs__default["default"].copySync(path__default["default"].join(assets.packageLocation, 'html-page'), paths.paths.appBuild, {
165
+ dereference: true
166
+ });
167
+ }
168
+ }
169
+
170
+ exports["default"] = run;