Skip to content

Commit 32b3926

Browse files
author
AceMood
committed
add cadacy
1 parent a524125 commit 32b3926

File tree

8 files changed

+77
-165
lines changed

8 files changed

+77
-165
lines changed

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ branches:
1616
- stable
1717

1818
before_script:
19-
- npm install -g mocha
19+
- npm install -g mocha
20+
- npm install -g istanbul

README.md

+59-111
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ __Miscellaneous__
1515
[![License][license-image]][license-url]
1616
[![maintain][maintain-image]][project-url]
1717

18-
## soi前端工程化工具
18+
## 前端构建工具
1919

2020
<img src="./doc/assets/sloc.png" alt="sloc stats" style="display: inline-block; position: relative; width: 80%; height: auto;" />
2121

@@ -42,145 +42,72 @@ __Miscellaneous__
4242
{
4343
"resource": {
4444
"js": {
45-
"app": {
46-
"uri": "https://fbstatic.com/static/res/5npylXEc+.app.js",
45+
"Backbone": {
46+
"uri": "https://bd.static0.com/dev/static/bb/7fedd6102.backbone.js",
4747
"type": "js",
48-
"path": "src/app/app.js",
49-
"within": [
50-
"p1"
51-
],
52-
"deps": [
53-
"AQJGK",
54-
"zMZ2x",
55-
"T4EMD"
56-
],
57-
"asyncLoaded": [
58-
"tospe"
59-
]
60-
},
61-
"Foo": {
62-
"uri": "https://fbstatic.com/static/res/zRPoJvV3n.class.js",
63-
"type": "js",
64-
"path": "src/es2015/class.js"
65-
},
66-
"react-app": {
67-
"uri": "https://fbstatic.com/static/res/17uDYG2lB.app.js",
68-
"type": "js",
69-
"path": "src/jsx/app.jsx",
48+
"path": "src/bb/backbone.js",
49+
"localPathName": "/static/bb/7fedd6102.backbone.js",
50+
"version": "7fedd6102",
7051
"deps": [
71-
"math"
52+
"underscore",
53+
"jquery"
7254
]
7355
},
74-
"math": {
75-
"uri": "https://fbstatic.com/static/res/Blpsm0bUP.math.js",
76-
"type": "js",
77-
"path": "src/jsx/math.js"
78-
},
79-
"vrcode": {
80-
"uri": "https://fbstatic.com/static/res/YAun8+H3+.vrcode.js",
56+
"jquery": {
57+
"uri": "https://bd.static0.com/dev/static/bb/5cd353a52.jquery.js",
8158
"type": "js",
82-
"path": "src/js/vrcode.js"
59+
"path": "src/bb/jquery.js",
60+
"localPathName": "/static/bb/5cd353a52.jquery.js",
61+
"version": "5cd353a52"
8362
},
84-
"base": {
85-
"uri": "https://fbstatic.com/static/res/ey9TqfIYO.withId.js",
63+
"underscore": {
64+
"uri": "https://bd.static0.com/dev/static/bb/71b05f21b.underscore.js",
8665
"type": "js",
87-
"path": "src/js/withId.js"
88-
},
89-
"AQJGK": {
90-
"uri": "https://fbstatic.com/static/res/MeDp4uPtR.moduleA.js",
91-
"type": "js",
92-
"path": "src/app/moduleA.js",
93-
"within": [
94-
"p1"
95-
],
96-
"css": [
97-
"a5tlT"
98-
]
99-
},
100-
"zMZ2x": {
101-
"uri": "https://fbstatic.com/static/res/KCwSmYCgZ.moduleB.js",
102-
"type": "js",
103-
"path": "src/app/moduleB.js",
104-
"within": [
105-
"p1"
106-
],
107-
"deps": [
108-
"AQJGK"
109-
]
66+
"path": "src/bb/underscore.js",
67+
"localPathName": "/static/bb/71b05f21b.underscore.js",
68+
"version": "71b05f21b"
11069
}
11170
},
11271
"css": {
113-
"reset-style": {
114-
"uri": "https://fbstatic.com/static/res/Vm87C6yZl.reset.css",
72+
"icon-style": {
73+
"uri": "https://bd.static0.com/dev/static/css/82e2712e8.font.css",
11574
"type": "css",
116-
"path": "src/css/reset.css",
75+
"path": "src/css/font.css",
76+
"localPathName": "/static/css/82e2712e8.font.css",
77+
"version": "82e2712e8",
11778
"within": [
11879
"p0"
11980
]
12081
},
121-
"main": {
122-
"uri": "https://fbstatic.com/static/res/g69kHLSo2.withId.css",
82+
"reset-style": {
83+
"uri": "https://bd.static0.com/dev/static/css/566f3b0ba.reset.css",
12384
"type": "css",
124-
"path": "src/css/withId.css",
85+
"path": "src/css/reset.css",
86+
"localPathName": "/static/css/566f3b0ba.reset.css",
87+
"version": "566f3b0ba",
12588
"within": [
12689
"p0"
12790
]
12891
},
129-
"a5tlT": {
130-
"uri": "https://fbstatic.com/static/res/ISzUrzbxo.moduleA.css",
131-
"type": "css",
132-
"path": "src/app/moduleA.css"
133-
},
134-
"YG9FV": {
135-
"uri": "https://fbstatic.com/static/res/47bCoH0Nq.inlineImage.css",
92+
"main": {
93+
"uri": "https://bd.static0.com/dev/static/css/31d9b6967.withId.css",
13694
"type": "css",
137-
"path": "src/css/inlineImage.css",
95+
"path": "src/css/withId.css",
96+
"localPathName": "/static/css/31d9b6967.withId.css",
97+
"version": "31d9b6967",
13898
"within": [
13999
"p0"
140100
]
141-
},
142-
"JAhPf": {
143-
"uri": "https://fbstatic.com/static/res/ukiiX1OM0.detail.css",
144-
"type": "css",
145-
"path": "src/less/detail.less"
146-
},
147-
"e6fCE": {
148-
"uri": "https://fbstatic.com/static/res/nLFdhtvim.dialog.css",
149-
"type": "css",
150-
"path": "src/less/dialog.less"
151-
},
152-
"zhSrg": {
153-
"type": "css",
154-
"path": "src/less/empty.less"
155-
},
156-
"UVPXf": {
157-
"uri": "https://fbstatic.com/static/res/tEUjsrWyA.import.css",
158-
"type": "css",
159-
"path": "src/less/import.less"
160101
}
161102
}
162103
},
163104
"paths": {
164-
"src/jsx/module.js": "WlvnF",
165-
"src/js/asyncRequire.js": "dj5Pa",
166-
"src/js/inlineTest.js": "27kaY",
167-
"src/js/entry.js": "sWXOl",
168-
"src/js/noId.js": "fvr+Q",
169-
"src/js/syncRequire.js": "GwHRf",
170-
"src/js/uriTest.js": "XvY+s",
105+
"src/bb/backbone.js": "Backbone",
106+
"src/bb/jquery.js": "jquery",
107+
"src/bb/underscore.js": "underscore",
108+
"src/css/font.css": "icon-style",
171109
"src/css/reset.css": "reset-style",
172-
"src/css/withId.css": "main",
173-
"src/app/moduleA.css": "a5tlT",
174-
"src/css/inlineImage.css": "YG9FV",
175-
"src/css/mangle.css": "+mruT",
176-
"src/css/plain.css": "mFLE6",
177-
"src/less/detail.less": "JAhPf",
178-
"src/less/dialog.less": "e6fCE",
179-
"src/less/empty.less": "zhSrg",
180-
"src/less/import.less": "UVPXf",
181-
"src/less/purecss.less": "J0bO1",
182-
"src/less/shop_list.less": "Dez3f",
183-
"src/less/verify_list.less": "xI2wM"
110+
"src/css/withId.css": "main"
184111
},
185112
"cssClassMap": {}
186113
}
@@ -230,6 +157,27 @@ soi 通过命令行执行操作, 默认当前目录为所要扫描的工程目
230157

231158
### soi.addRule
232159

160+
为多个构建任务添加全局共享的打包路径规则, 例
161+
162+
```
163+
soi.addRule(/src\/(.*)\/(.*)/, {
164+
to : function($0, $1, $2) {
165+
return [domain + '/static', $1, $2].join('/');
166+
}
167+
})
168+
```
169+
会匹配工程目录下路径类似`src/js/jquery.js`的所有资源, 将其线上打包路径设置为`https://s0.db.com/static/js/jquery.js`. addRule的第二个参数也可以为一个字符串配置, 例
170+
171+
```
172+
soi.addRule(/src\/(.*)\/(.*)/, '/static/$1/')
173+
```
174+
175+
注意:
176+
177+
1. task.addRule第二个参数传字符串不用自己拼接domain的设置, soi会自动加上为task设置的domain属性. 但是如果第二个参数传函数就需要自己拼接.
178+
2. task.addRule第二个参数传字符串
179+
180+
233181
### soi.config.get
234182

235183
### soi.config.set

lib/RuleMap.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* The MIT License (MIT)
33
* Copyright (c) 2016 Saber-Team
44
*
5-
* @file 线上路径规则的Map
5+
* @file rule map Class
66
* @author XCB, AceMood
77
*/
88

lib/command/deploy.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* The MIT License (MIT)
33
* Copyright (c) 2016 Saber-Team
44
*
5-
* @file deploy命令
5+
* @file deploy command
66
* @author AceMood
77
*/
88

@@ -27,9 +27,9 @@ exports.execute = function(taskName, argv) {
2727
}
2828

2929
task
30-
// 设置命令行参数
30+
// set command-line arguments
3131
.setArgs({taskName: taskName, argv: argv})
32-
// 应用插件
32+
// apply all plugins
3333
.applyPlugin()
3434
.run();
3535
};

lib/command/install.js

-18
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,6 @@
33
*
44
* Copyright (c) 2016 Saber-Team
55
*
6-
* Permission is hereby granted, free of charge, to any person obtaining a copy
7-
* of this software and associated documentation files (the "Software"), to deal
8-
* in the Software without restriction, including without limitation the rights
9-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10-
* copies of the Software, and to permit persons to whom the Software is
11-
* furnished to do so, subject to the following conditions:
12-
*
13-
* The above copyright notice and this permission notice shall be included in all
14-
* copies or substantial portions of the Software.
15-
*
16-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22-
* SOFTWARE.
23-
*
246
* @file server命令
257
* @author AceMood
268
*/

lib/command/release.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* The MIT License (MIT)
33
* Copyright (c) 2016 Saber-Team
44
*
5-
* @file release命令
5+
* @file release command
66
* @author AceMood
77
*/
88

@@ -27,9 +27,9 @@ exports.execute = function(taskName, argv) {
2727
}
2828

2929
task
30-
// 设置命令行参数
30+
// set command-line arguments
3131
.setArgs({taskName: taskName, argv: argv})
32-
// 应用插件
32+
// apply all plugins
3333
.applyPlugin()
3434
.run();
3535
};

lib/command/server.js

-26
This file was deleted.

package.json

+9-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88
"node": ">= 4.0.0"
99
},
1010
"scripts": {
11-
"test": "mocha --timeout 60000 ./test/**/*-Spec.js"
11+
"test": "mocha --timeout 60000 ./test/**/*-Spec.js",
12+
"cover": "istanbul cover -i ./lib/**/*.js ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/.bin/codacy-coverage && rm -rf ./coverage"
1213
},
14+
"pre-commit": [
15+
"cover"
16+
],
1317
"repository": {
1418
"type": "git",
1519
"url": "https://github.com/Saber-Team/soi.git"
@@ -39,6 +43,9 @@
3943
},
4044
"devDependencies": {
4145
"chai": "^3.5.0",
42-
"mocha": "^2.4.5"
46+
"codacy-coverage": "^2.0.0",
47+
"istanbul": "^0.4.5",
48+
"mocha": "^2.4.5",
49+
"mocha-lcov-reporter": "^1.2.0"
4350
}
4451
}

0 commit comments

Comments
 (0)