diff --git a/app.json b/app.json index 28b3c6e..90eb459 100644 --- a/app.json +++ b/app.json @@ -46,7 +46,7 @@ } }, "engines": { - "node": "10" + "node": "16" }, "buildpacks": [ { diff --git a/bin/main.ts b/bin/main.ts index c61fc7b..e5f98cf 100644 --- a/bin/main.ts +++ b/bin/main.ts @@ -1,3 +1,4 @@ +#!/usr/bin/env -S node --no-warnings --loader ts-node/esm import type { Probot, ApplicationFunctionOptions, @@ -8,14 +9,14 @@ import type { import { log, // VERSION, -} from '../src/config' -import { getBot } from '../src/get-bot' -import { setupBot } from '../src/setup-bot' -import { setupFinis } from '../src/setup-finis' +} from '../src/config.js' +import { getBot } from '../src/get-bot.js' +import { setupBot } from '../src/setup-bot.js' +import { setupFinis } from '../src/setup-finis.js' -import { configureProbot } from '../src/probot-handlers/mod' +import { configureProbot } from '../src/probot-handlers/mod.js' -import { configureRoutes } from '../src/routers' +import { configureRoutes } from '../src/routers.js' async function probotApp ( app: Probot, diff --git a/package.json b/package.json index 22e5f68..7fb8290 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,12 @@ { "name": "osschat", - "version": "0.10.9", + "version": "0.10.10", "description": "Apache OSSChat", "main": "index.js", "type": "module", "engines": { - "node": ">=14" + "node": ">=16", + "npm": ">=7" }, "scripts": { "heroku:env": "heroku config -s -a oss-chat | sed 's/\\\\\\\\/\\\\/g' | tee .env", @@ -37,10 +38,10 @@ "brolog": "^1.12.4", "commander": "^8", "dotenv": "^10.0.0", - "ducks": "^0.11.7", + "ducks": "^0.11.10", "express": "^4.17.1", "finis": "^0.4.4", - "ha-wechaty": "^0.9.6", + "ha-wechaty": "^0.9.8", "micromatch": "^4.0.4", "moment": "^2.29.1", "node-cache": "^5.1.2", @@ -54,10 +55,10 @@ "rx-queue": "^0.12.6", "smee-client": "^1.2.2", "wechaty": "^0.69.54", - "wechaty-ducks-contrib": "^0.2.2", + "wechaty-ducks-contrib": "^0.3.4", "wechaty-plugin-contrib": "^0.14.23", "wechaty-puppet-padlocal": "^0.4.2", - "wechaty-redux": "^0.3.4" + "wechaty-redux": "^0.5.6" }, "devDependencies": { "@chatie/eslint-config": "^0.14.1", diff --git a/src/chatops.ts b/src/chatops.ts index a6be2dc..f48ef8b 100644 --- a/src/chatops.ts +++ b/src/chatops.ts @@ -12,7 +12,7 @@ import { CHATOPS_ROOM_ID, DEVELOPER_ROOM_ID, HEARTBEAT_ROOM_ID, -} from './config' +} from './config.js' export class Chatops { diff --git a/src/config-projects/apache.ts b/src/config-projects/apache.ts index 0977276..630c1e6 100644 --- a/src/config-projects/apache.ts +++ b/src/config-projects/apache.ts @@ -6,7 +6,7 @@ */ import type { RepoConfig, -} from './config' +} from './config.js' export const config: RepoConfig = { 'apache/dolphinscheduler' : [ diff --git a/src/config-projects/baidu.ts b/src/config-projects/baidu.ts index e7f5f65..707b7cd 100644 --- a/src/config-projects/baidu.ts +++ b/src/config-projects/baidu.ts @@ -6,7 +6,7 @@ */ import type { RepoConfig, -} from './config' +} from './config.js' const ROOM_ID = '20755579878@chatroom' // bot测试 diff --git a/src/config-projects/kaiyuanshe.ts b/src/config-projects/kaiyuanshe.ts index 78c2d16..ec5b8cf 100644 --- a/src/config-projects/kaiyuanshe.ts +++ b/src/config-projects/kaiyuanshe.ts @@ -6,7 +6,7 @@ */ import type { RepoConfig, -} from './config' +} from './config.js' export const config: RepoConfig = { 'kaiyuanshe/osschat' : [ diff --git a/src/config-projects/mod.ts b/src/config-projects/mod.ts index f4cf2c3..9c8f83a 100644 --- a/src/config-projects/mod.ts +++ b/src/config-projects/mod.ts @@ -1,14 +1,14 @@ -import wechaty from './wechaty' -import zixia from './zixia' -import tensorflowBook from './tensorflow-book' -import baidu from './baidu' -import preangel from './preangel' -import apache from './apache' -import webank from './webank' -import qihoo360 from './qihoo360' -import tencent from './tencent' -import kaiyuanshe from './kaiyuanshe' -import others from './others' +import wechaty from './wechaty.js' +import zixia from './zixia.js' +import tensorflowBook from './tensorflow-book.js' +import baidu from './baidu.js' +import preangel from './preangel.js' +import apache from './apache.js' +import webank from './webank.js' +import qihoo360 from './qihoo360.js' +import tencent from './tencent.js' +import kaiyuanshe from './kaiyuanshe.js' +import others from './others.js' /** * Huan(202003) diff --git a/src/config-projects/others.ts b/src/config-projects/others.ts index 8b205ce..9f1bbf3 100644 --- a/src/config-projects/others.ts +++ b/src/config-projects/others.ts @@ -6,7 +6,7 @@ */ import type { RepoConfig, -} from './config' +} from './config.js' export const config: RepoConfig = { 'BUPT/clubber.ml': '18968477245@chatroom', diff --git a/src/config-projects/preangel.ts b/src/config-projects/preangel.ts index bbf849e..a16ce94 100644 --- a/src/config-projects/preangel.ts +++ b/src/config-projects/preangel.ts @@ -4,7 +4,7 @@ * Maintainer: Huan LI (李卓桓) https://github.com/huan * */ -import type { RepoConfig } from './config' +import type { RepoConfig } from './config.js' const PREANGEL = '17237607145@chatroom' // ChatOps - PreAngel diff --git a/src/config-projects/qihoo360.ts b/src/config-projects/qihoo360.ts index 2893a1c..b3c0c39 100644 --- a/src/config-projects/qihoo360.ts +++ b/src/config-projects/qihoo360.ts @@ -6,7 +6,7 @@ */ import type { RepoConfig, -} from './config' +} from './config.js' export const config: RepoConfig = { 'qihoo360/quicksql' : [ diff --git a/src/config-projects/streamnative.ts b/src/config-projects/streamnative.ts index e651095..3a4f536 100644 --- a/src/config-projects/streamnative.ts +++ b/src/config-projects/streamnative.ts @@ -6,7 +6,7 @@ */ import type { RepoConfig, -} from './config' +} from './config.js' export const config: RepoConfig = { 'streamnative/kop' : '18300408994@chatroom', diff --git a/src/config-projects/tencent.ts b/src/config-projects/tencent.ts index 3ce7263..a835d85 100644 --- a/src/config-projects/tencent.ts +++ b/src/config-projects/tencent.ts @@ -6,7 +6,7 @@ */ import type { RepoConfig, -} from './config' +} from './config.js' export const config: RepoConfig = { 'Tencent/wepy': '21886945130@chatroom', diff --git a/src/config-projects/tensorflow-book.ts b/src/config-projects/tensorflow-book.ts index 1366269..9a5af36 100644 --- a/src/config-projects/tensorflow-book.ts +++ b/src/config-projects/tensorflow-book.ts @@ -6,7 +6,7 @@ */ import type { RepoConfig, -} from './config' +} from './config.js' const ROOM_ID = '4510565418@chatroom' const JAVASCRIPT_ML = '4383052528@chatroom' // Machine Learning in JavaScript diff --git a/src/config-projects/webank.ts b/src/config-projects/webank.ts index ea24ce7..a49ef83 100644 --- a/src/config-projects/webank.ts +++ b/src/config-projects/webank.ts @@ -6,7 +6,7 @@ */ import type { RepoConfig, -} from './config' +} from './config.js' export const config: RepoConfig = { 'WeBankFinTech/DataSphereStudio' : [ diff --git a/src/config-projects/wechaty.ts b/src/config-projects/wechaty.ts index b63c71f..c2eab26 100644 --- a/src/config-projects/wechaty.ts +++ b/src/config-projects/wechaty.ts @@ -5,7 +5,7 @@ * */ /* eslint-disable sort-keys */ -import type { RepoConfig } from './config' +import type { RepoConfig } from './config.js' const roomConfig = { '17275396976@chatroom': [ // Wechaty Developers' Headquarters @@ -51,28 +51,28 @@ const roomConfig = { * Polyglot Wechaty User Groups */ '18005545363@chatroom': [ // .NET Wechaty User Group - 'wechaty/dotnet-wechaty*', + 'wechaty/dotnet-*', ], '19236545415@chatroom': [ // PHP Wechaty User Group - 'wechaty/php-wechaty*', + 'wechaty/php-*', ], '19459143119@chatroom': [ // OpenAPI Wechaty User Group - 'wechaty/openapi*', + 'wechaty/openapi-*', ], '20062821521@chatroom': [ // Java Wechaty User Group - 'wechaty/java-wechaty*', + 'wechaty/java-*', ], '20771403027@chatroom': [ // Python Wechaty User Group - 'wechaty/python-wechaty*', + 'wechaty/python-*', ], '21063503320@chatroom': [ // Rust Wechaty User Group - 'wechaty/rust-wechaty*', + 'wechaty/rust-*', ], '21153390249@chatroom': [ // Go Wechaty User Group - 'wechaty/go-wechaty*', + 'wechaty/go-*', ], '21366491788@chatroom': [ // Scala Wechaty User Group - 'wechaty/scala-wechaty*', + 'wechaty/scala-*', ], '21148500489@chatroom': [ // TypeScript Wechaty User Group 'wechaty/wechaty', diff --git a/src/config-projects/zixia.ts b/src/config-projects/zixia.ts index 3e3b76b..83a31f0 100644 --- a/src/config-projects/zixia.ts +++ b/src/config-projects/zixia.ts @@ -6,7 +6,7 @@ */ import type { RepoConfig, -} from './config' +} from './config.js' export const config: RepoConfig = { 'zixia/aka.org.cn' : '3408538832@chatroom', diff --git a/src/config.ts b/src/config.ts index 7650951..8436588 100644 --- a/src/config.ts +++ b/src/config.ts @@ -2,16 +2,21 @@ /** * VERSION */ -import readPkgUp from 'read-pkg-up' +import { readPackageUpSync } from 'read-pkg-up' import { log, } from 'wechaty' +import { dirname } from 'path' +import { fileURLToPath } from 'url' + import dotenv from 'dotenv' dotenv.config() -const pkg = readPkgUp.readPackageUpSync({ cwd: __dirname })!.packageJson +const __dirname = dirname(fileURLToPath(import.meta.url)) + +const pkg = readPackageUpSync({ cwd: __dirname })!.packageJson const VERSION = pkg.version /** diff --git a/src/deliver-card.ts b/src/deliver-card.ts index c5bd06f..d046b0f 100644 --- a/src/deliver-card.ts +++ b/src/deliver-card.ts @@ -8,16 +8,16 @@ import request from 'request' import { projectsRepoConfig, -} from './config-projects/mod' +} from './config-projects/mod.js' import { matchOwner, matchRepo, // exactMatch, -} from './pure-functions/match-org-repo' +} from './pure-functions/match-org-repo.js' -import { getBot } from './get-bot' -import { Chatops } from './chatops' +import { getBot } from './get-bot.js' +import { Chatops } from './chatops.js' async function deliverCard ( owner : string, diff --git a/src/get-bot.ts b/src/get-bot.ts index d588d12..e94c8e5 100644 --- a/src/get-bot.ts +++ b/src/get-bot.ts @@ -10,12 +10,12 @@ import { import { log, -} from './config' +} from './config.js' import { getMemory, -} from './get-memory' +} from './get-memory.js' -import { Chatops } from './chatops' +import { Chatops } from './chatops.js' const duckery = { counter : CounterDuck, diff --git a/src/get-memory.ts b/src/get-memory.ts index 096f3aa..8589ed6 100644 --- a/src/get-memory.ts +++ b/src/get-memory.ts @@ -4,7 +4,7 @@ import { import { log, -} from './config' +} from './config.js' export let memory: MemoryCard diff --git a/src/probot-handlers/issue-comment.created.ts b/src/probot-handlers/issue-comment.created.ts index d8043f1..cef28d1 100644 --- a/src/probot-handlers/issue-comment.created.ts +++ b/src/probot-handlers/issue-comment.created.ts @@ -6,7 +6,7 @@ import { log, } from 'wechaty' -import { deliverCard } from '../deliver-card' +import { deliverCard } from '../deliver-card.js' const issueCommentCreatedPlugin = (app: Probot) => app.on('issue_comment.created', async (context) => { const fullName = context.payload.repository.full_name diff --git a/src/probot-handlers/issues.opened.ts b/src/probot-handlers/issues.opened.ts index 2e74c52..033247e 100644 --- a/src/probot-handlers/issues.opened.ts +++ b/src/probot-handlers/issues.opened.ts @@ -6,7 +6,7 @@ import { log, } from 'wechaty' -import { deliverCard } from '../deliver-card' +import { deliverCard } from '../deliver-card.js' const issuesOpenedPlugin = (app: Probot) => app.on('issues.opened', async (context) => { const fullName = context.payload.repository.full_name diff --git a/src/probot-handlers/mod.ts b/src/probot-handlers/mod.ts index 12d7e4c..d4aff4b 100644 --- a/src/probot-handlers/mod.ts +++ b/src/probot-handlers/mod.ts @@ -1,10 +1,10 @@ import type { Probot } from 'probot' -import { issueCommentCreatedPlugin } from './issue-comment.created' -import { issuesOpenedPlugin } from './issues.opened' -import { pullRequestReviewCommentCreatedPlugin } from './pull-request-review-comment.created' -import { pullRequestReviewSubmittedPlugin } from './pull-request-review.submitted' -import { pullRequestOpenedPlugin } from './pull-request.opened' +import { issueCommentCreatedPlugin } from './issue-comment.created.js' +import { issuesOpenedPlugin } from './issues.opened.js' +import { pullRequestReviewCommentCreatedPlugin } from './pull-request-review-comment.created.js' +import { pullRequestReviewSubmittedPlugin } from './pull-request-review.submitted.js' +import { pullRequestOpenedPlugin } from './pull-request.opened.js' const pluginList = [ issueCommentCreatedPlugin, diff --git a/src/probot-handlers/pull-request-review-comment.created.ts b/src/probot-handlers/pull-request-review-comment.created.ts index bd5ab5e..978b5bb 100644 --- a/src/probot-handlers/pull-request-review-comment.created.ts +++ b/src/probot-handlers/pull-request-review-comment.created.ts @@ -6,7 +6,7 @@ import { log, } from 'wechaty' -import { deliverCard } from '../deliver-card' +import { deliverCard } from '../deliver-card.js' const pullRequestReviewCommentCreatedPlugin = (app: Probot) => app.on('pull_request_review_comment.created', async (context) => { const fullName = context.payload.repository.full_name diff --git a/src/probot-handlers/pull-request-review.submitted.ts b/src/probot-handlers/pull-request-review.submitted.ts index 9830a29..7a443d8 100644 --- a/src/probot-handlers/pull-request-review.submitted.ts +++ b/src/probot-handlers/pull-request-review.submitted.ts @@ -6,7 +6,7 @@ import { log, } from 'wechaty' -import { deliverCard } from '../deliver-card' +import { deliverCard } from '../deliver-card.js' const pullRequestReviewSubmittedPlugin = (app: Probot) => app.on('pull_request_review.submitted', async (context) => { const fullName = context.payload.repository.full_name diff --git a/src/probot-handlers/pull-request.opened.ts b/src/probot-handlers/pull-request.opened.ts index c71585f..b8b13f5 100644 --- a/src/probot-handlers/pull-request.opened.ts +++ b/src/probot-handlers/pull-request.opened.ts @@ -6,7 +6,7 @@ import { log, } from 'wechaty' -import { deliverCard } from '../deliver-card' +import { deliverCard } from '../deliver-card.js' const pullRequestOpenedPlugin = (app: Probot) => app.on('pull_request.opened', async (context) => { const fullName = context.payload.repository.full_name diff --git a/src/routers.ts b/src/routers.ts index ee7a33f..6fd77f6 100644 --- a/src/routers.ts +++ b/src/routers.ts @@ -12,15 +12,15 @@ import type { import { log, VERSION, -} from './config' -import { Chatops } from './chatops' -import { getBot } from './get-bot' +} from './config.js' +import { Chatops } from './chatops.js' +import { getBot } from './get-bot.js' // import { // duckStore, // wechatySelectors, // counterSelectors, -// } from './ducks/' +// } from './ducks/.js' const haBot = getBot() diff --git a/src/setup-bot.ts b/src/setup-bot.ts index e63f4bf..bcb8785 100644 --- a/src/setup-bot.ts +++ b/src/setup-bot.ts @@ -11,25 +11,25 @@ import { log, CHATOPS_ROOM_ID, HEARTBEAT_ROOM_ID, -} from './config' +} from './config.js' // import { // Chatops, -// } from './chatops' +// } from './chatops.js' // import { // Wtmp, -// } from './wtmp' -import { getBot } from './get-bot' +// } from './wtmp.js' +import { getBot } from './get-bot.js' -import onScan from './wechaty-handlers/on-scan' -import onError from './wechaty-handlers/on-error' -import onFriendship from './wechaty-handlers/on-friendship' -import onLogout from './wechaty-handlers/on-logout' -import onLogin from './wechaty-handlers/on-login' -import onMessage from './wechaty-handlers/on-message' -import onRoomTopic from './wechaty-handlers/on-room-topic' -import onRoomInvite from './wechaty-handlers/on-room-invite' -import onRoomJoin from './wechaty-handlers/on-room-join' -import onRoomLeave from './wechaty-handlers/on-room-leave' +import onScan from './wechaty-handlers/on-scan.js' +import onError from './wechaty-handlers/on-error.js' +import onFriendship from './wechaty-handlers/on-friendship.js' +import onLogout from './wechaty-handlers/on-logout.js' +import onLogin from './wechaty-handlers/on-login.js' +import onMessage from './wechaty-handlers/on-message.js' +import onRoomTopic from './wechaty-handlers/on-room-topic.js' +import onRoomInvite from './wechaty-handlers/on-room-invite.js' +import onRoomJoin from './wechaty-handlers/on-room-join.js' +import onRoomLeave from './wechaty-handlers/on-room-leave.js' // const absPath = (relatedPath: string) => path.join(__dirname, relatedPath) diff --git a/src/setup-finis.ts b/src/setup-finis.ts index 8d0b6fe..cb426dd 100644 --- a/src/setup-finis.ts +++ b/src/setup-finis.ts @@ -1,4 +1,4 @@ -import { finis } from 'finis' +import finisPkg from 'finis' import type { Contact, } from 'wechaty' @@ -6,12 +6,14 @@ import type { HAWechaty } from 'ha-wechaty' import { Chatops, -} from './chatops' +} from './chatops.js' import { log, VERSION, debug, -} from './config' +} from './config.js' + +const finis: typeof finisPkg = (finisPkg as any).default const BOT_NAME = 'OSSChat' diff --git a/src/wechaty-handlers/on-friendship.ts b/src/wechaty-handlers/on-friendship.ts index 563e6d4..b6aba36 100644 --- a/src/wechaty-handlers/on-friendship.ts +++ b/src/wechaty-handlers/on-friendship.ts @@ -4,7 +4,7 @@ import { Wechaty, } from 'wechaty' -import { Chatops } from '../chatops' +import { Chatops } from '../chatops.js' export default async function onFriendship ( this : Wechaty, diff --git a/src/wechaty-handlers/on-login.ts b/src/wechaty-handlers/on-login.ts index 6add6e9..0037628 100644 --- a/src/wechaty-handlers/on-login.ts +++ b/src/wechaty-handlers/on-login.ts @@ -4,12 +4,12 @@ import { VERSION, Wechaty, } from 'wechaty' -import { debug } from '../config' +import { debug } from '../config.js' // import { // duckStore, // wechatyActions, -// } from '../ducks/' +// } from '../ducks/.js' export default async function onLogin ( this : Wechaty, diff --git a/src/wechaty-handlers/on-logout.ts b/src/wechaty-handlers/on-logout.ts index ab918c3..e012160 100644 --- a/src/wechaty-handlers/on-logout.ts +++ b/src/wechaty-handlers/on-logout.ts @@ -7,7 +7,7 @@ import { // import { // duckStore, // wechatyActions, -// } from '../ducks/' +// } from '../ducks/.js' export default async function onLogout ( this : Wechaty, diff --git a/src/wechaty-handlers/on-message.ts b/src/wechaty-handlers/on-message.ts index 330be65..703bad3 100644 --- a/src/wechaty-handlers/on-message.ts +++ b/src/wechaty-handlers/on-message.ts @@ -8,14 +8,14 @@ import moment from 'moment' import { CHATOPS_ROOM_ID, -} from '../config' -// import { VoteManager } from '../managers/vote-manager' -import { Chatops } from '../chatops' +} from '../config.js' +// import { VoteManager } from '../managers/vote-manager.js' +import { Chatops } from '../chatops.js' // import { // duckStore, // counterActions, -// } from '../ducks/' +// } from '../ducks/.js' const BORN_TIME = Date.now() diff --git a/src/wechaty-handlers/on-room-invite.ts b/src/wechaty-handlers/on-room-invite.ts index bf2e452..c06143b 100644 --- a/src/wechaty-handlers/on-room-invite.ts +++ b/src/wechaty-handlers/on-room-invite.ts @@ -4,7 +4,7 @@ import { Wechaty, } from 'wechaty' -import { Chatops } from '../chatops' +import { Chatops } from '../chatops.js' export default async function onRoomInvite ( this : Wechaty, diff --git a/src/wechaty-handlers/on-scan.ts b/src/wechaty-handlers/on-scan.ts index cc758dd..04cc239 100644 --- a/src/wechaty-handlers/on-scan.ts +++ b/src/wechaty-handlers/on-scan.ts @@ -9,7 +9,7 @@ import * as qrTerminal from 'qrcode-terminal' // import { // duckStore, // wechatyActions, -// } from '../ducks/' +// } from '../ducks/.js' export default async function onScan ( this : Wechaty, diff --git a/tests/fixtures/smoke-testing.ts b/tests/fixtures/smoke-testing.ts index 85da9e1..8a5c9ff 100644 --- a/tests/fixtures/smoke-testing.ts +++ b/tests/fixtures/smoke-testing.ts @@ -1,8 +1,8 @@ #!/usr/bin/env -S node --no-warnings --loader ts-node/esm -import { getHAWechaty } from '../../src/get-wechaty' -import { startBot } from '../../src/start-bot' -import { startFinis } from '../../src/start-finis' +import { getHAWechaty } from '../../src/get-wechaty.js' +import { startBot } from '../../src/start-bot.js' +import { startFinis } from '../../src/start-finis.js' process.env.HA_WECHATY_PUPPET = 'wechaty-puppet-mock' process.env.HA_WECHATY_PUPPET_MOCK_TOKEN = 'mock-token' diff --git a/tests/integration.spec.ts b/tests/integration.spec.ts index a26e042..baf25b6 100755 --- a/tests/integration.spec.ts +++ b/tests/integration.spec.ts @@ -20,7 +20,7 @@ import { test } from 'tstest' -// import { log } from '../src/config' +// import { log } from '../src/config.js' // import { spy } from 'sinon'