Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade versions for 2023 #2475

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- windows-latest
- ubuntu-latest
node-version:
- 16
- 18
runs-on: ${{ matrix.os }}

steps:
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
strategy:
matrix:
node-version:
- 16
- 18
steps:
- uses: actions/checkout@v2
- name: Use Node.js 16
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
Expand All @@ -35,8 +35,9 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
name: Use Node.js ${{ matrix.node-version }}
with:
node-version: 16
node-version: ${{ matrix.node-version }}
cache: npm
cache-dependency-path: package.json

Expand All @@ -55,8 +56,9 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
name: Use Node.js ${{ matrix.node-version }}
with:
node-version: 16
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org/
cache: npm
cache-dependency-path: package.json
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RUN apt-get update \
&& apt-get purge --auto-remove \
&& rm -rf /tmp/* /var/lib/apt/lists/*

RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - \
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get update && apt-get install -y --no-install-recommends nodejs \
&& apt-get purge --auto-remove \
&& rm -rf /tmp/* /var/lib/apt/lists/*
Expand Down Expand Up @@ -91,7 +91,7 @@ LABEL \
org.label-schema.version="$DOCKER_TAG" \
org.label-schema.schema-version="$(wechaty-version)" \
org.label-schema.name="Wechaty" \
org.label-schema.description="Wechat for Bot" \
org.label-schema.description="Conversational RPA SDK" \
org.label-schema.usage="https://github.com/wechaty/wechaty/wiki/Docker" \
org.label-schema.url="https://www.chatie.io" \
org.label-schema.vendor="Chatie" \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Docker image for Alpine Linux with latest ShellCheck, a static analysis tool for shell scripts.
# https://hub.docker.com/r/nlknguyen/alpine-shellcheck/
# FROM nlknguyen/alpine-shellcheck
FROM mhart/alpine-node:7
FROM mhart/alpine-node:18
LABEL maintainer="Huan LI <[email protected]>"

RUN apk update && apk upgrade \
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,15 +482,15 @@ This project exists thanks to all the people who contribute. [[Contribute](CONTR

## :sunglasses: Backers

[![Backers on Open Collective](https://opencollective.com/wechaty/backers/badge.svg)](#backers)
![Backers on Open Collective](https://opencollective.com/wechaty/backers/badge.svg)

Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/wechaty#backer)]

[![Open Collective Wechaty](https://opencollective.com/wechaty/backers.svg?width=890)](https://opencollective.com/wechaty#backers)

## :smirk: Sponsors

[![Sponsors on Open Collective](https://opencollective.com/wechaty/sponsors/badge.svg)](#sponsors)
![Sponsors on Open Collective](https://opencollective.com/wechaty/sponsors/badge.svg)

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/wechaty#sponsor)]

Expand Down
42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wechaty",
"version": "1.20.2",
"version": "1.22.0",
"description": "Wechaty is a RPA SDK for Chatbot Makers.",
"type": "module",
"exports": {
Expand Down Expand Up @@ -29,8 +29,8 @@
},
"types": "./dist/esm/src/mods/mod.d.ts",
"engines": {
"node": ">=16",
"npm": ">=7"
"node": ">=18",
"npm": ">=9"
},
"wechaty": {
"DEFAULT_PORT": 8080,
Expand Down Expand Up @@ -110,53 +110,53 @@
"homepage": "https://github.com/wechaty/",
"dependencies": {
"clone-class": "^1.1.1",
"cmd-ts": "^0.10.0",
"cockatiel": "^2.0.2",
"cmd-ts": "^0.12.0",
"cockatiel": "^3.0.0",
"cross-spawn": "^7.0.3",
"dotenv": "^16.0.0",
"dotenv": "^16.0.3",
"file-box": "^1.4.15",
"fp-ts": "^2.11.9",
"fp-ts": "^2.13.1",
"gerror": "^1.0.16",
"get-port": "^6.1.2",
"json-rpc-peer": "^0.17.0",
"memory-card": "^1.1.2",
"open-graph": "^0.2.6",
"rx-queue": "^1.0.5",
"state-switch": "^1.6.3",
"uuid": "^8.3.2",
"wechaty-puppet": "^1.20.1",
"uuid": "^9.0.0",
"wechaty-puppet": "^1.20.2",
"wechaty-puppet-service": "^1.19.8",
"wechaty-puppet-wechat4u": "^1.11.1",
"wechaty-token": "^1.1.1",
"ws": "^8.5.0"
"ws": "^8.12.0"
},
"devDependencies": {
"@chatie/eslint-config": "^1.0.4",
"@chatie/eslint-config": "^1.4.1",
"@chatie/git-scripts": "^0.6.2",
"@chatie/semver": "^0.4.7",
"@chatie/tsconfig": "^4.6.3",
"@swc/core": "^1.2.155",
"@swc/helpers": "^0.3.6",
"@chatie/tsconfig": "^4.9.1",
"@swc/core": "^1.3.27",
"@swc/helpers": "^0.4.14",
"@types/cross-spawn": "^6.0.2",
"@types/dotenv": "^8.2.0",
"@types/glob": "^7.2.0",
"@types/glob": "^8.0.0",
"@types/open-graph": "^0.2.2",
"@types/qrcode-terminal": "^0.12.0",
"@types/raven": "^2.5.4",
"@types/uuid": "^8.3.4",
"@types/ws": "^8.5.3",
"@types/uuid": "^9.0.0",
"@types/ws": "^8.5.4",
"coveralls": "^3.1.1",
"glob": "^7.2.0",
"jsdoc-to-markdown": "^7.1.1",
"glob": "^8.1.0",
"jsdoc-to-markdown": "^8.0.0",
"nyc": "^15.1.0",
"qrcode-terminal": "^0.12.0",
"raven": "^2.6.4",
"regenerator-runtime": "^0.13.9",
"regenerator-runtime": "^0.13.11",
"sloc": "^0.2.1",
"typed-emitter": "^1.5.0-from-event",
"typedoc": "^1.0.0-dev.4 ",
"wechaty-puppet-mock": "^1.18.2",
"wechaty-puppet-padlocal": "^1.11.13"
"wechaty-puppet-padlocal": "^1.20.1"
},
"files": [
"bin/",
Expand Down
2 changes: 1 addition & 1 deletion src/doctor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class Doctor {
public chromedriverVersion (): string {
let version: string
try {
const cmd = spawn('chromedriver', ['--version'])
const cmd = spawn('chromedriver', [ '--version' ])
version = String(cmd.error) || cmd.stdout.toString() || cmd.stderr.toString()
} catch (e) {
version = (e as Error).message
Expand Down
6 changes: 3 additions & 3 deletions src/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ test('Wechaty Plugin uninstaller should be called after wechaty.stop()', async t

test('isWechatyPluginUninstaller()', async t => {
const FIXTURES = [
[undefined, false],
[() => {}, true],
[ undefined, false ],
[ () => {}, true ],
] as const

for (const [uninstaller, expected] of FIXTURES) {
for (const [ uninstaller, expected ] of FIXTURES) {
t.equal(isWechatyPluginUninstaller(uninstaller), expected, `isWechatyPluginUninstaller(${uninstaller}) === ${expected}`)
}
})
25 changes: 13 additions & 12 deletions src/pure-functions/retry-policy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {
Policy,
ExponentialBackoff,
handleAll,
retry,
RetryPolicy,
} from 'cockatiel'
import {
Expand All @@ -15,19 +17,18 @@ import {
const retryPolicy = getRetryPolicy()

function getRetryPolicy (): RetryPolicy {
const policy = Policy
.handleAll()
.retry()
.attempts(3)
.exponential({
/**
* ExponentialBackoff
* https://github.com/connor4312/cockatiel#exponentialbackoff
*/
const policy = retry(handleAll, {
/**
* ExponentialBackoff
* https://github.com/connor4312/cockatiel#exponentialbackoff
*/
backoff: new ExponentialBackoff({
initialDelay : 1000,
maxAttempts : 5,
// maxAttempts : 5,
maxDelay : 10 * 1000,
})
}),
maxAttempts: 3,
})

policy.onRetry(reason => log.silly('wechaty',
'retry-policy getRetryPolicy policy.onRetry() reason: "%s"',
Expand Down
4 changes: 2 additions & 2 deletions src/pure-functions/xml.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ test('unifyEmoji()', async t => {
],
]

ORIGNAL_XML_LIST.forEach(([xmlList, expectedEmojiXml]) => {
ORIGNAL_XML_LIST.forEach(([ xmlList, expectedEmojiXml ]) => {
xmlList.forEach(xml => {
const unifiedXml = unifyEmoji(xml)
t.equal(unifiedXml, expectedEmojiXml, 'should convert the emoji xml to the expected unified xml')
Expand All @@ -106,7 +106,7 @@ test('stripEmoji()', async t => {
],
]

EMOJI_STR.forEach(([emojiStr, expectResult]) => {
EMOJI_STR.forEach(([ emojiStr, expectResult ]) => {
const result = stripEmoji(emojiStr)
t.equal(result, expectResult, 'should strip to the expected str')
})
Expand Down
16 changes: 8 additions & 8 deletions src/user-mixins/validation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ test('validationMixin() valid()', async t => {
interface UserClass extends UserClassImpl {}

const FIXTURES = [
[new UserClassImpl(), true],
[ new UserClassImpl(), true ],
// Invalid things
[{}, false],
[[], false],
[new Map(), false],
[ {}, false ],
[ [], false ],
[ new Map(), false ],
// Object interface
[{ bar: true, foo: true }, true],
[{ bar: true }, false],
[{ foo: true }, false],
[ { bar: true, foo: true }, true ],
[ { bar: true }, false ],
[ { foo: true }, false ],
]

for (const [input, expected] of FIXTURES) {
for (const [ input, expected ] of FIXTURES) {
const valid = expected ? 'valid' : 'invalid'
/* eslint-disable multiline-ternary */
const type = typeof input !== 'object' ? typeof input
Expand Down
2 changes: 1 addition & 1 deletion src/user-modules/contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class ContactMixin extends MixinBase implements SayableSayer {
log.warn('Contact', 'find() got more than 1 result: %d total', contactList.length)
}

for (const [idx, contact] of contactList.entries()) {
for (const [ idx, contact ] of contactList.entries()) {
// use puppet.contactValidate() to confirm double confirm that this contactId is valid.
// https://github.com/wechaty/wechaty-puppet-padchat/issues/64
// https://github.com/wechaty/wechaty/issues/1345
Expand Down
4 changes: 2 additions & 2 deletions src/user-modules/message.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ test('recalled()', async t => {

sandbox.stub(puppet, 'roomMemberList').callsFake(async () => {
await new Promise((resolve) => setImmediate(resolve))
return [EXPECTED_TALKER_CONTACT_ID, EXPECTED_LISTENER_CONTACT_ID]
return [ EXPECTED_TALKER_CONTACT_ID, EXPECTED_LISTENER_CONTACT_ID ]
})

sandbox.stub(puppet, 'contactPayload').callsFake(async (id: string) => {
Expand All @@ -93,7 +93,7 @@ test('recalled()', async t => {

const fakeIdSearcher = async (...args: any[]) => {
await new Promise(setImmediate)
return [args[0].id]
return [ args[0].id ]
}

sandbox.stub(puppet, 'messageSearch').callsFake(fakeIdSearcher)
Expand Down
4 changes: 2 additions & 2 deletions src/user-modules/post.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ test.skip('Post smoke testing', async t => {
t.ok(descendantPost, 'tbw')
}

const [descendantList, _nextPageToken2] = await wechaty.Post.findAll({}, pagination)
const [ descendantList, _nextPageToken2 ] = await wechaty.Post.findAll({}, pagination)
t.ok(descendantList, 'tbw')

for await (const liker of post.taps({ type: PUPPET.types.Tap.Like })) {
t.ok(liker, 'tbw')
}

const [tapList, _nextPageToken3] = await post.tapFind({ type: PUPPET.types.Tap.Like }, pagination)
const [ tapList, _nextPageToken3 ] = await post.tapFind({ type: PUPPET.types.Tap.Like }, pagination)
t.ok(tapList, 'tbw')

await wechaty.stop()
Expand Down