crabatool 1.0.288 → 1.0.290
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/hash2.json +8 -0
- package/index.js +2 -1
- package/lib/server.js +3 -0
- package/package.json +3 -2
- package/tool/hash.js +33 -7
package/hash2.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"craba/beefun.js": "sha384-pkh4Pn8P8Bt2R3KEeN7N2WBZHd7xFWCD8fY2LuCdypHQv1DXLG538f1Jr+pCyJcM",
|
|
3
|
+
"craba/craba.js": "sha384-n2XKRVKzBD/TEJshcBPd47g8CuFGr3kaXtCOYmHlDiycT2oYgcS861vnbDO8oOU7",
|
|
4
|
+
"craba/jslint.js": "sha384-syKt/0UKHwxXV2mHXk7NrTYMaOn3BBKxKYVzetJ8adbczKfIRrDvX1mPu7ywNiwO",
|
|
5
|
+
"craba/test.js": "sha384-VQy3WyY/3vG+HckZphZEXGAZGOVP/NhqD8fx6wBjMPtfIaX5dUjMOxR+F23VhxAw",
|
|
6
|
+
"craba/zip.js": "sha384-CfuD5iXqZUPZwLBiIXf8neQb0iPRw5x/UQbWoqs6TFjd8RYiEpa571wYrJf8PRlT",
|
|
7
|
+
"craba/zip2.js": "sha384-Fm8dHm4XqM/t509sUp5Pawk2mzuRFZaFmIRW3nZCZPjbYA9gMIFGJ+2YaNrj5Fxw"
|
|
8
|
+
}
|
package/index.js
CHANGED
|
@@ -111,7 +111,8 @@ function checkFast(args) {
|
|
|
111
111
|
|
|
112
112
|
|
|
113
113
|
if (args.includes('-makeHash')) {
|
|
114
|
-
start.
|
|
114
|
+
start.bindConfigByArgv('-files', 'array');
|
|
115
|
+
start.bindConfigByArgv('-exts', 'array');
|
|
115
116
|
start.bindAndCheckConfig('-outJson');
|
|
116
117
|
require('./tool/hash.js').start(); // wps安全改造,工具生成js和css的hash值
|
|
117
118
|
return false;
|
package/lib/server.js
CHANGED
|
@@ -53,6 +53,9 @@ var server = http.createServer(app);
|
|
|
53
53
|
var hostname = '127.0.0.1';
|
|
54
54
|
server.listen(config.port, hostname, () => {
|
|
55
55
|
var url = 'http://127.0.0.1:' + config.port;
|
|
56
|
+
if (config.virtualName) {
|
|
57
|
+
url += "/" + config.virtualName;
|
|
58
|
+
}
|
|
56
59
|
if (config.defaultPage) { // 业务可以自行配置首页
|
|
57
60
|
url += '/' + config.defaultPage;
|
|
58
61
|
} else if (config.modName) { // ngp下面首页是login.html
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "crabatool",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.290",
|
|
4
4
|
"description": "crabatool",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"upload": "node run.js -upload -version master -Debug true -host http://127.0.0.1:9998 -hidejspath true -targetPath F:\\CarpaNET_NEW",
|
|
18
18
|
"crabaNgp": "node run.js -mergejs -hidejspath true -targetPath F:\\CarpaNET_NEW\\src\\Carpa.Web\\js\\crabaNgp -inNames initMs.js,businessControl.js -outName F:\\CarpaMS\\src\\js\\crabaNgp.js",
|
|
19
19
|
"webPath": "node ./test/test.js -checkjs -webhooks 0 -webPath F:\\crabaevery\\www -modName crabaevery",
|
|
20
|
-
"makeHash": "node run.js -makeHash -webPath ./test/ -modName craba -files http://crabadoc.ca.com/js/utils/utils.js,F:/newcrabadoc/www/js/utils/utils.js,./test/test.js,./test/beefun.js,https://s5.vip.wpscdn.cn/web-libs/2t/js/userinfo-collect/1.0.3/vas2t-userinfo-collect.min.js?a=1 -outJson ./hash.json -hashName sha384"
|
|
20
|
+
"makeHash": "node run.js -makeHash -webPath ./test/ -modName craba -files http://crabadoc.ca.com/js/utils/utils.js,F:/newcrabadoc/www/js/utils/utils.js,./test/test.js,./test/beefun.js,https://s5.vip.wpscdn.cn/web-libs/2t/js/userinfo-collect/1.0.3/vas2t-userinfo-collect.min.js?a=1 -outJson ./hash.json -hashName sha384",
|
|
21
|
+
"makeHash2": "node run.js -makeHash -webPath ./test/ -modName craba -files ./test/ -exts .js -outJson ./hash2.json -hashName sha384"
|
|
21
22
|
},
|
|
22
23
|
"author": "wssf",
|
|
23
24
|
"dependencies": {
|
package/tool/hash.js
CHANGED
|
@@ -13,17 +13,46 @@ module.exports.start = function() {
|
|
|
13
13
|
config.hashName = 'sha384';
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
if (!config.files) {
|
|
17
|
+
config.files = [];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var results = {};
|
|
21
|
+
buildFiles(results, config.files);
|
|
22
|
+
|
|
23
|
+
utils.mkdirsSync(config.outJson);
|
|
24
|
+
fs.writeFileSync(config.outJson, JSON.stringify(results));
|
|
25
|
+
}
|
|
19
26
|
|
|
27
|
+
function buildFiles(results, files) {
|
|
28
|
+
files.forEach(function(f) {
|
|
20
29
|
console.log(f);
|
|
30
|
+
|
|
21
31
|
var content;
|
|
22
32
|
var isHttp = f.startsWith('http');
|
|
23
33
|
if (isHttp) {
|
|
24
34
|
var res = requestSync("GET", f);
|
|
25
35
|
content = res.getBody();
|
|
26
36
|
} else if (fs.existsSync(f)) {
|
|
37
|
+
|
|
38
|
+
// 磁盘目录
|
|
39
|
+
var statFs = fs.statSync(f);
|
|
40
|
+
if (!statFs.isFile()) {
|
|
41
|
+
var files2 = fs.readdirSync(f);
|
|
42
|
+
files2 = files2.map(function(s) {
|
|
43
|
+
return utils.join(f, s);
|
|
44
|
+
});
|
|
45
|
+
buildFiles(results, files2);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (config.exts && config.exts.length > 0) {
|
|
50
|
+
var ext = path.extname(f).toLowerCase();
|
|
51
|
+
if (!config.exts.includes(ext)) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
27
56
|
content = fs.readFileSync(f);
|
|
28
57
|
} else {
|
|
29
58
|
console.error('文件不存在:' + f);
|
|
@@ -50,11 +79,8 @@ module.exports.start = function() {
|
|
|
50
79
|
// https://www.srihash.org/
|
|
51
80
|
|
|
52
81
|
var base64 = makeHash(content, config.hashName); // 将文件内容进行hash计算
|
|
53
|
-
|
|
82
|
+
results[f] = config.hashName + '-' + base64; // 使用 base64 编码 sha384 算法计算出摘要后的 integrity 值的示例
|
|
54
83
|
});
|
|
55
|
-
|
|
56
|
-
utils.mkdirsSync(config.outJson);
|
|
57
|
-
fs.writeFileSync(config.outJson, JSON.stringify(hash));
|
|
58
84
|
}
|
|
59
85
|
|
|
60
86
|
function makeHash(str, name) {
|