@commercetools-frontend/mc-scripts 0.0.0-CRAFT-1791-20251006162610
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +7 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.d.ts +2 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.dev.js +7 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.js +7 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js +7 -0
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.esm.js +5 -0
- package/application-runtime/package.json +4 -0
- package/bin/cli.js +8 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.d.ts +2 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +199 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.js +7 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +199 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +184 -0
- package/cli/package.json +4 -0
- package/config/create-webpack-config-for-development.js +8 -0
- package/config/create-webpack-config-for-production.js +8 -0
- package/config/vendors-to-transpile.js +6 -0
- package/dist/build-2a0a18bd.esm.js +155 -0
- package/dist/build-521f3f9f.cjs.prod.js +169 -0
- package/dist/build-988fc0f7.cjs.dev.js +169 -0
- package/dist/build-vite-16b1a575.cjs.dev.js +238 -0
- package/dist/build-vite-59e1f185.esm.js +208 -0
- package/dist/build-vite-5d317720.cjs.prod.js +238 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.d.ts +2 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +29 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.js +7 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +29 -0
- package/dist/commercetools-frontend-mc-scripts.esm.js +21 -0
- package/dist/compile-html-025cd493.esm.js +34 -0
- package/dist/compile-html-50fd05ec.cjs.prod.js +42 -0
- package/dist/compile-html-f4ac88cc.cjs.dev.js +42 -0
- package/dist/config-sync-70a16916.cjs.dev.js +852 -0
- package/dist/config-sync-72c20d80.cjs.prod.js +846 -0
- package/dist/config-sync-bc895390.esm.js +830 -0
- package/dist/create-postcss-config-cb7be312.cjs.dev.js +81 -0
- package/dist/create-postcss-config-dde0ccf1.esm.js +75 -0
- package/dist/create-postcss-config-edca0c33.cjs.prod.js +81 -0
- package/dist/create-webpack-config-for-development-1aed1cc0.cjs.prod.js +465 -0
- package/dist/create-webpack-config-for-development-a95f3634.esm.js +440 -0
- package/dist/create-webpack-config-for-development-d003697b.cjs.dev.js +465 -0
- package/dist/create-webpack-config-for-production-15fbe7db.cjs.dev.js +523 -0
- package/dist/create-webpack-config-for-production-764c482f.cjs.prod.js +523 -0
- package/dist/create-webpack-config-for-production-9f42c336.esm.js +493 -0
- package/dist/credentials-storage-66c1e51f.cjs.prod.js +95 -0
- package/dist/credentials-storage-d001f726.esm.js +83 -0
- package/dist/credentials-storage-e7884d17.cjs.dev.js +95 -0
- package/dist/declarations/src/application-runtime.d.ts +1 -0
- package/dist/declarations/src/cli.d.ts +4 -0
- package/dist/declarations/src/config/create-postcss-config.d.ts +4 -0
- package/dist/declarations/src/config/create-webpack-config-for-development.d.ts +10 -0
- package/dist/declarations/src/config/create-webpack-config-for-production.d.ts +10 -0
- package/dist/declarations/src/config/vendors-to-transpile.d.ts +2 -0
- package/dist/declarations/src/deprecated-entry-points.d.ts +7 -0
- package/dist/declarations/src/index.d.ts +3 -0
- package/dist/declarations/src/postcss.d.ts +1 -0
- package/dist/declarations/src/types.d.ts +94 -0
- package/dist/declarations/src/version.d.ts +2 -0
- package/dist/declarations/src/webpack-loaders/i18n-message-compilation-loader.d.ts +3 -0
- package/dist/declarations/src/webpack.d.ts +2 -0
- package/dist/deployment-previews-set-17e8ed48.cjs.prod.js +202 -0
- package/dist/deployment-previews-set-3648972f.esm.js +191 -0
- package/dist/deployment-previews-set-37aef990.cjs.dev.js +202 -0
- package/dist/does-file-exist-32618334.esm.js +12 -0
- package/dist/does-file-exist-be53305d.cjs.prod.js +18 -0
- package/dist/does-file-exist-eb86baca.cjs.dev.js +18 -0
- package/dist/graphql-requests-6a47ad5b.esm.js +247 -0
- package/dist/graphql-requests-779b867b.cjs.dev.js +270 -0
- package/dist/graphql-requests-8086eba7.cjs.prod.js +270 -0
- package/dist/has-jsx-runtime-aa5d21ee.cjs.dev.js +15 -0
- package/dist/has-jsx-runtime-c3202df5.cjs.prod.js +15 -0
- package/dist/has-jsx-runtime-e3ecb09b.esm.js +13 -0
- package/dist/i18n-message-complilation-21d3b0aa.esm.js +15 -0
- package/dist/i18n-message-complilation-7311cb29.cjs.dev.js +23 -0
- package/dist/i18n-message-complilation-7762da61.cjs.prod.js +23 -0
- package/dist/login-0a728449.esm.js +229 -0
- package/dist/login-817a5a26.cjs.dev.js +270 -0
- package/dist/login-85c25393.cjs.prod.js +270 -0
- package/dist/optimizations-7789145e.cjs.dev.js +85 -0
- package/dist/optimizations-bf991634.esm.js +67 -0
- package/dist/optimizations-fb93514f.cjs.prod.js +85 -0
- package/dist/package-7e170dc4.cjs.dev.js +160 -0
- package/dist/package-940b0a2a.cjs.prod.js +160 -0
- package/dist/package-99e547a7.esm.js +158 -0
- package/dist/paths-39f22b8b.esm.js +36 -0
- package/dist/paths-7768b440.cjs.prod.js +44 -0
- package/dist/paths-b76fc753.cjs.dev.js +44 -0
- package/dist/serve-1036c2de.esm.js +55 -0
- package/dist/serve-50d33f0b.cjs.dev.js +64 -0
- package/dist/serve-8a506da6.cjs.prod.js +64 -0
- package/dist/start-1d677ad8.cjs.dev.js +177 -0
- package/dist/start-2a7ae03d.esm.js +164 -0
- package/dist/start-f56cb5f7.cjs.prod.js +177 -0
- package/dist/start-vite-068e9f73.cjs.dev.js +128 -0
- package/dist/start-vite-29078b3a.cjs.prod.js +128 -0
- package/dist/start-vite-7d1161e8.esm.js +116 -0
- package/dist/vendors-to-transpile-04a49d40.cjs.prod.js +5 -0
- package/dist/vendors-to-transpile-6ab4ea06.cjs.dev.js +5 -0
- package/dist/vendors-to-transpile-7dc84a72.esm.js +3 -0
- package/dist/vite-plugin-svgr-4034a834.cjs.prod.js +151 -0
- package/dist/vite-plugin-svgr-7d06f400.cjs.dev.js +151 -0
- package/dist/vite-plugin-svgr-de6ee7da.esm.js +125 -0
- package/package.json +156 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.d.ts +2 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +12 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.js +7 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +12 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +4 -0
- package/postcss/package.json +4 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.d.ts +2 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +57 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.js +7 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +57 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +48 -0
- package/webpack/package.json +4 -0
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.d.ts +3 -0
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.dev.js +30 -0
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.js +7 -0
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.prod.js +30 -0
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.esm.js +26 -0
- package/webpack-loaders/i18n-message-compilation-loader/package.json +4 -0
|
@@ -0,0 +1,184 @@
|
|
|
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 { program } from 'commander';
|
|
7
|
+
import dotenv from 'dotenv';
|
|
8
|
+
import dotenvExpand from 'dotenv-expand';
|
|
9
|
+
import { p as pkgJson } from '../../dist/package-99e547a7.esm.js';
|
|
10
|
+
import { d as doesFileExist } from '../../dist/does-file-exist-32618334.esm.js';
|
|
11
|
+
import 'node:fs';
|
|
12
|
+
|
|
13
|
+
program.name('mc-scripts').description('CLI to develop and build Merchant Center customizations.').version(pkgJson.version).option('-e, --env <path...>',
|
|
14
|
+
// Variadic option. It allows multiple `--env` options to be provided.
|
|
15
|
+
`(optional) Parses the file path as a dotenv file and adds the variables to the environment. Multiple flags are allowed.`);
|
|
16
|
+
|
|
17
|
+
// Makes the script crash on unhandled rejections instead of silently
|
|
18
|
+
// ignoring them. In the future, promise rejections that are not handled will
|
|
19
|
+
// terminate the Node.js process with a non-zero exit code.
|
|
20
|
+
process.on('unhandledRejection', err => {
|
|
21
|
+
throw err;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Get the current directory where the CLI is executed from. Usually this is the application folder.
|
|
25
|
+
const applicationDirectory = fs.realpathSync(process.cwd());
|
|
26
|
+
async function run() {
|
|
27
|
+
// Command: start
|
|
28
|
+
program.command('start').alias('dev').description('Starts the application in development mode using Webpack Dev Server.').action(async () => {
|
|
29
|
+
const globalOptions = program.opts();
|
|
30
|
+
|
|
31
|
+
// Load dotenv files into the process environment.
|
|
32
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
33
|
+
loadDotEnvFiles(globalOptions);
|
|
34
|
+
|
|
35
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
36
|
+
process.env.BABEL_ENV = 'development';
|
|
37
|
+
process.env.NODE_ENV = 'development';
|
|
38
|
+
const shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
|
|
39
|
+
if (shouldUseExperimentalBundler) {
|
|
40
|
+
console.log('Experimental Vite bundler enabled! 🚀');
|
|
41
|
+
console.log('');
|
|
42
|
+
}
|
|
43
|
+
const startCommand = shouldUseExperimentalBundler ? await import('../../dist/start-vite-7d1161e8.esm.js') : await import('../../dist/start-2a7ae03d.esm.js');
|
|
44
|
+
await startCommand.default();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Command: build
|
|
48
|
+
program.command('build').description('Bundles the application in production mode. Outputs a "public" folder.').option('--build-only', '(optional) If defined, the command only creates the production bundles without compiling the "index.html".', false).action(async options => {
|
|
49
|
+
const globalOptions = program.opts();
|
|
50
|
+
// Load dotenv files into the process environment.
|
|
51
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
52
|
+
loadDotEnvFiles(globalOptions);
|
|
53
|
+
|
|
54
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
55
|
+
process.env.BABEL_ENV = 'production';
|
|
56
|
+
process.env.NODE_ENV = 'production';
|
|
57
|
+
const shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
|
|
58
|
+
if (shouldUseExperimentalBundler) {
|
|
59
|
+
console.log('Experimental Vite bundler enabled! 🚀');
|
|
60
|
+
console.log('');
|
|
61
|
+
}
|
|
62
|
+
const buildCommand = shouldUseExperimentalBundler ? await import('../../dist/build-vite-59e1f185.esm.js') : await import('../../dist/build-2a0a18bd.esm.js');
|
|
63
|
+
await buildCommand.default();
|
|
64
|
+
const shouldAlsoCompile = !options.buildOnly;
|
|
65
|
+
if (shouldAlsoCompile) {
|
|
66
|
+
console.log('');
|
|
67
|
+
const compileHtmlCommand = await import('../../dist/compile-html-025cd493.esm.js');
|
|
68
|
+
await compileHtmlCommand.default({
|
|
69
|
+
printSecurityHeaders: false
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// Command: compile-html
|
|
75
|
+
program.command('compile-html').description('Compiles "index.html.template" file into a "index.html" with all the required runtime configuration. The security headers are also compiled and injected into the "index.html".').option('--transformer <path>', '(optional) The path to a JS module that can be used to generate a configuration for a specific cloud provider (e.g. Vercel, Netlify).').option('--print-security-headers', '(optional) If defined, the compiled security headers are printed to stdout.', false).action(async options => {
|
|
76
|
+
const globalOptions = program.opts();
|
|
77
|
+
|
|
78
|
+
// Load dotenv files into the process environment.
|
|
79
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
80
|
+
loadDotEnvFiles(globalOptions);
|
|
81
|
+
|
|
82
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
83
|
+
process.env.NODE_ENV = 'production';
|
|
84
|
+
const compileHtmlCommand = await import('../../dist/compile-html-025cd493.esm.js');
|
|
85
|
+
await compileHtmlCommand.default(options);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Command: serve
|
|
89
|
+
program.command('serve').description('Serves previously built and compiled application from the "public" folder.').action(async () => {
|
|
90
|
+
const globalOptions = program.opts();
|
|
91
|
+
|
|
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(globalOptions);
|
|
95
|
+
|
|
96
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
97
|
+
process.env.NODE_ENV = 'production';
|
|
98
|
+
const serveCommand = await import('../../dist/serve-1036c2de.esm.js');
|
|
99
|
+
await serveCommand.default();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// Command: login
|
|
103
|
+
program.command('login').description('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.').action(async () => {
|
|
104
|
+
const globalOptions = program.opts();
|
|
105
|
+
|
|
106
|
+
// Load dotenv files into the process environment.
|
|
107
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
108
|
+
loadDotEnvFiles(globalOptions);
|
|
109
|
+
|
|
110
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
111
|
+
process.env.NODE_ENV = 'production';
|
|
112
|
+
const loginCommand = await import('../../dist/login-0a728449.esm.js');
|
|
113
|
+
await loginCommand.default();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Command: config:sync
|
|
117
|
+
program.command('config:sync').description('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.').option('--dry-run', '(optional) Executes the command but does not send any mutation request.', false).action(async options => {
|
|
118
|
+
const globalOptions = program.opts();
|
|
119
|
+
|
|
120
|
+
// Load dotenv files into the process environment.
|
|
121
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
122
|
+
loadDotEnvFiles(globalOptions);
|
|
123
|
+
|
|
124
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
125
|
+
process.env.NODE_ENV = 'production';
|
|
126
|
+
const configSyncCommand = await import('../../dist/config-sync-bc895390.esm.js');
|
|
127
|
+
await configSyncCommand.default(options);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// Command: deployment-previews:set
|
|
131
|
+
program.command('deployment-previews:set').description('Creates or updates a deployment preview for the Custom Application.').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.', false).action(async options => {
|
|
132
|
+
const globalOptions = program.opts();
|
|
133
|
+
|
|
134
|
+
// Load dotenv files into the process environment.
|
|
135
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
136
|
+
loadDotEnvFiles(globalOptions);
|
|
137
|
+
|
|
138
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
139
|
+
process.env.NODE_ENV = 'production';
|
|
140
|
+
const deploymentsSetCommand = await import('../../dist/deployment-previews-set-3648972f.esm.js');
|
|
141
|
+
await deploymentsSetCommand.default(options);
|
|
142
|
+
});
|
|
143
|
+
program.parse();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Load dotenv files into the process environment.
|
|
147
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
148
|
+
// Inspired also by https://create-react-app.dev/docs/adding-custom-environment-variables/#what-other-env-files-can-be-used
|
|
149
|
+
function loadDotEnvFiles(globalOptions) {
|
|
150
|
+
var _context;
|
|
151
|
+
const environment = process.env.MC_APP_ENV || process.env.NODE_ENV;
|
|
152
|
+
const dotenvFiles = [];
|
|
153
|
+
|
|
154
|
+
// Custom dotenv files specified by the `--env` option takes precedence.
|
|
155
|
+
if (typeof globalOptions.env === 'string') {
|
|
156
|
+
dotenvFiles.push(globalOptions.env);
|
|
157
|
+
} else if (_Array$isArray(globalOptions.env)) {
|
|
158
|
+
// Multiple `--env` options are allowed.
|
|
159
|
+
dotenvFiles.push(...globalOptions.env);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
|
|
163
|
+
dotenvFiles.push(..._filterInstanceProperty(_context = [`.env.${environment}.local`,
|
|
164
|
+
// Don't include `.env.local` for `test` environment
|
|
165
|
+
// since normally you expect tests to produce the same
|
|
166
|
+
// results for everyone
|
|
167
|
+
process.env.NODE_ENV !== 'test' && `.env.local`, `.env.${environment}`, '.env']).call(_context, Boolean));
|
|
168
|
+
|
|
169
|
+
// Load environment variables from .env* files. Suppress warnings using silent
|
|
170
|
+
// if this file is missing. dotenv will never modify any environment variables
|
|
171
|
+
// that have already been set. Variable expansion is supported in .env files.
|
|
172
|
+
// https://github.com/motdotla/dotenv
|
|
173
|
+
// https://github.com/motdotla/dotenv-expand
|
|
174
|
+
_forEachInstanceProperty(dotenvFiles).call(dotenvFiles, dotenvFile => {
|
|
175
|
+
const dotenvFilePath = path.resolve(path.join(applicationDirectory, dotenvFile));
|
|
176
|
+
if (doesFileExist(dotenvFilePath)) {
|
|
177
|
+
dotenvExpand.expand(dotenv.config({
|
|
178
|
+
path: dotenvFilePath
|
|
179
|
+
}));
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export { loadDotEnvFiles, run };
|
package/cli/package.json
ADDED
|
@@ -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,155 @@
|
|
|
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-9f42c336.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-dde0ccf1.esm.js';
|
|
42
|
+
import '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
43
|
+
import './package-99e547a7.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
|
+
if (!compiler) {
|
|
101
|
+
return _Promise.reject(new Error('Failed to create webpack compiler'));
|
|
102
|
+
}
|
|
103
|
+
return new _Promise((resolve, reject) => {
|
|
104
|
+
compiler.run((err, stats) => {
|
|
105
|
+
let messages;
|
|
106
|
+
if (err) {
|
|
107
|
+
if (!err.message) {
|
|
108
|
+
return reject(err);
|
|
109
|
+
}
|
|
110
|
+
let errMessage = err.message;
|
|
111
|
+
// Add additional information for postcss errors
|
|
112
|
+
if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
|
|
113
|
+
errMessage += '\nCompileError: Begins at CSS selector ' +
|
|
114
|
+
// @ts-ignore
|
|
115
|
+
err['postcssNode'].selector;
|
|
116
|
+
}
|
|
117
|
+
messages = formatWebpackMessages({
|
|
118
|
+
// @ts-ignore
|
|
119
|
+
errors: [errMessage],
|
|
120
|
+
warnings: []
|
|
121
|
+
});
|
|
122
|
+
} else {
|
|
123
|
+
messages = formatWebpackMessages(stats?.toJson({
|
|
124
|
+
all: false,
|
|
125
|
+
warnings: true,
|
|
126
|
+
errors: true
|
|
127
|
+
}));
|
|
128
|
+
}
|
|
129
|
+
if (messages.errors.length) {
|
|
130
|
+
// Only keep the first error. Others are often indicative
|
|
131
|
+
// of the same problem, but confuse the reader with noise.
|
|
132
|
+
if (messages.errors.length > 1) {
|
|
133
|
+
messages.errors.length = 1;
|
|
134
|
+
}
|
|
135
|
+
return reject(new Error(messages.errors.join('\n\n')));
|
|
136
|
+
}
|
|
137
|
+
if (process.env.CI && (typeof process.env.CI !== 'string' || process.env.CI.toLowerCase() !== 'false') && messages.warnings.length) {
|
|
138
|
+
console.log(chalk.yellow('\nTreating warnings as errors because process.env.CI = true.\n' + 'Most CI servers set it automatically.\n'));
|
|
139
|
+
return reject(new Error(messages.warnings.join('\n\n')));
|
|
140
|
+
}
|
|
141
|
+
return resolve({
|
|
142
|
+
stats: stats,
|
|
143
|
+
warnings: messages.warnings
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function copyDefaultFiles() {
|
|
149
|
+
fs.copySync(path.join(packageLocation, 'html-page'), paths.appBuild, {
|
|
150
|
+
dereference: true
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export { run as default };
|
|
@@ -0,0 +1,169 @@
|
|
|
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-764c482f.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-edca0c33.cjs.prod.js');
|
|
44
|
+
require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
45
|
+
require('./package-940b0a2a.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
|
+
if (!compiler) {
|
|
115
|
+
return _Promise__default["default"].reject(new Error('Failed to create webpack compiler'));
|
|
116
|
+
}
|
|
117
|
+
return new _Promise__default["default"]((resolve, reject) => {
|
|
118
|
+
compiler.run((err, stats) => {
|
|
119
|
+
let messages;
|
|
120
|
+
if (err) {
|
|
121
|
+
if (!err.message) {
|
|
122
|
+
return reject(err);
|
|
123
|
+
}
|
|
124
|
+
let errMessage = err.message;
|
|
125
|
+
// Add additional information for postcss errors
|
|
126
|
+
if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
|
|
127
|
+
errMessage += '\nCompileError: Begins at CSS selector ' +
|
|
128
|
+
// @ts-ignore
|
|
129
|
+
err['postcssNode'].selector;
|
|
130
|
+
}
|
|
131
|
+
messages = formatWebpackMessages__default["default"]({
|
|
132
|
+
// @ts-ignore
|
|
133
|
+
errors: [errMessage],
|
|
134
|
+
warnings: []
|
|
135
|
+
});
|
|
136
|
+
} else {
|
|
137
|
+
messages = formatWebpackMessages__default["default"](stats?.toJson({
|
|
138
|
+
all: false,
|
|
139
|
+
warnings: true,
|
|
140
|
+
errors: true
|
|
141
|
+
}));
|
|
142
|
+
}
|
|
143
|
+
if (messages.errors.length) {
|
|
144
|
+
// Only keep the first error. Others are often indicative
|
|
145
|
+
// of the same problem, but confuse the reader with noise.
|
|
146
|
+
if (messages.errors.length > 1) {
|
|
147
|
+
messages.errors.length = 1;
|
|
148
|
+
}
|
|
149
|
+
return reject(new Error(messages.errors.join('\n\n')));
|
|
150
|
+
}
|
|
151
|
+
if (process.env.CI && (typeof process.env.CI !== 'string' || process.env.CI.toLowerCase() !== 'false') && messages.warnings.length) {
|
|
152
|
+
console.log(chalk__default["default"].yellow('\nTreating warnings as errors because process.env.CI = true.\n' + 'Most CI servers set it automatically.\n'));
|
|
153
|
+
return reject(new Error(messages.warnings.join('\n\n')));
|
|
154
|
+
}
|
|
155
|
+
return resolve({
|
|
156
|
+
stats: stats,
|
|
157
|
+
warnings: messages.warnings
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
function copyDefaultFiles() {
|
|
163
|
+
fs__default["default"].copySync(path__default["default"].join(assets.packageLocation, 'html-page'), paths.paths.appBuild, {
|
|
164
|
+
dereference: true
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
exports["default"] = run;
|