Skip to content

Commit

Permalink
feat: npm
Browse files Browse the repository at this point in the history
  • Loading branch information
CakmLexi committed Jun 26, 2024
1 parent 5396a6c commit e1397a1
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 222 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release and Publish
on:
push:
branches:
- dev
permissions:
contents: write
pull-requests: write
jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: node
package-name: node-karin
# Checkout
- uses: actions/checkout@v4
if: ${{ steps.release.outputs.release_created }}
# Setup node
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'
if: ${{ steps.release.outputs.release_created }}
# Install dependencies
- run: npm install
env:
NODE_AUTH_TOKEN: ${{secrets.DOCS_TOKEN}}
if: ${{ steps.release.outputs.release_created }}
# Build output
- run: npm run build
if: ${{ steps.release.outputs.release_created }}
# Publish to npm
- run: npm run pub
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
if: ${{ steps.release.outputs.release_created }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ lib/adapter/kritor/kritor
lib/adapter/kritor/kritorGitee

# 编译后的文件
lib/
dist/
build/
42 changes: 33 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,54 @@
{
"name": "karin",
"name": "node-karin",
"version": "0.0.3",
"private": true,
"private": false,
"homepage": "https://github.com/KarinJS/Karin#readme",
"bugs": {
"url": "https://github.com/KarinJS/Karin/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/KarinJS/Karin.git"
},
"license": "GPL-3.0-only",
"author": "Karin",
"type": "module",
"imports": {
"#Karin": "./lib/index.js"
},
"main": "./lib/index.js",
"files": [
"/lib/**/*.js",
"/lib/**/*.d.ts",
"/config/defSet/*.yaml",
"/config/view/*.yaml",
"LICENSE",
"package.json",
"README.md"
],
"workspaces": [
"plugins/**"
],
"scripts": {
"app": "node .",
"fix": "npx eslint lib/**/*.js --fix",
"delete": "pm2 delete ./config/config/pm2.yaml",
"js": "node .",
"js:dev": "node . --dev",
"ts": "tsx ./src/index.ts --dev",
"ts:dev": "tsx ./src/index.ts --dev",
"build": "tsc --project tsconfig.json && tsc-alias -p tsconfig.json && npm run fix",
"delete": "pm2 delete ./config/config/pm2.yaml",
"fix": "eslint lib/**/*.js --fix",
"fix:all": "eslint lib/**/*.js --fix && eslint src/**/*.ts --fix",
"init": "node lib/tools/install.js",
"init:dev": "node lib/tools/install.js",
"init:pack": "node lib/tools/install.js",
"js": "node .",
"js:dev": "node . --dev",
"log": "node lib/tools/pm2Log.js",
"monit": "pm2 monit",
"pub": "npm publish --access public",
"restart": "pm2 restart ./config/config/pm2.yaml",
"sort:pack": "npx sort-package-json",
"start": "pm2 start ./config/config/pm2.yaml && pm2 monit",
"stop": "pm2 delete ./config/config/pm2.yaml",
"ts": "tsx ./src/index.ts --dev",
"ts:dev": "tsx ./src/index.ts --dev",
"uninstall": "node lib/tools/uninstall.js",
"ver": "node lib/tools/updateVersion.js"
},
Expand Down Expand Up @@ -65,5 +85,9 @@
},
"engines": {
"node": ">=18"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
}
}
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { RedisClientType } from 'redis'

// proto
import { kritor } from 'kritor-proto'
export * as types from './types/index'

// 初始化
server.init()
Expand Down
8 changes: 8 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export * from './adapter'
export * from './config'
export * from './logger'
export * from './onebots11'
export * from './plugin'
export * from './render'
export * from './reply'
export * from './types'
22 changes: 11 additions & 11 deletions src/types/onebots11.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
/**
* - OneBot 11 标准事件
*/
export type PostType = 'message' | 'notice' | 'request' | 'meta_event' | 'message_sent'
export type EventPostType = 'message' | 'notice' | 'request' | 'meta_event' | 'message_sent'
/**
* - 消息事件类型
*/
export type MessageType = 'private' | 'group'
export type EventMessageType = 'private' | 'group'
/**
* - 消息子类型
*/
export type MessageSubType = 'friend' | 'group' | 'other' | 'normal' | 'anonymous' | 'notice'
export type EventMessageSubType = 'friend' | 'group' | 'other' | 'normal' | 'anonymous' | 'notice'
/**
* - 通知事件类型
*/
export type NoticeType = 'group_upload' | 'group_admin' | 'group_decrease' | 'group_increase' | 'group_ban' | 'friend_add' | 'group_recall' | 'friend_recall' | 'notify' | 'group_msg_emoji_like'
export type EventNoticeType = 'group_upload' | 'group_admin' | 'group_decrease' | 'group_increase' | 'group_ban' | 'friend_add' | 'group_recall' | 'friend_recall' | 'notify' | 'group_msg_emoji_like'
/**
* - 请求类型
*/
export type RequestType = 'friend' | 'group'
export type EventRequestType = 'friend' | 'group'

/**
* - 消息事件映射
Expand All @@ -30,7 +30,7 @@ export interface MessageToSubType {
/**
* - 消息子类型映射
*/
export type MessageTypeToSubEvent<E extends MessageType> = E extends keyof MessageToSubType ? MessageToSubType[E] : never
export type MessageTypeToSubEvent<E extends EventMessageType> = E extends keyof MessageToSubType ? MessageToSubType[E] : never

/**
* - 事件基类
Expand All @@ -43,7 +43,7 @@ export interface OneBot11 {
/**
* - 事件类型
*/
post_type: PostType
post_type: EventPostType
/**
* - 收到事件的机器人 QQ 号
*/
Expand All @@ -61,7 +61,7 @@ export interface OneBot11Notice extends OneBot11 {
/**
* - 通知类型
*/
notice_type: NoticeType
notice_type: EventNoticeType
}

/**
Expand Down Expand Up @@ -755,11 +755,11 @@ export interface OneBot11Message extends OneBot11 {
/**
* - 消息类型
*/
message_type: MessageType
message_type: EventMessageType
/**
* - 消息子类型
*/
sub_type: MessageTypeToSubEvent<MessageType>
sub_type: MessageTypeToSubEvent<EventMessageType>
/**
* - 消息 ID
*/
Expand Down Expand Up @@ -897,7 +897,7 @@ export type OneBot11Event = OneBot11GroupMessage | OneBot11PrivateMessage | OneB
/**
* - 传入 post_type 返回对应的事件类型
*/
export type ByPostType<T extends PostType> = Extract<OneBot11Event, { post_type: T }>
export type ByPostType<T extends EventPostType> = Extract<OneBot11Event, { post_type: T }>

/**
* - OneBot11公开Api
Expand Down
Loading

0 comments on commit e1397a1

Please sign in to comment.