crabatool 1.0.831 → 1.0.832
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 +9 -0
- package/lib/config.js +1 -0
- package/package.json +1 -1
- package/tool/checkgspx.js +15 -0
- package/tool/checkjs.js +25 -3
- package/tool/start.js +1 -0
package/index.js
CHANGED
|
@@ -78,6 +78,15 @@ exports.run = async function(options) {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
async function checkFast(args) {
|
|
81
|
+
// 配置文件方式启用自动生成 ID(优先于长度判断,避免被提前 return 掉)
|
|
82
|
+
if (!args.includes('-autoId') && config.autoId === true) {
|
|
83
|
+
start.checkWebPath();
|
|
84
|
+
start.bindConfigByArgv('-ignoreAutoId', 'array');
|
|
85
|
+
start.bindConfigByArgv('-ignoreFiles', 'array');
|
|
86
|
+
require('./tool/addNodeId.js').start();
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
|
|
81
90
|
// 1. 服务端构建环境,自动化,根据命令行参数,直接调用脚手架功能
|
|
82
91
|
if (args.length < 3) {
|
|
83
92
|
return true;
|
package/lib/config.js
CHANGED
package/package.json
CHANGED
package/tool/checkgspx.js
CHANGED
|
@@ -9,6 +9,7 @@ module.exports.getResults = function() {
|
|
|
9
9
|
var data = {
|
|
10
10
|
count: 0,
|
|
11
11
|
tags: {},
|
|
12
|
+
labelList: {},
|
|
12
13
|
bizList: {},
|
|
13
14
|
tagList: [],
|
|
14
15
|
customs1: {},
|
|
@@ -96,6 +97,20 @@ function readGspxToJSON(fileName, data) {
|
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
}
|
|
100
|
+
|
|
101
|
+
if (name == 'Label') {
|
|
102
|
+
for (var key in attrs) {
|
|
103
|
+
if (key == 'ReadOnly') {
|
|
104
|
+
if (!data.labelList[fileName]) {
|
|
105
|
+
data.labelList[fileName] = [];
|
|
106
|
+
}
|
|
107
|
+
var id = attrs.ID || attrs.Label || attrs.Text;
|
|
108
|
+
data.labelList[fileName].push(id);
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
99
114
|
// 建议优化页面汇总
|
|
100
115
|
if (warnTags.includes(name)) {
|
|
101
116
|
if (name == 'CancelButton' || name == 'CloseButton') {
|
package/tool/checkjs.js
CHANGED
|
@@ -198,6 +198,7 @@ module.exports.start = async function() {
|
|
|
198
198
|
|
|
199
199
|
// 生成检测报告 markdown语法
|
|
200
200
|
var warnGspxCount = Object.keys(gspxData.warnList).length;
|
|
201
|
+
var readLabelCount = Object.keys(gspxData.labelList).length;
|
|
201
202
|
var trimErrKeys = Object.keys(trimErrDatas);
|
|
202
203
|
var errKeys = Object.keys(errDatas);
|
|
203
204
|
var undefKeys = Object.keys(undefDatas);
|
|
@@ -251,7 +252,9 @@ module.exports.start = async function() {
|
|
|
251
252
|
}
|
|
252
253
|
|
|
253
254
|
info.push(`| 超过${fileSize}kb的文件数 | ${bigList.length}个 |${calc(bigList.length, jsFiles.length)}|`);
|
|
254
|
-
|
|
255
|
+
if (readLabelCount > 0) {
|
|
256
|
+
info.push(`| 只读Label优化数 | ${readLabelCount}个 |${calc(readLabelCount, gspxData.count)}|`);
|
|
257
|
+
}
|
|
255
258
|
if (warnGspxCount > 0) {
|
|
256
259
|
info.push(`| gspx建议优化数 | ${warnGspxCount}个 |${calc(warnGspxCount, gspxData.count)}|`);
|
|
257
260
|
}
|
|
@@ -267,7 +270,8 @@ module.exports.start = async function() {
|
|
|
267
270
|
tipCount: infoKeys.length,
|
|
268
271
|
fileSize: fileSize,
|
|
269
272
|
fileSizeCount: bigList.length,
|
|
270
|
-
gspxWarnCount: warnGspxCount
|
|
273
|
+
gspxWarnCount: warnGspxCount,
|
|
274
|
+
readLabelCount: readLabelCount,
|
|
271
275
|
gspxErrorCount: gspxData.errorList.length,
|
|
272
276
|
jsTotal: jsFiles.length,
|
|
273
277
|
gspxTotal: gspxData.count
|
|
@@ -323,7 +327,9 @@ module.exports.start = async function() {
|
|
|
323
327
|
if (config.checkutf8 && notUtf8List.length > 0) {
|
|
324
328
|
webhookList.push(`1. 非utf8文件数:${notUtf8List.length}个,占比${calc(notUtf8List.length, jsFiles.length)}`);
|
|
325
329
|
}
|
|
326
|
-
|
|
330
|
+
if (readLabelCount > 0) {
|
|
331
|
+
webhookList.push(`1. 只读Label优化数:${readLabelCount}个,占比${calc(readLabelCount, gspxData.count)}`);
|
|
332
|
+
}
|
|
327
333
|
if (bigList.length > 0) {
|
|
328
334
|
webhookList.push(`1. 超过${fileSize}kb的文件数:${bigList.length}个,占比${calc(bigList.length, jsFiles.length)}`);
|
|
329
335
|
}
|
|
@@ -486,6 +492,22 @@ module.exports.start = async function() {
|
|
|
486
492
|
});
|
|
487
493
|
}
|
|
488
494
|
|
|
495
|
+
if (readLabelCount > 0) {
|
|
496
|
+
detail.push(`# 只读Label清单如下`);
|
|
497
|
+
Object.keys(gspxData.labelList).forEach((key, index) => {
|
|
498
|
+
var ids = gspxData.labelList[key];
|
|
499
|
+
|
|
500
|
+
detail.push(`**${index + 1}. ${key}**`);
|
|
501
|
+
detail.push(`>建议优化Label明细: \`${ids.join('`、`')}\``);
|
|
502
|
+
detail.push("");
|
|
503
|
+
detail.push("| Label特性 | 优化建议 |");
|
|
504
|
+
detail.push("| ----- | ------ |");
|
|
505
|
+
ids.forEach((id) => {
|
|
506
|
+
detail.push(`| ${id} | 去掉ReadOnly |`);
|
|
507
|
+
});
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
|
|
489
511
|
if (warnGspxCount > 0) {
|
|
490
512
|
detail.push(`# 建议优化gspx清单如下`);
|
|
491
513
|
Object.keys(gspxData.warnList).forEach((key, index) => {
|
package/tool/start.js
CHANGED