@raisenow/tamaro-cli 1.0.24 → 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.
- package/dist/{chunk-WGWOPIQD.js → chunk-ZAKDPU5F.js} +31 -11
- package/dist/cli.js +45 -35
- package/dist/webpack.config.js +38 -6
- package/package.json +39 -34
- package/src/commands/build.ts +5 -2
- package/src/commands/dev.ts +5 -2
- package/src/lib/env.ts +34 -16
- package/src/webpack.config.ts +4 -4
|
@@ -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
|
|
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
|
-
|
|
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",
|
|
@@ -207,9 +217,8 @@ var getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
|
|
|
207
217
|
"EPP_PROXY_URL_PROD",
|
|
208
218
|
"EPMS_PROXY_URL_STAGE",
|
|
209
219
|
"EPMS_PROXY_URL_PROD",
|
|
210
|
-
"
|
|
211
|
-
"
|
|
212
|
-
"CORE_VERSION"
|
|
220
|
+
"EPMS_TWINT_CHECKOUT_URL_STAGE",
|
|
221
|
+
"EPMS_TWINT_CHECKOUT_URL_PROD"
|
|
213
222
|
];
|
|
214
223
|
const raw = Object.keys(process.env).filter((key) => /^PUBLIC_/.test(key) || varNames.includes(key)).reduce((env, key) => {
|
|
215
224
|
env[key] = process.env[key];
|
|
@@ -226,8 +235,8 @@ var getEnvVars = (files, ifMin, ifCore, ifLocalCore, ifHttps) => {
|
|
|
226
235
|
var assertEnvValid = (env) => {
|
|
227
236
|
const { ifCore } = getIfCoreFns();
|
|
228
237
|
const paths = getPaths(ifCore);
|
|
229
|
-
const files =
|
|
230
|
-
const envs = files.map((file) => basename2(file).replace(/^\.env
|
|
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);
|
|
231
240
|
if (envs.length === 0) {
|
|
232
241
|
if (env) {
|
|
233
242
|
console.log("Flag \u201C--env\u201D is ignored.");
|
|
@@ -237,7 +246,7 @@ var assertEnvValid = (env) => {
|
|
|
237
246
|
if (!env) {
|
|
238
247
|
halt("Flag \u201C--env\u201D is required.");
|
|
239
248
|
}
|
|
240
|
-
if (!envs.includes(env)) {
|
|
249
|
+
if (env && !envs.includes(env)) {
|
|
241
250
|
halt(
|
|
242
251
|
stripIndent3(`
|
|
243
252
|
Flag \u201C--env\u201D has wrong value.
|
|
@@ -245,7 +254,17 @@ var assertEnvValid = (env) => {
|
|
|
245
254
|
`)
|
|
246
255
|
);
|
|
247
256
|
}
|
|
248
|
-
|
|
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) {
|
|
249
268
|
dotenvExpand(dotenvConfig({ path: filePath }));
|
|
250
269
|
}
|
|
251
270
|
};
|
|
@@ -276,5 +295,6 @@ export {
|
|
|
276
295
|
halt,
|
|
277
296
|
runCommandSync,
|
|
278
297
|
getEnvVars,
|
|
279
|
-
assertEnvValid
|
|
298
|
+
assertEnvValid,
|
|
299
|
+
applyEnv
|
|
280
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-
|
|
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.
|
|
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.
|
|
53
|
-
"@babel/core": "^7.
|
|
54
|
-
"@babel/plugin-proposal-decorators": "^7.
|
|
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.
|
|
57
|
-
"@babel/preset-env": "^7.
|
|
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.
|
|
60
|
-
"@babel/runtime-corejs3": "^7.
|
|
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.
|
|
63
|
+
"@statoscope/webpack-plugin": "^5.26.2",
|
|
63
64
|
"@types/columnify": "^1.5.1",
|
|
64
|
-
"@types/lodash": "^4.14.
|
|
65
|
-
"@types/node": "^18.11
|
|
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.
|
|
70
|
-
"@typescript-eslint/parser": "^5.
|
|
71
|
-
autoprefixer: "^10.4.
|
|
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.
|
|
81
|
+
"core-js": "^3.30.0",
|
|
81
82
|
"css-loader": "^6.7.3",
|
|
82
|
-
"css-minimizer-webpack-plugin": "^
|
|
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.
|
|
87
|
-
"eslint-config-prettier": "^8.
|
|
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": "^
|
|
91
|
-
execa: "^
|
|
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": "^
|
|
94
|
-
glob: "^
|
|
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.
|
|
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.
|
|
104
|
-
"postcss-loader": "^7.
|
|
105
|
-
prettier: "^2.8.
|
|
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.
|
|
109
|
-
"sass-loader": "^13.2.
|
|
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.
|
|
113
|
-
"tsconfig-paths-webpack-plugin": "^4.0.
|
|
114
|
-
tsup: "^6.
|
|
115
|
-
typescript: "^
|
|
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.
|
|
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.
|
|
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);
|
package/dist/webpack.config.js
CHANGED
|
@@ -10,13 +10,13 @@ import {
|
|
|
10
10
|
logTitle,
|
|
11
11
|
moduleFileExtensions,
|
|
12
12
|
resolveApp
|
|
13
|
-
} from "./chunk-
|
|
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
|
|
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 =
|
|
75
|
-
const appEnvFiles =
|
|
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:
|
|
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.
|
|
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.
|
|
24
|
-
"@babel/core": "^7.
|
|
25
|
-
"@babel/plugin-proposal-decorators": "^7.
|
|
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.
|
|
28
|
-
"@babel/preset-env": "^7.
|
|
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.
|
|
31
|
-
"@babel/runtime-corejs3": "^7.
|
|
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.
|
|
33
|
+
"@statoscope/webpack-plugin": "^5.26.2",
|
|
34
34
|
"@types/columnify": "^1.5.1",
|
|
35
|
-
"@types/lodash": "^4.14.
|
|
36
|
-
"@types/node": "^18.11
|
|
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.
|
|
41
|
-
"@typescript-eslint/parser": "^5.
|
|
42
|
-
"autoprefixer": "^10.4.
|
|
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.
|
|
51
|
+
"core-js": "^3.30.0",
|
|
52
52
|
"css-loader": "^6.7.3",
|
|
53
|
-
"css-minimizer-webpack-plugin": "^
|
|
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.
|
|
58
|
-
"eslint-config-prettier": "^8.
|
|
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": "^
|
|
62
|
-
"execa": "^
|
|
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": "^
|
|
65
|
-
"glob": "^
|
|
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.
|
|
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.
|
|
75
|
-
"postcss-loader": "^7.
|
|
76
|
-
"prettier": "^2.8.
|
|
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.
|
|
80
|
-
"sass-loader": "^13.2.
|
|
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.
|
|
84
|
-
"tsconfig-paths-webpack-plugin": "^4.0.
|
|
85
|
-
"tsup": "^6.
|
|
86
|
-
"typescript": "^
|
|
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.
|
|
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.
|
|
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
|
}
|
package/src/commands/build.ts
CHANGED
|
@@ -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
|
|
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()
|
package/src/commands/dev.ts
CHANGED
|
@@ -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
|
|
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
|
|
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
|
-
|
|
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
|
-
//
|
|
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',
|
|
@@ -95,11 +99,8 @@ export const getEnvVars = (
|
|
|
95
99
|
'EPP_PROXY_URL_PROD',
|
|
96
100
|
'EPMS_PROXY_URL_STAGE',
|
|
97
101
|
'EPMS_PROXY_URL_PROD',
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
'WIDGET_UUID',
|
|
101
|
-
'CORE_URL',
|
|
102
|
-
'CORE_VERSION', // must be explicitly specified in each config
|
|
102
|
+
'EPMS_TWINT_CHECKOUT_URL_STAGE',
|
|
103
|
+
'EPMS_TWINT_CHECKOUT_URL_PROD',
|
|
103
104
|
]
|
|
104
105
|
|
|
105
106
|
// Collect all vars which names start from "PUBLIC_" or present in "varNames" array
|
|
@@ -125,26 +126,31 @@ export const getEnvVars = (
|
|
|
125
126
|
|
|
126
127
|
///////////////////////////////////////////////////////////////////////////////
|
|
127
128
|
|
|
128
|
-
export const assertEnvValid = (env
|
|
129
|
+
export const assertEnvValid = (env?: string) => {
|
|
129
130
|
const {ifCore} = getIfCoreFns()
|
|
130
131
|
const paths = getPaths(ifCore)
|
|
131
|
-
const files =
|
|
132
|
+
const files = globSync(paths.appEnv)
|
|
132
133
|
const envs = files
|
|
133
|
-
.map((file) => basename(file).replace(/^\.env
|
|
134
|
+
.map((file) => basename(file).replace(/^\.env\./, ''))
|
|
135
|
+
.map((file) => basename(file).replace(/^\.env$/, ''))
|
|
134
136
|
.filter((v) => !!v)
|
|
135
137
|
|
|
136
138
|
if (envs.length === 0) {
|
|
137
139
|
if (env) {
|
|
140
|
+
// There are no ".env.<env>" files, so we must ignore "--env" flag
|
|
138
141
|
console.log('Flag “--env” is ignored.')
|
|
139
142
|
}
|
|
140
143
|
}
|
|
141
144
|
|
|
142
145
|
if (envs.length !== 0) {
|
|
143
146
|
if (!env) {
|
|
147
|
+
// There are some ".env.<env>" files, but no "--env" flag is specified,
|
|
148
|
+
// so we must require it
|
|
144
149
|
halt('Flag “--env” is required.')
|
|
145
150
|
}
|
|
146
151
|
|
|
147
|
-
if (!envs.includes(env)) {
|
|
152
|
+
if (env && !envs.includes(env)) {
|
|
153
|
+
// There are some ".env.<env>" files, but specified "--env" flag is incorrect
|
|
148
154
|
halt(
|
|
149
155
|
stripIndent(`
|
|
150
156
|
Flag “--env” has wrong value.
|
|
@@ -152,8 +158,20 @@ export const assertEnvValid = (env: string) => {
|
|
|
152
158
|
`),
|
|
153
159
|
)
|
|
154
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}`)
|
|
155
173
|
|
|
156
|
-
|
|
174
|
+
if (filePath) {
|
|
157
175
|
dotenvExpand(dotenvConfig({path: filePath}))
|
|
158
176
|
}
|
|
159
177
|
}
|
package/src/webpack.config.ts
CHANGED
|
@@ -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
|
|
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 =
|
|
49
|
-
const appEnvFiles =
|
|
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:
|
|
403
|
+
additionalStats: globSync('reports/*.json'),
|
|
404
404
|
open: false,
|
|
405
405
|
})
|
|
406
406
|
: undefined,
|