crabatool 1.0.337 → 1.0.340
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 +4 -0
- package/package.json +3 -3
- package/tool/checkiconfont.js +42 -0
- package/tool/checkjs.js +1 -0
package/index.js
CHANGED
|
@@ -39,12 +39,16 @@ function checkFast(args) {
|
|
|
39
39
|
|
|
40
40
|
if (args.includes('-checkjs')) {
|
|
41
41
|
start.bindConfigByArgv('-ignoreFiles','array');
|
|
42
|
+
start.bindConfigByArgv('-cssFiles','array');
|
|
43
|
+
|
|
42
44
|
start.checkAllJs();
|
|
43
45
|
return false;
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
if (args.includes('-checkiconfont')) {
|
|
47
49
|
start.bindConfigByArgv('-ignoreFiles','array');
|
|
50
|
+
start.bindConfigByArgv('-cssFiles','array');
|
|
51
|
+
|
|
48
52
|
start.checkIconfont();
|
|
49
53
|
return false;
|
|
50
54
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "crabatool",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.340",
|
|
4
4
|
"description": "crabatool",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"run": "node ./test/test.js -run",
|
|
13
13
|
"export": "node ./test/test.js -exportgspx -webPath F:\\Beefun\\srcs",
|
|
14
14
|
"checkjs": "node ./test/test.js -checkjs",
|
|
15
|
-
"checkiconfont": "node ./test/test.js -checkiconfont -webPath F:\\crabaevery\\www -modName crabaevery -reportHost http://127.0.0.1:9998 -ignoreFiles biconfont\\iconfont.js,iconfont\\iconfont.js",
|
|
15
|
+
"checkiconfont": "node ./test/test.js -checkiconfont -webPath F:\\crabaevery\\www -modName crabaevery -reportHost http://127.0.0.1:9998 -ignoreFiles biconfont\\iconfont.js,iconfont\\iconfont.js -cssFiles skins\\retail\\skin.css",
|
|
16
16
|
"checkiconfontBf": "node ./test/test.js -checkiconfont -webPath F:\\Beefun\\srcs -modName beefun -reportHost http://127.0.0.1:9998 -ignoreFiles biconfont\\iconfont.js,iconfont\\iconfont.js",
|
|
17
|
-
"checkiconfontCraba": "node ./test/test.js -checkiconfont -webPath F:\\CarpaNET_NEW\\src\\Carpa.Web\\js -modName craba -reportHost http://127.0.0.1:9998 -ignoreFiles biconfont\\iconfont.js,iconfont\\iconfont.js",
|
|
17
|
+
"checkiconfontCraba": "node ./test/test.js -checkiconfont -webPath F:\\CarpaNET_NEW\\src\\Carpa.Web\\js -modName craba -reportHost http://127.0.0.1:9998 -ignoreFiles biconfont\\iconfont.js,iconfont\\iconfont.js -cssFiles ../skins/craba.min.css",
|
|
18
18
|
"beefun": "node ./test/beefun.js -checkjs",
|
|
19
19
|
"checkUpdate": "node run.js -checkUpdate -version master -webPath F:\\crabaevery\\www",
|
|
20
20
|
"upload": "node run.js -upload -version master -Debug true -host http://127.0.0.1:9998 -hidejspath true -targetPath F:\\CarpaNET_NEW",
|
package/tool/checkiconfont.js
CHANGED
|
@@ -10,10 +10,14 @@ module.exports.start = async function() {
|
|
|
10
10
|
var ignores = config.ignoreFiles;
|
|
11
11
|
var files = utils.getFiles({ source: config.webPath, exts: ['.js', '.gspx'], ignores: ignores });
|
|
12
12
|
|
|
13
|
+
// js和gspx文件检测
|
|
13
14
|
var list = {};
|
|
14
15
|
var counts = {};
|
|
15
16
|
for (var i = 0; i < files.length; i++) {
|
|
16
17
|
var filePath = files[i];
|
|
18
|
+
if (!fs.existsSync(filePath)) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
17
21
|
var byte = fs.readFileSync(filePath);
|
|
18
22
|
var content = byte.toString();
|
|
19
23
|
|
|
@@ -32,6 +36,44 @@ module.exports.start = async function() {
|
|
|
32
36
|
});
|
|
33
37
|
}
|
|
34
38
|
}
|
|
39
|
+
|
|
40
|
+
// 特定css文件检测
|
|
41
|
+
var cssFiles = [];
|
|
42
|
+
if (config.cssFiles) {
|
|
43
|
+
config.cssFiles.forEach(function(src) {
|
|
44
|
+
cssFiles.push(utils.join(config.webPath, src));
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
for (var i = 0; i < cssFiles.length; i++) {
|
|
49
|
+
var filePath = cssFiles[i];
|
|
50
|
+
if (!fs.existsSync(filePath)) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
var byte = fs.readFileSync(filePath);
|
|
55
|
+
var content = byte.toString();
|
|
56
|
+
|
|
57
|
+
console.log('cssFiles', filePath);
|
|
58
|
+
var reg = /content:\s*['"]\\([0-9a-fA-F]{4})['"]/g;
|
|
59
|
+
if (reg.test(content)) {
|
|
60
|
+
var icons = [...content.matchAll(reg)];
|
|
61
|
+
icons = icons.map(function(match) {
|
|
62
|
+
return 'content-' + match[1]
|
|
63
|
+
});
|
|
64
|
+
var key = path.basename(filePath);
|
|
65
|
+
list[key] = icons;
|
|
66
|
+
|
|
67
|
+
icons.forEach(function(icon) {
|
|
68
|
+
if (counts[icon] === undefined) {
|
|
69
|
+
counts[icon] = 1;
|
|
70
|
+
} else {
|
|
71
|
+
counts[icon]++;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
35
77
|
// 用项目名+分支名确定唯一性
|
|
36
78
|
|
|
37
79
|
var reportData = {
|
package/tool/checkjs.js
CHANGED
|
@@ -217,6 +217,7 @@ module.exports.start = async function() {
|
|
|
217
217
|
info.push(`| 共检查 | ${jsFiles.length}个js文件 |`);
|
|
218
218
|
info.push(`| 共检查 | ${gspxData.count}个gspx文件 |`);
|
|
219
219
|
info.push(`| 忽略目录和文件 | ${config.ignoreCheck ? config.ignoreCheck.join('、') : '无' + ' |'}`);
|
|
220
|
+
info.push(`| 忽略全局变量 | ${config.globals ? config.globals.join('、') : '无' + ' |'}`);
|
|
220
221
|
|
|
221
222
|
info.push("# 检测结果汇总");
|
|
222
223
|
info.push("| 类型 | 数量 | 占比 |");
|