node-karin 0.0.3 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/LICENSE +674 -674
  2. package/README.md +57 -57
  3. package/config/defSet/App.yaml +37 -37
  4. package/config/defSet/config.yaml +43 -43
  5. package/config/defSet/group.yaml +18 -18
  6. package/config/defSet/pm2.yaml +21 -21
  7. package/config/defSet/server.yaml +42 -42
  8. package/config/view/App.yaml +74 -74
  9. package/config/view/config.yaml +100 -100
  10. package/config/view/group.yaml +62 -62
  11. package/config/view/pm2.yaml +41 -41
  12. package/config/view/redis.yaml +25 -25
  13. package/config/view/server.yaml +93 -93
  14. package/lib/adapter/onebot/onebot11.d.ts +430 -430
  15. package/lib/adapter/onebot/onebot11.js +1265 -1302
  16. package/lib/core/dir.d.ts +1 -0
  17. package/lib/core/dir.js +4 -0
  18. package/lib/core/init.js +4 -4
  19. package/lib/core/karin.d.ts +72 -72
  20. package/lib/core/karin.js +51 -51
  21. package/lib/core/listener.d.ts +121 -121
  22. package/lib/core/listener.js +178 -178
  23. package/lib/core/plugin.app.d.ts +15 -15
  24. package/lib/core/plugin.app.js +18 -18
  25. package/lib/core/plugin.d.ts +182 -182
  26. package/lib/core/plugin.js +132 -132
  27. package/lib/core/plugin.loader.d.ts +149 -149
  28. package/lib/core/plugin.loader.js +451 -451
  29. package/lib/core/server.d.ts +26 -26
  30. package/lib/core/server.js +209 -209
  31. package/lib/db/level.d.ts +20 -20
  32. package/lib/db/level.js +36 -36
  33. package/lib/db/redis.d.ts +41 -41
  34. package/lib/db/redis.js +131 -131
  35. package/lib/db/redis_level.d.ts +113 -113
  36. package/lib/db/redis_level.js +274 -274
  37. package/lib/event/event.d.ts +138 -138
  38. package/lib/event/event.handler.d.ts +29 -29
  39. package/lib/event/event.handler.js +138 -138
  40. package/lib/event/event.js +120 -120
  41. package/lib/event/message.d.ts +102 -102
  42. package/lib/event/message.handler.d.ts +25 -25
  43. package/lib/event/message.handler.js +237 -237
  44. package/lib/event/message.js +69 -69
  45. package/lib/event/notice.d.ts +49 -49
  46. package/lib/event/notice.js +14 -14
  47. package/lib/event/request.d.ts +49 -49
  48. package/lib/event/request.js +14 -14
  49. package/lib/event/review.handler.d.ts +54 -54
  50. package/lib/event/review.handler.js +374 -374
  51. package/lib/index.d.ts +24 -23
  52. package/lib/index.js +40 -40
  53. package/lib/renderer/app.d.ts +53 -53
  54. package/lib/renderer/app.js +88 -88
  55. package/lib/renderer/base.d.ts +30 -30
  56. package/lib/renderer/base.js +68 -68
  57. package/lib/renderer/client.d.ts +30 -30
  58. package/lib/renderer/client.js +155 -155
  59. package/lib/renderer/http.d.ts +19 -19
  60. package/lib/renderer/http.js +50 -50
  61. package/lib/renderer/server.d.ts +42 -42
  62. package/lib/renderer/server.js +110 -110
  63. package/lib/renderer/wormhole.d.ts +1 -1
  64. package/lib/renderer/wormhole.js +154 -154
  65. package/lib/tools/init.d.ts +2 -0
  66. package/lib/tools/init.js +31 -0
  67. package/lib/types/adapter.d.ts +575 -575
  68. package/lib/types/adapter.js +1 -1
  69. package/lib/types/config.d.ts +327 -327
  70. package/lib/types/config.js +1 -1
  71. package/lib/types/element.d.ts +576 -576
  72. package/lib/types/element.js +1 -1
  73. package/lib/types/index.d.ts +8 -8
  74. package/lib/types/index.js +8 -8
  75. package/lib/types/logger.d.ts +109 -109
  76. package/lib/types/logger.js +1 -1
  77. package/lib/types/onebots11.d.ts +1371 -1371
  78. package/lib/types/onebots11.js +1 -1
  79. package/lib/types/plugin.d.ts +282 -282
  80. package/lib/types/plugin.js +1 -1
  81. package/lib/types/render.d.ts +111 -111
  82. package/lib/types/render.js +1 -1
  83. package/lib/types/reply.d.ts +40 -40
  84. package/lib/types/reply.js +1 -1
  85. package/lib/types/types.d.ts +898 -898
  86. package/lib/types/types.js +1 -1
  87. package/lib/utils/YamlEditor.d.ts +62 -62
  88. package/lib/utils/YamlEditor.js +197 -197
  89. package/lib/utils/button.d.ts +49 -49
  90. package/lib/utils/button.js +75 -75
  91. package/lib/utils/common.d.ts +123 -123
  92. package/lib/utils/common.js +396 -396
  93. package/lib/utils/config.d.ts +72 -72
  94. package/lib/utils/config.js +259 -254
  95. package/lib/utils/exec.d.ts +22 -22
  96. package/lib/utils/exec.js +36 -36
  97. package/lib/utils/ffmpeg.d.ts +12 -12
  98. package/lib/utils/ffmpeg.js +25 -25
  99. package/lib/utils/handler.d.ts +76 -76
  100. package/lib/utils/handler.js +98 -98
  101. package/lib/utils/logger.d.ts +3 -3
  102. package/lib/utils/logger.js +104 -104
  103. package/lib/utils/segment.d.ts +276 -276
  104. package/lib/utils/segment.js +420 -420
  105. package/lib/utils/update.d.ts +69 -69
  106. package/lib/utils/update.js +145 -145
  107. package/lib/utils/updateVersion.d.ts +33 -33
  108. package/lib/utils/updateVersion.js +140 -140
  109. package/package.json +95 -91
@@ -1,145 +1,145 @@
1
- import fs from 'fs'
2
- import { exec } from 'child_process'
3
- export default class Version {
4
- path
5
- packageDir
6
- CHANGELOGDir
7
- packageJson
8
- version
9
- commitsMap
10
- HEAD
11
- cmd
12
- stdout
13
- url
14
- constructor (path) {
15
- this.cmd = ''
16
- this.stdout = ''
17
- this.url = ''
18
- this.HEAD = ''
19
- this.path = path
20
- this.packageDir = this.path + '/packageon'
21
- this.CHANGELOGDir = this.path + '/CHANGELOG.md'
22
- this.packageJson = JSON.parse(fs.readFileSync(this.packageDir, 'utf-8'))
23
- this.version = this.packageJson.version
24
- this.commitsMap = {
25
- release: ['### Releases'],
26
- feat: ['### 新增功能'],
27
- fix: ['### Bug修复'],
28
- docs: ['### 文档更新'],
29
- style: ['### 代码样式修改'],
30
- refactor: ['### 代码重构'],
31
- perf: ['### 性能优化'],
32
- chore: ['### 构建工具相关'],
33
- revert: ['### 回滚'],
34
- others: ['### 其他提交'],
35
- }
1
+ import fs from 'fs'
2
+ import { exec } from 'child_process'
3
+ export default class Version {
4
+ path
5
+ packageDir
6
+ CHANGELOGDir
7
+ packageJson
8
+ version
9
+ commitsMap
10
+ HEAD
11
+ cmd
12
+ stdout
13
+ url
14
+ constructor (path) {
15
+ this.cmd = ''
16
+ this.stdout = ''
17
+ this.url = ''
18
+ this.HEAD = ''
19
+ this.path = path
20
+ this.packageDir = this.path + '/packageon'
21
+ this.CHANGELOGDir = this.path + '/CHANGELOG.md'
22
+ this.packageJson = JSON.parse(fs.readFileSync(this.packageDir, 'utf-8'))
23
+ this.version = this.packageJson.version
24
+ this.commitsMap = {
25
+ release: ['### Releases'],
26
+ feat: ['### 新增功能'],
27
+ fix: ['### Bug修复'],
28
+ docs: ['### 文档更新'],
29
+ style: ['### 代码样式修改'],
30
+ refactor: ['### 代码重构'],
31
+ perf: ['### 性能优化'],
32
+ chore: ['### 构建工具相关'],
33
+ revert: ['### 回滚'],
34
+ others: ['### 其他提交'],
35
+ }
36
36
  }
37
-
38
- async init () {
39
- /** 获取仓库地址 */
40
- await this.gitUrl()
41
- /** 取tag对应的head */
42
- await this.gitTag()
43
- const HEAD = this.HEAD ? `${this.HEAD}..HEAD ` : ''
44
- this.cmd = `git log ${HEAD}--pretty=format:"HEAD: %H=分割=sha: %h=分割=log: %s"`
45
- this.stdout = (await this.exce(this.cmd))
46
- if (!this.stdout) { throw new Error('commit为空...') }
47
- this.stdout = this.stdout.trim().split('\n')
48
- const reg = /(fix|feat|docs|style|refactor|perf|release|chore|revert)(:|:)/i
49
- for (const commit of this.stdout) {
50
- /** 拆分 */
51
- const [HEAD, sha, log] = commit.split('=分割=').map(item => item.trim().replace(/^(HEAD|sha|log): /, ''))
52
- /** 排除此项 */
53
- if (log.startsWith('Merge branch')) { continue }
54
- const match = log.match(reg)
55
- const type = match ? match[1].toLowerCase() : 'others'
56
- /** 拼接commit */
57
- const info = `- ${log} ([${sha}](${this.url}/commit/${HEAD}))`
58
- this.commitsMap[type].push(info)
59
- }
60
- /** 更新版本号 */
61
- await this.updateVersion()
62
- /** YYYY-MM-DD */
63
- const date = new Date().toLocaleDateString().replace(/\//g, '-')
64
- const text = [`## ${this.version} (${date})`]
65
- for (const key in this.commitsMap) {
66
- /** 排除空 */
67
- if (this.commitsMap[key].length === 1) {
68
- delete this.commitsMap[key]
69
- continue
70
- }
71
- text.push(this.commitsMap[key].join('\n'))
72
- }
73
- /** 判断是否有CHANGELOG.md文件 */
74
- if (fs.existsSync(this.CHANGELOGDir)) {
75
- const oldText = fs.readFileSync(this.CHANGELOGDir, 'utf-8')
76
- text.push(oldText)
77
- }
78
- fs.writeFileSync(this.CHANGELOGDir, text.join('\n\n'))
79
- console.log('更新成功~')
37
+
38
+ async init () {
39
+ /** 获取仓库地址 */
40
+ await this.gitUrl()
41
+ /** 取tag对应的head */
42
+ await this.gitTag()
43
+ const HEAD = this.HEAD ? `${this.HEAD}..HEAD ` : ''
44
+ this.cmd = `git log ${HEAD}--pretty=format:"HEAD: %H=分割=sha: %h=分割=log: %s"`
45
+ this.stdout = (await this.exce(this.cmd))
46
+ if (!this.stdout) { throw new Error('commit为空...') }
47
+ this.stdout = this.stdout.trim().split('\n')
48
+ const reg = /(fix|feat|docs|style|refactor|perf|release|chore|revert)(:|:)/i
49
+ for (const commit of this.stdout) {
50
+ /** 拆分 */
51
+ const [HEAD, sha, log] = commit.split('=分割=').map(item => item.trim().replace(/^(HEAD|sha|log): /, ''))
52
+ /** 排除此项 */
53
+ if (log.startsWith('Merge branch')) { continue }
54
+ const match = log.match(reg)
55
+ const type = match ? match[1].toLowerCase() : 'others'
56
+ /** 拼接commit */
57
+ const info = `- ${log} ([${sha}](${this.url}/commit/${HEAD}))`
58
+ this.commitsMap[type].push(info)
59
+ }
60
+ /** 更新版本号 */
61
+ await this.updateVersion()
62
+ /** YYYY-MM-DD */
63
+ const date = new Date().toLocaleDateString().replace(/\//g, '-')
64
+ const text = [`## ${this.version} (${date})`]
65
+ for (const key in this.commitsMap) {
66
+ /** 排除空 */
67
+ if (this.commitsMap[key].length === 1) {
68
+ delete this.commitsMap[key]
69
+ continue
70
+ }
71
+ text.push(this.commitsMap[key].join('\n'))
72
+ }
73
+ /** 判断是否有CHANGELOG.md文件 */
74
+ if (fs.existsSync(this.CHANGELOGDir)) {
75
+ const oldText = fs.readFileSync(this.CHANGELOGDir, 'utf-8')
76
+ text.push(oldText)
77
+ }
78
+ fs.writeFileSync(this.CHANGELOGDir, text.join('\n\n'))
79
+ console.log('更新成功~')
80
80
  }
81
-
82
- /**
83
- * 获取当前仓库最新的一个标签的HEAD
84
- */
85
- async gitTag () {
86
- const cmd = 'git tag'
87
- const stdout = await this.exce(cmd)
88
- if (!stdout) { return false }
89
- const tags = stdout.trim().split('\n')
90
- const lastTag = tags[tags.length - 1]
91
- const cmd2 = `git rev-list -n 1 ${lastTag}`
92
- const HEAD = await this.exce(cmd2)
93
- this.HEAD = HEAD.trim()
81
+
82
+ /**
83
+ * 获取当前仓库最新的一个标签的HEAD
84
+ */
85
+ async gitTag () {
86
+ const cmd = 'git tag'
87
+ const stdout = await this.exce(cmd)
88
+ if (!stdout) { return false }
89
+ const tags = stdout.trim().split('\n')
90
+ const lastTag = tags[tags.length - 1]
91
+ const cmd2 = `git rev-list -n 1 ${lastTag}`
92
+ const HEAD = await this.exce(cmd2)
93
+ this.HEAD = HEAD.trim()
94
94
  }
95
-
96
- /**
97
- * 获取当前仓库的远程地址
98
- */
99
- async gitUrl () {
100
- const cmd = 'git remote -v'
101
- const stdout = await this.exce(cmd)
102
- let [url] = stdout.split('\n').map(item => item.split('\t')[1])
103
- url = url.trim().split(' ')[0]
104
- this.url = url
95
+
96
+ /**
97
+ * 获取当前仓库的远程地址
98
+ */
99
+ async gitUrl () {
100
+ const cmd = 'git remote -v'
101
+ const stdout = await this.exce(cmd)
102
+ let [url] = stdout.split('\n').map(item => item.split('\t')[1])
103
+ url = url.trim().split(' ')[0]
104
+ this.url = url
105
105
  }
106
-
107
- /**
108
- * 更新版本号 tag
109
- */
110
- async updateVersion () {
111
- /** 10进1 */
112
- const versionArr = this.version.split('.').map((item) => parseInt(item))
113
- if (versionArr[2] === 9) {
114
- versionArr[1]++
115
- versionArr[2] = 0
116
- } else {
117
- versionArr[2]++
118
- }
119
- this.version = versionArr.join('.')
120
- this.packageJson.version = this.version
121
- fs.writeFileSync(this.packageDir, JSON.stringify(this.packageJson, null, 2))
122
- /** tag */
123
- try {
124
- await this.exce(`git tag v${this.version}`)
125
- } catch (e) {
126
- console.log('tag已存在')
127
- }
106
+
107
+ /**
108
+ * 更新版本号 tag
109
+ */
110
+ async updateVersion () {
111
+ /** 10进1 */
112
+ const versionArr = this.version.split('.').map((item) => parseInt(item))
113
+ if (versionArr[2] === 9) {
114
+ versionArr[1]++
115
+ versionArr[2] = 0
116
+ } else {
117
+ versionArr[2]++
118
+ }
119
+ this.version = versionArr.join('.')
120
+ this.packageJson.version = this.version
121
+ fs.writeFileSync(this.packageDir, JSON.stringify(this.packageJson, null, 2))
122
+ /** tag */
123
+ try {
124
+ await this.exce(`git tag v${this.version}`)
125
+ } catch (e) {
126
+ console.log('tag已存在')
127
+ }
128
128
  }
129
-
130
- /**
131
- * 封装exce方法
132
- * @param {string} cmd 执行的命令
133
- */
134
- exce (cmd) {
135
- return new Promise((resolve, reject) => {
136
- exec(cmd, { cwd: this.path }, (error, stdout) => {
137
- if (error) {
138
- reject(error)
139
- return
140
- }
141
- resolve(stdout)
142
- })
143
- })
144
- }
145
- }
129
+
130
+ /**
131
+ * 封装exce方法
132
+ * @param {string} cmd 执行的命令
133
+ */
134
+ exce (cmd) {
135
+ return new Promise((resolve, reject) => {
136
+ exec(cmd, { cwd: this.path }, (error, stdout) => {
137
+ if (error) {
138
+ reject(error)
139
+ return
140
+ }
141
+ resolve(stdout)
142
+ })
143
+ })
144
+ }
145
+ }
package/package.json CHANGED
@@ -1,92 +1,96 @@
1
- {
2
- "name": "node-karin",
3
- "version": "0.0.3",
4
- "private": false,
5
- "homepage": "https://github.com/KarinJS/Karin#readme",
6
- "bugs": {
7
- "url": "https://github.com/KarinJS/Karin/issues"
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/KarinJS/Karin.git"
12
- },
13
- "author": "Karin",
14
- "type": "module",
15
- "imports": {
16
- "#Karin": "./lib/index.js"
17
- },
18
- "main": "./lib/index.js",
19
- "license": "GPL-3.0-only",
20
- "files": [
21
- "/lib/**/*.js",
22
- "/lib/**/*.d.ts",
23
- "/config/defSet/*.yaml",
24
- "/config/view/*.yaml",
25
- "LICENSE",
26
- "package.json",
27
- "README.md"
28
- ],
29
- "workspaces": [
30
- "plugins/**"
31
- ],
32
- "scripts": {
33
- "app": "node .",
34
- "build": "tsc --project tsconfig.json && tsc-alias -p tsconfig.json && npm run fix",
35
- "delete": "pm2 delete ./config/config/pm2.yaml",
36
- "fix": "npx eslint lib/**/*.js --fix",
37
- "init": "node lib/tools/install.js",
38
- "init:dev": "node lib/tools/install.js",
39
- "init:pack": "node lib/tools/install.js",
40
- "js": "node .",
41
- "js:dev": "node . --dev",
42
- "log": "node lib/tools/pm2Log.js",
43
- "monit": "pm2 monit",
44
- "pub": "npm publish --access public",
45
- "restart": "pm2 restart ./config/config/pm2.yaml",
46
- "sort:pack": "npx sort-package-json",
47
- "start": "pm2 start ./config/config/pm2.yaml && pm2 monit",
48
- "stop": "pm2 delete ./config/config/pm2.yaml",
49
- "ts": "tsx ./src/index.ts --dev",
50
- "ts:dev": "tsx ./src/index.ts --dev",
51
- "uninstall": "node lib/tools/uninstall.js",
52
- "ver": "node lib/tools/updateVersion.js"
53
- },
54
- "dependencies": {
55
- "@grpc/grpc-js": "1.10.10",
56
- "@grpc/proto-loader": "0.7.13",
57
- "art-template": "4.13.2",
58
- "axios": "1.7.2",
59
- "chalk": "5.3.0",
60
- "chokidar": "3.6.0",
61
- "express": "4.19.2",
62
- "kritor-proto": "^0.0.6",
63
- "level": "8.0.1",
64
- "lodash": "4.17.21",
65
- "log4js": "6.9.1",
66
- "moment": "2.30.1",
67
- "node-schedule": "2.1.1",
68
- "redis": "4.6.14",
69
- "ws": "8.16.0",
70
- "yaml": "2.4.1"
71
- },
72
- "devDependencies": {
73
- "@types/express": "^4.17.21",
74
- "@types/lodash": "^4.17.5",
75
- "@types/node": "^20.14.8",
76
- "@types/node-schedule": "^2.1.7",
77
- "@types/ws": "8.5.10",
78
- "eslint": "9.5.0",
79
- "neostandard": "^0.7.2",
80
- "sort-package-json": "^2.10.0",
81
- "tsc-alias": "^1.8.10",
82
- "tsx": "^4.15.7",
83
- "typescript": "^4.9.5"
84
- },
85
- "engines": {
86
- "node": ">=18"
87
- },
88
- "publishConfig": {
89
- "access": "public",
90
- "registry": "https://registry.npmjs.org"
91
- }
1
+ {
2
+ "name": "node-karin",
3
+ "version": "0.1.1",
4
+ "private": false,
5
+ "homepage": "https://github.com/KarinJS/Karin#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/KarinJS/Karin/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/KarinJS/Karin.git"
12
+ },
13
+ "license": "GPL-3.0-only",
14
+ "author": "Karin",
15
+ "type": "module",
16
+ "imports": {
17
+ "#Karin": "./lib/index.js"
18
+ },
19
+ "main": "./lib/index.js",
20
+ "bin": {
21
+ "init": "./lib/tools/init.js"
22
+ },
23
+ "files": [
24
+ "/lib/**/*.js",
25
+ "/lib/**/*.d.ts",
26
+ "/config/defSet/*.yaml",
27
+ "/config/view/*.yaml",
28
+ "LICENSE",
29
+ "package.json",
30
+ "README.md"
31
+ ],
32
+ "workspaces": [
33
+ "plugins/**"
34
+ ],
35
+ "scripts": {
36
+ "app": "node .",
37
+ "build": "tsc --project tsconfig.json && tsc-alias -p tsconfig.json && npm run fix",
38
+ "delete": "pm2 delete ./config/config/pm2.yaml",
39
+ "fix": "eslint lib/**/*.js --fix",
40
+ "fix:all": "eslint lib/**/*.js --fix && eslint src/**/*.ts --fix",
41
+ "init": "node lib/tools/install.js",
42
+ "init:dev": "node lib/tools/install.js",
43
+ "init:pack": "node lib/tools/install.js",
44
+ "js": "node .",
45
+ "js:dev": "node . --dev",
46
+ "log": "node lib/tools/pm2Log.js",
47
+ "monit": "pm2 monit",
48
+ "pub": "npm publish --access public",
49
+ "restart": "pm2 restart ./config/config/pm2.yaml",
50
+ "sort:pack": "npx sort-package-json",
51
+ "start": "pm2 start ./config/config/pm2.yaml && pm2 monit",
52
+ "stop": "pm2 delete ./config/config/pm2.yaml",
53
+ "ts": "tsx ./src/index.ts --dev",
54
+ "ts:dev": "tsx ./src/index.ts --dev",
55
+ "uninstall": "node lib/tools/uninstall.js",
56
+ "ver": "node lib/tools/updateVersion.js"
57
+ },
58
+ "dependencies": {
59
+ "@grpc/grpc-js": "1.10.10",
60
+ "@grpc/proto-loader": "0.7.13",
61
+ "art-template": "4.13.2",
62
+ "axios": "1.7.2",
63
+ "chalk": "5.3.0",
64
+ "chokidar": "3.6.0",
65
+ "express": "4.19.2",
66
+ "kritor-proto": "^0.0.6",
67
+ "level": "8.0.1",
68
+ "lodash": "4.17.21",
69
+ "log4js": "6.9.1",
70
+ "moment": "2.30.1",
71
+ "node-schedule": "2.1.1",
72
+ "redis": "4.6.14",
73
+ "ws": "8.16.0",
74
+ "yaml": "2.4.1"
75
+ },
76
+ "devDependencies": {
77
+ "@types/express": "^4.17.21",
78
+ "@types/lodash": "^4.17.5",
79
+ "@types/node": "^20.14.8",
80
+ "@types/node-schedule": "^2.1.7",
81
+ "@types/ws": "8.5.10",
82
+ "eslint": "9.5.0",
83
+ "neostandard": "^0.7.2",
84
+ "sort-package-json": "^2.10.0",
85
+ "tsc-alias": "^1.8.10",
86
+ "tsx": "^4.15.7",
87
+ "typescript": "^4.9.5"
88
+ },
89
+ "engines": {
90
+ "node": ">=18"
91
+ },
92
+ "publishConfig": {
93
+ "access": "public",
94
+ "registry": "https://registry.npmjs.org"
95
+ }
92
96
  }