Skip to content

Commit ee86d91

Browse files
committed
ci: remove grunt
and some cleanups
1 parent 263f99a commit ee86d91

File tree

8 files changed

+113
-207
lines changed

8 files changed

+113
-207
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ env:
1010
- EXSITING_ROOM_ID=5638313660b28815a724df31
1111
- SYS_CONV_ID=57bdb5965e1072004edd532c
1212
install:
13-
- npm install grunt-cli codecov -g
13+
- npm install codecov -g
1414
- npm install
1515
script:
1616
- npm test && codecov

Gruntfile.js

-87
This file was deleted.

README.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ npm install leancloud-realtime@3 --save
7777

7878
0. Fork 这个项目,clone 到本地
7979
1. 在目录中执行 `npm install` 安装所需 Node.js 依赖包
80-
1. 执行 `grunt dev` 浏览器打开 [](http://localhost:8000) 本地进行调试
8180
1. 编码,更新测试用例
8281
1. 运行 `npm test` 确保测试全部 pass
8382
1. 提交改动,请遵循 [conversational commit message 风格](http://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html)
@@ -173,10 +172,7 @@ npm run test:node -- --grep KEYWORDS
173172
浏览器测试
174173

175174
```
176-
# 在当前目录启动一个静态 server
177-
# static . -p 8000
178-
npm run test:browser
179-
# open http://localhost:8000/test/browser/
175+
npm run test:browser-local
180176
```
181177

182178
生成 dist/realtime.\*

karma-sauce.conf.js

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
module.exports = config => {
2+
const customLaunchers = {
3+
sl_chrome: {
4+
base: 'SauceLabs',
5+
browserName: 'chrome',
6+
version: '45',
7+
},
8+
sl_ios_safari: {
9+
base: 'SauceLabs',
10+
browserName: 'iPhone',
11+
version: '9.3',
12+
},
13+
};
14+
15+
config.set({
16+
// base path that will be used to resolve all patterns (eg. files, exclude)
17+
basePath: '',
18+
19+
// frameworks to use
20+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
21+
frameworks: ['mocha'],
22+
23+
client: {
24+
mocha: {
25+
ui: 'bdd',
26+
timeout: 30000,
27+
},
28+
},
29+
30+
// list of files / patterns to load in the browser
31+
files: ['test/browser/index.js'],
32+
33+
// list of files / patterns to exclude
34+
exclude: [],
35+
36+
// preprocess matching files before serving them to the browser
37+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
38+
preprocessors: {},
39+
40+
// test results reporter to use
41+
// possible values: 'dots', 'progress'
42+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
43+
reporters: ['dots', 'saucelabs'],
44+
45+
// web server port
46+
port: 9876,
47+
48+
// enable / disable colors in the output (reporters and logs)
49+
colors: true,
50+
51+
// level of logging
52+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
53+
logLevel: config.LOG_INFO,
54+
55+
// enable / disable watching file and executing tests whenever any file changes
56+
autoWatch: false,
57+
58+
sauceLabs: {
59+
testName: `LeanCloud Realtime SDK Test #${(
60+
process.env.TRAVIS_COMMIT || ''
61+
).slice(0, 7)}`,
62+
recordVideo: true,
63+
connectOptions: {
64+
noSslBumpDomains: 'all',
65+
logfile: 'sauce_connect.log',
66+
},
67+
},
68+
customLaunchers,
69+
captureTimeout: 480000,
70+
browserNoActivityTimeout: 120000,
71+
72+
// start these browsers
73+
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
74+
browsers: Object.keys(customLaunchers),
75+
76+
// Continuous Integration mode
77+
// if true, Karma captures browsers, runs the tests and exits
78+
singleRun: true,
79+
80+
// Concurrency level
81+
// how many browser should be started simultaneous
82+
concurrency: 1,
83+
});
84+
};

karma.conf.js

+3-40
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,4 @@
1-
// Karma configuration
2-
// Generated on Fri Apr 13 2018 13:53:08 GMT+0800 (CST)
3-
41
module.exports = config => {
5-
const customLaunchers = {
6-
sl_chrome: {
7-
base: 'SauceLabs',
8-
browserName: 'chrome',
9-
version: '45',
10-
},
11-
sl_ios_safari: {
12-
base: 'SauceLabs',
13-
browserName: 'iPhone',
14-
version: '9.3',
15-
},
16-
};
17-
182
config.set({
193
// base path that will be used to resolve all patterns (eg. files, exclude)
204
basePath: '',
@@ -23,13 +7,6 @@ module.exports = config => {
237
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
248
frameworks: ['mocha'],
259

26-
client: {
27-
mocha: {
28-
ui: 'bdd',
29-
timeout: 30000,
30-
},
31-
},
32-
3310
// list of files / patterns to load in the browser
3411
files: ['test/browser/index.js'],
3512

@@ -43,7 +20,7 @@ module.exports = config => {
4320
// test results reporter to use
4421
// possible values: 'dots', 'progress'
4522
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
46-
reporters: ['progress', 'saucelabs'],
23+
reporters: ['dots'],
4724

4825
// web server port
4926
port: 9876,
@@ -58,30 +35,16 @@ module.exports = config => {
5835
// enable / disable watching file and executing tests whenever any file changes
5936
autoWatch: false,
6037

61-
sauceLabs: {
62-
testName: `LeanCloud Realtime SDK Test #${(
63-
process.env.TRAVIS_COMMIT || ''
64-
).slice(0, 7)}`,
65-
recordVideo: true,
66-
connectOptions: {
67-
noSslBumpDomains: 'all',
68-
logfile: 'sauce_connect.log',
69-
},
70-
},
71-
customLaunchers,
72-
captureTimeout: 480000,
73-
browserNoActivityTimeout: 120000,
74-
7538
// start these browsers
7639
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
77-
browsers: Object.keys(customLaunchers),
40+
browsers: ['Chrome'],
7841

7942
// Continuous Integration mode
8043
// if true, Karma captures browsers, runs the tests and exits
8144
singleRun: true,
8245

8346
// Concurrency level
8447
// how many browser should be started simultaneous
85-
concurrency: 1,
48+
concurrency: Infinity,
8649
});
8750
};

package.json

+4-6
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
"npm run lint && npm run build && npm run docs && npm run test:node && npm run test:browser",
1717
"test:node":
1818
"NODE_ENV=test nyc mocha --timeout 30000 test/index.js plugins/**/test/index.js --exit",
19-
"test:browser": "npm run build:test && karma start",
19+
"test:browser":
20+
"if [ ! -z \"$SAUCE_ACCESS_KEY\" ]; then npm run build:test && karma start karma-sauce.conf.js; else echo 'Saucelabs test skipped, set SAUCE_USERNAME and SAUCE_ACCESS_KEY to start it.\n\rTo run browser tests locally, run `npm run test:browser-local`'; fi",
21+
"test:browser-local": "npm run build:test && karma start",
2022
"docs":
2123
"jsdoc src README.md package.json -d docs -c .jsdocrc.json && jsdoc plugins/typed-messages/src plugins/typed-messages/package.json src/messages/message.js src/messages/typed-message.js -d plugins/typed-messages/docs -c .jsdocrc.json && jsdoc plugins/webrtc/src plugins/webrtc/package.json -d plugins/webrtc/docs -c .jsdocrc.json && jsdoc plugins/groupchat-receipts/src plugins/groupchat-receipts/package.json -d plugins/groupchat-receipts/docs -c .jsdocrc.json",
2224
"build":
23-
"npm run build:realtime && npm run build:plugins && grunt validate-es5 --stack",
25+
"npm run build:realtime && npm run build:plugins && ./script/validate-es5.js",
2426
"build:realtime": "rollup -c rollup/rollup.config.realtime.js",
2527
"build:plugins": "rollup -c rollup/rollup.config.plugins.js",
2628
"build:test": "rollup -c rollup/rollup.config.test.js",
@@ -58,9 +60,6 @@
5860
"eslint-config-prettier": "^2.9.0",
5961
"eslint-plugin-import": "^2.0.0",
6062
"espree": "^3.1.4",
61-
"grunt": "^1.0.1",
62-
"grunt-contrib-connect": "^1.0.0",
63-
"grunt-saucelabs": "^9.0.0",
6463
"husky": "^0.14.3",
6564
"inherit": "^2.2.3",
6665
"jsdoc": "leeyeh/jsdoc#v3.4.0",
@@ -70,7 +69,6 @@
7069
"karma-mocha": "^1.3.0",
7170
"karma-sauce-launcher": "^1.2.0",
7271
"leancloud-storage": "^3.0.0",
73-
"load-grunt-tasks": "^3.4.1",
7472
"mocha": "^5.0.0",
7573
"nyc": "^11.2.1",
7674
"prettier": "^1.11.1",

script/validate-es5.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require('fs');
4+
const espree = require('espree');
5+
6+
[
7+
'./plugins/typed-messages/dist/typed-messages.js',
8+
'./plugins/webrtc/dist/webrtc.js',
9+
'./plugins/groupchat-receipts/dist/groupchat-receipts.js',
10+
'./plugins/live-query/dist/live-query.js',
11+
'./dist/realtime.browser.js',
12+
'./dist/realtime.weapp.js',
13+
].forEach(file => {
14+
process.stdout.write(`validate ${file}`);
15+
const code = fs.readFileSync(file);
16+
espree.parse(code, {
17+
ecmaVersion: 5,
18+
});
19+
console.log(' OK');
20+
});

0 commit comments

Comments
 (0)