Skip to content

Commit 0728987

Browse files
committed
init
1 parent 1d8e5cd commit 0728987

35 files changed

+6756
-0
lines changed

.editorconfig

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Editor configuration, see http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
end_of_line = lf
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
12+
[*.md]
13+
max_line_length = 0
14+
trim_trailing_whitespace = false

.markdownlintrc

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"default": true,
3+
"no-trailing-punctuation": {
4+
"punctuation": ".,;:!"
5+
},
6+
"MD013": false,
7+
"MD033": false,
8+
"first-line-h1": false,
9+
"no-hard-tabs": true,
10+
"no-trailing-spaces": {
11+
"br_spaces": 2
12+
}
13+
}

.travis.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
language: node_js
2+
node_js:
3+
- 10
4+
- 9
5+
6+
os:
7+
- linux
8+
9+
cache:
10+
directories:
11+
- node_modules
12+
13+
script:
14+
- node --version
15+
- npm --version
16+
- echo "Testing Started ..."
17+
- npm test
18+
- echo "Testing Finished."
19+
20+
stages:
21+
- test
22+
- pack
23+
- name: deploy
24+
if: (type = push) AND branch =~ ^(master|v\d+\.\d+)$
25+
26+
jobs:
27+
include:
28+
- stage: pack
29+
script:
30+
- echo "NPM Pack Testing Started ..."
31+
- npm version
32+
- npm run test:pack
33+
- echo "NPM Pack Testing Finished."
34+
35+
- stage: deploy
36+
script:
37+
- echo "NPM Deploying Started ..."
38+
- npm version
39+
- if ./scripts/development-release.ts; then ./scripts/package-publish-config-tag-next.ts; fi
40+
- npm run dist
41+
- echo "NPM Building Finished."
42+
43+
deploy:
44+
provider: npm
45+
46+
api_key: "$NPM_TOKEN"
47+
skip_cleanup: true
48+
on:
49+
all_branches: true
50+
51+
notifications:
52+
webhooks:
53+
urls:
54+
- https://webhooks.gitter.im/e/41a19fbf1d54a04e5217
55+
on_success: always # options: [always|never|change] default: always
56+
on_failure: always # options: [always|never|change] default: always
57+
on_start: never # options: [always|never|change] default: always
58+
email:
59+
on_success: change
60+
on_failure: change

.vscode/settings.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"typescript.tsdk": "./node_modules/typescript/lib"
3+
, "update.channel": "none"
4+
, "files.exclude": {
5+
"dist/": true
6+
, "doc/": true
7+
, "node_modules/": true
8+
, "package/": true
9+
}
10+
, "alignment": {
11+
"operatorPadding": "right"
12+
, "indentBase": "firstline"
13+
, "surroundSpace": {
14+
"colon": [1, 1], // The first number specify how much space to add to the left, can be negative. The second number is how much space to the right, can be negative.
15+
"assignment": [1, 1], // The same as above.
16+
"arrow": [1, 1], // The same as above.
17+
"comment": 2 // Special how much space to add between the trailing comment and the code.
18+
// If this value is negative, it means don't align the trailing comment.
19+
}
20+
}
21+
, "eslint.autoFixOnSave": false
22+
, "tslint.autoFixOnSave": false
23+
, "editor.formatOnSave": false
24+
, "typescript.extension.sortImports.sortOnSave": false
25+
}

docs/images/puppeteer-logo.png

20.7 KB
Loading

package.json

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
{
2+
"name": "wechaty-puppet-puppeteer",
3+
"version": "0.0.2",
4+
"description": "Puppet Puppeteer for Wechaty",
5+
"main": "dist/src/index.js",
6+
"typings": "dist/src/index.d.ts",
7+
"engines": {
8+
"wechaty": ">=0.17.46"
9+
},
10+
"scripts": {
11+
"clean": "shx rm -fr dist/*",
12+
"dist": "npm run clean && tsc",
13+
"pack": "npm pack",
14+
"lint": "npm run lint:ts && npm run lint:md",
15+
"lint:md": "markdownlint README.md",
16+
"lint:ts": "tslint --project tsconfig.json && tsc --noEmit",
17+
"test": "npm run lint && npm run test:unit",
18+
"test:pack": "bash -x scripts/npm-pack-testing.sh",
19+
"test:unit": "blue-tape -r ts-node/register \"src/**/*.spec.ts\" \"src/*.spec.ts\" \"tests/*.spec.ts\" \"tests/**/*.spec.ts\""
20+
},
21+
"repository": {
22+
"type": "git",
23+
"url": "git+https://github.com/Chatie/wechaty-puppet-puppeteer.git"
24+
},
25+
"keywords": [
26+
"chatie",
27+
"wechaty",
28+
"wechat",
29+
"chatbot",
30+
"bot",
31+
"sdk",
32+
"puppet",
33+
"weixin"
34+
],
35+
"author": "Huan LI <[email protected]>",
36+
"license": "Apache-2.0",
37+
"bugs": {
38+
"url": "https://github.com/Chatie/wechaty-puppet-puppeteer/issues"
39+
},
40+
"devDependencies": {
41+
"@types/bl": "^0.8.32",
42+
"@types/blue-tape": "^0.1.31",
43+
"@types/lru-cache": "^4.1.1",
44+
"@types/md5": "^2.1.32",
45+
"@types/mime": "^2.0.0",
46+
"@types/node": "^10.3.6",
47+
"@types/normalize-package-data": "^2.4.0",
48+
"@types/promise-retry": "^1.1.2",
49+
"@types/puppeteer": "^1.5.0",
50+
"@types/qr-image": "^3.2.1",
51+
"@types/raven": "^2.5.1",
52+
"@types/read-pkg-up": "^3.0.1",
53+
"@types/request": "^2.47.1",
54+
"@types/semver": "^5.5.0",
55+
"@types/sinon": "^5.0.1",
56+
"@types/xml2json": "^0.10.0",
57+
"blue-tape": "^1.0.0",
58+
"brolog": "^1.6.5",
59+
"clone-class": "^0.6.19",
60+
"file-box": "^0.8.22",
61+
"git-scripts": "^0.2.1",
62+
"hot-import": "^0.2.1",
63+
"lru-cache": "^4.1.3",
64+
"markdownlint-cli": "^0.10.0",
65+
"memory-card": "^0.2.0",
66+
"normalize-package-data": "^2.4.0",
67+
"promise-retry": "^1.1.1",
68+
"qr-image": "^3.2.0",
69+
"read-pkg-up": "^4.0.0",
70+
"semver": "^5.5.0",
71+
"shx": "^0.3.1",
72+
"sinon": "^6.0.1",
73+
"sinon-test": "^2.2.0",
74+
"state-switch": "^0.6.2",
75+
"ts-node": "^7.0.0",
76+
"tslint": "^5.10.0",
77+
"tslint-config-standard": "^7.1.0",
78+
"typescript": "^2.9.2",
79+
"watchdog": "^0.8.10",
80+
"wechaty": "^0.17.56",
81+
"wechaty-puppet": "0.2.3"
82+
},
83+
"git": {
84+
"scripts": {
85+
"pre-push": "./scripts/pre-push.sh"
86+
}
87+
},
88+
"peerDependencies": {
89+
"brolog": "^1.6.5",
90+
"file-box": "^0.8.22",
91+
"hot-import": "^0.2.1",
92+
"lru-cache": "^4.1.3",
93+
"normalize-package-data": "^2.4.0",
94+
"qr-image": "^3.2.0",
95+
"promise-retry": "^1.1.1",
96+
"read-pkg-up": "^4.0.0",
97+
"state-switch": "^0.6.2",
98+
"watchdog": "^0.8.10",
99+
"wechaty-puppet": "0.2.3"
100+
},
101+
"homepage": "https://github.com/Chatie/wechaty-puppet-puppeteer#readme",
102+
"dependencies": {
103+
"bl": "^2.0.1",
104+
"md5": "^2.2.1",
105+
"mime": "^2.3.1",
106+
"puppeteer": "^1.5.0",
107+
"request": "^2.87.0",
108+
"rx-queue": "^0.4.26",
109+
"xml2json": "^0.11.2"
110+
}
111+
}

scripts/development-release.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env ts-node
2+
3+
// tslint:disable:no-console
4+
// tslint:disable:no-var-requires
5+
6+
import { minor } from 'semver'
7+
8+
const { version } = require('../package.json')
9+
10+
if (minor(version) % 2 === 0) { // production release
11+
console.log(`${version} is production release`)
12+
process.exit(1) // exit 1 for not development
13+
}
14+
15+
// development release
16+
console.log(`${version} is development release`)
17+
process.exit(0)

scripts/npm-pack-testing.sh

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
npm run dist
5+
npm run pack
6+
7+
TMPDIR="/tmp/npm-pack-testing.$$"
8+
mkdir "$TMPDIR"
9+
mv *-*.*.*.tgz "$TMPDIR"
10+
cp tests/fixtures/smoke-testing.ts "$TMPDIR"
11+
12+
cd $TMPDIR
13+
npm init -y
14+
npm install *-*.*.*.tgz \
15+
@types/lru-cache \
16+
@types/node \
17+
@types/normalize-package-data \
18+
@types/promise-retry \
19+
brolog \
20+
file-box \
21+
hot-import \
22+
lru-cache \
23+
memory-card \
24+
normalize-package-data \
25+
state-switch \
26+
typescript \
27+
wechaty-puppet \
28+
wechat4u \
29+
qr-image \
30+
promise-retry \
31+
watchdog \
32+
33+
./node_modules/.bin/tsc \
34+
--esModuleInterop \
35+
--lib esnext \
36+
--noEmitOnError \
37+
--noImplicitAny \
38+
--target es6 \
39+
--module commonjs \
40+
smoke-testing.ts
41+
42+
node smoke-testing.js
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env ts-node
2+
3+
// tslint:disable:no-console
4+
// tslint:disable:no-var-requires
5+
6+
import * as fs from 'fs'
7+
import * as path from 'path'
8+
9+
const PACKAGE_JSON = path.join(__dirname, '../package.json')
10+
11+
const pkg = require(PACKAGE_JSON)
12+
13+
pkg.publishConfig = {
14+
access: 'public',
15+
...pkg.publishConfig,
16+
tag: 'next',
17+
}
18+
19+
fs.writeFileSync(PACKAGE_JSON, JSON.stringify(pkg, null, 2))
20+
// console.log(JSON.stringify(pkg, null, 2))
21+
22+
console.log('set package.json:publicConfig.tag to next.')

scripts/pre-push.sh

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
#
3+
# An example hook script to verify what is about to be committed.
4+
# Called by "git commit" with no arguments. The hook should
5+
# exit with non-zero status after issuing an appropriate message if
6+
# it wants to stop the commit.
7+
#
8+
# To enable this hook, rename this file to "pre-commit".
9+
set -e
10+
11+
[ -n "$NO_HOOK" ] && exit 0
12+
13+
[ -n "$HUAN_INNER_PRE_HOOK" ] && {
14+
# http://stackoverflow.com/a/21334985/1123955
15+
exit 0
16+
}
17+
18+
npm run lint
19+
20+
[ -z "$CYGWIN" ] && {
21+
# git rebase
22+
rm -f package-lock.json
23+
npm version patch --no-package-lock
24+
HUAN_INNER_PRE_HOOK=1 git push
25+
26+
cat <<'_STR_'
27+
____ _ _ ____ _
28+
/ ___(_) |_ | _ \ _ _ ___| |__
29+
| | _| | __| | |_) | | | / __| '_ \
30+
| |_| | | |_ | __/| |_| \__ \ | | |
31+
\____|_|\__| |_| \__,_|___/_| |_|
32+
33+
____ _ _
34+
/ ___| _ _ ___ ___ ___ ___ __| | |
35+
\___ \| | | |/ __/ __/ _ \/ _ \/ _` | |
36+
___) | |_| | (_| (_| __/ __/ (_| |_|
37+
|____/ \__,_|\___\___\___|\___|\__,_(_)
38+
39+
_STR_
40+
41+
echo
42+
echo
43+
echo
44+
echo " ### Npm verion bumped and pushed by inner push inside hook pre-push ###"
45+
echo " ------- vvvvvvv outer push will be canceled, never mind vvvvvvv -------"
46+
echo
47+
echo
48+
echo
49+
exit 127
50+
}
51+
52+
# must run this after the above `test` ([ -z ...]),
53+
# or will whow a error: error: failed to push some refs to '[email protected]:Chatie/wechaty.git'
54+
echo "PRE-PUSH HOOK PASSED"
55+
echo
56+

0 commit comments

Comments
 (0)