@commercetools-frontend/mc-scripts 21.7.0 → 21.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -42
- package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.d.ts +1 -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/{build/config/application-runtime.js → application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js} +2 -2
- 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 +1 -1
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.d.ts +1 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +361 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.js +7 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +361 -0
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +345 -0
- package/cli/package.json +4 -0
- package/config/create-webpack-config-for-development.js +7 -1
- package/config/create-webpack-config-for-production.js +7 -1
- package/config/vendors-to-transpile.js +5 -1
- package/dist/build-5357ad26.cjs.prod.js +224 -0
- package/dist/build-9b6d7eee.cjs.dev.js +224 -0
- package/dist/build-c483e87f.esm.js +209 -0
- package/dist/build-vite-3b82522e.cjs.dev.js +151 -0
- package/dist/build-vite-93abdc95.esm.js +139 -0
- package/dist/build-vite-b7cd993a.cjs.prod.js +151 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.d.ts +1 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +30 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.js +7 -0
- package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +30 -0
- package/dist/commercetools-frontend-mc-scripts.esm.js +22 -0
- package/dist/compile-html-4361a0b3.esm.js +77 -0
- package/dist/compile-html-d6331c35.cjs.prod.js +87 -0
- package/dist/compile-html-d9e731aa.cjs.dev.js +87 -0
- package/dist/config-sync-6b31d972.esm.js +840 -0
- package/dist/config-sync-a478bc0f.cjs.dev.js +864 -0
- package/dist/config-sync-f07734e4.cjs.prod.js +859 -0
- package/{build/config/create-postcss-config.js → dist/create-postcss-config-04243dea.esm.js} +27 -25
- package/dist/create-postcss-config-760e2dc5.cjs.dev.js +90 -0
- package/dist/create-postcss-config-ddc3abee.cjs.prod.js +90 -0
- package/dist/create-webpack-config-for-development-76fdab59.cjs.prod.js +419 -0
- package/{build/config/create-webpack-config-for-development.js → dist/create-webpack-config-for-development-d93ae4b2.esm.js} +94 -57
- package/dist/create-webpack-config-for-development-dfd1c174.cjs.dev.js +419 -0
- package/{build/config/create-webpack-config-for-production.js → dist/create-webpack-config-for-production-9290479a.esm.js} +120 -54
- package/dist/create-webpack-config-for-production-bc8c1f37.cjs.dev.js +469 -0
- package/dist/create-webpack-config-for-production-d652ad1a.cjs.prod.js +469 -0
- package/dist/declarations/src/application-runtime.d.ts +1 -0
- package/dist/declarations/src/cli.d.ts +4 -0
- package/dist/declarations/src/commands/build-vite.d.ts +2 -0
- package/dist/declarations/src/commands/build.d.ts +2 -0
- package/dist/declarations/src/commands/compile-html.d.ts +3 -0
- package/dist/declarations/src/commands/config-sync.d.ts +3 -0
- package/dist/declarations/src/commands/login.d.ts +2 -0
- package/dist/declarations/src/commands/serve.d.ts +2 -0
- package/dist/declarations/src/commands/start-vite.d.ts +2 -0
- package/dist/declarations/src/commands/start.d.ts +2 -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/has-jsx-runtime.d.ts +2 -0
- package/dist/declarations/src/config/moment-locales.d.ts +2 -0
- package/dist/declarations/src/config/paths.d.ts +12 -0
- package/dist/declarations/src/config/vendors-to-transpile.d.ts +2 -0
- package/dist/declarations/src/config/webpack-dev-server.config.d.ts +6 -0
- package/dist/declarations/src/deprecated-entry-points.d.ts +7 -0
- package/dist/declarations/src/generated/core.d.ts +710 -0
- package/dist/declarations/src/generated/settings.d.ts +2485 -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 +82 -0
- package/dist/declarations/src/utils/auth.d.ts +6 -0
- package/dist/declarations/src/utils/credentials-storage.d.ts +11 -0
- package/dist/declarations/src/utils/get-config-diff.d.ts +3 -0
- package/dist/declarations/src/utils/graphql-requests.d.ts +80 -0
- package/dist/declarations/src/utils/user-agent.d.ts +2 -0
- package/dist/declarations/src/version.d.ts +2 -0
- package/dist/declarations/src/vite-plugins/vite-plugin-custom-application.d.ts +4 -0
- package/dist/declarations/src/vite-plugins/vite-plugin-dynamic-base-assets-globals.d.ts +3 -0
- package/dist/declarations/src/vite-plugins/vite-plugin-svgr.d.ts +3 -0
- package/dist/declarations/src/webpack-plugins/final-stats-writer-plugin.d.ts +12 -0
- package/dist/declarations/src/webpack-plugins/local-html-webpack-plugin.d.ts +5 -0
- package/dist/declarations/src/webpack.d.ts +2 -0
- package/dist/has-jsx-runtime-0b03b72e.cjs.prod.js +17 -0
- package/dist/has-jsx-runtime-3d4bb633.cjs.dev.js +17 -0
- package/{build/config/has-jsx-runtime.js → dist/has-jsx-runtime-8314226e.esm.js} +1 -3
- package/dist/login-7b7ae27e.esm.js +155 -0
- package/dist/login-b13f26e7.cjs.dev.js +165 -0
- package/dist/login-c11fb977.cjs.prod.js +165 -0
- package/dist/package-4b4fcf02.cjs.prod.js +139 -0
- package/dist/package-4c3e3fb7.cjs.dev.js +139 -0
- package/dist/package-8e6305bd.esm.js +137 -0
- package/dist/paths-16823f56.cjs.dev.js +55 -0
- package/dist/paths-76b66e74.cjs.prod.js +55 -0
- package/dist/paths-ed23d5a1.esm.js +46 -0
- package/dist/serve-12de323b.cjs.dev.js +70 -0
- package/dist/serve-784f4fcd.cjs.prod.js +70 -0
- package/dist/serve-d6b437b1.esm.js +62 -0
- package/dist/start-1b7dad90.cjs.prod.js +209 -0
- package/dist/start-45ca01f2.cjs.dev.js +209 -0
- package/dist/start-600d06a3.esm.js +194 -0
- package/dist/start-vite-22de08dc.cjs.dev.js +151 -0
- package/dist/start-vite-dc046cba.esm.js +138 -0
- package/dist/start-vite-fe13330b.cjs.prod.js +151 -0
- package/dist/user-agent-5f8ec93d.cjs.prod.js +106 -0
- package/dist/user-agent-ca628320.esm.js +94 -0
- package/dist/user-agent-ee57c98a.cjs.dev.js +106 -0
- package/dist/vendors-to-transpile-367e0ba8.cjs.prod.js +5 -0
- package/dist/vendors-to-transpile-68e03526.esm.js +3 -0
- package/dist/vendors-to-transpile-b51af5d3.cjs.dev.js +5 -0
- package/dist/vite-plugin-svgr-4205f2b5.cjs.dev.js +110 -0
- package/dist/vite-plugin-svgr-eb8524fa.esm.js +85 -0
- package/dist/vite-plugin-svgr-f3bbedbe.cjs.prod.js +110 -0
- package/package.json +56 -50
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.d.ts +1 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +14 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.js +7 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +14 -0
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +6 -0
- package/postcss/package.json +4 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.d.ts +1 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +51 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.js +7 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +51 -0
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +42 -0
- package/webpack/package.json +4 -0
- package/build/bin/cli.js +0 -264
- package/build/commands/build-vite.js +0 -91
- package/build/commands/build.js +0 -140
- package/build/commands/compile-html.js +0 -53
- package/build/commands/config-sync.js +0 -176
- package/build/commands/login.js +0 -60
- package/build/commands/serve.js +0 -37
- package/build/commands/start-vite.js +0 -138
- package/build/commands/start.js +0 -108
- package/build/config/paths.js +0 -38
- package/build/config/vendors-to-transpile.js +0 -3
- package/build/config/webpack-dev-server.config.js +0 -69
- package/build/index.js +0 -16
- package/build/utils/auth.js +0 -34
- package/build/utils/auth.spec.js +0 -61
- package/build/utils/create-custom-application.settings.graphql +0 -8
- package/build/utils/credentials-storage.js +0 -72
- package/build/utils/credentials-storage.spec.js +0 -69
- package/build/utils/fetch-custom-application.settings.graphql +0 -36
- package/build/utils/fetch-user-organizations.core.graphql +0 -9
- package/build/utils/get-config-diff.js +0 -308
- package/build/utils/get-config-diff.spec.js +0 -285
- package/build/utils/graphql-requests.js +0 -105
- package/build/utils/graphql-requests.spec.js +0 -159
- package/build/utils/require-graphql.js +0 -15
- package/build/utils/update-custom-application.settings.graphql +0 -13
- package/build/utils/user-agent.js +0 -15
- package/build/webpack-plugins/final-stats-writer-plugin.js +0 -50
- package/build/webpack-plugins/local-html-webpack-plugin.js +0 -38
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import _toConsumableArray from '@babel/runtime-corejs3/helpers/esm/toConsumableArray';
|
|
2
|
+
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/esm/asyncToGenerator';
|
|
3
|
+
import _Array$isArray from '@babel/runtime-corejs3/core-js-stable/array/is-array';
|
|
4
|
+
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
5
|
+
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
|
|
6
|
+
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
7
|
+
import fs from 'fs';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import { cac } from 'cac';
|
|
10
|
+
import dotenv from 'dotenv';
|
|
11
|
+
import dotenvExpand from 'dotenv-expand';
|
|
12
|
+
import { p as pkgJson } from '../../dist/package-8e6305bd.esm.js';
|
|
13
|
+
|
|
14
|
+
var cli = cac('mc-scripts'); // Makes the script crash on unhandled rejections instead of silently
|
|
15
|
+
// ignoring them. In the future, promise rejections that are not handled will
|
|
16
|
+
// terminate the Node.js process with a non-zero exit code.
|
|
17
|
+
|
|
18
|
+
process.on('unhandledRejection', function (err) {
|
|
19
|
+
throw err;
|
|
20
|
+
}); // Get the current directory where the CLI is executed from. Usually this is the application folder.
|
|
21
|
+
|
|
22
|
+
var applicationDirectory = fs.realpathSync(process.cwd());
|
|
23
|
+
|
|
24
|
+
var run = function run() {
|
|
25
|
+
cli.help();
|
|
26
|
+
cli.version(pkgJson.version);
|
|
27
|
+
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
|
|
28
|
+
|
|
29
|
+
cli.command('').action(function () {
|
|
30
|
+
cli.outputHelp();
|
|
31
|
+
}); // Command: start
|
|
32
|
+
|
|
33
|
+
cli.command('start', 'Starts the application in development mode using Webpack Dev Server.').alias('dev').action( /*#__PURE__*/function () {
|
|
34
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
|
|
35
|
+
var shouldUseExperimentalBundler, startCommand;
|
|
36
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
37
|
+
while (1) {
|
|
38
|
+
switch (_context.prev = _context.next) {
|
|
39
|
+
case 0:
|
|
40
|
+
// Load dotenv files into the process environment.
|
|
41
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
42
|
+
loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
|
|
43
|
+
|
|
44
|
+
process.env.BABEL_ENV = 'development';
|
|
45
|
+
process.env.NODE_ENV = 'development';
|
|
46
|
+
shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
|
|
47
|
+
|
|
48
|
+
if (shouldUseExperimentalBundler) {
|
|
49
|
+
console.log('Experimental Vite bundler enabled! 🚀');
|
|
50
|
+
console.log('');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (!shouldUseExperimentalBundler) {
|
|
54
|
+
_context.next = 11;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
_context.next = 8;
|
|
59
|
+
return import('../../dist/start-vite-dc046cba.esm.js');
|
|
60
|
+
|
|
61
|
+
case 8:
|
|
62
|
+
_context.t0 = _context.sent;
|
|
63
|
+
_context.next = 14;
|
|
64
|
+
break;
|
|
65
|
+
|
|
66
|
+
case 11:
|
|
67
|
+
_context.next = 13;
|
|
68
|
+
return import('../../dist/start-600d06a3.esm.js');
|
|
69
|
+
|
|
70
|
+
case 13:
|
|
71
|
+
_context.t0 = _context.sent;
|
|
72
|
+
|
|
73
|
+
case 14:
|
|
74
|
+
startCommand = _context.t0;
|
|
75
|
+
_context.next = 17;
|
|
76
|
+
return startCommand.default();
|
|
77
|
+
|
|
78
|
+
case 17:
|
|
79
|
+
case "end":
|
|
80
|
+
return _context.stop();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}, _callee);
|
|
84
|
+
}));
|
|
85
|
+
|
|
86
|
+
return function (_x) {
|
|
87
|
+
return _ref.apply(this, arguments);
|
|
88
|
+
};
|
|
89
|
+
}()); // Command: build
|
|
90
|
+
|
|
91
|
+
cli.command('build', '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".', {
|
|
92
|
+
default: false
|
|
93
|
+
}).action( /*#__PURE__*/function () {
|
|
94
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(options) {
|
|
95
|
+
var shouldUseExperimentalBundler, buildCommand, shouldAlsoCompile, compileHtmlCommand;
|
|
96
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
97
|
+
while (1) {
|
|
98
|
+
switch (_context2.prev = _context2.next) {
|
|
99
|
+
case 0:
|
|
100
|
+
// Load dotenv files into the process environment.
|
|
101
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
102
|
+
loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
|
|
103
|
+
|
|
104
|
+
process.env.BABEL_ENV = 'production';
|
|
105
|
+
process.env.NODE_ENV = 'production';
|
|
106
|
+
shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
|
|
107
|
+
|
|
108
|
+
if (shouldUseExperimentalBundler) {
|
|
109
|
+
console.log('Experimental Vite bundler enabled! 🚀');
|
|
110
|
+
console.log('');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (!shouldUseExperimentalBundler) {
|
|
114
|
+
_context2.next = 11;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
_context2.next = 8;
|
|
119
|
+
return import('../../dist/build-vite-93abdc95.esm.js');
|
|
120
|
+
|
|
121
|
+
case 8:
|
|
122
|
+
_context2.t0 = _context2.sent;
|
|
123
|
+
_context2.next = 14;
|
|
124
|
+
break;
|
|
125
|
+
|
|
126
|
+
case 11:
|
|
127
|
+
_context2.next = 13;
|
|
128
|
+
return import('../../dist/build-c483e87f.esm.js');
|
|
129
|
+
|
|
130
|
+
case 13:
|
|
131
|
+
_context2.t0 = _context2.sent;
|
|
132
|
+
|
|
133
|
+
case 14:
|
|
134
|
+
buildCommand = _context2.t0;
|
|
135
|
+
_context2.next = 17;
|
|
136
|
+
return buildCommand.default();
|
|
137
|
+
|
|
138
|
+
case 17:
|
|
139
|
+
shouldAlsoCompile = !options.buildOnly;
|
|
140
|
+
|
|
141
|
+
if (!shouldAlsoCompile) {
|
|
142
|
+
_context2.next = 25;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
console.log('');
|
|
147
|
+
_context2.next = 22;
|
|
148
|
+
return import('../../dist/compile-html-4361a0b3.esm.js');
|
|
149
|
+
|
|
150
|
+
case 22:
|
|
151
|
+
compileHtmlCommand = _context2.sent;
|
|
152
|
+
_context2.next = 25;
|
|
153
|
+
return compileHtmlCommand.default({
|
|
154
|
+
printSecurityHeaders: false
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
case 25:
|
|
158
|
+
case "end":
|
|
159
|
+
return _context2.stop();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}, _callee2);
|
|
163
|
+
}));
|
|
164
|
+
|
|
165
|
+
return function (_x2) {
|
|
166
|
+
return _ref2.apply(this, arguments);
|
|
167
|
+
};
|
|
168
|
+
}()); // Command: compile-html
|
|
169
|
+
|
|
170
|
+
cli.command('compile-html', '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.', {
|
|
171
|
+
default: false
|
|
172
|
+
}).action( /*#__PURE__*/function () {
|
|
173
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(options) {
|
|
174
|
+
var compileHtmlCommand;
|
|
175
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
176
|
+
while (1) {
|
|
177
|
+
switch (_context3.prev = _context3.next) {
|
|
178
|
+
case 0:
|
|
179
|
+
// Load dotenv files into the process environment.
|
|
180
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
181
|
+
loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
|
|
182
|
+
|
|
183
|
+
process.env.NODE_ENV = 'production';
|
|
184
|
+
_context3.next = 4;
|
|
185
|
+
return import('../../dist/compile-html-4361a0b3.esm.js');
|
|
186
|
+
|
|
187
|
+
case 4:
|
|
188
|
+
compileHtmlCommand = _context3.sent;
|
|
189
|
+
_context3.next = 7;
|
|
190
|
+
return compileHtmlCommand.default(options);
|
|
191
|
+
|
|
192
|
+
case 7:
|
|
193
|
+
case "end":
|
|
194
|
+
return _context3.stop();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}, _callee3);
|
|
198
|
+
}));
|
|
199
|
+
|
|
200
|
+
return function (_x3) {
|
|
201
|
+
return _ref3.apply(this, arguments);
|
|
202
|
+
};
|
|
203
|
+
}()); // Command: serve
|
|
204
|
+
|
|
205
|
+
cli.command('serve', 'Serves previously built and compiled application from the "public" folder.').action( /*#__PURE__*/function () {
|
|
206
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(options) {
|
|
207
|
+
var serveCommand;
|
|
208
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
209
|
+
while (1) {
|
|
210
|
+
switch (_context4.prev = _context4.next) {
|
|
211
|
+
case 0:
|
|
212
|
+
// Load dotenv files into the process environment.
|
|
213
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
214
|
+
loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
|
|
215
|
+
|
|
216
|
+
process.env.NODE_ENV = 'production';
|
|
217
|
+
_context4.next = 4;
|
|
218
|
+
return import('../../dist/serve-d6b437b1.esm.js');
|
|
219
|
+
|
|
220
|
+
case 4:
|
|
221
|
+
serveCommand = _context4.sent;
|
|
222
|
+
_context4.next = 7;
|
|
223
|
+
return serveCommand.default();
|
|
224
|
+
|
|
225
|
+
case 7:
|
|
226
|
+
case "end":
|
|
227
|
+
return _context4.stop();
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}, _callee4);
|
|
231
|
+
}));
|
|
232
|
+
|
|
233
|
+
return function (_x4) {
|
|
234
|
+
return _ref4.apply(this, arguments);
|
|
235
|
+
};
|
|
236
|
+
}()); // Command: login
|
|
237
|
+
|
|
238
|
+
cli.command('login', '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.').action( /*#__PURE__*/function () {
|
|
239
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(options) {
|
|
240
|
+
var loginCommand;
|
|
241
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
242
|
+
while (1) {
|
|
243
|
+
switch (_context5.prev = _context5.next) {
|
|
244
|
+
case 0:
|
|
245
|
+
// Load dotenv files into the process environment.
|
|
246
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
247
|
+
loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
|
|
248
|
+
|
|
249
|
+
process.env.NODE_ENV = 'production';
|
|
250
|
+
_context5.next = 4;
|
|
251
|
+
return import('../../dist/login-7b7ae27e.esm.js');
|
|
252
|
+
|
|
253
|
+
case 4:
|
|
254
|
+
loginCommand = _context5.sent;
|
|
255
|
+
_context5.next = 7;
|
|
256
|
+
return loginCommand.default();
|
|
257
|
+
|
|
258
|
+
case 7:
|
|
259
|
+
case "end":
|
|
260
|
+
return _context5.stop();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}, _callee5);
|
|
264
|
+
}));
|
|
265
|
+
|
|
266
|
+
return function (_x5) {
|
|
267
|
+
return _ref5.apply(this, arguments);
|
|
268
|
+
};
|
|
269
|
+
}()); // Command: config:sync
|
|
270
|
+
|
|
271
|
+
cli.command('config:sync', '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.').option('--dry-run', '(optional) Executes the command but does not send any mutation request.', {
|
|
272
|
+
default: false
|
|
273
|
+
}).action( /*#__PURE__*/function () {
|
|
274
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(options) {
|
|
275
|
+
var configSyncCommand;
|
|
276
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
277
|
+
while (1) {
|
|
278
|
+
switch (_context6.prev = _context6.next) {
|
|
279
|
+
case 0:
|
|
280
|
+
// Load dotenv files into the process environment.
|
|
281
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
282
|
+
loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
|
|
283
|
+
|
|
284
|
+
process.env.NODE_ENV = 'production';
|
|
285
|
+
_context6.next = 4;
|
|
286
|
+
return import('../../dist/config-sync-6b31d972.esm.js');
|
|
287
|
+
|
|
288
|
+
case 4:
|
|
289
|
+
configSyncCommand = _context6.sent;
|
|
290
|
+
_context6.next = 7;
|
|
291
|
+
return configSyncCommand.default(options);
|
|
292
|
+
|
|
293
|
+
case 7:
|
|
294
|
+
case "end":
|
|
295
|
+
return _context6.stop();
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}, _callee6);
|
|
299
|
+
}));
|
|
300
|
+
|
|
301
|
+
return function (_x6) {
|
|
302
|
+
return _ref6.apply(this, arguments);
|
|
303
|
+
};
|
|
304
|
+
}());
|
|
305
|
+
cli.parse();
|
|
306
|
+
}; // Load dotenv files into the process environment.
|
|
307
|
+
// This is essentially what `dotenv-cli` does, but it's now built into this CLI.
|
|
308
|
+
// Inspired also by https://create-react-app.dev/docs/adding-custom-environment-variables/#what-other-env-files-can-be-used
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
function loadDotEnvFiles(globalOptions) {
|
|
312
|
+
var _context7;
|
|
313
|
+
|
|
314
|
+
var environment = process.env.MC_APP_ENV || process.env.NODE_ENV;
|
|
315
|
+
var dotenvFiles = []; // Custom dotenv files specified by the `--env` option takes precedence.
|
|
316
|
+
|
|
317
|
+
if (typeof globalOptions.env === 'string') {
|
|
318
|
+
dotenvFiles.push(globalOptions.env);
|
|
319
|
+
} else if (_Array$isArray(globalOptions.env)) {
|
|
320
|
+
// Multiple `--env` options are allowed.
|
|
321
|
+
dotenvFiles.push.apply(dotenvFiles, _toConsumableArray(globalOptions.env));
|
|
322
|
+
} // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
dotenvFiles.push.apply(dotenvFiles, _toConsumableArray(_filterInstanceProperty(_context7 = [".env.".concat(environment, ".local"), // Don't include `.env.local` for `test` environment
|
|
326
|
+
// since normally you expect tests to produce the same
|
|
327
|
+
// results for everyone
|
|
328
|
+
process.env.NODE_ENV !== 'test' && ".env.local", ".env.".concat(environment), '.env']).call(_context7, Boolean))); // Load environment variables from .env* files. Suppress warnings using silent
|
|
329
|
+
// if this file is missing. dotenv will never modify any environment variables
|
|
330
|
+
// that have already been set. Variable expansion is supported in .env files.
|
|
331
|
+
// https://github.com/motdotla/dotenv
|
|
332
|
+
// https://github.com/motdotla/dotenv-expand
|
|
333
|
+
|
|
334
|
+
_forEachInstanceProperty(dotenvFiles).call(dotenvFiles, function (dotenvFile) {
|
|
335
|
+
var dotenvFilePath = path.resolve(path.join(applicationDirectory, dotenvFile));
|
|
336
|
+
|
|
337
|
+
if (fs.existsSync(dotenvFilePath)) {
|
|
338
|
+
dotenvExpand.expand(dotenv.config({
|
|
339
|
+
path: dotenvFilePath
|
|
340
|
+
}));
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export { loadDotEnvFiles, run };
|
package/cli/package.json
ADDED
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
// For backwards compatibilty
|
|
2
|
-
|
|
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;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
// For backwards compatibilty
|
|
2
|
-
|
|
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;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
// For backwards compatibilty
|
|
2
|
-
|
|
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,224 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
4
|
+
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
5
|
+
var _Promise = require('@babel/runtime-corejs3/core-js-stable/promise');
|
|
6
|
+
var path = require('path');
|
|
7
|
+
var fs = require('fs-extra');
|
|
8
|
+
var webpack = require('webpack');
|
|
9
|
+
var chalk = require('chalk');
|
|
10
|
+
var checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
|
|
11
|
+
var formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
|
|
12
|
+
var FileSizeReporter = require('react-dev-utils/FileSizeReporter');
|
|
13
|
+
var printBuildError = require('react-dev-utils/printBuildError');
|
|
14
|
+
var assets = require('@commercetools-frontend/assets');
|
|
15
|
+
var paths = require('./paths-76b66e74.cjs.prod.js');
|
|
16
|
+
var createWebpackConfigForProduction = require('./create-webpack-config-for-production-d652ad1a.cjs.prod.js');
|
|
17
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
18
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
19
|
+
require('fs');
|
|
20
|
+
require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
21
|
+
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
22
|
+
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
23
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
24
|
+
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
25
|
+
require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
26
|
+
require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
27
|
+
require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
28
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
29
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
30
|
+
require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
31
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/ends-with');
|
|
32
|
+
require('@babel/runtime-corejs3/core-js-stable/number/is-integer');
|
|
33
|
+
require('html-webpack-plugin');
|
|
34
|
+
require('webpack-bundle-analyzer');
|
|
35
|
+
require('css-minimizer-webpack-plugin');
|
|
36
|
+
require('mini-css-extract-plugin');
|
|
37
|
+
require('moment-locales-webpack-plugin');
|
|
38
|
+
require('terser-webpack-plugin');
|
|
39
|
+
require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
40
|
+
require('@babel/runtime-corejs3/helpers/createClass');
|
|
41
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/bind');
|
|
42
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
43
|
+
require('@babel/runtime-corejs3/core-js-stable/object/assign');
|
|
44
|
+
require('./vendors-to-transpile-367e0ba8.cjs.prod.js');
|
|
45
|
+
require('./create-postcss-config-ddc3abee.cjs.prod.js');
|
|
46
|
+
require('@babel/runtime-corejs3/helpers/toConsumableArray');
|
|
47
|
+
require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
48
|
+
require('./package-4b4fcf02.cjs.prod.js');
|
|
49
|
+
require('./has-jsx-runtime-0b03b72e.cjs.prod.js');
|
|
50
|
+
|
|
51
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
52
|
+
|
|
53
|
+
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefault(_regeneratorRuntime);
|
|
54
|
+
var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
|
|
55
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
56
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
57
|
+
var webpack__default = /*#__PURE__*/_interopDefault(webpack);
|
|
58
|
+
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
59
|
+
var checkRequiredFiles__default = /*#__PURE__*/_interopDefault(checkRequiredFiles);
|
|
60
|
+
var formatWebpackMessages__default = /*#__PURE__*/_interopDefault(formatWebpackMessages);
|
|
61
|
+
var FileSizeReporter__default = /*#__PURE__*/_interopDefault(FileSizeReporter);
|
|
62
|
+
var printBuildError__default = /*#__PURE__*/_interopDefault(printBuildError);
|
|
63
|
+
|
|
64
|
+
var measureFileSizesBeforeBuild = FileSizeReporter__default["default"].measureFileSizesBeforeBuild;
|
|
65
|
+
var printFileSizesAfterBuild = FileSizeReporter__default["default"].printFileSizesAfterBuild; // These sizes are pretty large. We'll warn for bundles exceeding them.
|
|
66
|
+
|
|
67
|
+
var WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
|
68
|
+
var WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
|
69
|
+
|
|
70
|
+
function run() {
|
|
71
|
+
return _run.apply(this, arguments);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function _run() {
|
|
75
|
+
_run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2() {
|
|
76
|
+
var hasWebpackConfig, previousFileSizes, result, build, _build, copyDefaultFiles;
|
|
77
|
+
|
|
78
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
|
|
79
|
+
while (1) {
|
|
80
|
+
switch (_context2.prev = _context2.next) {
|
|
81
|
+
case 0:
|
|
82
|
+
copyDefaultFiles = function _copyDefaultFiles() {
|
|
83
|
+
fs__default["default"].copySync(path__default["default"].join(assets.packageLocation, 'html-page'), paths.paths.appBuild, {
|
|
84
|
+
dereference: true
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
_build = function _build3() {
|
|
89
|
+
_build = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
|
|
90
|
+
var config, compiler;
|
|
91
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
92
|
+
while (1) {
|
|
93
|
+
switch (_context.prev = _context.next) {
|
|
94
|
+
case 0:
|
|
95
|
+
console.log('Creating an optimized production build...');
|
|
96
|
+
config = hasWebpackConfig ? require(paths.paths.appWebpackConfig) : createWebpackConfigForProduction.createWebpackConfigForProduction();
|
|
97
|
+
compiler = webpack__default["default"](config);
|
|
98
|
+
return _context.abrupt("return", new _Promise__default["default"](function (resolve, reject) {
|
|
99
|
+
compiler.run(function (err, stats) {
|
|
100
|
+
var messages;
|
|
101
|
+
|
|
102
|
+
if (err) {
|
|
103
|
+
if (!err.message) {
|
|
104
|
+
return reject(err);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
var errMessage = err.message; // Add additional information for postcss errors
|
|
108
|
+
|
|
109
|
+
// Add additional information for postcss errors
|
|
110
|
+
if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
|
|
111
|
+
errMessage += '\nCompileError: Begins at CSS selector ' + // @ts-ignore
|
|
112
|
+
err['postcssNode'].selector;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
messages = formatWebpackMessages__default["default"]({
|
|
116
|
+
// @ts-ignore
|
|
117
|
+
errors: [errMessage],
|
|
118
|
+
warnings: []
|
|
119
|
+
});
|
|
120
|
+
} else {
|
|
121
|
+
messages = formatWebpackMessages__default["default"](stats === null || stats === void 0 ? void 0 : stats.toJson({
|
|
122
|
+
all: false,
|
|
123
|
+
warnings: true,
|
|
124
|
+
errors: true
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (messages.errors.length) {
|
|
129
|
+
// Only keep the first error. Others are often indicative
|
|
130
|
+
// of the same problem, but confuse the reader with noise.
|
|
131
|
+
if (messages.errors.length > 1) {
|
|
132
|
+
messages.errors.length = 1;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return reject(new Error(messages.errors.join('\n\n')));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (process.env.CI && (typeof process.env.CI !== 'string' || process.env.CI.toLowerCase() !== 'false') && messages.warnings.length) {
|
|
139
|
+
console.log(chalk__default["default"].yellow('\nTreating warnings as errors because process.env.CI = true.\n' + 'Most CI servers set it automatically.\n'));
|
|
140
|
+
return reject(new Error(messages.warnings.join('\n\n')));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return resolve({
|
|
144
|
+
stats: stats,
|
|
145
|
+
warnings: messages.warnings
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
}));
|
|
149
|
+
|
|
150
|
+
case 4:
|
|
151
|
+
case "end":
|
|
152
|
+
return _context.stop();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}, _callee);
|
|
156
|
+
}));
|
|
157
|
+
return _build.apply(this, arguments);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
build = function _build2() {
|
|
161
|
+
return _build.apply(this, arguments);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
hasWebpackConfig = fs__default["default"].existsSync(paths.paths.appWebpackConfig); // Warn and crash if required files are missing
|
|
165
|
+
|
|
166
|
+
if (!checkRequiredFiles__default["default"]([])) {
|
|
167
|
+
process.exit(1);
|
|
168
|
+
} // First, read the current file sizes in build directory.
|
|
169
|
+
// This lets us display how much they changed later.
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
_context2.next = 7;
|
|
173
|
+
return measureFileSizesBeforeBuild(paths.paths.appBuild);
|
|
174
|
+
|
|
175
|
+
case 7:
|
|
176
|
+
previousFileSizes = _context2.sent;
|
|
177
|
+
// Remove all content but keep the directory so that
|
|
178
|
+
// if you're in it, you don't end up in Trash
|
|
179
|
+
fs__default["default"].emptyDirSync(paths.paths.appBuild); // Copy default files
|
|
180
|
+
|
|
181
|
+
copyDefaultFiles();
|
|
182
|
+
_context2.prev = 10;
|
|
183
|
+
_context2.next = 13;
|
|
184
|
+
return build();
|
|
185
|
+
|
|
186
|
+
case 13:
|
|
187
|
+
result = _context2.sent;
|
|
188
|
+
|
|
189
|
+
if (result.warnings.length) {
|
|
190
|
+
console.log(chalk__default["default"].yellow('Compiled with warnings.\n'));
|
|
191
|
+
console.log(result.warnings.join('\n\n'));
|
|
192
|
+
console.log("\nSearch for the ".concat(chalk__default["default"].underline(chalk__default["default"].yellow('keywords')), " to learn more about each warning."));
|
|
193
|
+
console.log("To ignore, add ".concat(chalk__default["default"].cyan('// eslint-disable-next-line'), " to the line before.\n"));
|
|
194
|
+
} else {
|
|
195
|
+
console.log(chalk__default["default"].green('Compiled successfully.\n'));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
console.log('File sizes after gzip:\n');
|
|
199
|
+
printFileSizesAfterBuild(result.stats, previousFileSizes, paths.paths.appBuild, WARN_AFTER_BUNDLE_GZIP_SIZE, WARN_AFTER_CHUNK_GZIP_SIZE);
|
|
200
|
+
console.log();
|
|
201
|
+
_context2.next = 24;
|
|
202
|
+
break;
|
|
203
|
+
|
|
204
|
+
case 20:
|
|
205
|
+
_context2.prev = 20;
|
|
206
|
+
_context2.t0 = _context2["catch"](10);
|
|
207
|
+
|
|
208
|
+
if (_context2.t0 instanceof Error) {
|
|
209
|
+
printBuildError__default["default"](_context2.t0);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
throw new Error("Failed to compile");
|
|
213
|
+
|
|
214
|
+
case 24:
|
|
215
|
+
case "end":
|
|
216
|
+
return _context2.stop();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}, _callee2, null, [[10, 20]]);
|
|
220
|
+
}));
|
|
221
|
+
return _run.apply(this, arguments);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
exports["default"] = run;
|