From c881f86b3e7272d9a7dd89c51e0e71a16044dc92 Mon Sep 17 00:00:00 2001 From: Huan Date: Sat, 18 Sep 2021 23:36:12 +0800 Subject: [PATCH 1/5] ES Modules support --- .eslintrc.js => .eslintrc.cjs | 0 .github/workflows/npm.yml | 30 +++++++++----- examples/ducks.ts | 2 +- package.json | 68 +++++++++++++++++++------------ scripts/generate-package-json.sh | 17 ++++++++ scripts/generate-version.sh | 18 -------- scripts/npm-pack-testing.sh | 47 ++++++++++++++++++--- scripts/update-license.ts | 2 +- src/contrib/counter/actions.ts | 2 +- src/contrib/counter/epics.ts | 2 +- src/contrib/counter/mod.ts | 12 +++--- src/contrib/counter/operations.ts | 2 +- src/contrib/counter/reducers.ts | 2 +- src/contrib/counter/selectors.ts | 2 +- src/contrib/counter/tests.spec.ts | 4 +- src/mod.ts | 6 ++- src/package-json.spec.ts | 10 +++++ src/package-json.ts | 11 +++++ src/version.spec.ts | 28 ------------- src/version.ts | 21 ---------- tests/fixtures/smoke-testing.ts | 8 ++-- tests/integration.spec.ts | 4 +- tsconfig.cjs.json | 7 ++++ tsconfig.json | 4 +- 24 files changed, 173 insertions(+), 136 deletions(-) rename .eslintrc.js => .eslintrc.cjs (100%) create mode 100755 scripts/generate-package-json.sh delete mode 100755 scripts/generate-version.sh create mode 100755 src/package-json.spec.ts create mode 100644 src/package-json.ts delete mode 100644 src/version.spec.ts delete mode 100644 src/version.ts create mode 100644 tsconfig.cjs.json diff --git a/.eslintrc.js b/.eslintrc.cjs similarity index 100% rename from .eslintrc.js rename to .eslintrc.cjs diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml index 25db078..68139ce 100644 --- a/.github/workflows/npm.yml +++ b/.github/workflows/npm.yml @@ -7,16 +7,20 @@ jobs: name: Build strategy: matrix: - os: [ubuntu-latest] - node: [12] + os: + - ubuntu-latest + node: + - 16 runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} + cache: npm + cache-dependency-path: package.json - name: Install Dependencies run: npm install @@ -30,15 +34,17 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2 with: - node-version: 12 + node-version: 16 + cache: npm + cache-dependency-path: package.json - name: Install Dependencies run: npm install - - name: Generate Version - run: ./scripts/generate-version.sh + - name: Generate Package JSON + run: ./scripts/generate-package-json.sh - name: Pack Testing run: ./scripts/npm-pack-testing.sh @@ -52,16 +58,18 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2 with: - node-version: 12 + node-version: 16 registry-url: https://registry.npmjs.org/ + cache: npm + cache-dependency-path: package.json - name: Install Dependencies run: npm install - - name: Generate Version - run: ./scripts/generate-version.sh + - name: Generate Package JSON + run: ./scripts/generate-package-json.sh - name: Set Publish Config run: ./scripts/package-publish-config-tag.sh diff --git a/examples/ducks.ts b/examples/ducks.ts index da40e2c..6ae96c8 100644 --- a/examples/ducks.ts +++ b/examples/ducks.ts @@ -7,7 +7,7 @@ import { Duck as wechatyDuck, } from 'wechaty-redux' -import { Counter as CounterDuck } from '../src/mod' +import { Counter as CounterDuck } from '../src/mod.js' import { PuppetMock, mock, diff --git a/package.json b/package.json index 9b50c95..e64f5b6 100644 --- a/package.json +++ b/package.json @@ -1,25 +1,34 @@ { "name": "wechaty-ducks-contrib", - "version": "0.2.10", + "version": "0.3.0", "description": "Wechaty Ducks Contrib", - "main": "dist/src/mod.js", - "typings": "dist/src/mod.d.ts", - "directories": { - "test": "tests" + "type": "module", + "exports": { + ".": { + "import": "./dist/esm/src/mod.js", + "require": "./dist/cjs/src/mod.js" + } + }, + "typings": "./dist/esm/src/mod.d.ts", + "engines": { + "wechaty": ">=0.69", + "node": ">=14" }, + "scripts": { + "build": "tsc && tsc -p tsconfig.cjs.json", "clean": "shx rm -fr dist/*", - "dist": "npm run clean && tsc", - "example": "ts-node examples/ding-dong-bot.ts", - "pack": "npm pack", - "lint": "npm run lint:es && npm run lint:ts && npm run lint:md", + "dist": "npm-run-all clean build dist:commonjs", + "dist:commonjs": "jq -n \"{ type: \\\"commonjs\\\" }\" > dist/cjs/package.json", + "example": "cross-env NODE_OPTIONS=\"--no-warnings --loader=ts-node/esm\" node examples/ding-dong-bot.ts", + "lint": "npm-run-all lint:es lint:ts lint:md", "lint:md": "markdownlint README.md", - "lint:ts": "tsc --noEmit", + "lint:ts": "tsc --isolatedModules --noEmit", "redux-devtools": "redux-devtools --hostname=localhost --port=8000", - "start": "ts-node --files examples/ducks.ts", - "test": "npm run lint && npm run test:unit", + "start": "cross-env NODE_OPTIONS=\"--no-warnings --loader=ts-node/esm\" node --files examples/ducks.ts", + "test": "npm-run-all lint test:unit", "test:pack": "bash -x scripts/npm-pack-testing.sh", - "test:unit": "blue-tape -r ts-node/register \"src/**/*.spec.ts\" \"src/*.spec.ts\" \"tests/*.spec.ts\" \"tests/**/*.spec.ts\"", + "test:unit": "cross-env NODE_OPTIONS=\"--no-warnings --loader=ts-node/esm\" tap \"src/**/*.spec.ts\" \"tests/**/*.spec.ts\"", "lint:es": "eslint --ignore-pattern tests/fixtures/ '{bin,examples,scripts,src,tests}/**/*.ts'" }, "repository": { @@ -39,31 +48,38 @@ }, "homepage": "/~https://github.com/wechaty/wechaty-ducks-contrib#readme", "devDependencies": { - "@chatie/eslint-config": "^0.12.1", + "@chatie/eslint-config": "^0.14.1", "@chatie/git-scripts": "^0.6.2", "@chatie/semver": "^0.4.7", - "@chatie/tsconfig": "^0.14.1", - "@types/glob": "^7.1.3", - "@types/remote-redux-devtools": "^0.5.4", - "ducks": "^0.10.2", - "glob": "^7.1.6", - "pkg-jq": "^0.2.4", + "@chatie/tsconfig": "^0.20.2", + "@types/glob": "^7.1.4", + "@types/remote-redux-devtools": "^0.5.5", + "glob": "^7.1.7", + "pkg-jq": "^0.2.11", "redux-devtools-cli": "1.0.0-4", "remote-redux-devtools": "^0.5.16", "shx": "^0.3.3", - "tstest": "^0.4.10", + "tstest": "^0.5.16", "utility-types": "^3.10.0", - "wechaty": "^0.60.9", - "wechaty-puppet-mock": "^0.28.2", - "wechaty-redux": "^0.2.17" + "wechaty": "^0.69.54", + "wechaty-puppet-mock": "^0.31.5" }, "peerDependencies": { - "redux": ">=4.0", - "wechaty-redux": ">=0.2" + "ducks": "^0.11.7", + "redux": ">=4.1.1", + "wechaty-redux": ">=0.5.4" }, "dependencies": { "typesafe-actions": "^5.1.0" }, + "files": [ + "bin/", + "dist/", + "src/" + ], + "tap": { + "check-coverage": false + }, "git": { "scripts": { "pre-push": "npx git-scripts-pre-push" diff --git a/scripts/generate-package-json.sh b/scripts/generate-package-json.sh new file mode 100755 index 0000000..111e894 --- /dev/null +++ b/scripts/generate-package-json.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -e + +SRC_PACKAGE_JSON_TS_FILE='src/package-json.ts' + +[ -f ${SRC_PACKAGE_JSON_TS_FILE} ] || { + echo ${SRC_PACKAGE_JSON_TS_FILE}" not found" + exit 1 +} + +cat <<_SRC_ > ${SRC_PACKAGE_JSON_TS_FILE} +/** + * This file was auto generated from scripts/generate-version.sh + */ +import type { PackageJson } from 'type-fest' +export const packageJson: PackageJson = $(cat package.json) as any +_SRC_ diff --git a/scripts/generate-version.sh b/scripts/generate-version.sh deleted file mode 100755 index e8ef7f9..0000000 --- a/scripts/generate-version.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash -set -e - -SRC_VERSION_TS_FILE='src/version.ts' - -[ -f ${SRC_VERSION_TS_FILE} ] || { - echo ${SRC_VERSION_TS_FILE}" not found" - exit 1 -} - -VERSION=$(npx pkg-jq -r .version) - -cat <<_SRC_ > ${SRC_VERSION_TS_FILE} -/** - * This file was auto generated from scripts/generate-version.sh - */ -export const VERSION: string = '${VERSION}' -_SRC_ diff --git a/scripts/npm-pack-testing.sh b/scripts/npm-pack-testing.sh index 346b711..675d9f1 100755 --- a/scripts/npm-pack-testing.sh +++ b/scripts/npm-pack-testing.sh @@ -3,14 +3,14 @@ set -e VERSION=$(npx pkg-jq -r .version) -if npx --package @chatie/semver semver-is-prod $VERSION; then +if npx --package @chatie/semver semver-is-prod "$VERSION"; then NPM_TAG=latest else NPM_TAG=next fi npm run dist -npm run pack +npm pack TMPDIR="/tmp/npm-pack-testing.$$" mkdir "$TMPDIR" @@ -18,19 +18,54 @@ mv ./*-*.*.*.tgz "$TMPDIR" cp tests/fixtures/smoke-testing.ts "$TMPDIR" cd $TMPDIR + npm init -y -npm install *-*.*.*.tgz \ - @chatie/tsconfig \ +npm install --production ./*-*.*.*.tgz \ + @chatie/tsconfig@$NPM_TAG \ + pkg-jq \ + "wechaty-puppet@$NPM_TAG" \ "wechaty@$NPM_TAG" \ - ducks \ - wechaty-redux \ + "ducks@$NPM_TAG" \ + "wechaty-redux@NPM_TAG" \ + +# +# CommonJS +# ./node_modules/.bin/tsc \ + --target es6 \ + --module CommonJS \ + \ + --moduleResolution node \ --esModuleInterop \ --lib esnext \ + --noEmitOnError \ + --noImplicitAny \ --skipLibCheck \ + smoke-testing.ts + +echo +echo "CommonJS: pack testing..." +node smoke-testing.js + +# +# ES Modules +# +npx pkg-jq -i '.type="module"' + + +./node_modules/.bin/tsc \ + --target es2020 \ + --module es2020 \ + \ + --moduleResolution node \ + --esModuleInterop \ + --lib esnext \ --noEmitOnError \ --noImplicitAny \ + --skipLibCheck \ smoke-testing.ts +echo +echo "ES Module: pack testing..." node smoke-testing.js diff --git a/scripts/update-license.ts b/scripts/update-license.ts index 00d7191..2c4ae72 100644 --- a/scripts/update-license.ts +++ b/scripts/update-license.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env ts-node +#!/usr/bin/env -S node --no-warnings --loader ts-node/esm /** * Wechaty Open Source Software - /~https://github.com/wechaty diff --git a/src/contrib/counter/actions.ts b/src/contrib/counter/actions.ts index d45a384..50494a0 100644 --- a/src/contrib/counter/actions.ts +++ b/src/contrib/counter/actions.ts @@ -19,7 +19,7 @@ */ import { createAction } from 'typesafe-actions' -import * as types from './types' +import * as types from './types.js' const prepareWechaty = (wechatyId: string) => ({ wechatyId }) diff --git a/src/contrib/counter/epics.ts b/src/contrib/counter/epics.ts index a161356..e01f7d3 100644 --- a/src/contrib/counter/epics.ts +++ b/src/contrib/counter/epics.ts @@ -27,7 +27,7 @@ import { map, } from 'rxjs/operators' -import * as actions from './actions' +import * as actions from './actions.js' const counterEpic: Epic = actions$ => actions$.pipe( filter(isActionOf(wechatyDuck.actions.messageEvent)), diff --git a/src/contrib/counter/mod.ts b/src/contrib/counter/mod.ts index 93ebe0d..9370177 100644 --- a/src/contrib/counter/mod.ts +++ b/src/contrib/counter/mod.ts @@ -17,13 +17,13 @@ * limitations under the License. * */ -import reducer from './reducers' +import reducer from './reducers.js' -import * as actions from './actions' -import * as epics from './epics' -import * as operations from './operations' -import * as selectors from './selectors' -import * as types from './types' +import * as actions from './actions.js' +import * as epics from './epics.js' +import * as operations from './operations.js' +import * as selectors from './selectors.js' +import * as types from './types.js' export { actions, diff --git a/src/contrib/counter/operations.ts b/src/contrib/counter/operations.ts index 219c291..3b8e435 100644 --- a/src/contrib/counter/operations.ts +++ b/src/contrib/counter/operations.ts @@ -19,7 +19,7 @@ */ import { Dispatch } from 'redux' -import * as actions from './actions' +import * as actions from './actions.js' const outgoing = (dispatch: Dispatch) => (wechatyId: string) => dispatch(actions.outgoingMessage(wechatyId)) const incoming = (dispatch: Dispatch) => (wechatyId: string) => dispatch(actions.incomingMessage(wechatyId)) diff --git a/src/contrib/counter/reducers.ts b/src/contrib/counter/reducers.ts index 5019fc3..2404116 100644 --- a/src/contrib/counter/reducers.ts +++ b/src/contrib/counter/reducers.ts @@ -23,7 +23,7 @@ import { } from 'typesafe-actions' import { DeepReadonly } from 'utility-types' -import * as actions from './actions' +import * as actions from './actions.js' const initialState: DeepReadonly<{ incoming:{ [wechatyId: string]: undefined | number }, diff --git a/src/contrib/counter/selectors.ts b/src/contrib/counter/selectors.ts index 14a05c1..16f264a 100644 --- a/src/contrib/counter/selectors.ts +++ b/src/contrib/counter/selectors.ts @@ -17,7 +17,7 @@ * limitations under the License. * */ -import { State } from './reducers' +import { State } from './reducers.js' const getOutgoing = (state: State) => (wechatyId?: string) => { if (wechatyId) { diff --git a/src/contrib/counter/tests.spec.ts b/src/contrib/counter/tests.spec.ts index af20588..fefa6ce 100755 --- a/src/contrib/counter/tests.spec.ts +++ b/src/contrib/counter/tests.spec.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env ts-node +#!/usr/bin/env -S node --no-warnings --loader ts-node/esm /** * Wechaty Open Source Software - /~https://github.com/wechaty @@ -46,7 +46,7 @@ import { composeWithDevTools, } from 'remote-redux-devtools' -import * as CounterDuck from './mod' +import * as CounterDuck from './mod.js' // Let the bullets fly... const bulletsFly = async (ms = 0) => new Promise(resolve => setTimeout(resolve, ms)) diff --git a/src/mod.ts b/src/mod.ts index 255cd2e..a3e9089 100644 --- a/src/mod.ts +++ b/src/mod.ts @@ -17,9 +17,11 @@ * limitations under the License. * */ -import { VERSION } from './version' +import { packageJson } from './package-json.js' -import * as Counter from './contrib/counter/mod' +import * as Counter from './contrib/counter/mod.js' + +const VERSION = packageJson.version || '0.0.0' export { VERSION, diff --git a/src/package-json.spec.ts b/src/package-json.spec.ts new file mode 100755 index 0000000..5d9cac5 --- /dev/null +++ b/src/package-json.spec.ts @@ -0,0 +1,10 @@ +#!/usr/bin/env -S node --no-warnings --loader ts-node/esm + +import { test } from 'tstest' + +import { packageJson } from './package-json.js' + +test('Make sure the packageJson is fresh in source code', async t => { + const keyNum = Object.keys(packageJson).length + t.equal(keyNum, 0, 'packageJson should be empty in source code, only updated before publish to NPM') +}) diff --git a/src/package-json.ts b/src/package-json.ts new file mode 100644 index 0000000..0a9806f --- /dev/null +++ b/src/package-json.ts @@ -0,0 +1,11 @@ +/** + * This file will be overwrite when we publish NPM module + * by scripts/generate_version.ts + */ +import type { PackageJson } from 'type-fest' + +/** + * Huan(202108): + * The below default values is only for unit testing + */ +export const packageJson: PackageJson = {} diff --git a/src/version.spec.ts b/src/version.spec.ts deleted file mode 100644 index 36f47d0..0000000 --- a/src/version.spec.ts +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env ts-node - -/** - * Wechaty Open Source Software - /~https://github.com/wechaty - * - * @copyright 2016 Huan LI (李卓桓) , and - * Wechaty Contributors . - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -import test from 'tstest' - -import { VERSION } from './version' - -test('Make sure the VERSION is fresh in source code', async t => { - t.equal(VERSION, '0.0.0', 'version should be 0.0.0 in source code, only updated before publish to NPM') -}) diff --git a/src/version.ts b/src/version.ts deleted file mode 100644 index f2da2ca..0000000 --- a/src/version.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Wechaty Open Source Software - /~https://github.com/wechaty - * - * @copyright 2016 Huan LI (李卓桓) , and - * Wechaty Contributors . - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -export const VERSION = '0.0.0' diff --git a/tests/fixtures/smoke-testing.ts b/tests/fixtures/smoke-testing.ts index 43fa640..f35930e 100644 --- a/tests/fixtures/smoke-testing.ts +++ b/tests/fixtures/smoke-testing.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env ts-node +#!/usr/bin/env -S node --no-warnings --loader ts-node/esm /** * Wechaty Open Source Software - /~https://github.com/wechaty * @@ -25,13 +25,13 @@ import { import { Ducks } from 'ducks' async function main () { + const ducks = new Ducks({ counter: Counter }) + ducks.configureStore() + if (VERSION === '0.0.0') { throw new Error('version should be set before publishing') } - const ducks = new Ducks({ counter: Counter }) - ducks.configureStore() - return 0 } diff --git a/tests/integration.spec.ts b/tests/integration.spec.ts index 17ba0cc..f4dfb7f 100644 --- a/tests/integration.spec.ts +++ b/tests/integration.spec.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env ts-node +#!/usr/bin/env -S node --no-warnings --loader ts-node/esm /** * Wechaty Open Source Software - /~https://github.com/wechaty @@ -25,7 +25,7 @@ import { import { Counter, -} from '../src/mod' +} from '../src/mod.js' test('integration testing', async t => { t.ok(Counter, 'should available') diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json new file mode 100644 index 0000000..8693cd0 --- /dev/null +++ b/tsconfig.cjs.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "CommonJS", + "outDir": "dist/cjs", + }, +} diff --git a/tsconfig.json b/tsconfig.json index 728a055..cd74e88 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "@chatie/tsconfig", "compilerOptions": { - "outDir": "dist", + "outDir": "dist/esm", }, "exclude": [ "node_modules/", @@ -9,9 +9,7 @@ "tests/fixtures/", ], "include": [ - "app/**/*.ts", "bin/*.ts", - "bot/**/*.ts", "examples/**/*.ts", "scripts/**/*.ts", "src/**/*.ts", From e6e989d3707addb9554b4bd4aa77eed15bbee847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Huan=20=28=E6=9D=8E=E5=8D=93=E6=A1=93=29?= Date: Sun, 19 Sep 2021 00:15:07 +0800 Subject: [PATCH 2/5] use node 16 in ci --- .github/workflows/npm.yml | 2 +- examples/ducks.ts | 2 +- package.json | 5 +++-- scripts/update-license.ts | 4 ++-- src/contrib/counter/epics.ts | 2 +- src/contrib/counter/operations.ts | 2 +- src/contrib/counter/reducers.ts | 2 +- src/contrib/counter/selectors.ts | 2 +- src/contrib/counter/tests.spec.ts | 8 ++++---- 9 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml index 68139ce..84c1abc 100644 --- a/.github/workflows/npm.yml +++ b/.github/workflows/npm.yml @@ -9,7 +9,7 @@ jobs: matrix: os: - ubuntu-latest - node: + node-version: - 16 runs-on: ${{ matrix.os }} diff --git a/examples/ducks.ts b/examples/ducks.ts index 6ae96c8..8410040 100644 --- a/examples/ducks.ts +++ b/examples/ducks.ts @@ -39,7 +39,7 @@ async function main () { bot.use(WechatyRedux({ store })) await bot.start() - const [user, friend] = mocker.createContacts(2) + const [user, friend] = mocker.createContacts(2) as [mock.ContactMock, mock.ContactMock] mocker.login(user) const counterBundle = ducks.ducksify('counter') diff --git a/package.json b/package.json index e64f5b6..23862d2 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,9 @@ "typings": "./dist/esm/src/mod.d.ts", "engines": { "wechaty": ">=0.69", - "node": ">=14" + "node": ">=16", + "npm": ">=7" }, - "scripts": { "build": "tsc && tsc -p tsconfig.cjs.json", "clean": "shx rm -fr dist/*", @@ -55,6 +55,7 @@ "@types/glob": "^7.1.4", "@types/remote-redux-devtools": "^0.5.5", "glob": "^7.1.7", + "npm-run-all": "^4.1.5", "pkg-jq": "^0.2.11", "redux-devtools-cli": "1.0.0-4", "remote-redux-devtools": "^0.5.16", diff --git a/scripts/update-license.ts b/scripts/update-license.ts index 2c4ae72..54cd416 100644 --- a/scripts/update-license.ts +++ b/scripts/update-license.ts @@ -66,7 +66,7 @@ class LicenseTransformer extends Transform { // super(options) // } - public _transform (chunk: any, _: string /* encoding: string */, done: () => void) { + override _transform (chunk: any, _: string /* encoding: string */, done: () => void) { if (this.updated) { this.push(chunk) } else { @@ -127,7 +127,7 @@ class LicenseTransformer extends Transform { return updatedLineList.join('\n') } - public _flush (done: () => void) { + override _flush (done: () => void) { if (this.lineBuf) { this.push(this.lineBuf) this.lineBuf = '' diff --git a/src/contrib/counter/epics.ts b/src/contrib/counter/epics.ts index e01f7d3..35221ff 100644 --- a/src/contrib/counter/epics.ts +++ b/src/contrib/counter/epics.ts @@ -18,7 +18,7 @@ * */ import { isActionOf } from 'typesafe-actions' -import { Epic } from 'redux-observable' +import type { Epic } from 'redux-observable' import { Duck as wechatyDuck } from 'wechaty-redux' import { diff --git a/src/contrib/counter/operations.ts b/src/contrib/counter/operations.ts index 3b8e435..87ef398 100644 --- a/src/contrib/counter/operations.ts +++ b/src/contrib/counter/operations.ts @@ -17,7 +17,7 @@ * limitations under the License. * */ -import { Dispatch } from 'redux' +import type { Dispatch } from 'redux' import * as actions from './actions.js' diff --git a/src/contrib/counter/reducers.ts b/src/contrib/counter/reducers.ts index 2404116..60540ef 100644 --- a/src/contrib/counter/reducers.ts +++ b/src/contrib/counter/reducers.ts @@ -21,7 +21,7 @@ import { createReducer, ActionType, } from 'typesafe-actions' -import { DeepReadonly } from 'utility-types' +import type { DeepReadonly } from 'utility-types' import * as actions from './actions.js' diff --git a/src/contrib/counter/selectors.ts b/src/contrib/counter/selectors.ts index 16f264a..1410565 100644 --- a/src/contrib/counter/selectors.ts +++ b/src/contrib/counter/selectors.ts @@ -17,7 +17,7 @@ * limitations under the License. * */ -import { State } from './reducers.js' +import type { State } from './reducers.js' const getOutgoing = (state: State) => (wechatyId?: string) => { if (wechatyId) { diff --git a/src/contrib/counter/tests.spec.ts b/src/contrib/counter/tests.spec.ts index fefa6ce..bbe3f5f 100755 --- a/src/contrib/counter/tests.spec.ts +++ b/src/contrib/counter/tests.spec.ts @@ -19,7 +19,7 @@ * limitations under the License. * */ -import test from 'tstest' +import { test } from 'tstest' import { validateDuck, @@ -60,7 +60,7 @@ async function * wechatyFixtures () { let devCompose = compose - if (process.env.REDUX_DEVTOOLS) { + if (process.env['REDUX_DEVTOOLS']) { devCompose = composeWithDevTools({ hostname : 'localhost', port : 8000, @@ -85,10 +85,10 @@ async function * wechatyFixtures () { const bot = Wechaty.instance({ puppet }) bot.use(WechatyRedux({ store })) - const [mary, mike] = mocker.createContacts(2) + const [mary, mike] = mocker.createContacts(2) as [mock.ContactMock, mock.ContactMock] const user = mocker.createContact() - const [shop, yard] = mocker.createRooms(2) + const [shop, yard] = mocker.createRooms(2) as [mock.RoomMock, mock.RoomMock] const group = mocker.createRoom({ memberIdList: [ mike.id, From 39a32d6b13d1703b2343bc875d02d87eddf88ee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Huan=20=28=E6=9D=8E=E5=8D=93=E6=A1=93=29?= Date: Sun, 19 Sep 2021 00:15:44 +0800 Subject: [PATCH 3/5] 0.3.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 23862d2..02b59a0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wechaty-ducks-contrib", - "version": "0.3.0", + "version": "0.3.1", "description": "Wechaty Ducks Contrib", "type": "module", "exports": { From c70dc936f73ed157458aca921030f523c6e77dee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Huan=20=28=E6=9D=8E=E5=8D=93=E6=A1=93=29?= Date: Sun, 19 Sep 2021 00:40:55 +0800 Subject: [PATCH 4/5] update deps for peer dep --- README.md | 4 +++- package.json | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c0498f0..1ff6c2a 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,9 @@ npm start ## History -### master +### master v0.3 (Sep 19, 2021) + +1. ES Modules support ### v0.2 (Jun 5, 2020) diff --git a/package.json b/package.json index 02b59a0..4e5046a 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "@chatie/tsconfig": "^0.20.2", "@types/glob": "^7.1.4", "@types/remote-redux-devtools": "^0.5.5", + "cross-env": "^7.0.3", "glob": "^7.1.7", "npm-run-all": "^4.1.5", "pkg-jq": "^0.2.11", @@ -66,9 +67,9 @@ "wechaty-puppet-mock": "^0.31.5" }, "peerDependencies": { - "ducks": "^0.11.7", - "redux": ">=4.1.1", - "wechaty-redux": ">=0.5.4" + "ducks": "^0.11.10", + "redux": "^4.1.1", + "wechaty-redux": "^0.5.6" }, "dependencies": { "typesafe-actions": "^5.1.0" From 237f02e6ddccf15d59168090489e01da72bb2313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Huan=20=28=E6=9D=8E=E5=8D=93=E6=A1=93=29?= Date: Sun, 19 Sep 2021 00:41:24 +0800 Subject: [PATCH 5/5] 0.3.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4e5046a..55ac7d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wechaty-ducks-contrib", - "version": "0.3.1", + "version": "0.3.2", "description": "Wechaty Ducks Contrib", "type": "module", "exports": {