Skip to content

Commit 63c893e

Browse files
committed
feat: 更新package.json,更新test.js,删除public
fix: 补充license feat: 添加travis配置,删除多余代码,增加index转发 fix: 修改nodejs版本 fix: 增强错误处理 fix: 更新travis.yml fix: 调整测试文件位置,增加loader resolve路径以保证能找到文件 fix: update README fix: 去除多余的项目依赖 feat: 增加travis徽标
1 parent 31af928 commit 63c893e

19 files changed

Lines changed: 133 additions & 81 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
node_modules
44
*.log
55
*-lock.json
6-
coverage/
6+
coverage/
7+
test/**/public/

.prettierrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"tabWidth": 4,
3+
"singleQuote": true,
4+
"trailingComma": "es5",
5+
"arrowParens": "always"
6+
}

.travis.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
language: node_js
2+
3+
sudo: false
4+
5+
cache:
6+
apt: true
7+
directories:
8+
- node_modules
9+
10+
node_js: stable #设置相应的版本
11+
12+
install:
13+
- npm install -D #安装builder-webpack3依赖
14+
- cd ./test/template-project
15+
- npm install -D #安装模板项目依赖
16+
17+
script:
18+
- npm test

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![](https://img.shields.io/travis/feflow/builder-webpack3.svg)](https://travis-ci.org/feflow/builder-webpack3)
2+
13
# builder-webpack
24

35

@@ -118,6 +120,12 @@ class pageComponent extends Component {
118120
export default hot(module)(pageComponent)
119121
```
120122

123+
### 测试
124+
125+
1. `git clone`这个用于烟雾测试的[模板项目](https://github.com/feflow/generator-smoking-test)
126+
2. 配置`.travis.yml`,可以参考模板项目[README](https://github.com/feflow/generator-smoking-test)
127+
3.[Travis-ci](https://travis-ci.org/feflow/builder-webpack3)中打开此项目的自动构建
128+
121129
## 版本日志
122130

123131
[版本日志](CHANGELOG.md)

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
"commitmsg": "validate-commit-msg",
88
"commit": "git-cz ",
99
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
10-
"test": "mocha ./test/template-project/test.js"
10+
"test": "node ./test/template-project/index.js"
1111
},
1212
"repository": {
1313
"type": "git",
1414
"url": "https://github.com/iv-web/builder-webpack"
1515
},
16+
"license": "MIT",
1617
"configs": {
1718
"compatibleVersion": ">=0.4.3"
1819
},
@@ -38,13 +39,14 @@
3839
"caniuse-db": "^1.0.30000764",
3940
"clean-webpack-plugin": "^0.1.17",
4041
"css-loader": "^0.28.7",
41-
"less": "^3.8.0",
4242
"express": "^4.16.2",
4343
"file-loader": "^1.1.5",
44+
"glob": "^7.1.3",
4445
"happypack": "^4.0.0",
4546
"html-loader": "^0.5.1",
46-
"less-loader": "^4.1.0",
4747
"html-webpack-inline-source-plugin": "0.0.9",
48+
"less": "^3.8.0",
49+
"less-loader": "^4.1.0",
4850
"node-sass": "^4.9.0",
4951
"osenv": "^0.1.5",
5052
"px2rem-loader": "^0.1.7",

test/index.js

Whitespace-only changes.

test/template-project/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
public/

test/template-project/index.js

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,54 @@
1-
const builder = require('../../lib/index')
1+
const Mocha = require('mocha');
2+
const { exec } = require('child_process');
3+
const path = require('path');
4+
const webpack = require('webpack');
5+
const glob = require('glob-all');
6+
const rimraf = require('rimraf');
27

3-
builder('build')
8+
const startTest = function() {
9+
const mocha = new Mocha({
10+
timeout: '10000ms',
11+
});
12+
13+
process.chdir(__dirname); // 切换到当前template-project,否则找不到feflow.json
14+
const builder = require('../../lib/index');
15+
let prodConfig = builder.prodConfig;
16+
// 修改loader的解析路径,因为没有在travis-ci全局安装feflow,所以需要加入本地路径
17+
prodConfig.resolveLoader.modules = [
18+
'node_modules',
19+
path.resolve(__dirname, '../../node_modules'),
20+
];
21+
22+
// 清除public目录
23+
rimraf('./public', () => {
24+
webpack(prodConfig, (err, stats) => {
25+
if (err) {
26+
console.error('webpack配置错误');
27+
console.error(err.stack || err);
28+
if (err.details) {
29+
console.error(err.details);
30+
}
31+
return;
32+
}
33+
console.log(stats.toString('errors-only'));
34+
console.log('webpack compilation completed')
35+
glob('./test.js', (err, matches) => {
36+
testFile = matches[0];
37+
mocha.addFile(testFile);
38+
mocha.run();
39+
});
40+
});
41+
});
42+
};
43+
44+
startTest();
45+
46+
// exec("npm install -D", (error, stdout, stderr) => {
47+
// if (error) {
48+
// console.error(`exec error: ${error}`);
49+
// return;
50+
// }
51+
// console.log(`模板项目依赖安装情况: ${stdout}`);
52+
// console.log(`模板项目依赖安装提示: ${stderr}`);
53+
54+
// });

test/template-project/package.json

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
"main": "webpack.config.js",
66
"scripts": {
77
"dev": "webpack-dev-server --config webpack.dev.js --progress --colors",
8-
"build": "webpack --config webpack.config.js --env production --progress --colors"
8+
"build": "webpack --config webpack.config.js --env production --progress --colors",
9+
"test": "node ./index.js"
910
},
1011
"dependencies": {
12+
"@material-ui/core": "^3.0.3",
1113
"classnames": "2.2.5",
1214
"eruda": "^1.1.3",
1315
"humps": "*",
1416
"isomorphic-fetch": "2.0.1",
15-
"material-ui": "^1.0.0-beta.38",
1617
"process": "*",
1718
"react": "^16.0.2",
1819
"react-dom": "^16.0.2",
@@ -25,20 +26,10 @@
2526
"redux-thunk": "2.0.1"
2627
},
2728
"devDependencies": {
28-
"babel-loader": "^7.1.2",
29-
"babel-plugin-import": "^1.6.6",
30-
"babel-plugin-transform-decorators-legacy": "^1.3.4",
31-
"babel-preset-es2015": "^6.24.1",
32-
"babel-preset-react": "^6.24.1",
33-
"babel-preset-stage-0": "^6.24.1",
34-
"builder-webpack3": "^0.4.0",
3529
"commitizen": "^2.3.0",
3630
"conventional-changelog-cli": "^1.2.0",
3731
"husky": "^0.13.1",
38-
"node-sass": "^4.7.2",
3932
"validate-commit-msg": "^2.11.1",
40-
"webpack": "^3.8.1",
41-
"webpack-cli": "^3.1.0",
42-
"webpack-dev-server": "^2.9.1"
33+
"webpack": "^3.8.1"
4334
}
4435
}

test/template-project/public/cdn/category/index_a1c1d11f.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)