-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.js
47 lines (46 loc) · 1.8 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import fs from 'fs'
import {StarRunCheckConfig} from "./tools/StarRunCheckConfig.js";
let Cwd = process.cwd().replace(/\\/g, "/")
let Path, Version
logger.info(logger.magenta(`'-------------QwQ--------------`))
try {
Version = await JSON.parse(fs.readFileSync(`${Cwd}/plugins/FanSky_Qs/package.json`, 'utf-8'));
} catch (err) {
Version = {version: "1.5.4"}
}
logger.info(logger.magenta(`----FanSky_Qs插件【${Version.version}】初始化中------`))
const files = fs.readdirSync('./plugins/FanSky_Qs/apps').filter(file => file.endsWith('.js'))
await StarRunCheckConfig()
let ret = []
files.forEach((file) => {
ret.push(import(`./apps/${file}`))
})
ret = await Promise.allSettled(ret)
let apps = {}
let APackageFanError = 0
for (let i in files) {
let name = files[i].replace('.js', '')
if (ret[i].status !== 'fulfilled') {
logger.error(`[FanSky_Qs]载入JS错误:${logger.red(name)}`)
const ARegexFan = /Cannot find package '([^']+)'/;
let AFanReaSon = ret[i].reason + ""
const AMatchFan = AFanReaSon.match(ARegexFan);
if (AMatchFan) {
const APackageNameY = AMatchFan[1];
logger.warn(`请先在${logger.red(`plugins/FanSky_Qs`)}目录运行:${logger.red(`pnpm install`)}安装依赖`)
logger.error(AFanReaSon)
APackageFanError++
} else {
logger.error(ret[i].reason)
}
delete apps[name];
continue
}
apps[name] = ret[i].value[Object.keys(ret[i].value)[0]]
}
logger.info(logger.magenta(`----FanSky_Qs插件载入完成------`))
if (APackageFanError > 0) {
logger.warn(logger.yellow(`---请按提示安装依赖,否则对应功能会无效喵!------`))
logger.warn(logger.yellow(`---请按提示安装依赖,否则对应功能会无效喵!------`))
}
export {apps}