@qse/edu-scripts 1.13.7 → 1.13.8
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/CHANGELOG.md +10 -1
- package/app.d.ts +10 -0
- package/lib/auto-refactor.js +88 -95
- package/lib/build.js +33 -36
- package/lib/cli.js +64 -61
- package/lib/commit-dist.js +40 -54
- package/lib/config/babel.dependencies.js +41 -39
- package/lib/config/babel.js +82 -55
- package/lib/config/paths.js +27 -30
- package/lib/config/plugins/postcss-safe-area.js +12 -12
- package/lib/config/webpackConfig.js +360 -325
- package/lib/config/webpackDevServerConfig.js +20 -29
- package/lib/deploy.js +58 -100
- package/lib/generator.js +49 -81
- package/lib/index.js +26 -9
- package/lib/start.js +16 -22
- package/lib/utils/FileSizeReporter.js +45 -56
- package/lib/utils/appConfig.js +12 -13
- package/lib/utils/beforeStart.js +35 -35
- package/lib/utils/changeDeployVersion.js +36 -65
- package/lib/utils/defineConfig.js +27 -5
- package/lib/utils/exec.js +5 -9
- package/lib/utils/getConfig.js +6 -7
- package/lib/utils/getOverride.js +13 -17
- package/package.json +28 -29
- package/src/config/webpackConfig.js +9 -2
- package/src/utils/defineConfig.ts +1 -1
|
@@ -1,53 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const getOverride = require('../utils/getOverride');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @typedef {Object} Opts
|
|
7
|
-
* @property {string} [modules]
|
|
8
|
-
*
|
|
9
|
-
* @param {Opts} [opts]
|
|
10
|
-
* @return {*}
|
|
11
|
-
*/
|
|
1
|
+
// src/config/babel.dependencies.js
|
|
2
|
+
var getOverride = require("../utils/getOverride");
|
|
12
3
|
module.exports = function getBabelConfig(opts = {}) {
|
|
13
|
-
const isDev = process.env.NODE_ENV ===
|
|
4
|
+
const isDev = process.env.NODE_ENV === "development";
|
|
14
5
|
let config = {
|
|
15
6
|
cacheDirectory: true,
|
|
16
7
|
cacheCompression: false,
|
|
17
8
|
babelrc: false,
|
|
18
9
|
configFile: false,
|
|
19
|
-
sourceType:
|
|
10
|
+
sourceType: "unambiguous",
|
|
20
11
|
compact: false,
|
|
21
12
|
sourceMaps: isDev,
|
|
22
13
|
inputSourceMap: isDev,
|
|
23
|
-
presets: [
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
14
|
+
presets: [
|
|
15
|
+
[
|
|
16
|
+
"@babel/preset-env",
|
|
17
|
+
{
|
|
18
|
+
modules: opts.modules,
|
|
19
|
+
useBuiltIns: "entry",
|
|
20
|
+
corejs: 3,
|
|
21
|
+
// Exclude transforms that make all code slower
|
|
22
|
+
exclude: ["transform-typeof-symbol"]
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
].filter(Boolean),
|
|
26
|
+
plugins: [
|
|
27
|
+
[
|
|
28
|
+
"@babel/plugin-transform-runtime",
|
|
29
|
+
{
|
|
30
|
+
corejs: false,
|
|
31
|
+
helpers: true,
|
|
32
|
+
// By default, babel assumes babel/runtime version 7.0.0-beta.0,
|
|
33
|
+
// explicitly resolving to match the provided helper functions.
|
|
34
|
+
// https://github.com/babel/babel/issues/10261
|
|
35
|
+
version: require("@babel/runtime/package.json").version,
|
|
36
|
+
regenerator: true
|
|
37
|
+
// // https://babeljs.io/docs/en/babel-plugin-transform-runtime#useesmodules
|
|
38
|
+
// // We should turn this on once the lowest version of Node LTS
|
|
39
|
+
// // supports ES Modules.
|
|
40
|
+
// useESModules: true,
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
[
|
|
44
|
+
"import",
|
|
45
|
+
{ libraryName: "lodash", libraryDirectory: "", camel2DashComponentName: false },
|
|
46
|
+
"lodash"
|
|
47
|
+
]
|
|
48
|
+
].filter(Boolean)
|
|
47
49
|
};
|
|
48
50
|
const override = getOverride();
|
|
49
51
|
if (override.babel) {
|
|
50
|
-
config = override.babel(config,
|
|
52
|
+
config = override.babel(config, "node_modules") || config;
|
|
51
53
|
}
|
|
52
54
|
return config;
|
|
53
|
-
};
|
|
55
|
+
};
|
package/lib/config/babel.js
CHANGED
|
@@ -1,74 +1,101 @@
|
|
|
1
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from))
|
|
10
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
11
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
}
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
2
23
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
24
|
+
// src/config/babel.js
|
|
25
|
+
var fs = require("fs");
|
|
26
|
+
var paths = require("./paths");
|
|
27
|
+
var appConfig = require("../utils/appConfig");
|
|
28
|
+
var getOverride = require("../utils/getOverride");
|
|
29
|
+
var hasJsxRuntime = (() => {
|
|
8
30
|
try {
|
|
9
|
-
require.resolve(
|
|
10
|
-
return
|
|
31
|
+
require.resolve("react/jsx-runtime");
|
|
32
|
+
return appConfig.single;
|
|
11
33
|
} catch (error) {
|
|
12
34
|
return false;
|
|
13
35
|
}
|
|
14
36
|
})();
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @typedef {Object} Opts
|
|
18
|
-
* @property {string} [modules]
|
|
19
|
-
*
|
|
20
|
-
* @param {Opts} [opts]
|
|
21
|
-
* @return {*}
|
|
22
|
-
*/
|
|
23
37
|
module.exports = function getBabelConfig(opts = {}) {
|
|
24
38
|
const isTypeScriptEnabled = fs.existsSync(paths.tsconfig);
|
|
25
|
-
const isDev = process.env.NODE_ENV ===
|
|
39
|
+
const isDev = process.env.NODE_ENV === "development";
|
|
26
40
|
let config = {
|
|
27
41
|
cacheDirectory: true,
|
|
28
42
|
cacheCompression: false,
|
|
29
43
|
compact: !isDev,
|
|
30
44
|
babelrc: false,
|
|
31
45
|
configFile: false,
|
|
32
|
-
presets: [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
46
|
+
presets: [
|
|
47
|
+
[
|
|
48
|
+
"@babel/preset-env",
|
|
49
|
+
{
|
|
50
|
+
modules: opts.modules,
|
|
51
|
+
useBuiltIns: "entry",
|
|
52
|
+
corejs: 3,
|
|
53
|
+
// Exclude transforms that make all code slower
|
|
54
|
+
exclude: ["transform-typeof-symbol"]
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
[
|
|
58
|
+
"@babel/preset-react",
|
|
59
|
+
{
|
|
60
|
+
development: isDev,
|
|
61
|
+
runtime: hasJsxRuntime ? "automatic" : "classic",
|
|
62
|
+
useBuiltIns: !hasJsxRuntime
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
isTypeScriptEnabled && "@babel/preset-typescript"
|
|
66
|
+
].filter(Boolean),
|
|
67
|
+
plugins: [
|
|
68
|
+
[
|
|
69
|
+
"@babel/plugin-transform-runtime",
|
|
70
|
+
{
|
|
71
|
+
corejs: false,
|
|
72
|
+
helpers: true,
|
|
73
|
+
// By default, babel assumes babel/runtime version 7.0.0-beta.0,
|
|
74
|
+
// explicitly resolving to match the provided helper functions.
|
|
75
|
+
// https://github.com/babel/babel/issues/10261
|
|
76
|
+
version: require("@babel/runtime/package.json").version,
|
|
77
|
+
regenerator: true
|
|
78
|
+
// // https://babeljs.io/docs/en/babel-plugin-transform-runtime#useesmodules
|
|
79
|
+
// // We should turn this on once the lowest version of Node LTS
|
|
80
|
+
// // supports ES Modules.
|
|
81
|
+
// useESModules: true,
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
["@babel/plugin-proposal-decorators", { legacy: true }],
|
|
85
|
+
["@babel/plugin-proposal-class-properties", { loose: true }],
|
|
86
|
+
["@babel/plugin-proposal-private-methods", { loose: true }],
|
|
87
|
+
["@babel/plugin-proposal-private-property-in-object", { loose: true }],
|
|
88
|
+
[
|
|
89
|
+
"import",
|
|
90
|
+
{ libraryName: "lodash", libraryDirectory: "", camel2DashComponentName: false },
|
|
91
|
+
"lodash"
|
|
92
|
+
],
|
|
93
|
+
isDev && "react-refresh/babel"
|
|
94
|
+
].filter(Boolean)
|
|
68
95
|
};
|
|
69
96
|
const override = getOverride();
|
|
70
97
|
if (override.babel) {
|
|
71
|
-
config = override.babel(config,
|
|
98
|
+
config = override.babel(config, "src") || config;
|
|
72
99
|
}
|
|
73
100
|
return config;
|
|
74
|
-
};
|
|
101
|
+
};
|
package/lib/config/paths.js
CHANGED
|
@@ -1,38 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const glob = require('globby');
|
|
1
|
+
// src/config/paths.js
|
|
2
|
+
var path = require("path");
|
|
3
|
+
var fs = require("fs");
|
|
4
|
+
var glob = require("globby");
|
|
6
5
|
function resolveApp(...filePath) {
|
|
7
6
|
return path.resolve(process.cwd(), ...filePath);
|
|
8
7
|
}
|
|
9
|
-
function getExistPath(...
|
|
10
|
-
for (const
|
|
11
|
-
if (fs.existsSync(
|
|
12
|
-
return
|
|
8
|
+
function getExistPath(...paths2) {
|
|
9
|
+
for (const path2 of paths2) {
|
|
10
|
+
if (fs.existsSync(path2)) {
|
|
11
|
+
return path2;
|
|
13
12
|
}
|
|
14
13
|
}
|
|
15
|
-
return
|
|
14
|
+
return paths2[0];
|
|
16
15
|
}
|
|
17
|
-
|
|
16
|
+
var paths = {
|
|
18
17
|
resolveApp,
|
|
19
|
-
eduAppEnv: resolveApp(
|
|
20
|
-
dist: resolveApp(
|
|
21
|
-
sshSftp: resolveApp(
|
|
22
|
-
nodeModules: resolveApp(
|
|
23
|
-
tsconfig: resolveApp(
|
|
24
|
-
jsconfig: resolveApp(
|
|
25
|
-
package: resolveApp(
|
|
26
|
-
tailwind: resolveApp(
|
|
27
|
-
indexJS: resolveApp(
|
|
28
|
-
pages: resolveApp(
|
|
29
|
-
override: resolveApp(
|
|
30
|
-
indexHTML: glob.sync(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
static: resolveApp('public', 'static'),
|
|
36
|
-
theme: getExistPath(resolveApp('theme.json'), resolveApp('theme.js'))
|
|
18
|
+
eduAppEnv: resolveApp("src", "edu-app-env.d.ts"),
|
|
19
|
+
dist: resolveApp("dist"),
|
|
20
|
+
sshSftp: resolveApp(".sftprc.json"),
|
|
21
|
+
nodeModules: resolveApp("node_modules"),
|
|
22
|
+
tsconfig: resolveApp("tsconfig.json"),
|
|
23
|
+
jsconfig: resolveApp("jsconfig.json"),
|
|
24
|
+
package: resolveApp("package.json"),
|
|
25
|
+
tailwind: resolveApp("tailwind.config.js"),
|
|
26
|
+
indexJS: resolveApp("src", "index.js"),
|
|
27
|
+
pages: resolveApp("src", "pages"),
|
|
28
|
+
override: resolveApp("edu-scripts.override.js"),
|
|
29
|
+
indexHTML: glob.sync("./public/*.html", { absolute: true }),
|
|
30
|
+
src: resolveApp("src"),
|
|
31
|
+
public: resolveApp("public"),
|
|
32
|
+
static: resolveApp("public", "static"),
|
|
33
|
+
theme: getExistPath(resolveApp("theme.json"), resolveApp("theme.js"))
|
|
37
34
|
};
|
|
38
|
-
module.exports = paths;
|
|
35
|
+
module.exports = paths;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
// src/config/plugins/postcss-safe-area.js
|
|
2
|
+
var vars = [
|
|
3
|
+
"safe-area-inset-top",
|
|
4
|
+
"safe-area-inset-bottom",
|
|
5
|
+
"safe-area-inset-left",
|
|
6
|
+
"safe-area-inset-right"
|
|
7
|
+
];
|
|
8
|
+
var expr = new RegExp(`env\\(\\s*(${vars.join("|")})\\s*,?\\s*([^)]+)?\\s*\\)`, "g");
|
|
7
9
|
module.exports = () => {
|
|
8
10
|
return {
|
|
9
|
-
postcssPlugin:
|
|
11
|
+
postcssPlugin: "postcss-safe-area",
|
|
10
12
|
Declaration(decl) {
|
|
11
|
-
const fallback = decl.value.replace(expr, (match, param, defaultValue) => defaultValue ||
|
|
13
|
+
const fallback = decl.value.replace(expr, (match, param, defaultValue) => defaultValue || "0");
|
|
12
14
|
if (fallback !== decl.value) {
|
|
13
|
-
decl.cloneBefore({
|
|
14
|
-
value: fallback
|
|
15
|
-
});
|
|
15
|
+
decl.cloneBefore({ value: fallback });
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
-
};
|
|
19
|
+
};
|