node-karin 0.6.26 → 0.6.27
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.
- package/lib/index.d.ts +1 -1
- package/lib/utils/common.js +11 -1
- package/lib/utils/config.d.ts +1 -1
- package/lib/utils/config.js +8 -3
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export declare const Cfg: {
|
|
|
37
37
|
review: boolean;
|
|
38
38
|
logger: import("log4js").Logger;
|
|
39
39
|
initCfg(): Promise<void>;
|
|
40
|
-
getPlugins(): string[]
|
|
40
|
+
getPlugins(): Promise<string[]>;
|
|
41
41
|
mkdir(dirname: string): boolean;
|
|
42
42
|
dirPath(_path: string, plugins: string[]): Promise<void>;
|
|
43
43
|
timeout(type?: "ws" | "grpc"): number;
|
package/lib/utils/common.js
CHANGED
|
@@ -406,7 +406,17 @@ export const common = new (class Common {
|
|
|
406
406
|
const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'))
|
|
407
407
|
const dependencies = Object.keys(pkg.dependencies).filter((name) => !pkgdependencies.includes(name))
|
|
408
408
|
if (!showDetails) {
|
|
409
|
-
|
|
409
|
+
const list = []
|
|
410
|
+
// 检查pkg是否存在karin字段
|
|
411
|
+
const readPackageJson = async (name) => {
|
|
412
|
+
try {
|
|
413
|
+
const pkgPath = path.join(process.cwd(), 'node_modules', name, 'package.json')
|
|
414
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
|
|
415
|
+
if (pkg?.karin) { list.push(name) }
|
|
416
|
+
} catch { }
|
|
417
|
+
}
|
|
418
|
+
await Promise.all(dependencies.map(readPackageJson))
|
|
419
|
+
return list
|
|
410
420
|
} else {
|
|
411
421
|
const list = []
|
|
412
422
|
const readPackageJson = async (name) => {
|
package/lib/utils/config.d.ts
CHANGED
package/lib/utils/config.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from 'path'
|
|
2
2
|
import { karinDir } from '../core/dir.js'
|
|
3
3
|
import { fs, yaml as Yaml, chokidar } from '../modules.js'
|
|
4
|
+
import { common } from './common.js'
|
|
4
5
|
/**
|
|
5
6
|
* 配置文件
|
|
6
7
|
*/
|
|
@@ -57,7 +58,7 @@ export const config = new (class Cfg {
|
|
|
57
58
|
})
|
|
58
59
|
}
|
|
59
60
|
/** 为每个插件包创建统一存储的文件夹 */
|
|
60
|
-
const plugins = this.getPlugins()
|
|
61
|
+
const plugins = await this.getPlugins()
|
|
61
62
|
const DataList = [
|
|
62
63
|
'data',
|
|
63
64
|
'temp',
|
|
@@ -69,10 +70,14 @@ export const config = new (class Cfg {
|
|
|
69
70
|
this.logger = (await import('./logger.js')).default
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
getPlugins () {
|
|
73
|
+
async getPlugins () {
|
|
74
|
+
const list = []
|
|
73
75
|
const files = fs.readdirSync('./plugins', { withFileTypes: true })
|
|
74
76
|
// 过滤掉非karin-plugin-开头的文件夹
|
|
75
|
-
|
|
77
|
+
list.push(...files.filter(file => file.isDirectory() && (file.name.startsWith('karin-plugin-'))).map(dir => dir.name))
|
|
78
|
+
// 获取npm插件
|
|
79
|
+
list.push(...(await common.getNpmPlugins(false)))
|
|
80
|
+
return list
|
|
76
81
|
}
|
|
77
82
|
|
|
78
83
|
/**
|