node-karin 1.10.7 → 1.10.9
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/CHANGELOG.md +19 -0
- package/dist/index.d.ts +133 -9
- package/dist/index.mjs +509 -258
- package/dist/web/assets/css/index-aqeyhZYB.css.br +0 -0
- package/dist/web/assets/js/components-Cd6WUI5U.js.br +0 -0
- package/dist/web/assets/js/entry-DDvBvSzh.js.br +0 -0
- package/dist/web/assets/js/hooks-Bz0PQDoj.js.br +0 -0
- package/dist/web/assets/js/page-404.tsx-Cm9mH0_M.js +1 -0
- package/dist/web/assets/js/page-dashboard-CikEVMpJ.js.br +0 -0
- package/dist/web/assets/js/page-loading.tsx-BG2mVZvj.js.br +0 -0
- package/dist/web/assets/js/page-login.tsx-os7MxJ9E.js.br +0 -0
- package/dist/web/assets/js/{utils-DV3Ugabq.js → utils-DrIY2_89.js} +1 -1
- package/dist/web/assets/js/vendor-heroui-BfEoQ40M.js.br +0 -0
- package/dist/web/assets/js/vendor-others-BQzLsA1F.js.br +0 -0
- package/dist/web/assets/js/vendor-react-Dzwr57aT.js.br +0 -0
- package/dist/web/assets/js/vendor-visual-DsVosOWE.js.br +0 -0
- package/dist/web/index.html +10 -10
- package/package.json +1 -1
- package/dist/web/assets/css/index-Bq0kgume.css.br +0 -0
- package/dist/web/assets/js/components-C8mD5H9u.js.br +0 -0
- package/dist/web/assets/js/entry-B3jpAEDK.js.br +0 -0
- package/dist/web/assets/js/hooks-CrFgaybL.js.br +0 -0
- package/dist/web/assets/js/page-404.tsx-Dbb54KqG.js +0 -1
- package/dist/web/assets/js/page-dashboard-DNNUfIJO.js.br +0 -0
- package/dist/web/assets/js/page-loading.tsx-BUSG9gGO.js.br +0 -0
- package/dist/web/assets/js/page-login.tsx-CotDRIUl.js.br +0 -0
- package/dist/web/assets/js/vendor-heroui-DqoPVa63.js.br +0 -0
- package/dist/web/assets/js/vendor-others-DGUjmv7c.js.br +0 -0
- package/dist/web/assets/js/vendor-react-ZA9Ag8xC.js.br +0 -0
- package/dist/web/assets/js/vendor-visual-CTuViOkk.js.br +0 -0
package/dist/index.mjs
CHANGED
|
@@ -76,8 +76,8 @@ function getDefaultExportFromCjs(x) {
|
|
|
76
76
|
function requireMain() {
|
|
77
77
|
if (hasRequiredMain) return main$1.exports;
|
|
78
78
|
hasRequiredMain = 1;
|
|
79
|
-
const
|
|
80
|
-
const
|
|
79
|
+
const fs39 = fs15;
|
|
80
|
+
const path38 = path;
|
|
81
81
|
const os5 = require$$2;
|
|
82
82
|
const crypto9 = require$$22;
|
|
83
83
|
const packageJson = require$$4;
|
|
@@ -180,7 +180,7 @@ function requireMain() {
|
|
|
180
180
|
if (options && options.path && options.path.length > 0) {
|
|
181
181
|
if (Array.isArray(options.path)) {
|
|
182
182
|
for (const filepath of options.path) {
|
|
183
|
-
if (
|
|
183
|
+
if (fs39.existsSync(filepath)) {
|
|
184
184
|
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
185
185
|
}
|
|
186
186
|
}
|
|
@@ -188,15 +188,15 @@ function requireMain() {
|
|
|
188
188
|
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
189
189
|
}
|
|
190
190
|
} else {
|
|
191
|
-
possibleVaultPath =
|
|
191
|
+
possibleVaultPath = path38.resolve(process.cwd(), ".env.vault");
|
|
192
192
|
}
|
|
193
|
-
if (
|
|
193
|
+
if (fs39.existsSync(possibleVaultPath)) {
|
|
194
194
|
return possibleVaultPath;
|
|
195
195
|
}
|
|
196
196
|
return null;
|
|
197
197
|
}
|
|
198
198
|
function _resolveHome(envPath) {
|
|
199
|
-
return envPath[0] === "~" ?
|
|
199
|
+
return envPath[0] === "~" ? path38.join(os5.homedir(), envPath.slice(1)) : envPath;
|
|
200
200
|
}
|
|
201
201
|
function _configVault2(options) {
|
|
202
202
|
const debug3 = Boolean(options && options.debug);
|
|
@@ -212,7 +212,7 @@ function requireMain() {
|
|
|
212
212
|
return { parsed };
|
|
213
213
|
}
|
|
214
214
|
function configDotenv2(options) {
|
|
215
|
-
const dotenvPath =
|
|
215
|
+
const dotenvPath = path38.resolve(process.cwd(), ".env");
|
|
216
216
|
let encoding = "utf8";
|
|
217
217
|
const debug3 = Boolean(options && options.debug);
|
|
218
218
|
if (options && options.encoding) {
|
|
@@ -237,7 +237,7 @@ function requireMain() {
|
|
|
237
237
|
const parsedAll = {};
|
|
238
238
|
for (const path210 of optionPaths) {
|
|
239
239
|
try {
|
|
240
|
-
const parsed = DotenvModule.parse(
|
|
240
|
+
const parsed = DotenvModule.parse(fs39.readFileSync(path210, { encoding }));
|
|
241
241
|
DotenvModule.populate(parsedAll, parsed, options);
|
|
242
242
|
} catch (e) {
|
|
243
243
|
if (debug3) {
|
|
@@ -525,14 +525,18 @@ var init_env = __esm({
|
|
|
525
525
|
});
|
|
526
526
|
|
|
527
527
|
// src/env/key/redis.ts
|
|
528
|
-
var REDIS_PLUGIN_LIST_CACHE_KEY, REDIS_DEPENDENCIES_LIST_CACHE_KEY, REDIS_DEPENDENCIES_LIST_CACHE_EXPIRE,
|
|
528
|
+
var REDIS_PLUGIN_LIST_CACHE_KEY, REDIS_DEPENDENCIES_LIST_CACHE_KEY, REDIS_PLUGIN_MARKET_LIST_CACHE_KEY, REDIS_LOCAL_PLUGIN_LIST_CACHE_KEY, REDIS_LOCAL_PLUGIN_LIST_CACHE_KEY_FRONTEND, REDIS_DEPENDENCIES_LIST_CACHE_EXPIRE, REDIS_PLUGIN_MARKET_LIST_CACHE_EXPIRE, REDIS_PLUGIN_LIST_CACHE_EXPIRE, REDIS_LOCAL_PLUGIN_LIST_CACHE_EXPIRE_FRONTEND;
|
|
529
529
|
var init_redis = __esm({
|
|
530
530
|
"src/env/key/redis.ts"() {
|
|
531
531
|
REDIS_PLUGIN_LIST_CACHE_KEY = "karin:market:plugin:list";
|
|
532
532
|
REDIS_DEPENDENCIES_LIST_CACHE_KEY = "karin:dependencies:list";
|
|
533
|
-
REDIS_DEPENDENCIES_LIST_CACHE_EXPIRE = 3 * 60 * 60;
|
|
534
533
|
REDIS_PLUGIN_MARKET_LIST_CACHE_KEY = "karin:market:plugin:list:v2";
|
|
535
|
-
|
|
534
|
+
REDIS_LOCAL_PLUGIN_LIST_CACHE_KEY = "karin:local:plugin:list";
|
|
535
|
+
REDIS_LOCAL_PLUGIN_LIST_CACHE_KEY_FRONTEND = "karin:local:plugin:list:frontend";
|
|
536
|
+
REDIS_DEPENDENCIES_LIST_CACHE_EXPIRE = 24 * 60 * 60;
|
|
537
|
+
REDIS_PLUGIN_MARKET_LIST_CACHE_EXPIRE = 24 * 60 * 60;
|
|
538
|
+
REDIS_PLUGIN_LIST_CACHE_EXPIRE = 24 * 60 * 60;
|
|
539
|
+
REDIS_LOCAL_PLUGIN_LIST_CACHE_EXPIRE_FRONTEND = 24 * 60 * 60;
|
|
536
540
|
}
|
|
537
541
|
});
|
|
538
542
|
|
|
@@ -1287,9 +1291,9 @@ var init_data = __esm({
|
|
|
1287
1291
|
stream3.on("end", () => resolve(Buffer.concat(chunks)));
|
|
1288
1292
|
stream3.on("error", (error) => reject(error));
|
|
1289
1293
|
});
|
|
1290
|
-
readFile = async (
|
|
1294
|
+
readFile = async (path38) => {
|
|
1291
1295
|
try {
|
|
1292
|
-
const data = await fs5.promises.readFile(
|
|
1296
|
+
const data = await fs5.promises.readFile(path38);
|
|
1293
1297
|
return data;
|
|
1294
1298
|
} catch (error) {
|
|
1295
1299
|
logger.error(error);
|
|
@@ -1305,36 +1309,36 @@ var init_data = __esm({
|
|
|
1305
1309
|
var readJsonSync, writeJsonSync, readJson, writeJson, json;
|
|
1306
1310
|
var init_json = __esm({
|
|
1307
1311
|
"src/utils/fs/json.ts"() {
|
|
1308
|
-
readJsonSync = (
|
|
1312
|
+
readJsonSync = (path38, isThrow = false) => {
|
|
1309
1313
|
try {
|
|
1310
|
-
const data = fs5.readFileSync(
|
|
1314
|
+
const data = fs5.readFileSync(path38, "utf8");
|
|
1311
1315
|
return JSON.parse(data);
|
|
1312
1316
|
} catch (error) {
|
|
1313
1317
|
if (isThrow) throw error;
|
|
1314
1318
|
return null;
|
|
1315
1319
|
}
|
|
1316
1320
|
};
|
|
1317
|
-
writeJsonSync = (
|
|
1321
|
+
writeJsonSync = (path38, data, isThrow = false) => {
|
|
1318
1322
|
try {
|
|
1319
|
-
fs5.writeFileSync(
|
|
1323
|
+
fs5.writeFileSync(path38, JSON.stringify(data, null, 2));
|
|
1320
1324
|
return true;
|
|
1321
1325
|
} catch (error) {
|
|
1322
1326
|
if (isThrow) throw error;
|
|
1323
1327
|
return false;
|
|
1324
1328
|
}
|
|
1325
1329
|
};
|
|
1326
|
-
readJson = async (
|
|
1330
|
+
readJson = async (path38, isThrow = false) => {
|
|
1327
1331
|
try {
|
|
1328
|
-
const data = await fs5.promises.readFile(
|
|
1332
|
+
const data = await fs5.promises.readFile(path38, "utf8");
|
|
1329
1333
|
return JSON.parse(data);
|
|
1330
1334
|
} catch (error) {
|
|
1331
1335
|
if (isThrow) throw error;
|
|
1332
1336
|
return null;
|
|
1333
1337
|
}
|
|
1334
1338
|
};
|
|
1335
|
-
writeJson = async (
|
|
1339
|
+
writeJson = async (path38, data, isThrow = false) => {
|
|
1336
1340
|
try {
|
|
1337
|
-
await fs5.promises.writeFile(
|
|
1341
|
+
await fs5.promises.writeFile(path38, JSON.stringify(data, null, 2));
|
|
1338
1342
|
return true;
|
|
1339
1343
|
} catch (error) {
|
|
1340
1344
|
if (isThrow) throw error;
|
|
@@ -1530,10 +1534,10 @@ var init_yaml = __esm({
|
|
|
1530
1534
|
* 获取指定路径的值
|
|
1531
1535
|
* @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
|
|
1532
1536
|
*/
|
|
1533
|
-
get(
|
|
1537
|
+
get(path38) {
|
|
1534
1538
|
try {
|
|
1535
|
-
if (!
|
|
1536
|
-
return lodash3.get(this.document.toJSON(),
|
|
1539
|
+
if (!path38) return this.document.toJSON();
|
|
1540
|
+
return lodash3.get(this.document.toJSON(), path38);
|
|
1537
1541
|
} catch (error) {
|
|
1538
1542
|
logger.error(`[YamlEditor] \u83B7\u53D6\u6570\u636E\u65F6\u51FA\u9519\uFF1A${error}`);
|
|
1539
1543
|
return null;
|
|
@@ -1545,9 +1549,9 @@ var init_yaml = __esm({
|
|
|
1545
1549
|
* @param value - 要设置的值 允许的类型:`string`, `boolean`, `number`, `object`, `array`
|
|
1546
1550
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1547
1551
|
*/
|
|
1548
|
-
set(
|
|
1552
|
+
set(path38, value, isSplit = true) {
|
|
1549
1553
|
try {
|
|
1550
|
-
const _path = typeof
|
|
1554
|
+
const _path = typeof path38 === "string" ? isSplit ? path38.split(".") : [path38] : path38;
|
|
1551
1555
|
this.document.setIn(_path, value);
|
|
1552
1556
|
return true;
|
|
1553
1557
|
} catch (error) {
|
|
@@ -1561,11 +1565,11 @@ var init_yaml = __esm({
|
|
|
1561
1565
|
* @param value - 要添加的值
|
|
1562
1566
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1563
1567
|
*/
|
|
1564
|
-
add(
|
|
1568
|
+
add(path38, value, isSplit = true) {
|
|
1565
1569
|
try {
|
|
1566
|
-
const _path = typeof
|
|
1570
|
+
const _path = typeof path38 === "string" ? isSplit ? path38.split(".") : [path38] : path38;
|
|
1567
1571
|
this.document.addIn(_path, value);
|
|
1568
|
-
logger.debug(`[YamlEditor] \u5DF2\u5728 ${
|
|
1572
|
+
logger.debug(`[YamlEditor] \u5DF2\u5728 ${path38} \u6DFB\u52A0\u65B0\u7684\u503C`);
|
|
1569
1573
|
return true;
|
|
1570
1574
|
} catch (error) {
|
|
1571
1575
|
logger.error(`[YamlEditor] \u6DFB\u52A0\u6570\u636E\u65F6\u51FA\u9519\uFF1A${error}`);
|
|
@@ -1578,9 +1582,9 @@ var init_yaml = __esm({
|
|
|
1578
1582
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1579
1583
|
* @returns 是否删除成功
|
|
1580
1584
|
*/
|
|
1581
|
-
del(
|
|
1585
|
+
del(path38, isSplit = true) {
|
|
1582
1586
|
try {
|
|
1583
|
-
const _path = typeof
|
|
1587
|
+
const _path = typeof path38 === "string" ? isSplit ? path38.split(".") : [path38] : path38;
|
|
1584
1588
|
this.document.deleteIn(_path);
|
|
1585
1589
|
return true;
|
|
1586
1590
|
} catch (error) {
|
|
@@ -1595,9 +1599,9 @@ var init_yaml = __esm({
|
|
|
1595
1599
|
* @param prepend - 如果为 true,则添加到数组的开头,否则添加到末尾
|
|
1596
1600
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1597
1601
|
*/
|
|
1598
|
-
append(
|
|
1602
|
+
append(path38, value, prepend = false, isSplit = true) {
|
|
1599
1603
|
try {
|
|
1600
|
-
const _path = typeof
|
|
1604
|
+
const _path = typeof path38 === "string" ? isSplit ? path38.split(".") : [path38] : path38;
|
|
1601
1605
|
let current = this.document.getIn(_path);
|
|
1602
1606
|
if (!current) {
|
|
1603
1607
|
current = new YAML.YAMLSeq();
|
|
@@ -1608,7 +1612,7 @@ var init_yaml = __esm({
|
|
|
1608
1612
|
} else {
|
|
1609
1613
|
prepend ? current.items.unshift(value) : current.add(value);
|
|
1610
1614
|
}
|
|
1611
|
-
logger.debug(`[YamlEditor] \u5DF2\u5411 ${
|
|
1615
|
+
logger.debug(`[YamlEditor] \u5DF2\u5411 ${path38} \u6570\u7EC4${prepend ? "\u5F00\u5934" : "\u672B\u5C3E"}\u6DFB\u52A0\u65B0\u5143\u7D20\uFF1A${value}`);
|
|
1612
1616
|
return true;
|
|
1613
1617
|
} catch (error) {
|
|
1614
1618
|
logger.error(`[YamlEditor] \u5411\u6570\u7EC4\u6DFB\u52A0\u5143\u7D20\u65F6\u51FA\u9519\uFF1A${error}`);
|
|
@@ -1621,9 +1625,9 @@ var init_yaml = __esm({
|
|
|
1621
1625
|
* @param value - 要删除的值
|
|
1622
1626
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1623
1627
|
*/
|
|
1624
|
-
remove(
|
|
1628
|
+
remove(path38, value, isSplit = true) {
|
|
1625
1629
|
try {
|
|
1626
|
-
const _path = typeof
|
|
1630
|
+
const _path = typeof path38 === "string" ? isSplit ? path38.split(".") : [path38] : path38;
|
|
1627
1631
|
const current = this.document.getIn(_path);
|
|
1628
1632
|
if (!current) {
|
|
1629
1633
|
logger.error("[YamlEditor] \u6307\u5B9A\u7684\u8DEF\u5F84\u4E0D\u5B58\u5728");
|
|
@@ -1639,7 +1643,7 @@ var init_yaml = __esm({
|
|
|
1639
1643
|
return false;
|
|
1640
1644
|
}
|
|
1641
1645
|
current.items.splice(index6, 1);
|
|
1642
|
-
logger.debug(`[YamlEditor] \u5DF2\u4ECE ${
|
|
1646
|
+
logger.debug(`[YamlEditor] \u5DF2\u4ECE ${path38} \u6570\u7EC4\u5220\u9664\u5143\u7D20\uFF1A${value}`);
|
|
1643
1647
|
return true;
|
|
1644
1648
|
} catch (error) {
|
|
1645
1649
|
logger.error(`[YamlEditor] \u4ECE\u6570\u7EC4\u5220\u9664\u5143\u7D20\u65F6\u51FA\u9519\uFF1A${error}`);
|
|
@@ -1651,9 +1655,9 @@ var init_yaml = __esm({
|
|
|
1651
1655
|
* @param path - 路径,用点号分隔
|
|
1652
1656
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1653
1657
|
*/
|
|
1654
|
-
has(
|
|
1658
|
+
has(path38, isSplit = true) {
|
|
1655
1659
|
try {
|
|
1656
|
-
const _path = typeof
|
|
1660
|
+
const _path = typeof path38 === "string" ? isSplit ? path38.split(".") : [path38] : path38;
|
|
1657
1661
|
return this.document.hasIn(_path);
|
|
1658
1662
|
} catch (error) {
|
|
1659
1663
|
logger.error(`[YamlEditor] \u68C0\u67E5\u8DEF\u5F84\u662F\u5426\u5B58\u5728\u65F6\u51FA\u9519\uFF1A${error}`);
|
|
@@ -1666,9 +1670,9 @@ var init_yaml = __esm({
|
|
|
1666
1670
|
* @param value - 要查询的值
|
|
1667
1671
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1668
1672
|
*/
|
|
1669
|
-
hasval(
|
|
1673
|
+
hasval(path38, value, isSplit = true) {
|
|
1670
1674
|
try {
|
|
1671
|
-
const _path = typeof
|
|
1675
|
+
const _path = typeof path38 === "string" ? isSplit ? path38.split(".") : [path38] : path38;
|
|
1672
1676
|
const current = this.document.getIn(_path);
|
|
1673
1677
|
if (!current) return false;
|
|
1674
1678
|
if (current instanceof YAML.YAMLSeq) {
|
|
@@ -1679,7 +1683,7 @@ var init_yaml = __esm({
|
|
|
1679
1683
|
return lodash3.isEqual(current, value);
|
|
1680
1684
|
}
|
|
1681
1685
|
} catch (error) {
|
|
1682
|
-
logger.error(`[YamlEditor] \u68C0\u67E5\u8DEF\u5F84 ${
|
|
1686
|
+
logger.error(`[YamlEditor] \u68C0\u67E5\u8DEF\u5F84 ${path38} \u662F\u5426\u5305\u542B\u503C\u65F6\u51FA\u9519\uFF1A${error}`);
|
|
1683
1687
|
return false;
|
|
1684
1688
|
}
|
|
1685
1689
|
}
|
|
@@ -1689,8 +1693,8 @@ var init_yaml = __esm({
|
|
|
1689
1693
|
* @param value - 要查询的值
|
|
1690
1694
|
* @deprecated 请使用 `hasval` 代替
|
|
1691
1695
|
*/
|
|
1692
|
-
hasVal(
|
|
1693
|
-
return this.hasval(
|
|
1696
|
+
hasVal(path38, value) {
|
|
1697
|
+
return this.hasval(path38, value);
|
|
1694
1698
|
}
|
|
1695
1699
|
/**
|
|
1696
1700
|
* 向根节点新增元素,如果根节点不是数组,则将其转换为数组再新增元素
|
|
@@ -1735,9 +1739,9 @@ var init_yaml = __esm({
|
|
|
1735
1739
|
* @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
|
|
1736
1740
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1737
1741
|
*/
|
|
1738
|
-
getpair(
|
|
1739
|
-
if (!
|
|
1740
|
-
const keys = typeof
|
|
1742
|
+
getpair(path38, isSplit = true) {
|
|
1743
|
+
if (!path38) throw new Error("path is required");
|
|
1744
|
+
const keys = typeof path38 === "string" ? isSplit ? path38.split(".") : [path38] : path38;
|
|
1741
1745
|
let pair = this.document.contents;
|
|
1742
1746
|
keys.forEach((key) => {
|
|
1743
1747
|
if (isMap(pair)) {
|
|
@@ -1757,10 +1761,10 @@ var init_yaml = __esm({
|
|
|
1757
1761
|
* @param prepend - 如果为 true,则添加注释到开头,否则添加到同一行的末尾
|
|
1758
1762
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1759
1763
|
*/
|
|
1760
|
-
comment(
|
|
1761
|
-
if (!
|
|
1762
|
-
const pair = this.getpair(
|
|
1763
|
-
if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${
|
|
1764
|
+
comment(path38, comment2, prepend = true, isSplit = true) {
|
|
1765
|
+
if (!path38) throw new Error("[YamlEditor] path \u4E0D\u80FD\u4E3A\u7A7A");
|
|
1766
|
+
const pair = this.getpair(path38, isSplit);
|
|
1767
|
+
if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${path38}`);
|
|
1764
1768
|
comment2 = ` ${comment2}`;
|
|
1765
1769
|
if (prepend) {
|
|
1766
1770
|
pair.key.commentBefore = comment2;
|
|
@@ -1774,10 +1778,10 @@ var init_yaml = __esm({
|
|
|
1774
1778
|
* @param type - 要删除的注释类型,`before` 为注释前,`after` 为注释后,`all` 为全部
|
|
1775
1779
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1776
1780
|
*/
|
|
1777
|
-
uncomment(
|
|
1778
|
-
if (!
|
|
1779
|
-
const pair = this.getpair(
|
|
1780
|
-
if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${
|
|
1781
|
+
uncomment(path38, type = "all", isSplit = true) {
|
|
1782
|
+
if (!path38) throw new Error("[YamlEditor] path \u4E0D\u80FD\u4E3A\u7A7A");
|
|
1783
|
+
const pair = this.getpair(path38, isSplit);
|
|
1784
|
+
if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${path38}`);
|
|
1781
1785
|
if (type === "all") {
|
|
1782
1786
|
delete pair.key.comment;
|
|
1783
1787
|
delete pair.key.commentBefore;
|
|
@@ -1793,10 +1797,10 @@ var init_yaml = __esm({
|
|
|
1793
1797
|
* @param type - 要检查的注释类型,`before` 为注释前,`after` 为注释后
|
|
1794
1798
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1795
1799
|
*/
|
|
1796
|
-
hascomment(
|
|
1797
|
-
if (!
|
|
1798
|
-
const pair = this.getpair(
|
|
1799
|
-
if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${
|
|
1800
|
+
hascomment(path38, type, isSplit = true) {
|
|
1801
|
+
if (!path38) throw new Error("[YamlEditor] path \u4E0D\u80FD\u4E3A\u7A7A");
|
|
1802
|
+
const pair = this.getpair(path38, isSplit);
|
|
1803
|
+
if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${path38}`);
|
|
1800
1804
|
if (type === "before") {
|
|
1801
1805
|
return !!pair.key.commentBefore;
|
|
1802
1806
|
} else if (type === "after") {
|
|
@@ -1809,10 +1813,10 @@ var init_yaml = __esm({
|
|
|
1809
1813
|
* @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
|
|
1810
1814
|
* @param isSplit - 是否使用分割路径路径,默认为 `true`
|
|
1811
1815
|
*/
|
|
1812
|
-
getcomment(
|
|
1813
|
-
if (!
|
|
1814
|
-
const pair = this.getpair(
|
|
1815
|
-
if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${
|
|
1816
|
+
getcomment(path38, isSplit = true) {
|
|
1817
|
+
if (!path38) throw new Error("[YamlEditor] path \u4E0D\u80FD\u4E3A\u7A7A");
|
|
1818
|
+
const pair = this.getpair(path38, isSplit);
|
|
1819
|
+
if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${path38}`);
|
|
1816
1820
|
return pair.key.commentBefore || pair.key.comment;
|
|
1817
1821
|
}
|
|
1818
1822
|
/**
|
|
@@ -1824,11 +1828,11 @@ var init_yaml = __esm({
|
|
|
1824
1828
|
logger.debug("[YamlEditor] \u6587\u4EF6\u5DF2\u4FDD\u5B58");
|
|
1825
1829
|
}
|
|
1826
1830
|
};
|
|
1827
|
-
read = (
|
|
1828
|
-
const data = YAML.parse(fs5.readFileSync(
|
|
1831
|
+
read = (path38) => {
|
|
1832
|
+
const data = YAML.parse(fs5.readFileSync(path38, "utf-8"));
|
|
1829
1833
|
read.save = (options) => {
|
|
1830
1834
|
try {
|
|
1831
|
-
save(
|
|
1835
|
+
save(path38, data, typeof options === "string" ? JSON.parse(options) : options);
|
|
1832
1836
|
return true;
|
|
1833
1837
|
} catch (error) {
|
|
1834
1838
|
logger.error("[YamlEditor] \u4FDD\u5B58\u6587\u4EF6\u65F6\u51FA\u9519");
|
|
@@ -1838,23 +1842,23 @@ var init_yaml = __esm({
|
|
|
1838
1842
|
};
|
|
1839
1843
|
return data;
|
|
1840
1844
|
};
|
|
1841
|
-
write = (
|
|
1845
|
+
write = (path38, value) => {
|
|
1842
1846
|
try {
|
|
1843
|
-
fs5.writeFileSync(
|
|
1847
|
+
fs5.writeFileSync(path38, YAML.stringify(value));
|
|
1844
1848
|
return true;
|
|
1845
1849
|
} catch {
|
|
1846
1850
|
return false;
|
|
1847
1851
|
}
|
|
1848
1852
|
};
|
|
1849
|
-
save = (
|
|
1853
|
+
save = (path38, value, options) => {
|
|
1850
1854
|
if (!options) {
|
|
1851
|
-
fs5.writeFileSync(
|
|
1855
|
+
fs5.writeFileSync(path38, YAML.stringify(value));
|
|
1852
1856
|
return;
|
|
1853
1857
|
}
|
|
1854
1858
|
const editor = new YamlEditor(YAML.stringify(value));
|
|
1855
1859
|
const comment2 = typeof options === "string" ? JSON.parse(fs5.readFileSync(options, "utf8")) : options;
|
|
1856
1860
|
applyComments(editor, comment2);
|
|
1857
|
-
fs5.writeFileSync(
|
|
1861
|
+
fs5.writeFileSync(path38, editor.document.toString());
|
|
1858
1862
|
};
|
|
1859
1863
|
comment = (filePath, commentConfig) => {
|
|
1860
1864
|
const editor = new YamlEditor(filePath);
|
|
@@ -4037,9 +4041,25 @@ var init_status_listener = __esm({
|
|
|
4037
4041
|
memory: ((mem.heapTotal + mem.external + mem.arrayBuffers) / 1024 / 1024).toFixed(2)
|
|
4038
4042
|
};
|
|
4039
4043
|
}
|
|
4044
|
+
/**
|
|
4045
|
+
* 获取系统状态信息
|
|
4046
|
+
*/
|
|
4040
4047
|
systemStatus() {
|
|
4041
4048
|
const karinUsage = this.karinUsage();
|
|
4042
4049
|
const sysCpuInfo = this.sysCpuInfo();
|
|
4050
|
+
const memUsage = process.memoryUsage();
|
|
4051
|
+
let userInfo;
|
|
4052
|
+
try {
|
|
4053
|
+
userInfo = os.userInfo();
|
|
4054
|
+
} catch (e) {
|
|
4055
|
+
userInfo = void 0;
|
|
4056
|
+
}
|
|
4057
|
+
let loadavg;
|
|
4058
|
+
try {
|
|
4059
|
+
loadavg = os.loadavg();
|
|
4060
|
+
} catch (e) {
|
|
4061
|
+
loadavg = void 0;
|
|
4062
|
+
}
|
|
4043
4063
|
return {
|
|
4044
4064
|
cpu: {
|
|
4045
4065
|
core: sysCpuInfo.core,
|
|
@@ -4055,9 +4075,45 @@ var init_status_listener = __esm({
|
|
|
4055
4075
|
usage: {
|
|
4056
4076
|
system: this.sysMemoryUsage(),
|
|
4057
4077
|
karin: karinUsage.memory
|
|
4078
|
+
},
|
|
4079
|
+
details: {
|
|
4080
|
+
rss: (memUsage.rss / 1024 / 1024).toFixed(2),
|
|
4081
|
+
heapTotal: (memUsage.heapTotal / 1024 / 1024).toFixed(2),
|
|
4082
|
+
heapUsed: (memUsage.heapUsed / 1024 / 1024).toFixed(2),
|
|
4083
|
+
external: (memUsage.external / 1024 / 1024).toFixed(2),
|
|
4084
|
+
arrayBuffers: (memUsage.arrayBuffers / 1024 / 1024).toFixed(2)
|
|
4058
4085
|
}
|
|
4059
4086
|
},
|
|
4060
|
-
|
|
4087
|
+
system: {
|
|
4088
|
+
arch: `${os.platform()} ${os.arch()}`,
|
|
4089
|
+
hostname: os.hostname(),
|
|
4090
|
+
osName: os.type(),
|
|
4091
|
+
osVersion: os.release(),
|
|
4092
|
+
platform: os.platform(),
|
|
4093
|
+
uptime: os.uptime(),
|
|
4094
|
+
loadavg,
|
|
4095
|
+
tmpdir: os.tmpdir(),
|
|
4096
|
+
homedir: os.homedir()
|
|
4097
|
+
},
|
|
4098
|
+
process: {
|
|
4099
|
+
nodeVersion: process.version,
|
|
4100
|
+
pid: process.pid,
|
|
4101
|
+
uptime: process.uptime(),
|
|
4102
|
+
execPath: process.execPath,
|
|
4103
|
+
argv: process.argv,
|
|
4104
|
+
env: {
|
|
4105
|
+
nodeEnv: process.env.NODE_ENV,
|
|
4106
|
+
timezone: process.env.TZ
|
|
4107
|
+
},
|
|
4108
|
+
user: userInfo ? {
|
|
4109
|
+
username: userInfo.username,
|
|
4110
|
+
homedir: userInfo.homedir,
|
|
4111
|
+
shell: userInfo.shell
|
|
4112
|
+
} : void 0
|
|
4113
|
+
},
|
|
4114
|
+
network: {
|
|
4115
|
+
interfaces: os.networkInterfaces()
|
|
4116
|
+
}
|
|
4061
4117
|
};
|
|
4062
4118
|
}
|
|
4063
4119
|
};
|
|
@@ -10100,7 +10156,7 @@ var init_port = __esm({
|
|
|
10100
10156
|
});
|
|
10101
10157
|
|
|
10102
10158
|
// src/utils/system/import.ts
|
|
10103
|
-
var importModule;
|
|
10159
|
+
var importModule, imports;
|
|
10104
10160
|
var init_import = __esm({
|
|
10105
10161
|
"src/utils/system/import.ts"() {
|
|
10106
10162
|
importModule = async (url, isRefresh = false) => {
|
|
@@ -10111,6 +10167,14 @@ var init_import = __esm({
|
|
|
10111
10167
|
return { status: false, data: error };
|
|
10112
10168
|
}
|
|
10113
10169
|
};
|
|
10170
|
+
imports = async (url, options = {}) => {
|
|
10171
|
+
const { isRefresh = false, isImportDefault = true } = options;
|
|
10172
|
+
const module = await import(`file://${url}${isRefresh ? `?t=${Date.now()}` : ""}`);
|
|
10173
|
+
if (isImportDefault) {
|
|
10174
|
+
return module.default;
|
|
10175
|
+
}
|
|
10176
|
+
return module;
|
|
10177
|
+
};
|
|
10114
10178
|
}
|
|
10115
10179
|
});
|
|
10116
10180
|
|
|
@@ -10228,11 +10292,11 @@ var init_list = __esm({
|
|
|
10228
10292
|
const apps = [];
|
|
10229
10293
|
const files = [];
|
|
10230
10294
|
const allApps = [];
|
|
10231
|
-
const pushApps = (
|
|
10232
|
-
if (typeof
|
|
10233
|
-
files.push(
|
|
10234
|
-
} else if (Array.isArray(
|
|
10235
|
-
files.push(...
|
|
10295
|
+
const pushApps = (app5) => {
|
|
10296
|
+
if (typeof app5 === "string") {
|
|
10297
|
+
files.push(app5);
|
|
10298
|
+
} else if (Array.isArray(app5)) {
|
|
10299
|
+
files.push(...app5);
|
|
10236
10300
|
}
|
|
10237
10301
|
};
|
|
10238
10302
|
if (isTs()) {
|
|
@@ -10241,8 +10305,8 @@ var init_list = __esm({
|
|
|
10241
10305
|
pkg2.karin.apps && pushApps(pkg2.karin.apps);
|
|
10242
10306
|
}
|
|
10243
10307
|
await Promise.allSettled(
|
|
10244
|
-
files.map(async (
|
|
10245
|
-
const appPath = path4.join(dir2,
|
|
10308
|
+
files.map(async (app5) => {
|
|
10309
|
+
const appPath = path4.join(dir2, app5);
|
|
10246
10310
|
if (!fs5.existsSync(appPath)) return;
|
|
10247
10311
|
apps.push(...filesByExt(appPath, ext, "abs"));
|
|
10248
10312
|
allApps.push(appPath);
|
|
@@ -10269,8 +10333,8 @@ var init_list = __esm({
|
|
|
10269
10333
|
files.push(...pkg2.karin.apps);
|
|
10270
10334
|
}
|
|
10271
10335
|
await Promise.allSettled(
|
|
10272
|
-
files.map(async (
|
|
10273
|
-
const appPath = path4.join(dir2,
|
|
10336
|
+
files.map(async (app5) => {
|
|
10337
|
+
const appPath = path4.join(dir2, app5);
|
|
10274
10338
|
if (!fs5.existsSync(appPath)) return;
|
|
10275
10339
|
apps.push(...filesByExt(appPath, ext, "abs"));
|
|
10276
10340
|
allApps.push(appPath);
|
|
@@ -10597,11 +10661,11 @@ var init_update = __esm({
|
|
|
10597
10661
|
}
|
|
10598
10662
|
};
|
|
10599
10663
|
getCommit = async (options) => {
|
|
10600
|
-
const { path:
|
|
10664
|
+
const { path: path38, count: count3 = 1, hash, branch } = options;
|
|
10601
10665
|
let cmd = `git log -${count3} --format="[%ad]%s %n" --date="format:%m-%d %H:%M"`;
|
|
10602
10666
|
if (hash) cmd = `git log ${hash}..HEAD --format="[%ad] %s %n" --date="format:%m-%d %H:%M"`;
|
|
10603
10667
|
if (branch) cmd = `git log -${count3} ${branch} --format="[%ad] %s %n" --date="format:%m-%d %H:%M"`;
|
|
10604
|
-
const { stdout, error } = await exec(cmd, { cwd:
|
|
10668
|
+
const { stdout, error } = await exec(cmd, { cwd: path38 });
|
|
10605
10669
|
if (error) {
|
|
10606
10670
|
throw error;
|
|
10607
10671
|
}
|
|
@@ -11255,7 +11319,6 @@ var restart, restartDirect;
|
|
|
11255
11319
|
var init_restart = __esm({
|
|
11256
11320
|
"src/utils/system/restart.ts"() {
|
|
11257
11321
|
init_exec();
|
|
11258
|
-
init_config();
|
|
11259
11322
|
restart = async (selfId, contact3, messageId, isFront = true, reloadDeps = false) => {
|
|
11260
11323
|
const options = {
|
|
11261
11324
|
selfId,
|
|
@@ -11284,19 +11347,6 @@ var init_restart = __esm({
|
|
|
11284
11347
|
restartDirect = async (options) => {
|
|
11285
11348
|
const { isPm2 = false, reloadDeps = false } = options || {};
|
|
11286
11349
|
logger.mark("\u6536\u5230\u91CD\u542F\u8BF7\u6C42\uFF0C\u6B63\u5728\u91CD\u542F...");
|
|
11287
|
-
const envCfg = env();
|
|
11288
|
-
if (isPm2 && envCfg.RUNTIME === "node") {
|
|
11289
|
-
const envCfg2 = env();
|
|
11290
|
-
if (envCfg2.RUNTIME === "node") {
|
|
11291
|
-
envCfg2.RUNTIME = "pm2";
|
|
11292
|
-
const envData = Object.entries(envCfg2).map(([key, value]) => ({
|
|
11293
|
-
key,
|
|
11294
|
-
value,
|
|
11295
|
-
comment: value.comment
|
|
11296
|
-
}));
|
|
11297
|
-
writeEnv(envData, void 0, true);
|
|
11298
|
-
}
|
|
11299
|
-
}
|
|
11300
11350
|
if (!isPm2 && process?.send) {
|
|
11301
11351
|
process.send(JSON.stringify({ type: "restart", reloadDeps }));
|
|
11302
11352
|
logger.debug("\u6B63\u5728\u901A\u77E5\u7236\u8FDB\u7A0B\u91CD\u542F...");
|
|
@@ -11531,6 +11581,7 @@ __export(system_exports, {
|
|
|
11531
11581
|
getRequestIp: () => getRequestIp,
|
|
11532
11582
|
getTime: () => getTime,
|
|
11533
11583
|
importModule: () => importModule,
|
|
11584
|
+
imports: () => imports,
|
|
11534
11585
|
isClass: () => isClass,
|
|
11535
11586
|
isDocker: () => isDocker,
|
|
11536
11587
|
isIPv4Loop: () => isIPv4Loop,
|
|
@@ -11668,8 +11719,13 @@ var init_race = __esm({
|
|
|
11668
11719
|
"https://registry.npmjs.com",
|
|
11669
11720
|
"https://mirrors.cloud.tencent.com/npm"
|
|
11670
11721
|
];
|
|
11671
|
-
|
|
11672
|
-
|
|
11722
|
+
try {
|
|
11723
|
+
const result = await raceRequest(urls);
|
|
11724
|
+
return result?.config.url || urls[0];
|
|
11725
|
+
} catch (error) {
|
|
11726
|
+
console.error("\u83B7\u53D6\u6700\u5FEB\u7684npm registry\u5931\u8D25:", error);
|
|
11727
|
+
return urls[0];
|
|
11728
|
+
}
|
|
11673
11729
|
};
|
|
11674
11730
|
getPackageJson = async (owner, repo) => {
|
|
11675
11731
|
try {
|
|
@@ -11712,8 +11768,8 @@ var init_github = __esm({
|
|
|
11712
11768
|
const urlObj = new URL$1(url);
|
|
11713
11769
|
const owner = urlObj.pathname.split("/")[1];
|
|
11714
11770
|
const repo = urlObj.pathname.split("/")[2];
|
|
11715
|
-
const
|
|
11716
|
-
return { owner, repo, path:
|
|
11771
|
+
const path38 = urlObj.pathname.split("/").slice(3).join("/");
|
|
11772
|
+
return { owner, repo, path: path38 };
|
|
11717
11773
|
};
|
|
11718
11774
|
getFastGithub = async (type) => {
|
|
11719
11775
|
const list2 = [
|
|
@@ -11733,8 +11789,8 @@ var init_github = __esm({
|
|
|
11733
11789
|
isClone: false,
|
|
11734
11790
|
isRaw: true,
|
|
11735
11791
|
raw: function(url) {
|
|
11736
|
-
const { owner, repo, path:
|
|
11737
|
-
return `${this.proxy}/${owner}/${repo}/${
|
|
11792
|
+
const { owner, repo, path: path38 } = parseGithubUrl(url);
|
|
11793
|
+
return `${this.proxy}/${owner}/${repo}/${path38}`;
|
|
11738
11794
|
},
|
|
11739
11795
|
clone: function(url) {
|
|
11740
11796
|
const { owner, repo } = parseGithubUrl(url);
|
|
@@ -11746,8 +11802,8 @@ var init_github = __esm({
|
|
|
11746
11802
|
isClone: false,
|
|
11747
11803
|
isRaw: true,
|
|
11748
11804
|
raw: function(url) {
|
|
11749
|
-
const { owner, repo, path:
|
|
11750
|
-
return `${this.proxy}/${owner}/${repo}/${
|
|
11805
|
+
const { owner, repo, path: path38 } = parseGithubUrl(url);
|
|
11806
|
+
return `${this.proxy}/${owner}/${repo}/${path38}`;
|
|
11751
11807
|
},
|
|
11752
11808
|
clone: function(url) {
|
|
11753
11809
|
const { owner, repo } = parseGithubUrl(url);
|
|
@@ -17315,29 +17371,29 @@ var init_cache3 = __esm({
|
|
|
17315
17371
|
return i;
|
|
17316
17372
|
};
|
|
17317
17373
|
unregisterRender = (index6) => {
|
|
17318
|
-
const
|
|
17319
|
-
if (!
|
|
17374
|
+
const app5 = cache8.find((app6) => app6.index === index6);
|
|
17375
|
+
if (!app5) {
|
|
17320
17376
|
logger.error(`[render] \u5378\u8F7D\u5931\u8D25: \u4E0D\u5B58\u5728\u7D22\u5F15 ${index6}`);
|
|
17321
17377
|
return false;
|
|
17322
17378
|
}
|
|
17323
|
-
cache8.splice(cache8.findIndex((
|
|
17324
|
-
logger.mark(`[render] ${logger.yellow("\u5378\u8F7D\u6210\u529F")}: ${
|
|
17379
|
+
cache8.splice(cache8.findIndex((app6) => app6.index === index6), 1);
|
|
17380
|
+
logger.mark(`[render] ${logger.yellow("\u5378\u8F7D\u6210\u529F")}: ${app5.id}`);
|
|
17325
17381
|
return true;
|
|
17326
17382
|
};
|
|
17327
17383
|
getRender = (id) => {
|
|
17328
17384
|
if (cache8.length === 0) throw new Error("[\u8C03\u7528\u6E32\u67D3\u5668\u5931\u8D25] \u6E32\u67D3\u5668\u5217\u8868\u4E3A\u7A7A");
|
|
17329
17385
|
if (!id) {
|
|
17330
|
-
const
|
|
17331
|
-
return
|
|
17386
|
+
const app6 = cache8[Math.floor(Math.random() * cache8.length)];
|
|
17387
|
+
return app6;
|
|
17332
17388
|
}
|
|
17333
17389
|
if (typeof id === "number") {
|
|
17334
|
-
const
|
|
17335
|
-
if (!
|
|
17336
|
-
return
|
|
17390
|
+
const app6 = cache8.find((app7) => app7.index === id);
|
|
17391
|
+
if (!app6) throw new Error(`[\u8C03\u7528\u6E32\u67D3\u5668\u5931\u8D25] \u672A\u627E\u5230\u6E32\u67D3\u5668\uFF1A${id}`);
|
|
17392
|
+
return app6;
|
|
17337
17393
|
}
|
|
17338
|
-
const
|
|
17339
|
-
if (!
|
|
17340
|
-
return
|
|
17394
|
+
const app5 = cache8.find((app6) => app6.id === id);
|
|
17395
|
+
if (!app5) throw new Error(`[\u8C03\u7528\u6E32\u67D3\u5668\u5931\u8D25] \u672A\u627E\u5230\u6E32\u67D3\u5668\uFF1A${id}`);
|
|
17396
|
+
return app5;
|
|
17341
17397
|
};
|
|
17342
17398
|
callRender = async (options, id) => {
|
|
17343
17399
|
const res = getRender(id);
|
|
@@ -17346,7 +17402,7 @@ var init_cache3 = __esm({
|
|
|
17346
17402
|
};
|
|
17347
17403
|
getRenderCount = () => cache8.length;
|
|
17348
17404
|
getRenderList = () => {
|
|
17349
|
-
const list2 = cache8.map((
|
|
17405
|
+
const list2 = cache8.map((app5) => app5);
|
|
17350
17406
|
return list2;
|
|
17351
17407
|
};
|
|
17352
17408
|
renderHtml = (data) => {
|
|
@@ -17852,7 +17908,7 @@ var init_file2 = __esm({
|
|
|
17852
17908
|
});
|
|
17853
17909
|
|
|
17854
17910
|
// src/server/router/router.ts
|
|
17855
|
-
var BASE_ROUTER, LOGIN_ROUTER, REFRESH_ROUTER, GET_CONFIG_ROUTER, SAVE_CONFIG_ROUTER, GET_LOG_ROUTER, SET_LOG_LEVEL_ROUTER, GET_LOG_FILE_LIST_ROUTER, GET_LOG_FILE_ROUTER, EXIT_ROUTER, RESTART_ROUTER, GET_NETWORK_STATUS_ROUTER, UPDATE_CORE_ROUTER, GET_BOTS_ROUTER, CONSOLE_ROUTER, PING_ROUTER, SYSTEM_STATUS_ROUTER, SYSTEM_INFO_ROUTER, SYSTEM_STATUS_WS_ROUTER, SYSTEM_STATUS_KARIN_ROUTER, GET_ONLINE_PLUGIN_LIST_ROUTER, GET_PLUGIN_LIST_ROUTER, GET_PLUGIN_APPS_ROUTER, GET_PLUGIN_FILE_ROUTER, GET_UPDATABLE_PLUGINS_ROUTER, BATCH_UPDATE_PLUGINS_ROUTER, GET_PLUGIN_CONFIG_ROUTER, SAVE_PLUGIN_CONFIG_ROUTER, IS_PLUGIN_CONFIG_EXIST_ROUTER, UPDATE_PLUGIN_ROUTER, INSTALL_PLUGIN_ROUTER, UNINSTALL_PLUGIN_ROUTER, GET_TASK_STATUS_ROUTER, GET_TASK_LIST_ROUTER, UPDATE_TASK_STATUS_ROUTER, GET_LOCAL_PLUGIN_LIST_ROUTER, CREATE_TERMINAL_ROUTER, GET_TERMINAL_LIST_ROUTER, CLOSE_TERMINAL_ROUTER, CHECK_PLUGIN_ROUTER, INSTALL_WEBUI_PLUGIN_ROUTER, GET_WEBUI_PLUGIN_LIST_ROUTER, UNINSTALL_WEBUI_PLUGIN_ROUTER, GET_WEBUI_PLUGIN_VERSIONS_ROUTER, UPDATE_WEBUI_PLUGIN_VERSION_ROUTER, TASK_LIST_ROUTER, TASK_RUN_ROUTER, TASK_LOGS_ROUTER, TASK_DELETE_ROUTER, PLUGIN_ADMIN_ROUTER, GET_PLUGIN_LIST_PLUGIN_ADMIN_ROUTER, GET_DEPENDENCIES_LIST_ROUTER, MANAGE_DEPENDENCIES_ROUTER, GET_NPMRC_LIST_ROUTER, GET_NPM_CONFIG_ROUTER, GET_NPM_BASE_CONFIG_ROUTER, SAVE_NPMRC_ROUTER, GET_LOADED_COMMAND_PLUGIN_CACHE_LIST_ROUTER, GET_PLUGIN_MARKET_LIST_ROUTER;
|
|
17911
|
+
var BASE_ROUTER, LOGIN_ROUTER, REFRESH_ROUTER, GET_CONFIG_ROUTER, SAVE_CONFIG_ROUTER, GET_LOG_ROUTER, SET_LOG_LEVEL_ROUTER, GET_LOG_FILE_LIST_ROUTER, GET_LOG_FILE_ROUTER, EXIT_ROUTER, RESTART_ROUTER, GET_NETWORK_STATUS_ROUTER, UPDATE_CORE_ROUTER, GET_BOTS_ROUTER, CONSOLE_ROUTER, PING_ROUTER, SYSTEM_STATUS_ROUTER, SYSTEM_INFO_ROUTER, SYSTEM_STATUS_WS_ROUTER, SYSTEM_STATUS_KARIN_ROUTER, GET_ONLINE_PLUGIN_LIST_ROUTER, GET_PLUGIN_LIST_ROUTER, GET_PLUGIN_APPS_ROUTER, GET_PLUGIN_FILE_ROUTER, GET_UPDATABLE_PLUGINS_ROUTER, BATCH_UPDATE_PLUGINS_ROUTER, GET_PLUGIN_CONFIG_ROUTER, SAVE_PLUGIN_CONFIG_ROUTER, IS_PLUGIN_CONFIG_EXIST_ROUTER, UPDATE_PLUGIN_ROUTER, INSTALL_PLUGIN_ROUTER, UNINSTALL_PLUGIN_ROUTER, GET_TASK_STATUS_ROUTER, GET_TASK_LIST_ROUTER, UPDATE_TASK_STATUS_ROUTER, GET_LOCAL_PLUGIN_LIST_ROUTER, CREATE_TERMINAL_ROUTER, GET_TERMINAL_LIST_ROUTER, CLOSE_TERMINAL_ROUTER, CHECK_PLUGIN_ROUTER, INSTALL_WEBUI_PLUGIN_ROUTER, GET_WEBUI_PLUGIN_LIST_ROUTER, UNINSTALL_WEBUI_PLUGIN_ROUTER, GET_WEBUI_PLUGIN_VERSIONS_ROUTER, UPDATE_WEBUI_PLUGIN_VERSION_ROUTER, TASK_LIST_ROUTER, TASK_RUN_ROUTER, TASK_LOGS_ROUTER, TASK_DELETE_ROUTER, PLUGIN_ADMIN_ROUTER, GET_PLUGIN_LIST_PLUGIN_ADMIN_ROUTER, GET_DEPENDENCIES_LIST_ROUTER, MANAGE_DEPENDENCIES_ROUTER, GET_NPMRC_LIST_ROUTER, GET_NPM_CONFIG_ROUTER, GET_NPM_BASE_CONFIG_ROUTER, SAVE_NPMRC_ROUTER, GET_LOADED_COMMAND_PLUGIN_CACHE_LIST_ROUTER, GET_PLUGIN_MARKET_LIST_ROUTER, GET_LOCAL_PLUGIN_FRONTEND_LIST_ROUTER;
|
|
17856
17912
|
var init_router = __esm({
|
|
17857
17913
|
"src/server/router/router.ts"() {
|
|
17858
17914
|
BASE_ROUTER = "/api/v1";
|
|
@@ -17914,6 +17970,7 @@ var init_router = __esm({
|
|
|
17914
17970
|
SAVE_NPMRC_ROUTER = "/dependencies/npmrc/save";
|
|
17915
17971
|
GET_LOADED_COMMAND_PLUGIN_CACHE_LIST_ROUTER = "/plugin/loaded/command";
|
|
17916
17972
|
GET_PLUGIN_MARKET_LIST_ROUTER = "/plugin/market";
|
|
17973
|
+
GET_LOCAL_PLUGIN_FRONTEND_LIST_ROUTER = "/plugin/local/frontend";
|
|
17917
17974
|
}
|
|
17918
17975
|
});
|
|
17919
17976
|
var isWindows, tips, createHttpClient, request, handleResponse, checkPort2, safeExecSync, getPm2Id, safeKillProcess, forceKillProcess, checkProcess;
|
|
@@ -17930,35 +17987,35 @@ var init_check = __esm({
|
|
|
17930
17987
|
headers: { Authorization: `Bearer ${process.env.HTTP_AUTH_KEY}` },
|
|
17931
17988
|
validateStatus: () => true
|
|
17932
17989
|
});
|
|
17933
|
-
request = async (url,
|
|
17990
|
+
request = async (url, path38, method, timeout2, isPrint = true) => {
|
|
17934
17991
|
const client = createHttpClient(url, timeout2);
|
|
17935
17992
|
try {
|
|
17936
|
-
const result = await client[method](
|
|
17937
|
-
return handleResponse(result, method,
|
|
17993
|
+
const result = await client[method](path38);
|
|
17994
|
+
return handleResponse(result, method, path38, isPrint);
|
|
17938
17995
|
} catch (error) {
|
|
17939
17996
|
logger.debug(
|
|
17940
|
-
tips(`${method.toUpperCase()} \u8BF7\u6C42\u5F02\u5E38:`, true) + ` ${
|
|
17997
|
+
tips(`${method.toUpperCase()} \u8BF7\u6C42\u5F02\u5E38:`, true) + ` ${path38} - ${error?.message || "\u672A\u77E5\u9519\u8BEF"}`
|
|
17941
17998
|
);
|
|
17942
17999
|
return { code: 500, success: false };
|
|
17943
18000
|
}
|
|
17944
18001
|
};
|
|
17945
|
-
handleResponse = (result, method,
|
|
18002
|
+
handleResponse = (result, method, path38, isPrint) => {
|
|
17946
18003
|
if (result.status === 200) {
|
|
17947
18004
|
isPrint && logger.info(
|
|
17948
|
-
tips(`${method.toUpperCase()} \u8BF7\u6C42\u6210\u529F:`, true) + ` ${
|
|
18005
|
+
tips(`${method.toUpperCase()} \u8BF7\u6C42\u6210\u529F:`, true) + ` ${path38} -> ${JSON.stringify(result.data)}`
|
|
17949
18006
|
);
|
|
17950
18007
|
return { code: result.status, success: true, data: result.data };
|
|
17951
18008
|
}
|
|
17952
18009
|
if (result.status === 401) {
|
|
17953
18010
|
logger.error(
|
|
17954
|
-
tips(`${method.toUpperCase()} \u9274\u6743\u5931\u8D25:`, true) + ` ${
|
|
18011
|
+
tips(`${method.toUpperCase()} \u9274\u6743\u5931\u8D25:`, true) + ` ${path38} -> ${JSON.stringify(result.data)}`
|
|
17955
18012
|
);
|
|
17956
18013
|
return { code: result.status, success: false };
|
|
17957
18014
|
}
|
|
17958
|
-
const logMethod =
|
|
18015
|
+
const logMethod = path38 === "/ping" ? logger.debug : logger.error;
|
|
17959
18016
|
logMethod.call(
|
|
17960
18017
|
logger,
|
|
17961
|
-
tips(`${method.toUpperCase()} \u8BF7\u6C42\u5931\u8D25:`, true) + ` ${
|
|
18018
|
+
tips(`${method.toUpperCase()} \u8BF7\u6C42\u5931\u8D25:`, true) + ` ${path38} -> ${JSON.stringify(result.data)}`
|
|
17962
18019
|
);
|
|
17963
18020
|
return { code: result.status, success: false };
|
|
17964
18021
|
};
|
|
@@ -19471,10 +19528,10 @@ var init_load = __esm({
|
|
|
19471
19528
|
}
|
|
19472
19529
|
}
|
|
19473
19530
|
}
|
|
19474
|
-
pkg2.apps.forEach((
|
|
19531
|
+
pkg2.apps.forEach((app5) => {
|
|
19475
19532
|
const promise = async () => {
|
|
19476
|
-
const result = await pkgLoadModule(pkg2.name,
|
|
19477
|
-
pkgCache(result, pkg2,
|
|
19533
|
+
const result = await pkgLoadModule(pkg2.name, app5);
|
|
19534
|
+
pkgCache(result, pkg2, app5);
|
|
19478
19535
|
};
|
|
19479
19536
|
allPromises.push(promise());
|
|
19480
19537
|
});
|
|
@@ -19504,12 +19561,12 @@ var init_load = __esm({
|
|
|
19504
19561
|
isType = (val, type) => {
|
|
19505
19562
|
return val.file?.type === type;
|
|
19506
19563
|
};
|
|
19507
|
-
pkgCache = (result, pkg2,
|
|
19564
|
+
pkgCache = (result, pkg2, app5) => {
|
|
19508
19565
|
const cacheHandler = (val, key) => {
|
|
19509
19566
|
if (typeof val !== "object") return;
|
|
19510
19567
|
if (!val?.pkg || !val.file) return;
|
|
19511
19568
|
val.pkg = pkg2;
|
|
19512
|
-
val.file = createFile2(
|
|
19569
|
+
val.file = createFile2(app5, val.file.type, key, val.file.name);
|
|
19513
19570
|
if (isType(val, "accept")) {
|
|
19514
19571
|
cache3.count.accept++;
|
|
19515
19572
|
cache3.accept.push(val);
|
|
@@ -19553,7 +19610,7 @@ var init_load = __esm({
|
|
|
19553
19610
|
if (key === "default") continue;
|
|
19554
19611
|
if (typeof result[key] === "function") {
|
|
19555
19612
|
if (!isClass(result[key])) continue;
|
|
19556
|
-
cacheClassPlugin(result[key], pkg2,
|
|
19613
|
+
cacheClassPlugin(result[key], pkg2, app5, key);
|
|
19557
19614
|
continue;
|
|
19558
19615
|
}
|
|
19559
19616
|
const data = result[key];
|
|
@@ -19562,9 +19619,9 @@ var init_load = __esm({
|
|
|
19562
19619
|
}
|
|
19563
19620
|
}
|
|
19564
19621
|
};
|
|
19565
|
-
createFile2 = (
|
|
19622
|
+
createFile2 = (app5, type, method, name) => {
|
|
19566
19623
|
return {
|
|
19567
|
-
absPath:
|
|
19624
|
+
absPath: app5,
|
|
19568
19625
|
get dirname() {
|
|
19569
19626
|
return path4.dirname(this.absPath);
|
|
19570
19627
|
},
|
|
@@ -19576,14 +19633,14 @@ var init_load = __esm({
|
|
|
19576
19633
|
name: name || type
|
|
19577
19634
|
};
|
|
19578
19635
|
};
|
|
19579
|
-
cacheClassPlugin = (Method, pkg2,
|
|
19636
|
+
cacheClassPlugin = (Method, pkg2, app5, _) => {
|
|
19580
19637
|
const command2 = new Method();
|
|
19581
19638
|
if (!command2.name) {
|
|
19582
|
-
logger.error(`[load][${
|
|
19639
|
+
logger.error(`[load][${app5}] plugin.name \u4E0D\u80FD\u4E3A\u7A7A`);
|
|
19583
19640
|
return;
|
|
19584
19641
|
}
|
|
19585
19642
|
if (!command2.rule || !Array.isArray(command2.rule) || command2.rule?.length === 0) {
|
|
19586
|
-
logger.error(`[load][${
|
|
19643
|
+
logger.error(`[load][${app5}] ${command2.name} plugin.rule \u4E0D\u80FD\u4E3A\u7A7A`);
|
|
19587
19644
|
return;
|
|
19588
19645
|
}
|
|
19589
19646
|
command2.rule.forEach((v) => {
|
|
@@ -19600,7 +19657,7 @@ var init_load = __esm({
|
|
|
19600
19657
|
permission: v.permission || "all",
|
|
19601
19658
|
event: v.event || command2.event || "message",
|
|
19602
19659
|
priority: v.priority || 1e4,
|
|
19603
|
-
file: createFile2(
|
|
19660
|
+
file: createFile2(app5, "command", v.fnc, command2.name),
|
|
19604
19661
|
authFailMsg: v.authFailMsg || true
|
|
19605
19662
|
});
|
|
19606
19663
|
});
|
|
@@ -19638,6 +19695,15 @@ var init_load = __esm({
|
|
|
19638
19695
|
};
|
|
19639
19696
|
}
|
|
19640
19697
|
});
|
|
19698
|
+
|
|
19699
|
+
// src/core/db/index.ts
|
|
19700
|
+
var init_db = __esm({
|
|
19701
|
+
"src/core/db/index.ts"() {
|
|
19702
|
+
init_redis3();
|
|
19703
|
+
init_mock2();
|
|
19704
|
+
init_kv();
|
|
19705
|
+
}
|
|
19706
|
+
});
|
|
19641
19707
|
var createHttpRenderClient;
|
|
19642
19708
|
var init_http3 = __esm({
|
|
19643
19709
|
"src/adapter/render/connect/http.ts"() {
|
|
@@ -20383,6 +20449,7 @@ var init_config4 = __esm({
|
|
|
20383
20449
|
init_env2();
|
|
20384
20450
|
init_require();
|
|
20385
20451
|
init_response();
|
|
20452
|
+
init_list();
|
|
20386
20453
|
fileExists = (filepath) => {
|
|
20387
20454
|
try {
|
|
20388
20455
|
return fs5.existsSync(filepath);
|
|
@@ -20538,10 +20605,23 @@ var init_config4 = __esm({
|
|
|
20538
20605
|
};
|
|
20539
20606
|
pluginGetConfig = async (req, res) => {
|
|
20540
20607
|
const options = req.body;
|
|
20541
|
-
if (!options.
|
|
20608
|
+
if (!options.name) {
|
|
20542
20609
|
createServerErrorResponse(res, "\u53C2\u6570\u9519\u8BEF");
|
|
20543
20610
|
return;
|
|
20544
20611
|
}
|
|
20612
|
+
const type = await (async () => {
|
|
20613
|
+
const list3 = await getPlugins("all", false);
|
|
20614
|
+
const npmName = `npm:${options.name}`;
|
|
20615
|
+
const gitName = `git:${options.name}`;
|
|
20616
|
+
const rootName = `root:${options.name}`;
|
|
20617
|
+
for (const item of list3) {
|
|
20618
|
+
if (item === npmName) return "npm";
|
|
20619
|
+
if (item === gitName) return "git";
|
|
20620
|
+
if (item === rootName) return "npm";
|
|
20621
|
+
}
|
|
20622
|
+
return "git";
|
|
20623
|
+
})();
|
|
20624
|
+
options.type = type;
|
|
20545
20625
|
const config3 = await getWebConfig(options.type, options.name, () => {
|
|
20546
20626
|
logger.error(`[plugin] \u63D2\u4EF6${options.name}\u7684web\u914D\u7F6E\u6587\u4EF6\u540D\u79F0\u4E0D\u6B63\u786E: \u9700\u8981\u4EE5 web.config \u547D\u540D`);
|
|
20547
20627
|
createSuccessResponse(res, null);
|
|
@@ -20549,6 +20629,9 @@ var init_config4 = __esm({
|
|
|
20549
20629
|
if (!config3) {
|
|
20550
20630
|
return createServerErrorResponse(res, "\u53C2\u6570\u9519\u8BEF");
|
|
20551
20631
|
}
|
|
20632
|
+
if (typeof config3.components !== "function") {
|
|
20633
|
+
return createServerErrorResponse(res, "\u8BE5\u63D2\u4EF6\u672A\u63D0\u4F9B\u9ED8\u8BA4\u7EC4\u4EF6\u914D\u7F6E\u51FD\u6570");
|
|
20634
|
+
}
|
|
20552
20635
|
const list2 = [];
|
|
20553
20636
|
let result = config3.components();
|
|
20554
20637
|
result = util5.types.isPromise(result) ? await result : result;
|
|
@@ -20575,6 +20658,9 @@ var init_config4 = __esm({
|
|
|
20575
20658
|
const configPath2 = getConfigPath(options);
|
|
20576
20659
|
if (!configPath2) return createServerErrorResponse(res, "\u53C2\u6570\u9519\u8BEF");
|
|
20577
20660
|
const { save: save2 } = await loadConfig(configPath2);
|
|
20661
|
+
if (typeof save2 !== "function") {
|
|
20662
|
+
return createServerErrorResponse(res, "\u8BE5\u63D2\u4EF6\u672A\u63D0\u4F9B\u9ED8\u8BA4\u7EC4\u4EF6\u4FDD\u5B58\u5B8C\u6210");
|
|
20663
|
+
}
|
|
20578
20664
|
const result = save2(options.config);
|
|
20579
20665
|
const response = util5.types.isPromise(result) ? await result : result;
|
|
20580
20666
|
createSuccessResponse(res, response || { success: true, message: "\u6CA1\u6709\u8FD4\u56DE\u503C\u54E6 \u03C6(>\u03C9<*) " });
|
|
@@ -20597,11 +20683,11 @@ var init_local = __esm({
|
|
|
20597
20683
|
init_response();
|
|
20598
20684
|
pluginGetLocalList = async (req, res) => {
|
|
20599
20685
|
const { isForce } = req.body;
|
|
20600
|
-
const [
|
|
20686
|
+
const [npm2, git2] = await Promise.all([
|
|
20601
20687
|
getPlugins("npm", true, isForce ?? false),
|
|
20602
20688
|
getPlugins("git", true, isForce ?? false)
|
|
20603
20689
|
]);
|
|
20604
|
-
const list2 = [...
|
|
20690
|
+
const list2 = [...npm2, ...git2];
|
|
20605
20691
|
const result = [];
|
|
20606
20692
|
const promise = [];
|
|
20607
20693
|
list2.forEach((val) => promise.push(isWebConfigPlugin(val, result)));
|
|
@@ -22267,27 +22353,27 @@ var init_update3 = __esm({
|
|
|
22267
22353
|
return handleReturn2(res, true, "\u66F4\u65B0\u4EFB\u52A1\u5DF2\u521B\u5EFA\uFF0C\u8BF7\u901A\u8FC7taskId\u6267\u884C\u4EFB\u52A1", id2);
|
|
22268
22354
|
}
|
|
22269
22355
|
const performUpdate = async (_, log3) => {
|
|
22270
|
-
const
|
|
22271
|
-
const
|
|
22356
|
+
const npm2 = [];
|
|
22357
|
+
const git2 = [];
|
|
22272
22358
|
const notExist = [];
|
|
22273
22359
|
const list2 = await getPlugins("all", false, true);
|
|
22274
22360
|
for (const item of data.target) {
|
|
22275
22361
|
if (item.type === "npm") {
|
|
22276
|
-
list2.includes(`${item.type}:${item.name}`) ?
|
|
22362
|
+
list2.includes(`${item.type}:${item.name}`) ? npm2.push({ name: item.name, version: item.version || "latest" }) : notExist.push(item.name);
|
|
22277
22363
|
continue;
|
|
22278
22364
|
}
|
|
22279
22365
|
if (item.type === "git") {
|
|
22280
22366
|
const force = typeof item.force === "boolean" ? item.force : false;
|
|
22281
|
-
list2.includes(`${item.type}:${item.name}`) ?
|
|
22367
|
+
list2.includes(`${item.type}:${item.name}`) ? git2.push({ name: item.name, version: item.version || "latest", force }) : notExist.push(item.name);
|
|
22282
22368
|
continue;
|
|
22283
22369
|
}
|
|
22284
22370
|
notExist.push(item.name);
|
|
22285
22371
|
}
|
|
22286
|
-
if (
|
|
22287
|
-
const args =
|
|
22372
|
+
if (npm2.length > 0) {
|
|
22373
|
+
const args = npm2.map((item) => `${item.name}@${item.version}`);
|
|
22288
22374
|
await spawnProcess("pnpm", ["update", ...args, "--save"], { timeout: 60 * 1e3 }, log3);
|
|
22289
22375
|
}
|
|
22290
|
-
for (const item of
|
|
22376
|
+
for (const item of git2) {
|
|
22291
22377
|
const { name, force } = item;
|
|
22292
22378
|
const cwd = path4.join(karinPathPlugins, name);
|
|
22293
22379
|
const result = await gitPull(cwd, { force, timeout: 60 * 1e3 });
|
|
@@ -22322,16 +22408,16 @@ var init_update3 = __esm({
|
|
|
22322
22408
|
updateAll = async (_, log3, options) => {
|
|
22323
22409
|
const categorizePlugins = async () => {
|
|
22324
22410
|
const list2 = await getPlugins("all", true, true);
|
|
22325
|
-
const
|
|
22326
|
-
const
|
|
22411
|
+
const git3 = [];
|
|
22412
|
+
const npm3 = ["node-karin"];
|
|
22327
22413
|
for (const item of list2) {
|
|
22328
22414
|
if (item.type === "npm") {
|
|
22329
|
-
|
|
22415
|
+
npm3.push(item.name);
|
|
22330
22416
|
} else if (item.type === "git") {
|
|
22331
|
-
|
|
22417
|
+
git3.push(item.name);
|
|
22332
22418
|
}
|
|
22333
22419
|
}
|
|
22334
|
-
return { npm:
|
|
22420
|
+
return { npm: npm3, git: git3 };
|
|
22335
22421
|
};
|
|
22336
22422
|
const updateNpmPlugins = async (npmPlugins) => {
|
|
22337
22423
|
if (npmPlugins.length === 0) return;
|
|
@@ -22357,10 +22443,10 @@ var init_update3 = __esm({
|
|
|
22357
22443
|
}
|
|
22358
22444
|
log3("\u5168\u90E8git\u63D2\u4EF6\u66F4\u65B0\u5B8C\u6210");
|
|
22359
22445
|
};
|
|
22360
|
-
const { npm, git } = await categorizePlugins();
|
|
22446
|
+
const { npm: npm2, git: git2 } = await categorizePlugins();
|
|
22361
22447
|
try {
|
|
22362
|
-
await updateNpmPlugins(
|
|
22363
|
-
await updateGitPlugins(
|
|
22448
|
+
await updateNpmPlugins(npm2);
|
|
22449
|
+
await updateGitPlugins(git2);
|
|
22364
22450
|
} catch (error) {
|
|
22365
22451
|
log3(`* \u53D1\u751F\u9519\u8BEF: ${error instanceof Error ? error.message : String(error)}`);
|
|
22366
22452
|
}
|
|
@@ -22538,8 +22624,8 @@ var init_installMarket = __esm({
|
|
|
22538
22624
|
);
|
|
22539
22625
|
}
|
|
22540
22626
|
let isRace = false;
|
|
22541
|
-
for (const
|
|
22542
|
-
if (
|
|
22627
|
+
for (const app5 of urls) {
|
|
22628
|
+
if (app5.url.startsWith("https://raw.githubusercontent.com")) {
|
|
22543
22629
|
isRace = true;
|
|
22544
22630
|
break;
|
|
22545
22631
|
}
|
|
@@ -22565,11 +22651,11 @@ var init_installMarket = __esm({
|
|
|
22565
22651
|
const dir2 = path4.join(karinPathPlugins, "karin-plugin-example");
|
|
22566
22652
|
mkdirSync(dir2);
|
|
22567
22653
|
emitLog("\u5F00\u59CB\u4E0B\u8F7D\u63D2\u4EF6\u6587\u4EF6...");
|
|
22568
|
-
await Promise.all(urls.map(async (
|
|
22569
|
-
const filename2 = path4.basename(
|
|
22654
|
+
await Promise.all(urls.map(async (app5) => {
|
|
22655
|
+
const filename2 = path4.basename(app5.url);
|
|
22570
22656
|
const fileUrl = path4.join(dir2, filename2);
|
|
22571
22657
|
emitLog(`\u6B63\u5728\u4E0B\u8F7D: ${filename2}`);
|
|
22572
|
-
const result = await downloadFile(
|
|
22658
|
+
const result = await downloadFile(app5.url, fileUrl);
|
|
22573
22659
|
if (!result.success) {
|
|
22574
22660
|
let err = `${filename2} \u4E0B\u8F7D\u5931\u8D25: `;
|
|
22575
22661
|
if (result.data instanceof AxiosError) {
|
|
@@ -22580,14 +22666,14 @@ var init_installMarket = __esm({
|
|
|
22580
22666
|
err += String(result.data);
|
|
22581
22667
|
}
|
|
22582
22668
|
logger.error(`[install] \u4E0B\u8F7Dapp\u63D2\u4EF6\u5931\u8D25:
|
|
22583
|
-
url: ${
|
|
22669
|
+
url: ${app5.url}
|
|
22584
22670
|
message: ${err}`);
|
|
22585
22671
|
msg.push(err);
|
|
22586
22672
|
emitLog(err);
|
|
22587
22673
|
return;
|
|
22588
22674
|
}
|
|
22589
|
-
msg.push(`${
|
|
22590
|
-
emitLog(`${
|
|
22675
|
+
msg.push(`${app5.url} \u4E0B\u8F7D\u6210\u529F`);
|
|
22676
|
+
emitLog(`${app5.url} \u4E0B\u8F7D\u6210\u529F`);
|
|
22591
22677
|
}));
|
|
22592
22678
|
emitLog("\u5B89\u88C5\u5B8C\u6210");
|
|
22593
22679
|
return true;
|
|
@@ -22763,28 +22849,28 @@ var init_uninstall = __esm({
|
|
|
22763
22849
|
return handleReturn2(res, false, "\u65E0\u6548\u8BF7\u6C42: \u63D2\u4EF6\u76EE\u6807\u9519\u8BEF");
|
|
22764
22850
|
}
|
|
22765
22851
|
const performUninstall = async (emitLog) => {
|
|
22766
|
-
const
|
|
22767
|
-
const
|
|
22768
|
-
const
|
|
22852
|
+
const npm2 = [];
|
|
22853
|
+
const git2 = [];
|
|
22854
|
+
const app5 = [];
|
|
22769
22855
|
const notExist = [];
|
|
22770
22856
|
const list2 = await getPlugins("all");
|
|
22771
22857
|
target.forEach(async (v) => {
|
|
22772
22858
|
if (v.type === "npm") {
|
|
22773
|
-
list2.includes(`${v.type}:${v.name}`) ?
|
|
22859
|
+
list2.includes(`${v.type}:${v.name}`) ? npm2.push(v.name) : notExist.push(v.name);
|
|
22774
22860
|
return;
|
|
22775
22861
|
}
|
|
22776
22862
|
if (v.type === "git") {
|
|
22777
|
-
list2.includes(`${v.type}:${v.name}`) ?
|
|
22863
|
+
list2.includes(`${v.type}:${v.name}`) ? git2.push(v.name) : notExist.push(v.name);
|
|
22778
22864
|
return;
|
|
22779
22865
|
}
|
|
22780
22866
|
if (v.type === "app") {
|
|
22781
|
-
|
|
22867
|
+
app5.push(v.name);
|
|
22782
22868
|
return;
|
|
22783
22869
|
}
|
|
22784
22870
|
notExist.push(v.name);
|
|
22785
22871
|
});
|
|
22786
|
-
await spawnProcess("pnpm", ["remove", ...
|
|
22787
|
-
for (const v of
|
|
22872
|
+
await spawnProcess("pnpm", ["remove", ...npm2, "--save"], { timeout: 60 * 1e3 }, emitLog);
|
|
22873
|
+
for (const v of git2) {
|
|
22788
22874
|
emitLog("-----------------------");
|
|
22789
22875
|
emitLog(`\u5F00\u59CB\u5378\u8F7D git \u63D2\u4EF6: ${v}`);
|
|
22790
22876
|
if (v.includes("..")) {
|
|
@@ -22804,7 +22890,7 @@ var init_uninstall = __esm({
|
|
|
22804
22890
|
}
|
|
22805
22891
|
emitLog("-----------------------\n\n");
|
|
22806
22892
|
}
|
|
22807
|
-
for (const v of
|
|
22893
|
+
for (const v of app5) {
|
|
22808
22894
|
emitLog("-----------------------");
|
|
22809
22895
|
emitLog(`\u5F00\u59CB\u5378\u8F7D app \u63D2\u4EF6: ${v}`);
|
|
22810
22896
|
if (v.includes("..")) {
|
|
@@ -22890,7 +22976,36 @@ var init_router2 = __esm({
|
|
|
22890
22976
|
};
|
|
22891
22977
|
}
|
|
22892
22978
|
});
|
|
22893
|
-
var
|
|
22979
|
+
var getRegistry, getNpmRegistry, getNpmLatestVersion;
|
|
22980
|
+
var init_registry = __esm({
|
|
22981
|
+
"src/utils/npm/registry.ts"() {
|
|
22982
|
+
init_exec();
|
|
22983
|
+
getRegistry = async () => {
|
|
22984
|
+
if (process.env.npm_config_registry) {
|
|
22985
|
+
return process.env.npm_config_registry;
|
|
22986
|
+
}
|
|
22987
|
+
const registry = await exec("npm config get registry");
|
|
22988
|
+
process.env.npm_config_registry = registry.stdout;
|
|
22989
|
+
return registry.stdout;
|
|
22990
|
+
};
|
|
22991
|
+
getNpmRegistry = async (name) => {
|
|
22992
|
+
const registry = await getRegistry();
|
|
22993
|
+
const response = await axios9.get(`${registry}/${name}`);
|
|
22994
|
+
return response.data;
|
|
22995
|
+
};
|
|
22996
|
+
getNpmLatestVersion = async (name) => {
|
|
22997
|
+
try {
|
|
22998
|
+
const result = await getNpmRegistry(name);
|
|
22999
|
+
return result["dist-tags"].latest;
|
|
23000
|
+
} catch (error) {
|
|
23001
|
+
logger.debug(new Error(`\u83B7\u53D6${name}\u6700\u65B0\u7248\u672C\u5931\u8D25`, { cause: error }));
|
|
23002
|
+
return null;
|
|
23003
|
+
}
|
|
23004
|
+
};
|
|
23005
|
+
getRegistry();
|
|
23006
|
+
}
|
|
23007
|
+
});
|
|
23008
|
+
var getDependenciesListRouter, getDependenciesInfo, getCache, setCache;
|
|
22894
23009
|
var init_list2 = __esm({
|
|
22895
23010
|
"src/server/dependencies/list.ts"() {
|
|
22896
23011
|
init_exec();
|
|
@@ -22898,6 +23013,7 @@ var init_list2 = __esm({
|
|
|
22898
23013
|
init_require();
|
|
22899
23014
|
init_response();
|
|
22900
23015
|
init_redis();
|
|
23016
|
+
init_registry();
|
|
22901
23017
|
getDependenciesListRouter = async (req, res) => {
|
|
22902
23018
|
try {
|
|
22903
23019
|
const cache10 = await getCache(req, res);
|
|
@@ -22967,9 +23083,8 @@ var init_list2 = __esm({
|
|
|
22967
23083
|
return;
|
|
22968
23084
|
}
|
|
22969
23085
|
try {
|
|
22970
|
-
const registry = await
|
|
22971
|
-
const
|
|
22972
|
-
const versions = Object.keys(response.data.versions || {});
|
|
23086
|
+
const registry = await getNpmRegistry(value.from);
|
|
23087
|
+
const versions = Object.keys(registry.versions);
|
|
22973
23088
|
const latest = versions.slice(-15).filter(Boolean);
|
|
22974
23089
|
let packageValue = "";
|
|
22975
23090
|
if (pkg2.dependencies?.[key]) {
|
|
@@ -22998,14 +23113,6 @@ var init_list2 = __esm({
|
|
|
22998
23113
|
logger.debug(`[getDependenciesInfo] \u83B7\u53D6${key}\u7684\u7248\u672C\u4FE1\u606F\u5931\u8D25`, error);
|
|
22999
23114
|
}
|
|
23000
23115
|
};
|
|
23001
|
-
getRegistry = async () => {
|
|
23002
|
-
if (process.env.npm_config_registry) {
|
|
23003
|
-
return process.env.npm_config_registry;
|
|
23004
|
-
}
|
|
23005
|
-
const registry = await exec("npm config get registry");
|
|
23006
|
-
process.env.npm_config_registry = registry.stdout;
|
|
23007
|
-
return registry.stdout;
|
|
23008
|
-
};
|
|
23009
23116
|
getCache = async (req, _) => {
|
|
23010
23117
|
if (req.body?.force) {
|
|
23011
23118
|
return null;
|
|
@@ -23030,7 +23137,6 @@ var init_list2 = __esm({
|
|
|
23030
23137
|
{ EX: REDIS_DEPENDENCIES_LIST_CACHE_EXPIRE }
|
|
23031
23138
|
);
|
|
23032
23139
|
};
|
|
23033
|
-
getRegistry();
|
|
23034
23140
|
}
|
|
23035
23141
|
});
|
|
23036
23142
|
var manageDependenciesRouter, installDependencies, removeDependencies, addDependencies;
|
|
@@ -23417,6 +23523,7 @@ var init_npmrc = __esm({
|
|
|
23417
23523
|
var init_npm = __esm({
|
|
23418
23524
|
"src/utils/npm/index.ts"() {
|
|
23419
23525
|
init_npmrc();
|
|
23526
|
+
init_registry();
|
|
23420
23527
|
}
|
|
23421
23528
|
});
|
|
23422
23529
|
|
|
@@ -23438,12 +23545,12 @@ var init_config5 = __esm({
|
|
|
23438
23545
|
};
|
|
23439
23546
|
getNpmrcContentRouter = async (req, res) => {
|
|
23440
23547
|
try {
|
|
23441
|
-
const { path:
|
|
23548
|
+
const { path: path38 } = req.body;
|
|
23442
23549
|
const list2 = await getNpmConfigList();
|
|
23443
|
-
if (!list2.find((item) => item.path ===
|
|
23550
|
+
if (!list2.find((item) => item.path === path38)) {
|
|
23444
23551
|
return createBadRequestResponse(res, "\u6587\u4EF6\u4E0D\u5B58\u5728");
|
|
23445
23552
|
}
|
|
23446
|
-
const content = ini.read(
|
|
23553
|
+
const content = ini.read(path38);
|
|
23447
23554
|
return createSuccessResponse(res, content);
|
|
23448
23555
|
} catch (error) {
|
|
23449
23556
|
logger.error("[getNpmrcContentRouter]", error);
|
|
@@ -23470,7 +23577,7 @@ var init_config5 = __esm({
|
|
|
23470
23577
|
};
|
|
23471
23578
|
saveNpmrcRouter = async (req, res) => {
|
|
23472
23579
|
try {
|
|
23473
|
-
const { path:
|
|
23580
|
+
const { path: path38, content, baseConfig } = req.body;
|
|
23474
23581
|
const list2 = await getNpmConfigList();
|
|
23475
23582
|
const promises = [];
|
|
23476
23583
|
if (baseConfig.registry) {
|
|
@@ -23483,11 +23590,11 @@ var init_config5 = __esm({
|
|
|
23483
23590
|
promises.push(setNpmConfig("https-proxy", baseConfig["https-proxy"]));
|
|
23484
23591
|
}
|
|
23485
23592
|
await Promise.all(promises);
|
|
23486
|
-
if (
|
|
23487
|
-
if (!list2.find((item) => item.path ===
|
|
23593
|
+
if (path38 && content) {
|
|
23594
|
+
if (!list2.find((item) => item.path === path38)) {
|
|
23488
23595
|
return createBadRequestResponse(res, "\u6587\u4EF6\u4E0D\u5B58\u5728");
|
|
23489
23596
|
}
|
|
23490
|
-
ini.write(content,
|
|
23597
|
+
ini.write(content, path38);
|
|
23491
23598
|
}
|
|
23492
23599
|
return createSuccessResponse(res, "\u4FDD\u5B58\u6210\u529F");
|
|
23493
23600
|
} catch (error) {
|
|
@@ -23497,52 +23604,149 @@ var init_config5 = __esm({
|
|
|
23497
23604
|
};
|
|
23498
23605
|
}
|
|
23499
23606
|
});
|
|
23500
|
-
var
|
|
23607
|
+
var getWebConfig2, defaultWebConfig, getWebConfigPath, getWebConfigMore;
|
|
23608
|
+
var init_webConfig = __esm({
|
|
23609
|
+
"src/server/plugins/config/webConfig.ts"() {
|
|
23610
|
+
init_env2();
|
|
23611
|
+
init_utils();
|
|
23612
|
+
init_list();
|
|
23613
|
+
getWebConfig2 = async (name) => {
|
|
23614
|
+
const list2 = await getPlugins("all", true);
|
|
23615
|
+
const plugin = list2.find((v) => v.name === name);
|
|
23616
|
+
if (!plugin) return defaultWebConfig();
|
|
23617
|
+
if (plugin.type === "npm" || plugin.type === "git") {
|
|
23618
|
+
const filepath = getWebConfigPath(plugin);
|
|
23619
|
+
if (!filepath) return defaultWebConfig();
|
|
23620
|
+
return getWebConfigMore(filepath);
|
|
23621
|
+
}
|
|
23622
|
+
return defaultWebConfig();
|
|
23623
|
+
};
|
|
23624
|
+
defaultWebConfig = (exists2, path38, customComponent, defaultComponent) => {
|
|
23625
|
+
return {
|
|
23626
|
+
exists: exists2 ?? false,
|
|
23627
|
+
path: path38 || "",
|
|
23628
|
+
customComponent: customComponent ?? false,
|
|
23629
|
+
defaultComponent: defaultComponent ?? false
|
|
23630
|
+
};
|
|
23631
|
+
};
|
|
23632
|
+
getWebConfigPath = (plugin) => {
|
|
23633
|
+
const dev = isDev();
|
|
23634
|
+
const pkg2 = plugin.pkgData;
|
|
23635
|
+
if (!pkg2.karin?.web) return null;
|
|
23636
|
+
if (dev) {
|
|
23637
|
+
if (!pkg2.karin["ts-web"]) return null;
|
|
23638
|
+
const filepath2 = path.join(plugin.dir, pkg2.karin["ts-web"]);
|
|
23639
|
+
if (!fs15.existsSync(filepath2)) return null;
|
|
23640
|
+
return filepath2;
|
|
23641
|
+
}
|
|
23642
|
+
const filepath = path.join(plugin.dir, pkg2.karin.web);
|
|
23643
|
+
if (!fs15.existsSync(filepath)) return null;
|
|
23644
|
+
return filepath;
|
|
23645
|
+
};
|
|
23646
|
+
getWebConfigMore = async (filepath) => {
|
|
23647
|
+
try {
|
|
23648
|
+
const web2 = await imports(filepath, { isImportDefault: true, isRefresh: isDev() });
|
|
23649
|
+
return defaultWebConfig(
|
|
23650
|
+
true,
|
|
23651
|
+
filepath,
|
|
23652
|
+
typeof web2?.customComponent === "function",
|
|
23653
|
+
typeof web2?.components === "function"
|
|
23654
|
+
);
|
|
23655
|
+
} catch (error) {
|
|
23656
|
+
logger.error(new Error("\u83B7\u53D6\u63D2\u4EF6web.config\u6587\u4EF6\u5931\u8D25", { cause: error }));
|
|
23657
|
+
return defaultWebConfig();
|
|
23658
|
+
}
|
|
23659
|
+
};
|
|
23660
|
+
}
|
|
23661
|
+
});
|
|
23662
|
+
var git, npm, app3, getPluginLocalList, getPluginListPluginAdmin, getLoadedCommandPluginCacheList, getFrontendInstalledPluginList;
|
|
23501
23663
|
var init_list4 = __esm({
|
|
23502
23664
|
"src/server/plugins/detail/list.ts"() {
|
|
23503
|
-
init_list();
|
|
23504
23665
|
init_system3();
|
|
23666
|
+
init_list();
|
|
23667
|
+
init_db();
|
|
23668
|
+
init_npm();
|
|
23669
|
+
init_webConfig();
|
|
23505
23670
|
init_git();
|
|
23506
23671
|
init_response();
|
|
23507
|
-
|
|
23672
|
+
init_env2();
|
|
23673
|
+
git = async (plugin) => {
|
|
23508
23674
|
try {
|
|
23509
|
-
const
|
|
23510
|
-
const
|
|
23511
|
-
|
|
23512
|
-
|
|
23513
|
-
|
|
23514
|
-
|
|
23515
|
-
|
|
23516
|
-
|
|
23517
|
-
|
|
23518
|
-
|
|
23519
|
-
|
|
23520
|
-
|
|
23521
|
-
|
|
23522
|
-
|
|
23523
|
-
|
|
23524
|
-
|
|
23525
|
-
|
|
23526
|
-
|
|
23527
|
-
|
|
23528
|
-
|
|
23529
|
-
|
|
23530
|
-
|
|
23531
|
-
|
|
23532
|
-
|
|
23533
|
-
|
|
23534
|
-
|
|
23535
|
-
|
|
23536
|
-
|
|
23537
|
-
|
|
23538
|
-
|
|
23539
|
-
|
|
23540
|
-
|
|
23541
|
-
|
|
23542
|
-
|
|
23543
|
-
|
|
23544
|
-
|
|
23545
|
-
|
|
23675
|
+
const version2 = await getLocalCommitHash(plugin.dir, { short: true });
|
|
23676
|
+
const latestHash = await getRemoteCommitHash(plugin.dir, { short: true });
|
|
23677
|
+
return {
|
|
23678
|
+
type: "git",
|
|
23679
|
+
id: plugin.pkgData.name,
|
|
23680
|
+
name: plugin.name,
|
|
23681
|
+
version: version2,
|
|
23682
|
+
latestVersion: latestHash,
|
|
23683
|
+
webConfig: await getWebConfig2(plugin.name)
|
|
23684
|
+
};
|
|
23685
|
+
} catch (error) {
|
|
23686
|
+
logger.debug(`\u83B7\u53D6\u63D2\u4EF6${plugin.name}\u63D0\u4EA4\u54C8\u5E0C\u5931\u8D25`, { cache: error });
|
|
23687
|
+
return {
|
|
23688
|
+
type: "git",
|
|
23689
|
+
id: plugin.pkgData.name,
|
|
23690
|
+
name: plugin.name,
|
|
23691
|
+
version: "0.0.0",
|
|
23692
|
+
latestVersion: "0.0.0",
|
|
23693
|
+
webConfig: await getWebConfig2(plugin.name)
|
|
23694
|
+
};
|
|
23695
|
+
}
|
|
23696
|
+
};
|
|
23697
|
+
npm = async (plugin) => {
|
|
23698
|
+
return {
|
|
23699
|
+
type: "npm",
|
|
23700
|
+
id: plugin.pkgData.name,
|
|
23701
|
+
name: plugin.name,
|
|
23702
|
+
version: plugin.pkgData.version,
|
|
23703
|
+
latestVersion: await getNpmLatestVersion(plugin.pkgData.name) || "0.0.0",
|
|
23704
|
+
webConfig: defaultWebConfig()
|
|
23705
|
+
};
|
|
23706
|
+
};
|
|
23707
|
+
app3 = async (plugin) => {
|
|
23708
|
+
return plugin.apps.map((v) => {
|
|
23709
|
+
return {
|
|
23710
|
+
type: "app",
|
|
23711
|
+
id: plugin.name,
|
|
23712
|
+
name: `${plugin.name}/${path4.basename(v)}`,
|
|
23713
|
+
version: "",
|
|
23714
|
+
latestVersion: "",
|
|
23715
|
+
webConfig: defaultWebConfig()
|
|
23716
|
+
};
|
|
23717
|
+
});
|
|
23718
|
+
};
|
|
23719
|
+
getPluginLocalList = async (isRefresh = false) => {
|
|
23720
|
+
if (!isRefresh) {
|
|
23721
|
+
const cachedData = await redis2.get(REDIS_LOCAL_PLUGIN_LIST_CACHE_KEY);
|
|
23722
|
+
if (cachedData) {
|
|
23723
|
+
return JSON.parse(cachedData);
|
|
23724
|
+
}
|
|
23725
|
+
}
|
|
23726
|
+
const list2 = [];
|
|
23727
|
+
const plugin = await getPlugins("all", true);
|
|
23728
|
+
await Promise.all(plugin.map(async (plugin2) => {
|
|
23729
|
+
if (plugin2.type === "git") {
|
|
23730
|
+
return list2.push(await git(plugin2));
|
|
23731
|
+
}
|
|
23732
|
+
if (plugin2.type === "npm") {
|
|
23733
|
+
return list2.push(await npm(plugin2));
|
|
23734
|
+
}
|
|
23735
|
+
if (plugin2.type === "app") {
|
|
23736
|
+
const result = await app3(plugin2);
|
|
23737
|
+
return list2.push(...result);
|
|
23738
|
+
}
|
|
23739
|
+
}));
|
|
23740
|
+
await redis2.set(REDIS_LOCAL_PLUGIN_LIST_CACHE_KEY, JSON.stringify(list2), {
|
|
23741
|
+
EX: REDIS_PLUGIN_LIST_CACHE_EXPIRE
|
|
23742
|
+
});
|
|
23743
|
+
return list2;
|
|
23744
|
+
};
|
|
23745
|
+
getPluginListPluginAdmin = async (req, res) => {
|
|
23746
|
+
try {
|
|
23747
|
+
const { isRefresh = false } = req.body;
|
|
23748
|
+
const result = await getPluginLocalList(isRefresh);
|
|
23749
|
+
createSuccessResponse(res, result);
|
|
23546
23750
|
} catch (error) {
|
|
23547
23751
|
createServerErrorResponse(res, error.message);
|
|
23548
23752
|
logger.error(error);
|
|
@@ -23584,6 +23788,56 @@ var init_list4 = __esm({
|
|
|
23584
23788
|
logger.error(error);
|
|
23585
23789
|
}
|
|
23586
23790
|
};
|
|
23791
|
+
getFrontendInstalledPluginList = async (req, res) => {
|
|
23792
|
+
const isRefresh = req.body.isRefresh || false;
|
|
23793
|
+
try {
|
|
23794
|
+
if (!isRefresh) {
|
|
23795
|
+
const cachedData = await redis2.get(REDIS_LOCAL_PLUGIN_LIST_CACHE_KEY_FRONTEND);
|
|
23796
|
+
if (cachedData) {
|
|
23797
|
+
return createSuccessResponse(res, JSON.parse(cachedData));
|
|
23798
|
+
}
|
|
23799
|
+
}
|
|
23800
|
+
const [list2, marketResult] = await Promise.all([
|
|
23801
|
+
getPlugins("all", false, isRefresh),
|
|
23802
|
+
getPluginMarket(isRefresh)
|
|
23803
|
+
]);
|
|
23804
|
+
const marketMap = {};
|
|
23805
|
+
marketResult.plugins.forEach((item) => {
|
|
23806
|
+
marketMap[item.name] = item;
|
|
23807
|
+
});
|
|
23808
|
+
const result = await Promise.all(
|
|
23809
|
+
list2.map(
|
|
23810
|
+
async (item) => {
|
|
23811
|
+
const [type, name] = item.split(":");
|
|
23812
|
+
const market = marketMap[name];
|
|
23813
|
+
const webConfig = await getWebConfig2(name);
|
|
23814
|
+
return {
|
|
23815
|
+
id: name,
|
|
23816
|
+
name,
|
|
23817
|
+
type,
|
|
23818
|
+
isMarketPlugin: !!market,
|
|
23819
|
+
description: market?.description || "",
|
|
23820
|
+
author: {
|
|
23821
|
+
name: market?.author[0].name || "",
|
|
23822
|
+
home: market?.author[0].home || "",
|
|
23823
|
+
avatar: market?.author[0].avatar || market?.author[0].home ? `${market?.author[0].home}.png` : ""
|
|
23824
|
+
},
|
|
23825
|
+
repoUrl: market?.repo[0].url || "",
|
|
23826
|
+
hasConfig: webConfig.defaultComponent,
|
|
23827
|
+
hasCustomComponent: false
|
|
23828
|
+
};
|
|
23829
|
+
}
|
|
23830
|
+
)
|
|
23831
|
+
);
|
|
23832
|
+
createSuccessResponse(res, result);
|
|
23833
|
+
await redis2.set(REDIS_LOCAL_PLUGIN_LIST_CACHE_KEY_FRONTEND, JSON.stringify(result), {
|
|
23834
|
+
EX: REDIS_LOCAL_PLUGIN_LIST_CACHE_EXPIRE_FRONTEND
|
|
23835
|
+
});
|
|
23836
|
+
} catch (error) {
|
|
23837
|
+
createServerErrorResponse(res, error.message);
|
|
23838
|
+
logger.error(error);
|
|
23839
|
+
}
|
|
23840
|
+
};
|
|
23587
23841
|
}
|
|
23588
23842
|
});
|
|
23589
23843
|
|
|
@@ -23804,6 +24058,7 @@ var init_router3 = __esm({
|
|
|
23804
24058
|
router.post(TASK_DELETE_ROUTER, taskDeleteRouter);
|
|
23805
24059
|
router.post(GET_LOADED_COMMAND_PLUGIN_CACHE_LIST_ROUTER, getLoadedCommandPluginCacheList);
|
|
23806
24060
|
router.post(GET_PLUGIN_MARKET_LIST_ROUTER, getPluginMarketList);
|
|
24061
|
+
router.post(GET_LOCAL_PLUGIN_FRONTEND_LIST_ROUTER, getFrontendInstalledPluginList);
|
|
23807
24062
|
}
|
|
23808
24063
|
});
|
|
23809
24064
|
|
|
@@ -23897,11 +24152,11 @@ headers: ${JSON.stringify(request2.headers, null, 2)}`
|
|
|
23897
24152
|
// src/server/app/app.ts
|
|
23898
24153
|
var app_exports = {};
|
|
23899
24154
|
__export(app_exports, {
|
|
23900
|
-
app: () =>
|
|
24155
|
+
app: () => app4,
|
|
23901
24156
|
initExpress: () => initExpress,
|
|
23902
24157
|
server: () => server
|
|
23903
24158
|
});
|
|
23904
|
-
var
|
|
24159
|
+
var app4, server, listen, web, initExpress;
|
|
23905
24160
|
var init_app = __esm({
|
|
23906
24161
|
"src/server/app/app.ts"() {
|
|
23907
24162
|
init_getMimeType();
|
|
@@ -23909,8 +24164,8 @@ var init_app = __esm({
|
|
|
23909
24164
|
init_listeners();
|
|
23910
24165
|
init_router3();
|
|
23911
24166
|
init_router();
|
|
23912
|
-
|
|
23913
|
-
server = createServer(
|
|
24167
|
+
app4 = express2();
|
|
24168
|
+
server = createServer(app4);
|
|
23914
24169
|
listen = (port2, host2) => {
|
|
23915
24170
|
server.listen(port2, host2, () => {
|
|
23916
24171
|
logger.info(`[server] express \u5DF2\u542F\u52A8 \u6B63\u5728\u76D1\u542C: http://${host2}:${port2}`);
|
|
@@ -23924,17 +24179,17 @@ var init_app = __esm({
|
|
|
23924
24179
|
};
|
|
23925
24180
|
web = (dir2) => {
|
|
23926
24181
|
const webDir = path4.join(dir2.karinDir, "dist/web");
|
|
23927
|
-
|
|
23928
|
-
|
|
23929
|
-
|
|
23930
|
-
|
|
24182
|
+
app4.use("/web", express2.static(webDir));
|
|
24183
|
+
app4.use("/sandbox/data", express2.static(dir2.sandboxDataPath));
|
|
24184
|
+
app4.use("/sandbox/file", express2.static(dir2.sandboxTempPath));
|
|
24185
|
+
app4.get("/web/{*splat}", (_, res) => {
|
|
23931
24186
|
res.sendFile("index.html", {
|
|
23932
24187
|
root: path4.resolve(webDir)
|
|
23933
24188
|
});
|
|
23934
24189
|
});
|
|
23935
24190
|
listeners.once("online", () => {
|
|
23936
24191
|
setTimeout(() => {
|
|
23937
|
-
|
|
24192
|
+
app4.all("/{*splat}", (_, res) => {
|
|
23938
24193
|
res.redirect("/web");
|
|
23939
24194
|
});
|
|
23940
24195
|
}, 5e3);
|
|
@@ -23942,7 +24197,7 @@ var init_app = __esm({
|
|
|
23942
24197
|
};
|
|
23943
24198
|
initExpress = async (dir2, port2, host2) => {
|
|
23944
24199
|
const webDir = path4.join(dir2.karinDir, "dist/web");
|
|
23945
|
-
|
|
24200
|
+
app4.use("/web", (req, res, next) => {
|
|
23946
24201
|
const filePath = path4.join(webDir, req.path);
|
|
23947
24202
|
const brPath = `${filePath}.br`;
|
|
23948
24203
|
const acceptEncoding = req.headers["accept-encoding"] || "";
|
|
@@ -23970,8 +24225,8 @@ var init_app = __esm({
|
|
|
23970
24225
|
next();
|
|
23971
24226
|
});
|
|
23972
24227
|
await Promise.resolve().then(() => (init_ws3(), ws_exports));
|
|
23973
|
-
|
|
23974
|
-
|
|
24228
|
+
app4.use(BASE_ROUTER, router);
|
|
24229
|
+
app4.get("/", rootRouter);
|
|
23975
24230
|
web(dir2);
|
|
23976
24231
|
listen(port2, host2);
|
|
23977
24232
|
};
|
|
@@ -24217,7 +24472,7 @@ var init_input = __esm({
|
|
|
24217
24472
|
}
|
|
24218
24473
|
});
|
|
24219
24474
|
var DEFAULT_USER_AVATAR, root, selfInfo, dir, stream2, addWrite, deleteData, addFriend, getFriendList, getFriend, writeAccountToFriendList, main2;
|
|
24220
|
-
var
|
|
24475
|
+
var init_db2 = __esm({
|
|
24221
24476
|
"src/service/sandbox/db.ts"() {
|
|
24222
24477
|
init_root();
|
|
24223
24478
|
DEFAULT_USER_AVATAR = "https://q1.qlogo.cn/g?b=qq&nk=1812868335&s=0";
|
|
@@ -24372,7 +24627,7 @@ var init_avatar = __esm({
|
|
|
24372
24627
|
"src/service/sandbox/avatar.ts"() {
|
|
24373
24628
|
init_root();
|
|
24374
24629
|
init_data();
|
|
24375
|
-
|
|
24630
|
+
init_db2();
|
|
24376
24631
|
}
|
|
24377
24632
|
});
|
|
24378
24633
|
|
|
@@ -24382,7 +24637,7 @@ var init_adapter2 = __esm({
|
|
|
24382
24637
|
init_base();
|
|
24383
24638
|
init_sender();
|
|
24384
24639
|
init_avatar();
|
|
24385
|
-
|
|
24640
|
+
init_db2();
|
|
24386
24641
|
}
|
|
24387
24642
|
});
|
|
24388
24643
|
|
|
@@ -24661,12 +24916,8 @@ var printStartLog = (version2) => {
|
|
|
24661
24916
|
logger.mark("https://github.com/KarinJS/Karin");
|
|
24662
24917
|
};
|
|
24663
24918
|
|
|
24664
|
-
// src/core/db/index.ts
|
|
24665
|
-
init_redis3();
|
|
24666
|
-
init_mock2();
|
|
24667
|
-
init_kv();
|
|
24668
|
-
|
|
24669
24919
|
// src/index.ts
|
|
24920
|
+
init_db();
|
|
24670
24921
|
init_render2();
|
|
24671
24922
|
|
|
24672
24923
|
// src/adapter/onebot/api/api.ts
|
|
@@ -24693,7 +24944,7 @@ var onebotPostRouter = async (req, res) => {
|
|
|
24693
24944
|
var router2 = Router();
|
|
24694
24945
|
router2.use(express2.json());
|
|
24695
24946
|
router2.post("/", onebotPostRouter);
|
|
24696
|
-
|
|
24947
|
+
app4.use("/onebot", router2);
|
|
24697
24948
|
|
|
24698
24949
|
// src/adapter/onebot/index.ts
|
|
24699
24950
|
init_internal();
|
|
@@ -25849,4 +26100,4 @@ var start2 = async () => {
|
|
|
25849
26100
|
(*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
25850
26101
|
*/
|
|
25851
26102
|
|
|
25852
|
-
export { AdapterBase, BASE_ROUTER, BATCH_UPDATE_PLUGINS_ROUTER, BaseEvent, Bot, CHECK_PLUGIN_ROUTER, CLOSE_TERMINAL_ROUTER, CONSOLE_ROUTER, CREATE_TERMINAL_ROUTER, DirectMessage, EVENT_COUNT, EXIT_ROUTER, FILE_CHANGE, FriendDecreaseNotice, FriendIncreaseNotice, FriendMessage, GET_BOTS_ROUTER, GET_CONFIG_ROUTER, GET_DEPENDENCIES_LIST_ROUTER, GET_LOADED_COMMAND_PLUGIN_CACHE_LIST_ROUTER, GET_LOCAL_PLUGIN_LIST_ROUTER, GET_LOG_FILE_LIST_ROUTER, GET_LOG_FILE_ROUTER, GET_LOG_ROUTER, GET_NETWORK_STATUS_ROUTER, GET_NPMRC_LIST_ROUTER, GET_NPM_BASE_CONFIG_ROUTER, GET_NPM_CONFIG_ROUTER, GET_ONLINE_PLUGIN_LIST_ROUTER, GET_PLUGIN_APPS_ROUTER, GET_PLUGIN_CONFIG_ROUTER, GET_PLUGIN_FILE_ROUTER, GET_PLUGIN_LIST_PLUGIN_ADMIN_ROUTER, GET_PLUGIN_LIST_ROUTER, GET_PLUGIN_MARKET_LIST_ROUTER, GET_TASK_LIST_ROUTER, GET_TASK_STATUS_ROUTER, GET_TERMINAL_LIST_ROUTER, GET_UPDATABLE_PLUGINS_ROUTER, GET_WEBUI_PLUGIN_LIST_ROUTER, GET_WEBUI_PLUGIN_VERSIONS_ROUTER, GroupAdminChangedNotice, GroupApplyRequest, GroupCardChangedNotice, GroupFileUploadedNotice, GroupHlightsChangedNotice, GroupHonorChangedNotice, GroupInviteRequest, GroupLuckKingNotice, GroupMemberBanNotice, GroupMemberDecreaseNotice, GroupMemberIncreaseNotice, GroupMemberTitleUpdatedNotice, GroupMessage, GroupMessageReactionNotice, GroupNotice, GroupPokeNotice, GroupRecallNotice, GroupSignInNotice, GroupTempMessage, GroupWholeBanNotice, GuildMessage, HTTPStatusCode, INSTALL_PLUGIN_ROUTER, INSTALL_WEBUI_PLUGIN_ROUTER, IS_PLUGIN_CONFIG_EXIST_ROUTER, LOGIN_ROUTER, MANAGE_DEPENDENCIES_ROUTER, MessageBase, NoticeBase, OB11ApiAction, OB11Event, OB11MessageSubType, OB11MessageType, OB11NoticeType, OB11RequestType, OB11Sex, PING_ROUTER, PLUGIN_ADMIN_ROUTER, Plugin, PrivateApplyRequest, PrivateFileUploadedNotice, PrivatePokeNotice, PrivateRecallNotice, RECV_MSG, REFRESH_ROUTER, RESTART_ROUTER, ReceiveLikeNotice, Renderer, RequestBase, SAVE_CONFIG_ROUTER, SAVE_NPMRC_ROUTER, SAVE_PLUGIN_CONFIG_ROUTER, SEND_MSG, SET_LOG_LEVEL_ROUTER, SYSTEM_INFO_ROUTER, SYSTEM_STATUS_KARIN_ROUTER, SYSTEM_STATUS_ROUTER, SYSTEM_STATUS_WS_ROUTER, TASK_DELETE_ROUTER, TASK_LIST_ROUTER, TASK_LOGS_ROUTER, TASK_RUN_ROUTER, UNINSTALL_PLUGIN_ROUTER, UNINSTALL_WEBUI_PLUGIN_ROUTER, UPDATE_CORE_ROUTER, UPDATE_PLUGIN_ROUTER, UPDATE_TASK_STATUS_ROUTER, UPDATE_WEBUI_PLUGIN_VERSION_ROUTER, WS_CLOSE, WS_CLOSE_ONEBOT, WS_CLOSE_PUPPETEER, WS_CLOSE_SANDBOX, WS_CONNECTION, WS_CONNECTION_ONEBOT, WS_CONNECTION_PUPPETEER, WS_CONNECTION_SANDBOX, WS_CONNECTION_TERMINAL, WS_SNAPKA, Watch, Watcher, YamlEditor, absPath, accordion, accordionItem, accordionPro,
|
|
26103
|
+
export { AdapterBase, BASE_ROUTER, BATCH_UPDATE_PLUGINS_ROUTER, BaseEvent, Bot, CHECK_PLUGIN_ROUTER, CLOSE_TERMINAL_ROUTER, CONSOLE_ROUTER, CREATE_TERMINAL_ROUTER, DirectMessage, EVENT_COUNT, EXIT_ROUTER, FILE_CHANGE, FriendDecreaseNotice, FriendIncreaseNotice, FriendMessage, GET_BOTS_ROUTER, GET_CONFIG_ROUTER, GET_DEPENDENCIES_LIST_ROUTER, GET_LOADED_COMMAND_PLUGIN_CACHE_LIST_ROUTER, GET_LOCAL_PLUGIN_FRONTEND_LIST_ROUTER, GET_LOCAL_PLUGIN_LIST_ROUTER, GET_LOG_FILE_LIST_ROUTER, GET_LOG_FILE_ROUTER, GET_LOG_ROUTER, GET_NETWORK_STATUS_ROUTER, GET_NPMRC_LIST_ROUTER, GET_NPM_BASE_CONFIG_ROUTER, GET_NPM_CONFIG_ROUTER, GET_ONLINE_PLUGIN_LIST_ROUTER, GET_PLUGIN_APPS_ROUTER, GET_PLUGIN_CONFIG_ROUTER, GET_PLUGIN_FILE_ROUTER, GET_PLUGIN_LIST_PLUGIN_ADMIN_ROUTER, GET_PLUGIN_LIST_ROUTER, GET_PLUGIN_MARKET_LIST_ROUTER, GET_TASK_LIST_ROUTER, GET_TASK_STATUS_ROUTER, GET_TERMINAL_LIST_ROUTER, GET_UPDATABLE_PLUGINS_ROUTER, GET_WEBUI_PLUGIN_LIST_ROUTER, GET_WEBUI_PLUGIN_VERSIONS_ROUTER, GroupAdminChangedNotice, GroupApplyRequest, GroupCardChangedNotice, GroupFileUploadedNotice, GroupHlightsChangedNotice, GroupHonorChangedNotice, GroupInviteRequest, GroupLuckKingNotice, GroupMemberBanNotice, GroupMemberDecreaseNotice, GroupMemberIncreaseNotice, GroupMemberTitleUpdatedNotice, GroupMessage, GroupMessageReactionNotice, GroupNotice, GroupPokeNotice, GroupRecallNotice, GroupSignInNotice, GroupTempMessage, GroupWholeBanNotice, GuildMessage, HTTPStatusCode, INSTALL_PLUGIN_ROUTER, INSTALL_WEBUI_PLUGIN_ROUTER, IS_PLUGIN_CONFIG_EXIST_ROUTER, LOGIN_ROUTER, MANAGE_DEPENDENCIES_ROUTER, MessageBase, NoticeBase, OB11ApiAction, OB11Event, OB11MessageSubType, OB11MessageType, OB11NoticeType, OB11RequestType, OB11Sex, PING_ROUTER, PLUGIN_ADMIN_ROUTER, Plugin, PrivateApplyRequest, PrivateFileUploadedNotice, PrivatePokeNotice, PrivateRecallNotice, RECV_MSG, REFRESH_ROUTER, RESTART_ROUTER, ReceiveLikeNotice, Renderer, RequestBase, SAVE_CONFIG_ROUTER, SAVE_NPMRC_ROUTER, SAVE_PLUGIN_CONFIG_ROUTER, SEND_MSG, SET_LOG_LEVEL_ROUTER, SYSTEM_INFO_ROUTER, SYSTEM_STATUS_KARIN_ROUTER, SYSTEM_STATUS_ROUTER, SYSTEM_STATUS_WS_ROUTER, TASK_DELETE_ROUTER, TASK_LIST_ROUTER, TASK_LOGS_ROUTER, TASK_RUN_ROUTER, UNINSTALL_PLUGIN_ROUTER, UNINSTALL_WEBUI_PLUGIN_ROUTER, UPDATE_CORE_ROUTER, UPDATE_PLUGIN_ROUTER, UPDATE_TASK_STATUS_ROUTER, UPDATE_WEBUI_PLUGIN_VERSION_ROUTER, WS_CLOSE, WS_CLOSE_ONEBOT, WS_CLOSE_PUPPETEER, WS_CLOSE_SANDBOX, WS_CONNECTION, WS_CONNECTION_ONEBOT, WS_CONNECTION_PUPPETEER, WS_CONNECTION_SANDBOX, WS_CONNECTION_TERMINAL, WS_SNAPKA, Watch, Watcher, YamlEditor, absPath, accordion, accordionItem, accordionPro, app4 as app, applyComments, authMiddleware, base64, basePath, buffer, buildGithub, buttonHandle, callRender, changelog_exports as changelog, checkGitPluginUpdate, checkPkgUpdate, checkPort, clearRequire, clearRequireFile, comment, commentPath, common_exports as common, components, config_exports as config, configPath, consolePath, contact2 as contact, contactDirect, contactFriend, contactGroup, contactGroupTemp, contactGuild, copyConfig, copyConfigSync, copyFiles, copyFilesSync, createAccessTokenExpiredResponse, createBadRequestResponse, createClient2 as createClient, createDirectMessage, createForbiddenResponse, createFriendDecreaseNotice, createFriendIncreaseNotice, createFriendMessage, createGroupAdminChangedNotice, createGroupApplyRequest, createGroupCardChangedNotice, createGroupFileUploadedNotice, createGroupHlightsChangedNotice, createGroupHonorChangedNotice, createGroupInviteRequest, createGroupLuckKingNotice, createGroupMemberAddNotice, createGroupMemberBanNotice, createGroupMemberDelNotice, createGroupMemberTitleUpdatedNotice, createGroupMessage, createGroupMessageReactionNotice, createGroupPokeNotice, createGroupRecallNotice, createGroupSignInNotice, createGroupTempMessage, createGroupWholeBanNotice, createGuildMessage, createHttp, createINIParser, createMethodNotAllowedResponse, createNotFoundResponse, createPayloadTooLargeResponse, createPluginDir, createPrivateApplyRequest, createPrivateFileUploadedNotice, createPrivatePokeNotice, createPrivateRecallNotice, createRawMessage, createReceiveLikeNotice, createRefreshTokenExpiredResponse, createResponse, createServerErrorResponse, createSuccessResponse, createTaskDatabase, createUnauthorizedResponse, cron, dataPath, db, dbPath, debug2 as debug, karin as default, defaultConfigPath, defaultViewPath, defineConfig, divider, downFile, downloadFile, errorToString, exec, executeTask, existToMkdir, existToMkdirSync, exists, existsSync, ffmpeg, ffplay, ffprobe, fs_exports as file, fileToUrl, fileToUrlHandlerKey, filesByExt, formatPath, formatTime, fs_exports2 as fs, getAllBot, getAllBotID, getAllBotList, getAllFiles, getAllFilesSync, getBot, getBotCount, getCommit, getDefaultBranch, getFastGithub, getFastRegistry, getFiles, getHash, getLocalBranches, getLocalCommitHash, getMimeType, getPackageJson, getPid, getPkgVersion, getPluginInfo, getPlugins, getRelPath, getRemoteBranches, getRemoteCommitHash, getRemotePkgVersion, getRender, getRenderCount, getRenderList, getRequestIp, getTaskCallback, getTaskDatabase, getTime, gitPull, handler, hooks, htmlPath, importModule, imports, ini, initOneBot, initTaskSystem, input, isClass, isDir, isDirSync, isDocker, isFile, isFileSync, isIPv4Loop, isIPv6Loop, isLinux, isLocalRequest, isLoopback, isMac, isPackaged, isPathEqual, isPkg, isPlugin, isPublic, isRoot, isSubPath, isWin2 as isWin, json, karin, karinDir, karinMain, karinPathBase, karinPathComment, karinPathConfig, karinPathConsole, karinPathData, karinPathDb, karinPathDefaultConfig, karinPathDefaultView, karinPathHtml, karinPathKv, karinPathLogs, karinPathMain, karinPathPlugins, karinPathPm2Config, karinPathRedisSqlite3, karinPathResource, karinPathRoot, karinPathSandboxData, karinPathSandboxTemp, karinPathTaskDb, karinPathTemp, karinToQQBot, key_exports as key, killApp, kvPath, lock, lockMethod, lockProp, log, logger2 as logger, logs, logsPath, makeForward, makeMessage, mkdir, mkdirSync, parseChangelog, parseGithubUrl, pingRequest, pkgRoot, pluginDir, pm2Path, qqbotToKarin, raceRequest, randomStr, range, read, readFile, readJson, readJsonSync, redis2 as redis, redisSqlite3Path, registerBot, registerRender, removeTaskCallback, render, renderHtml, renderMultiHtml, renderTpl, requireFile, requireFileSync, resourcePath, restart, restartDirect, rmSync, router, sandboxDataPath, sandboxTempPath, satisfies, save, segment_exports as segment, sendMsg2 as sendMsg, sender, senderDirect, senderFriend, senderGroup, senderGroupTemp, senderGuild, sep, server, setTaskCallback, setTaskDatabase, splitPath, start2 as start, stream, stringifyError, switchComponent, system_exports as system, taskAdd, taskExists, taskGet, taskList, taskSystem, taskUpdateLogs, taskUpdateStatus, tempPath, unregisterBot, unregisterRender, updateAllGitPlugin, updateAllPkg, updateGitPlugin, updatePkg, updateTaskLogs, updateTaskStatus, uptime, urlToPath, waitPort, watch, watchAndMerge, write, writeJson, writeJsonSync, yaml3 as yaml };
|