node-karin 0.6.27 → 0.7.0

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.
@@ -1,5 +1,5 @@
1
1
  import { KarinRender, KarinRenderApp, KarinRenderType } from '../types/index.js';
2
- declare class Renderer {
2
+ declare class Renderers {
3
3
  index: number;
4
4
  Apps: Array<KarinRenderApp>;
5
5
  constructor();
@@ -42,5 +42,9 @@ declare class Renderer {
42
42
  /**
43
43
  * 渲染器管理器
44
44
  */
45
- export declare const render: Renderer;
45
+ export declare const render: Renderers;
46
+ /**
47
+ * @description 即将废弃,请使用 `render`
48
+ */
49
+ export declare const Renderer: Renderers;
46
50
  export {};
package/lib/render/app.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { logger } from '../utils/index.js'
2
- class Renderer {
2
+ class Renderers {
3
3
  index
4
4
  Apps
5
5
  constructor () {
@@ -91,4 +91,8 @@ class Renderer {
91
91
  /**
92
92
  * 渲染器管理器
93
93
  */
94
- export const render = new Renderer()
94
+ export const render = new Renderers()
95
+ /**
96
+ * @description 即将废弃,请使用 `render`
97
+ */
98
+ export const Renderer = render
@@ -148,6 +148,7 @@ export declare const common: {
148
148
  getNpmPlugins<T extends boolean>(showDetails: T): Promise<T extends true ? {
149
149
  dir: string;
150
150
  name: fileName;
151
+ isMain: boolean;
151
152
  }[] : string[]>;
152
153
  /**
153
154
  * 获取运行时间
@@ -426,7 +426,7 @@ export const common = new (class Common {
426
426
  if (pkg?.karin) {
427
427
  if (pkg?.main) {
428
428
  const dir = `${name}/${path.dirname(pkg.main).replace(/\.\//, '')}`
429
- list.push({ dir, name: path.basename(pkg.main) })
429
+ list.push({ dir, name: path.basename(pkg.main), isMain: true })
430
430
  }
431
431
  if (pkg?.karin?.apps?.length) {
432
432
  pkg.karin.apps.forEach((app) => {
@@ -434,7 +434,7 @@ export const common = new (class Common {
434
434
  /** 忽略非js */
435
435
  if (!name.endsWith('.js')) { return }
436
436
  const dir = `${name}/${app}`
437
- list.push({ dir, name })
437
+ list.push({ dir, name, isMain: false })
438
438
  })
439
439
  })
440
440
  }
@@ -88,3 +88,88 @@ export declare const config: {
88
88
  change_group(): Promise<void>;
89
89
  "__#2@#review"(): Promise<void>;
90
90
  };
91
+ export declare const Cfg: {
92
+ /**
93
+ * 根项目绝对路径
94
+ */
95
+ projPath: string;
96
+ /**
97
+ * 根项目配置文件夹路径
98
+ */
99
+ projConfigPath: string;
100
+ /**
101
+ * npm包路径
102
+ */
103
+ pkgPath: string;
104
+ /**
105
+ * karin包配置文件夹路径
106
+ */
107
+ pkgConfigPath: string;
108
+ change: Map<string, any>;
109
+ watcher: Map<string, any>;
110
+ review: boolean;
111
+ logger: Logger;
112
+ /** 初始化配置 */
113
+ initCfg(): Promise<void>;
114
+ getPlugins(): Promise<string[]>;
115
+ /**
116
+ * 递归创建目录
117
+ * @param dirname - 要创建的文件夹路径
118
+ */
119
+ mkdir(dirname: string): boolean;
120
+ /**
121
+ * 为每一个插件建立对应的文件夹
122
+ */
123
+ dirPath(_path: string, plugins: string[]): Promise<void>;
124
+ /**
125
+ * 超时时间
126
+ */
127
+ timeout(type?: "ws" | "grpc"): number;
128
+ /**
129
+ * Redis 配置
130
+ * 采用实时读取优化性能
131
+ */
132
+ readonly redis: Redis;
133
+ /**
134
+ * 主人列表
135
+ */
136
+ readonly master: string[];
137
+ /**
138
+ * 管理员列表
139
+ */
140
+ readonly admin: string[];
141
+ /** App管理 */
142
+ readonly App: App;
143
+ /**
144
+ * 基本配置
145
+ */
146
+ readonly Config: Config;
147
+ /**
148
+ * Server 配置文档
149
+ */
150
+ readonly Server: Server;
151
+ /**
152
+ * packageon
153
+ * 实时获取packageon文件
154
+ */
155
+ readonly package: Package;
156
+ /**
157
+ * 获取群配置
158
+ */
159
+ group(group_id?: string): GroupCfg;
160
+ /**
161
+ * 获取配置yaml
162
+ */
163
+ getYaml(type: "defSet" | "config", name: string, isWatch?: boolean): any;
164
+ /**
165
+ * 监听配置文件
166
+ * @param {'defSet'|'config'} type 类型
167
+ * @param {string} name 文件名称 不带后缀
168
+ * @param {string} file 文件路径
169
+ */
170
+ watch(type: "defSet" | "config", name: string, file: string): Promise<true | undefined>;
171
+ change_App(): Promise<void>;
172
+ change_config(): Promise<void>;
173
+ change_group(): Promise<void>;
174
+ "__#2@#review"(): Promise<void>;
175
+ };
@@ -309,3 +309,4 @@ export const config = new (class Cfg {
309
309
  this.review = false
310
310
  }
311
311
  })()
312
+ export const Cfg = config
@@ -61,3 +61,65 @@ export declare const update: {
61
61
  count: string | number;
62
62
  }>;
63
63
  };
64
+ export declare const Update: {
65
+ dir: string;
66
+ /**
67
+ * 更新框架或插件
68
+ * @param path - 插件相对路径
69
+ * @param cmd - 更新命令 默认git pull
70
+ * @param time - 超时时间 默认120s
71
+ */
72
+ update(path: string, cmd?: string, time?: number): Promise<{
73
+ status: string;
74
+ data: string;
75
+ }>;
76
+ /**
77
+ * 获取指定仓库最后一次提交时间日期
78
+ * @param path - 插件相对路径
79
+ */
80
+ getTime(path: string): Promise<string>;
81
+ /**
82
+ * 获取指定仓库最后一次提交哈希值
83
+ * @param {string} path - 插件相对路径
84
+ * @param {boolean} [short] - 是否获取短哈希 默认true
85
+ * @returns {Promise<string>}
86
+ */
87
+ getHash(path: string, short?: boolean): Promise<string>;
88
+ /**
89
+ * 获取指定仓库的提交记录
90
+ * @param {{
91
+ * path: string,
92
+ * count?: number,
93
+ * hash?: string
94
+ * }} options - 参数
95
+ * @param {string} options.path - 插件相对路径
96
+ * @param {number} [options.count] - 获取日志条数 默认1条
97
+ * @param {string} [options.hash] - 指定HEAD
98
+ * @returns {Promise<string>}
99
+ */
100
+ getCommit(options: {
101
+ path: any;
102
+ count?: any;
103
+ hash?: any;
104
+ branch?: any;
105
+ }): Promise<string>;
106
+ /**
107
+ * 检查插件是否有更新
108
+ * @param {string} path - 插件相对路径
109
+ * @param {number} [time] - 超时时间 默认120s
110
+ * @returns {Promise<{status: 'ok'|'failed', data: string|boolean}>}
111
+ */
112
+ checkUpdate(path: fs.PathLike, time?: number): Promise<{
113
+ status: string;
114
+ data: string | undefined;
115
+ count?: undefined;
116
+ } | {
117
+ status: string;
118
+ data: boolean;
119
+ count?: undefined;
120
+ } | {
121
+ status: string;
122
+ data: string;
123
+ count: string | number;
124
+ }>;
125
+ };
@@ -132,3 +132,4 @@ export const update = new (class Update {
132
132
  return { status: 'ok', data, count }
133
133
  }
134
134
  })()
135
+ export const Update = update
@@ -1,60 +1,85 @@
1
1
  import Yaml from 'yaml';
2
+ export type YamlValue = string | boolean | number | object | any[];
2
3
  export declare class YamlEditor {
3
4
  filePath: string;
4
5
  document: Yaml.Document;
5
- constructor(filePath: string);
6
- load(): void;
6
+ constructor(file: string);
7
7
  /**
8
8
  * 获取指定路径的值
9
- * @param path - 路径,用点号分隔,例如:'a.b.c'
9
+ * @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
10
10
  */
11
11
  get(path: string): any;
12
12
  /**
13
13
  * 设置指定路径的值
14
- * @param path - 路径,用点号分隔,例如:'a.b.c'
15
- * @param value - 要设置的值
14
+ * @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
15
+ * @param value - 要设置的值 允许的类型:`string`, `boolean`, `number`, `object`, `array`
16
16
  */
17
- set(path: string | string[], value: string | boolean): null | undefined;
17
+ set(path: string, value: YamlValue): null | undefined;
18
18
  /**
19
19
  * 向指定路径添加新值
20
- * @param path - 路径,用点号分隔,例如:'a.b.c'
20
+ * @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
21
21
  * @param value - 要添加的值
22
22
  */
23
- add(path: string | string[], value: string): void;
23
+ add(path: string, value: YamlValue): void;
24
24
  /**
25
25
  * 删除指定路径
26
- * @param path - 路径,用点号分隔,例如:'a.b.c'
26
+ * @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
27
27
  * @returns 是否删除成功
28
28
  */
29
- del(path: string | string[]): boolean;
29
+ del(path: string): boolean;
30
30
  /**
31
31
  * 向指定路径的数组添加新值,可以选择添加到数组的开始或结束
32
- * @param path - 路径,用点号分隔,例如:'a.b.c'
32
+ * @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
33
33
  * @param value - 要添加的值
34
34
  * @param prepend - 如果为 true,则添加到数组的开头,否则添加到末尾
35
35
  */
36
- append(path: string | string[], value: string, prepend?: boolean): void;
36
+ append(path: string, value: string, prepend?: boolean): void;
37
37
  /**
38
38
  * 检查指定路径的键是否存在
39
39
  * @param path - 路径,用点号分隔
40
40
  */
41
- has(path: string | string[]): boolean;
41
+ has(path: string): boolean;
42
42
  /**
43
43
  * 查询指定路径中是否包含指定的值
44
44
  * @param path - 路径,用点号分隔
45
45
  * @param value - 要查询的值
46
46
  */
47
- hasVal(path: string | string[], value: any): boolean;
47
+ hasval(path: string, value: YamlValue): boolean;
48
+ /**
49
+ * 查询指定路径中是否包含指定的值
50
+ * @param path - 路径,用点号分隔
51
+ * @param value - 要查询的值
52
+ * @deprecated 请使用 `hasval` 代替
53
+ */
54
+ hasVal(path: string, value: YamlValue): boolean;
48
55
  /**
49
56
  * 向根节点新增元素,如果根节点不是数组,则将其转换为数组再新增元素
50
57
  * @param value - 要新增的元素
51
58
  */
52
- pusharr(value: any): false | undefined;
59
+ pusharr(value: YamlValue): false | undefined;
53
60
  /**
54
61
  * 根据索引从根节点数组删除元素
55
62
  * @param index - 要删除元素的索引
56
63
  */
57
64
  delarr(index: number): boolean;
65
+ /**
66
+ * 获取指定路径的pair对象
67
+ * @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
68
+ */
69
+ getpair(path: string): any;
70
+ /**
71
+ * 设置指定键的注释
72
+ * @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
73
+ * @param comment - 要设置的注释
74
+ * @param prepend - 如果为 true,则添加到注释的开头,否则添加到同一行的末尾
75
+ */
76
+ comment(path: string, comment: string, prepend?: boolean): void;
77
+ /**
78
+ * 删除指定键的注释
79
+ * @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
80
+ * @param type - 要删除的注释类型,`before` 为注释前,`after` 为注释后,`all` 为全部
81
+ */
82
+ uncomment(path: string, type?: 'before' | 'after' | 'all'): void;
58
83
  /**
59
84
  * 保存文件
60
85
  */
@@ -4,30 +4,20 @@
4
4
  * https://github.com/OpenAI
5
5
  */
6
6
  import fs from 'fs'
7
- import Yaml from 'yaml'
8
7
  import lodash from 'lodash'
9
8
  import logger from './logger.js'
9
+ import Yaml, { isMap, isSeq, isPair } from 'yaml'
10
10
  export class YamlEditor {
11
11
  filePath
12
12
  document
13
- constructor (filePath) {
14
- this.filePath = filePath
15
- this.load()
16
- }
17
-
18
- load () {
19
- try {
20
- const fileContents = fs.readFileSync(this.filePath, 'utf8')
21
- this.document = Yaml.parseDocument(fileContents)
22
- logger.debug('[YamlEditor] 文件加载成功')
23
- } catch (error) {
24
- logger.error(`[YamlEditor] 加载文件时出错:${error}`)
25
- }
13
+ constructor (file) {
14
+ this.filePath = file
15
+ this.document = Yaml.parseDocument(fs.readFileSync(file, 'utf8'))
26
16
  }
27
17
 
28
18
  /**
29
19
  * 获取指定路径的值
30
- * @param path - 路径,用点号分隔,例如:'a.b.c'
20
+ * @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
31
21
  */
32
22
  get (path) {
33
23
  try {
@@ -41,13 +31,13 @@ export class YamlEditor {
41
31
 
42
32
  /**
43
33
  * 设置指定路径的值
44
- * @param path - 路径,用点号分隔,例如:'a.b.c'
45
- * @param value - 要设置的值
34
+ * @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
35
+ * @param value - 要设置的值 允许的类型:`string`, `boolean`, `number`, `object`, `array`
46
36
  */
47
37
  set (path, value) {
48
38
  try {
49
- path = typeof path === 'string' ? path.split('.') : path
50
- this.document.setIn(path, value)
39
+ const _path = typeof path === 'string' ? path.split('.') : path
40
+ this.document.setIn(_path, value)
51
41
  } catch (error) {
52
42
  logger.error(`[YamlEditor] 设置数据时出错:${error}`)
53
43
  return null
@@ -56,13 +46,13 @@ export class YamlEditor {
56
46
 
57
47
  /**
58
48
  * 向指定路径添加新值
59
- * @param path - 路径,用点号分隔,例如:'a.b.c'
49
+ * @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
60
50
  * @param value - 要添加的值
61
51
  */
62
52
  add (path, value) {
63
53
  try {
64
- path = typeof path === 'string' ? path.split('.') : path
65
- this.document.addIn(path, value)
54
+ const _path = typeof path === 'string' ? path.split('.') : path
55
+ this.document.addIn(_path, value)
66
56
  logger.debug(`[YamlEditor] 已在 ${path} 添加新的值`)
67
57
  } catch (error) {
68
58
  logger.error(`[YamlEditor] 添加数据时出错:${error}`)
@@ -71,13 +61,13 @@ export class YamlEditor {
71
61
 
72
62
  /**
73
63
  * 删除指定路径
74
- * @param path - 路径,用点号分隔,例如:'a.b.c'
64
+ * @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
75
65
  * @returns 是否删除成功
76
66
  */
77
67
  del (path) {
78
68
  try {
79
- path = typeof path === 'string' ? path.split('.') : path
80
- this.document.deleteIn(path)
69
+ const _path = typeof path === 'string' ? path.split('.') : path
70
+ this.document.deleteIn(_path)
81
71
  return true
82
72
  } catch (error) {
83
73
  logger.error(`[YamlEditor] 删除数据时出错:${error}`)
@@ -87,25 +77,21 @@ export class YamlEditor {
87
77
 
88
78
  /**
89
79
  * 向指定路径的数组添加新值,可以选择添加到数组的开始或结束
90
- * @param path - 路径,用点号分隔,例如:'a.b.c'
80
+ * @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
91
81
  * @param value - 要添加的值
92
82
  * @param prepend - 如果为 true,则添加到数组的开头,否则添加到末尾
93
83
  */
94
84
  append (path, value, prepend = false) {
95
85
  try {
96
- path = typeof path === 'string' ? path.split('.') : path || []
97
- let current = this.document.getIn(path)
86
+ const _path = typeof path === 'string' ? path.split('.') : path || []
87
+ let current = this.document.getIn(_path)
98
88
  if (!current) {
99
89
  current = new Yaml.YAMLSeq()
100
- this.document.setIn(path, current)
90
+ this.document.setIn(_path, current)
101
91
  } else if (!(current instanceof Yaml.YAMLSeq)) {
102
92
  throw new Error('[YamlEditor] 指定的路径不是数组')
103
93
  } else {
104
- if (prepend) {
105
- current.items.unshift(value)
106
- } else {
107
- current.add(value)
108
- }
94
+ prepend ? current.items.unshift(value) : current.add(value)
109
95
  }
110
96
  logger.debug(`[YamlEditor] 已向 ${path} 数组${prepend ? '开头' : '末尾'}添加新元素:${value}`)
111
97
  } catch (error) {
@@ -119,8 +105,8 @@ export class YamlEditor {
119
105
  */
120
106
  has (path) {
121
107
  try {
122
- path = typeof path === 'string' ? path.split('.') : path
123
- return this.document.hasIn(path)
108
+ const _path = typeof path === 'string' ? path.split('.') : path
109
+ return this.document.hasIn(_path)
124
110
  } catch (error) {
125
111
  logger.error(`[YamlEditor] 检查路径是否存在时出错:${error}`)
126
112
  return false
@@ -132,10 +118,10 @@ export class YamlEditor {
132
118
  * @param path - 路径,用点号分隔
133
119
  * @param value - 要查询的值
134
120
  */
135
- hasVal (path, value) {
121
+ hasval (path, value) {
136
122
  try {
137
- path = typeof path === 'string' ? path.split('.') : path
138
- const current = this.document.getIn(path)
123
+ const _path = typeof path === 'string' ? path.split('.') : path
124
+ const current = this.document.getIn(_path)
139
125
  if (!current) { return false }
140
126
  /** 检查当前节点是否包含指定的值 */
141
127
  if (current instanceof Yaml.YAMLSeq) {
@@ -154,6 +140,16 @@ export class YamlEditor {
154
140
  }
155
141
  }
156
142
 
143
+ /**
144
+ * 查询指定路径中是否包含指定的值
145
+ * @param path - 路径,用点号分隔
146
+ * @param value - 要查询的值
147
+ * @deprecated 请使用 `hasval` 代替
148
+ */
149
+ hasVal (path, value) {
150
+ return this.hasval(path, value)
151
+ }
152
+
157
153
  /**
158
154
  * 向根节点新增元素,如果根节点不是数组,则将其转换为数组再新增元素
159
155
  * @param value - 要新增的元素
@@ -194,6 +190,63 @@ export class YamlEditor {
194
190
  }
195
191
  }
196
192
 
193
+ /**
194
+ * 获取指定路径的pair对象
195
+ * @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
196
+ */
197
+ getpair (path) {
198
+ if (!path) { throw new Error('path is required') }
199
+ const keys = path.split('.')
200
+ // 好多any啊,我要当any糕手~
201
+ let pair = this.document.contents
202
+ keys.forEach(key => {
203
+ if (isMap(pair)) {
204
+ pair = pair.items.find((item) => item.key.value === key)
205
+ } else if (isSeq(pair)) {
206
+ pair = pair.items.find((item) => item.value === key)
207
+ } else if (isPair(pair)) {
208
+ pair = pair.value.items.find((item) => item.key.value === key)
209
+ }
210
+ })
211
+ return pair
212
+ }
213
+
214
+ /**
215
+ * 设置指定键的注释
216
+ * @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
217
+ * @param comment - 要设置的注释
218
+ * @param prepend - 如果为 true,则添加到注释的开头,否则添加到同一行的末尾
219
+ */
220
+ comment (path, comment, prepend = false) {
221
+ if (!path) { throw new Error('[YamlEditor] path 不能为空') }
222
+ const pair = this.getpair(path)
223
+ if (!pair) { throw new Error(`[YamlEditor] 未找到节点 ${path}`) }
224
+ if (prepend) {
225
+ pair.key.commentBefore = comment
226
+ } else {
227
+ pair.key.comment = comment
228
+ }
229
+ }
230
+
231
+ /**
232
+ * 删除指定键的注释
233
+ * @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
234
+ * @param type - 要删除的注释类型,`before` 为注释前,`after` 为注释后,`all` 为全部
235
+ */
236
+ uncomment (path, type = 'all') {
237
+ if (!path) { throw new Error('[YamlEditor] path 不能为空') }
238
+ const pair = this.getpair(path)
239
+ if (!pair) { throw new Error(`[YamlEditor] 未找到节点 ${path}`) }
240
+ if (type === 'all') {
241
+ delete pair.key.comment
242
+ delete pair.key.commentBefore
243
+ } else if (type === 'before') {
244
+ delete pair.key.commentBefore
245
+ } else if (type === 'after') {
246
+ delete pair.key.comment
247
+ }
248
+ }
249
+
197
250
  /**
198
251
  * 保存文件
199
252
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-karin",
3
- "version": "0.6.27",
3
+ "version": "0.7.0",
4
4
  "private": false,
5
5
  "description": "基于 Kritor 进行开发的nodejs机器人框架",
6
6
  "homepage": "https://github.com/KarinJS/Karin",
@@ -17,14 +17,8 @@
17
17
  "main": "./lib/index.js",
18
18
  "types": "./lib/index.d.ts",
19
19
  "bin": {
20
- "app": "lib/index.js",
21
- "debug": "lib/index.js",
22
- "dev": "lib/index.js",
23
20
  "init": "lib/cli/init.js",
24
- "log": "lib/cli/log.js",
25
- "rs": "lib/cli/restart.js",
26
- "start": "lib/cli/start.js",
27
- "stop": "lib/cli/stop.js"
21
+ "karin": "lib/cli/karin.js"
28
22
  },
29
23
  "files": [
30
24
  "/lib/**/*.js",
@@ -49,35 +43,36 @@
49
43
  "sort": "npx sort-package-json"
50
44
  },
51
45
  "dependencies": {
52
- "@grpc/grpc-js": "1.10.11",
46
+ "@grpc/grpc-js": "1.11.1",
53
47
  "@grpc/proto-loader": "0.7.13",
54
48
  "art-template": "4.13.2",
55
49
  "axios": "1.7.2",
56
50
  "chalk": "5.3.0",
57
51
  "chokidar": "3.6.0",
52
+ "commander": "^12.1.0",
58
53
  "express": "4.19.2",
59
- "kritor-proto": "latest",
54
+ "kritor-proto": "^1.0.2",
60
55
  "level": "8.0.1",
61
56
  "lodash": "4.17.21",
62
57
  "log4js": "6.9.1",
63
58
  "moment": "2.30.1",
64
59
  "node-schedule": "2.1.1",
65
- "redis": "4.6.14",
60
+ "redis": "4.6.15",
66
61
  "ws": "8.18.0",
67
62
  "yaml": "2.4.5"
68
63
  },
69
64
  "devDependencies": {
70
- "@types/express": "latest",
71
- "@types/lodash": "latest",
72
- "@types/node": "latest",
73
- "@types/node-schedule": "latest",
74
- "@types/ws": "latest",
75
- "eslint": "latest",
76
- "neostandard": "latest",
77
- "sort-package-json": "latest",
78
- "tsc-alias": "latest",
79
- "tsx": "latest",
80
- "typescript": "latest"
65
+ "@types/express": "^4.17.21",
66
+ "@types/lodash": "^4.17.7",
67
+ "@types/node": "^20.14.11",
68
+ "@types/node-schedule": "^2.1.7",
69
+ "@types/ws": "^8.5.11",
70
+ "eslint": "^9.7.0",
71
+ "neostandard": "^0.11.1",
72
+ "sort-package-json": "^2.10.0",
73
+ "tsc-alias": "^1.8.10",
74
+ "tsx": "^4.16.2",
75
+ "typescript": "^5.5.3"
81
76
  },
82
77
  "engines": {
83
78
  "node": ">=18"
package/lib/cli/log.js DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env node
2
- import fs from 'fs'
3
- import yaml from 'yaml'
4
- import path from 'path'
5
- import { spawn } from 'child_process'
6
- const cwd = process.cwd()
7
- const _path = path.resolve(cwd + '/config/config/pm2.yaml')
8
- const data = yaml.parse(fs.readFileSync(_path, 'utf8'))
9
- const name = data.apps[0].name
10
- const lines = data.lines || 1000
11
- const cmd = process.platform === 'win32' ? 'pm2.cmd' : 'pm2'
12
- spawn(cmd, ['logs', '--lines', lines, name], { stdio: 'inherit', shell: true, cwd })
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env node
2
- import fs from 'fs'
3
- import { execSync } from 'child_process'
4
- import { karinDir } from '../core/dir.js'
5
- let config = process.cwd() + '/config/config/pm2.yaml'
6
- if (!fs.existsSync(config)) {
7
- config = `${karinDir}/config/config/pm2.yaml`
8
- }
9
- const cmd = `pm2 restart ${config}`
10
- execSync(cmd, { stdio: 'inherit', cwd: process.cwd(), env: process.env })
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/lib/cli/start.js DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env node
2
- import fs from 'fs'
3
- import { execSync } from 'child_process'
4
- import { karinDir } from '../core/dir.js'
5
- let config = process.cwd() + '/config/config/pm2.yaml'
6
- if (!fs.existsSync(config)) {
7
- config = `${karinDir}/config/config/pm2.yaml`
8
- }
9
- const cmd = `pm2 start ${config}`
10
- execSync(cmd, { stdio: 'inherit', cwd: process.cwd(), env: process.env })
package/lib/cli/stop.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};