@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,361 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
6
+ var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
7
+ var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
8
+ var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
9
+ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
10
+ var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
11
+ var fs = require('fs');
12
+ var path = require('path');
13
+ var cac = require('cac');
14
+ var dotenv = require('dotenv');
15
+ var dotenvExpand = require('dotenv-expand');
16
+ var _package = require('../../dist/package-4b4fcf02.cjs.prod.js');
17
+
18
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
19
+
20
+ var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
21
+ var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
22
+ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
23
+ var _regeneratorRuntime__default = /*#__PURE__*/_interopDefault(_regeneratorRuntime);
24
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
25
+ var path__default = /*#__PURE__*/_interopDefault(path);
26
+ var dotenv__default = /*#__PURE__*/_interopDefault(dotenv);
27
+ var dotenvExpand__default = /*#__PURE__*/_interopDefault(dotenvExpand);
28
+
29
+ var cli = cac.cac('mc-scripts'); // Makes the script crash on unhandled rejections instead of silently
30
+ // ignoring them. In the future, promise rejections that are not handled will
31
+ // terminate the Node.js process with a non-zero exit code.
32
+
33
+ process.on('unhandledRejection', function (err) {
34
+ throw err;
35
+ }); // Get the current directory where the CLI is executed from. Usually this is the application folder.
36
+
37
+ var applicationDirectory = fs__default["default"].realpathSync(process.cwd());
38
+
39
+ var run = function run() {
40
+ cli.help();
41
+ cli.version(_package.pkgJson.version);
42
+ 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
43
+
44
+ cli.command('').action(function () {
45
+ cli.outputHelp();
46
+ }); // Command: start
47
+
48
+ cli.command('start', 'Starts the application in development mode using Webpack Dev Server.').alias('dev').action( /*#__PURE__*/function () {
49
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(options) {
50
+ var shouldUseExperimentalBundler, startCommand;
51
+ return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
52
+ while (1) {
53
+ switch (_context.prev = _context.next) {
54
+ case 0:
55
+ // Load dotenv files into the process environment.
56
+ // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
57
+ loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
58
+
59
+ process.env.BABEL_ENV = 'development';
60
+ process.env.NODE_ENV = 'development';
61
+ shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
62
+
63
+ if (shouldUseExperimentalBundler) {
64
+ console.log('Experimental Vite bundler enabled! 🚀');
65
+ console.log('');
66
+ }
67
+
68
+ if (!shouldUseExperimentalBundler) {
69
+ _context.next = 11;
70
+ break;
71
+ }
72
+
73
+ _context.next = 8;
74
+ return Promise.resolve().then(function () { return require('../../dist/start-vite-fe13330b.cjs.prod.js'); });
75
+
76
+ case 8:
77
+ _context.t0 = _context.sent;
78
+ _context.next = 14;
79
+ break;
80
+
81
+ case 11:
82
+ _context.next = 13;
83
+ return Promise.resolve().then(function () { return require('../../dist/start-1b7dad90.cjs.prod.js'); });
84
+
85
+ case 13:
86
+ _context.t0 = _context.sent;
87
+
88
+ case 14:
89
+ startCommand = _context.t0;
90
+ _context.next = 17;
91
+ return startCommand.default();
92
+
93
+ case 17:
94
+ case "end":
95
+ return _context.stop();
96
+ }
97
+ }
98
+ }, _callee);
99
+ }));
100
+
101
+ return function (_x) {
102
+ return _ref.apply(this, arguments);
103
+ };
104
+ }()); // Command: build
105
+
106
+ 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".', {
107
+ default: false
108
+ }).action( /*#__PURE__*/function () {
109
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(options) {
110
+ var shouldUseExperimentalBundler, buildCommand, shouldAlsoCompile, compileHtmlCommand;
111
+ return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
112
+ while (1) {
113
+ switch (_context2.prev = _context2.next) {
114
+ case 0:
115
+ // Load dotenv files into the process environment.
116
+ // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
117
+ loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
118
+
119
+ process.env.BABEL_ENV = 'production';
120
+ process.env.NODE_ENV = 'production';
121
+ shouldUseExperimentalBundler = process.env.ENABLE_EXPERIMENTAL_VITE_BUNDLER === 'true';
122
+
123
+ if (shouldUseExperimentalBundler) {
124
+ console.log('Experimental Vite bundler enabled! 🚀');
125
+ console.log('');
126
+ }
127
+
128
+ if (!shouldUseExperimentalBundler) {
129
+ _context2.next = 11;
130
+ break;
131
+ }
132
+
133
+ _context2.next = 8;
134
+ return Promise.resolve().then(function () { return require('../../dist/build-vite-b7cd993a.cjs.prod.js'); });
135
+
136
+ case 8:
137
+ _context2.t0 = _context2.sent;
138
+ _context2.next = 14;
139
+ break;
140
+
141
+ case 11:
142
+ _context2.next = 13;
143
+ return Promise.resolve().then(function () { return require('../../dist/build-5357ad26.cjs.prod.js'); });
144
+
145
+ case 13:
146
+ _context2.t0 = _context2.sent;
147
+
148
+ case 14:
149
+ buildCommand = _context2.t0;
150
+ _context2.next = 17;
151
+ return buildCommand.default();
152
+
153
+ case 17:
154
+ shouldAlsoCompile = !options.buildOnly;
155
+
156
+ if (!shouldAlsoCompile) {
157
+ _context2.next = 25;
158
+ break;
159
+ }
160
+
161
+ console.log('');
162
+ _context2.next = 22;
163
+ return Promise.resolve().then(function () { return require('../../dist/compile-html-d6331c35.cjs.prod.js'); });
164
+
165
+ case 22:
166
+ compileHtmlCommand = _context2.sent;
167
+ _context2.next = 25;
168
+ return compileHtmlCommand.default({
169
+ printSecurityHeaders: false
170
+ });
171
+
172
+ case 25:
173
+ case "end":
174
+ return _context2.stop();
175
+ }
176
+ }
177
+ }, _callee2);
178
+ }));
179
+
180
+ return function (_x2) {
181
+ return _ref2.apply(this, arguments);
182
+ };
183
+ }()); // Command: compile-html
184
+
185
+ 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.', {
186
+ default: false
187
+ }).action( /*#__PURE__*/function () {
188
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(options) {
189
+ var compileHtmlCommand;
190
+ return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context3) {
191
+ while (1) {
192
+ switch (_context3.prev = _context3.next) {
193
+ case 0:
194
+ // Load dotenv files into the process environment.
195
+ // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
196
+ loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
197
+
198
+ process.env.NODE_ENV = 'production';
199
+ _context3.next = 4;
200
+ return Promise.resolve().then(function () { return require('../../dist/compile-html-d6331c35.cjs.prod.js'); });
201
+
202
+ case 4:
203
+ compileHtmlCommand = _context3.sent;
204
+ _context3.next = 7;
205
+ return compileHtmlCommand.default(options);
206
+
207
+ case 7:
208
+ case "end":
209
+ return _context3.stop();
210
+ }
211
+ }
212
+ }, _callee3);
213
+ }));
214
+
215
+ return function (_x3) {
216
+ return _ref3.apply(this, arguments);
217
+ };
218
+ }()); // Command: serve
219
+
220
+ cli.command('serve', 'Serves previously built and compiled application from the "public" folder.').action( /*#__PURE__*/function () {
221
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(options) {
222
+ var serveCommand;
223
+ return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context4) {
224
+ while (1) {
225
+ switch (_context4.prev = _context4.next) {
226
+ case 0:
227
+ // Load dotenv files into the process environment.
228
+ // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
229
+ loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
230
+
231
+ process.env.NODE_ENV = 'production';
232
+ _context4.next = 4;
233
+ return Promise.resolve().then(function () { return require('../../dist/serve-784f4fcd.cjs.prod.js'); });
234
+
235
+ case 4:
236
+ serveCommand = _context4.sent;
237
+ _context4.next = 7;
238
+ return serveCommand.default();
239
+
240
+ case 7:
241
+ case "end":
242
+ return _context4.stop();
243
+ }
244
+ }
245
+ }, _callee4);
246
+ }));
247
+
248
+ return function (_x4) {
249
+ return _ref4.apply(this, arguments);
250
+ };
251
+ }()); // Command: login
252
+
253
+ 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 () {
254
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee5(options) {
255
+ var loginCommand;
256
+ return _regeneratorRuntime__default["default"].wrap(function _callee5$(_context5) {
257
+ while (1) {
258
+ switch (_context5.prev = _context5.next) {
259
+ case 0:
260
+ // Load dotenv files into the process environment.
261
+ // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
262
+ loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
263
+
264
+ process.env.NODE_ENV = 'production';
265
+ _context5.next = 4;
266
+ return Promise.resolve().then(function () { return require('../../dist/login-c11fb977.cjs.prod.js'); });
267
+
268
+ case 4:
269
+ loginCommand = _context5.sent;
270
+ _context5.next = 7;
271
+ return loginCommand.default();
272
+
273
+ case 7:
274
+ case "end":
275
+ return _context5.stop();
276
+ }
277
+ }
278
+ }, _callee5);
279
+ }));
280
+
281
+ return function (_x5) {
282
+ return _ref5.apply(this, arguments);
283
+ };
284
+ }()); // Command: config:sync
285
+
286
+ 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.', {
287
+ default: false
288
+ }).action( /*#__PURE__*/function () {
289
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee6(options) {
290
+ var configSyncCommand;
291
+ return _regeneratorRuntime__default["default"].wrap(function _callee6$(_context6) {
292
+ while (1) {
293
+ switch (_context6.prev = _context6.next) {
294
+ case 0:
295
+ // Load dotenv files into the process environment.
296
+ // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
297
+ loadDotEnvFiles(options); // Do this as the first thing so that any code reading it knows the right env.
298
+
299
+ process.env.NODE_ENV = 'production';
300
+ _context6.next = 4;
301
+ return Promise.resolve().then(function () { return require('../../dist/config-sync-f07734e4.cjs.prod.js'); });
302
+
303
+ case 4:
304
+ configSyncCommand = _context6.sent;
305
+ _context6.next = 7;
306
+ return configSyncCommand.default(options);
307
+
308
+ case 7:
309
+ case "end":
310
+ return _context6.stop();
311
+ }
312
+ }
313
+ }, _callee6);
314
+ }));
315
+
316
+ return function (_x6) {
317
+ return _ref6.apply(this, arguments);
318
+ };
319
+ }());
320
+ cli.parse();
321
+ }; // Load dotenv files into the process environment.
322
+ // This is essentially what `dotenv-cli` does, but it's now built into this CLI.
323
+ // Inspired also by https://create-react-app.dev/docs/adding-custom-environment-variables/#what-other-env-files-can-be-used
324
+
325
+
326
+ function loadDotEnvFiles(globalOptions) {
327
+ var _context7;
328
+
329
+ var environment = process.env.MC_APP_ENV || "production";
330
+ var dotenvFiles = []; // Custom dotenv files specified by the `--env` option takes precedence.
331
+
332
+ if (typeof globalOptions.env === 'string') {
333
+ dotenvFiles.push(globalOptions.env);
334
+ } else if (_Array$isArray__default["default"](globalOptions.env)) {
335
+ // Multiple `--env` options are allowed.
336
+ dotenvFiles.push.apply(dotenvFiles, _toConsumableArray(globalOptions.env));
337
+ } // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
338
+
339
+
340
+ dotenvFiles.push.apply(dotenvFiles, _toConsumableArray(_filterInstanceProperty__default["default"](_context7 = [".env.".concat(environment, ".local"), // Don't include `.env.local` for `test` environment
341
+ // since normally you expect tests to produce the same
342
+ // results for everyone
343
+ ".env.local", ".env.".concat(environment), '.env']).call(_context7, Boolean))); // Load environment variables from .env* files. Suppress warnings using silent
344
+ // if this file is missing. dotenv will never modify any environment variables
345
+ // that have already been set. Variable expansion is supported in .env files.
346
+ // https://github.com/motdotla/dotenv
347
+ // https://github.com/motdotla/dotenv-expand
348
+
349
+ _forEachInstanceProperty__default["default"](dotenvFiles).call(dotenvFiles, function (dotenvFile) {
350
+ var dotenvFilePath = path__default["default"].resolve(path__default["default"].join(applicationDirectory, dotenvFile));
351
+
352
+ if (fs__default["default"].existsSync(dotenvFilePath)) {
353
+ dotenvExpand__default["default"].expand(dotenv__default["default"].config({
354
+ path: dotenvFilePath
355
+ }));
356
+ }
357
+ });
358
+ }
359
+
360
+ exports.loadDotEnvFiles = loadDotEnvFiles;
361
+ exports.run = run;