node-karin 1.10.8 → 1.10.10
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 +528 -256
- 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-DohyAioE.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-CG_dRKas.css.br +0 -0
- package/dist/web/assets/js/components-Bfe97cUJ.js.br +0 -0
- package/dist/web/assets/js/entry-BkAwtknL.js.br +0 -0
- package/dist/web/assets/js/hooks-BmMMMnav.js.br +0 -0
- package/dist/web/assets/js/page-404.tsx-DxI0lnTI.js +0 -1
- package/dist/web/assets/js/page-dashboard-DgtEZIey.js.br +0 -0
- package/dist/web/assets/js/page-loading.tsx-R9MyejLO.js.br +0 -0
- package/dist/web/assets/js/page-login.tsx-DVk1uIS7.js.br +0 -0
- package/dist/web/assets/js/vendor-heroui-BsSXGCwu.js.br +0 -0
- package/dist/web/assets/js/vendor-others-BGzZLgXC.js.br +0 -0
- package/dist/web/assets/js/vendor-react-CRkGRYXV.js.br +0 -0
- package/dist/web/assets/js/vendor-visual-BH1GvI0o.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
|
}
|
|
@@ -11517,6 +11581,7 @@ __export(system_exports, {
|
|
|
11517
11581
|
getRequestIp: () => getRequestIp,
|
|
11518
11582
|
getTime: () => getTime,
|
|
11519
11583
|
importModule: () => importModule,
|
|
11584
|
+
imports: () => imports,
|
|
11520
11585
|
isClass: () => isClass,
|
|
11521
11586
|
isDocker: () => isDocker,
|
|
11522
11587
|
isIPv4Loop: () => isIPv4Loop,
|
|
@@ -11654,8 +11719,13 @@ var init_race = __esm({
|
|
|
11654
11719
|
"https://registry.npmjs.com",
|
|
11655
11720
|
"https://mirrors.cloud.tencent.com/npm"
|
|
11656
11721
|
];
|
|
11657
|
-
|
|
11658
|
-
|
|
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
|
+
}
|
|
11659
11729
|
};
|
|
11660
11730
|
getPackageJson = async (owner, repo) => {
|
|
11661
11731
|
try {
|
|
@@ -11698,8 +11768,8 @@ var init_github = __esm({
|
|
|
11698
11768
|
const urlObj = new URL$1(url);
|
|
11699
11769
|
const owner = urlObj.pathname.split("/")[1];
|
|
11700
11770
|
const repo = urlObj.pathname.split("/")[2];
|
|
11701
|
-
const
|
|
11702
|
-
return { owner, repo, path:
|
|
11771
|
+
const path38 = urlObj.pathname.split("/").slice(3).join("/");
|
|
11772
|
+
return { owner, repo, path: path38 };
|
|
11703
11773
|
};
|
|
11704
11774
|
getFastGithub = async (type) => {
|
|
11705
11775
|
const list2 = [
|
|
@@ -11719,8 +11789,8 @@ var init_github = __esm({
|
|
|
11719
11789
|
isClone: false,
|
|
11720
11790
|
isRaw: true,
|
|
11721
11791
|
raw: function(url) {
|
|
11722
|
-
const { owner, repo, path:
|
|
11723
|
-
return `${this.proxy}/${owner}/${repo}/${
|
|
11792
|
+
const { owner, repo, path: path38 } = parseGithubUrl(url);
|
|
11793
|
+
return `${this.proxy}/${owner}/${repo}/${path38}`;
|
|
11724
11794
|
},
|
|
11725
11795
|
clone: function(url) {
|
|
11726
11796
|
const { owner, repo } = parseGithubUrl(url);
|
|
@@ -11732,8 +11802,8 @@ var init_github = __esm({
|
|
|
11732
11802
|
isClone: false,
|
|
11733
11803
|
isRaw: true,
|
|
11734
11804
|
raw: function(url) {
|
|
11735
|
-
const { owner, repo, path:
|
|
11736
|
-
return `${this.proxy}/${owner}/${repo}/${
|
|
11805
|
+
const { owner, repo, path: path38 } = parseGithubUrl(url);
|
|
11806
|
+
return `${this.proxy}/${owner}/${repo}/${path38}`;
|
|
11737
11807
|
},
|
|
11738
11808
|
clone: function(url) {
|
|
11739
11809
|
const { owner, repo } = parseGithubUrl(url);
|
|
@@ -17301,29 +17371,29 @@ var init_cache3 = __esm({
|
|
|
17301
17371
|
return i;
|
|
17302
17372
|
};
|
|
17303
17373
|
unregisterRender = (index6) => {
|
|
17304
|
-
const
|
|
17305
|
-
if (!
|
|
17374
|
+
const app5 = cache8.find((app6) => app6.index === index6);
|
|
17375
|
+
if (!app5) {
|
|
17306
17376
|
logger.error(`[render] \u5378\u8F7D\u5931\u8D25: \u4E0D\u5B58\u5728\u7D22\u5F15 ${index6}`);
|
|
17307
17377
|
return false;
|
|
17308
17378
|
}
|
|
17309
|
-
cache8.splice(cache8.findIndex((
|
|
17310
|
-
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}`);
|
|
17311
17381
|
return true;
|
|
17312
17382
|
};
|
|
17313
17383
|
getRender = (id) => {
|
|
17314
17384
|
if (cache8.length === 0) throw new Error("[\u8C03\u7528\u6E32\u67D3\u5668\u5931\u8D25] \u6E32\u67D3\u5668\u5217\u8868\u4E3A\u7A7A");
|
|
17315
17385
|
if (!id) {
|
|
17316
|
-
const
|
|
17317
|
-
return
|
|
17386
|
+
const app6 = cache8[Math.floor(Math.random() * cache8.length)];
|
|
17387
|
+
return app6;
|
|
17318
17388
|
}
|
|
17319
17389
|
if (typeof id === "number") {
|
|
17320
|
-
const
|
|
17321
|
-
if (!
|
|
17322
|
-
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;
|
|
17323
17393
|
}
|
|
17324
|
-
const
|
|
17325
|
-
if (!
|
|
17326
|
-
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;
|
|
17327
17397
|
};
|
|
17328
17398
|
callRender = async (options, id) => {
|
|
17329
17399
|
const res = getRender(id);
|
|
@@ -17332,7 +17402,7 @@ var init_cache3 = __esm({
|
|
|
17332
17402
|
};
|
|
17333
17403
|
getRenderCount = () => cache8.length;
|
|
17334
17404
|
getRenderList = () => {
|
|
17335
|
-
const list2 = cache8.map((
|
|
17405
|
+
const list2 = cache8.map((app5) => app5);
|
|
17336
17406
|
return list2;
|
|
17337
17407
|
};
|
|
17338
17408
|
renderHtml = (data) => {
|
|
@@ -17838,7 +17908,7 @@ var init_file2 = __esm({
|
|
|
17838
17908
|
});
|
|
17839
17909
|
|
|
17840
17910
|
// src/server/router/router.ts
|
|
17841
|
-
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;
|
|
17842
17912
|
var init_router = __esm({
|
|
17843
17913
|
"src/server/router/router.ts"() {
|
|
17844
17914
|
BASE_ROUTER = "/api/v1";
|
|
@@ -17900,6 +17970,7 @@ var init_router = __esm({
|
|
|
17900
17970
|
SAVE_NPMRC_ROUTER = "/dependencies/npmrc/save";
|
|
17901
17971
|
GET_LOADED_COMMAND_PLUGIN_CACHE_LIST_ROUTER = "/plugin/loaded/command";
|
|
17902
17972
|
GET_PLUGIN_MARKET_LIST_ROUTER = "/plugin/market";
|
|
17973
|
+
GET_LOCAL_PLUGIN_FRONTEND_LIST_ROUTER = "/plugin/local/frontend";
|
|
17903
17974
|
}
|
|
17904
17975
|
});
|
|
17905
17976
|
var isWindows, tips, createHttpClient, request, handleResponse, checkPort2, safeExecSync, getPm2Id, safeKillProcess, forceKillProcess, checkProcess;
|
|
@@ -17916,35 +17987,35 @@ var init_check = __esm({
|
|
|
17916
17987
|
headers: { Authorization: `Bearer ${process.env.HTTP_AUTH_KEY}` },
|
|
17917
17988
|
validateStatus: () => true
|
|
17918
17989
|
});
|
|
17919
|
-
request = async (url,
|
|
17990
|
+
request = async (url, path38, method, timeout2, isPrint = true) => {
|
|
17920
17991
|
const client = createHttpClient(url, timeout2);
|
|
17921
17992
|
try {
|
|
17922
|
-
const result = await client[method](
|
|
17923
|
-
return handleResponse(result, method,
|
|
17993
|
+
const result = await client[method](path38);
|
|
17994
|
+
return handleResponse(result, method, path38, isPrint);
|
|
17924
17995
|
} catch (error) {
|
|
17925
17996
|
logger.debug(
|
|
17926
|
-
tips(`${method.toUpperCase()} \u8BF7\u6C42\u5F02\u5E38:`, true) + ` ${
|
|
17997
|
+
tips(`${method.toUpperCase()} \u8BF7\u6C42\u5F02\u5E38:`, true) + ` ${path38} - ${error?.message || "\u672A\u77E5\u9519\u8BEF"}`
|
|
17927
17998
|
);
|
|
17928
17999
|
return { code: 500, success: false };
|
|
17929
18000
|
}
|
|
17930
18001
|
};
|
|
17931
|
-
handleResponse = (result, method,
|
|
18002
|
+
handleResponse = (result, method, path38, isPrint) => {
|
|
17932
18003
|
if (result.status === 200) {
|
|
17933
18004
|
isPrint && logger.info(
|
|
17934
|
-
tips(`${method.toUpperCase()} \u8BF7\u6C42\u6210\u529F:`, true) + ` ${
|
|
18005
|
+
tips(`${method.toUpperCase()} \u8BF7\u6C42\u6210\u529F:`, true) + ` ${path38} -> ${JSON.stringify(result.data)}`
|
|
17935
18006
|
);
|
|
17936
18007
|
return { code: result.status, success: true, data: result.data };
|
|
17937
18008
|
}
|
|
17938
18009
|
if (result.status === 401) {
|
|
17939
18010
|
logger.error(
|
|
17940
|
-
tips(`${method.toUpperCase()} \u9274\u6743\u5931\u8D25:`, true) + ` ${
|
|
18011
|
+
tips(`${method.toUpperCase()} \u9274\u6743\u5931\u8D25:`, true) + ` ${path38} -> ${JSON.stringify(result.data)}`
|
|
17941
18012
|
);
|
|
17942
18013
|
return { code: result.status, success: false };
|
|
17943
18014
|
}
|
|
17944
|
-
const logMethod =
|
|
18015
|
+
const logMethod = path38 === "/ping" ? logger.debug : logger.error;
|
|
17945
18016
|
logMethod.call(
|
|
17946
18017
|
logger,
|
|
17947
|
-
tips(`${method.toUpperCase()} \u8BF7\u6C42\u5931\u8D25:`, true) + ` ${
|
|
18018
|
+
tips(`${method.toUpperCase()} \u8BF7\u6C42\u5931\u8D25:`, true) + ` ${path38} -> ${JSON.stringify(result.data)}`
|
|
17948
18019
|
);
|
|
17949
18020
|
return { code: result.status, success: false };
|
|
17950
18021
|
};
|
|
@@ -19457,10 +19528,10 @@ var init_load = __esm({
|
|
|
19457
19528
|
}
|
|
19458
19529
|
}
|
|
19459
19530
|
}
|
|
19460
|
-
pkg2.apps.forEach((
|
|
19531
|
+
pkg2.apps.forEach((app5) => {
|
|
19461
19532
|
const promise = async () => {
|
|
19462
|
-
const result = await pkgLoadModule(pkg2.name,
|
|
19463
|
-
pkgCache(result, pkg2,
|
|
19533
|
+
const result = await pkgLoadModule(pkg2.name, app5);
|
|
19534
|
+
pkgCache(result, pkg2, app5);
|
|
19464
19535
|
};
|
|
19465
19536
|
allPromises.push(promise());
|
|
19466
19537
|
});
|
|
@@ -19490,12 +19561,12 @@ var init_load = __esm({
|
|
|
19490
19561
|
isType = (val, type) => {
|
|
19491
19562
|
return val.file?.type === type;
|
|
19492
19563
|
};
|
|
19493
|
-
pkgCache = (result, pkg2,
|
|
19564
|
+
pkgCache = (result, pkg2, app5) => {
|
|
19494
19565
|
const cacheHandler = (val, key) => {
|
|
19495
19566
|
if (typeof val !== "object") return;
|
|
19496
19567
|
if (!val?.pkg || !val.file) return;
|
|
19497
19568
|
val.pkg = pkg2;
|
|
19498
|
-
val.file = createFile2(
|
|
19569
|
+
val.file = createFile2(app5, val.file.type, key, val.file.name);
|
|
19499
19570
|
if (isType(val, "accept")) {
|
|
19500
19571
|
cache3.count.accept++;
|
|
19501
19572
|
cache3.accept.push(val);
|
|
@@ -19539,7 +19610,7 @@ var init_load = __esm({
|
|
|
19539
19610
|
if (key === "default") continue;
|
|
19540
19611
|
if (typeof result[key] === "function") {
|
|
19541
19612
|
if (!isClass(result[key])) continue;
|
|
19542
|
-
cacheClassPlugin(result[key], pkg2,
|
|
19613
|
+
cacheClassPlugin(result[key], pkg2, app5, key);
|
|
19543
19614
|
continue;
|
|
19544
19615
|
}
|
|
19545
19616
|
const data = result[key];
|
|
@@ -19548,9 +19619,9 @@ var init_load = __esm({
|
|
|
19548
19619
|
}
|
|
19549
19620
|
}
|
|
19550
19621
|
};
|
|
19551
|
-
createFile2 = (
|
|
19622
|
+
createFile2 = (app5, type, method, name) => {
|
|
19552
19623
|
return {
|
|
19553
|
-
absPath:
|
|
19624
|
+
absPath: app5,
|
|
19554
19625
|
get dirname() {
|
|
19555
19626
|
return path4.dirname(this.absPath);
|
|
19556
19627
|
},
|
|
@@ -19562,14 +19633,14 @@ var init_load = __esm({
|
|
|
19562
19633
|
name: name || type
|
|
19563
19634
|
};
|
|
19564
19635
|
};
|
|
19565
|
-
cacheClassPlugin = (Method, pkg2,
|
|
19636
|
+
cacheClassPlugin = (Method, pkg2, app5, _) => {
|
|
19566
19637
|
const command2 = new Method();
|
|
19567
19638
|
if (!command2.name) {
|
|
19568
|
-
logger.error(`[load][${
|
|
19639
|
+
logger.error(`[load][${app5}] plugin.name \u4E0D\u80FD\u4E3A\u7A7A`);
|
|
19569
19640
|
return;
|
|
19570
19641
|
}
|
|
19571
19642
|
if (!command2.rule || !Array.isArray(command2.rule) || command2.rule?.length === 0) {
|
|
19572
|
-
logger.error(`[load][${
|
|
19643
|
+
logger.error(`[load][${app5}] ${command2.name} plugin.rule \u4E0D\u80FD\u4E3A\u7A7A`);
|
|
19573
19644
|
return;
|
|
19574
19645
|
}
|
|
19575
19646
|
command2.rule.forEach((v) => {
|
|
@@ -19586,7 +19657,7 @@ var init_load = __esm({
|
|
|
19586
19657
|
permission: v.permission || "all",
|
|
19587
19658
|
event: v.event || command2.event || "message",
|
|
19588
19659
|
priority: v.priority || 1e4,
|
|
19589
|
-
file: createFile2(
|
|
19660
|
+
file: createFile2(app5, "command", v.fnc, command2.name),
|
|
19590
19661
|
authFailMsg: v.authFailMsg || true
|
|
19591
19662
|
});
|
|
19592
19663
|
});
|
|
@@ -19624,6 +19695,15 @@ var init_load = __esm({
|
|
|
19624
19695
|
};
|
|
19625
19696
|
}
|
|
19626
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
|
+
});
|
|
19627
19707
|
var createHttpRenderClient;
|
|
19628
19708
|
var init_http3 = __esm({
|
|
19629
19709
|
"src/adapter/render/connect/http.ts"() {
|
|
@@ -20363,12 +20443,13 @@ var init_ping = __esm({
|
|
|
20363
20443
|
};
|
|
20364
20444
|
}
|
|
20365
20445
|
});
|
|
20366
|
-
var fileExists, getWebConfigPathFromPkg, getNpmPluginConfigPath, getLocalPluginConfigPath, getConfigPath, loadConfig, getWebConfig, normalizeAuthor, pluginGetConfig, pluginSaveConfig, pluginIsConfigExist;
|
|
20446
|
+
var fileExists, getWebConfigPathFromPkg, getNpmPluginConfigPath, getLocalPluginConfigPath, getConfigPath, loadConfig, getWebConfig, normalizeAuthor, pluginGetConfig, pluginSaveConfig, pluginIsConfigExist, getPluginType;
|
|
20367
20447
|
var init_config4 = __esm({
|
|
20368
20448
|
"src/server/plugins/config.ts"() {
|
|
20369
20449
|
init_env2();
|
|
20370
20450
|
init_require();
|
|
20371
20451
|
init_response();
|
|
20452
|
+
init_list();
|
|
20372
20453
|
fileExists = (filepath) => {
|
|
20373
20454
|
try {
|
|
20374
20455
|
return fs5.existsSync(filepath);
|
|
@@ -20452,13 +20533,13 @@ var init_config4 = __esm({
|
|
|
20452
20533
|
}
|
|
20453
20534
|
return null;
|
|
20454
20535
|
};
|
|
20455
|
-
getConfigPath = (
|
|
20536
|
+
getConfigPath = (type, name) => {
|
|
20456
20537
|
try {
|
|
20457
|
-
switch (
|
|
20538
|
+
switch (type) {
|
|
20458
20539
|
case "npm":
|
|
20459
|
-
return getNpmPluginConfigPath(
|
|
20540
|
+
return getNpmPluginConfigPath(name);
|
|
20460
20541
|
case "git":
|
|
20461
|
-
return getLocalPluginConfigPath(
|
|
20542
|
+
return getLocalPluginConfigPath(name);
|
|
20462
20543
|
default:
|
|
20463
20544
|
return null;
|
|
20464
20545
|
}
|
|
@@ -20479,7 +20560,7 @@ var init_config4 = __esm({
|
|
|
20479
20560
|
if (!["git", "npm"].includes(type)) {
|
|
20480
20561
|
return null;
|
|
20481
20562
|
}
|
|
20482
|
-
const webConfig = getConfigPath(
|
|
20563
|
+
const webConfig = getConfigPath(type, id);
|
|
20483
20564
|
if (!webConfig) {
|
|
20484
20565
|
return null;
|
|
20485
20566
|
}
|
|
@@ -20524,17 +20605,22 @@ var init_config4 = __esm({
|
|
|
20524
20605
|
};
|
|
20525
20606
|
pluginGetConfig = async (req, res) => {
|
|
20526
20607
|
const options = req.body;
|
|
20527
|
-
if (!options.
|
|
20608
|
+
if (!options.name) {
|
|
20528
20609
|
createServerErrorResponse(res, "\u53C2\u6570\u9519\u8BEF");
|
|
20529
20610
|
return;
|
|
20530
20611
|
}
|
|
20531
|
-
const
|
|
20612
|
+
const type = await getPluginType(options.name);
|
|
20613
|
+
if (!type) return createServerErrorResponse(res, "\u53C2\u6570\u9519\u8BEF");
|
|
20614
|
+
const config3 = await getWebConfig(type, options.name, () => {
|
|
20532
20615
|
logger.error(`[plugin] \u63D2\u4EF6${options.name}\u7684web\u914D\u7F6E\u6587\u4EF6\u540D\u79F0\u4E0D\u6B63\u786E: \u9700\u8981\u4EE5 web.config \u547D\u540D`);
|
|
20533
20616
|
createSuccessResponse(res, null);
|
|
20534
20617
|
});
|
|
20535
20618
|
if (!config3) {
|
|
20536
20619
|
return createServerErrorResponse(res, "\u53C2\u6570\u9519\u8BEF");
|
|
20537
20620
|
}
|
|
20621
|
+
if (typeof config3.components !== "function") {
|
|
20622
|
+
return createServerErrorResponse(res, "\u8BE5\u63D2\u4EF6\u672A\u63D0\u4F9B\u9ED8\u8BA4\u7EC4\u4EF6\u914D\u7F6E\u51FD\u6570");
|
|
20623
|
+
}
|
|
20538
20624
|
const list2 = [];
|
|
20539
20625
|
let result = config3.components();
|
|
20540
20626
|
result = util5.types.isPromise(result) ? await result : result;
|
|
@@ -20557,19 +20643,40 @@ var init_config4 = __esm({
|
|
|
20557
20643
|
createSuccessResponse(res, data);
|
|
20558
20644
|
};
|
|
20559
20645
|
pluginSaveConfig = async (req, res) => {
|
|
20560
|
-
const
|
|
20561
|
-
const
|
|
20646
|
+
const { name, config: config3 } = req.body;
|
|
20647
|
+
const type = await getPluginType(name);
|
|
20648
|
+
if (!type) return createServerErrorResponse(res, "\u53C2\u6570\u9519\u8BEF");
|
|
20649
|
+
const configPath2 = getConfigPath(type, name);
|
|
20562
20650
|
if (!configPath2) return createServerErrorResponse(res, "\u53C2\u6570\u9519\u8BEF");
|
|
20563
20651
|
const { save: save2 } = await loadConfig(configPath2);
|
|
20564
|
-
|
|
20652
|
+
if (typeof save2 !== "function") {
|
|
20653
|
+
return createServerErrorResponse(res, "\u8BE5\u63D2\u4EF6\u672A\u63D0\u4F9B\u9ED8\u8BA4\u7EC4\u4EF6\u4FDD\u5B58\u5B8C\u6210");
|
|
20654
|
+
}
|
|
20655
|
+
const result = save2(config3);
|
|
20565
20656
|
const response = util5.types.isPromise(result) ? await result : result;
|
|
20566
20657
|
createSuccessResponse(res, response || { success: true, message: "\u6CA1\u6709\u8FD4\u56DE\u503C\u54E6 \u03C6(>\u03C9<*) " });
|
|
20567
20658
|
};
|
|
20568
20659
|
pluginIsConfigExist = async (req, res) => {
|
|
20569
|
-
const
|
|
20570
|
-
const
|
|
20660
|
+
const name = req.body.name;
|
|
20661
|
+
const type = await getPluginType(name);
|
|
20662
|
+
if (!name || !type) {
|
|
20663
|
+
return createServerErrorResponse(res, "\u53C2\u6570\u9519\u8BEF");
|
|
20664
|
+
}
|
|
20665
|
+
const configPath2 = getConfigPath(type, name);
|
|
20571
20666
|
createSuccessResponse(res, typeof configPath2 === "string");
|
|
20572
20667
|
};
|
|
20668
|
+
getPluginType = async (name) => {
|
|
20669
|
+
const list2 = await getPlugins("all", false);
|
|
20670
|
+
const npmName = `npm:${name}`;
|
|
20671
|
+
const gitName = `git:${name}`;
|
|
20672
|
+
const rootName = `root:${name}`;
|
|
20673
|
+
for (const item of list2) {
|
|
20674
|
+
if (item === npmName) return "npm";
|
|
20675
|
+
if (item === gitName) return "git";
|
|
20676
|
+
if (item === rootName) return "npm";
|
|
20677
|
+
}
|
|
20678
|
+
return null;
|
|
20679
|
+
};
|
|
20573
20680
|
}
|
|
20574
20681
|
});
|
|
20575
20682
|
|
|
@@ -20583,11 +20690,11 @@ var init_local = __esm({
|
|
|
20583
20690
|
init_response();
|
|
20584
20691
|
pluginGetLocalList = async (req, res) => {
|
|
20585
20692
|
const { isForce } = req.body;
|
|
20586
|
-
const [
|
|
20693
|
+
const [npm2, git2] = await Promise.all([
|
|
20587
20694
|
getPlugins("npm", true, isForce ?? false),
|
|
20588
20695
|
getPlugins("git", true, isForce ?? false)
|
|
20589
20696
|
]);
|
|
20590
|
-
const list2 = [...
|
|
20697
|
+
const list2 = [...npm2, ...git2];
|
|
20591
20698
|
const result = [];
|
|
20592
20699
|
const promise = [];
|
|
20593
20700
|
list2.forEach((val) => promise.push(isWebConfigPlugin(val, result)));
|
|
@@ -22253,27 +22360,27 @@ var init_update3 = __esm({
|
|
|
22253
22360
|
return handleReturn2(res, true, "\u66F4\u65B0\u4EFB\u52A1\u5DF2\u521B\u5EFA\uFF0C\u8BF7\u901A\u8FC7taskId\u6267\u884C\u4EFB\u52A1", id2);
|
|
22254
22361
|
}
|
|
22255
22362
|
const performUpdate = async (_, log3) => {
|
|
22256
|
-
const
|
|
22257
|
-
const
|
|
22363
|
+
const npm2 = [];
|
|
22364
|
+
const git2 = [];
|
|
22258
22365
|
const notExist = [];
|
|
22259
22366
|
const list2 = await getPlugins("all", false, true);
|
|
22260
22367
|
for (const item of data.target) {
|
|
22261
22368
|
if (item.type === "npm") {
|
|
22262
|
-
list2.includes(`${item.type}:${item.name}`) ?
|
|
22369
|
+
list2.includes(`${item.type}:${item.name}`) ? npm2.push({ name: item.name, version: item.version || "latest" }) : notExist.push(item.name);
|
|
22263
22370
|
continue;
|
|
22264
22371
|
}
|
|
22265
22372
|
if (item.type === "git") {
|
|
22266
22373
|
const force = typeof item.force === "boolean" ? item.force : false;
|
|
22267
|
-
list2.includes(`${item.type}:${item.name}`) ?
|
|
22374
|
+
list2.includes(`${item.type}:${item.name}`) ? git2.push({ name: item.name, version: item.version || "latest", force }) : notExist.push(item.name);
|
|
22268
22375
|
continue;
|
|
22269
22376
|
}
|
|
22270
22377
|
notExist.push(item.name);
|
|
22271
22378
|
}
|
|
22272
|
-
if (
|
|
22273
|
-
const args =
|
|
22379
|
+
if (npm2.length > 0) {
|
|
22380
|
+
const args = npm2.map((item) => `${item.name}@${item.version}`);
|
|
22274
22381
|
await spawnProcess("pnpm", ["update", ...args, "--save"], { timeout: 60 * 1e3 }, log3);
|
|
22275
22382
|
}
|
|
22276
|
-
for (const item of
|
|
22383
|
+
for (const item of git2) {
|
|
22277
22384
|
const { name, force } = item;
|
|
22278
22385
|
const cwd = path4.join(karinPathPlugins, name);
|
|
22279
22386
|
const result = await gitPull(cwd, { force, timeout: 60 * 1e3 });
|
|
@@ -22308,16 +22415,16 @@ var init_update3 = __esm({
|
|
|
22308
22415
|
updateAll = async (_, log3, options) => {
|
|
22309
22416
|
const categorizePlugins = async () => {
|
|
22310
22417
|
const list2 = await getPlugins("all", true, true);
|
|
22311
|
-
const
|
|
22312
|
-
const
|
|
22418
|
+
const git3 = [];
|
|
22419
|
+
const npm3 = ["node-karin"];
|
|
22313
22420
|
for (const item of list2) {
|
|
22314
22421
|
if (item.type === "npm") {
|
|
22315
|
-
|
|
22422
|
+
npm3.push(item.name);
|
|
22316
22423
|
} else if (item.type === "git") {
|
|
22317
|
-
|
|
22424
|
+
git3.push(item.name);
|
|
22318
22425
|
}
|
|
22319
22426
|
}
|
|
22320
|
-
return { npm:
|
|
22427
|
+
return { npm: npm3, git: git3 };
|
|
22321
22428
|
};
|
|
22322
22429
|
const updateNpmPlugins = async (npmPlugins) => {
|
|
22323
22430
|
if (npmPlugins.length === 0) return;
|
|
@@ -22343,10 +22450,10 @@ var init_update3 = __esm({
|
|
|
22343
22450
|
}
|
|
22344
22451
|
log3("\u5168\u90E8git\u63D2\u4EF6\u66F4\u65B0\u5B8C\u6210");
|
|
22345
22452
|
};
|
|
22346
|
-
const { npm, git } = await categorizePlugins();
|
|
22453
|
+
const { npm: npm2, git: git2 } = await categorizePlugins();
|
|
22347
22454
|
try {
|
|
22348
|
-
await updateNpmPlugins(
|
|
22349
|
-
await updateGitPlugins(
|
|
22455
|
+
await updateNpmPlugins(npm2);
|
|
22456
|
+
await updateGitPlugins(git2);
|
|
22350
22457
|
} catch (error) {
|
|
22351
22458
|
log3(`* \u53D1\u751F\u9519\u8BEF: ${error instanceof Error ? error.message : String(error)}`);
|
|
22352
22459
|
}
|
|
@@ -22524,8 +22631,8 @@ var init_installMarket = __esm({
|
|
|
22524
22631
|
);
|
|
22525
22632
|
}
|
|
22526
22633
|
let isRace = false;
|
|
22527
|
-
for (const
|
|
22528
|
-
if (
|
|
22634
|
+
for (const app5 of urls) {
|
|
22635
|
+
if (app5.url.startsWith("https://raw.githubusercontent.com")) {
|
|
22529
22636
|
isRace = true;
|
|
22530
22637
|
break;
|
|
22531
22638
|
}
|
|
@@ -22551,11 +22658,11 @@ var init_installMarket = __esm({
|
|
|
22551
22658
|
const dir2 = path4.join(karinPathPlugins, "karin-plugin-example");
|
|
22552
22659
|
mkdirSync(dir2);
|
|
22553
22660
|
emitLog("\u5F00\u59CB\u4E0B\u8F7D\u63D2\u4EF6\u6587\u4EF6...");
|
|
22554
|
-
await Promise.all(urls.map(async (
|
|
22555
|
-
const filename2 = path4.basename(
|
|
22661
|
+
await Promise.all(urls.map(async (app5) => {
|
|
22662
|
+
const filename2 = path4.basename(app5.url);
|
|
22556
22663
|
const fileUrl = path4.join(dir2, filename2);
|
|
22557
22664
|
emitLog(`\u6B63\u5728\u4E0B\u8F7D: ${filename2}`);
|
|
22558
|
-
const result = await downloadFile(
|
|
22665
|
+
const result = await downloadFile(app5.url, fileUrl);
|
|
22559
22666
|
if (!result.success) {
|
|
22560
22667
|
let err = `${filename2} \u4E0B\u8F7D\u5931\u8D25: `;
|
|
22561
22668
|
if (result.data instanceof AxiosError) {
|
|
@@ -22566,14 +22673,14 @@ var init_installMarket = __esm({
|
|
|
22566
22673
|
err += String(result.data);
|
|
22567
22674
|
}
|
|
22568
22675
|
logger.error(`[install] \u4E0B\u8F7Dapp\u63D2\u4EF6\u5931\u8D25:
|
|
22569
|
-
url: ${
|
|
22676
|
+
url: ${app5.url}
|
|
22570
22677
|
message: ${err}`);
|
|
22571
22678
|
msg.push(err);
|
|
22572
22679
|
emitLog(err);
|
|
22573
22680
|
return;
|
|
22574
22681
|
}
|
|
22575
|
-
msg.push(`${
|
|
22576
|
-
emitLog(`${
|
|
22682
|
+
msg.push(`${app5.url} \u4E0B\u8F7D\u6210\u529F`);
|
|
22683
|
+
emitLog(`${app5.url} \u4E0B\u8F7D\u6210\u529F`);
|
|
22577
22684
|
}));
|
|
22578
22685
|
emitLog("\u5B89\u88C5\u5B8C\u6210");
|
|
22579
22686
|
return true;
|
|
@@ -22749,28 +22856,28 @@ var init_uninstall = __esm({
|
|
|
22749
22856
|
return handleReturn2(res, false, "\u65E0\u6548\u8BF7\u6C42: \u63D2\u4EF6\u76EE\u6807\u9519\u8BEF");
|
|
22750
22857
|
}
|
|
22751
22858
|
const performUninstall = async (emitLog) => {
|
|
22752
|
-
const
|
|
22753
|
-
const
|
|
22754
|
-
const
|
|
22859
|
+
const npm2 = [];
|
|
22860
|
+
const git2 = [];
|
|
22861
|
+
const app5 = [];
|
|
22755
22862
|
const notExist = [];
|
|
22756
22863
|
const list2 = await getPlugins("all");
|
|
22757
22864
|
target.forEach(async (v) => {
|
|
22758
22865
|
if (v.type === "npm") {
|
|
22759
|
-
list2.includes(`${v.type}:${v.name}`) ?
|
|
22866
|
+
list2.includes(`${v.type}:${v.name}`) ? npm2.push(v.name) : notExist.push(v.name);
|
|
22760
22867
|
return;
|
|
22761
22868
|
}
|
|
22762
22869
|
if (v.type === "git") {
|
|
22763
|
-
list2.includes(`${v.type}:${v.name}`) ?
|
|
22870
|
+
list2.includes(`${v.type}:${v.name}`) ? git2.push(v.name) : notExist.push(v.name);
|
|
22764
22871
|
return;
|
|
22765
22872
|
}
|
|
22766
22873
|
if (v.type === "app") {
|
|
22767
|
-
|
|
22874
|
+
app5.push(v.name);
|
|
22768
22875
|
return;
|
|
22769
22876
|
}
|
|
22770
22877
|
notExist.push(v.name);
|
|
22771
22878
|
});
|
|
22772
|
-
await spawnProcess("pnpm", ["remove", ...
|
|
22773
|
-
for (const v of
|
|
22879
|
+
await spawnProcess("pnpm", ["remove", ...npm2, "--save"], { timeout: 60 * 1e3 }, emitLog);
|
|
22880
|
+
for (const v of git2) {
|
|
22774
22881
|
emitLog("-----------------------");
|
|
22775
22882
|
emitLog(`\u5F00\u59CB\u5378\u8F7D git \u63D2\u4EF6: ${v}`);
|
|
22776
22883
|
if (v.includes("..")) {
|
|
@@ -22790,7 +22897,7 @@ var init_uninstall = __esm({
|
|
|
22790
22897
|
}
|
|
22791
22898
|
emitLog("-----------------------\n\n");
|
|
22792
22899
|
}
|
|
22793
|
-
for (const v of
|
|
22900
|
+
for (const v of app5) {
|
|
22794
22901
|
emitLog("-----------------------");
|
|
22795
22902
|
emitLog(`\u5F00\u59CB\u5378\u8F7D app \u63D2\u4EF6: ${v}`);
|
|
22796
22903
|
if (v.includes("..")) {
|
|
@@ -22876,7 +22983,36 @@ var init_router2 = __esm({
|
|
|
22876
22983
|
};
|
|
22877
22984
|
}
|
|
22878
22985
|
});
|
|
22879
|
-
var
|
|
22986
|
+
var getRegistry, getNpmRegistry, getNpmLatestVersion;
|
|
22987
|
+
var init_registry = __esm({
|
|
22988
|
+
"src/utils/npm/registry.ts"() {
|
|
22989
|
+
init_exec();
|
|
22990
|
+
getRegistry = async () => {
|
|
22991
|
+
if (process.env.npm_config_registry) {
|
|
22992
|
+
return process.env.npm_config_registry;
|
|
22993
|
+
}
|
|
22994
|
+
const registry = await exec("npm config get registry");
|
|
22995
|
+
process.env.npm_config_registry = registry.stdout;
|
|
22996
|
+
return registry.stdout;
|
|
22997
|
+
};
|
|
22998
|
+
getNpmRegistry = async (name) => {
|
|
22999
|
+
const registry = await getRegistry();
|
|
23000
|
+
const response = await axios9.get(`${registry}/${name}`);
|
|
23001
|
+
return response.data;
|
|
23002
|
+
};
|
|
23003
|
+
getNpmLatestVersion = async (name) => {
|
|
23004
|
+
try {
|
|
23005
|
+
const result = await getNpmRegistry(name);
|
|
23006
|
+
return result["dist-tags"].latest;
|
|
23007
|
+
} catch (error) {
|
|
23008
|
+
logger.debug(new Error(`\u83B7\u53D6${name}\u6700\u65B0\u7248\u672C\u5931\u8D25`, { cause: error }));
|
|
23009
|
+
return null;
|
|
23010
|
+
}
|
|
23011
|
+
};
|
|
23012
|
+
getRegistry();
|
|
23013
|
+
}
|
|
23014
|
+
});
|
|
23015
|
+
var getDependenciesListRouter, getDependenciesInfo, getCache, setCache;
|
|
22880
23016
|
var init_list2 = __esm({
|
|
22881
23017
|
"src/server/dependencies/list.ts"() {
|
|
22882
23018
|
init_exec();
|
|
@@ -22884,6 +23020,7 @@ var init_list2 = __esm({
|
|
|
22884
23020
|
init_require();
|
|
22885
23021
|
init_response();
|
|
22886
23022
|
init_redis();
|
|
23023
|
+
init_registry();
|
|
22887
23024
|
getDependenciesListRouter = async (req, res) => {
|
|
22888
23025
|
try {
|
|
22889
23026
|
const cache10 = await getCache(req, res);
|
|
@@ -22953,9 +23090,8 @@ var init_list2 = __esm({
|
|
|
22953
23090
|
return;
|
|
22954
23091
|
}
|
|
22955
23092
|
try {
|
|
22956
|
-
const registry = await
|
|
22957
|
-
const
|
|
22958
|
-
const versions = Object.keys(response.data.versions || {});
|
|
23093
|
+
const registry = await getNpmRegistry(value.from);
|
|
23094
|
+
const versions = Object.keys(registry.versions);
|
|
22959
23095
|
const latest = versions.slice(-15).filter(Boolean);
|
|
22960
23096
|
let packageValue = "";
|
|
22961
23097
|
if (pkg2.dependencies?.[key]) {
|
|
@@ -22984,14 +23120,6 @@ var init_list2 = __esm({
|
|
|
22984
23120
|
logger.debug(`[getDependenciesInfo] \u83B7\u53D6${key}\u7684\u7248\u672C\u4FE1\u606F\u5931\u8D25`, error);
|
|
22985
23121
|
}
|
|
22986
23122
|
};
|
|
22987
|
-
getRegistry = async () => {
|
|
22988
|
-
if (process.env.npm_config_registry) {
|
|
22989
|
-
return process.env.npm_config_registry;
|
|
22990
|
-
}
|
|
22991
|
-
const registry = await exec("npm config get registry");
|
|
22992
|
-
process.env.npm_config_registry = registry.stdout;
|
|
22993
|
-
return registry.stdout;
|
|
22994
|
-
};
|
|
22995
23123
|
getCache = async (req, _) => {
|
|
22996
23124
|
if (req.body?.force) {
|
|
22997
23125
|
return null;
|
|
@@ -23016,7 +23144,6 @@ var init_list2 = __esm({
|
|
|
23016
23144
|
{ EX: REDIS_DEPENDENCIES_LIST_CACHE_EXPIRE }
|
|
23017
23145
|
);
|
|
23018
23146
|
};
|
|
23019
|
-
getRegistry();
|
|
23020
23147
|
}
|
|
23021
23148
|
});
|
|
23022
23149
|
var manageDependenciesRouter, installDependencies, removeDependencies, addDependencies;
|
|
@@ -23403,6 +23530,7 @@ var init_npmrc = __esm({
|
|
|
23403
23530
|
var init_npm = __esm({
|
|
23404
23531
|
"src/utils/npm/index.ts"() {
|
|
23405
23532
|
init_npmrc();
|
|
23533
|
+
init_registry();
|
|
23406
23534
|
}
|
|
23407
23535
|
});
|
|
23408
23536
|
|
|
@@ -23424,12 +23552,12 @@ var init_config5 = __esm({
|
|
|
23424
23552
|
};
|
|
23425
23553
|
getNpmrcContentRouter = async (req, res) => {
|
|
23426
23554
|
try {
|
|
23427
|
-
const { path:
|
|
23555
|
+
const { path: path38 } = req.body;
|
|
23428
23556
|
const list2 = await getNpmConfigList();
|
|
23429
|
-
if (!list2.find((item) => item.path ===
|
|
23557
|
+
if (!list2.find((item) => item.path === path38)) {
|
|
23430
23558
|
return createBadRequestResponse(res, "\u6587\u4EF6\u4E0D\u5B58\u5728");
|
|
23431
23559
|
}
|
|
23432
|
-
const content = ini.read(
|
|
23560
|
+
const content = ini.read(path38);
|
|
23433
23561
|
return createSuccessResponse(res, content);
|
|
23434
23562
|
} catch (error) {
|
|
23435
23563
|
logger.error("[getNpmrcContentRouter]", error);
|
|
@@ -23456,7 +23584,7 @@ var init_config5 = __esm({
|
|
|
23456
23584
|
};
|
|
23457
23585
|
saveNpmrcRouter = async (req, res) => {
|
|
23458
23586
|
try {
|
|
23459
|
-
const { path:
|
|
23587
|
+
const { path: path38, content, baseConfig } = req.body;
|
|
23460
23588
|
const list2 = await getNpmConfigList();
|
|
23461
23589
|
const promises = [];
|
|
23462
23590
|
if (baseConfig.registry) {
|
|
@@ -23469,11 +23597,11 @@ var init_config5 = __esm({
|
|
|
23469
23597
|
promises.push(setNpmConfig("https-proxy", baseConfig["https-proxy"]));
|
|
23470
23598
|
}
|
|
23471
23599
|
await Promise.all(promises);
|
|
23472
|
-
if (
|
|
23473
|
-
if (!list2.find((item) => item.path ===
|
|
23600
|
+
if (path38 && content) {
|
|
23601
|
+
if (!list2.find((item) => item.path === path38)) {
|
|
23474
23602
|
return createBadRequestResponse(res, "\u6587\u4EF6\u4E0D\u5B58\u5728");
|
|
23475
23603
|
}
|
|
23476
|
-
ini.write(content,
|
|
23604
|
+
ini.write(content, path38);
|
|
23477
23605
|
}
|
|
23478
23606
|
return createSuccessResponse(res, "\u4FDD\u5B58\u6210\u529F");
|
|
23479
23607
|
} catch (error) {
|
|
@@ -23483,52 +23611,149 @@ var init_config5 = __esm({
|
|
|
23483
23611
|
};
|
|
23484
23612
|
}
|
|
23485
23613
|
});
|
|
23486
|
-
var
|
|
23614
|
+
var getWebConfig2, defaultWebConfig, getWebConfigPath, getWebConfigMore;
|
|
23615
|
+
var init_webConfig = __esm({
|
|
23616
|
+
"src/server/plugins/config/webConfig.ts"() {
|
|
23617
|
+
init_env2();
|
|
23618
|
+
init_utils();
|
|
23619
|
+
init_list();
|
|
23620
|
+
getWebConfig2 = async (name) => {
|
|
23621
|
+
const list2 = await getPlugins("all", true);
|
|
23622
|
+
const plugin = list2.find((v) => v.name === name);
|
|
23623
|
+
if (!plugin) return defaultWebConfig();
|
|
23624
|
+
if (plugin.type === "npm" || plugin.type === "git") {
|
|
23625
|
+
const filepath = getWebConfigPath(plugin);
|
|
23626
|
+
if (!filepath) return defaultWebConfig();
|
|
23627
|
+
return getWebConfigMore(filepath);
|
|
23628
|
+
}
|
|
23629
|
+
return defaultWebConfig();
|
|
23630
|
+
};
|
|
23631
|
+
defaultWebConfig = (exists2, path38, customComponent, defaultComponent) => {
|
|
23632
|
+
return {
|
|
23633
|
+
exists: exists2 ?? false,
|
|
23634
|
+
path: path38 || "",
|
|
23635
|
+
customComponent: customComponent ?? false,
|
|
23636
|
+
defaultComponent: defaultComponent ?? false
|
|
23637
|
+
};
|
|
23638
|
+
};
|
|
23639
|
+
getWebConfigPath = (plugin) => {
|
|
23640
|
+
const dev = isDev();
|
|
23641
|
+
const pkg2 = plugin.pkgData;
|
|
23642
|
+
if (!pkg2.karin?.web) return null;
|
|
23643
|
+
if (dev) {
|
|
23644
|
+
if (!pkg2.karin["ts-web"]) return null;
|
|
23645
|
+
const filepath2 = path.join(plugin.dir, pkg2.karin["ts-web"]);
|
|
23646
|
+
if (!fs15.existsSync(filepath2)) return null;
|
|
23647
|
+
return filepath2;
|
|
23648
|
+
}
|
|
23649
|
+
const filepath = path.join(plugin.dir, pkg2.karin.web);
|
|
23650
|
+
if (!fs15.existsSync(filepath)) return null;
|
|
23651
|
+
return filepath;
|
|
23652
|
+
};
|
|
23653
|
+
getWebConfigMore = async (filepath) => {
|
|
23654
|
+
try {
|
|
23655
|
+
const web2 = await imports(filepath, { isImportDefault: true, isRefresh: isDev() });
|
|
23656
|
+
return defaultWebConfig(
|
|
23657
|
+
true,
|
|
23658
|
+
filepath,
|
|
23659
|
+
typeof web2?.customComponent === "function",
|
|
23660
|
+
typeof web2?.components === "function"
|
|
23661
|
+
);
|
|
23662
|
+
} catch (error) {
|
|
23663
|
+
logger.error(new Error("\u83B7\u53D6\u63D2\u4EF6web.config\u6587\u4EF6\u5931\u8D25", { cause: error }));
|
|
23664
|
+
return defaultWebConfig();
|
|
23665
|
+
}
|
|
23666
|
+
};
|
|
23667
|
+
}
|
|
23668
|
+
});
|
|
23669
|
+
var git, npm, app3, getPluginLocalList, getPluginListPluginAdmin, getLoadedCommandPluginCacheList, getFrontendInstalledPluginList;
|
|
23487
23670
|
var init_list4 = __esm({
|
|
23488
23671
|
"src/server/plugins/detail/list.ts"() {
|
|
23489
|
-
init_list();
|
|
23490
23672
|
init_system3();
|
|
23673
|
+
init_list();
|
|
23674
|
+
init_db();
|
|
23675
|
+
init_npm();
|
|
23676
|
+
init_webConfig();
|
|
23491
23677
|
init_git();
|
|
23492
23678
|
init_response();
|
|
23493
|
-
|
|
23679
|
+
init_env2();
|
|
23680
|
+
git = async (plugin) => {
|
|
23494
23681
|
try {
|
|
23495
|
-
const
|
|
23496
|
-
const
|
|
23497
|
-
|
|
23498
|
-
|
|
23499
|
-
|
|
23500
|
-
|
|
23501
|
-
|
|
23502
|
-
|
|
23503
|
-
|
|
23504
|
-
|
|
23505
|
-
|
|
23506
|
-
|
|
23507
|
-
|
|
23508
|
-
|
|
23509
|
-
|
|
23510
|
-
|
|
23511
|
-
|
|
23512
|
-
|
|
23513
|
-
|
|
23514
|
-
|
|
23515
|
-
|
|
23516
|
-
|
|
23517
|
-
|
|
23518
|
-
|
|
23519
|
-
|
|
23520
|
-
|
|
23521
|
-
|
|
23522
|
-
|
|
23523
|
-
|
|
23524
|
-
|
|
23525
|
-
|
|
23526
|
-
|
|
23527
|
-
|
|
23528
|
-
|
|
23529
|
-
|
|
23530
|
-
|
|
23531
|
-
|
|
23682
|
+
const version2 = await getLocalCommitHash(plugin.dir, { short: true });
|
|
23683
|
+
const latestHash = await getRemoteCommitHash(plugin.dir, { short: true });
|
|
23684
|
+
return {
|
|
23685
|
+
type: "git",
|
|
23686
|
+
id: plugin.pkgData.name,
|
|
23687
|
+
name: plugin.name,
|
|
23688
|
+
version: version2,
|
|
23689
|
+
latestVersion: latestHash,
|
|
23690
|
+
webConfig: await getWebConfig2(plugin.name)
|
|
23691
|
+
};
|
|
23692
|
+
} catch (error) {
|
|
23693
|
+
logger.debug(`\u83B7\u53D6\u63D2\u4EF6${plugin.name}\u63D0\u4EA4\u54C8\u5E0C\u5931\u8D25`, { cache: error });
|
|
23694
|
+
return {
|
|
23695
|
+
type: "git",
|
|
23696
|
+
id: plugin.pkgData.name,
|
|
23697
|
+
name: plugin.name,
|
|
23698
|
+
version: "0.0.0",
|
|
23699
|
+
latestVersion: "0.0.0",
|
|
23700
|
+
webConfig: await getWebConfig2(plugin.name)
|
|
23701
|
+
};
|
|
23702
|
+
}
|
|
23703
|
+
};
|
|
23704
|
+
npm = async (plugin) => {
|
|
23705
|
+
return {
|
|
23706
|
+
type: "npm",
|
|
23707
|
+
id: plugin.pkgData.name,
|
|
23708
|
+
name: plugin.name,
|
|
23709
|
+
version: plugin.pkgData.version,
|
|
23710
|
+
latestVersion: await getNpmLatestVersion(plugin.pkgData.name) || "0.0.0",
|
|
23711
|
+
webConfig: defaultWebConfig()
|
|
23712
|
+
};
|
|
23713
|
+
};
|
|
23714
|
+
app3 = async (plugin) => {
|
|
23715
|
+
return plugin.apps.map((v) => {
|
|
23716
|
+
return {
|
|
23717
|
+
type: "app",
|
|
23718
|
+
id: plugin.name,
|
|
23719
|
+
name: `${plugin.name}/${path4.basename(v)}`,
|
|
23720
|
+
version: "",
|
|
23721
|
+
latestVersion: "",
|
|
23722
|
+
webConfig: defaultWebConfig()
|
|
23723
|
+
};
|
|
23724
|
+
});
|
|
23725
|
+
};
|
|
23726
|
+
getPluginLocalList = async (isRefresh = false) => {
|
|
23727
|
+
if (!isRefresh) {
|
|
23728
|
+
const cachedData = await redis2.get(REDIS_LOCAL_PLUGIN_LIST_CACHE_KEY);
|
|
23729
|
+
if (cachedData) {
|
|
23730
|
+
return JSON.parse(cachedData);
|
|
23731
|
+
}
|
|
23732
|
+
}
|
|
23733
|
+
const list2 = [];
|
|
23734
|
+
const plugin = await getPlugins("all", true);
|
|
23735
|
+
await Promise.all(plugin.map(async (plugin2) => {
|
|
23736
|
+
if (plugin2.type === "git") {
|
|
23737
|
+
return list2.push(await git(plugin2));
|
|
23738
|
+
}
|
|
23739
|
+
if (plugin2.type === "npm") {
|
|
23740
|
+
return list2.push(await npm(plugin2));
|
|
23741
|
+
}
|
|
23742
|
+
if (plugin2.type === "app") {
|
|
23743
|
+
const result = await app3(plugin2);
|
|
23744
|
+
return list2.push(...result);
|
|
23745
|
+
}
|
|
23746
|
+
}));
|
|
23747
|
+
await redis2.set(REDIS_LOCAL_PLUGIN_LIST_CACHE_KEY, JSON.stringify(list2), {
|
|
23748
|
+
EX: REDIS_PLUGIN_LIST_CACHE_EXPIRE
|
|
23749
|
+
});
|
|
23750
|
+
return list2;
|
|
23751
|
+
};
|
|
23752
|
+
getPluginListPluginAdmin = async (req, res) => {
|
|
23753
|
+
try {
|
|
23754
|
+
const { isRefresh = false } = req.body;
|
|
23755
|
+
const result = await getPluginLocalList(isRefresh);
|
|
23756
|
+
createSuccessResponse(res, result);
|
|
23532
23757
|
} catch (error) {
|
|
23533
23758
|
createServerErrorResponse(res, error.message);
|
|
23534
23759
|
logger.error(error);
|
|
@@ -23570,6 +23795,56 @@ var init_list4 = __esm({
|
|
|
23570
23795
|
logger.error(error);
|
|
23571
23796
|
}
|
|
23572
23797
|
};
|
|
23798
|
+
getFrontendInstalledPluginList = async (req, res) => {
|
|
23799
|
+
const isRefresh = req.body.isRefresh || false;
|
|
23800
|
+
try {
|
|
23801
|
+
if (!isRefresh) {
|
|
23802
|
+
const cachedData = await redis2.get(REDIS_LOCAL_PLUGIN_LIST_CACHE_KEY_FRONTEND);
|
|
23803
|
+
if (cachedData) {
|
|
23804
|
+
return createSuccessResponse(res, JSON.parse(cachedData));
|
|
23805
|
+
}
|
|
23806
|
+
}
|
|
23807
|
+
const [list2, marketResult] = await Promise.all([
|
|
23808
|
+
getPlugins("all", false, isRefresh),
|
|
23809
|
+
getPluginMarket(isRefresh)
|
|
23810
|
+
]);
|
|
23811
|
+
const marketMap = {};
|
|
23812
|
+
marketResult.plugins.forEach((item) => {
|
|
23813
|
+
marketMap[item.name] = item;
|
|
23814
|
+
});
|
|
23815
|
+
const result = await Promise.all(
|
|
23816
|
+
list2.map(
|
|
23817
|
+
async (item) => {
|
|
23818
|
+
const [type, name] = item.split(":");
|
|
23819
|
+
const market = marketMap[name];
|
|
23820
|
+
const webConfig = await getWebConfig2(name);
|
|
23821
|
+
return {
|
|
23822
|
+
id: name,
|
|
23823
|
+
name,
|
|
23824
|
+
type,
|
|
23825
|
+
isMarketPlugin: !!market,
|
|
23826
|
+
description: market?.description || "",
|
|
23827
|
+
author: {
|
|
23828
|
+
name: market?.author[0].name || "",
|
|
23829
|
+
home: market?.author[0].home || "",
|
|
23830
|
+
avatar: market?.author[0].avatar || market?.author[0].home ? `${market?.author[0].home}.png` : ""
|
|
23831
|
+
},
|
|
23832
|
+
repoUrl: market?.repo[0].url || "",
|
|
23833
|
+
hasConfig: webConfig.defaultComponent,
|
|
23834
|
+
hasCustomComponent: false
|
|
23835
|
+
};
|
|
23836
|
+
}
|
|
23837
|
+
)
|
|
23838
|
+
);
|
|
23839
|
+
createSuccessResponse(res, result);
|
|
23840
|
+
await redis2.set(REDIS_LOCAL_PLUGIN_LIST_CACHE_KEY_FRONTEND, JSON.stringify(result), {
|
|
23841
|
+
EX: REDIS_LOCAL_PLUGIN_LIST_CACHE_EXPIRE_FRONTEND
|
|
23842
|
+
});
|
|
23843
|
+
} catch (error) {
|
|
23844
|
+
createServerErrorResponse(res, error.message);
|
|
23845
|
+
logger.error(error);
|
|
23846
|
+
}
|
|
23847
|
+
};
|
|
23573
23848
|
}
|
|
23574
23849
|
});
|
|
23575
23850
|
|
|
@@ -23790,6 +24065,7 @@ var init_router3 = __esm({
|
|
|
23790
24065
|
router.post(TASK_DELETE_ROUTER, taskDeleteRouter);
|
|
23791
24066
|
router.post(GET_LOADED_COMMAND_PLUGIN_CACHE_LIST_ROUTER, getLoadedCommandPluginCacheList);
|
|
23792
24067
|
router.post(GET_PLUGIN_MARKET_LIST_ROUTER, getPluginMarketList);
|
|
24068
|
+
router.post(GET_LOCAL_PLUGIN_FRONTEND_LIST_ROUTER, getFrontendInstalledPluginList);
|
|
23793
24069
|
}
|
|
23794
24070
|
});
|
|
23795
24071
|
|
|
@@ -23883,11 +24159,11 @@ headers: ${JSON.stringify(request2.headers, null, 2)}`
|
|
|
23883
24159
|
// src/server/app/app.ts
|
|
23884
24160
|
var app_exports = {};
|
|
23885
24161
|
__export(app_exports, {
|
|
23886
|
-
app: () =>
|
|
24162
|
+
app: () => app4,
|
|
23887
24163
|
initExpress: () => initExpress,
|
|
23888
24164
|
server: () => server
|
|
23889
24165
|
});
|
|
23890
|
-
var
|
|
24166
|
+
var app4, server, listen, web, initExpress;
|
|
23891
24167
|
var init_app = __esm({
|
|
23892
24168
|
"src/server/app/app.ts"() {
|
|
23893
24169
|
init_getMimeType();
|
|
@@ -23895,8 +24171,8 @@ var init_app = __esm({
|
|
|
23895
24171
|
init_listeners();
|
|
23896
24172
|
init_router3();
|
|
23897
24173
|
init_router();
|
|
23898
|
-
|
|
23899
|
-
server = createServer(
|
|
24174
|
+
app4 = express2();
|
|
24175
|
+
server = createServer(app4);
|
|
23900
24176
|
listen = (port2, host2) => {
|
|
23901
24177
|
server.listen(port2, host2, () => {
|
|
23902
24178
|
logger.info(`[server] express \u5DF2\u542F\u52A8 \u6B63\u5728\u76D1\u542C: http://${host2}:${port2}`);
|
|
@@ -23910,17 +24186,17 @@ var init_app = __esm({
|
|
|
23910
24186
|
};
|
|
23911
24187
|
web = (dir2) => {
|
|
23912
24188
|
const webDir = path4.join(dir2.karinDir, "dist/web");
|
|
23913
|
-
|
|
23914
|
-
|
|
23915
|
-
|
|
23916
|
-
|
|
24189
|
+
app4.use("/web", express2.static(webDir));
|
|
24190
|
+
app4.use("/sandbox/data", express2.static(dir2.sandboxDataPath));
|
|
24191
|
+
app4.use("/sandbox/file", express2.static(dir2.sandboxTempPath));
|
|
24192
|
+
app4.get("/web/{*splat}", (_, res) => {
|
|
23917
24193
|
res.sendFile("index.html", {
|
|
23918
24194
|
root: path4.resolve(webDir)
|
|
23919
24195
|
});
|
|
23920
24196
|
});
|
|
23921
24197
|
listeners.once("online", () => {
|
|
23922
24198
|
setTimeout(() => {
|
|
23923
|
-
|
|
24199
|
+
app4.all("/{*splat}", (_, res) => {
|
|
23924
24200
|
res.redirect("/web");
|
|
23925
24201
|
});
|
|
23926
24202
|
}, 5e3);
|
|
@@ -23928,7 +24204,7 @@ var init_app = __esm({
|
|
|
23928
24204
|
};
|
|
23929
24205
|
initExpress = async (dir2, port2, host2) => {
|
|
23930
24206
|
const webDir = path4.join(dir2.karinDir, "dist/web");
|
|
23931
|
-
|
|
24207
|
+
app4.use("/web", (req, res, next) => {
|
|
23932
24208
|
const filePath = path4.join(webDir, req.path);
|
|
23933
24209
|
const brPath = `${filePath}.br`;
|
|
23934
24210
|
const acceptEncoding = req.headers["accept-encoding"] || "";
|
|
@@ -23956,8 +24232,8 @@ var init_app = __esm({
|
|
|
23956
24232
|
next();
|
|
23957
24233
|
});
|
|
23958
24234
|
await Promise.resolve().then(() => (init_ws3(), ws_exports));
|
|
23959
|
-
|
|
23960
|
-
|
|
24235
|
+
app4.use(BASE_ROUTER, router);
|
|
24236
|
+
app4.get("/", rootRouter);
|
|
23961
24237
|
web(dir2);
|
|
23962
24238
|
listen(port2, host2);
|
|
23963
24239
|
};
|
|
@@ -24203,7 +24479,7 @@ var init_input = __esm({
|
|
|
24203
24479
|
}
|
|
24204
24480
|
});
|
|
24205
24481
|
var DEFAULT_USER_AVATAR, root, selfInfo, dir, stream2, addWrite, deleteData, addFriend, getFriendList, getFriend, writeAccountToFriendList, main2;
|
|
24206
|
-
var
|
|
24482
|
+
var init_db2 = __esm({
|
|
24207
24483
|
"src/service/sandbox/db.ts"() {
|
|
24208
24484
|
init_root();
|
|
24209
24485
|
DEFAULT_USER_AVATAR = "https://q1.qlogo.cn/g?b=qq&nk=1812868335&s=0";
|
|
@@ -24358,7 +24634,7 @@ var init_avatar = __esm({
|
|
|
24358
24634
|
"src/service/sandbox/avatar.ts"() {
|
|
24359
24635
|
init_root();
|
|
24360
24636
|
init_data();
|
|
24361
|
-
|
|
24637
|
+
init_db2();
|
|
24362
24638
|
}
|
|
24363
24639
|
});
|
|
24364
24640
|
|
|
@@ -24368,7 +24644,7 @@ var init_adapter2 = __esm({
|
|
|
24368
24644
|
init_base();
|
|
24369
24645
|
init_sender();
|
|
24370
24646
|
init_avatar();
|
|
24371
|
-
|
|
24647
|
+
init_db2();
|
|
24372
24648
|
}
|
|
24373
24649
|
});
|
|
24374
24650
|
|
|
@@ -24647,12 +24923,8 @@ var printStartLog = (version2) => {
|
|
|
24647
24923
|
logger.mark("https://github.com/KarinJS/Karin");
|
|
24648
24924
|
};
|
|
24649
24925
|
|
|
24650
|
-
// src/core/db/index.ts
|
|
24651
|
-
init_redis3();
|
|
24652
|
-
init_mock2();
|
|
24653
|
-
init_kv();
|
|
24654
|
-
|
|
24655
24926
|
// src/index.ts
|
|
24927
|
+
init_db();
|
|
24656
24928
|
init_render2();
|
|
24657
24929
|
|
|
24658
24930
|
// src/adapter/onebot/api/api.ts
|
|
@@ -24679,7 +24951,7 @@ var onebotPostRouter = async (req, res) => {
|
|
|
24679
24951
|
var router2 = Router();
|
|
24680
24952
|
router2.use(express2.json());
|
|
24681
24953
|
router2.post("/", onebotPostRouter);
|
|
24682
|
-
|
|
24954
|
+
app4.use("/onebot", router2);
|
|
24683
24955
|
|
|
24684
24956
|
// src/adapter/onebot/index.ts
|
|
24685
24957
|
init_internal();
|
|
@@ -25835,4 +26107,4 @@ var start2 = async () => {
|
|
|
25835
26107
|
(*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
25836
26108
|
*/
|
|
25837
26109
|
|
|
25838
|
-
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,
|
|
26110
|
+
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 };
|