@raisenow/tamaro-cli 1.0.25 → 1.0.26

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.
@@ -137,7 +137,7 @@ var getIfCoreFns = () => {
137
137
  // src/lib/env.ts
138
138
  import { createRequire as createRequire2 } from "module";
139
139
  import { basename as basename2 } from "path";
140
- import glob from "glob";
140
+ import { globSync } from "glob";
141
141
  import { expand as dotenvExpand } from "dotenv-expand";
142
142
  import { config as dotenvConfig } from "dotenv";
143
143
  import stripIndent3 from "strip-indent";
@@ -159,7 +159,9 @@ var runCommandSync = (cmd, options) => {
159
159
  var require3 = createRequire2(import.meta.url);
160
160
  var getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
161
161
  const filePath = files.find((file) => basename2(file) === ".env");
162
- dotenvExpand(dotenvConfig({ path: filePath }));
162
+ if (filePath) {
163
+ dotenvExpand(dotenvConfig({ path: filePath }));
164
+ }
163
165
  process.env.NODE_ENV ??= ifMin("production", "development");
164
166
  process.env.BABEL_ENV ??= ifMin("production", "development");
165
167
  process.env.EXPOSE_VAR ??= ifCore("rnw.tamaroCore", "rnw.tamaro");
@@ -168,7 +170,7 @@ var getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
168
170
  "rnw-tamaro"
169
171
  );
170
172
  process.env.WEBPACK_UNIQUE_NAME ??= ifCore("RnwTamaroCore", "RnwTamaro");
171
- process.env.BUILD_DATE = new Date().toISOString();
173
+ process.env.BUILD_DATE = (/* @__PURE__ */ new Date()).toISOString();
172
174
  process.env.PUBLIC_URL ??= "";
173
175
  process.env.HMR_ENABLED ??= ifMin("false", "true");
174
176
  if (ifCore()) {
@@ -189,6 +191,7 @@ var getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
189
191
  }
190
192
  }
191
193
  const varNames = [
194
+ // common
192
195
  "NODE_ENV",
193
196
  "BABEL_ENV",
194
197
  "EXPOSE_VAR",
@@ -196,8 +199,15 @@ var getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
196
199
  "WEBPACK_UNIQUE_NAME",
197
200
  "BUILD_DATE",
198
201
  "PUBLIC_URL",
202
+ // core
199
203
  "PRODUCT_NAME",
200
204
  "PRODUCT_VERSION",
205
+ // config
206
+ "WIDGET_UUID",
207
+ "CORE_URL",
208
+ "CORE_VERSION",
209
+ // should be explicitly specified in each config
210
+ // epik (obsolete since Tamaro v2.5.0)
201
211
  "EPP_API_KEY_DEFAULT",
202
212
  "EPP_API_URL_STAGE",
203
213
  "EPP_API_URL_PROD",
@@ -208,10 +218,7 @@ var getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
208
218
  "EPMS_PROXY_URL_STAGE",
209
219
  "EPMS_PROXY_URL_PROD",
210
220
  "EPMS_TWINT_CHECKOUT_URL_STAGE",
211
- "EPMS_TWINT_CHECKOUT_URL_PROD",
212
- "WIDGET_UUID",
213
- "CORE_URL",
214
- "CORE_VERSION"
221
+ "EPMS_TWINT_CHECKOUT_URL_PROD"
215
222
  ];
216
223
  const raw = Object.keys(process.env).filter((key) => /^PUBLIC_/.test(key) || varNames.includes(key)).reduce((env, key) => {
217
224
  env[key] = process.env[key];
@@ -228,8 +235,8 @@ var getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
228
235
  var assertEnvValid = (env) => {
229
236
  const { ifCore } = getIfCoreFns();
230
237
  const paths = getPaths(ifCore);
231
- const files = glob.sync(paths.appEnv);
232
- const envs = files.map((file) => basename2(file).replace(/^\.env\.?/, "")).filter((v) => !!v);
238
+ const files = globSync(paths.appEnv);
239
+ const envs = files.map((file) => basename2(file).replace(/^\.env\./, "")).map((file) => basename2(file).replace(/^\.env$/, "")).filter((v) => !!v);
233
240
  if (envs.length === 0) {
234
241
  if (env) {
235
242
  console.log("Flag \u201C--env\u201D is ignored.");
@@ -239,7 +246,7 @@ var assertEnvValid = (env) => {
239
246
  if (!env) {
240
247
  halt("Flag \u201C--env\u201D is required.");
241
248
  }
242
- if (!envs.includes(env)) {
249
+ if (env && !envs.includes(env)) {
243
250
  halt(
244
251
  stripIndent3(`
245
252
  Flag \u201C--env\u201D has wrong value.
@@ -247,7 +254,17 @@ var assertEnvValid = (env) => {
247
254
  `)
248
255
  );
249
256
  }
250
- const filePath = files.find((file) => basename2(file) === `.env.${env}`);
257
+ }
258
+ };
259
+ var applyEnv = (env) => {
260
+ if (!env) {
261
+ return;
262
+ }
263
+ const { ifCore } = getIfCoreFns();
264
+ const paths = getPaths(ifCore);
265
+ const files = globSync(paths.appEnv);
266
+ const filePath = files.find((file) => basename2(file) === `.env.${env}`);
267
+ if (filePath) {
251
268
  dotenvExpand(dotenvConfig({ path: filePath }));
252
269
  }
253
270
  };
@@ -278,5 +295,6 @@ export {
278
295
  halt,
279
296
  runCommandSync,
280
297
  getEnvVars,
281
- assertEnvValid
298
+ assertEnvValid,
299
+ applyEnv
282
300
  };
package/dist/cli.js CHANGED
@@ -9,6 +9,7 @@ import {
9
9
  DEFAULT_TAG,
10
10
  HTTPS_CRT_FILE,
11
11
  HTTPS_KEY_FILE,
12
+ applyEnv,
12
13
  assertEnvValid,
13
14
  getIfCoreFns,
14
15
  getPaths,
@@ -21,7 +22,7 @@ import {
21
22
  resolveBin,
22
23
  resolveOwn,
23
24
  runCommandSync
24
- } from "./chunk-XC5QT3RG.js";
25
+ } from "./chunk-ZAKDPU5F.js";
25
26
 
26
27
  // src/cli.ts
27
28
  import { createCommand } from "commander";
@@ -29,7 +30,7 @@ import { createCommand } from "commander";
29
30
  // package.json
30
31
  var package_default = {
31
32
  name: "@raisenow/tamaro-cli",
32
- version: "1.0.25",
33
+ version: "1.0.26",
33
34
  author: {
34
35
  name: "RaiseNow",
35
36
  email: "development@raisenow.com"
@@ -49,26 +50,26 @@ var package_default = {
49
50
  npm: ">=8"
50
51
  },
51
52
  dependencies: {
52
- "@babel/cli": "^7.20.7",
53
- "@babel/core": "^7.20.12",
54
- "@babel/plugin-proposal-decorators": "^7.20.13",
53
+ "@babel/cli": "^7.21.0",
54
+ "@babel/core": "^7.21.4",
55
+ "@babel/plugin-proposal-decorators": "^7.21.0",
55
56
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
56
- "@babel/plugin-transform-runtime": "^7.19.6",
57
- "@babel/preset-env": "^7.20.2",
57
+ "@babel/plugin-transform-runtime": "^7.21.4",
58
+ "@babel/preset-env": "^7.21.4",
58
59
  "@babel/preset-react": "^7.18.6",
59
- "@babel/preset-typescript": "^7.18.6",
60
- "@babel/runtime-corejs3": "^7.20.13",
60
+ "@babel/preset-typescript": "^7.21.4",
61
+ "@babel/runtime-corejs3": "^7.21.0",
61
62
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
62
- "@statoscope/webpack-plugin": "^5.24.0",
63
+ "@statoscope/webpack-plugin": "^5.26.2",
63
64
  "@types/columnify": "^1.5.1",
64
- "@types/lodash": "^4.14.191",
65
- "@types/node": "^18.11.18",
65
+ "@types/lodash": "^4.14.192",
66
+ "@types/node": "^18.15.11",
66
67
  "@types/node-notifier": "^8.0.2",
67
68
  "@types/resolve-bin": "^0.4.1",
68
69
  "@types/webpack-config-utils": "^2.3.1",
69
- "@typescript-eslint/eslint-plugin": "^5.50.0",
70
- "@typescript-eslint/parser": "^5.50.0",
71
- autoprefixer: "^10.4.13",
70
+ "@typescript-eslint/eslint-plugin": "^5.57.1",
71
+ "@typescript-eslint/parser": "^5.57.1",
72
+ autoprefixer: "^10.4.14",
72
73
  "babel-loader": "^9.1.2",
73
74
  "babel-plugin-istanbul": "^6.1.1",
74
75
  "babel-plugin-lodash": "^3.3.4",
@@ -77,48 +78,53 @@ var package_default = {
77
78
  columnify: "^1.6.0",
78
79
  commander: "^10.0.0",
79
80
  "copy-webpack-plugin": "^11.0.0",
80
- "core-js": "^3.27.2",
81
+ "core-js": "^3.30.0",
81
82
  "css-loader": "^6.7.3",
82
- "css-minimizer-webpack-plugin": "^4.2.2",
83
+ "css-minimizer-webpack-plugin": "^5.0.0",
83
84
  dotenv: "^16.0.3",
84
85
  "dotenv-expand": "^10.0.0",
85
86
  "escape-string-regexp": "^5.0.0",
86
- eslint: "^8.33.0",
87
- "eslint-config-prettier": "^8.6.0",
87
+ eslint: "^8.37.0",
88
+ "eslint-config-prettier": "^8.8.0",
88
89
  "eslint-plugin-node": "^11.1.0",
89
90
  "eslint-plugin-promise": "^6.1.1",
90
- "eslint-webpack-plugin": "^3.2.0",
91
- execa: "^6.1.0",
91
+ "eslint-webpack-plugin": "^4.0.0",
92
+ execa: "^7.1.1",
92
93
  "file-loader": "^6.2.0",
93
- "fork-ts-checker-webpack-plugin": "^7.3.0",
94
- glob: "^8.1.0",
94
+ "fork-ts-checker-webpack-plugin": "^8.0.0",
95
+ glob: "^9.3.4",
95
96
  "html-loader": "^4.2.0",
96
97
  "html-webpack-plugin": "^5.5.0",
97
98
  "json-loader": "^0.5.7",
98
99
  lodash: "^4.17.21",
99
- "mini-css-extract-plugin": "^2.7.2",
100
+ "mini-css-extract-plugin": "^2.7.5",
100
101
  "node-notifier": "^10.0.1",
101
102
  portfinder: "^1.0.32",
102
103
  postcss: "^8.4.21",
103
- "postcss-custom-properties": "^13.1.1",
104
- "postcss-loader": "^7.0.2",
105
- prettier: "^2.8.3",
104
+ "postcss-custom-properties": "^13.1.4",
105
+ "postcss-loader": "^7.2.4",
106
+ prettier: "^2.8.7",
106
107
  "react-refresh": "^0.14.0",
107
108
  "resolve-url-loader": "^5.0.0",
108
- sass: "^1.58.0",
109
- "sass-loader": "^13.2.0",
109
+ sass: "^1.60.0",
110
+ "sass-loader": "^13.2.2",
110
111
  "source-map-loader": "^4.0.1",
111
112
  "strip-indent": "^4.0.0",
112
- "style-loader": "^3.3.1",
113
- "tsconfig-paths-webpack-plugin": "^4.0.0",
114
- tsup: "^6.5.0",
115
- typescript: "^4.9.5",
113
+ "style-loader": "^3.3.2",
114
+ "tsconfig-paths-webpack-plugin": "^4.0.1",
115
+ tsup: "^6.7.0",
116
+ typescript: "^5.0.3",
116
117
  "url-loader": "^4.1.1",
117
- webpack: "^5.75.0",
118
+ webpack: "^5.78.0",
118
119
  "webpack-cli": "^5.0.1",
119
120
  "webpack-config-utils": "^2.3.1",
120
- "webpack-dev-server": "^4.11.1",
121
+ "webpack-dev-server": "^4.13.2",
121
122
  "yaml-loader": "^0.8.0"
123
+ },
124
+ overrides: {
125
+ "babel-plugin-lodash": {
126
+ "@babel/types": "~7.20.0"
127
+ }
122
128
  }
123
129
  };
124
130
 
@@ -148,7 +154,9 @@ var assertCrtExists = () => {
148
154
 
149
155
  // src/commands/dev.ts
150
156
  var dev = async (options) => {
157
+ const { env } = options;
151
158
  assertOptionsValid(options);
159
+ applyEnv(env);
152
160
  const flags = (await prepareFlags([], options)).join(" ");
153
161
  const { ifCore } = getIfCoreFns();
154
162
  const title = ifCore(
@@ -279,7 +287,9 @@ var notify = (args) => {
279
287
 
280
288
  // src/commands/build.ts
281
289
  var build = async (options) => {
290
+ const { env } = options;
282
291
  assertOptionsValid2(options);
292
+ applyEnv(env);
283
293
  const flags = prepareFlags3([], options).join(" ");
284
294
  const { ifCore } = getIfCoreFns();
285
295
  const paths = getPaths(ifCore);
@@ -10,13 +10,13 @@ import {
10
10
  logTitle,
11
11
  moduleFileExtensions,
12
12
  resolveApp
13
- } from "./chunk-XC5QT3RG.js";
13
+ } from "./chunk-ZAKDPU5F.js";
14
14
 
15
15
  // src/webpack.config.ts
16
16
  import { createRequire } from "module";
17
17
  import { basename, dirname, resolve } from "path";
18
18
  import { existsSync } from "fs";
19
- import glob from "glob";
19
+ import { globSync } from "glob";
20
20
  import { getIfUtils, removeEmpty } from "webpack-config-utils";
21
21
  import webpack from "webpack";
22
22
  import { TsconfigPathsPlugin } from "tsconfig-paths-webpack-plugin";
@@ -71,8 +71,8 @@ var getWebpackConfig = async (env) => {
71
71
  const { ifLocalCore } = getIfUtils(env, ["localCore"]);
72
72
  const { ifCore } = getIfCoreFns();
73
73
  const paths = getPaths(ifCore);
74
- const appHtmlFiles = glob.sync(paths.appHtml);
75
- const appEnvFiles = glob.sync(paths.appEnv);
74
+ const appHtmlFiles = globSync(paths.appHtml);
75
+ const appEnvFiles = globSync(paths.appEnv);
76
76
  const envVars = getEnvVars(appEnvFiles, ifMin, ifCore, ifLocalCore, ifHttps);
77
77
  const { ifHmr } = getIfUtils({ hmr: process.env.HMR_ENABLED === "true" }, ["hmr"]);
78
78
  const useTailwind = ifCore() && paths.appTailwindConfig && existsSync(paths.appTailwindConfig);
@@ -105,6 +105,7 @@ var getWebpackConfig = async (env) => {
105
105
  postcssOptions: {
106
106
  plugins: removeEmpty([
107
107
  useTailwind ? [
108
+ // eslint-disable-next-line node/no-missing-require
108
109
  require2.resolve("tailwindcss", {
109
110
  paths: [paths.appNodeModules]
110
111
  }),
@@ -165,6 +166,7 @@ var getWebpackConfig = async (env) => {
165
166
  ),
166
167
  module: {
167
168
  rules: removeEmpty([
169
+ // Source maps
168
170
  ifNotMin({
169
171
  enforce: "pre",
170
172
  exclude: /@babel\/runtime/,
@@ -173,6 +175,8 @@ var getWebpackConfig = async (env) => {
173
175
  }),
174
176
  {
175
177
  oneOf: [
178
+ // App Javascript and Typescript (Babel)
179
+ // and some dependencies distributed in a non-es5 formats
176
180
  {
177
181
  test: /\.(js|ts)x?$/,
178
182
  include: ifCore(
@@ -225,9 +229,11 @@ var getWebpackConfig = async (env) => {
225
229
  ])
226
230
  }
227
231
  },
232
+ // Other Javascript (not in app) - no transformation
228
233
  {
229
234
  test: /\.(js|mjs)$/
230
235
  },
236
+ // Styles (not modules)
231
237
  {
232
238
  test: /\.s?css$/,
233
239
  exclude: /\.module\.s?css$/,
@@ -235,12 +241,14 @@ var getWebpackConfig = async (env) => {
235
241
  modules: false
236
242
  })
237
243
  },
244
+ // Styles (modules)
238
245
  {
239
246
  test: /\.module\.s?css$/,
240
247
  use: getCssLoaders({
241
248
  modules: { localIdentName: "[local]__[hash:base64]" }
242
249
  })
243
250
  },
251
+ // Images and fonts
244
252
  {
245
253
  test: /\.(png|jpe?g|svg|webp|gif|ico|ttf|eot|woff2?)$/,
246
254
  type: "asset",
@@ -250,6 +258,7 @@ var getWebpackConfig = async (env) => {
250
258
  }
251
259
  }
252
260
  },
261
+ // YML
253
262
  {
254
263
  test: /\.ya?ml$/,
255
264
  use: [
@@ -260,6 +269,7 @@ var getWebpackConfig = async (env) => {
260
269
  }
261
270
  ]
262
271
  },
272
+ // HTML
263
273
  {
264
274
  test: /\.html$/,
265
275
  loader: require2.resolve("html-loader"),
@@ -267,6 +277,8 @@ var getWebpackConfig = async (env) => {
267
277
  minimize: false
268
278
  }
269
279
  },
280
+ // All other files - fallback
281
+ // This must be the latest rule!
270
282
  {
271
283
  exclude: [/^$/, /\.(js|jsx|ts|tsx|mjs)$/, /\.html$/, /\.json$/],
272
284
  type: "asset/resource"
@@ -301,8 +313,12 @@ var getWebpackConfig = async (env) => {
301
313
  })
302
314
  },
303
315
  optimization: {
316
+ // minimize: false,
304
317
  removeEmptyChunks: true,
318
+ // moduleIds: 'deterministic', // todo: use instead of HashedModuleIdsPlugin
319
+ // chunkIds: 'named',
305
320
  minimizer: ["...", new CssMinimizerPlugin()]
321
+ // sourceMaps: true?
306
322
  },
307
323
  plugins: removeEmpty([
308
324
  new webpack.ProgressPlugin(),
@@ -313,7 +329,9 @@ var getWebpackConfig = async (env) => {
313
329
  resolvePluginsRelativeTo: paths.app
314
330
  }),
315
331
  ifMin(
316
- new CleanWebpackPlugin({})
332
+ new CleanWebpackPlugin({
333
+ // verbose: true,
334
+ })
317
335
  ),
318
336
  ...appHtmlFiles.map(
319
337
  (file) => new HtmlWebpackPlugin2({
@@ -321,6 +339,19 @@ var getWebpackConfig = async (env) => {
321
339
  filename: basename(file),
322
340
  inject: false,
323
341
  minify: false
342
+ // ...ifMin({
343
+ // minify: {
344
+ // collapseWhitespace: true,
345
+ // removeComments: true,
346
+ // removeRedundantAttributes: true,
347
+ // removeScriptTypeAttributes: true,
348
+ // removeStyleLinkTypeAttributes: true,
349
+ // useShortDoctype: true,
350
+ // quoteCharacter: '"',
351
+ // minifyJS: true,
352
+ // minifyCSS: true,
353
+ // },
354
+ // }),
324
355
  })
325
356
  ),
326
357
  new InterpolateHtmlPlugin(envVars.raw),
@@ -356,6 +387,7 @@ var getWebpackConfig = async (env) => {
356
387
  contextRegExp: /moment$/
357
388
  }),
358
389
  ifMin(new webpack.ids.HashedModuleIdsPlugin()),
390
+ // todo: remove?
359
391
  ifMin() && ifCore() ? new CopyPlugin({
360
392
  patterns: ["*.md", "*.html"]
361
393
  }) : void 0,
@@ -363,7 +395,7 @@ var getWebpackConfig = async (env) => {
363
395
  name: ifCore("tamaro-core", "tamaro-customer-config"),
364
396
  saveReportTo: "reports/report.html",
365
397
  saveStatsTo: "reports/stats-[name]-[hash].json",
366
- additionalStats: glob.sync("reports/*.json"),
398
+ additionalStats: globSync("reports/*.json"),
367
399
  open: false
368
400
  }) : void 0
369
401
  ]),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raisenow/tamaro-cli",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "author": {
5
5
  "name": "RaiseNow",
6
6
  "email": "development@raisenow.com"
@@ -20,26 +20,26 @@
20
20
  "npm": ">=8"
21
21
  },
22
22
  "dependencies": {
23
- "@babel/cli": "^7.20.7",
24
- "@babel/core": "^7.20.12",
25
- "@babel/plugin-proposal-decorators": "^7.20.13",
23
+ "@babel/cli": "^7.21.0",
24
+ "@babel/core": "^7.21.4",
25
+ "@babel/plugin-proposal-decorators": "^7.21.0",
26
26
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
27
- "@babel/plugin-transform-runtime": "^7.19.6",
28
- "@babel/preset-env": "^7.20.2",
27
+ "@babel/plugin-transform-runtime": "^7.21.4",
28
+ "@babel/preset-env": "^7.21.4",
29
29
  "@babel/preset-react": "^7.18.6",
30
- "@babel/preset-typescript": "^7.18.6",
31
- "@babel/runtime-corejs3": "^7.20.13",
30
+ "@babel/preset-typescript": "^7.21.4",
31
+ "@babel/runtime-corejs3": "^7.21.0",
32
32
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
33
- "@statoscope/webpack-plugin": "^5.24.0",
33
+ "@statoscope/webpack-plugin": "^5.26.2",
34
34
  "@types/columnify": "^1.5.1",
35
- "@types/lodash": "^4.14.191",
36
- "@types/node": "^18.11.18",
35
+ "@types/lodash": "^4.14.192",
36
+ "@types/node": "^18.15.11",
37
37
  "@types/node-notifier": "^8.0.2",
38
38
  "@types/resolve-bin": "^0.4.1",
39
39
  "@types/webpack-config-utils": "^2.3.1",
40
- "@typescript-eslint/eslint-plugin": "^5.50.0",
41
- "@typescript-eslint/parser": "^5.50.0",
42
- "autoprefixer": "^10.4.13",
40
+ "@typescript-eslint/eslint-plugin": "^5.57.1",
41
+ "@typescript-eslint/parser": "^5.57.1",
42
+ "autoprefixer": "^10.4.14",
43
43
  "babel-loader": "^9.1.2",
44
44
  "babel-plugin-istanbul": "^6.1.1",
45
45
  "babel-plugin-lodash": "^3.3.4",
@@ -48,47 +48,52 @@
48
48
  "columnify": "^1.6.0",
49
49
  "commander": "^10.0.0",
50
50
  "copy-webpack-plugin": "^11.0.0",
51
- "core-js": "^3.27.2",
51
+ "core-js": "^3.30.0",
52
52
  "css-loader": "^6.7.3",
53
- "css-minimizer-webpack-plugin": "^4.2.2",
53
+ "css-minimizer-webpack-plugin": "^5.0.0",
54
54
  "dotenv": "^16.0.3",
55
55
  "dotenv-expand": "^10.0.0",
56
56
  "escape-string-regexp": "^5.0.0",
57
- "eslint": "^8.33.0",
58
- "eslint-config-prettier": "^8.6.0",
57
+ "eslint": "^8.37.0",
58
+ "eslint-config-prettier": "^8.8.0",
59
59
  "eslint-plugin-node": "^11.1.0",
60
60
  "eslint-plugin-promise": "^6.1.1",
61
- "eslint-webpack-plugin": "^3.2.0",
62
- "execa": "^6.1.0",
61
+ "eslint-webpack-plugin": "^4.0.0",
62
+ "execa": "^7.1.1",
63
63
  "file-loader": "^6.2.0",
64
- "fork-ts-checker-webpack-plugin": "^7.3.0",
65
- "glob": "^8.1.0",
64
+ "fork-ts-checker-webpack-plugin": "^8.0.0",
65
+ "glob": "^9.3.4",
66
66
  "html-loader": "^4.2.0",
67
67
  "html-webpack-plugin": "^5.5.0",
68
68
  "json-loader": "^0.5.7",
69
69
  "lodash": "^4.17.21",
70
- "mini-css-extract-plugin": "^2.7.2",
70
+ "mini-css-extract-plugin": "^2.7.5",
71
71
  "node-notifier": "^10.0.1",
72
72
  "portfinder": "^1.0.32",
73
73
  "postcss": "^8.4.21",
74
- "postcss-custom-properties": "^13.1.1",
75
- "postcss-loader": "^7.0.2",
76
- "prettier": "^2.8.3",
74
+ "postcss-custom-properties": "^13.1.4",
75
+ "postcss-loader": "^7.2.4",
76
+ "prettier": "^2.8.7",
77
77
  "react-refresh": "^0.14.0",
78
78
  "resolve-url-loader": "^5.0.0",
79
- "sass": "^1.58.0",
80
- "sass-loader": "^13.2.0",
79
+ "sass": "^1.60.0",
80
+ "sass-loader": "^13.2.2",
81
81
  "source-map-loader": "^4.0.1",
82
82
  "strip-indent": "^4.0.0",
83
- "style-loader": "^3.3.1",
84
- "tsconfig-paths-webpack-plugin": "^4.0.0",
85
- "tsup": "^6.5.0",
86
- "typescript": "^4.9.5",
83
+ "style-loader": "^3.3.2",
84
+ "tsconfig-paths-webpack-plugin": "^4.0.1",
85
+ "tsup": "^6.7.0",
86
+ "typescript": "^5.0.3",
87
87
  "url-loader": "^4.1.1",
88
- "webpack": "^5.75.0",
88
+ "webpack": "^5.78.0",
89
89
  "webpack-cli": "^5.0.1",
90
90
  "webpack-config-utils": "^2.3.1",
91
- "webpack-dev-server": "^4.11.1",
91
+ "webpack-dev-server": "^4.13.2",
92
92
  "yaml-loader": "^0.8.0"
93
+ },
94
+ "overrides": {
95
+ "babel-plugin-lodash": {
96
+ "@babel/types": "~7.20.0"
97
+ }
93
98
  }
94
99
  }
@@ -7,7 +7,7 @@ import {
7
7
  resolveBin,
8
8
  resolveOwn,
9
9
  } from 'lib/resolve'
10
- import {assertEnvValid} from 'lib/env'
10
+ import {applyEnv, assertEnvValid} from 'lib/env'
11
11
  import {assertCrtExists} from 'lib/https'
12
12
  import {logCommand, logTitle} from 'lib/logging'
13
13
  import {notify} from 'lib/notifier'
@@ -22,7 +22,7 @@ export type BuildOptions = {
22
22
  https: boolean
23
23
  serve: boolean
24
24
  deploy: boolean
25
- env: string
25
+ env?: string
26
26
  }
27
27
 
28
28
  ///////////////////////////////////////////////////////////////////////////////
@@ -30,7 +30,10 @@ export type BuildOptions = {
30
30
  export const build = async (
31
31
  options: BuildOptions & DeployOptions,
32
32
  ): Promise<void> => {
33
+ const {env} = options
34
+
33
35
  assertOptionsValid(options)
36
+ applyEnv(env)
34
37
 
35
38
  const flags = prepareFlags([], options).join(' ')
36
39
  const {ifCore} = getIfCoreFns()
@@ -2,7 +2,7 @@ import {getPortPromise} from 'portfinder'
2
2
  import {getIfCoreFns, resolveBin, resolveOwn} from 'lib/resolve'
3
3
  import {logCommand, logTitle} from 'lib/logging'
4
4
  import {halt, runCommandSync} from 'lib/command'
5
- import {assertEnvValid} from 'lib/env'
5
+ import {applyEnv, assertEnvValid} from 'lib/env'
6
6
  import {assertCrtExists} from 'lib/https'
7
7
 
8
8
  ///////////////////////////////////////////////////////////////////////////////
@@ -11,13 +11,16 @@ export type DevOptions = {
11
11
  localCore: boolean
12
12
  https: boolean
13
13
  port: string
14
- env: string
14
+ env?: string
15
15
  }
16
16
 
17
17
  ///////////////////////////////////////////////////////////////////////////////
18
18
 
19
19
  export const dev = async (options: DevOptions): Promise<void> => {
20
+ const {env} = options
21
+
20
22
  assertOptionsValid(options)
23
+ applyEnv(env)
21
24
 
22
25
  const flags = (await prepareFlags([], options)).join(' ')
23
26
  const {ifCore} = getIfCoreFns()
package/src/lib/env.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import {createRequire} from 'module'
2
2
  import {basename} from 'path'
3
- import glob from 'glob'
3
+ import {globSync} from 'glob'
4
4
  import type {IfUtilsFn} from 'webpack-config-utils'
5
5
  import {expand as dotenvExpand} from 'dotenv-expand'
6
6
  import {config as dotenvConfig} from 'dotenv'
@@ -29,7 +29,9 @@ export const getEnvVars = (
29
29
  ) => {
30
30
  const filePath = files.find((file) => basename(file) === '.env')
31
31
 
32
- dotenvExpand(dotenvConfig({path: filePath}))
32
+ if (filePath) {
33
+ dotenvExpand(dotenvConfig({path: filePath}))
34
+ }
33
35
 
34
36
  process.env.NODE_ENV ??= ifMin('production', 'development')
35
37
  process.env.BABEL_ENV ??= ifMin('production', 'development')
@@ -41,9 +43,6 @@ export const getEnvVars = (
41
43
  process.env.WEBPACK_UNIQUE_NAME ??= ifCore('RnwTamaroCore', 'RnwTamaro')
42
44
  process.env.BUILD_DATE = new Date().toISOString()
43
45
  process.env.PUBLIC_URL ??= ''
44
-
45
- // HMR doesn't work in ie11, it breaks everything.
46
- // If you want to run dev-server and test in ie11, set HMR_ENABLED to 'false'
47
46
  process.env.HMR_ENABLED ??= ifMin('false', 'true')
48
47
 
49
48
  if (ifCore()) {
@@ -85,7 +84,12 @@ export const getEnvVars = (
85
84
  'PRODUCT_NAME',
86
85
  'PRODUCT_VERSION',
87
86
 
88
- // epik
87
+ // config
88
+ 'WIDGET_UUID',
89
+ 'CORE_URL',
90
+ 'CORE_VERSION', // should be explicitly specified in each config
91
+
92
+ // epik (obsolete since Tamaro v2.5.0)
89
93
  'EPP_API_KEY_DEFAULT',
90
94
  'EPP_API_URL_STAGE',
91
95
  'EPP_API_URL_PROD',
@@ -97,11 +101,6 @@ export const getEnvVars = (
97
101
  'EPMS_PROXY_URL_PROD',
98
102
  'EPMS_TWINT_CHECKOUT_URL_STAGE',
99
103
  'EPMS_TWINT_CHECKOUT_URL_PROD',
100
-
101
- // config
102
- 'WIDGET_UUID',
103
- 'CORE_URL',
104
- 'CORE_VERSION', // must be explicitly specified in each config
105
104
  ]
106
105
 
107
106
  // Collect all vars which names start from "PUBLIC_" or present in "varNames" array
@@ -127,26 +126,31 @@ export const getEnvVars = (
127
126
 
128
127
  ///////////////////////////////////////////////////////////////////////////////
129
128
 
130
- export const assertEnvValid = (env: string) => {
129
+ export const assertEnvValid = (env?: string) => {
131
130
  const {ifCore} = getIfCoreFns()
132
131
  const paths = getPaths(ifCore)
133
- const files = glob.sync(paths.appEnv)
132
+ const files = globSync(paths.appEnv)
134
133
  const envs = files
135
- .map((file) => basename(file).replace(/^\.env\.?/, ''))
134
+ .map((file) => basename(file).replace(/^\.env\./, ''))
135
+ .map((file) => basename(file).replace(/^\.env$/, ''))
136
136
  .filter((v) => !!v)
137
137
 
138
138
  if (envs.length === 0) {
139
139
  if (env) {
140
+ // There are no ".env.<env>" files, so we must ignore "--env" flag
140
141
  console.log('Flag “--env” is ignored.')
141
142
  }
142
143
  }
143
144
 
144
145
  if (envs.length !== 0) {
145
146
  if (!env) {
147
+ // There are some ".env.<env>" files, but no "--env" flag is specified,
148
+ // so we must require it
146
149
  halt('Flag “--env” is required.')
147
150
  }
148
151
 
149
- if (!envs.includes(env)) {
152
+ if (env && !envs.includes(env)) {
153
+ // There are some ".env.<env>" files, but specified "--env" flag is incorrect
150
154
  halt(
151
155
  stripIndent(`
152
156
  Flag “--env” has wrong value.
@@ -154,8 +158,20 @@ export const assertEnvValid = (env: string) => {
154
158
  `),
155
159
  )
156
160
  }
161
+ }
162
+ }
163
+
164
+ export const applyEnv = (env?: string) => {
165
+ if (!env) {
166
+ return
167
+ }
168
+
169
+ const {ifCore} = getIfCoreFns()
170
+ const paths = getPaths(ifCore)
171
+ const files = globSync(paths.appEnv)
172
+ const filePath = files.find((file) => basename(file) === `.env.${env}`)
157
173
 
158
- const filePath = files.find((file) => basename(file) === `.env.${env}`)
174
+ if (filePath) {
159
175
  dotenvExpand(dotenvConfig({path: filePath}))
160
176
  }
161
177
  }
@@ -1,7 +1,7 @@
1
1
  import {createRequire} from 'module'
2
2
  import {basename, dirname, resolve} from 'path'
3
3
  import {existsSync} from 'fs'
4
- import glob from 'glob'
4
+ import {globSync} from 'glob'
5
5
  import {getIfUtils, removeEmpty} from 'webpack-config-utils'
6
6
  import webpack from 'webpack'
7
7
  import type {Configuration, RuleSetUseItem} from 'webpack'
@@ -45,8 +45,8 @@ const getWebpackConfig = async (env: any): Promise<Configuration> => {
45
45
  const {ifLocalCore} = getIfUtils(env, ['localCore'])
46
46
  const {ifCore} = getIfCoreFns()
47
47
  const paths = getPaths(ifCore)
48
- const appHtmlFiles = glob.sync(paths.appHtml)
49
- const appEnvFiles = glob.sync(paths.appEnv)
48
+ const appHtmlFiles = globSync(paths.appHtml)
49
+ const appEnvFiles = globSync(paths.appEnv)
50
50
  const envVars = getEnvVars(appEnvFiles, ifMin, ifCore, ifLocalCore, ifHttps)
51
51
  const {ifHmr} = getIfUtils({hmr: process.env.HMR_ENABLED === 'true'}, ['hmr'])
52
52
  const useTailwind =
@@ -400,7 +400,7 @@ const getWebpackConfig = async (env: any): Promise<Configuration> => {
400
400
  name: ifCore('tamaro-core', 'tamaro-customer-config'),
401
401
  saveReportTo: 'reports/report.html',
402
402
  saveStatsTo: 'reports/stats-[name]-[hash].json',
403
- additionalStats: glob.sync('reports/*.json'),
403
+ additionalStats: globSync('reports/*.json'),
404
404
  open: false,
405
405
  })
406
406
  : undefined,