@qse/edu-scripts 1.14.9 → 1.14.11
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 +12 -0
- package/lib/asset/template/edu-scripts.override.js.tpl +2 -9
- package/lib/cli.js +5 -10
- package/lib/config/plugins/ws-utils-createSocketURL.js +118 -0
- package/lib/config/webpackConfig.js +28 -2
- package/lib/config/webpackDevServerConfig.js +1 -3
- package/lib/deploy.js +22 -37
- package/lib/generator.js +0 -50
- package/lib/start.js +0 -2
- package/package.json +26 -26
- package/src/asset/template/edu-scripts.override.js.tpl +2 -9
- package/src/cli.js +6 -17
- package/src/config/plugins/ws-utils-createSocketURL.js +140 -0
- package/src/config/webpackConfig.js +5 -2
- package/src/config/webpackDevServerConfig.js +1 -3
- package/src/deploy.js +22 -38
- package/src/generator.js +0 -70
- package/src/start.js +0 -3
- package/lib/asset/template/page/index.class.js.tpl +0 -24
- package/lib/asset/template/page/index.class.tsx.tpl +0 -10
- package/lib/asset/template/page/index.fc.js.tpl +0 -16
- package/lib/asset/template/page/index.fc.tsx.tpl +0 -9
- package/lib/asset/template/page/index.less.tpl +0 -3
- package/lib/asset/template/page/logic.js.tpl +0 -4
- package/lib/asset/template/page/route.js.tpl +0 -12
- package/src/asset/template/page/index.class.js.tpl +0 -24
- package/src/asset/template/page/index.class.tsx.tpl +0 -10
- package/src/asset/template/page/index.fc.js.tpl +0 -16
- package/src/asset/template/page/index.fc.tsx.tpl +0 -9
- package/src/asset/template/page/index.less.tpl +0 -3
- package/src/asset/template/page/logic.js.tpl +0 -4
- package/src/asset/template/page/route.js.tpl +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## 1.14.11 (2025-05-12)
|
|
4
|
+
|
|
5
|
+
- feat: 优化热更新能力,适配 v1 环境
|
|
6
|
+
|
|
7
|
+
## 1.14.10 (2025-05-08)
|
|
8
|
+
|
|
9
|
+
- feat: 部署增加文曲智阅(钉钉一方化)
|
|
10
|
+
|
|
11
|
+
## 1.14.9 (2025-05-08)
|
|
12
|
+
|
|
13
|
+
- feat: 打包时自动增加 webpackChunkName
|
|
14
|
+
|
|
3
15
|
## 1.14.8 (2025-02-12)
|
|
4
16
|
|
|
5
17
|
- fix: 缓存依赖增加 theme.json 文件
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
const { defineConfig } = require('@qse/edu-scripts')
|
|
2
2
|
|
|
3
|
-
// if (process.env.NODE_ENV === 'development') {
|
|
4
|
-
// process.env.BROWSERSLIST = 'ie 11'
|
|
5
|
-
// }
|
|
6
|
-
|
|
7
3
|
module.exports = defineConfig({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
devServer: (config) => {
|
|
12
|
-
return config
|
|
4
|
+
startup: ({ logger, chalk }) => {
|
|
5
|
+
logger.info('本地免登录开发地址:', chalk.cyan(`http://127.0.0.1:${process.env.PORT}/index.html`))
|
|
13
6
|
},
|
|
14
7
|
})
|
package/lib/cli.js
CHANGED
|
@@ -37,22 +37,17 @@ require("yargs").usage(`教育工程化 webpack5 基础框架
|
|
|
37
37
|
desc: "上传到文曲智阅",
|
|
38
38
|
default: false,
|
|
39
39
|
boolean: true
|
|
40
|
+
}).option("compositionshelves-dingtalk", {
|
|
41
|
+
alias: "cd",
|
|
42
|
+
desc: "上传到文曲智阅(钉钉一方化)",
|
|
43
|
+
default: false,
|
|
44
|
+
boolean: true
|
|
40
45
|
}),
|
|
41
46
|
(args) => require("./deploy")(args)
|
|
42
47
|
).command(
|
|
43
48
|
["generator", "g"],
|
|
44
49
|
"自动生成代码",
|
|
45
50
|
(yargs) => yargs.command(
|
|
46
|
-
"page",
|
|
47
|
-
"生成 page 模版, 默认根据环境生成 js/ts 与 less 文件",
|
|
48
|
-
(yargs2) => yargs2.option("name", { desc: "模块名称", string: true }).demandOption("name", "必须输入模块名称").option("ts", { alias: "t", desc: "生成 ts 文件", boolean: true, default: true }).option("route", {
|
|
49
|
-
alias: "r",
|
|
50
|
-
desc: "生成 index.js 路由文件",
|
|
51
|
-
boolean: true,
|
|
52
|
-
default: true
|
|
53
|
-
}).option("fc", { alias: "f", desc: "生成 Function Component 文件", boolean: true }),
|
|
54
|
-
(args) => require("./generator").page(args)
|
|
55
|
-
).command(
|
|
56
51
|
"override",
|
|
57
52
|
"创建 override 文件",
|
|
58
53
|
{},
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/config/plugins/ws-utils-createSocketURL.js
|
|
20
|
+
var ws_utils_createSocketURL_exports = {};
|
|
21
|
+
__export(ws_utils_createSocketURL_exports, {
|
|
22
|
+
default: () => ws_utils_createSocketURL_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(ws_utils_createSocketURL_exports);
|
|
25
|
+
function format(objURL) {
|
|
26
|
+
var protocol = objURL.protocol || "";
|
|
27
|
+
if (protocol && protocol.substr(-1) !== ":") {
|
|
28
|
+
protocol += ":";
|
|
29
|
+
}
|
|
30
|
+
var auth = objURL.auth || "";
|
|
31
|
+
if (auth) {
|
|
32
|
+
auth = encodeURIComponent(auth);
|
|
33
|
+
auth = auth.replace(/%3A/i, ":");
|
|
34
|
+
auth += "@";
|
|
35
|
+
}
|
|
36
|
+
var host = "";
|
|
37
|
+
if (objURL.hostname) {
|
|
38
|
+
host = auth + (objURL.hostname.indexOf(":") === -1 ? objURL.hostname : "[".concat(objURL.hostname, "]"));
|
|
39
|
+
if (objURL.port) {
|
|
40
|
+
host += ":".concat(objURL.port);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
var pathname = objURL.pathname || "";
|
|
44
|
+
if (objURL.slashes) {
|
|
45
|
+
host = "//".concat(host || "");
|
|
46
|
+
if (pathname && pathname.charAt(0) !== "/") {
|
|
47
|
+
pathname = "/".concat(pathname);
|
|
48
|
+
}
|
|
49
|
+
} else if (!host) {
|
|
50
|
+
host = "";
|
|
51
|
+
}
|
|
52
|
+
var search = objURL.search || "";
|
|
53
|
+
if (search && search.charAt(0) !== "?") {
|
|
54
|
+
search = "?".concat(search);
|
|
55
|
+
}
|
|
56
|
+
var hash = objURL.hash || "";
|
|
57
|
+
if (hash && hash.charAt(0) !== "#") {
|
|
58
|
+
hash = "#".concat(hash);
|
|
59
|
+
}
|
|
60
|
+
pathname = pathname.replace(
|
|
61
|
+
/[?#]/g,
|
|
62
|
+
/**
|
|
63
|
+
* @param {string} match
|
|
64
|
+
* @returns {string}
|
|
65
|
+
*/
|
|
66
|
+
function(match) {
|
|
67
|
+
return encodeURIComponent(match);
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
search = search.replace("#", "%23");
|
|
71
|
+
return "".concat(protocol).concat(host).concat(pathname).concat(search).concat(hash);
|
|
72
|
+
}
|
|
73
|
+
function createSocketURL(parsedURL) {
|
|
74
|
+
var hostname = parsedURL.hostname;
|
|
75
|
+
var isInAddrAny = hostname === "0.0.0.0" || hostname === "::" || hostname === "[::]";
|
|
76
|
+
if (isInAddrAny && self.location.hostname && self.location.protocol.indexOf("http") === 0) {
|
|
77
|
+
hostname = self.location.hostname;
|
|
78
|
+
}
|
|
79
|
+
var socketURLProtocol = parsedURL.protocol || self.location.protocol;
|
|
80
|
+
if (socketURLProtocol === "auto:" || hostname && isInAddrAny && self.location.protocol === "https:") {
|
|
81
|
+
socketURLProtocol = self.location.protocol;
|
|
82
|
+
}
|
|
83
|
+
socketURLProtocol = socketURLProtocol.replace(/^(?:http|.+-extension|file)/i, "ws");
|
|
84
|
+
var socketURLAuth = "";
|
|
85
|
+
if (parsedURL.username) {
|
|
86
|
+
socketURLAuth = parsedURL.username;
|
|
87
|
+
if (parsedURL.password) {
|
|
88
|
+
socketURLAuth = socketURLAuth.concat(":", parsedURL.password);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
var socketURLHostname = (hostname || self.location.hostname || "localhost").replace(
|
|
92
|
+
/^\[(.*)\]$/,
|
|
93
|
+
"$1"
|
|
94
|
+
);
|
|
95
|
+
var socketURLPort = parsedURL.port;
|
|
96
|
+
if (!socketURLPort || socketURLPort === "0") {
|
|
97
|
+
socketURLPort = self.location.port;
|
|
98
|
+
}
|
|
99
|
+
var socketURLPathname = "/ws";
|
|
100
|
+
if (parsedURL.pathname && !parsedURL.fromCurrentScript) {
|
|
101
|
+
socketURLPathname = parsedURL.pathname;
|
|
102
|
+
if (hostname.indexOf("zhidianbao.cn") > -1 || hostname.indexOf("qsban.cn") > -1) {
|
|
103
|
+
var ctx = self.location.pathname.split("/")[1];
|
|
104
|
+
if (ctx) {
|
|
105
|
+
socketURLPathname = "/" + ctx + socketURLPathname;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return format({
|
|
110
|
+
protocol: socketURLProtocol,
|
|
111
|
+
auth: socketURLAuth,
|
|
112
|
+
hostname: socketURLHostname,
|
|
113
|
+
port: socketURLPort,
|
|
114
|
+
pathname: socketURLPathname,
|
|
115
|
+
slashes: true
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
var ws_utils_createSocketURL_default = createSocketURL;
|
|
@@ -1,3 +1,26 @@
|
|
|
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
|
+
));
|
|
23
|
+
|
|
1
24
|
// src/config/webpackConfig.js
|
|
2
25
|
var fs = require("fs");
|
|
3
26
|
var webpack = require("webpack");
|
|
@@ -318,6 +341,11 @@ module.exports = function getWebpackConfig(args, override) {
|
|
|
318
341
|
qseCDN.isUseCommon && new webpack.DllReferencePlugin({
|
|
319
342
|
manifest: require("../asset/dll/libcommon3-manifest.json")
|
|
320
343
|
}),
|
|
344
|
+
new webpack.NormalModuleReplacementPlugin(/createSocketURL\.js$/, (resource) => {
|
|
345
|
+
if (resource.context.includes("webpack-dev-server")) {
|
|
346
|
+
resource.request = require.resolve("./plugins/ws-utils-createSocketURL");
|
|
347
|
+
}
|
|
348
|
+
}),
|
|
321
349
|
new webpack.IgnorePlugin({
|
|
322
350
|
resourceRegExp: /^\.\/locale$/,
|
|
323
351
|
contextRegExp: /moment$/
|
|
@@ -327,8 +355,6 @@ module.exports = function getWebpackConfig(args, override) {
|
|
|
327
355
|
"process.env.APP_VERSION": JSON.stringify(appPkg.version),
|
|
328
356
|
"process.env.BABEL_ENV": JSON.stringify(process.env.BABEL_ENV),
|
|
329
357
|
"process.env.BROWSERSLIST": JSON.stringify(process.env.BROWSERSLIST),
|
|
330
|
-
"process.env.WDS_SOCKET_HOST": JSON.stringify(process.env.WDS_SOCKET_HOST),
|
|
331
|
-
"process.env.WDS_SOCKET_PORT": JSON.stringify(process.env.WDS_SOCKET_PORT),
|
|
332
358
|
...override.define
|
|
333
359
|
}),
|
|
334
360
|
new webpack.ProgressPlugin(),
|
|
@@ -3,8 +3,6 @@ var WebpackDevServer = require("webpack-dev-server");
|
|
|
3
3
|
var setupMockServer = require("./plugins/mock-server");
|
|
4
4
|
module.exports = function getWebpackDevServerConfig(args, override) {
|
|
5
5
|
const host = process.env.HOST || "0.0.0.0";
|
|
6
|
-
const sockHost = process.env.WDS_SOCKET_HOST;
|
|
7
|
-
const sockPort = process.env.WDS_SOCKET_PORT;
|
|
8
6
|
const devServer = {
|
|
9
7
|
hot: true,
|
|
10
8
|
allowedHosts: "all",
|
|
@@ -13,7 +11,7 @@ module.exports = function getWebpackDevServerConfig(args, override) {
|
|
|
13
11
|
open: args.open,
|
|
14
12
|
host,
|
|
15
13
|
client: {
|
|
16
|
-
webSocketURL:
|
|
14
|
+
webSocketURL: "auto://0.0.0.0:0/ws",
|
|
17
15
|
overlay: {
|
|
18
16
|
runtimeErrors: false,
|
|
19
17
|
errors: true,
|
package/lib/deploy.js
CHANGED
|
@@ -17,24 +17,6 @@ var baseConfig = {
|
|
|
17
17
|
noWarn: true
|
|
18
18
|
};
|
|
19
19
|
async function normalDeploy(args) {
|
|
20
|
-
const presetConfig = {
|
|
21
|
-
s: {
|
|
22
|
-
context: "eduwebngv1",
|
|
23
|
-
folder: "userportal"
|
|
24
|
-
},
|
|
25
|
-
b: {
|
|
26
|
-
context: "eduwebngv1",
|
|
27
|
-
folder: "bureaupc"
|
|
28
|
-
},
|
|
29
|
-
d: {
|
|
30
|
-
context: "eduwebngv1",
|
|
31
|
-
folder: "documentshelves"
|
|
32
|
-
},
|
|
33
|
-
c: {
|
|
34
|
-
context: "eduwebngv1",
|
|
35
|
-
folder: "compositionshelves"
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
20
|
const resolve = (...pathSegments) => path.resolve(process.cwd(), ...pathSegments);
|
|
39
21
|
function getLocalAndRemoteFilePath(remoteFilePath, opts) {
|
|
40
22
|
const splited = remoteFilePath.split("/");
|
|
@@ -98,34 +80,37 @@ async function normalDeploy(args) {
|
|
|
98
80
|
fs.removeSync(tmpBase);
|
|
99
81
|
}
|
|
100
82
|
}
|
|
101
|
-
const
|
|
83
|
+
const presetConfig = {
|
|
84
|
+
s: { preset: { context: "eduwebngv1", folder: "userportal" } },
|
|
85
|
+
b: { preset: { context: "eduwebngv1", folder: "bureaupc" } },
|
|
86
|
+
d: { preset: { context: "eduwebngv1", folder: "documentshelves" } },
|
|
87
|
+
c: { preset: { context: "eduwebngv1", folder: "compositionshelves" } },
|
|
88
|
+
cd: {
|
|
89
|
+
preset: { server: "19" },
|
|
90
|
+
remotePath: "/erp/edumaven/dingcorrection-page-dev/compositionshelves"
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const uploadSftpConfigs = [];
|
|
102
94
|
if (args.b) {
|
|
103
|
-
|
|
95
|
+
uploadSftpConfigs.push(presetConfig.b);
|
|
104
96
|
}
|
|
105
97
|
if (args.s) {
|
|
106
|
-
|
|
98
|
+
uploadSftpConfigs.push(presetConfig.s);
|
|
107
99
|
}
|
|
108
100
|
if (args.d) {
|
|
109
|
-
|
|
101
|
+
uploadSftpConfigs.push(presetConfig.d);
|
|
110
102
|
}
|
|
111
103
|
if (args.c) {
|
|
112
|
-
|
|
104
|
+
uploadSftpConfigs.push(presetConfig.c);
|
|
105
|
+
}
|
|
106
|
+
if (args.cd) {
|
|
107
|
+
uploadSftpConfigs.push(presetConfig.cd);
|
|
113
108
|
}
|
|
114
|
-
if (
|
|
109
|
+
if (uploadSftpConfigs.length === 0) {
|
|
115
110
|
console.log(
|
|
116
111
|
`
|
|
117
112
|
${chalk.red("指定 deploy 部署范围")}
|
|
118
|
-
|
|
119
|
-
# 部署代码 校端
|
|
120
|
-
${chalk.green("edu-scripts deploy -s")}
|
|
121
|
-
# 部署代码 局端
|
|
122
|
-
${chalk.green("edu-scripts deploy -b")}
|
|
123
|
-
# 部署代码 公文
|
|
124
|
-
${chalk.green("edu-scripts deploy -d")}
|
|
125
|
-
# 部署代码 文曲智阅
|
|
126
|
-
${chalk.green("edu-scripts deploy -c")}
|
|
127
|
-
# 部署代码 校端 + 局端
|
|
128
|
-
${chalk.green("edu-scripts deploy -s -b")}
|
|
113
|
+
执行 ${chalk.green("npx edu-scripts deploy -h")} 查看具体用法
|
|
129
114
|
`
|
|
130
115
|
);
|
|
131
116
|
process.exit();
|
|
@@ -134,8 +119,8 @@ async function normalDeploy(args) {
|
|
|
134
119
|
if (!appConfig.mainProject) {
|
|
135
120
|
uploadConfig.ignore = [...uploadConfig.ignore, "!(js|images)"];
|
|
136
121
|
}
|
|
137
|
-
for (const
|
|
138
|
-
await upload({ ...uploadConfig,
|
|
122
|
+
for (const config of uploadSftpConfigs) {
|
|
123
|
+
await upload({ ...uploadConfig, ...config });
|
|
139
124
|
}
|
|
140
125
|
}
|
|
141
126
|
async function singleDeploy() {
|
package/lib/generator.js
CHANGED
|
@@ -1,58 +1,9 @@
|
|
|
1
1
|
// src/generator.js
|
|
2
2
|
var path = require("path");
|
|
3
3
|
var fs = require("fs-extra");
|
|
4
|
-
var { upperFirst, camelCase, has } = require("lodash");
|
|
5
4
|
var paths = require("./config/paths");
|
|
6
5
|
var chalk = require("chalk");
|
|
7
6
|
var getTmpPath = (...args) => path.resolve(__dirname, "asset", "template", ...args);
|
|
8
|
-
function genFile({ source, target, modulePath, replace }) {
|
|
9
|
-
let content = fs.readFileSync(source, "utf-8");
|
|
10
|
-
if (typeof replace === "object") {
|
|
11
|
-
Object.entries(replace).forEach(([searchValue, replaceValue]) => {
|
|
12
|
-
content = content.replaceAll(searchValue, replaceValue);
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
fs.writeFileSync(path.resolve(modulePath, target), content);
|
|
16
|
-
}
|
|
17
|
-
async function generatorPage(args) {
|
|
18
|
-
const tmpPath = getTmpPath("page", "index.[type].[ext].tpl");
|
|
19
|
-
const lessPath = tmpPath.replace("[type].[ext]", "less");
|
|
20
|
-
const moduleName = camelCase(args.name);
|
|
21
|
-
const ModuleName = upperFirst(moduleName);
|
|
22
|
-
const type = args.fc ? "fc" : "class";
|
|
23
|
-
const ext = fs.existsSync(paths.tsconfig) ? args.ts ? "tsx" : "js" : "js";
|
|
24
|
-
const jsPath = tmpPath.replace("[type]", type).replace("[ext]", ext);
|
|
25
|
-
const routePath = tmpPath.replace("index.[type].[ext]", "route.js");
|
|
26
|
-
const logicPath = tmpPath.replace("index.[type].[ext]", "logic.js");
|
|
27
|
-
const modulePath = path.resolve(paths.pages, moduleName);
|
|
28
|
-
const ModuleFileName = args.route ? ModuleName : "index";
|
|
29
|
-
const ModuleLogicName = args.route ? ModuleName + "Logic" : "logic";
|
|
30
|
-
const replace = { ModuleName, moduleName, ModuleFileName, ModuleLogicName };
|
|
31
|
-
fs.ensureDirSync(modulePath);
|
|
32
|
-
genFile({ source: jsPath, target: `${ModuleFileName}.${ext}`, modulePath, replace });
|
|
33
|
-
genFile({ source: lessPath, target: `${ModuleFileName}.less`, modulePath, replace });
|
|
34
|
-
if (type === "class" && ext === "js") {
|
|
35
|
-
genFile({
|
|
36
|
-
source: logicPath,
|
|
37
|
-
target: `${ModuleLogicName}.${ext.slice(0, 2)}`,
|
|
38
|
-
modulePath,
|
|
39
|
-
replace
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
if (args.route) {
|
|
43
|
-
genFile({ source: routePath, target: `index.${ext.slice(0, 2)}`, modulePath, replace });
|
|
44
|
-
}
|
|
45
|
-
console.log(
|
|
46
|
-
chalk.green(
|
|
47
|
-
[
|
|
48
|
-
`生成完毕:`,
|
|
49
|
-
`import ${ModuleName} from '@/pages/${moduleName}'`,
|
|
50
|
-
`const ${ModuleName} = lazy(() => import(/* webpackChunkName: '${moduleName}' */ '@/pages/${moduleName}'))`,
|
|
51
|
-
`{ path: '/${moduleName}', element: <${ModuleName} /> },`
|
|
52
|
-
].join("\n")
|
|
53
|
-
)
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
7
|
async function generatorOverride() {
|
|
57
8
|
if (fs.existsSync(paths.override)) {
|
|
58
9
|
console.log(chalk.red(`文件已存在 ${paths.override}`));
|
|
@@ -93,7 +44,6 @@ async function generatorTailwind() {
|
|
|
93
44
|
);
|
|
94
45
|
}
|
|
95
46
|
module.exports = {
|
|
96
|
-
page: generatorPage,
|
|
97
47
|
override: generatorOverride,
|
|
98
48
|
ts: generatorTsconfig,
|
|
99
49
|
tailwind: generatorTailwind
|
package/lib/start.js
CHANGED
|
@@ -10,14 +10,12 @@ var WebpackDevServer = require("webpack-dev-server");
|
|
|
10
10
|
var webpack = require("webpack");
|
|
11
11
|
var getConfig = require("./utils/getConfig");
|
|
12
12
|
var chalk = require("chalk");
|
|
13
|
-
process.env.WDS_SOCKET_HOST = WebpackDevServer.internalIPSync("v4") || "127.0.0.1";
|
|
14
13
|
module.exports = async function start(args) {
|
|
15
14
|
const basePort = process.env.WEBPACK_DEV_SERVER_BASE_PORT;
|
|
16
15
|
const port = await WebpackDevServer.getFreePort(args.port || process.env.PORT);
|
|
17
16
|
if (!(args.port || process.env.PORT) && +port !== +basePort) {
|
|
18
17
|
console.log(chalk.bgYellow(`${basePort} 端口已被占用,现切换到 ${port} 端口运行`));
|
|
19
18
|
}
|
|
20
|
-
process.env.WDS_SOCKET_PORT = port;
|
|
21
19
|
args.port = port;
|
|
22
20
|
process.env.PORT = port;
|
|
23
21
|
const compiler = webpack(getConfig(args));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qse/edu-scripts",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.11",
|
|
4
4
|
"author": "Kinoko",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "教育工程化基础框架",
|
|
@@ -34,63 +34,63 @@
|
|
|
34
34
|
"extends": "qsb-react"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@babel/core": "~7.
|
|
38
|
-
"@babel/plugin-proposal-decorators": "~7.
|
|
39
|
-
"@babel/plugin-transform-runtime": "~7.
|
|
40
|
-
"@babel/preset-env": "~7.
|
|
41
|
-
"@babel/preset-react": "~7.
|
|
42
|
-
"@babel/preset-typescript": "~7.
|
|
43
|
-
"@babel/register": "~7.
|
|
44
|
-
"@babel/runtime": "~7.
|
|
45
|
-
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.
|
|
37
|
+
"@babel/core": "~7.26.10",
|
|
38
|
+
"@babel/plugin-proposal-decorators": "~7.25.9",
|
|
39
|
+
"@babel/plugin-transform-runtime": "~7.26.10",
|
|
40
|
+
"@babel/preset-env": "~7.26.9",
|
|
41
|
+
"@babel/preset-react": "~7.26.3",
|
|
42
|
+
"@babel/preset-typescript": "~7.27.0",
|
|
43
|
+
"@babel/register": "~7.25.9",
|
|
44
|
+
"@babel/runtime": "~7.27.0",
|
|
45
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.16",
|
|
46
46
|
"@qse/ssh-sftp": "^1.0.1",
|
|
47
47
|
"@svgr/webpack": "^8.1.0",
|
|
48
|
-
"babel-loader": "^9.1
|
|
48
|
+
"babel-loader": "^9.2.1",
|
|
49
49
|
"babel-plugin-import": "^1.13.8",
|
|
50
50
|
"case-sensitive-paths-webpack-plugin": "^2.4.0",
|
|
51
51
|
"chalk": "^4.1.2",
|
|
52
52
|
"chokidar": "^3.6.0",
|
|
53
|
-
"cookie-parser": "^1.4.
|
|
53
|
+
"cookie-parser": "^1.4.7",
|
|
54
54
|
"css-loader": "^6.11.0",
|
|
55
55
|
"cssnano": "^6.1.2",
|
|
56
|
-
"debug": "^4.
|
|
56
|
+
"debug": "^4.4.0",
|
|
57
57
|
"esbuild-loader": "^2.21.0",
|
|
58
|
-
"express": "^4.
|
|
58
|
+
"express": "^4.21.2",
|
|
59
59
|
"filesize": "^8.0.7",
|
|
60
60
|
"fs-extra": "^10.1.0",
|
|
61
61
|
"globby": "^11.1.0",
|
|
62
62
|
"gzip-size": "^6.0.0",
|
|
63
|
-
"html-webpack-plugin": "^5.6.
|
|
63
|
+
"html-webpack-plugin": "^5.6.3",
|
|
64
64
|
"image-minimizer-webpack-plugin": "^3.8.3",
|
|
65
65
|
"inquirer": "^8.2.6",
|
|
66
66
|
"less": "^3.13.1",
|
|
67
67
|
"less-loader": "^10.2.0",
|
|
68
68
|
"lodash": "^4.17.21",
|
|
69
|
-
"multer": "^1.4.5-lts.
|
|
69
|
+
"multer": "^1.4.5-lts.2",
|
|
70
70
|
"open": "^8.4.2",
|
|
71
|
-
"path-to-regexp": "^6.
|
|
72
|
-
"postcss": "^8.
|
|
71
|
+
"path-to-regexp": "^6.3.0",
|
|
72
|
+
"postcss": "^8.5.3",
|
|
73
73
|
"postcss-flexbugs-fixes": "^5.0.2",
|
|
74
74
|
"postcss-loader": "^7.3.4",
|
|
75
75
|
"postcss-momentum-scrolling": "^3.14.22",
|
|
76
76
|
"postcss-normalize": "^8.0.1",
|
|
77
|
-
"postcss-preset-env": "^9.
|
|
77
|
+
"postcss-preset-env": "^9.6.0",
|
|
78
78
|
"prettier": "^2.8.8",
|
|
79
79
|
"prettier-plugin-tailwindcss": "^0.4.1",
|
|
80
80
|
"react-refresh": "^0.14.2",
|
|
81
81
|
"recursive-readdir": "^2.2.3",
|
|
82
82
|
"rimraf": "^3.0.2",
|
|
83
|
-
"semver": "^7.
|
|
83
|
+
"semver": "^7.7.1",
|
|
84
84
|
"sharp": "^0.32.6",
|
|
85
85
|
"strip-ansi": "^6.0.1",
|
|
86
86
|
"style-loader": "^3.3.4",
|
|
87
|
-
"tailwindcss": "^3.4.
|
|
88
|
-
"terser-webpack-plugin": "~5.3.
|
|
87
|
+
"tailwindcss": "^3.4.17",
|
|
88
|
+
"terser-webpack-plugin": "~5.3.14",
|
|
89
89
|
"tmp": "^0.2.3",
|
|
90
|
-
"typescript": "^5.
|
|
90
|
+
"typescript": "^5.8.3",
|
|
91
91
|
"update-notifier": "^5.1.0",
|
|
92
92
|
"url-loader": "^4.1.1",
|
|
93
|
-
"webpack": "^5.
|
|
93
|
+
"webpack": "^5.99.6",
|
|
94
94
|
"webpack-bundle-analyzer": "^4.10.2",
|
|
95
95
|
"webpack-dev-server": "^4.15.2",
|
|
96
96
|
"yargs": "^17.7.2"
|
|
@@ -98,10 +98,10 @@
|
|
|
98
98
|
"devDependencies": {
|
|
99
99
|
"@types/fs-extra": "^9.0.13",
|
|
100
100
|
"@types/jest": "^28.1.8",
|
|
101
|
-
"@types/yargs": "^17.0.
|
|
101
|
+
"@types/yargs": "^17.0.33",
|
|
102
102
|
"dumi": "^1.1.54",
|
|
103
103
|
"eslint-config-qsb-react": "^1.1.1",
|
|
104
|
-
"father": "^4.
|
|
104
|
+
"father": "^4.5.2",
|
|
105
105
|
"jest": "^28.1.3"
|
|
106
106
|
}
|
|
107
107
|
}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
const { defineConfig } = require('@qse/edu-scripts')
|
|
2
2
|
|
|
3
|
-
// if (process.env.NODE_ENV === 'development') {
|
|
4
|
-
// process.env.BROWSERSLIST = 'ie 11'
|
|
5
|
-
// }
|
|
6
|
-
|
|
7
3
|
module.exports = defineConfig({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
devServer: (config) => {
|
|
12
|
-
return config
|
|
4
|
+
startup: ({ logger, chalk }) => {
|
|
5
|
+
logger.info('本地免登录开发地址:', chalk.cyan(`http://127.0.0.1:${process.env.PORT}/index.html`))
|
|
13
6
|
},
|
|
14
7
|
})
|
package/src/cli.js
CHANGED
|
@@ -53,28 +53,17 @@ require('yargs')
|
|
|
53
53
|
desc: '上传到文曲智阅',
|
|
54
54
|
default: false,
|
|
55
55
|
boolean: true,
|
|
56
|
+
})
|
|
57
|
+
.option('compositionshelves-dingtalk', {
|
|
58
|
+
alias: 'cd',
|
|
59
|
+
desc: '上传到文曲智阅(钉钉一方化)',
|
|
60
|
+
default: false,
|
|
61
|
+
boolean: true,
|
|
56
62
|
}),
|
|
57
63
|
(args) => require('./deploy')(args)
|
|
58
64
|
)
|
|
59
65
|
.command(['generator', 'g'], '自动生成代码', (yargs) =>
|
|
60
66
|
yargs
|
|
61
|
-
.command(
|
|
62
|
-
'page',
|
|
63
|
-
'生成 page 模版, 默认根据环境生成 js/ts 与 less 文件',
|
|
64
|
-
(yargs) =>
|
|
65
|
-
yargs
|
|
66
|
-
.option('name', { desc: '模块名称', string: true })
|
|
67
|
-
.demandOption('name', '必须输入模块名称')
|
|
68
|
-
.option('ts', { alias: 't', desc: '生成 ts 文件', boolean: true, default: true })
|
|
69
|
-
.option('route', {
|
|
70
|
-
alias: 'r',
|
|
71
|
-
desc: '生成 index.js 路由文件',
|
|
72
|
-
boolean: true,
|
|
73
|
-
default: true,
|
|
74
|
-
})
|
|
75
|
-
.option('fc', { alias: 'f', desc: '生成 Function Component 文件', boolean: true }),
|
|
76
|
-
(args) => require('./generator').page(args)
|
|
77
|
-
)
|
|
78
67
|
.command('override', '创建 override 文件', {}, (args) =>
|
|
79
68
|
require('./generator').override(args)
|
|
80
69
|
)
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/* eslint-disable no-restricted-globals */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {{ protocol?: string, auth?: string, hostname?: string, port?: string, pathname?: string, search?: string, hash?: string, slashes?: boolean }} objURL
|
|
5
|
+
* @returns {string}
|
|
6
|
+
*/
|
|
7
|
+
function format(objURL) {
|
|
8
|
+
var protocol = objURL.protocol || ''
|
|
9
|
+
if (protocol && protocol.substr(-1) !== ':') {
|
|
10
|
+
protocol += ':'
|
|
11
|
+
}
|
|
12
|
+
var auth = objURL.auth || ''
|
|
13
|
+
if (auth) {
|
|
14
|
+
auth = encodeURIComponent(auth)
|
|
15
|
+
auth = auth.replace(/%3A/i, ':')
|
|
16
|
+
auth += '@'
|
|
17
|
+
}
|
|
18
|
+
var host = ''
|
|
19
|
+
if (objURL.hostname) {
|
|
20
|
+
host =
|
|
21
|
+
auth +
|
|
22
|
+
(objURL.hostname.indexOf(':') === -1 ? objURL.hostname : '['.concat(objURL.hostname, ']'))
|
|
23
|
+
if (objURL.port) {
|
|
24
|
+
host += ':'.concat(objURL.port)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
var pathname = objURL.pathname || ''
|
|
28
|
+
if (objURL.slashes) {
|
|
29
|
+
host = '//'.concat(host || '')
|
|
30
|
+
if (pathname && pathname.charAt(0) !== '/') {
|
|
31
|
+
pathname = '/'.concat(pathname)
|
|
32
|
+
}
|
|
33
|
+
} else if (!host) {
|
|
34
|
+
host = ''
|
|
35
|
+
}
|
|
36
|
+
var search = objURL.search || ''
|
|
37
|
+
if (search && search.charAt(0) !== '?') {
|
|
38
|
+
search = '?'.concat(search)
|
|
39
|
+
}
|
|
40
|
+
var hash = objURL.hash || ''
|
|
41
|
+
if (hash && hash.charAt(0) !== '#') {
|
|
42
|
+
hash = '#'.concat(hash)
|
|
43
|
+
}
|
|
44
|
+
pathname = pathname.replace(
|
|
45
|
+
/[?#]/g,
|
|
46
|
+
/**
|
|
47
|
+
* @param {string} match
|
|
48
|
+
* @returns {string}
|
|
49
|
+
*/
|
|
50
|
+
function (match) {
|
|
51
|
+
return encodeURIComponent(match)
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
search = search.replace('#', '%23')
|
|
55
|
+
return ''.concat(protocol).concat(host).concat(pathname).concat(search).concat(hash)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @param {URL & { fromCurrentScript?: boolean }} parsedURL
|
|
60
|
+
* @returns {string}
|
|
61
|
+
*/
|
|
62
|
+
function createSocketURL(parsedURL) {
|
|
63
|
+
var hostname = parsedURL.hostname
|
|
64
|
+
|
|
65
|
+
// Node.js module parses it as `::`
|
|
66
|
+
// `new URL(urlString, [baseURLString])` parses it as '[::]'
|
|
67
|
+
var isInAddrAny = hostname === '0.0.0.0' || hostname === '::' || hostname === '[::]'
|
|
68
|
+
|
|
69
|
+
// why do we need this check?
|
|
70
|
+
// hostname n/a for file protocol (example, when using electron, ionic)
|
|
71
|
+
// see: https://github.com/webpack/webpack-dev-server/pull/384
|
|
72
|
+
if (isInAddrAny && self.location.hostname && self.location.protocol.indexOf('http') === 0) {
|
|
73
|
+
hostname = self.location.hostname
|
|
74
|
+
}
|
|
75
|
+
var socketURLProtocol = parsedURL.protocol || self.location.protocol
|
|
76
|
+
|
|
77
|
+
// When https is used in the app, secure web sockets are always necessary because the browser doesn't accept non-secure web sockets.
|
|
78
|
+
if (
|
|
79
|
+
socketURLProtocol === 'auto:' ||
|
|
80
|
+
(hostname && isInAddrAny && self.location.protocol === 'https:')
|
|
81
|
+
) {
|
|
82
|
+
socketURLProtocol = self.location.protocol
|
|
83
|
+
}
|
|
84
|
+
socketURLProtocol = socketURLProtocol.replace(/^(?:http|.+-extension|file)/i, 'ws')
|
|
85
|
+
var socketURLAuth = ''
|
|
86
|
+
|
|
87
|
+
// `new URL(urlString, [baseURLstring])` doesn't have `auth` property
|
|
88
|
+
// Parse authentication credentials in case we need them
|
|
89
|
+
if (parsedURL.username) {
|
|
90
|
+
socketURLAuth = parsedURL.username
|
|
91
|
+
|
|
92
|
+
// Since HTTP basic authentication does not allow empty username,
|
|
93
|
+
// we only include password if the username is not empty.
|
|
94
|
+
if (parsedURL.password) {
|
|
95
|
+
// Result: <username>:<password>
|
|
96
|
+
socketURLAuth = socketURLAuth.concat(':', parsedURL.password)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// In case the host is a raw IPv6 address, it can be enclosed in
|
|
101
|
+
// the brackets as the brackets are needed in the final URL string.
|
|
102
|
+
// Need to remove those as url.format blindly adds its own set of brackets
|
|
103
|
+
// if the host string contains colons. That would lead to non-working
|
|
104
|
+
// double brackets (e.g. [[::]]) host
|
|
105
|
+
//
|
|
106
|
+
// All of these web socket url params are optionally passed in through resourceQuery,
|
|
107
|
+
// so we need to fall back to the default if they are not provided
|
|
108
|
+
var socketURLHostname = (hostname || self.location.hostname || 'localhost').replace(
|
|
109
|
+
/^\[(.*)\]$/,
|
|
110
|
+
'$1'
|
|
111
|
+
)
|
|
112
|
+
var socketURLPort = parsedURL.port
|
|
113
|
+
if (!socketURLPort || socketURLPort === '0') {
|
|
114
|
+
socketURLPort = self.location.port
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// If path is provided it'll be passed in via the resourceQuery as a
|
|
118
|
+
// query param so it has to be parsed out of the querystring in order for the
|
|
119
|
+
// client to open the socket to the correct location.
|
|
120
|
+
var socketURLPathname = '/ws'
|
|
121
|
+
if (parsedURL.pathname && !parsedURL.fromCurrentScript) {
|
|
122
|
+
socketURLPathname = parsedURL.pathname
|
|
123
|
+
|
|
124
|
+
if (hostname.indexOf('zhidianbao.cn') > -1 || hostname.indexOf('qsban.cn') > -1) {
|
|
125
|
+
var ctx = self.location.pathname.split('/')[1]
|
|
126
|
+
if (ctx) {
|
|
127
|
+
socketURLPathname = '/' + ctx + socketURLPathname
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return format({
|
|
132
|
+
protocol: socketURLProtocol,
|
|
133
|
+
auth: socketURLAuth,
|
|
134
|
+
hostname: socketURLHostname,
|
|
135
|
+
port: socketURLPort,
|
|
136
|
+
pathname: socketURLPathname,
|
|
137
|
+
slashes: true,
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
export default createSocketURL
|
|
@@ -340,6 +340,11 @@ module.exports = function getWebpackConfig(args, override) {
|
|
|
340
340
|
new webpack.DllReferencePlugin({
|
|
341
341
|
manifest: require('../asset/dll/libcommon3-manifest.json'),
|
|
342
342
|
}),
|
|
343
|
+
new webpack.NormalModuleReplacementPlugin(/createSocketURL\.js$/, (resource) => {
|
|
344
|
+
if (resource.context.includes('webpack-dev-server')) {
|
|
345
|
+
resource.request = require.resolve('./plugins/ws-utils-createSocketURL')
|
|
346
|
+
}
|
|
347
|
+
}),
|
|
343
348
|
new webpack.IgnorePlugin({
|
|
344
349
|
resourceRegExp: /^\.\/locale$/,
|
|
345
350
|
contextRegExp: /moment$/,
|
|
@@ -349,8 +354,6 @@ module.exports = function getWebpackConfig(args, override) {
|
|
|
349
354
|
'process.env.APP_VERSION': JSON.stringify(appPkg.version),
|
|
350
355
|
'process.env.BABEL_ENV': JSON.stringify(process.env.BABEL_ENV),
|
|
351
356
|
'process.env.BROWSERSLIST': JSON.stringify(process.env.BROWSERSLIST),
|
|
352
|
-
'process.env.WDS_SOCKET_HOST': JSON.stringify(process.env.WDS_SOCKET_HOST),
|
|
353
|
-
'process.env.WDS_SOCKET_PORT': JSON.stringify(process.env.WDS_SOCKET_PORT),
|
|
354
357
|
...override.define,
|
|
355
358
|
}),
|
|
356
359
|
new webpack.ProgressPlugin(),
|
|
@@ -7,8 +7,6 @@ const setupMockServer = require('./plugins/mock-server')
|
|
|
7
7
|
*/
|
|
8
8
|
module.exports = function getWebpackDevServerConfig(args, override) {
|
|
9
9
|
const host = process.env.HOST || '0.0.0.0'
|
|
10
|
-
const sockHost = process.env.WDS_SOCKET_HOST
|
|
11
|
-
const sockPort = process.env.WDS_SOCKET_PORT
|
|
12
10
|
|
|
13
11
|
/** @type {WebpackDevServer.Configuration} */
|
|
14
12
|
const devServer = {
|
|
@@ -19,7 +17,7 @@ module.exports = function getWebpackDevServerConfig(args, override) {
|
|
|
19
17
|
open: args.open,
|
|
20
18
|
host,
|
|
21
19
|
client: {
|
|
22
|
-
webSocketURL:
|
|
20
|
+
webSocketURL: 'auto://0.0.0.0:0/ws',
|
|
23
21
|
overlay: {
|
|
24
22
|
runtimeErrors: false,
|
|
25
23
|
errors: true,
|
package/src/deploy.js
CHANGED
|
@@ -18,25 +18,6 @@ const baseConfig = {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
async function normalDeploy(args) {
|
|
21
|
-
const presetConfig = {
|
|
22
|
-
s: {
|
|
23
|
-
context: 'eduwebngv1',
|
|
24
|
-
folder: 'userportal',
|
|
25
|
-
},
|
|
26
|
-
b: {
|
|
27
|
-
context: 'eduwebngv1',
|
|
28
|
-
folder: 'bureaupc',
|
|
29
|
-
},
|
|
30
|
-
d: {
|
|
31
|
-
context: 'eduwebngv1',
|
|
32
|
-
folder: 'documentshelves',
|
|
33
|
-
},
|
|
34
|
-
c: {
|
|
35
|
-
context: 'eduwebngv1',
|
|
36
|
-
folder: 'compositionshelves',
|
|
37
|
-
},
|
|
38
|
-
}
|
|
39
|
-
|
|
40
21
|
const resolve = (...pathSegments) => path.resolve(process.cwd(), ...pathSegments)
|
|
41
22
|
|
|
42
23
|
/**
|
|
@@ -128,34 +109,37 @@ async function normalDeploy(args) {
|
|
|
128
109
|
}
|
|
129
110
|
}
|
|
130
111
|
|
|
131
|
-
const
|
|
112
|
+
const presetConfig = {
|
|
113
|
+
s: { preset: { context: 'eduwebngv1', folder: 'userportal' } },
|
|
114
|
+
b: { preset: { context: 'eduwebngv1', folder: 'bureaupc' } },
|
|
115
|
+
d: { preset: { context: 'eduwebngv1', folder: 'documentshelves' } },
|
|
116
|
+
c: { preset: { context: 'eduwebngv1', folder: 'compositionshelves' } },
|
|
117
|
+
cd: {
|
|
118
|
+
preset: { server: '19' },
|
|
119
|
+
remotePath: '/erp/edumaven/dingcorrection-page-dev/compositionshelves',
|
|
120
|
+
},
|
|
121
|
+
}
|
|
122
|
+
const uploadSftpConfigs = []
|
|
132
123
|
if (args.b) {
|
|
133
|
-
|
|
124
|
+
uploadSftpConfigs.push(presetConfig.b)
|
|
134
125
|
}
|
|
135
126
|
if (args.s) {
|
|
136
|
-
|
|
127
|
+
uploadSftpConfigs.push(presetConfig.s)
|
|
137
128
|
}
|
|
138
129
|
if (args.d) {
|
|
139
|
-
|
|
130
|
+
uploadSftpConfigs.push(presetConfig.d)
|
|
140
131
|
}
|
|
141
132
|
if (args.c) {
|
|
142
|
-
|
|
133
|
+
uploadSftpConfigs.push(presetConfig.c)
|
|
134
|
+
}
|
|
135
|
+
if (args.cd) {
|
|
136
|
+
uploadSftpConfigs.push(presetConfig.cd)
|
|
143
137
|
}
|
|
144
|
-
if (
|
|
138
|
+
if (uploadSftpConfigs.length === 0) {
|
|
145
139
|
console.log(
|
|
146
140
|
`
|
|
147
141
|
${chalk.red('指定 deploy 部署范围')}
|
|
148
|
-
|
|
149
|
-
# 部署代码 校端
|
|
150
|
-
${chalk.green('edu-scripts deploy -s')}
|
|
151
|
-
# 部署代码 局端
|
|
152
|
-
${chalk.green('edu-scripts deploy -b')}
|
|
153
|
-
# 部署代码 公文
|
|
154
|
-
${chalk.green('edu-scripts deploy -d')}
|
|
155
|
-
# 部署代码 文曲智阅
|
|
156
|
-
${chalk.green('edu-scripts deploy -c')}
|
|
157
|
-
# 部署代码 校端 + 局端
|
|
158
|
-
${chalk.green('edu-scripts deploy -s -b')}
|
|
142
|
+
执行 ${chalk.green('npx edu-scripts deploy -h')} 查看具体用法
|
|
159
143
|
`
|
|
160
144
|
)
|
|
161
145
|
process.exit()
|
|
@@ -166,8 +150,8 @@ async function normalDeploy(args) {
|
|
|
166
150
|
uploadConfig.ignore = [...uploadConfig.ignore, '!(js|images)']
|
|
167
151
|
}
|
|
168
152
|
|
|
169
|
-
for (const
|
|
170
|
-
await upload({ ...uploadConfig,
|
|
153
|
+
for (const config of uploadSftpConfigs) {
|
|
154
|
+
await upload({ ...uploadConfig, ...config })
|
|
171
155
|
}
|
|
172
156
|
}
|
|
173
157
|
|
package/src/generator.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
2
|
const fs = require('fs-extra')
|
|
3
|
-
const { upperFirst, camelCase, has } = require('lodash')
|
|
4
3
|
const paths = require('./config/paths')
|
|
5
4
|
const chalk = require('chalk')
|
|
6
5
|
|
|
@@ -10,74 +9,6 @@ const chalk = require('chalk')
|
|
|
10
9
|
*/
|
|
11
10
|
const getTmpPath = (...args) => path.resolve(__dirname, 'asset', 'template', ...args)
|
|
12
11
|
|
|
13
|
-
function genFile({ source, target, modulePath, replace }) {
|
|
14
|
-
let content = fs.readFileSync(source, 'utf-8')
|
|
15
|
-
|
|
16
|
-
if (typeof replace === 'object') {
|
|
17
|
-
Object.entries(replace).forEach(([searchValue, replaceValue]) => {
|
|
18
|
-
content = content.replaceAll(searchValue, replaceValue)
|
|
19
|
-
})
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
fs.writeFileSync(path.resolve(modulePath, target), content)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @typedef {Object} PageArgs
|
|
27
|
-
* @property {string} name
|
|
28
|
-
* @property {boolean} [fc=false]
|
|
29
|
-
* @property {boolean} [ts=true]
|
|
30
|
-
* @property {boolean} [route=true]
|
|
31
|
-
*
|
|
32
|
-
* @param {PageArgs} args
|
|
33
|
-
*/
|
|
34
|
-
async function generatorPage(args) {
|
|
35
|
-
const tmpPath = getTmpPath('page', 'index.[type].[ext].tpl')
|
|
36
|
-
const lessPath = tmpPath.replace('[type].[ext]', 'less')
|
|
37
|
-
|
|
38
|
-
const moduleName = camelCase(args.name)
|
|
39
|
-
const ModuleName = upperFirst(moduleName)
|
|
40
|
-
const type = args.fc ? 'fc' : 'class'
|
|
41
|
-
const ext = fs.existsSync(paths.tsconfig) ? (args.ts ? 'tsx' : 'js') : 'js'
|
|
42
|
-
|
|
43
|
-
const jsPath = tmpPath.replace('[type]', type).replace('[ext]', ext)
|
|
44
|
-
const routePath = tmpPath.replace('index.[type].[ext]', 'route.js')
|
|
45
|
-
const logicPath = tmpPath.replace('index.[type].[ext]', 'logic.js')
|
|
46
|
-
|
|
47
|
-
const modulePath = path.resolve(paths.pages, moduleName)
|
|
48
|
-
|
|
49
|
-
const ModuleFileName = args.route ? ModuleName : 'index'
|
|
50
|
-
const ModuleLogicName = args.route ? ModuleName + 'Logic' : 'logic'
|
|
51
|
-
|
|
52
|
-
const replace = { ModuleName, moduleName, ModuleFileName, ModuleLogicName }
|
|
53
|
-
|
|
54
|
-
fs.ensureDirSync(modulePath)
|
|
55
|
-
genFile({ source: jsPath, target: `${ModuleFileName}.${ext}`, modulePath, replace })
|
|
56
|
-
genFile({ source: lessPath, target: `${ModuleFileName}.less`, modulePath, replace })
|
|
57
|
-
if (type === 'class' && ext === 'js') {
|
|
58
|
-
genFile({
|
|
59
|
-
source: logicPath,
|
|
60
|
-
target: `${ModuleLogicName}.${ext.slice(0, 2)}`,
|
|
61
|
-
modulePath,
|
|
62
|
-
replace,
|
|
63
|
-
})
|
|
64
|
-
}
|
|
65
|
-
if (args.route) {
|
|
66
|
-
genFile({ source: routePath, target: `index.${ext.slice(0, 2)}`, modulePath, replace })
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
console.log(
|
|
70
|
-
chalk.green(
|
|
71
|
-
[
|
|
72
|
-
`生成完毕:`,
|
|
73
|
-
`import ${ModuleName} from '@/pages/${moduleName}'`,
|
|
74
|
-
`const ${ModuleName} = lazy(() => import(/* webpackChunkName: '${moduleName}' */ '@/pages/${moduleName}'))`,
|
|
75
|
-
`{ path: '/${moduleName}', element: <${ModuleName} /> },`,
|
|
76
|
-
].join('\n')
|
|
77
|
-
)
|
|
78
|
-
)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
12
|
async function generatorOverride() {
|
|
82
13
|
if (fs.existsSync(paths.override)) {
|
|
83
14
|
console.log(chalk.red(`文件已存在 ${paths.override}`))
|
|
@@ -131,7 +62,6 @@ async function generatorTailwind() {
|
|
|
131
62
|
}
|
|
132
63
|
|
|
133
64
|
module.exports = {
|
|
134
|
-
page: generatorPage,
|
|
135
65
|
override: generatorOverride,
|
|
136
66
|
ts: generatorTsconfig,
|
|
137
67
|
tailwind: generatorTailwind,
|
package/src/start.js
CHANGED
|
@@ -15,15 +15,12 @@ const webpack = require('webpack')
|
|
|
15
15
|
const getConfig = require('./utils/getConfig')
|
|
16
16
|
const chalk = require('chalk')
|
|
17
17
|
|
|
18
|
-
process.env.WDS_SOCKET_HOST = WebpackDevServer.internalIPSync('v4') || '127.0.0.1'
|
|
19
|
-
|
|
20
18
|
module.exports = async function start(args) {
|
|
21
19
|
const basePort = process.env.WEBPACK_DEV_SERVER_BASE_PORT
|
|
22
20
|
const port = await WebpackDevServer.getFreePort(args.port || process.env.PORT)
|
|
23
21
|
if (!(args.port || process.env.PORT) && +port !== +basePort) {
|
|
24
22
|
console.log(chalk.bgYellow(`${basePort} 端口已被占用,现切换到 ${port} 端口运行`))
|
|
25
23
|
}
|
|
26
|
-
process.env.WDS_SOCKET_PORT = port
|
|
27
24
|
args.port = port
|
|
28
25
|
process.env.PORT = port
|
|
29
26
|
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import styles from './ModuleFileName.less'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import { Component } from 'refast'
|
|
4
|
-
import logic from './ModuleLogicName'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @typedef {object} ModuleNameProps
|
|
8
|
-
* @property {string} [name]
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @extends {React.Component<ModuleNameProps>}
|
|
13
|
-
*/
|
|
14
|
-
export default class ModuleName extends Component {
|
|
15
|
-
constructor(props) {
|
|
16
|
-
super(props, logic)
|
|
17
|
-
this.state = {
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
render() {
|
|
22
|
-
return <div className={styles.ModuleName}></div>
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import styles from './ModuleFileName.less'
|
|
2
|
-
import React, { Component } from 'react'
|
|
3
|
-
|
|
4
|
-
export interface ModuleNameState {}
|
|
5
|
-
export interface ModuleNameProps {}
|
|
6
|
-
export default class ModuleName extends Component<ModuleNameProps, ModuleNameState> {
|
|
7
|
-
render() {
|
|
8
|
-
return <div className={styles.ModuleName}></div>
|
|
9
|
-
}
|
|
10
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import styles from './ModuleFileName.less'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @typedef {object} ModuleNameProps
|
|
6
|
-
* @property {string} [name]
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @type {React.FC<ModuleNameProps>}
|
|
11
|
-
*/
|
|
12
|
-
const ModuleName = (props) => {
|
|
13
|
-
return <div className={styles.ModuleName}></div>
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default ModuleName
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Control } from 'react-keeper'
|
|
2
|
-
|
|
3
|
-
const moduleNameRoute = {
|
|
4
|
-
Load: (callback) => {
|
|
5
|
-
const prePath = Control.path
|
|
6
|
-
import(/* webpackChunkName: 'moduleName' */ './ModuleName').then((mod) => {
|
|
7
|
-
callback(Control.path === prePath ? mod.default : null)
|
|
8
|
-
})
|
|
9
|
-
},
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default moduleNameRoute
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import styles from './ModuleFileName.less'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import { Component } from 'refast'
|
|
4
|
-
import logic from './ModuleLogicName'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @typedef {object} ModuleNameProps
|
|
8
|
-
* @property {string} [name]
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @extends {React.Component<ModuleNameProps>}
|
|
13
|
-
*/
|
|
14
|
-
export default class ModuleName extends Component {
|
|
15
|
-
constructor(props) {
|
|
16
|
-
super(props, logic)
|
|
17
|
-
this.state = {
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
render() {
|
|
22
|
-
return <div className={styles.ModuleName}></div>
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import styles from './ModuleFileName.less'
|
|
2
|
-
import React, { Component } from 'react'
|
|
3
|
-
|
|
4
|
-
export interface ModuleNameState {}
|
|
5
|
-
export interface ModuleNameProps {}
|
|
6
|
-
export default class ModuleName extends Component<ModuleNameProps, ModuleNameState> {
|
|
7
|
-
render() {
|
|
8
|
-
return <div className={styles.ModuleName}></div>
|
|
9
|
-
}
|
|
10
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import styles from './ModuleFileName.less'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @typedef {object} ModuleNameProps
|
|
6
|
-
* @property {string} [name]
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @type {React.FC<ModuleNameProps>}
|
|
11
|
-
*/
|
|
12
|
-
const ModuleName = (props) => {
|
|
13
|
-
return <div className={styles.ModuleName}></div>
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default ModuleName
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Control } from 'react-keeper'
|
|
2
|
-
|
|
3
|
-
const moduleNameRoute = {
|
|
4
|
-
Load: (callback) => {
|
|
5
|
-
const prePath = Control.path
|
|
6
|
-
import(/* webpackChunkName: 'moduleName' */ './ModuleName').then((mod) => {
|
|
7
|
-
callback(Control.path === prePath ? mod.default : null)
|
|
8
|
-
})
|
|
9
|
-
},
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default moduleNameRoute
|