@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.
Files changed (152) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -42
  3. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.d.ts +1 -0
  4. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.dev.js +7 -0
  5. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.js +7 -0
  6. package/{build/config/application-runtime.js → application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js} +2 -2
  7. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.esm.js +5 -0
  8. package/application-runtime/package.json +4 -0
  9. package/bin/cli.js +1 -1
  10. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.d.ts +1 -0
  11. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +361 -0
  12. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.js +7 -0
  13. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +361 -0
  14. package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +345 -0
  15. package/cli/package.json +4 -0
  16. package/config/create-webpack-config-for-development.js +7 -1
  17. package/config/create-webpack-config-for-production.js +7 -1
  18. package/config/vendors-to-transpile.js +5 -1
  19. package/dist/build-5357ad26.cjs.prod.js +224 -0
  20. package/dist/build-9b6d7eee.cjs.dev.js +224 -0
  21. package/dist/build-c483e87f.esm.js +209 -0
  22. package/dist/build-vite-3b82522e.cjs.dev.js +151 -0
  23. package/dist/build-vite-93abdc95.esm.js +139 -0
  24. package/dist/build-vite-b7cd993a.cjs.prod.js +151 -0
  25. package/dist/commercetools-frontend-mc-scripts.cjs.d.ts +1 -0
  26. package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +30 -0
  27. package/dist/commercetools-frontend-mc-scripts.cjs.js +7 -0
  28. package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +30 -0
  29. package/dist/commercetools-frontend-mc-scripts.esm.js +22 -0
  30. package/dist/compile-html-4361a0b3.esm.js +77 -0
  31. package/dist/compile-html-d6331c35.cjs.prod.js +87 -0
  32. package/dist/compile-html-d9e731aa.cjs.dev.js +87 -0
  33. package/dist/config-sync-6b31d972.esm.js +840 -0
  34. package/dist/config-sync-a478bc0f.cjs.dev.js +864 -0
  35. package/dist/config-sync-f07734e4.cjs.prod.js +859 -0
  36. package/{build/config/create-postcss-config.js → dist/create-postcss-config-04243dea.esm.js} +27 -25
  37. package/dist/create-postcss-config-760e2dc5.cjs.dev.js +90 -0
  38. package/dist/create-postcss-config-ddc3abee.cjs.prod.js +90 -0
  39. package/dist/create-webpack-config-for-development-76fdab59.cjs.prod.js +419 -0
  40. package/{build/config/create-webpack-config-for-development.js → dist/create-webpack-config-for-development-d93ae4b2.esm.js} +94 -57
  41. package/dist/create-webpack-config-for-development-dfd1c174.cjs.dev.js +419 -0
  42. package/{build/config/create-webpack-config-for-production.js → dist/create-webpack-config-for-production-9290479a.esm.js} +120 -54
  43. package/dist/create-webpack-config-for-production-bc8c1f37.cjs.dev.js +469 -0
  44. package/dist/create-webpack-config-for-production-d652ad1a.cjs.prod.js +469 -0
  45. package/dist/declarations/src/application-runtime.d.ts +1 -0
  46. package/dist/declarations/src/cli.d.ts +4 -0
  47. package/dist/declarations/src/commands/build-vite.d.ts +2 -0
  48. package/dist/declarations/src/commands/build.d.ts +2 -0
  49. package/dist/declarations/src/commands/compile-html.d.ts +3 -0
  50. package/dist/declarations/src/commands/config-sync.d.ts +3 -0
  51. package/dist/declarations/src/commands/login.d.ts +2 -0
  52. package/dist/declarations/src/commands/serve.d.ts +2 -0
  53. package/dist/declarations/src/commands/start-vite.d.ts +2 -0
  54. package/dist/declarations/src/commands/start.d.ts +2 -0
  55. package/dist/declarations/src/config/create-postcss-config.d.ts +4 -0
  56. package/dist/declarations/src/config/create-webpack-config-for-development.d.ts +10 -0
  57. package/dist/declarations/src/config/create-webpack-config-for-production.d.ts +10 -0
  58. package/dist/declarations/src/config/has-jsx-runtime.d.ts +2 -0
  59. package/dist/declarations/src/config/moment-locales.d.ts +2 -0
  60. package/dist/declarations/src/config/paths.d.ts +12 -0
  61. package/dist/declarations/src/config/vendors-to-transpile.d.ts +2 -0
  62. package/dist/declarations/src/config/webpack-dev-server.config.d.ts +6 -0
  63. package/dist/declarations/src/deprecated-entry-points.d.ts +7 -0
  64. package/dist/declarations/src/generated/core.d.ts +710 -0
  65. package/dist/declarations/src/generated/settings.d.ts +2485 -0
  66. package/dist/declarations/src/index.d.ts +3 -0
  67. package/dist/declarations/src/postcss.d.ts +1 -0
  68. package/dist/declarations/src/types.d.ts +82 -0
  69. package/dist/declarations/src/utils/auth.d.ts +6 -0
  70. package/dist/declarations/src/utils/credentials-storage.d.ts +11 -0
  71. package/dist/declarations/src/utils/get-config-diff.d.ts +3 -0
  72. package/dist/declarations/src/utils/graphql-requests.d.ts +80 -0
  73. package/dist/declarations/src/utils/user-agent.d.ts +2 -0
  74. package/dist/declarations/src/version.d.ts +2 -0
  75. package/dist/declarations/src/vite-plugins/vite-plugin-custom-application.d.ts +4 -0
  76. package/dist/declarations/src/vite-plugins/vite-plugin-dynamic-base-assets-globals.d.ts +3 -0
  77. package/dist/declarations/src/vite-plugins/vite-plugin-svgr.d.ts +3 -0
  78. package/dist/declarations/src/webpack-plugins/final-stats-writer-plugin.d.ts +12 -0
  79. package/dist/declarations/src/webpack-plugins/local-html-webpack-plugin.d.ts +5 -0
  80. package/dist/declarations/src/webpack.d.ts +2 -0
  81. package/dist/has-jsx-runtime-0b03b72e.cjs.prod.js +17 -0
  82. package/dist/has-jsx-runtime-3d4bb633.cjs.dev.js +17 -0
  83. package/{build/config/has-jsx-runtime.js → dist/has-jsx-runtime-8314226e.esm.js} +1 -3
  84. package/dist/login-7b7ae27e.esm.js +155 -0
  85. package/dist/login-b13f26e7.cjs.dev.js +165 -0
  86. package/dist/login-c11fb977.cjs.prod.js +165 -0
  87. package/dist/package-4b4fcf02.cjs.prod.js +139 -0
  88. package/dist/package-4c3e3fb7.cjs.dev.js +139 -0
  89. package/dist/package-8e6305bd.esm.js +137 -0
  90. package/dist/paths-16823f56.cjs.dev.js +55 -0
  91. package/dist/paths-76b66e74.cjs.prod.js +55 -0
  92. package/dist/paths-ed23d5a1.esm.js +46 -0
  93. package/dist/serve-12de323b.cjs.dev.js +70 -0
  94. package/dist/serve-784f4fcd.cjs.prod.js +70 -0
  95. package/dist/serve-d6b437b1.esm.js +62 -0
  96. package/dist/start-1b7dad90.cjs.prod.js +209 -0
  97. package/dist/start-45ca01f2.cjs.dev.js +209 -0
  98. package/dist/start-600d06a3.esm.js +194 -0
  99. package/dist/start-vite-22de08dc.cjs.dev.js +151 -0
  100. package/dist/start-vite-dc046cba.esm.js +138 -0
  101. package/dist/start-vite-fe13330b.cjs.prod.js +151 -0
  102. package/dist/user-agent-5f8ec93d.cjs.prod.js +106 -0
  103. package/dist/user-agent-ca628320.esm.js +94 -0
  104. package/dist/user-agent-ee57c98a.cjs.dev.js +106 -0
  105. package/dist/vendors-to-transpile-367e0ba8.cjs.prod.js +5 -0
  106. package/dist/vendors-to-transpile-68e03526.esm.js +3 -0
  107. package/dist/vendors-to-transpile-b51af5d3.cjs.dev.js +5 -0
  108. package/dist/vite-plugin-svgr-4205f2b5.cjs.dev.js +110 -0
  109. package/dist/vite-plugin-svgr-eb8524fa.esm.js +85 -0
  110. package/dist/vite-plugin-svgr-f3bbedbe.cjs.prod.js +110 -0
  111. package/package.json +56 -50
  112. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.d.ts +1 -0
  113. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +14 -0
  114. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.js +7 -0
  115. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +14 -0
  116. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +6 -0
  117. package/postcss/package.json +4 -0
  118. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.d.ts +1 -0
  119. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +51 -0
  120. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.js +7 -0
  121. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +51 -0
  122. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +42 -0
  123. package/webpack/package.json +4 -0
  124. package/build/bin/cli.js +0 -264
  125. package/build/commands/build-vite.js +0 -91
  126. package/build/commands/build.js +0 -140
  127. package/build/commands/compile-html.js +0 -53
  128. package/build/commands/config-sync.js +0 -176
  129. package/build/commands/login.js +0 -60
  130. package/build/commands/serve.js +0 -37
  131. package/build/commands/start-vite.js +0 -138
  132. package/build/commands/start.js +0 -108
  133. package/build/config/paths.js +0 -38
  134. package/build/config/vendors-to-transpile.js +0 -3
  135. package/build/config/webpack-dev-server.config.js +0 -69
  136. package/build/index.js +0 -16
  137. package/build/utils/auth.js +0 -34
  138. package/build/utils/auth.spec.js +0 -61
  139. package/build/utils/create-custom-application.settings.graphql +0 -8
  140. package/build/utils/credentials-storage.js +0 -72
  141. package/build/utils/credentials-storage.spec.js +0 -69
  142. package/build/utils/fetch-custom-application.settings.graphql +0 -36
  143. package/build/utils/fetch-user-organizations.core.graphql +0 -9
  144. package/build/utils/get-config-diff.js +0 -308
  145. package/build/utils/get-config-diff.spec.js +0 -285
  146. package/build/utils/graphql-requests.js +0 -105
  147. package/build/utils/graphql-requests.spec.js +0 -159
  148. package/build/utils/require-graphql.js +0 -15
  149. package/build/utils/update-custom-application.settings.graphql +0 -13
  150. package/build/utils/user-agent.js +0 -15
  151. package/build/webpack-plugins/final-stats-writer-plugin.js +0 -50
  152. package/build/webpack-plugins/local-html-webpack-plugin.js +0 -38
@@ -0,0 +1,194 @@
1
+ import _asyncToGenerator from '@babel/runtime-corejs3/helpers/esm/asyncToGenerator';
2
+ import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
3
+ import _parseInt from '@babel/runtime-corejs3/core-js-stable/parse-int';
4
+ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
5
+ import fs from 'fs';
6
+ import webpack from 'webpack';
7
+ import WebpackDevServer from 'webpack-dev-server';
8
+ import chalk from 'chalk';
9
+ import clearConsole from 'react-dev-utils/clearConsole';
10
+ import checkRequiredFiles from 'react-dev-utils/checkRequiredFiles';
11
+ import { prepareUrls, createCompiler, choosePort } from 'react-dev-utils/WebpackDevServerUtils';
12
+ import openBrowser from 'react-dev-utils/openBrowser';
13
+ import { p as paths } from './paths-ed23d5a1.esm.js';
14
+ import { processConfig } from '@commercetools-frontend/application-config';
15
+ import { processHeaders } from '@commercetools-frontend/mc-html-template';
16
+ import { createMcDevAuthenticationMiddleware } from '@commercetools-frontend/mc-dev-authentication';
17
+ import { c as createWebpackConfigForDevelopment } from './create-webpack-config-for-development-d93ae4b2.esm.js';
18
+ import '@babel/runtime-corejs3/core-js-stable/instance/find';
19
+ import '@babel/runtime-corejs3/core-js-stable/instance/concat';
20
+ import 'path';
21
+ import '@babel/runtime-corejs3/core-js-stable/object/keys';
22
+ import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
23
+ import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
24
+ import '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
25
+ import '@babel/runtime-corejs3/core-js-stable/object/define-properties';
26
+ import '@babel/runtime-corejs3/core-js-stable/object/define-property';
27
+ import '@babel/runtime-corejs3/helpers/defineProperty';
28
+ import '@babel/runtime-corejs3/core-js-stable/instance/map';
29
+ import '@babel/runtime-corejs3/core-js-stable/instance/filter';
30
+ import '@babel/runtime-corejs3/core-js-stable/json/stringify';
31
+ import '@babel/runtime-corejs3/core-js-stable/instance/ends-with';
32
+ import 'webpackbar';
33
+ import 'html-webpack-plugin';
34
+ import 'moment-locales-webpack-plugin';
35
+ import '@pmmmwh/react-refresh-webpack-plugin';
36
+ import '@babel/runtime-corejs3/helpers/classCallCheck';
37
+ import '@babel/runtime-corejs3/helpers/createClass';
38
+ import '@babel/runtime-corejs3/core-js-stable/object/assign';
39
+ import './vendors-to-transpile-68e03526.esm.js';
40
+ import './create-postcss-config-04243dea.esm.js';
41
+ import '@babel/runtime-corejs3/helpers/toConsumableArray';
42
+ import '@babel/runtime-corejs3/helpers/slicedToArray';
43
+ import './package-8e6305bd.esm.js';
44
+ import './has-jsx-runtime-8314226e.esm.js';
45
+
46
+ var host = process.env.HOST || '0.0.0.0'; // We support configuring the sockjs pathname during development.
47
+ // These settings let a developer run multiple simultaneous projects.
48
+ // They are used as the connection `hostname`, `pathname` and `port`
49
+ // in webpackHotDevClient. They are used as the `sockHost`, `sockPath`
50
+ // and `sockPort` options in webpack-dev-server.
51
+
52
+ var sockHost = process.env.WDS_SOCKET_HOST;
53
+ var sockPath = process.env.WDS_SOCKET_PATH; // default: '/ws'
54
+
55
+ var sockPort = process.env.WDS_SOCKET_PORT;
56
+
57
+ var createWebpackDevServerConfig = function createWebpackDevServerConfig(_ref) {
58
+ var port = _ref.port,
59
+ publicPath = _ref.publicPath;
60
+ var applicationConfig = processConfig();
61
+ var compiledHeaders = processHeaders(applicationConfig);
62
+ return {
63
+ client: {
64
+ overlay: false,
65
+ webSocketURL: {
66
+ hostname: sockHost,
67
+ pathname: sockPath,
68
+ port: sockPort
69
+ }
70
+ },
71
+ // Enable gzip compression of generated files.
72
+ compress: true,
73
+ devMiddleware: {
74
+ // It is important to tell WebpackDevServer to use the same "publicPath" path as
75
+ // we specified in the webpack config. When homepage is '.', default to serving
76
+ // from the root.
77
+ publicPath: publicPath
78
+ },
79
+ headers: compiledHeaders,
80
+ historyApiFallback: {
81
+ // Paths with dots should still use the history fallback.
82
+ // See https://github.com/facebookincubator/create-react-app/issues/387.
83
+ disableDotRule: true,
84
+ index: publicPath
85
+ },
86
+ host: host,
87
+ hot: true,
88
+ https: false,
89
+ port: port,
90
+ setupMiddlewares: function setupMiddlewares(middlewares, devServer) {
91
+ var _devServer$app;
92
+
93
+ if (!devServer) {
94
+ throw new Error('webpack-dev-server is not defined');
95
+ }
96
+
97
+ (_devServer$app = devServer.app) === null || _devServer$app === void 0 ? void 0 : _devServer$app.use(createMcDevAuthenticationMiddleware(applicationConfig));
98
+ return middlewares;
99
+ }
100
+ };
101
+ };
102
+
103
+ function run() {
104
+ return _run.apply(this, arguments);
105
+ }
106
+
107
+ function _run() {
108
+ _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
109
+ var _config$output, _context;
110
+
111
+ var useYarn, isInteractive, hasWebpackConfig, DEFAULT_PORT, HOST, port, protocol, appName, urls, config, compiler, serverConfig, devServer;
112
+ return _regeneratorRuntime.wrap(function _callee$(_context2) {
113
+ while (1) {
114
+ switch (_context2.prev = _context2.next) {
115
+ case 0:
116
+ useYarn = fs.existsSync(paths.yarnLockFile);
117
+ isInteractive = process.stdout.isTTY; // Whether or not `react-refresh` is enabled, `react-refresh` is not 100% stable at this time,
118
+ // which is why it's disabled by default.
119
+
120
+ hasWebpackConfig = fs.existsSync(paths.appWebpackConfig); // Warn and crash if required files are missing
121
+
122
+ if (!checkRequiredFiles([])) {
123
+ process.exit(1);
124
+ } // Tools like Cloud9 rely on this.
125
+
126
+
127
+ DEFAULT_PORT = _parseInt(String(process.env.HTTP_PORT), 10) || 3001;
128
+ HOST = process.env.HOST || '0.0.0.0'; // We attempt to use the default port but if it is busy, we offer the user to
129
+ // run on a different port. `detect()` Promise resolves to the next free port.
130
+
131
+ _context2.next = 8;
132
+ return choosePort(HOST, DEFAULT_PORT);
133
+
134
+ case 8:
135
+ port = _context2.sent;
136
+
137
+ if (!(port == null)) {
138
+ _context2.next = 12;
139
+ break;
140
+ }
141
+
142
+ console.warn('Could not find a free port. Aborting.'); // We have not found a port.
143
+
144
+ return _context2.abrupt("return");
145
+
146
+ case 12:
147
+ protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
148
+ appName = require(paths.appPackageJson).name;
149
+ urls = prepareUrls(protocol, HOST, port); // Get webpack config
150
+
151
+ config = hasWebpackConfig ? require(paths.appWebpackConfig) : createWebpackConfigForDevelopment(); // Create a webpack compiler that is configured with custom messages.
152
+
153
+ compiler = createCompiler({
154
+ appName: appName,
155
+ config: config,
156
+ useYarn: useYarn,
157
+ webpack: webpack,
158
+ urls: urls
159
+ }); // Serve webpack assets generated by the compiler over a web sever.
160
+
161
+ serverConfig = createWebpackDevServerConfig({
162
+ port: port,
163
+ publicPath: (_config$output = config.output) === null || _config$output === void 0 ? void 0 : _config$output.publicPath
164
+ });
165
+ devServer = new WebpackDevServer(serverConfig, compiler);
166
+ _context2.next = 21;
167
+ return devServer.start();
168
+
169
+ case 21:
170
+ if (isInteractive) {
171
+ clearConsole();
172
+ }
173
+
174
+ console.log(chalk.cyan('Starting the development server...\n'));
175
+ openBrowser(urls.localUrlForBrowser);
176
+
177
+ _forEachInstanceProperty(_context = ['SIGINT', 'SIGTERM']).call(_context, function (sig) {
178
+ process.on(sig, function () {
179
+ devServer.close();
180
+ process.exit();
181
+ });
182
+ });
183
+
184
+ case 25:
185
+ case "end":
186
+ return _context2.stop();
187
+ }
188
+ }
189
+ }, _callee);
190
+ }));
191
+ return _run.apply(this, arguments);
192
+ }
193
+
194
+ export { run as default };
@@ -0,0 +1,151 @@
1
+ 'use strict';
2
+
3
+ var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
4
+ var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
5
+ var _parseInt = require('@babel/runtime-corejs3/core-js-stable/parse-int');
6
+ var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
7
+ var fs = require('fs-extra');
8
+ var path = require('path');
9
+ var vite = require('vite');
10
+ var pluginGraphql = require('@rollup/plugin-graphql');
11
+ var pluginReact = require('@vitejs/plugin-react');
12
+ var applicationConfig = require('@commercetools-frontend/application-config');
13
+ var mcHtmlTemplate = require('@commercetools-frontend/mc-html-template');
14
+ var assets = require('@commercetools-frontend/assets');
15
+ var paths = require('./paths-16823f56.cjs.dev.js');
16
+ var _Object$assign = require('@babel/runtime-corejs3/core-js-stable/object/assign');
17
+ var mcDevAuthentication = require('@commercetools-frontend/mc-dev-authentication');
18
+ var vitePluginSvgr = require('./vite-plugin-svgr-4205f2b5.cjs.dev.js');
19
+ require('@babel/runtime-corejs3/core-js-stable/instance/find');
20
+ require('@babel/runtime-corejs3/core-js-stable/instance/concat');
21
+ require('fs');
22
+ require('@rollup/pluginutils');
23
+
24
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
25
+
26
+ var _regeneratorRuntime__default = /*#__PURE__*/_interopDefault(_regeneratorRuntime);
27
+ var _parseInt__default = /*#__PURE__*/_interopDefault(_parseInt);
28
+ var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
29
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
30
+ var path__default = /*#__PURE__*/_interopDefault(path);
31
+ var pluginGraphql__default = /*#__PURE__*/_interopDefault(pluginGraphql);
32
+ var pluginReact__default = /*#__PURE__*/_interopDefault(pluginReact);
33
+ var _Object$assign__default = /*#__PURE__*/_interopDefault(_Object$assign);
34
+
35
+ var vitePluginCustomApplication = function vitePluginCustomApplication(applicationConfig) {
36
+ return {
37
+ name: 'custom-application',
38
+ configureServer: function configureServer(server) {
39
+ return function () {
40
+ // Users do not need to have/maintain the `index.html` (as expected by Vite)
41
+ // as it's generated and maintained by the Custom Application CLI.
42
+ // Therefore, the generated `index.html` (template) is written into the `/public`
43
+ // folder so that it's gitignored.
44
+ // As a result, we need to make sure to point the URI path to the correct location.
45
+ server.middlewares.use(function (req, _res, next) {
46
+ if (req.url === '/index.html') {
47
+ req.url = '/public/index.html';
48
+ }
49
+
50
+ next();
51
+ }); // Handle auth routes for internal local development.
52
+
53
+ server.middlewares.use(mcDevAuthentication.createMcDevAuthenticationMiddleware(applicationConfig));
54
+ };
55
+ },
56
+
57
+ /**
58
+ * @type {import('vite').IndexHtmlTransformHook}
59
+ */
60
+ transformIndexHtml: function transformIndexHtml(rawHtml, _ctx) {
61
+ var compiledHeaders = mcHtmlTemplate.processHeaders(applicationConfig);
62
+
63
+ var enhancedLocalEnv = _Object$assign__default["default"]({}, applicationConfig.env, // Now that the app config is defined as a `env.json`, when we start the FE app
64
+ // to point to the local backend API by passing the `MC_API_URL` env does not
65
+ // work anymore). To make it work again, we can override the `env.json` config
66
+ // with the env variable before injecting the values into the index.html.
67
+ // NOTE: this is only necessary for development.
68
+ process.env.MC_API_URL ? {
69
+ mcApiUrl: process.env.MC_API_URL
70
+ } : {}); // Resolve the placeholders of the `index.html` (template) file, before serving it.
71
+
72
+
73
+ var html = mcHtmlTemplate.replaceHtmlPlaceholders(rawHtml, {
74
+ env: enhancedLocalEnv,
75
+ headers: compiledHeaders
76
+ });
77
+ return html;
78
+ }
79
+ };
80
+ };
81
+
82
+ function run() {
83
+ return _run.apply(this, arguments);
84
+ }
85
+
86
+ function _run() {
87
+ _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
88
+ var DEFAULT_PORT, applicationConfig$1, appEntryPoint, html, server;
89
+ return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
90
+ while (1) {
91
+ switch (_context.prev = _context.next) {
92
+ case 0:
93
+ DEFAULT_PORT = _parseInt__default["default"](String(process.env.HTTP_PORT), 10) || 3001; // Load the Custom Application config file first.
94
+
95
+ applicationConfig$1 = applicationConfig.processConfig(); // Ensure the `/public` folder exists.
96
+
97
+ fs__default["default"].mkdirSync(paths.paths.appBuild, {
98
+ recursive: true
99
+ }); // Generate `index.html` (template).
100
+
101
+ appEntryPoint = path__default["default"].relative(paths.paths.appRoot, paths.paths.entryPoint);
102
+ html = mcHtmlTemplate.generateTemplate({
103
+ // Define the module entry point (path relative to the `/public` folder).
104
+ // NOTE: that this is different from the production configuration.
105
+ scriptImports: ["<script type=\"module\" src=\"/../".concat(appEntryPoint, "\"></script>")]
106
+ }); // Write `index.html` (template) into the `/public` folder.
107
+
108
+ fs__default["default"].writeFileSync(paths.paths.appIndexHtml, html, {
109
+ encoding: 'utf8'
110
+ });
111
+ _context.next = 8;
112
+ return vite.createServer({
113
+ root: paths.paths.appRoot,
114
+ define: {
115
+ 'process.env.DEBUG': _JSON$stringify__default["default"](false),
116
+ 'process.env.NODE_ENV': _JSON$stringify__default["default"]('development')
117
+ },
118
+ server: {
119
+ port: DEFAULT_PORT
120
+ },
121
+ plugins: [pluginGraphql__default["default"](), pluginReact__default["default"]({
122
+ jsxImportSource: '@emotion/react',
123
+ babel: {
124
+ plugins: ['@emotion/babel-plugin']
125
+ }
126
+ }), vitePluginSvgr.vitePluginSvgr(), vitePluginCustomApplication(applicationConfig$1)]
127
+ });
128
+
129
+ case 8:
130
+ server = _context.sent;
131
+ _context.next = 11;
132
+ return server.listen();
133
+
134
+ case 11:
135
+ // Copy public assets to `/public` folder (even in development).
136
+ fs__default["default"].copySync(path__default["default"].join(assets.packageLocation, 'html-page'), paths.paths.appBuild, {
137
+ dereference: true
138
+ });
139
+ server.printUrls();
140
+
141
+ case 13:
142
+ case "end":
143
+ return _context.stop();
144
+ }
145
+ }
146
+ }, _callee);
147
+ }));
148
+ return _run.apply(this, arguments);
149
+ }
150
+
151
+ exports["default"] = run;
@@ -0,0 +1,138 @@
1
+ import _asyncToGenerator from '@babel/runtime-corejs3/helpers/esm/asyncToGenerator';
2
+ import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
3
+ import _parseInt from '@babel/runtime-corejs3/core-js-stable/parse-int';
4
+ import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
5
+ import fs from 'fs-extra';
6
+ import path from 'path';
7
+ import { createServer } from 'vite';
8
+ import pluginGraphql from '@rollup/plugin-graphql';
9
+ import pluginReact from '@vitejs/plugin-react';
10
+ import { processConfig } from '@commercetools-frontend/application-config';
11
+ import { processHeaders, replaceHtmlPlaceholders, generateTemplate } from '@commercetools-frontend/mc-html-template';
12
+ import { packageLocation } from '@commercetools-frontend/assets';
13
+ import { p as paths } from './paths-ed23d5a1.esm.js';
14
+ import _Object$assign from '@babel/runtime-corejs3/core-js-stable/object/assign';
15
+ import { createMcDevAuthenticationMiddleware } from '@commercetools-frontend/mc-dev-authentication';
16
+ import { v as vitePluginSvgr } from './vite-plugin-svgr-eb8524fa.esm.js';
17
+ import '@babel/runtime-corejs3/core-js-stable/instance/find';
18
+ import '@babel/runtime-corejs3/core-js-stable/instance/concat';
19
+ import 'fs';
20
+ import '@rollup/pluginutils';
21
+
22
+ var vitePluginCustomApplication = function vitePluginCustomApplication(applicationConfig) {
23
+ return {
24
+ name: 'custom-application',
25
+ configureServer: function configureServer(server) {
26
+ return function () {
27
+ // Users do not need to have/maintain the `index.html` (as expected by Vite)
28
+ // as it's generated and maintained by the Custom Application CLI.
29
+ // Therefore, the generated `index.html` (template) is written into the `/public`
30
+ // folder so that it's gitignored.
31
+ // As a result, we need to make sure to point the URI path to the correct location.
32
+ server.middlewares.use(function (req, _res, next) {
33
+ if (req.url === '/index.html') {
34
+ req.url = '/public/index.html';
35
+ }
36
+
37
+ next();
38
+ }); // Handle auth routes for internal local development.
39
+
40
+ server.middlewares.use(createMcDevAuthenticationMiddleware(applicationConfig));
41
+ };
42
+ },
43
+
44
+ /**
45
+ * @type {import('vite').IndexHtmlTransformHook}
46
+ */
47
+ transformIndexHtml: function transformIndexHtml(rawHtml, _ctx) {
48
+ var compiledHeaders = processHeaders(applicationConfig);
49
+
50
+ var enhancedLocalEnv = _Object$assign({}, applicationConfig.env, // Now that the app config is defined as a `env.json`, when we start the FE app
51
+ // to point to the local backend API by passing the `MC_API_URL` env does not
52
+ // work anymore). To make it work again, we can override the `env.json` config
53
+ // with the env variable before injecting the values into the index.html.
54
+ // NOTE: this is only necessary for development.
55
+ process.env.MC_API_URL ? {
56
+ mcApiUrl: process.env.MC_API_URL
57
+ } : {}); // Resolve the placeholders of the `index.html` (template) file, before serving it.
58
+
59
+
60
+ var html = replaceHtmlPlaceholders(rawHtml, {
61
+ env: enhancedLocalEnv,
62
+ headers: compiledHeaders
63
+ });
64
+ return html;
65
+ }
66
+ };
67
+ };
68
+
69
+ function run() {
70
+ return _run.apply(this, arguments);
71
+ }
72
+
73
+ function _run() {
74
+ _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
75
+ var DEFAULT_PORT, applicationConfig, appEntryPoint, html, server;
76
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
77
+ while (1) {
78
+ switch (_context.prev = _context.next) {
79
+ case 0:
80
+ DEFAULT_PORT = _parseInt(String(process.env.HTTP_PORT), 10) || 3001; // Load the Custom Application config file first.
81
+
82
+ applicationConfig = processConfig(); // Ensure the `/public` folder exists.
83
+
84
+ fs.mkdirSync(paths.appBuild, {
85
+ recursive: true
86
+ }); // Generate `index.html` (template).
87
+
88
+ appEntryPoint = path.relative(paths.appRoot, paths.entryPoint);
89
+ html = generateTemplate({
90
+ // Define the module entry point (path relative to the `/public` folder).
91
+ // NOTE: that this is different from the production configuration.
92
+ scriptImports: ["<script type=\"module\" src=\"/../".concat(appEntryPoint, "\"></script>")]
93
+ }); // Write `index.html` (template) into the `/public` folder.
94
+
95
+ fs.writeFileSync(paths.appIndexHtml, html, {
96
+ encoding: 'utf8'
97
+ });
98
+ _context.next = 8;
99
+ return createServer({
100
+ root: paths.appRoot,
101
+ define: {
102
+ 'process.env.DEBUG': _JSON$stringify(false),
103
+ 'process.env.NODE_ENV': _JSON$stringify('development')
104
+ },
105
+ server: {
106
+ port: DEFAULT_PORT
107
+ },
108
+ plugins: [pluginGraphql(), pluginReact({
109
+ jsxImportSource: '@emotion/react',
110
+ babel: {
111
+ plugins: ['@emotion/babel-plugin']
112
+ }
113
+ }), vitePluginSvgr(), vitePluginCustomApplication(applicationConfig)]
114
+ });
115
+
116
+ case 8:
117
+ server = _context.sent;
118
+ _context.next = 11;
119
+ return server.listen();
120
+
121
+ case 11:
122
+ // Copy public assets to `/public` folder (even in development).
123
+ fs.copySync(path.join(packageLocation, 'html-page'), paths.appBuild, {
124
+ dereference: true
125
+ });
126
+ server.printUrls();
127
+
128
+ case 13:
129
+ case "end":
130
+ return _context.stop();
131
+ }
132
+ }
133
+ }, _callee);
134
+ }));
135
+ return _run.apply(this, arguments);
136
+ }
137
+
138
+ export { run as default };
@@ -0,0 +1,151 @@
1
+ 'use strict';
2
+
3
+ var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
4
+ var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
5
+ var _parseInt = require('@babel/runtime-corejs3/core-js-stable/parse-int');
6
+ var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
7
+ var fs = require('fs-extra');
8
+ var path = require('path');
9
+ var vite = require('vite');
10
+ var pluginGraphql = require('@rollup/plugin-graphql');
11
+ var pluginReact = require('@vitejs/plugin-react');
12
+ var applicationConfig = require('@commercetools-frontend/application-config');
13
+ var mcHtmlTemplate = require('@commercetools-frontend/mc-html-template');
14
+ var assets = require('@commercetools-frontend/assets');
15
+ var paths = require('./paths-76b66e74.cjs.prod.js');
16
+ var _Object$assign = require('@babel/runtime-corejs3/core-js-stable/object/assign');
17
+ var mcDevAuthentication = require('@commercetools-frontend/mc-dev-authentication');
18
+ var vitePluginSvgr = require('./vite-plugin-svgr-f3bbedbe.cjs.prod.js');
19
+ require('@babel/runtime-corejs3/core-js-stable/instance/find');
20
+ require('@babel/runtime-corejs3/core-js-stable/instance/concat');
21
+ require('fs');
22
+ require('@rollup/pluginutils');
23
+
24
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
25
+
26
+ var _regeneratorRuntime__default = /*#__PURE__*/_interopDefault(_regeneratorRuntime);
27
+ var _parseInt__default = /*#__PURE__*/_interopDefault(_parseInt);
28
+ var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
29
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
30
+ var path__default = /*#__PURE__*/_interopDefault(path);
31
+ var pluginGraphql__default = /*#__PURE__*/_interopDefault(pluginGraphql);
32
+ var pluginReact__default = /*#__PURE__*/_interopDefault(pluginReact);
33
+ var _Object$assign__default = /*#__PURE__*/_interopDefault(_Object$assign);
34
+
35
+ var vitePluginCustomApplication = function vitePluginCustomApplication(applicationConfig) {
36
+ return {
37
+ name: 'custom-application',
38
+ configureServer: function configureServer(server) {
39
+ return function () {
40
+ // Users do not need to have/maintain the `index.html` (as expected by Vite)
41
+ // as it's generated and maintained by the Custom Application CLI.
42
+ // Therefore, the generated `index.html` (template) is written into the `/public`
43
+ // folder so that it's gitignored.
44
+ // As a result, we need to make sure to point the URI path to the correct location.
45
+ server.middlewares.use(function (req, _res, next) {
46
+ if (req.url === '/index.html') {
47
+ req.url = '/public/index.html';
48
+ }
49
+
50
+ next();
51
+ }); // Handle auth routes for internal local development.
52
+
53
+ server.middlewares.use(mcDevAuthentication.createMcDevAuthenticationMiddleware(applicationConfig));
54
+ };
55
+ },
56
+
57
+ /**
58
+ * @type {import('vite').IndexHtmlTransformHook}
59
+ */
60
+ transformIndexHtml: function transformIndexHtml(rawHtml, _ctx) {
61
+ var compiledHeaders = mcHtmlTemplate.processHeaders(applicationConfig);
62
+
63
+ var enhancedLocalEnv = _Object$assign__default["default"]({}, applicationConfig.env, // Now that the app config is defined as a `env.json`, when we start the FE app
64
+ // to point to the local backend API by passing the `MC_API_URL` env does not
65
+ // work anymore). To make it work again, we can override the `env.json` config
66
+ // with the env variable before injecting the values into the index.html.
67
+ // NOTE: this is only necessary for development.
68
+ process.env.MC_API_URL ? {
69
+ mcApiUrl: process.env.MC_API_URL
70
+ } : {}); // Resolve the placeholders of the `index.html` (template) file, before serving it.
71
+
72
+
73
+ var html = mcHtmlTemplate.replaceHtmlPlaceholders(rawHtml, {
74
+ env: enhancedLocalEnv,
75
+ headers: compiledHeaders
76
+ });
77
+ return html;
78
+ }
79
+ };
80
+ };
81
+
82
+ function run() {
83
+ return _run.apply(this, arguments);
84
+ }
85
+
86
+ function _run() {
87
+ _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
88
+ var DEFAULT_PORT, applicationConfig$1, appEntryPoint, html, server;
89
+ return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
90
+ while (1) {
91
+ switch (_context.prev = _context.next) {
92
+ case 0:
93
+ DEFAULT_PORT = _parseInt__default["default"](String(process.env.HTTP_PORT), 10) || 3001; // Load the Custom Application config file first.
94
+
95
+ applicationConfig$1 = applicationConfig.processConfig(); // Ensure the `/public` folder exists.
96
+
97
+ fs__default["default"].mkdirSync(paths.paths.appBuild, {
98
+ recursive: true
99
+ }); // Generate `index.html` (template).
100
+
101
+ appEntryPoint = path__default["default"].relative(paths.paths.appRoot, paths.paths.entryPoint);
102
+ html = mcHtmlTemplate.generateTemplate({
103
+ // Define the module entry point (path relative to the `/public` folder).
104
+ // NOTE: that this is different from the production configuration.
105
+ scriptImports: ["<script type=\"module\" src=\"/../".concat(appEntryPoint, "\"></script>")]
106
+ }); // Write `index.html` (template) into the `/public` folder.
107
+
108
+ fs__default["default"].writeFileSync(paths.paths.appIndexHtml, html, {
109
+ encoding: 'utf8'
110
+ });
111
+ _context.next = 8;
112
+ return vite.createServer({
113
+ root: paths.paths.appRoot,
114
+ define: {
115
+ 'process.env.DEBUG': _JSON$stringify__default["default"](false),
116
+ 'process.env.NODE_ENV': _JSON$stringify__default["default"]('development')
117
+ },
118
+ server: {
119
+ port: DEFAULT_PORT
120
+ },
121
+ plugins: [pluginGraphql__default["default"](), pluginReact__default["default"]({
122
+ jsxImportSource: '@emotion/react',
123
+ babel: {
124
+ plugins: ['@emotion/babel-plugin']
125
+ }
126
+ }), vitePluginSvgr.vitePluginSvgr(), vitePluginCustomApplication(applicationConfig$1)]
127
+ });
128
+
129
+ case 8:
130
+ server = _context.sent;
131
+ _context.next = 11;
132
+ return server.listen();
133
+
134
+ case 11:
135
+ // Copy public assets to `/public` folder (even in development).
136
+ fs__default["default"].copySync(path__default["default"].join(assets.packageLocation, 'html-page'), paths.paths.appBuild, {
137
+ dereference: true
138
+ });
139
+ server.printUrls();
140
+
141
+ case 13:
142
+ case "end":
143
+ return _context.stop();
144
+ }
145
+ }
146
+ }, _callee);
147
+ }));
148
+ return _run.apply(this, arguments);
149
+ }
150
+
151
+ exports["default"] = run;