@qse/edu-scripts 1.14.9 → 1.14.10
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 +8 -0
- package/lib/asset/template/edu-scripts.override.js.tpl +2 -9
- package/lib/cli.js +5 -10
- package/lib/deploy.js +22 -37
- package/lib/generator.js +0 -50
- package/package.json +26 -26
- package/src/asset/template/edu-scripts.override.js.tpl +2 -9
- package/src/cli.js +6 -17
- package/src/deploy.js +22 -38
- package/src/generator.js +0 -70
- 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,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
|
{},
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qse/edu-scripts",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.10",
|
|
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
|
)
|
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,
|
|
@@ -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
|