crabatool 1.0.194 → 1.0.195
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/package.json +1 -1
- package/tool/checkgspx.js +7 -1
- package/tool/checkjs.js +6 -4
package/package.json
CHANGED
package/tool/checkgspx.js
CHANGED
|
@@ -13,7 +13,9 @@ module.exports.getResults = function() {
|
|
|
13
13
|
warnList: {},
|
|
14
14
|
errorList: []
|
|
15
15
|
};
|
|
16
|
-
if (!config.checkgspx)
|
|
16
|
+
if (!config.checkgspx) {
|
|
17
|
+
return data;
|
|
18
|
+
}
|
|
17
19
|
|
|
18
20
|
var gspxFiles = utils.getFiles({ source: config.webPath, exts: '.gspx' });
|
|
19
21
|
data.count = gspxFiles.length;
|
|
@@ -25,6 +27,7 @@ module.exports.getResults = function() {
|
|
|
25
27
|
Object.keys(data.tags).forEach((tag, index) => {
|
|
26
28
|
data.tagList.push({ name: tag, count: data.tags[tag] });
|
|
27
29
|
});
|
|
30
|
+
|
|
28
31
|
data.tagList.sort(function(item0, item1) {
|
|
29
32
|
return item0.count > item1.count ? -1 : 1;
|
|
30
33
|
});
|
|
@@ -37,6 +40,9 @@ function readGspxToJSON(fileName, data) {
|
|
|
37
40
|
var node;
|
|
38
41
|
var byte = fs.readFileSync(fileName);
|
|
39
42
|
var gspxXML = utils.toUtf8(byte);
|
|
43
|
+
if (!gspxXML.startsWith('<?xml')) {
|
|
44
|
+
data.errorList.push({ fileName: fileName, tag: '', error: 'gspx文件第一行必须是:<?xml version="1.0" encoding="UTF-8"?>' });
|
|
45
|
+
}
|
|
40
46
|
var level = 0;
|
|
41
47
|
|
|
42
48
|
fileName = fileName.replace(config.webPath, ''); // 简化文件路径
|
package/tool/checkjs.js
CHANGED
|
@@ -213,6 +213,10 @@ module.exports.start = async function() {
|
|
|
213
213
|
webhookList.push(`1. 共检测 ${jsFiles.length}个 js文件 `);
|
|
214
214
|
webhookList.push(`1. 共检测 ${gspxData.count}个 gspx文件 `);
|
|
215
215
|
|
|
216
|
+
if (gspxData.errorList.length > 0) {
|
|
217
|
+
webhookList.push(`1. gspx语法错误数:${gspxData.errorList.length}个,占比${calc(gspxData.errorList.length, gspxData.count)}`);
|
|
218
|
+
}
|
|
219
|
+
|
|
216
220
|
// 输出到钉钉的简易报告
|
|
217
221
|
//if (errKeys.length > 0) {
|
|
218
222
|
webhookList.push(`1. 语法异常文件数Error:${errKeys.length}个,占比${calc(errKeys.length, jsFiles.length)}`);
|
|
@@ -251,9 +255,7 @@ module.exports.start = async function() {
|
|
|
251
255
|
if (warnGspxCount > 0) {
|
|
252
256
|
webhookList.push(`1. gspx建议优化数:${warnGspxCount}个,占比${calc(warnGspxCount, gspxData.count)}`);
|
|
253
257
|
}
|
|
254
|
-
|
|
255
|
-
webhookList.push(`1. gspx语法错误数:${gspxData.errorList.length}个,占比${calc(gspxData.errorList.length, gspxData.count)}`);
|
|
256
|
-
}
|
|
258
|
+
|
|
257
259
|
|
|
258
260
|
// 代码质量管理需要格式
|
|
259
261
|
var sonar = {
|
|
@@ -334,7 +336,7 @@ module.exports.start = async function() {
|
|
|
334
336
|
}
|
|
335
337
|
|
|
336
338
|
if (gspxData.errorList.length > 0) {
|
|
337
|
-
detail.push(`#
|
|
339
|
+
detail.push(`# 出错gspx页面清单如下`);
|
|
338
340
|
gspxData.errorList.forEach((info, index) => {
|
|
339
341
|
detail.push(`${index + 1}. ${info.name}`);
|
|
340
342
|
detail.push(`> 错误标签: ${info.tag}`);
|