Replace WebDriver by Puppeteer (#790) (#860)
REFACTOR ---------------- ### 1. Use Chrome Puppeteer to control WebWechat. All codes related with WebDriver/Selenium had been removed. 1. This makes the logic simple: no server, no https endpoint, no WebSocket anymore; 1. Removed lots of Classes, like `PuppetWebServer`, `PuppetWebBrowser`, `PuppetWebBrowserDriver`, `ssl-pem` and `PUppetWebBrowserCookie` ; 1. Removed all the `Xvfb` packages and settings; ### 2. Upgrade CircleCI from v1 to v2. Nothing changed except all the YAML syntax of the CircleCI configuration file. Workflows look very good, maybe set it up later. ### 3. Dockerfile switch from `alpine` to `node:7` image The size increased hugely. However, this will let us feel better if we want to add more and more packages into our Docker Image: Debian has better support to the packaging ecosystem. ### 4. Drop Node.js v6 support No special reasons, it's just tooold. ### 5. Use `blue-tape` to do unit testing, with Typing support. Do not use AVA anymore, do not wait for TAP anymore. They all support TypeScript not well. ### 6. Separate source code related with `watchdog` to a new NPM module. It's modulized very well and can be used as needed everywhere: https://github.com/zixia/watchdog ### 7. Created a new module `RxQueue` for `throttle` / `debounce` / `delay` tasks. Consider publishing a solo NPM module in the future. ### 8. Arrange all the WEB JSON data structure Save them into a single file: `schema.ts` ### 9. A new Class for manage Wechaty Profile Use it to `new Profile('botName')` and `save()`/`load()`/`get()`/`set` etc.
Showing
.circleci/config.yml
0 → 100644
Dockerfile.alpine
0 → 100644
Dockerfile.node
已删除
100644 → 0
bin/xvfb-chromium
已删除
100755 → 0
bin/xvfb-run
已删除
100755 → 0
circle.yml
已删除
100644 → 0
{ | { | ||
"name": "wechaty", | "name": "wechaty", | ||
"version": "0.9.5", | "version": "0.10.1", | ||
"description": "Wechat for Bot(Personal Account)", | "description": "Wechat for Bot(Personal Account)", | ||
"main": "dist/index.js", | "main": "dist/index.js", | ||
"types": "dist/index.d.ts", | "types": "dist/index.d.ts", | ||
"wechaty": { | "wechaty": { | ||
"DEFAULT_HEAD": "chrome", | |||
"DEFAULT_PUPPET": "web", | "DEFAULT_PUPPET": "web", | ||
"DEFAULT_PROFILE": "demo", | "DEFAULT_PROFILE": "demo", | ||
"DEFAULT_PORT": 8788, | |||
"DEFAULT_PROTOCOL": "io|0.0.1", | "DEFAULT_PROTOCOL": "io|0.0.1", | ||
"DEFAULT_TOKEN": "WECHATY_IO_TOKEN", | "DEFAULT_TOKEN": "WECHATY_IO_TOKEN", | ||
"DEFAULT_APIHOST": "api.chatie.io", | "DEFAULT_APIHOST": "api.chatie.io" | ||
"CMD_CHROMIUM": "/wechaty/bin/xvfb-chromium" | |||
}, | }, | ||
"scripts": { | "scripts": { | ||
"ava": "ava --verbose --extension ts", | |||
"ts-node": "ts-node", | "ts-node": "ts-node", | ||
"dist": "npm run clean && tsc && jq \"del (.files)\" < package.json > dist/package.json && shx cp src/puppet-web/*.js dist/src/puppet-web/", | "dist": "npm run clean && tsc && jq \"del (.files)\" < package.json > dist/package.json && shx cp src/puppet-web/*.js dist/src/puppet-web/", | ||
"doc": "npm run dist && echo '# Wechaty v'$(jq -r .version package.json)' Documentation\n' > docs/index.md && jsdoc2md dist/src/{wechaty,room,contact,friend-request,message}.js dist/src/puppet-web/friend-request.js>> docs/index.md", | "doc": "npm run dist && echo '# Wechaty v'$(jq -r .version package.json)' Documentation\n' > docs/index.md && jsdoc2md dist/src/{wechaty,room,contact,friend-request,message}.js dist/src/puppet-web/friend-request.js>> docs/index.md", | ||
... | @@ -23,25 +19,18 @@ | ... | @@ -23,25 +19,18 @@ |
"changelog": "github_changelog_generator -u chatie -p wechaty && sed -i'.bak' /greenkeeper/d CHANGELOG.md && ts-node script/sort-contributiveness.ts < CHANGELOG.md > CHANGELOG.new.md && cat CHANGELOG.md >> CHANGELOG.new.md && mv CHANGELOG.new.md CHANGELOG.md", | "changelog": "github_changelog_generator -u chatie -p wechaty && sed -i'.bak' /greenkeeper/d CHANGELOG.md && ts-node script/sort-contributiveness.ts < CHANGELOG.md > CHANGELOG.new.md && cat CHANGELOG.md >> CHANGELOG.new.md && mv CHANGELOG.new.md CHANGELOG.md", | ||
"doctor": "npm run check-node-version && ts-node bin/doctor", | "doctor": "npm run check-node-version && ts-node bin/doctor", | ||
"clean": "shx rm -fr dist/*", | "clean": "shx rm -fr dist/*", | ||
"check-node-version": "check-node-version --node \">= 6.9\"", | "check-node-version": "check-node-version --node \">= 7\"", | ||
"lint": "npm run clean && npm run check-node-version && npm run lint:es && npm run lint:ts", | "lint": "npm run check-node-version && npm run lint:ts && npm run lint:es && npm run lint:sh", | ||
"lint:es": "eslint \"{bin,example,src,test}/**/*.js\" --ignore-pattern=\"test/fixture/**\"", | "lint:es": "eslint \"{bin,example,src,test}/**/*.js\" --ignore-pattern=\"test/fixture/**\"", | ||
"lint:ts": "tslint --version && tslint --project tsconfig.json --type-check \"{bin,example,src,test}/**/*.ts\" --exclude \"test/fixture/**\" --exclude \"dist/\" && npm run clean && tsc --noEmit", | "lint:ts": "npm run clean && echo tslint v`tslint --version` && tslint --project tsconfig.json --type-check \"{bin,example,src,test}/**/*.ts\" --exclude \"test/fixture/**\" --exclude \"dist/\" && tsc --noEmit", | ||
"lint:sh": "bash -n bin/*.sh", | "lint:sh": "bash -n bin/*.sh", | ||
"nycava": "WECHATY_HEAD=chrome nyc ava --serial --fail-fast --verbose --timeout=5m \"dist/{src,test}/**/*.spec.js\"", | |||
"pretest": "npm run clean && npm run lint && npm run dist", | |||
"sloc": "sloc bin example src test index.ts --details --format cli-table --keys total,source,comment && sloc bin example src test index.ts", | "sloc": "sloc bin example src test index.ts --details --format cli-table --keys total,source,comment && sloc bin example src test index.ts", | ||
"test": "npm run test:chrome", | "pretest": "npm run clean && npm run lint", | ||
"posttest": "npm run clean && npm run sloc", | "test": "blue-tape -r ts-node/register -r source-map-support/register \"src/**/*.spec.ts\" \"tests/**/*.spec.ts\"", | ||
"test:chrome": "cross-env LC_ALL=C WECHATY_HEAD=chrome ava --serial --fail-fast --verbose --timeout=5m \"dist/{src,test}/**/*.spec.js\"", | "posttest": "npm run sloc", | ||
"test:bug": "cross-env LC_ALL=C WECHATY_HEAD=chrome WECHATY_LOG=silly ava --serial --fail-fast --verbose --timeout=5m \"dist/src/message.spec.js\"", | "test:linux": "npm run pretest && parallel ts-node -- ./src/**/*.spec.ts ./test/**/*.spec.ts && npm run posttest", | ||
"test:chrome:fast": "cross-env LC_ALL=C WECHATY_HEAD=chrome ava --concurrency 5 --fail-fast --timeout=5m \"dist/{src,test}/**/*.spec.js\"", | "test:npm": "npm run dist && export TMPDIR=/tmp/wechaty.$$ && npm pack && mkdir $TMPDIR && mv wechaty-*.*.*.tgz $TMPDIR && cp test/fixture/smoke-testing.js $TMPDIR && cd $TMPDIR && npm init -y && npm i wechaty-*.*.*.tgz && node smoke-testing.js", | ||
"testdev": "cross-env LC_ALL=C WECHATY_LOG=silly ava --ext ts --serial --verbose --fail-fast --timeout=2m", | |||
"testdist": "cross-env WECHATY_LOG=SILLY WECHATY_HEAD=chrome ava --ext ts --verbose --fail-fast --timeout=2m", | |||
"test:pack": "npm run dist && rm -fr package wechaty-*.*.*.tgz && npm pack --verbose && tar zxvf wechaty-*.*.*.tgz", | |||
"test:npm": "export TMPDIR=/tmp/wechaty.$$ && npm pack && mkdir $TMPDIR && mv wechaty-*.*.*.tgz $TMPDIR && cp test/fixture/smoke-testing.js $TMPDIR && cd $TMPDIR && npm init -y && npm i wechaty-*.*.*.tgz && node smoke-testing.js", | |||
"io-client": "ts-node bin/io-client", | "io-client": "ts-node bin/io-client", | ||
"dev": "ts-node dev.ts", | |||
"demo": "ts-node example/ding-dong-bot.ts", | "demo": "ts-node example/ding-dong-bot.ts", | ||
"start": "npm run demo" | "start": "npm run demo" | ||
}, | }, | ||
... | @@ -83,67 +72,58 @@ | ... | @@ -83,67 +72,58 @@ |
"node": true, | "node": true, | ||
"es6": true | "es6": true | ||
}, | }, | ||
"plugins": [ | |||
"ava" | |||
], | |||
"parser": "babel-eslint", | "parser": "babel-eslint", | ||
"parserOptions": { | "parserOptions": { | ||
"ecmaVersion": 7, | "ecmaVersion": 7, | ||
"sourceType": "module", | "sourceType": "module", | ||
"ecmaFeatures": { | "ecmaFeatures": { | ||
"impliedStrict": true | "impliedStrict": true | ||
}, | } | ||
"extends": "plugin:ava/recommended" | |||
} | } | ||
}, | }, | ||
"ava": { | |||
"require": [ | |||
"ts-node/register" | |||
] | |||
}, | |||
"engines": { | "engines": { | ||
"node": ">= 6.9.0" | "node": ">= 7" | ||
}, | }, | ||
"dependencies": { | "dependencies": { | ||
"@types/express": "4.0.37", | |||
"@types/node": "8.0.33", | "@types/node": "8.0.33", | ||
"@types/ws": "3.2.0", | "@types/ws": "3.2.0", | ||
"bl": "1.2.1", | "bl": "1.2.1", | ||
"body-parser": "1.18.2", | "body-parser": "1.18.2", | ||
"brolog": "1.2.8", | "brolog": "1.2.8", | ||
"chromedriver": "2.33.0", | |||
"express": "4.15.2", | |||
"hot-import": "0.1.21", | "hot-import": "0.1.21", | ||
"ps-tree": "1.1.0", | "puppeteer": "0.11.0", | ||
"raven": "2.2.1", | "raven": "2.2.1", | ||
"request": "2.83.0", | "request": "2.83.0", | ||
"retry-promise": "1.0.0", | "retry-promise": "1.0.0", | ||
"selenium-webdriver": "3.6.0", | "rxjs": "^5.4.3", | ||
"state-switch": "0.1.13", | "state-switch": "0.1.13", | ||
"ws": "3.2.0", | "ws": "3.2.0", | ||
"xml2js": "0.4.19" | "xml2js": "0.4.19" | ||
}, | }, | ||
"devDependencies": { | "devDependencies": { | ||
"@types/blue-tape": "^0.1.31", | |||
"@types/body-parser": "1.16.5", | "@types/body-parser": "1.16.5", | ||
"@types/express": "4.0.37", | |||
"@types/fluent-ffmpeg": "2.1.4", | "@types/fluent-ffmpeg": "2.1.4", | ||
"@types/glob": "5.0.33", | "@types/glob": "5.0.33", | ||
"@types/mime": "2.0.0", | "@types/mime": "2.0.0", | ||
"@types/puppeteer": "0.10.1", | |||
"@types/raven": "2.1.2", | "@types/raven": "2.1.2", | ||
"@types/request": "2.0.4", | "@types/request": "2.0.4", | ||
"@types/selenium-webdriver": "3.0.7", | |||
"@types/sinon": "2.3.5", | "@types/sinon": "2.3.5", | ||
"@types/xml2js": "0.4.0", | "@types/xml2js": "0.4.0", | ||
"apiai": "4.0.3", | "apiai": "4.0.3", | ||
"ava": "0.22.0", | |||
"babel-cli": "6.26.0", | "babel-cli": "6.26.0", | ||
"babel-eslint": "8.0.1", | "babel-eslint": "8.0.1", | ||
"babel-preset-es2015": "6.24.1", | "babel-preset-env": "^1.6.0", | ||
"blue-tape": "^1.0.0", | |||
"body-parser": "1.18.2", | |||
"check-node-version": "2.1.0", | "check-node-version": "2.1.0", | ||
"cookie-parser": "1.4.3", | "cookie-parser": "1.4.3", | ||
"coveralls": "3.0.0", | "coveralls": "3.0.0", | ||
"cross-env": "5.0.5", | "cross-env": "5.0.5", | ||
"eslint": "4.8.0", | "eslint": "4.8.0", | ||
"eslint-plugin-ava": "4.2.2", | "express": "4.15.2", | ||
"finis": "0.0.2", | "finis": "0.0.2", | ||
"fluent-ffmpeg": "2.1.2", | "fluent-ffmpeg": "2.1.2", | ||
"glob": "7.1.2", | "glob": "7.1.2", | ||
... | ... |
src/config.spec.ts
100644 → 100755
src/message.spec.ts
100644 → 100755
src/util-lib.spec.ts
→
src/misc.spec.ts
100644 → 100755
src/profile.ts
0 → 100644
src/puppet-web/bridge.spec.ts
100644 → 100755
src/puppet-web/browser.ts
已删除
100644 → 0
src/puppet-web/firer.spec.ts
100644 → 100755
src/puppet-web/friend-request.spec.ts
100644 → 100755
src/puppet-web/index.spec.ts
100644 → 100755
src/puppet-web/schema.ts
0 → 100644
此差异已折叠。
src/puppet-web/server.ts
已删除
100644 → 0
此差异已折叠。
src/puppet-web/ssl-pem.ts
已删除
100644 → 0
src/puppet-web/watchdog.ts
已删除
100644 → 0
此差异已折叠。
src/puppet.spec.ts
100644 → 100755
此差异已折叠。
此差异已折叠。
src/rx-queue.spec.ts
0 → 100755
此差异已折叠。
src/rx-queue.ts
0 → 100644
此差异已折叠。
src/watchrat.spec.ts
0 → 100755
此差异已折叠。
src/watchrat.ts
0 → 100644
此差异已折叠。
此差异已折叠。
test/contact.spec.ts
100644 → 100755
此差异已折叠。
test/docker.spec.ts
已删除
100644 → 0
此差异已折叠。
test/electron.spec.ts
100644 → 100755
此差异已折叠。
test/fixture/inject-file.js
0 → 100644
test/node.spec.ts
100644 → 100755
此差异已折叠。
test/puppet-web/bridge.spec.ts
100644 → 100755
此差异已折叠。
此差异已折叠。
test/puppet-web/event.spec.ts
100644 → 100755
此差异已折叠。
test/puppet-web/puppet-web.spec.ts
100644 → 100755
此差异已折叠。
此差异已折叠。
此差异已折叠。
test/puppeteer.spec.ts
0 → 100755
此差异已折叠。
test/room.spec.ts
100644 → 100755
此差异已折叠。
test/webdriver.spec.ts
已删除
100644 → 0
此差异已折叠。
test/wechaty.spec.ts
100644 → 100755
此差异已折叠。
此差异已折叠。
此差异已折叠。
想要评论请 注册 或 登录