crabatool 1.0.152 → 1.0.154
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/index.js +2 -2
- package/package.json +1 -1
- package/tool/checkjs.js +18 -10
- package/tool/start.js +2 -1
- package/tool/upgrade.js +7 -7
package/index.js
CHANGED
|
@@ -34,12 +34,12 @@ module.exports.run = function(options) {
|
|
|
34
34
|
|
|
35
35
|
// 安装vscode环境
|
|
36
36
|
if (arr.includes('-vscode')) {
|
|
37
|
-
return
|
|
37
|
+
return start.installvscode();
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
// 安装idea环境
|
|
41
41
|
if (arr.includes('-idea')) {
|
|
42
|
-
return
|
|
42
|
+
return start.installIDEA();
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
package/package.json
CHANGED
package/tool/checkjs.js
CHANGED
|
@@ -64,15 +64,17 @@ module.exports.start = async function() {
|
|
|
64
64
|
var eslintResults = await eslintCheck(content);
|
|
65
65
|
|
|
66
66
|
// 检查编码
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
} else {
|
|
71
|
-
var reg = /[\u4e00-\u9FA5]+/;
|
|
72
|
-
if (!reg.test(content)) { // 不包含中文的情况,jschardet把utf-8也认为是gbk了
|
|
67
|
+
if (config.checkutf8) {
|
|
68
|
+
var ret = jschardet.detect(byte);
|
|
69
|
+
if (utils.isUtf8(byte, ret.encoding) || ret.encoding == 'UTF-8') {
|
|
73
70
|
utf8List.push(filePath);
|
|
74
71
|
} else {
|
|
75
|
-
|
|
72
|
+
var reg = /[\u4e00-\u9FA5]+/;
|
|
73
|
+
if (!reg.test(content)) { // 不包含中文的情况,jschardet把utf-8也认为是gbk了
|
|
74
|
+
utf8List.push(filePath);
|
|
75
|
+
} else {
|
|
76
|
+
notUtf8List.push(`路径:${filePath} 编码:${ret.encoding}`);
|
|
77
|
+
}
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
80
|
pb.value++;
|
|
@@ -184,7 +186,11 @@ module.exports.start = async function() {
|
|
|
184
186
|
info.push(`| 语法异常文件数Error | ${errKeys.length}个 |${calc(errKeys.length, jsFiles.length)}|`);
|
|
185
187
|
info.push(`| 语法警告文件数Warn | ${warnKeys.length}个 |${calc(warnKeys.length, jsFiles.length)}|`);
|
|
186
188
|
info.push(`| 语法提示文件数Info | ${infoKeys.length}个 |${calc(infoKeys.length, jsFiles.length)}|`);
|
|
187
|
-
|
|
189
|
+
|
|
190
|
+
if (config.checkutf8) {
|
|
191
|
+
info.push(`| 非utf8文件数 | ${notUtf8List.length}个 |${calc(notUtf8List.length, jsFiles.length)}|`);
|
|
192
|
+
}
|
|
193
|
+
|
|
188
194
|
info.push(`| 超过${fileSize}kb的文件数 | ${bigList.length}个 |${calc(bigList.length, jsFiles.length)}|`);
|
|
189
195
|
info.push(`| gspx建议优化数 | ${warnGspxCount}个 |${calc(warnGspxCount, gspxData.count)}|`);
|
|
190
196
|
info.push(`| gspx语法错误数 | ${gspxData.errorList.length}个 |${calc(gspxData.errorList.length, gspxData.count)}|`);
|
|
@@ -227,9 +233,11 @@ module.exports.start = async function() {
|
|
|
227
233
|
webhookList.push(`7. 语法警告文件数Warn:${warnKeys.length}个,占比${calc(warnKeys.length, jsFiles.length)}`);
|
|
228
234
|
//}
|
|
229
235
|
webhookList.push(`8. 语法提示文件数Info:${infoKeys.length}个,占比${calc(infoKeys.length, jsFiles.length)}`);
|
|
230
|
-
|
|
236
|
+
|
|
237
|
+
if (config.checkutf8 && notUtf8List.length > 0) {
|
|
231
238
|
webhookList.push(`1. 非utf8文件数:${notUtf8List.length}个,占比${calc(notUtf8List.length, jsFiles.length)}`);
|
|
232
239
|
}
|
|
240
|
+
|
|
233
241
|
if (bigList.length > 0) {
|
|
234
242
|
webhookList.push(`1. 超过${fileSize}kb的文件数:${bigList.length}个,占比${calc(bigList.length, jsFiles.length)}`);
|
|
235
243
|
}
|
|
@@ -298,7 +306,7 @@ module.exports.start = async function() {
|
|
|
298
306
|
});
|
|
299
307
|
//}
|
|
300
308
|
|
|
301
|
-
if (notUtf8List.length > 0) {
|
|
309
|
+
if (config.checkutf8 && notUtf8List.length > 0) {
|
|
302
310
|
detail.push("");
|
|
303
311
|
detail.push('# 非utf8清单如下');
|
|
304
312
|
notUtf8List.forEach((s, index) => {
|
package/tool/start.js
CHANGED
|
@@ -56,7 +56,7 @@ class Start {
|
|
|
56
56
|
start.installvscode();
|
|
57
57
|
} else if (num == 8) {
|
|
58
58
|
var options = {};
|
|
59
|
-
options.type = await question('选择项目类型:1. 普通craba
|
|
59
|
+
options.type = await question('选择项目类型:1. 普通craba纯前端项目; 2. ngp微前端项目;输入编号:');
|
|
60
60
|
if (options.type != 1 && options.type != 2) options.type = 1;
|
|
61
61
|
if (options.type == 2) {
|
|
62
62
|
options.modName = await question('请输入微服务的模块名称:');
|
|
@@ -85,6 +85,7 @@ class Start {
|
|
|
85
85
|
bindConfigByArgv('-ignoreCompress', 'boolean');
|
|
86
86
|
bindConfigByArgv('-Debug', 'boolean');
|
|
87
87
|
bindConfigByArgv('-checkgspx', 'boolean');
|
|
88
|
+
bindConfigByArgv('-checkutf8', 'boolean');
|
|
88
89
|
//bindConfigByArgv('-branchName');
|
|
89
90
|
}
|
|
90
91
|
|
package/tool/upgrade.js
CHANGED
|
@@ -82,15 +82,15 @@ class Upgrade {
|
|
|
82
82
|
|
|
83
83
|
createProject(options) {
|
|
84
84
|
var projectPath = "";
|
|
85
|
-
if (options.type == 1) {
|
|
85
|
+
if (options.type == 1) { // 普通前端项目
|
|
86
86
|
projectPath = utils.join(options.projectPath, 'www');
|
|
87
|
-
} else if (options.type == 2) {
|
|
88
|
-
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
} else {
|
|
92
|
-
projectPath = utils.join(options.projectPath, projectPath, options.modName);
|
|
87
|
+
} else if (options.type == 2) { // ngp微前端
|
|
88
|
+
var name1 = options.modName;
|
|
89
|
+
if (options.projectPath.includes(options.modName)) { // 输入的路径已经包含模块名了
|
|
90
|
+
name1 = '';
|
|
93
91
|
}
|
|
92
|
+
projectPath = `${name1}/web/src/main/resources/static/${options.modName}`;
|
|
93
|
+
projectPath = utils.join(options.projectPath, projectPath);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
this.done = this._createDone;
|