@commercetools-frontend/mc-scripts 0.0.0-FEC-157-preview-releases-20241126230331

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 (156) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -0
  3. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.d.ts +2 -0
  4. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.d.ts.map +1 -0
  5. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.dev.js +7 -0
  6. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.js +7 -0
  7. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js +7 -0
  8. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.esm.js +5 -0
  9. package/application-runtime/package.json +4 -0
  10. package/bin/cli.js +8 -0
  11. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.d.ts +2 -0
  12. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.d.ts.map +1 -0
  13. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +211 -0
  14. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.js +7 -0
  15. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +211 -0
  16. package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +196 -0
  17. package/cli/package.json +4 -0
  18. package/config/create-webpack-config-for-development.js +8 -0
  19. package/config/create-webpack-config-for-production.js +8 -0
  20. package/config/vendors-to-transpile.js +6 -0
  21. package/dist/build-99744dae.cjs.prod.js +166 -0
  22. package/dist/build-a93715aa.esm.js +152 -0
  23. package/dist/build-f56ce7ec.cjs.dev.js +166 -0
  24. package/dist/build-vite-000f0a2d.cjs.prod.js +193 -0
  25. package/dist/build-vite-722f0dcf.esm.js +182 -0
  26. package/dist/build-vite-838c8e01.cjs.dev.js +193 -0
  27. package/dist/commercetools-frontend-mc-scripts.cjs.d.ts +2 -0
  28. package/dist/commercetools-frontend-mc-scripts.cjs.d.ts.map +1 -0
  29. package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +29 -0
  30. package/dist/commercetools-frontend-mc-scripts.cjs.js +7 -0
  31. package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +29 -0
  32. package/dist/commercetools-frontend-mc-scripts.esm.js +21 -0
  33. package/dist/compile-html-025cd493.esm.js +34 -0
  34. package/dist/compile-html-50fd05ec.cjs.prod.js +42 -0
  35. package/dist/compile-html-f4ac88cc.cjs.dev.js +42 -0
  36. package/dist/config-sync-2ff62f08.cjs.dev.js +845 -0
  37. package/dist/config-sync-b57f79e2.cjs.prod.js +839 -0
  38. package/dist/config-sync-cda7662e.esm.js +823 -0
  39. package/dist/create-postcss-config-2f709335.esm.js +75 -0
  40. package/dist/create-postcss-config-3b540c7c.cjs.prod.js +81 -0
  41. package/dist/create-postcss-config-5962fa01.cjs.dev.js +81 -0
  42. package/dist/create-webpack-config-for-development-7d9e4dc4.cjs.prod.js +463 -0
  43. package/dist/create-webpack-config-for-development-86baace3.esm.js +438 -0
  44. package/dist/create-webpack-config-for-development-b379913b.cjs.dev.js +463 -0
  45. package/dist/create-webpack-config-for-production-3a40f56b.cjs.dev.js +518 -0
  46. package/dist/create-webpack-config-for-production-5ec9d0e2.cjs.prod.js +518 -0
  47. package/dist/create-webpack-config-for-production-b6ee3116.esm.js +488 -0
  48. package/dist/credentials-storage-3cea94ea.cjs.dev.js +95 -0
  49. package/dist/credentials-storage-b13e1406.esm.js +83 -0
  50. package/dist/credentials-storage-dc849808.cjs.prod.js +95 -0
  51. package/dist/declarations/src/application-runtime.d.ts +1 -0
  52. package/dist/declarations/src/cli.d.ts +4 -0
  53. package/dist/declarations/src/commands/build-vite.d.ts +2 -0
  54. package/dist/declarations/src/commands/build.d.ts +2 -0
  55. package/dist/declarations/src/commands/compile-html.d.ts +3 -0
  56. package/dist/declarations/src/commands/config-sync.d.ts +3 -0
  57. package/dist/declarations/src/commands/deployment-previews-set.d.ts +3 -0
  58. package/dist/declarations/src/commands/login.d.ts +2 -0
  59. package/dist/declarations/src/commands/serve.d.ts +2 -0
  60. package/dist/declarations/src/commands/start-vite.d.ts +2 -0
  61. package/dist/declarations/src/commands/start.d.ts +2 -0
  62. package/dist/declarations/src/config/create-postcss-config.d.ts +4 -0
  63. package/dist/declarations/src/config/create-webpack-config-for-development.d.ts +10 -0
  64. package/dist/declarations/src/config/create-webpack-config-for-production.d.ts +10 -0
  65. package/dist/declarations/src/config/has-jsx-runtime.d.ts +2 -0
  66. package/dist/declarations/src/config/moment-locales.d.ts +2 -0
  67. package/dist/declarations/src/config/optimizations.d.ts +2 -0
  68. package/dist/declarations/src/config/paths.d.ts +12 -0
  69. package/dist/declarations/src/config/vendors-to-transpile.d.ts +2 -0
  70. package/dist/declarations/src/config/webpack-dev-server.config.d.ts +6 -0
  71. package/dist/declarations/src/deprecated-entry-points.d.ts +7 -0
  72. package/dist/declarations/src/generated/core.d.ts +739 -0
  73. package/dist/declarations/src/generated/settings.d.ts +2116 -0
  74. package/dist/declarations/src/index.d.ts +3 -0
  75. package/dist/declarations/src/postcss.d.ts +1 -0
  76. package/dist/declarations/src/types.d.ts +87 -0
  77. package/dist/declarations/src/utils/auth.d.ts +6 -0
  78. package/dist/declarations/src/utils/credentials-storage.d.ts +11 -0
  79. package/dist/declarations/src/utils/does-file-exist.d.ts +2 -0
  80. package/dist/declarations/src/utils/get-config-diff.d.ts +3 -0
  81. package/dist/declarations/src/utils/graphql-requests.d.ts +172 -0
  82. package/dist/declarations/src/utils/i18n-message-complilation.d.ts +4 -0
  83. package/dist/declarations/src/utils/user-agent.d.ts +2 -0
  84. package/dist/declarations/src/version.d.ts +2 -0
  85. package/dist/declarations/src/vite-plugins/vite-plugin-dynamic-base-assets-globals.d.ts +3 -0
  86. package/dist/declarations/src/vite-plugins/vite-plugin-i18n-message-compilation.d.ts +3 -0
  87. package/dist/declarations/src/vite-plugins/vite-plugin-merchant-center-customization.d.ts +4 -0
  88. package/dist/declarations/src/vite-plugins/vite-plugin-svgr.d.ts +3 -0
  89. package/dist/declarations/src/webpack-loaders/i18n-message-compilation-loader.d.ts +3 -0
  90. package/dist/declarations/src/webpack-plugins/final-stats-writer-plugin.d.ts +12 -0
  91. package/dist/declarations/src/webpack-plugins/local-html-webpack-plugin.d.ts +5 -0
  92. package/dist/declarations/src/webpack.d.ts +2 -0
  93. package/dist/deployment-previews-set-173d8491.cjs.dev.js +203 -0
  94. package/dist/deployment-previews-set-923f79de.esm.js +192 -0
  95. package/dist/deployment-previews-set-f451242a.cjs.prod.js +203 -0
  96. package/dist/does-file-exist-32618334.esm.js +12 -0
  97. package/dist/does-file-exist-be53305d.cjs.prod.js +18 -0
  98. package/dist/does-file-exist-eb86baca.cjs.dev.js +18 -0
  99. package/dist/graphql-requests-0e427050.esm.js +243 -0
  100. package/dist/graphql-requests-733aac06.cjs.dev.js +266 -0
  101. package/dist/graphql-requests-db54706e.cjs.prod.js +266 -0
  102. package/dist/has-jsx-runtime-aa5d21ee.cjs.dev.js +15 -0
  103. package/dist/has-jsx-runtime-c3202df5.cjs.prod.js +15 -0
  104. package/dist/has-jsx-runtime-e3ecb09b.esm.js +13 -0
  105. package/dist/i18n-message-complilation-21d3b0aa.esm.js +15 -0
  106. package/dist/i18n-message-complilation-7311cb29.cjs.dev.js +23 -0
  107. package/dist/i18n-message-complilation-7762da61.cjs.prod.js +23 -0
  108. package/dist/login-35f578e3.esm.js +86 -0
  109. package/dist/login-65c78b83.cjs.dev.js +103 -0
  110. package/dist/login-c616d769.cjs.prod.js +103 -0
  111. package/dist/optimizations-7789145e.cjs.dev.js +85 -0
  112. package/dist/optimizations-bf991634.esm.js +67 -0
  113. package/dist/optimizations-fb93514f.cjs.prod.js +85 -0
  114. package/dist/package-436331e6.cjs.dev.js +151 -0
  115. package/dist/package-a7096308.cjs.prod.js +151 -0
  116. package/dist/package-b2f2b4e5.esm.js +149 -0
  117. package/dist/paths-39f22b8b.esm.js +36 -0
  118. package/dist/paths-7768b440.cjs.prod.js +44 -0
  119. package/dist/paths-b76fc753.cjs.dev.js +44 -0
  120. package/dist/serve-5666b16a.cjs.prod.js +48 -0
  121. package/dist/serve-6a951584.esm.js +41 -0
  122. package/dist/serve-f898c45e.cjs.dev.js +48 -0
  123. package/dist/start-4e79e08f.esm.js +164 -0
  124. package/dist/start-569eb0f9.cjs.dev.js +177 -0
  125. package/dist/start-b0765c9a.cjs.prod.js +177 -0
  126. package/dist/start-vite-45bfc42f.esm.js +110 -0
  127. package/dist/start-vite-a68e1b9f.cjs.prod.js +122 -0
  128. package/dist/start-vite-a787f80d.cjs.dev.js +122 -0
  129. package/dist/vendors-to-transpile-04a49d40.cjs.prod.js +5 -0
  130. package/dist/vendors-to-transpile-6ab4ea06.cjs.dev.js +5 -0
  131. package/dist/vendors-to-transpile-7dc84a72.esm.js +3 -0
  132. package/dist/vite-plugin-svgr-069f402d.esm.js +83 -0
  133. package/dist/vite-plugin-svgr-7fb42bbf.cjs.dev.js +108 -0
  134. package/dist/vite-plugin-svgr-b080c510.cjs.prod.js +108 -0
  135. package/package.json +147 -0
  136. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.d.ts +2 -0
  137. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.d.ts.map +1 -0
  138. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +12 -0
  139. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.js +7 -0
  140. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +12 -0
  141. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +4 -0
  142. package/postcss/package.json +4 -0
  143. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.d.ts +2 -0
  144. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.d.ts.map +1 -0
  145. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +57 -0
  146. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.js +7 -0
  147. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +57 -0
  148. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +48 -0
  149. package/webpack/package.json +4 -0
  150. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.d.ts +3 -0
  151. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.d.ts.map +1 -0
  152. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.dev.js +30 -0
  153. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.js +7 -0
  154. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.prod.js +30 -0
  155. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.esm.js +26 -0
  156. package/webpack-loaders/i18n-message-compilation-loader/package.json +4 -0
@@ -0,0 +1,196 @@
1
+ import _Array$isArray from '@babel/runtime-corejs3/core-js-stable/array/is-array';
2
+ import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
3
+ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
4
+ import fs from 'fs';
5
+ import path from 'path';
6
+ import { cac } from 'cac';
7
+ import dotenv from 'dotenv';
8
+ import dotenvExpand from 'dotenv-expand';
9
+ import { p as pkgJson } from '../../dist/package-b2f2b4e5.esm.js';
10
+ import { d as doesFileExist } from '../../dist/does-file-exist-32618334.esm.js';
11
+ import 'node:fs';
12
+
13
+ const cli = cac('mc-scripts');
14
+
15
+ // Makes the script crash on unhandled rejections instead of silently
16
+ // ignoring them. In the future, promise rejections that are not handled will
17
+ // terminate the Node.js process with a non-zero exit code.
18
+ process.on('unhandledRejection', err => {
19
+ throw err;
20
+ });
21
+
22
+ // Get the current directory where the CLI is executed from. Usually this is the application folder.
23
+ const applicationDirectory = fs.realpathSync(process.cwd());
24
+ async function run() {
25
+ cli.option('--env <path>', `(optional) Parses the file path as a dotenv file and adds the variables to the environment. Multiple flags are allowed.`);
26
+
27
+ // Default command
28
+ cli.command('').usage('\n\n Develop and build Custom Applications.').action(() => {
29
+ cli.outputHelp();
30
+ });
31
+
32
+ // Command: start
33
+ const usageStart = 'Starts the application in development mode using Webpack Dev Server.';
34
+ cli.command('start', usageStart).usage(`\n\n ${usageStart}`).alias('dev').action(async options => {
35
+ // Load dotenv files into the process environment.
36
+ // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
37
+ loadDotEnvFiles(options);
38
+
39
+ // Do this as the first thing so that any code reading it knows the right env.
40
+ process.env.BABEL_ENV = 'development';
41
+ process.env.NODE_ENV = 'development';
42
+ const shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
43
+ if (shouldUseExperimentalBundler) {
44
+ console.log('Experimental Vite bundler enabled! 🚀');
45
+ console.log('');
46
+ }
47
+ const startCommand = shouldUseExperimentalBundler ? await import('../../dist/start-vite-45bfc42f.esm.js') : await import('../../dist/start-4e79e08f.esm.js');
48
+ await startCommand.default();
49
+ });
50
+
51
+ // Command: build
52
+ const usageBuild = 'Bundles the application in production mode. Outputs a "public" folder.';
53
+ cli.command('build', usageBuild).usage(`\n\n ${usageBuild}`).option('--build-only', '(optional) If defined, the command only creates the production bundles without compiling the "index.html".', {
54
+ default: false
55
+ }).action(async options => {
56
+ // Load dotenv files into the process environment.
57
+ // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
58
+ loadDotEnvFiles(options);
59
+
60
+ // Do this as the first thing so that any code reading it knows the right env.
61
+ process.env.BABEL_ENV = 'production';
62
+ process.env.NODE_ENV = 'production';
63
+ const shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
64
+ if (shouldUseExperimentalBundler) {
65
+ console.log('Experimental Vite bundler enabled! 🚀');
66
+ console.log('');
67
+ }
68
+ const buildCommand = shouldUseExperimentalBundler ? await import('../../dist/build-vite-722f0dcf.esm.js') : await import('../../dist/build-a93715aa.esm.js');
69
+ await buildCommand.default();
70
+ const shouldAlsoCompile = !options.buildOnly;
71
+ if (shouldAlsoCompile) {
72
+ console.log('');
73
+ const compileHtmlCommand = await import('../../dist/compile-html-025cd493.esm.js');
74
+ await compileHtmlCommand.default({
75
+ printSecurityHeaders: false
76
+ });
77
+ }
78
+ });
79
+
80
+ // Command: compile-html
81
+ 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".';
82
+ cli.command('compile-html', usageCompileHtml).usage(`\n\n ${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.', {
83
+ default: false
84
+ }).action(async options => {
85
+ // Load dotenv files into the process environment.
86
+ // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
87
+ loadDotEnvFiles(options);
88
+
89
+ // Do this as the first thing so that any code reading it knows the right env.
90
+ process.env.NODE_ENV = 'production';
91
+ const compileHtmlCommand = await import('../../dist/compile-html-025cd493.esm.js');
92
+ await compileHtmlCommand.default(options);
93
+ });
94
+
95
+ // Command: serve
96
+ const usageServe = 'Serves previously built and compiled application from the "public" folder.';
97
+ cli.command('serve', usageServe).usage(`\n\n ${usageServe}`).action(async options => {
98
+ // Load dotenv files into the process environment.
99
+ // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
100
+ loadDotEnvFiles(options);
101
+
102
+ // Do this as the first thing so that any code reading it knows the right env.
103
+ process.env.NODE_ENV = 'production';
104
+ const serveCommand = await import('../../dist/serve-6a951584.esm.js');
105
+ await serveCommand.default();
106
+ });
107
+
108
+ // Command: login
109
+ const usageLogin = 'Log in to your Merchant Center account through the CLI, using the cloud environment information from the Merchant Center customization config file. An API token is generated and stored in a configuration file for the related cloud environment, and valid for 36 hours.';
110
+ cli.command('login', usageLogin).usage(`\n\n ${usageLogin}`).action(async options => {
111
+ // Load dotenv files into the process environment.
112
+ // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
113
+ loadDotEnvFiles(options);
114
+
115
+ // Do this as the first thing so that any code reading it knows the right env.
116
+ process.env.NODE_ENV = 'production';
117
+ const loginCommand = await import('../../dist/login-35f578e3.esm.js');
118
+ await loginCommand.default();
119
+ });
120
+
121
+ // Command: config:sync
122
+ const usageConfigSync = 'Synchronizes the local Merchant Center customization config with the Merchant Center. A new Merchant Center customization will be created if none existed, otherwise it will be updated.';
123
+ cli.command('config:sync', usageConfigSync).usage(`\n\n ${usageConfigSync}`).option('--dry-run', '(optional) Executes the command but does not send any mutation request.', {
124
+ default: false
125
+ }).action(async options => {
126
+ // Load dotenv files into the process environment.
127
+ // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
128
+ loadDotEnvFiles(options);
129
+
130
+ // Do this as the first thing so that any code reading it knows the right env.
131
+ process.env.NODE_ENV = 'production';
132
+ const configSyncCommand = await import('../../dist/config-sync-cda7662e.esm.js');
133
+ await configSyncCommand.default(options);
134
+ });
135
+
136
+ // Command: deployment-previews:set
137
+ const usageDeploymentPreviewsSet = 'Creates or updates a deployment preview for the Custom Application.';
138
+ cli.command('deployment-previews:set', usageDeploymentPreviewsSet).usage(`\n\n ${usageDeploymentPreviewsSet}`).option('--alias <deployment-preview-alias>', "(optional) Alias to be used for the deployment preview. If you don't provide an alias, the command will prompt you for it.").option('--url <deployment-preview-url>', "(optional) URL to be used for the deployment preview. If you don't provide a URL, the command will prompt you for it.").option('--dry-run', '(optional) Executes the command but does not send any mutation request.', {
139
+ default: false
140
+ }).action(async options => {
141
+ // Load dotenv files into the process environment.
142
+ // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
143
+ loadDotEnvFiles(options);
144
+
145
+ // Do this as the first thing so that any code reading it knows the right env.
146
+ process.env.NODE_ENV = 'production';
147
+ const deploymentsSetCommand = await import('../../dist/deployment-previews-set-923f79de.esm.js');
148
+ await deploymentsSetCommand.default(options);
149
+ });
150
+ cli.help();
151
+ cli.version(pkgJson.version);
152
+ cli.parse(process.argv, {
153
+ run: false
154
+ });
155
+ await cli.runMatchedCommand();
156
+ }
157
+
158
+ // Load dotenv files into the process environment.
159
+ // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
160
+ // Inspired also by https://create-react-app.dev/docs/adding-custom-environment-variables/#what-other-env-files-can-be-used
161
+ function loadDotEnvFiles(globalOptions) {
162
+ var _context;
163
+ const environment = process.env.MC_APP_ENV || process.env.NODE_ENV;
164
+ const dotenvFiles = [];
165
+
166
+ // Custom dotenv files specified by the `--env` option takes precedence.
167
+ if (typeof globalOptions.env === 'string') {
168
+ dotenvFiles.push(globalOptions.env);
169
+ } else if (_Array$isArray(globalOptions.env)) {
170
+ // Multiple `--env` options are allowed.
171
+ dotenvFiles.push(...globalOptions.env);
172
+ }
173
+
174
+ // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
175
+ dotenvFiles.push(..._filterInstanceProperty(_context = [`.env.${environment}.local`,
176
+ // Don't include `.env.local` for `test` environment
177
+ // since normally you expect tests to produce the same
178
+ // results for everyone
179
+ process.env.NODE_ENV !== 'test' && `.env.local`, `.env.${environment}`, '.env']).call(_context, Boolean));
180
+
181
+ // Load environment variables from .env* files. Suppress warnings using silent
182
+ // if this file is missing. dotenv will never modify any environment variables
183
+ // that have already been set. Variable expansion is supported in .env files.
184
+ // https://github.com/motdotla/dotenv
185
+ // https://github.com/motdotla/dotenv-expand
186
+ _forEachInstanceProperty(dotenvFiles).call(dotenvFiles, dotenvFile => {
187
+ const dotenvFilePath = path.resolve(path.join(applicationDirectory, dotenvFile));
188
+ if (doesFileExist(dotenvFilePath)) {
189
+ dotenvExpand.expand(dotenv.config({
190
+ path: dotenvFilePath
191
+ }));
192
+ }
193
+ });
194
+ }
195
+
196
+ export { loadDotEnvFiles, run };
@@ -0,0 +1,4 @@
1
+ {
2
+ "main": "dist/commercetools-frontend-mc-scripts-cli.cjs.js",
3
+ "module": "dist/commercetools-frontend-mc-scripts-cli.esm.js"
4
+ }
@@ -0,0 +1,8 @@
1
+ // For backwards compatibilty
2
+ console.log(
3
+ 'The import "@commercetools-frontend/mc-scripts/config/create-webpack-config-for-development" is deprecated. Use the entry point "@commercetools-frontend/mc-scripts/webpack" instead.'
4
+ );
5
+ const {
6
+ createWebpackConfigForDevelopment,
7
+ } = require('@commercetools-frontend/mc-scripts/webpack');
8
+ module.exports = createWebpackConfigForDevelopment;
@@ -0,0 +1,8 @@
1
+ // For backwards compatibilty
2
+ console.log(
3
+ 'The import "@commercetools-frontend/mc-scripts/config/create-webpack-config-for-production" is deprecated. Use the entry point "@commercetools-frontend/mc-scripts/webpack" instead.'
4
+ );
5
+ const {
6
+ createWebpackConfigForProduction,
7
+ } = require('@commercetools-frontend/mc-scripts/webpack');
8
+ module.exports = createWebpackConfigForProduction;
@@ -0,0 +1,6 @@
1
+ // For backwards compatibilty
2
+ console.log(
3
+ 'The import "@commercetools-frontend/mc-scripts/config/vendors-to-transpile" is deprecated. Use the main entry point "@commercetools-frontend/mc-scripts" instead.'
4
+ );
5
+ const { vendorsToTranspile } = require('../');
6
+ module.exports = vendorsToTranspile;
@@ -0,0 +1,166 @@
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-5ec9d0e2.cjs.prod.js');
14
+ var paths = require('./paths-7768b440.cjs.prod.js');
15
+ var doesFileExist = require('./does-file-exist-be53305d.cjs.prod.js');
16
+ require('@babel/runtime-corejs3/core-js-stable/object/keys');
17
+ require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
18
+ require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
19
+ require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
20
+ require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
21
+ require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
22
+ require('@babel/runtime-corejs3/core-js-stable/object/define-property');
23
+ require('@babel/runtime-corejs3/helpers/defineProperty');
24
+ require('@babel/runtime-corejs3/core-js-stable/instance/filter');
25
+ require('@babel/runtime-corejs3/core-js-stable/instance/map');
26
+ require('@babel/runtime-corejs3/core-js-stable/json/stringify');
27
+ require('@babel/runtime-corejs3/core-js-stable/instance/ends-with');
28
+ require('@babel/runtime-corejs3/core-js-stable/number/is-integer');
29
+ require('@babel/runtime-corejs3/core-js-stable/instance/concat');
30
+ require('crypto');
31
+ require('css-minimizer-webpack-plugin');
32
+ require('html-webpack-plugin');
33
+ require('mini-css-extract-plugin');
34
+ require('moment-locales-webpack-plugin');
35
+ require('terser-webpack-plugin');
36
+ require('webpack-bundle-analyzer');
37
+ require('@babel/runtime-corejs3/helpers/classCallCheck');
38
+ require('@babel/runtime-corejs3/helpers/createClass');
39
+ require('@babel/runtime-corejs3/core-js-stable/instance/bind');
40
+ require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
41
+ require('@babel/runtime-corejs3/core-js-stable/object/assign');
42
+ require('fs');
43
+ require('./create-postcss-config-3b540c7c.cjs.prod.js');
44
+ require('@babel/runtime-corejs3/helpers/slicedToArray');
45
+ require('./package-a7096308.cjs.prod.js');
46
+ require('./has-jsx-runtime-c3202df5.cjs.prod.js');
47
+ require('./optimizations-fb93514f.cjs.prod.js');
48
+ require('@babel/runtime-corejs3/core-js-stable/object/entries');
49
+ require('@babel/runtime-corejs3/core-js-stable/instance/includes');
50
+ require('./vendors-to-transpile-04a49d40.cjs.prod.js');
51
+ require('@babel/runtime-corejs3/core-js-stable/instance/find');
52
+ require('node:fs');
53
+
54
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
55
+
56
+ var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
57
+ var path__default = /*#__PURE__*/_interopDefault(path);
58
+ var chalk__default = /*#__PURE__*/_interopDefault(chalk);
59
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
60
+ var checkRequiredFiles__default = /*#__PURE__*/_interopDefault(checkRequiredFiles);
61
+ var FileSizeReporter__default = /*#__PURE__*/_interopDefault(FileSizeReporter);
62
+ var formatWebpackMessages__default = /*#__PURE__*/_interopDefault(formatWebpackMessages);
63
+ var printBuildError__default = /*#__PURE__*/_interopDefault(printBuildError);
64
+ var webpack__default = /*#__PURE__*/_interopDefault(webpack);
65
+
66
+ const measureFileSizesBeforeBuild = FileSizeReporter__default["default"].measureFileSizesBeforeBuild;
67
+ const printFileSizesAfterBuild = FileSizeReporter__default["default"].printFileSizesAfterBuild;
68
+
69
+ // These sizes are pretty large. We'll warn for bundles exceeding them.
70
+ const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
71
+ const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
72
+ async function run() {
73
+ const hasWebpackConfig = doesFileExist.doesFileExist(paths.paths.appWebpackConfig);
74
+
75
+ // Warn and crash if required files are missing
76
+ if (!checkRequiredFiles__default["default"]([])) {
77
+ process.exit(1);
78
+ }
79
+
80
+ // First, read the current file sizes in build directory.
81
+ // This lets us display how much they changed later.
82
+ const previousFileSizes = await measureFileSizesBeforeBuild(paths.paths.appBuild);
83
+
84
+ // Remove all content but keep the directory so that
85
+ // if you're in it, you don't end up in Trash
86
+ fs__default["default"].emptyDirSync(paths.paths.appBuild);
87
+ // Copy default files
88
+ copyDefaultFiles();
89
+ try {
90
+ // Start the webpack build
91
+ const result = await build();
92
+ if (result.warnings.length) {
93
+ console.log(chalk__default["default"].yellow('Compiled with warnings.\n'));
94
+ console.log(result.warnings.join('\n\n'));
95
+ console.log('\n');
96
+ } else {
97
+ console.log(chalk__default["default"].green('Compiled successfully.\n'));
98
+ }
99
+ console.log('File sizes after gzip:\n');
100
+ printFileSizesAfterBuild(result.stats, previousFileSizes, paths.paths.appBuild, WARN_AFTER_BUNDLE_GZIP_SIZE, WARN_AFTER_CHUNK_GZIP_SIZE);
101
+ console.log();
102
+ } catch (error) {
103
+ if (error instanceof Error) {
104
+ printBuildError__default["default"](error);
105
+ }
106
+ throw new Error(`Failed to compile`);
107
+ }
108
+
109
+ // Create the production build and print the deployment instructions.
110
+ async function build() {
111
+ console.log('Creating an optimized production build...');
112
+ const config = hasWebpackConfig ? require(paths.paths.appWebpackConfig) : createWebpackConfigForProduction.createWebpackConfigForProduction();
113
+ const compiler = webpack__default["default"](config);
114
+ return new _Promise__default["default"]((resolve, reject) => {
115
+ compiler.run((err, stats) => {
116
+ let messages;
117
+ if (err) {
118
+ if (!err.message) {
119
+ return reject(err);
120
+ }
121
+ let errMessage = err.message;
122
+ // Add additional information for postcss errors
123
+ if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
124
+ errMessage += '\nCompileError: Begins at CSS selector ' +
125
+ // @ts-ignore
126
+ err['postcssNode'].selector;
127
+ }
128
+ messages = formatWebpackMessages__default["default"]({
129
+ // @ts-ignore
130
+ errors: [errMessage],
131
+ warnings: []
132
+ });
133
+ } else {
134
+ messages = formatWebpackMessages__default["default"](stats?.toJson({
135
+ all: false,
136
+ warnings: true,
137
+ errors: true
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
+ return reject(new Error(messages.errors.join('\n\n')));
147
+ }
148
+ if (process.env.CI && (typeof process.env.CI !== 'string' || process.env.CI.toLowerCase() !== 'false') && messages.warnings.length) {
149
+ console.log(chalk__default["default"].yellow('\nTreating warnings as errors because process.env.CI = true.\n' + 'Most CI servers set it automatically.\n'));
150
+ return reject(new Error(messages.warnings.join('\n\n')));
151
+ }
152
+ return resolve({
153
+ stats: stats,
154
+ warnings: messages.warnings
155
+ });
156
+ });
157
+ });
158
+ }
159
+ function copyDefaultFiles() {
160
+ fs__default["default"].copySync(path__default["default"].join(assets.packageLocation, 'html-page'), paths.paths.appBuild, {
161
+ dereference: true
162
+ });
163
+ }
164
+ }
165
+
166
+ exports["default"] = run;
@@ -0,0 +1,152 @@
1
+ import _Promise from '@babel/runtime-corejs3/core-js-stable/promise';
2
+ import path from 'path';
3
+ import chalk from 'chalk';
4
+ import fs from 'fs-extra';
5
+ import checkRequiredFiles from 'react-dev-utils/checkRequiredFiles';
6
+ import FileSizeReporter from 'react-dev-utils/FileSizeReporter';
7
+ import formatWebpackMessages from 'react-dev-utils/formatWebpackMessages';
8
+ import printBuildError from 'react-dev-utils/printBuildError';
9
+ import webpack from 'webpack';
10
+ import { packageLocation } from '@commercetools-frontend/assets';
11
+ import { c as createWebpackConfigForProduction } from './create-webpack-config-for-production-b6ee3116.esm.js';
12
+ import { p as paths } from './paths-39f22b8b.esm.js';
13
+ import { d as doesFileExist } from './does-file-exist-32618334.esm.js';
14
+ import '@babel/runtime-corejs3/core-js-stable/object/keys';
15
+ import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
16
+ import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
17
+ import '@babel/runtime-corejs3/core-js-stable/instance/for-each';
18
+ import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
19
+ import '@babel/runtime-corejs3/core-js-stable/object/define-properties';
20
+ import '@babel/runtime-corejs3/core-js-stable/object/define-property';
21
+ import '@babel/runtime-corejs3/helpers/defineProperty';
22
+ import '@babel/runtime-corejs3/core-js-stable/instance/filter';
23
+ import '@babel/runtime-corejs3/core-js-stable/instance/map';
24
+ import '@babel/runtime-corejs3/core-js-stable/json/stringify';
25
+ import '@babel/runtime-corejs3/core-js-stable/instance/ends-with';
26
+ import '@babel/runtime-corejs3/core-js-stable/number/is-integer';
27
+ import '@babel/runtime-corejs3/core-js-stable/instance/concat';
28
+ import 'crypto';
29
+ import 'css-minimizer-webpack-plugin';
30
+ import 'html-webpack-plugin';
31
+ import 'mini-css-extract-plugin';
32
+ import 'moment-locales-webpack-plugin';
33
+ import 'terser-webpack-plugin';
34
+ import 'webpack-bundle-analyzer';
35
+ import '@babel/runtime-corejs3/helpers/classCallCheck';
36
+ import '@babel/runtime-corejs3/helpers/createClass';
37
+ import '@babel/runtime-corejs3/core-js-stable/instance/bind';
38
+ import '@babel/runtime-corejs3/core-js-stable/instance/reduce';
39
+ import '@babel/runtime-corejs3/core-js-stable/object/assign';
40
+ import 'fs';
41
+ import './create-postcss-config-2f709335.esm.js';
42
+ import '@babel/runtime-corejs3/helpers/slicedToArray';
43
+ import './package-b2f2b4e5.esm.js';
44
+ import './has-jsx-runtime-e3ecb09b.esm.js';
45
+ import './optimizations-bf991634.esm.js';
46
+ import '@babel/runtime-corejs3/core-js-stable/object/entries';
47
+ import '@babel/runtime-corejs3/core-js-stable/instance/includes';
48
+ import './vendors-to-transpile-7dc84a72.esm.js';
49
+ import '@babel/runtime-corejs3/core-js-stable/instance/find';
50
+ import 'node:fs';
51
+
52
+ const measureFileSizesBeforeBuild = FileSizeReporter.measureFileSizesBeforeBuild;
53
+ const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
54
+
55
+ // These sizes are pretty large. We'll warn for bundles exceeding them.
56
+ const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
57
+ const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
58
+ async function run() {
59
+ const hasWebpackConfig = doesFileExist(paths.appWebpackConfig);
60
+
61
+ // Warn and crash if required files are missing
62
+ if (!checkRequiredFiles([])) {
63
+ process.exit(1);
64
+ }
65
+
66
+ // First, read the current file sizes in build directory.
67
+ // This lets us display how much they changed later.
68
+ const previousFileSizes = await measureFileSizesBeforeBuild(paths.appBuild);
69
+
70
+ // Remove all content but keep the directory so that
71
+ // if you're in it, you don't end up in Trash
72
+ fs.emptyDirSync(paths.appBuild);
73
+ // Copy default files
74
+ copyDefaultFiles();
75
+ try {
76
+ // Start the webpack build
77
+ const result = await build();
78
+ if (result.warnings.length) {
79
+ console.log(chalk.yellow('Compiled with warnings.\n'));
80
+ console.log(result.warnings.join('\n\n'));
81
+ console.log('\n');
82
+ } else {
83
+ console.log(chalk.green('Compiled successfully.\n'));
84
+ }
85
+ console.log('File sizes after gzip:\n');
86
+ printFileSizesAfterBuild(result.stats, previousFileSizes, paths.appBuild, WARN_AFTER_BUNDLE_GZIP_SIZE, WARN_AFTER_CHUNK_GZIP_SIZE);
87
+ console.log();
88
+ } catch (error) {
89
+ if (error instanceof Error) {
90
+ printBuildError(error);
91
+ }
92
+ throw new Error(`Failed to compile`);
93
+ }
94
+
95
+ // Create the production build and print the deployment instructions.
96
+ async function build() {
97
+ console.log('Creating an optimized production build...');
98
+ const config = hasWebpackConfig ? require(paths.appWebpackConfig) : createWebpackConfigForProduction();
99
+ const compiler = webpack(config);
100
+ return new _Promise((resolve, reject) => {
101
+ compiler.run((err, stats) => {
102
+ let messages;
103
+ if (err) {
104
+ if (!err.message) {
105
+ return reject(err);
106
+ }
107
+ let errMessage = err.message;
108
+ // Add additional information for postcss errors
109
+ if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
110
+ errMessage += '\nCompileError: Begins at CSS selector ' +
111
+ // @ts-ignore
112
+ err['postcssNode'].selector;
113
+ }
114
+ messages = formatWebpackMessages({
115
+ // @ts-ignore
116
+ errors: [errMessage],
117
+ warnings: []
118
+ });
119
+ } else {
120
+ messages = formatWebpackMessages(stats?.toJson({
121
+ all: false,
122
+ warnings: true,
123
+ errors: true
124
+ }));
125
+ }
126
+ if (messages.errors.length) {
127
+ // Only keep the first error. Others are often indicative
128
+ // of the same problem, but confuse the reader with noise.
129
+ if (messages.errors.length > 1) {
130
+ messages.errors.length = 1;
131
+ }
132
+ return reject(new Error(messages.errors.join('\n\n')));
133
+ }
134
+ if (process.env.CI && (typeof process.env.CI !== 'string' || process.env.CI.toLowerCase() !== 'false') && messages.warnings.length) {
135
+ console.log(chalk.yellow('\nTreating warnings as errors because process.env.CI = true.\n' + 'Most CI servers set it automatically.\n'));
136
+ return reject(new Error(messages.warnings.join('\n\n')));
137
+ }
138
+ return resolve({
139
+ stats: stats,
140
+ warnings: messages.warnings
141
+ });
142
+ });
143
+ });
144
+ }
145
+ function copyDefaultFiles() {
146
+ fs.copySync(path.join(packageLocation, 'html-page'), paths.appBuild, {
147
+ dereference: true
148
+ });
149
+ }
150
+ }
151
+
152
+ export { run as default };