@qse/edu-scripts 1.13.0 → 1.13.2
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 +13 -0
- package/docs/refactor-react-16.md +1 -4
- package/lib/auto-refactor.js +1 -1
- package/lib/deploy.js +13 -1
- package/lib/utils/changeDeployVersion.js +14 -0
- package/package.json +1 -1
- package/src/auto-refactor.js +1 -1
- package/src/deploy.js +12 -1
- package/src/utils/changeDeployVersion.js +11 -0
- package/tsconfig.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## 1.13.2 (2023-02-01)
|
|
4
|
+
|
|
5
|
+
- fix: 修复部署日志错误
|
|
6
|
+
|
|
7
|
+
## 1.13.1 (2023-02-01)
|
|
8
|
+
|
|
9
|
+
- feat: 优化日志格式
|
|
10
|
+
- feat: 部署时清理 `ver.js` 里杂乱的 `comments`
|
|
11
|
+
|
|
12
|
+
## 1.13.0 (2022-11-10)
|
|
13
|
+
|
|
14
|
+
- feat: 教育集成项目部署增加日志功能
|
|
15
|
+
|
|
3
16
|
## 1.12.5 (2022-11-03)
|
|
4
17
|
|
|
5
18
|
- feat: 优化 cdn external 规则
|
|
@@ -19,11 +19,8 @@ frame 项目 react15 升级 react16 指南
|
|
|
19
19
|
```html
|
|
20
20
|
<script src="//static.qsepay.net/lib/react15.4.1_fastclick1.0.6_natty-storage2.0.2-fetch2.4.2_common2.js"></script>
|
|
21
21
|
|
|
22
|
-
将上面这条 CDN
|
|
22
|
+
将上面这条 CDN 替换成下面这条
|
|
23
23
|
|
|
24
|
-
<!-- 一般使用这条 -->
|
|
25
|
-
<script src="//static.qsepay.net/lib/react16.14_fastclick1.0.6_natty-storage2.0.2-fetch2.4.2_common31.js"></script>
|
|
26
|
-
<!-- 如果需要 axios 请使用这条 -->
|
|
27
24
|
<script src="//static.qsepay.net/lib/react16.14_fastclick1.0.6_natty-storage2.0.2-fetch2.4.2_axios0.21.1_common31.js"></script>
|
|
28
25
|
```
|
|
29
26
|
|
package/lib/auto-refactor.js
CHANGED
|
@@ -144,7 +144,7 @@ module.exports = async function autoRefactor() {
|
|
|
144
144
|
scripts.postversion = 'npm run build && npm run deploy';
|
|
145
145
|
});
|
|
146
146
|
await step('删除 babel/webpack 相关依赖', spinner => {
|
|
147
|
-
const deleteRe = /(babel|autoprefixer|webpack|loader|less|css|sass|hmr|ssh-sftp|regenerator-runtime|nowa)/i;
|
|
147
|
+
const deleteRe = /(babel|autoprefixer|webpack|loader|less|css|sass|hmr|ssh-sftp|regenerator-runtime|nowa|prettier)/i;
|
|
148
148
|
const deletePkgs = {
|
|
149
149
|
dependencies: [],
|
|
150
150
|
devDependencies: []
|
package/lib/deploy.js
CHANGED
|
@@ -71,6 +71,18 @@ async function normalDeploy(args) {
|
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
function dateTime() {
|
|
75
|
+
let date = new Date();
|
|
76
|
+
date = new Date(date.getTime() - date.getTimezoneOffset() * 60000);
|
|
77
|
+
return date.toISOString().replace(/T/, ' ').replace(/\..+/, '');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function updateLogContent(content, info) {
|
|
81
|
+
const lines = content.trim().split('\n');
|
|
82
|
+
lines.push(`[${dateTime()}] ${JSON.stringify(info)}\n`);
|
|
83
|
+
return lines.slice(-50).join('\n');
|
|
84
|
+
}
|
|
85
|
+
|
|
74
86
|
async function upload(opts) {
|
|
75
87
|
// 上传dist文件
|
|
76
88
|
const {
|
|
@@ -121,7 +133,7 @@ async function normalDeploy(args) {
|
|
|
121
133
|
content = await fs.readFile(tmpLogFile, 'utf-8');
|
|
122
134
|
} catch (error) {}
|
|
123
135
|
|
|
124
|
-
content
|
|
136
|
+
content = updateLogContent(content, info);
|
|
125
137
|
await fs.writeFile(tmpLogFile, content);
|
|
126
138
|
await sftp.fastPut(tmpLogFile, remoteLogFile);
|
|
127
139
|
}
|
|
@@ -94,6 +94,19 @@ function changeDeployVersion(code, pkg) {
|
|
|
94
94
|
path.node.properties.push(t.objectProperty(t.identifier(keyName), t.stringLiteral(version)));
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* @param {babel.NodePath<t.ObjectExpression>} path
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
function deleteModuleComments(path) {
|
|
103
|
+
path.traverse({
|
|
104
|
+
ObjectExpression(path) {
|
|
105
|
+
delete path.node.leadingComments;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
});
|
|
109
|
+
}
|
|
97
110
|
/**
|
|
98
111
|
* @param {babel.NodePath<t.VariableDeclarator>} path
|
|
99
112
|
*/
|
|
@@ -114,6 +127,7 @@ function changeDeployVersion(code, pkg) {
|
|
|
114
127
|
addModuleToTarget(targetPath);
|
|
115
128
|
}
|
|
116
129
|
|
|
130
|
+
deleteModuleComments(targetPath);
|
|
117
131
|
return format(generate(ast, {
|
|
118
132
|
minified: true
|
|
119
133
|
}).code, {
|
package/package.json
CHANGED
package/src/auto-refactor.js
CHANGED
|
@@ -134,7 +134,7 @@ module.exports = async function autoRefactor() {
|
|
|
134
134
|
|
|
135
135
|
await step('删除 babel/webpack 相关依赖', (spinner) => {
|
|
136
136
|
const deleteRe =
|
|
137
|
-
/(babel|autoprefixer|webpack|loader|less|css|sass|hmr|ssh-sftp|regenerator-runtime|nowa)/i
|
|
137
|
+
/(babel|autoprefixer|webpack|loader|less|css|sass|hmr|ssh-sftp|regenerator-runtime|nowa|prettier)/i
|
|
138
138
|
|
|
139
139
|
const deletePkgs = {
|
|
140
140
|
dependencies: [],
|
package/src/deploy.js
CHANGED
|
@@ -55,6 +55,17 @@ async function normalDeploy(args) {
|
|
|
55
55
|
return { tmpDir, tmpFile, remoteFile, tmpBase }
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
function dateTime() {
|
|
59
|
+
let date = new Date()
|
|
60
|
+
date = new Date(date.getTime() - date.getTimezoneOffset() * 60000)
|
|
61
|
+
return date.toISOString().replace(/T/, ' ').replace(/\..+/, '')
|
|
62
|
+
}
|
|
63
|
+
function updateLogContent(content, info) {
|
|
64
|
+
const lines = content.trim().split('\n')
|
|
65
|
+
lines.push(`[${dateTime()}] ${JSON.stringify(info)}\n`)
|
|
66
|
+
return lines.slice(-50).join('\n')
|
|
67
|
+
}
|
|
68
|
+
|
|
58
69
|
async function upload(opts) {
|
|
59
70
|
// 上传dist文件
|
|
60
71
|
const { sftp, opts: fullOpts } = await sshSftp(opts)
|
|
@@ -97,7 +108,7 @@ async function normalDeploy(args) {
|
|
|
97
108
|
await sftp.fastGet(remoteLogFile, tmpLogFile)
|
|
98
109
|
content = await fs.readFile(tmpLogFile, 'utf-8')
|
|
99
110
|
} catch (error) {}
|
|
100
|
-
content
|
|
111
|
+
content = updateLogContent(content, info)
|
|
101
112
|
await fs.writeFile(tmpLogFile, content)
|
|
102
113
|
await sftp.fastPut(tmpLogFile, remoteLogFile)
|
|
103
114
|
}
|
|
@@ -80,6 +80,16 @@ function changeDeployVersion(code, pkg) {
|
|
|
80
80
|
path.node.properties.push(t.objectProperty(t.identifier(keyName), t.stringLiteral(version)))
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* @param {babel.NodePath<t.ObjectExpression>} path
|
|
85
|
+
*/
|
|
86
|
+
function deleteModuleComments(path) {
|
|
87
|
+
path.traverse({
|
|
88
|
+
ObjectExpression(path) {
|
|
89
|
+
delete path.node.leadingComments
|
|
90
|
+
},
|
|
91
|
+
})
|
|
92
|
+
}
|
|
83
93
|
|
|
84
94
|
/**
|
|
85
95
|
* @param {babel.NodePath<t.VariableDeclarator>} path
|
|
@@ -105,6 +115,7 @@ function changeDeployVersion(code, pkg) {
|
|
|
105
115
|
} else {
|
|
106
116
|
addModuleToTarget(targetPath)
|
|
107
117
|
}
|
|
118
|
+
deleteModuleComments(targetPath)
|
|
108
119
|
|
|
109
120
|
return format(generate(ast, { minified: true }).code, {
|
|
110
121
|
parser: 'babel',
|