crabatool 1.0.32 → 1.0.35
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/lib/config.js +2 -0
- package/package.json +2 -2
- package/tool/checkjs.js +22 -9
package/lib/config.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
var path = require('path');
|
|
2
2
|
var os = require('os');
|
|
3
|
+
var pg = require('../package.json');
|
|
3
4
|
|
|
4
5
|
class Config {
|
|
5
6
|
constructor() {
|
|
6
7
|
this.reportHost = "http://crabadoc.ca.com"; // 用于接收检测报告的服务器,可配置的。由于产品没有提供服务,目前统一放到平台的文档服务器
|
|
7
8
|
this.webhooks = "https://oapi.dingtalk.com/robot/send?access_token=ce27b1b1540881540d44c0bd05ba738d865363758892ede137dc1020bd36bd5a";
|
|
8
9
|
|
|
10
|
+
this.Version = pg.version;
|
|
9
11
|
this.Debug = false;
|
|
10
12
|
this.Host = "http://crabadoc.mygjp.com.cn";
|
|
11
13
|
this.TempPath = path.join(os.tmpdir(), '_crabatemp');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "crabatool",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.35",
|
|
4
4
|
"description": "crabatool",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"test": "node ./test/test.js",
|
|
9
9
|
"run": "node ./test/test.js -run",
|
|
10
10
|
"checkjs": "node ./test/test.js -checkjs",
|
|
11
|
-
"webPath": "node ./test/test.js -checkjs -webPath F:\\
|
|
11
|
+
"webPath": "node ./test/test.js -checkjs -webhooks 0 -webPath F:\\newcrabadoc\\www -modName crabadoc -ignoreCheck ueditor,iconfont,biconfont,js\\math.min.js,js\\es6-promise.auto.min.js,js\\craba.rollup.min.js"
|
|
12
12
|
},
|
|
13
13
|
"author": "wssf",
|
|
14
14
|
"dependencies": {
|
package/tool/checkjs.js
CHANGED
|
@@ -72,11 +72,15 @@ module.exports.start = function() {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
var modName = config.modName || 'noname';
|
|
75
|
+
var dtList = [];
|
|
75
76
|
var info = [];
|
|
76
77
|
info.push(`# ${modName}代码检测报告——${status}`);
|
|
78
|
+
dtList.push(info[0]);
|
|
79
|
+
|
|
77
80
|
info.push("| 名称 | 结果 |");
|
|
78
81
|
info.push("| ------ | ------ |");
|
|
79
|
-
info.push(
|
|
82
|
+
info.push(`| 助手版本 | ${config.Version} |`);
|
|
83
|
+
info.push(`| 生成报告时间 | ${new Date().toString()} |`);
|
|
80
84
|
info.push(`| 共检查 | ${jsFiles.length}个js文件 |`);
|
|
81
85
|
if (config.ignoreCheck) {
|
|
82
86
|
info.push(`| 忽略目录和文件 | ${config.ignoreCheck.join('、') + ' |'}`);
|
|
@@ -86,8 +90,17 @@ module.exports.start = function() {
|
|
|
86
90
|
info.push("| 异常类型 | 数量 |");
|
|
87
91
|
info.push("| ------ | ------ |");
|
|
88
92
|
info.push(`| 语法异常文件数 | ${errList.length}个 |`);
|
|
89
|
-
|
|
90
|
-
|
|
93
|
+
dtList.push(`1. 语法异常文件数:${errList.length}个`);
|
|
94
|
+
|
|
95
|
+
if (notUtf8List.length > 0) {
|
|
96
|
+
info.push(`| 非utf8文件数 | ${notUtf8List.length}个 |`);
|
|
97
|
+
dtList.push(`1. 非utf8文件数:${notUtf8List.length}个`);
|
|
98
|
+
}
|
|
99
|
+
if (bigList.length > 0) {
|
|
100
|
+
info.push(`| 超过${fileSize}kb的文件数 | ${bigList.length}个 |`);
|
|
101
|
+
dtList.push(`1. 超过${fileSize}kb的文件数:${bigList.length}个`);
|
|
102
|
+
}
|
|
103
|
+
|
|
91
104
|
|
|
92
105
|
var detail = [];
|
|
93
106
|
if (errList.length > 0) {
|
|
@@ -101,7 +114,7 @@ module.exports.start = function() {
|
|
|
101
114
|
detail.push("| 异常字符 | 位置 |");
|
|
102
115
|
detail.push("| ----- | ------ |");
|
|
103
116
|
err.list.forEach((item) => {
|
|
104
|
-
detail.push(`| ${item.char} | ${item.index} |`);
|
|
117
|
+
detail.push(`| ${item.char.trim()} | ${item.index} |`);
|
|
105
118
|
});
|
|
106
119
|
});
|
|
107
120
|
}
|
|
@@ -124,7 +137,7 @@ module.exports.start = function() {
|
|
|
124
137
|
|
|
125
138
|
//console.log(detail.join('\r\n'));
|
|
126
139
|
var id = modName + '_' + new Date().getTime();
|
|
127
|
-
var content = info.concat(detail).join(' \n');
|
|
140
|
+
var content = info.concat(detail).join(' \r\n');
|
|
128
141
|
console.log(content);
|
|
129
142
|
|
|
130
143
|
var data = {
|
|
@@ -158,16 +171,16 @@ module.exports.start = function() {
|
|
|
158
171
|
//utils.openProcess(reportUrl);
|
|
159
172
|
|
|
160
173
|
//return;
|
|
161
|
-
if (!config.webhooks) {
|
|
162
|
-
|
|
174
|
+
if (!config.webhooks || config.webhooks == '0') {
|
|
175
|
+
console.log("::: craba.js里面配置config.webhooks,用于语法检测报告推送地址");
|
|
163
176
|
return;
|
|
164
177
|
}
|
|
165
178
|
|
|
166
179
|
if (status == '健康') return; // 检查结果检查就不发到钉钉了
|
|
167
180
|
|
|
168
181
|
// 推送到钉钉只推送详情
|
|
169
|
-
|
|
170
|
-
data.markdown.text =
|
|
182
|
+
dtList.push(`[报告详情](${reportUrl})`);
|
|
183
|
+
data.markdown.text = dtList.join(' \n');
|
|
171
184
|
|
|
172
185
|
axios({
|
|
173
186
|
method: 'post',
|