@chatbi-v/cli 3.1.1 → 3.1.3
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/dist/index.js +976 -649
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -27,7 +27,7 @@ var init_package = __esm({
|
|
|
27
27
|
"package.json"() {
|
|
28
28
|
package_default = {
|
|
29
29
|
name: "@chatbi-v/cli",
|
|
30
|
-
version: "3.1.
|
|
30
|
+
version: "3.1.3",
|
|
31
31
|
description: "Standardized CLI tooling for ChatBI Monorepo",
|
|
32
32
|
type: "module",
|
|
33
33
|
main: "dist/index.js",
|
|
@@ -56,7 +56,8 @@ var init_package = __esm({
|
|
|
56
56
|
dev: "tsup --watch",
|
|
57
57
|
test: "vitest run tests/**/*.test.ts --exclude tests/e2e/**",
|
|
58
58
|
"test:e2e": "pnpm build && vitest run tests/e2e/plugin-create.e2e.test.ts tests/e2e/sandbox-isolation.e2e.test.ts",
|
|
59
|
-
"test:all": "pnpm test && pnpm test:e2e"
|
|
59
|
+
"test:all": "pnpm test && pnpm test:e2e",
|
|
60
|
+
prepublishOnly: "pnpm build"
|
|
60
61
|
},
|
|
61
62
|
dependencies: {
|
|
62
63
|
"@chatbi-v/config": "workspace:*",
|
|
@@ -290,7 +291,7 @@ import ora from "ora";
|
|
|
290
291
|
import path3 from "path";
|
|
291
292
|
import pc from "picocolors";
|
|
292
293
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
293
|
-
var _require, _filename, _dirname, config, UPDATE_CHECK_INTERVAL, CACHE_DIR, CACHE_FILE, isDebug, setDebugMode,
|
|
294
|
+
var _require, _filename, _dirname, config, UPDATE_CHECK_INTERVAL, CACHE_DIR, CACHE_FILE, isDebug, setDebugMode, logger2, createSpinner, printBox, findPackageRoot, getCliRoot, checkForUpdates, printUpdateNotification;
|
|
294
295
|
var init_utils = __esm({
|
|
295
296
|
"src/utils.ts"() {
|
|
296
297
|
"use strict";
|
|
@@ -307,7 +308,7 @@ var init_utils = __esm({
|
|
|
307
308
|
setDebugMode = (debug) => {
|
|
308
309
|
isDebug = debug;
|
|
309
310
|
};
|
|
310
|
-
|
|
311
|
+
logger2 = {
|
|
311
312
|
info: (msg) => console.log(pc.cyan(`\u2139 ${msg}`)),
|
|
312
313
|
success: (msg) => console.log(pc.green(`\u2714 ${msg}`)),
|
|
313
314
|
warn: (msg) => console.log(pc.yellow(`\u26A0 ${msg}`)),
|
|
@@ -366,15 +367,18 @@ var init_utils = __esm({
|
|
|
366
367
|
getCliRoot = async () => {
|
|
367
368
|
let myCliRoot = "";
|
|
368
369
|
let checkDir = _dirname;
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
370
|
+
try {
|
|
371
|
+
while (checkDir !== path3.parse(checkDir).root) {
|
|
372
|
+
if (fs.existsSync(path3.join(checkDir, "package.json"))) {
|
|
373
|
+
const pkg = await fs.readJson(path3.join(checkDir, "package.json"));
|
|
374
|
+
if (pkg.name === "@chatbi-v/cli") {
|
|
375
|
+
myCliRoot = checkDir;
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
375
378
|
}
|
|
379
|
+
checkDir = path3.dirname(checkDir);
|
|
376
380
|
}
|
|
377
|
-
|
|
381
|
+
} catch {
|
|
378
382
|
}
|
|
379
383
|
if (!myCliRoot) {
|
|
380
384
|
myCliRoot = findPackageRoot("@chatbi-v/cli") || "";
|
|
@@ -385,15 +389,18 @@ var init_utils = __esm({
|
|
|
385
389
|
try {
|
|
386
390
|
await fs.ensureDir(CACHE_DIR);
|
|
387
391
|
let cache = { lastCheck: 0, latestVersion: currentVersion };
|
|
388
|
-
|
|
392
|
+
try {
|
|
389
393
|
cache = await fs.readJson(CACHE_FILE);
|
|
394
|
+
} catch {
|
|
390
395
|
}
|
|
391
396
|
const now = Date.now();
|
|
392
397
|
if (now - cache.lastCheck > UPDATE_CHECK_INTERVAL) {
|
|
393
|
-
const subprocess = execa("npm", ["view", "@chatbi-v/cli", "version"]
|
|
398
|
+
const subprocess = execa("npm", ["view", "@chatbi-v/cli", "version"], {
|
|
399
|
+
reject: false
|
|
400
|
+
});
|
|
394
401
|
subprocess.unref();
|
|
395
402
|
subprocess.then(async ({ stdout }) => {
|
|
396
|
-
const latest = stdout
|
|
403
|
+
const latest = stdout?.trim() || "";
|
|
397
404
|
await fs.writeJson(CACHE_FILE, {
|
|
398
405
|
lastCheck: now,
|
|
399
406
|
latestVersion: latest
|
|
@@ -486,38 +493,35 @@ var init_config2 = __esm({
|
|
|
486
493
|
*/
|
|
487
494
|
static async loadConfig(cwd = process.cwd()) {
|
|
488
495
|
if (!fs2.existsSync(cwd)) {
|
|
489
|
-
|
|
496
|
+
logger2.warn(`\u9879\u76EE\u76EE\u5F55\u4E0D\u5B58\u5728: ${cwd}\uFF0C\u4F7F\u7528\u9ED8\u8BA4\u914D\u7F6E`);
|
|
490
497
|
return {};
|
|
491
498
|
}
|
|
492
499
|
const config4 = {};
|
|
493
500
|
const versionFilePath = path4.join(cwd, SANDBOX_CONFIG.LOCK_FILE);
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
config4.coreVersion = version;
|
|
499
|
-
}
|
|
500
|
-
} catch {
|
|
501
|
+
try {
|
|
502
|
+
const version = (await fs2.readFile(versionFilePath, "utf-8")).trim();
|
|
503
|
+
if (version) {
|
|
504
|
+
config4.coreVersion = version;
|
|
501
505
|
}
|
|
506
|
+
} catch (e) {
|
|
507
|
+
logger2.debug(`\u8BFB\u53D6 .chatbi-version \u5931\u8D25: ${e.message}`);
|
|
502
508
|
}
|
|
503
509
|
const jiti = createJiti(cwd);
|
|
504
510
|
let projectConfig = {};
|
|
505
511
|
for (const file of this.CONFIG_FILES) {
|
|
506
512
|
const configPath = path4.join(cwd, file);
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
projectConfig = await fs2.readJson(configPath);
|
|
516
|
-
}
|
|
517
|
-
break;
|
|
518
|
-
} catch {
|
|
519
|
-
logger.error(`\u8BFB\u53D6\u914D\u7F6E\u6587\u4EF6 ${file} \u5931\u8D25`);
|
|
513
|
+
try {
|
|
514
|
+
if (file.endsWith(".ts") || file.endsWith(".js")) {
|
|
515
|
+
const mod = await jiti.import(configPath, {
|
|
516
|
+
default: true
|
|
517
|
+
});
|
|
518
|
+
projectConfig = mod.default || mod || {};
|
|
519
|
+
} else if (file.endsWith(".json") || file.startsWith(".chatbirc")) {
|
|
520
|
+
projectConfig = await fs2.readJson(configPath);
|
|
520
521
|
}
|
|
522
|
+
break;
|
|
523
|
+
} catch (e) {
|
|
524
|
+
logger2.error(`\u8BFB\u53D6\u914D\u7F6E\u6587\u4EF6 ${file} \u5931\u8D25: ${e.message}`);
|
|
521
525
|
}
|
|
522
526
|
}
|
|
523
527
|
const envConfig = {};
|
|
@@ -571,30 +575,27 @@ var init_config2 = __esm({
|
|
|
571
575
|
const jiti = createJiti(cwd);
|
|
572
576
|
for (const file of TSUP_CONFIG_FILES) {
|
|
573
577
|
const configPath = path4.join(cwd, file);
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
return mod.default || mod || {};
|
|
583
|
-
}
|
|
584
|
-
} catch (e) {
|
|
585
|
-
logger.warn(`\u52A0\u8F7D tsup \u914D\u7F6E\u6587\u4EF6 ${file} \u5931\u8D25: ${e.message}`);
|
|
578
|
+
try {
|
|
579
|
+
if (file.endsWith(".json")) {
|
|
580
|
+
return await fs2.readJson(configPath);
|
|
581
|
+
} else {
|
|
582
|
+
const mod = await jiti.import(configPath, {
|
|
583
|
+
default: true
|
|
584
|
+
});
|
|
585
|
+
return mod.default || mod || {};
|
|
586
586
|
}
|
|
587
|
+
} catch (e) {
|
|
588
|
+
logger2.warn(`\u52A0\u8F7D tsup \u914D\u7F6E\u6587\u4EF6 ${file} \u5931\u8D25: ${e.message}`);
|
|
587
589
|
}
|
|
588
590
|
}
|
|
589
591
|
const pkgPath = path4.join(cwd, "package.json");
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
return pkg.tsup;
|
|
595
|
-
}
|
|
596
|
-
} catch {
|
|
592
|
+
try {
|
|
593
|
+
const pkg = await fs2.readJson(pkgPath);
|
|
594
|
+
if (pkg.tsup) {
|
|
595
|
+
return pkg.tsup;
|
|
597
596
|
}
|
|
597
|
+
} catch (e) {
|
|
598
|
+
logger2.debug(`\u8BFB\u53D6 package.json \u5931\u8D25: ${e.message}`);
|
|
598
599
|
}
|
|
599
600
|
return {};
|
|
600
601
|
}
|
|
@@ -612,6 +613,7 @@ var init_CacheValidator = __esm({
|
|
|
612
613
|
"src/sandbox/CacheValidator.ts"() {
|
|
613
614
|
"use strict";
|
|
614
615
|
init_esm_shims();
|
|
616
|
+
init_utils();
|
|
615
617
|
MANIFEST_FILE = ".sandbox-manifest.json";
|
|
616
618
|
CacheValidator = class {
|
|
617
619
|
constructor(versionPath) {
|
|
@@ -638,7 +640,8 @@ var init_CacheValidator = __esm({
|
|
|
638
640
|
try {
|
|
639
641
|
const content = await fs3.readFile(filePath);
|
|
640
642
|
return `sha256:${crypto.createHash("sha256").update(content).digest("hex")}`;
|
|
641
|
-
} catch {
|
|
643
|
+
} catch (e) {
|
|
644
|
+
logger2.debug(`\u8BA1\u7B97\u6587\u4EF6 Hash \u5931\u8D25: ${e.message}`);
|
|
642
645
|
return "";
|
|
643
646
|
}
|
|
644
647
|
}
|
|
@@ -649,25 +652,26 @@ var init_CacheValidator = __esm({
|
|
|
649
652
|
const packages = {};
|
|
650
653
|
try {
|
|
651
654
|
const nodeModulesPath = this.getNodeModulesPath();
|
|
652
|
-
|
|
655
|
+
let entries;
|
|
656
|
+
try {
|
|
657
|
+
entries = await fs3.readdir(nodeModulesPath, {
|
|
658
|
+
withFileTypes: true
|
|
659
|
+
});
|
|
660
|
+
} catch {
|
|
653
661
|
return "";
|
|
654
662
|
}
|
|
655
|
-
const entries = await fs3.readdir(nodeModulesPath, {
|
|
656
|
-
withFileTypes: true
|
|
657
|
-
});
|
|
658
663
|
for (const entry of entries) {
|
|
659
664
|
if (entry.isDirectory() && !entry.name.startsWith(".")) {
|
|
660
|
-
const
|
|
665
|
+
const pkgJsonPath2 = path5.join(
|
|
661
666
|
nodeModulesPath,
|
|
662
667
|
entry.name,
|
|
663
668
|
"package.json"
|
|
664
669
|
);
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
}
|
|
670
|
+
try {
|
|
671
|
+
const pkg = await fs3.readJson(pkgJsonPath2);
|
|
672
|
+
packages[entry.name] = `${pkg.name}@${pkg.version}`;
|
|
673
|
+
} catch {
|
|
674
|
+
logger2.debug(`\u5FFD\u7565\u65E0\u6548 package.json: ${pkgJsonPath2}`);
|
|
671
675
|
}
|
|
672
676
|
}
|
|
673
677
|
}
|
|
@@ -682,19 +686,30 @@ var init_CacheValidator = __esm({
|
|
|
682
686
|
*/
|
|
683
687
|
async generatePackageIntegrity(pkgPath) {
|
|
684
688
|
try {
|
|
685
|
-
const
|
|
686
|
-
|
|
687
|
-
const content = await fs3.readFile(
|
|
689
|
+
const pkgJsonPath2 = path5.join(pkgPath, "package.json");
|
|
690
|
+
try {
|
|
691
|
+
const content = await fs3.readFile(pkgJsonPath2);
|
|
688
692
|
return `sha256:${crypto.createHash("sha256").update(content).digest("hex")}`;
|
|
693
|
+
} catch {
|
|
694
|
+
logger2.debug(`package.json \u4E0D\u5B58\u5728\uFF0C\u4F7F\u7528\u76EE\u5F55\u5185\u5BB9: ${pkgPath}`);
|
|
695
|
+
}
|
|
696
|
+
let files;
|
|
697
|
+
try {
|
|
698
|
+
files = await fs3.readdir(pkgPath);
|
|
699
|
+
} catch {
|
|
700
|
+
return "";
|
|
689
701
|
}
|
|
690
|
-
const files = await fs3.readdir(pkgPath);
|
|
691
702
|
const combinedHash = crypto.createHash("sha256");
|
|
692
703
|
for (const file of files.slice(0, 10)) {
|
|
693
704
|
const filePath = path5.join(pkgPath, file);
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
705
|
+
try {
|
|
706
|
+
const stats = await fs3.stat(filePath);
|
|
707
|
+
if (stats.isFile()) {
|
|
708
|
+
const content = await fs3.readFile(filePath);
|
|
709
|
+
combinedHash.update(content);
|
|
710
|
+
}
|
|
711
|
+
} catch (e) {
|
|
712
|
+
logger2.debug(`\u5904\u7406\u6587\u4EF6\u5931\u8D25: ${file}: ${e.message}`);
|
|
698
713
|
}
|
|
699
714
|
}
|
|
700
715
|
return `sha256:${combinedHash.digest("hex")}`;
|
|
@@ -710,13 +725,11 @@ var init_CacheValidator = __esm({
|
|
|
710
725
|
return this.manifest;
|
|
711
726
|
}
|
|
712
727
|
const manifestPath = this.getManifestPath();
|
|
713
|
-
if (!fs3.existsSync(manifestPath)) {
|
|
714
|
-
return null;
|
|
715
|
-
}
|
|
716
728
|
try {
|
|
717
729
|
this.manifest = await fs3.readJson(manifestPath);
|
|
718
730
|
return this.manifest;
|
|
719
|
-
} catch {
|
|
731
|
+
} catch (e) {
|
|
732
|
+
logger2.debug(`\u52A0\u8F7D manifest \u5931\u8D25: ${e.message}`);
|
|
720
733
|
return null;
|
|
721
734
|
}
|
|
722
735
|
}
|
|
@@ -887,7 +900,12 @@ var init_CacheValidator = __esm({
|
|
|
887
900
|
const criticalPkgs = Object.keys(manifest.packages);
|
|
888
901
|
for (const pkg of criticalPkgs) {
|
|
889
902
|
const pkgPath = path5.join(this.getNodeModulesPath(), pkg);
|
|
890
|
-
|
|
903
|
+
try {
|
|
904
|
+
const stats = await fs3.stat(pkgPath);
|
|
905
|
+
if (!stats.isDirectory()) {
|
|
906
|
+
return false;
|
|
907
|
+
}
|
|
908
|
+
} catch {
|
|
891
909
|
return false;
|
|
892
910
|
}
|
|
893
911
|
}
|
|
@@ -919,8 +937,10 @@ var init_CacheValidator = __esm({
|
|
|
919
937
|
*/
|
|
920
938
|
async clearManifest() {
|
|
921
939
|
const manifestPath = this.getManifestPath();
|
|
922
|
-
|
|
940
|
+
try {
|
|
923
941
|
await fs3.remove(manifestPath);
|
|
942
|
+
} catch (e) {
|
|
943
|
+
logger2.debug(`\u5220\u9664\u7F13\u5B58\u5931\u8D25: ${e.message}`);
|
|
924
944
|
}
|
|
925
945
|
this.manifest = null;
|
|
926
946
|
}
|
|
@@ -996,13 +1016,15 @@ var init_SandboxPath = __esm({
|
|
|
996
1016
|
while (current !== path6.parse(current).root) {
|
|
997
1017
|
const pkgPath = path6.join(current, "package.json");
|
|
998
1018
|
const pnpmWorkspacePath = path6.join(current, "pnpm-workspace.yaml");
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1019
|
+
try {
|
|
1020
|
+
const content = await fs4.readFile(pnpmWorkspacePath, "utf-8");
|
|
1021
|
+
if (content.includes("packages:")) return current;
|
|
1022
|
+
} catch {
|
|
1023
|
+
}
|
|
1024
|
+
try {
|
|
1025
|
+
const pkg = await fs4.readJson(pkgPath);
|
|
1026
|
+
if (pkg.workspaces) return current;
|
|
1027
|
+
} catch {
|
|
1006
1028
|
}
|
|
1007
1029
|
current = path6.dirname(current);
|
|
1008
1030
|
}
|
|
@@ -1161,12 +1183,12 @@ var init_SandboxPlatform = __esm({
|
|
|
1161
1183
|
let result = await attemptStrategy(strategy);
|
|
1162
1184
|
if (!result.success && strategy !== "copy") {
|
|
1163
1185
|
if (verbose) {
|
|
1164
|
-
|
|
1186
|
+
logger2.warn(`[SandboxPlatform] ${strategy} \u7B56\u7565\u5931\u8D25: ${result.error}`);
|
|
1165
1187
|
}
|
|
1166
1188
|
if (strategy === "symlink" && caps.supportsJunctions && type === "dir") {
|
|
1167
1189
|
result = await attemptStrategy("junction");
|
|
1168
1190
|
if (!result.success && verbose) {
|
|
1169
|
-
|
|
1191
|
+
logger2.warn(`[SandboxPlatform] junction \u7B56\u7565\u4E5F\u5931\u8D25: ${result.error}`);
|
|
1170
1192
|
}
|
|
1171
1193
|
}
|
|
1172
1194
|
if (!result.success) {
|
|
@@ -1174,14 +1196,14 @@ var init_SandboxPlatform = __esm({
|
|
|
1174
1196
|
}
|
|
1175
1197
|
}
|
|
1176
1198
|
if (verbose && !result.success) {
|
|
1177
|
-
|
|
1199
|
+
logger2.error(
|
|
1178
1200
|
`[SandboxPlatform] \u65E0\u6CD5\u521B\u5EFA\u865A\u62DF node_modules: ${result.error}`
|
|
1179
1201
|
);
|
|
1180
1202
|
if (result.suggestion) {
|
|
1181
|
-
|
|
1203
|
+
logger2.info(` \u89E3\u51B3\u65B9\u6848: ${result.suggestion}`);
|
|
1182
1204
|
}
|
|
1183
1205
|
} else if (verbose && result.success && result.suggestion) {
|
|
1184
|
-
|
|
1206
|
+
logger2.warn(`[SandboxPlatform] ${result.suggestion}`);
|
|
1185
1207
|
}
|
|
1186
1208
|
return result;
|
|
1187
1209
|
}
|
|
@@ -1261,6 +1283,7 @@ var init_SandboxContext = __esm({
|
|
|
1261
1283
|
"use strict";
|
|
1262
1284
|
init_esm_shims();
|
|
1263
1285
|
init_constants();
|
|
1286
|
+
init_utils();
|
|
1264
1287
|
init_SandboxPath();
|
|
1265
1288
|
init_SandboxPlatform();
|
|
1266
1289
|
SandboxContext = class {
|
|
@@ -1284,8 +1307,10 @@ var init_SandboxContext = __esm({
|
|
|
1284
1307
|
await fs6.ensureDir(chatbiDir);
|
|
1285
1308
|
if (projectRoot !== targetRoot) {
|
|
1286
1309
|
const localChatbiDir = path8.join(projectRoot, SANDBOX_CONFIG.DIRS.CACHE);
|
|
1287
|
-
|
|
1310
|
+
try {
|
|
1288
1311
|
await fs6.remove(localChatbiDir);
|
|
1312
|
+
} catch (e) {
|
|
1313
|
+
logger2.debug(`\u5220\u9664 .chatbi \u5931\u8D25: ${e.message}`);
|
|
1289
1314
|
}
|
|
1290
1315
|
await this.fixTsConfigExtends(projectRoot, targetRoot);
|
|
1291
1316
|
await this.ensureGitignore(targetRoot);
|
|
@@ -1303,11 +1328,13 @@ var init_SandboxContext = __esm({
|
|
|
1303
1328
|
await fs6.ensureDir(vscodeDir);
|
|
1304
1329
|
const settingsPath = path8.join(vscodeDir, "settings.json");
|
|
1305
1330
|
let settings = {};
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1331
|
+
try {
|
|
1332
|
+
const loaded = await fs6.readJson(settingsPath);
|
|
1333
|
+
if (loaded && typeof loaded === "object") {
|
|
1334
|
+
settings = loaded;
|
|
1310
1335
|
}
|
|
1336
|
+
} catch (e) {
|
|
1337
|
+
logger2.debug(`\u52A0\u8F7D settings.json \u5931\u8D25: ${e.message}`);
|
|
1311
1338
|
}
|
|
1312
1339
|
const sandboxPath = SandboxPath.getVersionPath(version);
|
|
1313
1340
|
const tsdkPath = path8.join(sandboxPath, "node_modules/typescript/lib");
|
|
@@ -1321,30 +1348,33 @@ var init_SandboxContext = __esm({
|
|
|
1321
1348
|
*/
|
|
1322
1349
|
static async fixTsConfigExtends(projectRoot, workspaceRoot) {
|
|
1323
1350
|
const tsConfigPath = path8.join(projectRoot, "tsconfig.json");
|
|
1324
|
-
|
|
1351
|
+
let tsConfig;
|
|
1325
1352
|
try {
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
await fs6.writeJson(tsConfigPath, tsConfig, { spaces: 2 });
|
|
1342
|
-
}
|
|
1343
|
-
} else {
|
|
1344
|
-
tsConfig.extends = extendsTarget;
|
|
1353
|
+
tsConfig = await fs6.readJson(tsConfigPath);
|
|
1354
|
+
} catch (e) {
|
|
1355
|
+
logger2.debug(`\u52A0\u8F7D tsconfig.json \u5931\u8D25: ${e.message}`);
|
|
1356
|
+
return;
|
|
1357
|
+
}
|
|
1358
|
+
if (!tsConfig || typeof tsConfig !== "object") return;
|
|
1359
|
+
let extendsTarget = path8.relative(
|
|
1360
|
+
projectRoot,
|
|
1361
|
+
path8.join(workspaceRoot, ".chatbi/tsconfig.json")
|
|
1362
|
+
);
|
|
1363
|
+
if (!extendsTarget.startsWith(".")) extendsTarget = `./${extendsTarget}`;
|
|
1364
|
+
const hasExtend = (p) => p.includes(".chatbi/tsconfig.json") || p.includes(".chatbi/tsconfig.paths.json");
|
|
1365
|
+
if (Array.isArray(tsConfig.extends)) {
|
|
1366
|
+
if (!tsConfig.extends.some((p) => hasExtend(p))) {
|
|
1367
|
+
tsConfig.extends.push(extendsTarget);
|
|
1345
1368
|
await fs6.writeJson(tsConfigPath, tsConfig, { spaces: 2 });
|
|
1346
1369
|
}
|
|
1347
|
-
}
|
|
1370
|
+
} else if (typeof tsConfig.extends === "string") {
|
|
1371
|
+
if (!hasExtend(tsConfig.extends)) {
|
|
1372
|
+
tsConfig.extends = [tsConfig.extends, extendsTarget];
|
|
1373
|
+
await fs6.writeJson(tsConfigPath, tsConfig, { spaces: 2 });
|
|
1374
|
+
}
|
|
1375
|
+
} else {
|
|
1376
|
+
tsConfig.extends = extendsTarget;
|
|
1377
|
+
await fs6.writeJson(tsConfigPath, tsConfig, { spaces: 2 });
|
|
1348
1378
|
}
|
|
1349
1379
|
}
|
|
1350
1380
|
/**
|
|
@@ -1352,17 +1382,20 @@ var init_SandboxContext = __esm({
|
|
|
1352
1382
|
*/
|
|
1353
1383
|
static async ensureGitignore(root) {
|
|
1354
1384
|
const gitignorePath = path8.join(root, ".gitignore");
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1385
|
+
let content = "";
|
|
1386
|
+
try {
|
|
1387
|
+
content = await fs6.readFile(gitignorePath, "utf-8");
|
|
1388
|
+
} catch (e) {
|
|
1389
|
+
logger2.debug(`\u52A0\u8F7D .gitignore \u5931\u8D25: ${e.message}`);
|
|
1390
|
+
}
|
|
1391
|
+
if (typeof content === "string" && !content.includes(SANDBOX_CONFIG.DIRS.CACHE)) {
|
|
1392
|
+
await fs6.appendFile(
|
|
1393
|
+
gitignorePath,
|
|
1394
|
+
`
|
|
1361
1395
|
# ChatBI
|
|
1362
1396
|
${SANDBOX_CONFIG.DIRS.CACHE}
|
|
1363
1397
|
`
|
|
1364
|
-
|
|
1365
|
-
}
|
|
1398
|
+
);
|
|
1366
1399
|
}
|
|
1367
1400
|
}
|
|
1368
1401
|
/**
|
|
@@ -1394,27 +1427,27 @@ ${SANDBOX_CONFIG.DIRS.CACHE}
|
|
|
1394
1427
|
sandboxNodeModules,
|
|
1395
1428
|
"@chatbi-v/config/base.json"
|
|
1396
1429
|
);
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
// 但这里主要用于沙箱环境的类型解析,"@/*" 的映射可能需要在具体项目的 tsconfig 中覆盖
|
|
1413
|
-
"@/*": ["./src/*"]
|
|
1414
|
-
// "*": ["./node_modules/*"] // 已经在上面添加了 corePaths['*']
|
|
1430
|
+
let tsConfig;
|
|
1431
|
+
try {
|
|
1432
|
+
await fs6.readJson(baseConfigPath);
|
|
1433
|
+
tsConfig = {
|
|
1434
|
+
extends: baseConfigPath,
|
|
1435
|
+
compilerOptions: {
|
|
1436
|
+
baseUrl: ".",
|
|
1437
|
+
moduleResolution: "bundler",
|
|
1438
|
+
skipLibCheck: true,
|
|
1439
|
+
typeRoots: ["./node_modules/@types", "./node_modules"],
|
|
1440
|
+
preserveSymlinks: true,
|
|
1441
|
+
paths: {
|
|
1442
|
+
...corePaths,
|
|
1443
|
+
"@/*": ["./src/*"]
|
|
1444
|
+
}
|
|
1415
1445
|
}
|
|
1416
|
-
}
|
|
1417
|
-
}
|
|
1446
|
+
};
|
|
1447
|
+
} catch (e) {
|
|
1448
|
+
logger2.debug(`base.json \u52A0\u8F7D\u5931\u8D25\uFF0C\u4F7F\u7528\u964D\u7EA7\u914D\u7F6E: ${e.message}`);
|
|
1449
|
+
tsConfig = this.getDefaultTsConfig(corePaths);
|
|
1450
|
+
}
|
|
1418
1451
|
await fs6.writeJson(path8.join(chatbiDir, "tsconfig.json"), tsConfig, {
|
|
1419
1452
|
spaces: 2
|
|
1420
1453
|
});
|
|
@@ -1424,7 +1457,8 @@ ${SANDBOX_CONFIG.DIRS.CACHE}
|
|
|
1424
1457
|
{ spaces: 2 }
|
|
1425
1458
|
);
|
|
1426
1459
|
const virtualNodeModules = path8.join(chatbiDir, "node_modules");
|
|
1427
|
-
|
|
1460
|
+
try {
|
|
1461
|
+
await fs6.access(sandboxNodeModules);
|
|
1428
1462
|
const result = await SandboxPlatform.safeSymlink({
|
|
1429
1463
|
source: sandboxNodeModules,
|
|
1430
1464
|
target: virtualNodeModules,
|
|
@@ -1437,8 +1471,28 @@ ${SANDBOX_CONFIG.DIRS.CACHE}
|
|
|
1437
1471
|
\u5EFA\u8BAE: ${result.suggestion || "\u8FD0\u884C chatbi sandbox update --force \u91CD\u5EFA\u6C99\u7BB1"}`
|
|
1438
1472
|
);
|
|
1439
1473
|
}
|
|
1474
|
+
} catch (e) {
|
|
1475
|
+
logger2.debug(`sandboxNodeModules \u4E0D\u5B58\u5728: ${e.message}`);
|
|
1440
1476
|
}
|
|
1441
1477
|
}
|
|
1478
|
+
/**
|
|
1479
|
+
* Bug-6 Fix: 生成默认 tsconfig 配置(当 base.json 不可用时)
|
|
1480
|
+
*/
|
|
1481
|
+
static getDefaultTsConfig(corePaths) {
|
|
1482
|
+
return {
|
|
1483
|
+
compilerOptions: {
|
|
1484
|
+
baseUrl: ".",
|
|
1485
|
+
moduleResolution: "bundler",
|
|
1486
|
+
skipLibCheck: true,
|
|
1487
|
+
typeRoots: ["./node_modules/@types", "./node_modules"],
|
|
1488
|
+
preserveSymlinks: true,
|
|
1489
|
+
paths: {
|
|
1490
|
+
...corePaths,
|
|
1491
|
+
"@/*": ["./src/*"]
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
};
|
|
1495
|
+
}
|
|
1442
1496
|
};
|
|
1443
1497
|
}
|
|
1444
1498
|
});
|
|
@@ -1470,43 +1524,56 @@ var init_WorkspaceResolver = __esm({
|
|
|
1470
1524
|
reject: false
|
|
1471
1525
|
}
|
|
1472
1526
|
);
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1527
|
+
if (!stdout || typeof stdout !== "string" || stdout.trim() === "") {
|
|
1528
|
+
logger2.warn("pnpm \u89E3\u6790\u8FD4\u56DE\u7A7A\u7ED3\u679C\uFF0C\u5C1D\u8BD5\u964D\u7EA7\u65B9\u6848...");
|
|
1529
|
+
} else {
|
|
1530
|
+
try {
|
|
1531
|
+
const pnpmPackages = JSON.parse(stdout);
|
|
1532
|
+
if (Array.isArray(pnpmPackages)) {
|
|
1533
|
+
for (const pkg of pnpmPackages) {
|
|
1534
|
+
if (pkg.name && pkg.path) {
|
|
1535
|
+
packages[pkg.name] = pkg.path;
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
if (Object.keys(packages).length > 0) {
|
|
1539
|
+
return packages;
|
|
1479
1540
|
}
|
|
1480
1541
|
}
|
|
1481
|
-
|
|
1482
|
-
return packages;
|
|
1483
|
-
}
|
|
1542
|
+
} catch {
|
|
1484
1543
|
}
|
|
1485
|
-
} catch {
|
|
1486
1544
|
}
|
|
1487
1545
|
} catch (e) {
|
|
1488
|
-
|
|
1546
|
+
logger2.warn(`pnpm \u89E3\u6790\u5931\u8D25: ${e.message}\uFF0C\u5C1D\u8BD5\u964D\u7EA7\u65B9\u6848...`);
|
|
1489
1547
|
}
|
|
1548
|
+
let patterns = ["packages/*"];
|
|
1549
|
+
const workspaceYamlPath = path9.join(workspaceRoot, "pnpm-workspace.yaml");
|
|
1550
|
+
let foundWorkspaceYaml = false;
|
|
1490
1551
|
try {
|
|
1491
|
-
const
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
const
|
|
1496
|
-
if (
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1552
|
+
const content = await fs7.readFile(workspaceYamlPath, "utf-8");
|
|
1553
|
+
foundWorkspaceYaml = true;
|
|
1554
|
+
const match = content.match(/packages:\s*([\s\S]*?)(?:\n\S|$)/);
|
|
1555
|
+
if (match && match[1]) {
|
|
1556
|
+
const lines = match[1].split("\n").map((l) => l.trim()).filter((l) => l.startsWith("-")).map((l) => l.replace(/^-\s*['"]?|['"]?$/g, ""));
|
|
1557
|
+
if (lines.length > 0) patterns = lines;
|
|
1558
|
+
}
|
|
1559
|
+
} catch (e) {
|
|
1560
|
+
logger2.debug(`\u8BFB\u53D6 workspace.yaml \u5931\u8D25: ${e.message}`);
|
|
1561
|
+
}
|
|
1562
|
+
if (!foundWorkspaceYaml) {
|
|
1563
|
+
const pkgJsonPath2 = path9.join(workspaceRoot, "package.json");
|
|
1564
|
+
try {
|
|
1565
|
+
const pkg = await fs7.readJson(pkgJsonPath2);
|
|
1566
|
+
if (Array.isArray(pkg.workspaces)) {
|
|
1567
|
+
patterns = pkg.workspaces;
|
|
1507
1568
|
}
|
|
1569
|
+
} catch (e) {
|
|
1570
|
+
logger2.debug(
|
|
1571
|
+
`\u8BFB\u53D6 package.json \u5931\u8D25: ${pkgJsonPath2}: ${e.message}`
|
|
1572
|
+
);
|
|
1508
1573
|
}
|
|
1509
|
-
|
|
1574
|
+
}
|
|
1575
|
+
const globPatterns = patterns.map((p) => path9.join(p, "package.json"));
|
|
1576
|
+
try {
|
|
1510
1577
|
const { default: fg3 } = await import("fast-glob");
|
|
1511
1578
|
const pkgJsonFiles = await fg3(globPatterns, {
|
|
1512
1579
|
cwd: workspaceRoot,
|
|
@@ -1519,11 +1586,12 @@ var init_WorkspaceResolver = __esm({
|
|
|
1519
1586
|
if (pkg.name) {
|
|
1520
1587
|
packages[pkg.name] = path9.dirname(file);
|
|
1521
1588
|
}
|
|
1522
|
-
} catch {
|
|
1589
|
+
} catch (e) {
|
|
1590
|
+
logger2.debug(`\u626B\u63CF\u5305\u5931\u8D25: ${file}: ${e.message}`);
|
|
1523
1591
|
}
|
|
1524
1592
|
}
|
|
1525
1593
|
} catch (e) {
|
|
1526
|
-
|
|
1594
|
+
logger2.warn(`\u5DE5\u4F5C\u533A\u626B\u63CF\u5931\u8D25: ${e.message}`);
|
|
1527
1595
|
}
|
|
1528
1596
|
return packages;
|
|
1529
1597
|
}
|
|
@@ -1582,12 +1650,31 @@ var init_SandboxPkgManager = __esm({
|
|
|
1582
1650
|
try {
|
|
1583
1651
|
const stats = await fs8.lstat(targetLinkPath).catch(() => null);
|
|
1584
1652
|
if (stats) await fs8.remove(targetLinkPath);
|
|
1585
|
-
} catch {
|
|
1653
|
+
} catch (e) {
|
|
1654
|
+
logger2.debug(
|
|
1655
|
+
`\u521B\u5EFA\u8F6F\u94FE\u63A5\u5931\u8D25: ${targetLinkPath}: ${e.message}`
|
|
1656
|
+
);
|
|
1657
|
+
}
|
|
1658
|
+
try {
|
|
1659
|
+
await fs8.symlink(pkgPath, targetLinkPath, "dir");
|
|
1660
|
+
} catch (e) {
|
|
1661
|
+
console.warn(
|
|
1662
|
+
pc4.yellow(
|
|
1663
|
+
` \u26A0\uFE0F \u521B\u5EFA\u8F6F\u94FE\u63A5\u5931\u8D25: ${targetLinkPath} -> ${pkgPath}: ${e.message}`
|
|
1664
|
+
)
|
|
1665
|
+
);
|
|
1586
1666
|
}
|
|
1587
|
-
await fs8.symlink(pkgPath, targetLinkPath, "dir");
|
|
1588
1667
|
}
|
|
1589
1668
|
const sandboxPkgJsonPath = path10.join(versionPath, "package.json");
|
|
1590
|
-
|
|
1669
|
+
let sandboxPkgJson;
|
|
1670
|
+
try {
|
|
1671
|
+
sandboxPkgJson = await fs8.readJson(sandboxPkgJsonPath);
|
|
1672
|
+
} catch (e) {
|
|
1673
|
+
console.warn(
|
|
1674
|
+
pc4.yellow(` \u26A0\uFE0F \u8BFB\u53D6\u6C99\u7BB1 package.json \u5931\u8D25: ${e.message}`)
|
|
1675
|
+
);
|
|
1676
|
+
return false;
|
|
1677
|
+
}
|
|
1591
1678
|
const sections = ["dependencies", "devDependencies"];
|
|
1592
1679
|
let modified = false;
|
|
1593
1680
|
for (const section of sections) {
|
|
@@ -1609,26 +1696,28 @@ var init_SandboxPkgManager = __esm({
|
|
|
1609
1696
|
await fs8.writeJson(sandboxPkgJsonPath, sandboxPkgJson, { spaces: 2 });
|
|
1610
1697
|
}
|
|
1611
1698
|
const shellPkgJsonPath = path10.join(versionPath, "shell", "package.json");
|
|
1612
|
-
|
|
1613
|
-
const
|
|
1699
|
+
try {
|
|
1700
|
+
const shellPkgJson2 = await fs8.readJson(shellPkgJsonPath);
|
|
1614
1701
|
let shellModified = false;
|
|
1615
1702
|
const allPackagesToLink = { ...localPackages };
|
|
1616
1703
|
if (allLocalPackages["@chatbi-v/cli"]) {
|
|
1617
1704
|
allPackagesToLink["@chatbi-v/cli"] = allLocalPackages["@chatbi-v/cli"];
|
|
1618
1705
|
}
|
|
1619
1706
|
for (const section of sections) {
|
|
1620
|
-
if (
|
|
1707
|
+
if (shellPkgJson2[section]) {
|
|
1621
1708
|
for (const [name, pkgPath] of Object.entries(allPackagesToLink)) {
|
|
1622
|
-
if (
|
|
1623
|
-
|
|
1709
|
+
if (shellPkgJson2[section][name]) {
|
|
1710
|
+
shellPkgJson2[section][name] = `link:${pkgPath}`;
|
|
1624
1711
|
shellModified = true;
|
|
1625
1712
|
}
|
|
1626
1713
|
}
|
|
1627
1714
|
}
|
|
1628
1715
|
}
|
|
1629
1716
|
if (shellModified) {
|
|
1630
|
-
await fs8.writeJson(shellPkgJsonPath,
|
|
1717
|
+
await fs8.writeJson(shellPkgJsonPath, shellPkgJson2, { spaces: 2 });
|
|
1631
1718
|
}
|
|
1719
|
+
} catch {
|
|
1720
|
+
logger2.debug(`shell package.json \u4E0D\u5B58\u5728: ${shellPkgJson}`);
|
|
1632
1721
|
}
|
|
1633
1722
|
return true;
|
|
1634
1723
|
} catch (e) {
|
|
@@ -1762,11 +1851,12 @@ var init_SandboxRenderer = __esm({
|
|
|
1762
1851
|
}
|
|
1763
1852
|
}
|
|
1764
1853
|
}
|
|
1765
|
-
|
|
1854
|
+
try {
|
|
1766
1855
|
const existingContent = await fs9.readFile(destPath, "utf-8");
|
|
1767
1856
|
if (existingContent === outputContent) {
|
|
1768
1857
|
return;
|
|
1769
1858
|
}
|
|
1859
|
+
} catch {
|
|
1770
1860
|
}
|
|
1771
1861
|
await fs9.outputFile(destPath, outputContent);
|
|
1772
1862
|
}
|
|
@@ -1818,8 +1908,10 @@ var init_sandbox = __esm({
|
|
|
1818
1908
|
/** 清理指定版本的沙箱物理文件 */
|
|
1819
1909
|
static async cleanVersion(version) {
|
|
1820
1910
|
const versionPath = this.getVersionPath(version);
|
|
1821
|
-
|
|
1911
|
+
try {
|
|
1822
1912
|
await fs10.remove(versionPath);
|
|
1913
|
+
} catch (e) {
|
|
1914
|
+
logger2.debug(`\u6E05\u7406\u7248\u672C\u76EE\u5F55\u5931\u8D25: ${e.message}`);
|
|
1823
1915
|
}
|
|
1824
1916
|
}
|
|
1825
1917
|
/**
|
|
@@ -1868,23 +1960,24 @@ var init_sandbox = __esm({
|
|
|
1868
1960
|
for (const dir of distDirs) {
|
|
1869
1961
|
const stats = await fs10.lstat(dir).catch(() => null);
|
|
1870
1962
|
if (stats) {
|
|
1871
|
-
|
|
1872
|
-
path12.join(path12.dirname(dir), "package.json")
|
|
1873
|
-
);
|
|
1874
|
-
if (hasPkg) {
|
|
1963
|
+
try {
|
|
1964
|
+
await fs10.access(path12.join(path12.dirname(dir), "package.json"));
|
|
1875
1965
|
targetDirs.push(dir);
|
|
1966
|
+
} catch {
|
|
1876
1967
|
}
|
|
1877
1968
|
}
|
|
1878
1969
|
}
|
|
1879
1970
|
const globalRoot = this.getRoot();
|
|
1880
|
-
|
|
1971
|
+
try {
|
|
1972
|
+
await fs10.access(globalRoot);
|
|
1881
1973
|
targetDirs.push(globalRoot);
|
|
1974
|
+
} catch {
|
|
1882
1975
|
}
|
|
1883
1976
|
}
|
|
1884
1977
|
if (dryRun) {
|
|
1885
1978
|
spinner.stop();
|
|
1886
1979
|
if (targetDirs.length === 0) {
|
|
1887
|
-
|
|
1980
|
+
logger2.info(pc5.green("\u2728 \u6CA1\u6709\u53D1\u73B0\u9700\u8981\u6E05\u7406\u7684\u7F13\u5B58\u76EE\u5F55"));
|
|
1888
1981
|
} else {
|
|
1889
1982
|
printBox(
|
|
1890
1983
|
`${pc5.yellow("\u5373\u5C06\u6E05\u7406\u4EE5\u4E0B\u76EE\u5F55\uFF1A")}
|
|
@@ -1919,8 +2012,10 @@ var init_sandbox = __esm({
|
|
|
1919
2012
|
return versionPath;
|
|
1920
2013
|
}
|
|
1921
2014
|
}
|
|
1922
|
-
|
|
2015
|
+
try {
|
|
1923
2016
|
await fs10.remove(path12.join(versionPath, "node_modules"));
|
|
2017
|
+
} catch (e) {
|
|
2018
|
+
logger2.debug(`\u5220\u9664 node_modules \u5931\u8D25: ${e.message}`);
|
|
1924
2019
|
}
|
|
1925
2020
|
await fs10.ensureDir(versionPath);
|
|
1926
2021
|
const spinner = createSpinner(
|
|
@@ -1962,7 +2057,7 @@ var init_sandbox = __esm({
|
|
|
1962
2057
|
spinner.warn(
|
|
1963
2058
|
pc5.yellow(`\u6C99\u7BB1\u521D\u59CB\u5316\u53D1\u751F\u7F51\u7EDC/\u7248\u672C\u9519\u8BEF (\u6D4B\u8BD5\u73AF\u5883\u5DF2\u5FFD\u7565)`)
|
|
1964
2059
|
);
|
|
1965
|
-
|
|
2060
|
+
logger2.warn(`\u5FFD\u7565\u7684\u5B89\u88C5\u9519\u8BEF: ${installErr.message.split("\n")[0]}`);
|
|
1966
2061
|
} else {
|
|
1967
2062
|
throw installErr;
|
|
1968
2063
|
}
|
|
@@ -1982,37 +2077,51 @@ var init_sandbox = __esm({
|
|
|
1982
2077
|
static async ensureShell(version, force = false) {
|
|
1983
2078
|
const versionPath = this.getVersionPath(version);
|
|
1984
2079
|
const shellDestDir = path12.join(versionPath, "shell");
|
|
1985
|
-
if (!force
|
|
1986
|
-
|
|
2080
|
+
if (!force) {
|
|
2081
|
+
try {
|
|
2082
|
+
await fs10.access(path12.join(shellDestDir, "tsconfig.paths.json"));
|
|
2083
|
+
return shellDestDir;
|
|
2084
|
+
} catch (e) {
|
|
2085
|
+
logger2.debug(`globalRoot \u68C0\u67E5: ${e.message}`);
|
|
2086
|
+
}
|
|
1987
2087
|
}
|
|
1988
2088
|
const cliRoot = await getCliRoot();
|
|
1989
|
-
|
|
1990
|
-
|
|
2089
|
+
let cliVersion = "0.0.0";
|
|
2090
|
+
try {
|
|
2091
|
+
const cliPkg = await fs10.readJson(path12.join(cliRoot, "package.json"));
|
|
2092
|
+
cliVersion = cliPkg.version;
|
|
2093
|
+
} catch {
|
|
2094
|
+
logger2.warn(`\u65E0\u6CD5\u8BFB\u53D6 CLI \u7248\u672C\uFF0C\u4F7F\u7528\u9ED8\u8BA4\u503C: ${cliVersion}`);
|
|
2095
|
+
}
|
|
1991
2096
|
const shellTemplateDir = path12.join(cliRoot, "templates/app");
|
|
1992
|
-
|
|
1993
|
-
await fs10.
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
cliVersion,
|
|
1998
|
-
theme: DEFAULT_CONFIG.THEME,
|
|
1999
|
-
isShell: true,
|
|
2000
|
-
isBusiness: true,
|
|
2001
|
-
tsconfigPath: "./tsconfig.paths.json"
|
|
2002
|
-
};
|
|
2003
|
-
await SandboxRenderer.renderDirectory(
|
|
2004
|
-
shellTemplateDir,
|
|
2005
|
-
shellDestDir,
|
|
2006
|
-
templateData
|
|
2007
|
-
);
|
|
2008
|
-
await fs10.writeJson(
|
|
2009
|
-
path12.join(shellDestDir, "tsconfig.paths.json"),
|
|
2010
|
-
{
|
|
2011
|
-
compilerOptions: { baseUrl: ".", paths: { "@/*": ["./src/*"] } }
|
|
2012
|
-
},
|
|
2013
|
-
{ spaces: 2 }
|
|
2014
|
-
);
|
|
2097
|
+
try {
|
|
2098
|
+
await fs10.access(shellTemplateDir);
|
|
2099
|
+
} catch {
|
|
2100
|
+
logger2.warn(`Shell \u6A21\u677F\u76EE\u5F55\u4E0D\u5B58\u5728: ${shellTemplateDir}`);
|
|
2101
|
+
return shellDestDir;
|
|
2015
2102
|
}
|
|
2103
|
+
await fs10.remove(shellDestDir);
|
|
2104
|
+
const templateData = {
|
|
2105
|
+
name: "chatbi-shell",
|
|
2106
|
+
version,
|
|
2107
|
+
cliVersion,
|
|
2108
|
+
theme: DEFAULT_CONFIG.THEME,
|
|
2109
|
+
isShell: true,
|
|
2110
|
+
isBusiness: true,
|
|
2111
|
+
tsconfigPath: "./tsconfig.paths.json"
|
|
2112
|
+
};
|
|
2113
|
+
await SandboxRenderer.renderDirectory(
|
|
2114
|
+
shellTemplateDir,
|
|
2115
|
+
shellDestDir,
|
|
2116
|
+
templateData
|
|
2117
|
+
);
|
|
2118
|
+
await fs10.writeJson(
|
|
2119
|
+
path12.join(shellDestDir, "tsconfig.paths.json"),
|
|
2120
|
+
{
|
|
2121
|
+
compilerOptions: { baseUrl: ".", paths: { "@/*": ["./src/*"] } }
|
|
2122
|
+
},
|
|
2123
|
+
{ spaces: 2 }
|
|
2124
|
+
);
|
|
2016
2125
|
return shellDestDir;
|
|
2017
2126
|
}
|
|
2018
2127
|
/** 注入项目虚拟上下文 */
|
|
@@ -2032,7 +2141,14 @@ var init_sandbox = __esm({
|
|
|
2032
2141
|
this.CORE_PACKAGES.map((pkg) => {
|
|
2033
2142
|
const packageRoot = path12.join(sandboxNodeModules, pkg);
|
|
2034
2143
|
const sourceRoot = path12.join(packageRoot, "src");
|
|
2035
|
-
|
|
2144
|
+
try {
|
|
2145
|
+
const stats = fs10.statSync(sourceRoot);
|
|
2146
|
+
if (stats.isDirectory()) {
|
|
2147
|
+
return [pkg, sourceRoot];
|
|
2148
|
+
}
|
|
2149
|
+
} catch {
|
|
2150
|
+
}
|
|
2151
|
+
return [pkg, packageRoot];
|
|
2036
2152
|
})
|
|
2037
2153
|
);
|
|
2038
2154
|
}
|
|
@@ -2041,8 +2157,15 @@ var init_sandbox = __esm({
|
|
|
2041
2157
|
const versionRoot = this.getVersionRoot();
|
|
2042
2158
|
const currentLink = path12.join(versionRoot, SANDBOX_CONFIG.DIRS.CURRENT);
|
|
2043
2159
|
const targetPath = this.getVersionPath(version);
|
|
2044
|
-
|
|
2045
|
-
|
|
2160
|
+
try {
|
|
2161
|
+
await fs10.access(targetPath);
|
|
2162
|
+
} catch {
|
|
2163
|
+
throw new Error(`\u7248\u672C ${version} \u4E0D\u5B58\u5728`);
|
|
2164
|
+
}
|
|
2165
|
+
try {
|
|
2166
|
+
await fs10.remove(currentLink);
|
|
2167
|
+
} catch {
|
|
2168
|
+
}
|
|
2046
2169
|
await fs10.ensureSymlink(targetPath, currentLink, "dir");
|
|
2047
2170
|
}
|
|
2048
2171
|
/** 解析版本号 */
|
|
@@ -2052,8 +2175,10 @@ var init_sandbox = __esm({
|
|
|
2052
2175
|
this.getVersionRoot(),
|
|
2053
2176
|
SANDBOX_CONFIG.DIRS.CURRENT
|
|
2054
2177
|
);
|
|
2055
|
-
|
|
2056
|
-
|
|
2178
|
+
try {
|
|
2179
|
+
const realPath = await fs10.readlink(currentLink);
|
|
2180
|
+
return path12.basename(realPath);
|
|
2181
|
+
} catch {
|
|
2057
2182
|
}
|
|
2058
2183
|
const versions = await this.listVersions();
|
|
2059
2184
|
return versions[0] || "1.0.0";
|
|
@@ -2063,9 +2188,12 @@ var init_sandbox = __esm({
|
|
|
2063
2188
|
/** 列出所有已安装版本 */
|
|
2064
2189
|
static async listVersions() {
|
|
2065
2190
|
const versionRoot = this.getVersionRoot();
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2191
|
+
try {
|
|
2192
|
+
const dirs = await fs10.readdir(versionRoot);
|
|
2193
|
+
return dirs.filter((d) => d !== SANDBOX_CONFIG.DIRS.CURRENT && !d.startsWith(".")).sort().reverse();
|
|
2194
|
+
} catch {
|
|
2195
|
+
return [];
|
|
2196
|
+
}
|
|
2069
2197
|
}
|
|
2070
2198
|
/** 可视化展示沙箱状态 */
|
|
2071
2199
|
static async visualizeStatus(cwd) {
|
|
@@ -2105,7 +2233,7 @@ var init_corekit = __esm({
|
|
|
2105
2233
|
CoreKit = class {
|
|
2106
2234
|
static async getWorkspacePatterns(rootDir) {
|
|
2107
2235
|
const workspaceYamlPath = path13.join(rootDir, "pnpm-workspace.yaml");
|
|
2108
|
-
|
|
2236
|
+
try {
|
|
2109
2237
|
const content = await fs11.readFile(workspaceYamlPath, "utf-8");
|
|
2110
2238
|
const match = content.match(/packages:\s*([\s\S]*?)(?:\n\S|$)/);
|
|
2111
2239
|
if (match && match[1]) {
|
|
@@ -2114,17 +2242,18 @@ var init_corekit = __esm({
|
|
|
2114
2242
|
return patterns;
|
|
2115
2243
|
}
|
|
2116
2244
|
}
|
|
2245
|
+
} catch {
|
|
2117
2246
|
}
|
|
2118
2247
|
const pkgPath = path13.join(rootDir, "package.json");
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2248
|
+
try {
|
|
2249
|
+
const pkg = await fs11.readJson(pkgPath);
|
|
2250
|
+
if (Array.isArray(pkg.workspaces)) {
|
|
2251
|
+
return pkg.workspaces;
|
|
2252
|
+
}
|
|
2253
|
+
if (Array.isArray(pkg.workspaces?.packages)) {
|
|
2254
|
+
return pkg.workspaces.packages;
|
|
2255
|
+
}
|
|
2256
|
+
} catch {
|
|
2128
2257
|
}
|
|
2129
2258
|
return [];
|
|
2130
2259
|
}
|
|
@@ -2138,21 +2267,39 @@ var init_corekit = __esm({
|
|
|
2138
2267
|
}
|
|
2139
2268
|
static async getPluginPackagesDir(rootDir) {
|
|
2140
2269
|
const pluginPatterns = await this.getPluginWorkspacePatterns(rootDir);
|
|
2141
|
-
const
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2270
|
+
const sortedPatterns = [
|
|
2271
|
+
...pluginPatterns.filter(
|
|
2272
|
+
(pattern) => pattern.startsWith("packages/plugins/")
|
|
2273
|
+
),
|
|
2274
|
+
...pluginPatterns.filter((pattern) => pattern.startsWith("plugins/")),
|
|
2275
|
+
...pluginPatterns.filter(
|
|
2276
|
+
(pattern) => !pattern.startsWith("packages/plugins/") && !pattern.startsWith("plugins/")
|
|
2277
|
+
)
|
|
2278
|
+
];
|
|
2279
|
+
for (const pattern of sortedPatterns) {
|
|
2280
|
+
const dir = path13.resolve(rootDir, pattern.replace(/\/\*$/, ""));
|
|
2281
|
+
if (fs11.existsSync(dir)) {
|
|
2282
|
+
return dir;
|
|
2283
|
+
}
|
|
2146
2284
|
}
|
|
2147
|
-
return
|
|
2285
|
+
return null;
|
|
2148
2286
|
}
|
|
2149
2287
|
static async getAppPackagesDir(rootDir) {
|
|
2150
2288
|
const appPatterns = await this.getAppWorkspacePatterns(rootDir);
|
|
2151
|
-
const
|
|
2152
|
-
|
|
2153
|
-
|
|
2289
|
+
const sortedPatterns = [
|
|
2290
|
+
...appPatterns.filter((pattern) => pattern.startsWith("packages/apps/")),
|
|
2291
|
+
...appPatterns.filter((pattern) => pattern.startsWith("apps/")),
|
|
2292
|
+
...appPatterns.filter(
|
|
2293
|
+
(pattern) => !pattern.startsWith("packages/apps/") && !pattern.startsWith("apps/")
|
|
2294
|
+
)
|
|
2295
|
+
];
|
|
2296
|
+
for (const pattern of sortedPatterns) {
|
|
2297
|
+
const dir = path13.resolve(rootDir, pattern.replace(/\/\*$/, ""));
|
|
2298
|
+
if (fs11.existsSync(dir)) {
|
|
2299
|
+
return dir;
|
|
2300
|
+
}
|
|
2154
2301
|
}
|
|
2155
|
-
return
|
|
2302
|
+
return null;
|
|
2156
2303
|
}
|
|
2157
2304
|
static async resolvePluginDirectory(rootDir, pluginName) {
|
|
2158
2305
|
const plugins = await this.discoverPlugins(rootDir);
|
|
@@ -2203,19 +2350,15 @@ var init_corekit = __esm({
|
|
|
2203
2350
|
try {
|
|
2204
2351
|
const cliRoot = await getCliRoot();
|
|
2205
2352
|
const cliVersionFile = path13.join(cliRoot, ".chatbi-version");
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
if (version) return version;
|
|
2209
|
-
}
|
|
2353
|
+
const version = (await fs11.readFile(cliVersionFile, "utf-8")).trim();
|
|
2354
|
+
if (version) return version;
|
|
2210
2355
|
} catch {
|
|
2211
2356
|
}
|
|
2212
2357
|
const currentLinkPath = path13.join(Sandbox.getVersionRoot(), "current");
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
} catch {
|
|
2218
|
-
}
|
|
2358
|
+
try {
|
|
2359
|
+
const realPath = await fs11.realpath(currentLinkPath);
|
|
2360
|
+
return path13.basename(realPath);
|
|
2361
|
+
} catch {
|
|
2219
2362
|
}
|
|
2220
2363
|
const versions = await this.listVersions();
|
|
2221
2364
|
return versions[0] || "latest";
|
|
@@ -2302,7 +2445,7 @@ ${pc6.gray("Root: ")} ${pc6.white(cwd)}`,
|
|
|
2302
2445
|
static async startMonorepoDevServer(rootDir, version, customPort) {
|
|
2303
2446
|
const appsDir = await this.getAppPackagesDir(rootDir) || path13.join(rootDir, "apps");
|
|
2304
2447
|
if (!fs11.existsSync(appsDir)) {
|
|
2305
|
-
|
|
2448
|
+
logger2.warn(
|
|
2306
2449
|
`\u5F53\u524D Monorepo \u4E0B\u672A\u627E\u5230\u5E94\u7528\u76EE\u5F55: ${path13.relative(rootDir, appsDir) || "apps"}`
|
|
2307
2450
|
);
|
|
2308
2451
|
return;
|
|
@@ -2316,7 +2459,7 @@ ${pc6.gray("Root: ")} ${pc6.white(cwd)}`,
|
|
|
2316
2459
|
path: path13.dirname(pkgPath)
|
|
2317
2460
|
}));
|
|
2318
2461
|
if (apps.length === 0) {
|
|
2319
|
-
|
|
2462
|
+
logger2.info("\u5F53\u524D Monorepo \u4E0B\u672A\u627E\u5230\u4EFB\u4F55\u5E94\u7528 (apps/)");
|
|
2320
2463
|
return;
|
|
2321
2464
|
}
|
|
2322
2465
|
const { default: prompts7 } = await import("prompts");
|
|
@@ -2331,7 +2474,7 @@ ${pc6.gray("Root: ")} ${pc6.white(cwd)}`,
|
|
|
2331
2474
|
initial: 0
|
|
2332
2475
|
});
|
|
2333
2476
|
if (!response.appPath) {
|
|
2334
|
-
|
|
2477
|
+
logger2.info("\u5DF2\u53D6\u6D88");
|
|
2335
2478
|
return;
|
|
2336
2479
|
}
|
|
2337
2480
|
await this.startAppDevServer(response.appPath, version, customPort, true);
|
|
@@ -2340,7 +2483,7 @@ ${pc6.gray("Root: ")} ${pc6.white(cwd)}`,
|
|
|
2340
2483
|
* 启动插件开发服务器 (Hosted Mode)
|
|
2341
2484
|
*/
|
|
2342
2485
|
static async startPluginDevServer(pluginDir, version, customPort) {
|
|
2343
|
-
|
|
2486
|
+
logger2.info("\u6B63\u5728\u542F\u52A8\u6258\u7BA1\u5F0F Shell...");
|
|
2344
2487
|
const shellPort = customPort || 5173;
|
|
2345
2488
|
const sandboxRoot = Sandbox.getRoot();
|
|
2346
2489
|
const versionPath = Sandbox.getVersionPath(version);
|
|
@@ -2353,6 +2496,12 @@ ${pc6.gray("Root: ")} ${pc6.white(cwd)}`,
|
|
|
2353
2496
|
if (!fs11.existsSync(pluginEntry)) {
|
|
2354
2497
|
pluginEntry = path13.join(pluginDir, "src/index.ts");
|
|
2355
2498
|
}
|
|
2499
|
+
if (!fs11.existsSync(pluginEntry)) {
|
|
2500
|
+
throw new Error(
|
|
2501
|
+
`\u63D2\u4EF6\u5165\u53E3\u6587\u4EF6\u4E0D\u5B58\u5728: ${pluginDir}/src/index.{ts,tsx}
|
|
2502
|
+
\u8BF7\u786E\u4FDD\u63D2\u4EF6\u76EE\u5F55\u5305\u542B src/index.ts \u6216 src/index.tsx`
|
|
2503
|
+
);
|
|
2504
|
+
}
|
|
2356
2505
|
const define = {
|
|
2357
2506
|
"process.env.CHATBI_PLUGIN_PATH": JSON.stringify(pluginDir)
|
|
2358
2507
|
};
|
|
@@ -2418,14 +2567,14 @@ ${pc6.white("Local: ")} ${pc6.cyan(pc6.underline(localUrl))}`,
|
|
|
2418
2567
|
"Shell Success"
|
|
2419
2568
|
);
|
|
2420
2569
|
} catch (e) {
|
|
2421
|
-
|
|
2570
|
+
logger2.error("Shell \u670D\u52A1\u5668\u542F\u52A8\u5931\u8D25", e);
|
|
2422
2571
|
}
|
|
2423
2572
|
}
|
|
2424
2573
|
/**
|
|
2425
2574
|
* 启动应用开发服务器 (Integrated Mode)
|
|
2426
2575
|
*/
|
|
2427
2576
|
static async startAppDevServer(appDir, version, customPort, isMonorepo = false) {
|
|
2428
|
-
|
|
2577
|
+
logger2.info("\u6B63\u5728\u542F\u52A8\u5E94\u7528...");
|
|
2429
2578
|
const versionPath = Sandbox.getVersionPath(version);
|
|
2430
2579
|
const sandboxNodeModules = path13.join(versionPath, "node_modules");
|
|
2431
2580
|
const cliRoot = await getCliRoot();
|
|
@@ -2444,7 +2593,7 @@ ${pc6.white("Local: ")} ${pc6.cyan(pc6.underline(localUrl))}`,
|
|
|
2444
2593
|
void 0,
|
|
2445
2594
|
appDir
|
|
2446
2595
|
).catch((e) => {
|
|
2447
|
-
|
|
2596
|
+
logger2.warn(`\u52A0\u8F7D vite.config.ts \u5931\u8D25: ${e.message}`);
|
|
2448
2597
|
return null;
|
|
2449
2598
|
});
|
|
2450
2599
|
}
|
|
@@ -2497,7 +2646,7 @@ ${pc6.white("Local: ")} ${pc6.cyan(pc6.underline(localUrl))}`,
|
|
|
2497
2646
|
"App Success"
|
|
2498
2647
|
);
|
|
2499
2648
|
} catch (e) {
|
|
2500
|
-
|
|
2649
|
+
logger2.error("\u5E94\u7528\u542F\u52A8\u5931\u8D25", e);
|
|
2501
2650
|
}
|
|
2502
2651
|
}
|
|
2503
2652
|
};
|
|
@@ -2533,11 +2682,13 @@ import pc7 from "picocolors";
|
|
|
2533
2682
|
async function build(options) {
|
|
2534
2683
|
const cwd = process.cwd();
|
|
2535
2684
|
const pkgPath = path14.join(cwd, "package.json");
|
|
2536
|
-
|
|
2537
|
-
|
|
2685
|
+
let pkg = {};
|
|
2686
|
+
try {
|
|
2687
|
+
pkg = await fs12.readJson(pkgPath);
|
|
2688
|
+
} catch {
|
|
2689
|
+
logger2.error(`\u5728 ${cwd} \u4E2D\u672A\u627E\u5230\u6216\u65E0\u6CD5\u8BFB\u53D6 package.json`);
|
|
2538
2690
|
return;
|
|
2539
2691
|
}
|
|
2540
|
-
const pkg = await fs12.readJson(pkgPath);
|
|
2541
2692
|
if (options.force) {
|
|
2542
2693
|
const spinnerClean = createSpinner("\u6B63\u5728\u6E05\u7406\u7F13\u5B58\u73AF\u5883...").start();
|
|
2543
2694
|
try {
|
|
@@ -2545,11 +2696,11 @@ async function build(options) {
|
|
|
2545
2696
|
spinnerClean.succeed("\u7F13\u5B58\u73AF\u5883\u6E05\u7406\u5B8C\u6210");
|
|
2546
2697
|
} catch {
|
|
2547
2698
|
spinnerClean.fail("\u7F13\u5B58\u6E05\u7406\u5931\u8D25");
|
|
2548
|
-
|
|
2699
|
+
logger2.error("\u6E05\u7406\u8FC7\u7A0B\u4E2D\u53D1\u751F\u9519\u8BEF");
|
|
2549
2700
|
}
|
|
2550
2701
|
}
|
|
2551
2702
|
const version = await CoreKit.resolveVersion(cwd);
|
|
2552
|
-
|
|
2703
|
+
logger2.info(
|
|
2553
2704
|
`\u6B63\u5728\u6784\u5EFA\u9879\u76EE: ${pc7.bold(pkg.name || "unnamed")} (\u5185\u6838\u7248\u672C: ${version})
|
|
2554
2705
|
`
|
|
2555
2706
|
);
|
|
@@ -2582,28 +2733,41 @@ async function build(options) {
|
|
|
2582
2733
|
if (pkg.scripts && pkg.scripts.build && !process.env.CHATBI_CLI_INTERNAL) {
|
|
2583
2734
|
const buildScript = pkg.scripts.build;
|
|
2584
2735
|
if (!buildScript.includes("chatbi-cli build") && !buildScript.includes("chatbi build")) {
|
|
2585
|
-
|
|
2736
|
+
logger2.info(
|
|
2586
2737
|
`\u68C0\u6D4B\u5230\u81EA\u5B9A\u4E49 build \u811A\u672C\uFF0C\u6B63\u5728\u6267\u884C: ${pc7.cyan("npm run build")}`
|
|
2587
2738
|
);
|
|
2588
2739
|
const args = ["run", "build"];
|
|
2589
2740
|
if (options.watch) {
|
|
2590
2741
|
args.push("--", "--watch");
|
|
2591
2742
|
}
|
|
2592
|
-
await execa4("npm", args, {
|
|
2743
|
+
const npmResult = await execa4("npm", args, {
|
|
2593
2744
|
stdio: "inherit",
|
|
2594
|
-
env: { ...process.env, CHATBI_CLI_INTERNAL: "true" }
|
|
2745
|
+
env: { ...process.env, CHATBI_CLI_INTERNAL: "true" },
|
|
2746
|
+
reject: false
|
|
2595
2747
|
});
|
|
2748
|
+
if (npmResult.failed) {
|
|
2749
|
+
logger2.error(`npm run build \u6267\u884C\u5931\u8D25: exitCode=${npmResult.exitCode}`);
|
|
2750
|
+
return;
|
|
2751
|
+
}
|
|
2596
2752
|
return;
|
|
2597
2753
|
}
|
|
2598
2754
|
}
|
|
2599
2755
|
const mode = await CoreKit.detectMode(cwd);
|
|
2600
2756
|
if (mode === "monorepo") {
|
|
2601
|
-
|
|
2602
|
-
await execa4("pnpm", ["-r", "build"], {
|
|
2757
|
+
logger2.info("\u68C0\u6D4B\u5230 Monorepo \u9879\u76EE\uFF0C\u6B63\u5728\u9012\u5F52\u6784\u5EFA\u5B50\u5305...");
|
|
2758
|
+
const pnpmResult = await execa4("pnpm", ["-r", "build"], {
|
|
2759
|
+
stdio: "inherit",
|
|
2760
|
+
cwd,
|
|
2761
|
+
reject: false
|
|
2762
|
+
});
|
|
2763
|
+
if (pnpmResult.failed) {
|
|
2764
|
+
logger2.error(`pnpm -r build \u6267\u884C\u5931\u8D25: exitCode=${pnpmResult.exitCode}`);
|
|
2765
|
+
return;
|
|
2766
|
+
}
|
|
2603
2767
|
return;
|
|
2604
2768
|
}
|
|
2605
2769
|
if (mode === "app") {
|
|
2606
|
-
|
|
2770
|
+
logger2.info("\u6B63\u5728\u6784\u5EFA\u5E94\u7528 (Vite)...");
|
|
2607
2771
|
const { build: viteBuild } = await import("vite");
|
|
2608
2772
|
const coreAlias = Sandbox.getCoreAlias(version);
|
|
2609
2773
|
await viteBuild({
|
|
@@ -2637,22 +2801,30 @@ async function build(options) {
|
|
|
2637
2801
|
}
|
|
2638
2802
|
const { build: tsupBuild } = await import("tsup");
|
|
2639
2803
|
let entry = ["src/index.ts"];
|
|
2640
|
-
|
|
2804
|
+
const tsxPath = path14.join(cwd, "src/index.tsx");
|
|
2805
|
+
const tsPath = path14.join(cwd, "src/index.ts");
|
|
2806
|
+
try {
|
|
2807
|
+
await fs12.access(tsxPath);
|
|
2641
2808
|
entry = ["src/index.tsx"];
|
|
2642
|
-
}
|
|
2643
|
-
|
|
2644
|
-
|
|
2809
|
+
} catch {
|
|
2810
|
+
try {
|
|
2811
|
+
await fs12.access(tsPath);
|
|
2812
|
+
} catch {
|
|
2813
|
+
logger2.error("\u672A\u627E\u5230\u5165\u53E3\u6587\u4EF6\u3002\u671F\u671B src/index.ts \u6216 src/index.tsx");
|
|
2814
|
+
return;
|
|
2815
|
+
}
|
|
2645
2816
|
}
|
|
2646
2817
|
const isPlugin = mode === "plugin";
|
|
2647
2818
|
const userConfig = await ConfigManager.loadTsupConfig(cwd);
|
|
2648
2819
|
if (Object.keys(userConfig).length > 0) {
|
|
2649
|
-
|
|
2820
|
+
logger2.info(`\u5DF2\u52A0\u8F7D\u672C\u5730\u6784\u5EFA\u914D\u7F6E`);
|
|
2650
2821
|
}
|
|
2651
2822
|
if (!options.watch) {
|
|
2652
2823
|
await fs12.remove(path14.join(cwd, "dist"));
|
|
2653
2824
|
const tsbuildinfo = path14.join(cwd, "tsconfig.tsbuildinfo");
|
|
2654
|
-
|
|
2825
|
+
try {
|
|
2655
2826
|
await fs12.remove(tsbuildinfo);
|
|
2827
|
+
} catch {
|
|
2656
2828
|
}
|
|
2657
2829
|
}
|
|
2658
2830
|
if (isPlugin) {
|
|
@@ -2755,22 +2927,46 @@ async function build(options) {
|
|
|
2755
2927
|
} else if (fs12.existsSync(sandboxTsc)) {
|
|
2756
2928
|
tscBin = sandboxTsc;
|
|
2757
2929
|
} else {
|
|
2930
|
+
let dtsFailed = false;
|
|
2758
2931
|
if (fs12.existsSync(path14.join(cwd, "pnpm-lock.yaml"))) {
|
|
2759
|
-
await execa4(
|
|
2760
|
-
|
|
2932
|
+
const pnpmResult = await execa4(
|
|
2933
|
+
"pnpm",
|
|
2934
|
+
["exec", "tsc", "--build", "tsconfig.json"],
|
|
2935
|
+
{ reject: false }
|
|
2936
|
+
);
|
|
2937
|
+
if (pnpmResult.failed) {
|
|
2938
|
+
dtsFailed = true;
|
|
2939
|
+
logger2.error(
|
|
2940
|
+
`pnpm exec tsc \u6267\u884C\u5931\u8D25: exitCode=${pnpmResult.exitCode}`
|
|
2941
|
+
);
|
|
2942
|
+
} else {
|
|
2943
|
+
dtsSpinner.succeed("\u7C7B\u578B\u5B9A\u4E49\u751F\u6210\u5B8C\u6210");
|
|
2944
|
+
}
|
|
2761
2945
|
} else {
|
|
2762
|
-
await execa4(
|
|
2763
|
-
"
|
|
2764
|
-
"typescript",
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2946
|
+
const npxResult = await execa4(
|
|
2947
|
+
"npx",
|
|
2948
|
+
["-p", "typescript", "tsc", "--build", "tsconfig.json"],
|
|
2949
|
+
{ reject: false }
|
|
2950
|
+
);
|
|
2951
|
+
if (npxResult.failed) {
|
|
2952
|
+
dtsFailed = true;
|
|
2953
|
+
logger2.error(`npx tsc \u6267\u884C\u5931\u8D25: exitCode=${npxResult.exitCode}`);
|
|
2954
|
+
} else {
|
|
2955
|
+
dtsSpinner.succeed("\u7C7B\u578B\u5B9A\u4E49\u751F\u6210\u5B8C\u6210");
|
|
2956
|
+
}
|
|
2957
|
+
}
|
|
2958
|
+
if (dtsFailed) {
|
|
2959
|
+
throw new Error("DTS generation failed");
|
|
2770
2960
|
}
|
|
2771
2961
|
}
|
|
2772
2962
|
if (tscBin !== "tsc") {
|
|
2773
|
-
await execa4(tscBin, ["--build", "tsconfig.json"]
|
|
2963
|
+
const tscResult = await execa4(tscBin, ["--build", "tsconfig.json"], {
|
|
2964
|
+
reject: false
|
|
2965
|
+
});
|
|
2966
|
+
if (tscResult.failed) {
|
|
2967
|
+
dtsSpinner.warn(`\u7C7B\u578B\u751F\u6210\u5931\u8D25: exitCode=${tscResult.exitCode}`);
|
|
2968
|
+
throw new Error("DTS generation failed");
|
|
2969
|
+
}
|
|
2774
2970
|
dtsSpinner.succeed("\u7C7B\u578B\u5B9A\u4E49\u751F\u6210\u5B8C\u6210");
|
|
2775
2971
|
}
|
|
2776
2972
|
} catch {
|
|
@@ -2802,6 +2998,10 @@ import { execa as execa5 } from "execa";
|
|
|
2802
2998
|
import path15 from "path";
|
|
2803
2999
|
import pc8 from "picocolors";
|
|
2804
3000
|
async function fetch(version, options = {}) {
|
|
3001
|
+
if (!version || typeof version !== "string" || version.trim() === "") {
|
|
3002
|
+
logger2.error("\u7248\u672C\u53F7\u4E0D\u80FD\u4E3A\u7A7A\u6216\u65E0\u6548");
|
|
3003
|
+
return;
|
|
3004
|
+
}
|
|
2805
3005
|
const fetchSpinner = createSpinner(
|
|
2806
3006
|
`\u6B63\u5728\u83B7\u53D6\u5185\u6838\u7248\u672C ${pc8.cyan(version)}...`
|
|
2807
3007
|
).start();
|
|
@@ -2811,13 +3011,24 @@ async function fetch(version, options = {}) {
|
|
|
2811
3011
|
const packSpinner = createSpinner("\u6B63\u5728\u6253\u5305\u79BB\u7EBF\u8D44\u6E90...").start();
|
|
2812
3012
|
const tgzName = `chatbi-core-${version}.tgz`;
|
|
2813
3013
|
const tgzPath = path15.resolve(process.cwd(), tgzName);
|
|
2814
|
-
await execa5(
|
|
2815
|
-
"
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
3014
|
+
const { failed, exitCode, stderr } = await execa5(
|
|
3015
|
+
"tar",
|
|
3016
|
+
[
|
|
3017
|
+
"-czf",
|
|
3018
|
+
tgzPath,
|
|
3019
|
+
"-C",
|
|
3020
|
+
path15.dirname(versionPath),
|
|
3021
|
+
path15.basename(versionPath)
|
|
3022
|
+
],
|
|
3023
|
+
{ reject: false }
|
|
3024
|
+
);
|
|
3025
|
+
if (failed) {
|
|
3026
|
+
packSpinner.fail(
|
|
3027
|
+
`\u79BB\u7EBF\u8D44\u6E90\u6253\u5305\u5931\u8D25: exitCode=${exitCode}, stderr=${stderr || "unknown"}`
|
|
3028
|
+
);
|
|
3029
|
+
logger2.error(`tar \u547D\u4EE4\u6267\u884C\u5931\u8D25\uFF0C\u8BF7\u786E\u4FDD\u7CFB\u7EDF\u5DF2\u5B89\u88C5 tar`);
|
|
3030
|
+
return;
|
|
3031
|
+
}
|
|
2821
3032
|
packSpinner.succeed("\u79BB\u7EBF\u8D44\u6E90\u6253\u5305\u5B8C\u6210");
|
|
2822
3033
|
printBox(
|
|
2823
3034
|
`${pc8.green(pc8.bold("\u2728 \u79BB\u7EBF\u5305\u5DF2\u751F\u6210!"))}
|
|
@@ -2827,7 +3038,7 @@ ${pc8.white("\u5B89\u88C5\u547D\u4EE4: ")} ${pc8.gray(`chatbi install ${tgzName}
|
|
|
2827
3038
|
"Pack Success"
|
|
2828
3039
|
);
|
|
2829
3040
|
} else {
|
|
2830
|
-
|
|
3041
|
+
logger2.success(`\u5185\u6838\u7248\u672C ${pc8.cyan(version)} \u5DF2\u51C6\u5907\u5C31\u7EEA\u3002`);
|
|
2831
3042
|
}
|
|
2832
3043
|
}
|
|
2833
3044
|
var init_fetch = __esm({
|
|
@@ -2849,36 +3060,56 @@ import fs13 from "fs-extra";
|
|
|
2849
3060
|
import path16 from "path";
|
|
2850
3061
|
import pc9 from "picocolors";
|
|
2851
3062
|
async function install(target) {
|
|
2852
|
-
if (target.endsWith(".tgz")
|
|
2853
|
-
|
|
2854
|
-
`\u6B63\u5728\u5B89\u88C5\u672C\u5730\u79BB\u7EBF\u5305: ${pc9.bold(target)}...`
|
|
2855
|
-
).start();
|
|
3063
|
+
if (target.endsWith(".tgz")) {
|
|
3064
|
+
let fileAccessible = false;
|
|
2856
3065
|
try {
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
}
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
3066
|
+
await fs13.access(target);
|
|
3067
|
+
fileAccessible = true;
|
|
3068
|
+
} catch {
|
|
3069
|
+
}
|
|
3070
|
+
if (!fileAccessible) {
|
|
3071
|
+
logger.error(`\u672C\u5730\u6587\u4EF6\u4E0D\u5B58\u5728\u6216\u4E0D\u53EF\u8BBF\u95EE: ${target}`);
|
|
3072
|
+
} else {
|
|
3073
|
+
const spinner = createSpinner(
|
|
3074
|
+
`\u6B63\u5728\u5B89\u88C5\u672C\u5730\u79BB\u7EBF\u5305: ${pc9.bold(target)}...`
|
|
3075
|
+
).start();
|
|
3076
|
+
try {
|
|
3077
|
+
const tgzPath = path16.resolve(target);
|
|
3078
|
+
const match = path16.basename(target).match(/chatbi-core-(.+)\.tgz/);
|
|
3079
|
+
let version = "unknown";
|
|
3080
|
+
if (match) {
|
|
3081
|
+
version = match[1];
|
|
3082
|
+
}
|
|
3083
|
+
if (version === "unknown") {
|
|
3084
|
+
spinner.warn("\u65E0\u6CD5\u4ECE\u6587\u4EF6\u540D\u8BC6\u522B\u7248\u672C\uFF0C\u5C06\u4F7F\u7528\u5F53\u524D\u65F6\u95F4\u6233\u4F5C\u4E3A\u7248\u672C\u53F7");
|
|
3085
|
+
version = `local-${Date.now()}`;
|
|
3086
|
+
}
|
|
3087
|
+
const versionRoot = Sandbox.getVersionRoot();
|
|
3088
|
+
await fs13.ensureDir(versionRoot);
|
|
3089
|
+
spinner.text = "\u6B63\u5728\u89E3\u538B\u6587\u4EF6...";
|
|
3090
|
+
const { failed, exitCode, stderr } = await execa6(
|
|
3091
|
+
"tar",
|
|
3092
|
+
["-xzf", tgzPath, "-C", versionRoot],
|
|
3093
|
+
{ reject: false }
|
|
3094
|
+
);
|
|
3095
|
+
if (failed) {
|
|
3096
|
+
spinner.fail(`\u89E3\u538B\u5931\u8D25: exitCode=${exitCode}`);
|
|
3097
|
+
logger.error(`tar \u547D\u4EE4\u6267\u884C\u5931\u8D25: ${stderr || tgzPath}`);
|
|
3098
|
+
throw new Error(`Failed to extract ${tgzPath}: exitCode=${exitCode}`);
|
|
3099
|
+
}
|
|
3100
|
+
spinner.succeed(`\u672C\u5730\u5305\u5DF2\u5B89\u88C5\u81F3\u6C99\u7BB1: ${version}`);
|
|
3101
|
+
spinner.text = "\u6B63\u5728\u51C6\u5907\u5185\u6838\u73AF\u5883...";
|
|
3102
|
+
await Sandbox.prepare(version);
|
|
3103
|
+
spinner.succeed("\u5185\u6838\u73AF\u5883\u5C31\u7EEA");
|
|
3104
|
+
printBox(
|
|
3105
|
+
pc9.green(pc9.bold("\u2728 \u672C\u5730\u5185\u6838\u5B89\u88C5\u6210\u529F!")) + "\n\n" + pc9.white("\u7248\u672C: ") + pc9.cyan(version) + "\n" + pc9.white("\u8DEF\u5F84: ") + pc9.gray(Sandbox.getVersionPath(version)),
|
|
3106
|
+
"Install Success"
|
|
3107
|
+
);
|
|
3108
|
+
return;
|
|
3109
|
+
} catch (e) {
|
|
3110
|
+
spinner.fail("\u5B89\u88C5\u5931\u8D25");
|
|
3111
|
+
throw e;
|
|
3112
|
+
}
|
|
2882
3113
|
}
|
|
2883
3114
|
} else {
|
|
2884
3115
|
const { fetch: fetch2 } = await Promise.resolve().then(() => (init_fetch(), fetch_exports));
|
|
@@ -2981,11 +3212,13 @@ import pc10 from "picocolors";
|
|
|
2981
3212
|
async function sync(options = {}) {
|
|
2982
3213
|
const cwd = options.cwd || process.cwd();
|
|
2983
3214
|
const pkgPath = path17.join(cwd, "package.json");
|
|
2984
|
-
|
|
2985
|
-
|
|
3215
|
+
let pkg = {};
|
|
3216
|
+
try {
|
|
3217
|
+
pkg = await fs14.readJson(pkgPath);
|
|
3218
|
+
} catch {
|
|
3219
|
+
logger2.error("\u672A\u627E\u5230 package.json\u3002\u8BF7\u5728\u9879\u76EE\u6839\u76EE\u5F55\u4E0B\u8FD0\u884C\u3002");
|
|
2986
3220
|
return;
|
|
2987
3221
|
}
|
|
2988
|
-
const pkg = await fs14.readJson(pkgPath);
|
|
2989
3222
|
let version = options.version;
|
|
2990
3223
|
if (!version) {
|
|
2991
3224
|
version = await CoreKit.resolveVersion(cwd);
|
|
@@ -3152,7 +3385,7 @@ async function init(options) {
|
|
|
3152
3385
|
],
|
|
3153
3386
|
{
|
|
3154
3387
|
onCancel: () => {
|
|
3155
|
-
|
|
3388
|
+
logger2.warn("\u5DF2\u53D6\u6D88\u521D\u59CB\u5316");
|
|
3156
3389
|
process.exit(0);
|
|
3157
3390
|
}
|
|
3158
3391
|
}
|
|
@@ -3167,7 +3400,14 @@ async function init(options) {
|
|
|
3167
3400
|
const isPluginIncluded = finalIncludePlugin;
|
|
3168
3401
|
const rootDir = cwd || process.cwd();
|
|
3169
3402
|
const targetDir = path18.resolve(rootDir, name);
|
|
3170
|
-
|
|
3403
|
+
let targetDirExists = false;
|
|
3404
|
+
try {
|
|
3405
|
+
const stats = await fs15.stat(targetDir);
|
|
3406
|
+
targetDirExists = stats.isDirectory();
|
|
3407
|
+
} catch {
|
|
3408
|
+
targetDirExists = false;
|
|
3409
|
+
}
|
|
3410
|
+
if (targetDirExists) {
|
|
3171
3411
|
if (force) {
|
|
3172
3412
|
await fs15.remove(targetDir);
|
|
3173
3413
|
} else {
|
|
@@ -3190,7 +3430,7 @@ async function init(options) {
|
|
|
3190
3430
|
]
|
|
3191
3431
|
});
|
|
3192
3432
|
if (action === "cancel" || !action) {
|
|
3193
|
-
|
|
3433
|
+
logger2.warn("\u5DF2\u53D6\u6D88\u521D\u59CB\u5316");
|
|
3194
3434
|
return;
|
|
3195
3435
|
}
|
|
3196
3436
|
if (action === "overwrite") {
|
|
@@ -3201,20 +3441,25 @@ async function init(options) {
|
|
|
3201
3441
|
initial: false
|
|
3202
3442
|
});
|
|
3203
3443
|
if (!confirm) {
|
|
3204
|
-
|
|
3444
|
+
logger2.warn("\u5DF2\u53D6\u6D88\u8986\u76D6");
|
|
3205
3445
|
return;
|
|
3206
3446
|
}
|
|
3207
3447
|
await fs15.remove(targetDir);
|
|
3208
3448
|
}
|
|
3209
3449
|
}
|
|
3210
3450
|
}
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3451
|
+
logger2.info(`\u6B63\u5728\u521D\u59CB\u5316\u9879\u76EE: ${pc11.bold(name)}...`);
|
|
3452
|
+
logger2.info(pc11.gray(`\u7C7B\u578B: ${projectType} | \u4E3B\u9898: ${theme || "N/A"}`));
|
|
3453
|
+
logger2.info("");
|
|
3214
3454
|
try {
|
|
3215
3455
|
const myCliRoot = await getCliRoot();
|
|
3216
|
-
|
|
3217
|
-
|
|
3456
|
+
let cliVersion = "0.0.0";
|
|
3457
|
+
try {
|
|
3458
|
+
const cliPkg = await fs15.readJson(path18.join(myCliRoot, "package.json"));
|
|
3459
|
+
cliVersion = cliPkg.version;
|
|
3460
|
+
} catch {
|
|
3461
|
+
logger2.warn(`\u65E0\u6CD5\u8BFB\u53D6 CLI \u7248\u672C\uFF0C\u4F7F\u7528\u9ED8\u8BA4\u503C: ${cliVersion}`);
|
|
3462
|
+
}
|
|
3218
3463
|
const config4 = { coreSource: "npm" };
|
|
3219
3464
|
const kernelVersionFile = path18.join(myCliRoot, SANDBOX_CONFIG.LOCK_FILE);
|
|
3220
3465
|
if (fs15.existsSync(kernelVersionFile)) {
|
|
@@ -3301,11 +3546,11 @@ async function init(options) {
|
|
|
3301
3546
|
);
|
|
3302
3547
|
}
|
|
3303
3548
|
spinner.succeed(pc11.green(`\u9879\u76EE ${name} \u521D\u59CB\u5316\u5B8C\u6210\uFF01`));
|
|
3304
|
-
|
|
3305
|
-
|
|
3549
|
+
logger2.info("");
|
|
3550
|
+
logger2.info(pc11.cyan("\u6B63\u5728\u521D\u59CB\u5316\u5185\u6838\u73AF\u5883..."));
|
|
3306
3551
|
const projectCwd = targetDir;
|
|
3307
3552
|
await sync({ force: true, cwd: projectCwd });
|
|
3308
|
-
|
|
3553
|
+
logger2.info("");
|
|
3309
3554
|
printBox(
|
|
3310
3555
|
`${pc11.green("\u{1F389} \u9879\u76EE\u51C6\u5907\u5C31\u7EEA\uFF01")}
|
|
3311
3556
|
|
|
@@ -3314,7 +3559,7 @@ chatbi dev`,
|
|
|
3314
3559
|
"Happy Coding"
|
|
3315
3560
|
);
|
|
3316
3561
|
} catch (e) {
|
|
3317
|
-
|
|
3562
|
+
logger2.error(`\u521D\u59CB\u5316\u5931\u8D25: ${e.message}`);
|
|
3318
3563
|
}
|
|
3319
3564
|
}
|
|
3320
3565
|
var init_init = __esm({
|
|
@@ -3344,14 +3589,20 @@ async function add(options) {
|
|
|
3344
3589
|
const cwd = process.cwd();
|
|
3345
3590
|
const pkgPath = path19.join(cwd, "package.json");
|
|
3346
3591
|
if (!fs16.existsSync(pkgPath)) {
|
|
3347
|
-
|
|
3592
|
+
logger2.error("\u672A\u627E\u5230 package.json\u3002\u8BF7\u5728 ChatBI-V \u9879\u76EE\u6839\u76EE\u5F55\u4E0B\u8FD0\u884C\u6B64\u547D\u4EE4\u3002");
|
|
3593
|
+
return;
|
|
3594
|
+
}
|
|
3595
|
+
let pkg = {};
|
|
3596
|
+
try {
|
|
3597
|
+
pkg = await fs16.readJson(pkgPath);
|
|
3598
|
+
} catch {
|
|
3599
|
+
logger2.error(`\u8BFB\u53D6 package.json \u5931\u8D25: ${pkgPath}`);
|
|
3348
3600
|
return;
|
|
3349
3601
|
}
|
|
3350
|
-
const pkg = await fs16.readJson(pkgPath);
|
|
3351
3602
|
const pluginPackagesDir = await CoreKit.getPluginPackagesDir(cwd);
|
|
3352
3603
|
const isMonorepo = Boolean(pluginPackagesDir);
|
|
3353
3604
|
if (!isMonorepo) {
|
|
3354
|
-
|
|
3605
|
+
logger2.error(
|
|
3355
3606
|
"\u5F53\u524D\u4E0D\u662F Monorepo \u9879\u76EE\uFF0C\u65E0\u6CD5\u6DFB\u52A0\u63D2\u4EF6 (\u8BF7\u5728\u5305\u542B\u63D2\u4EF6\u5DE5\u4F5C\u7A7A\u95F4\u7684\u9879\u76EE\u4E2D\u8FD0\u884C)"
|
|
3356
3607
|
);
|
|
3357
3608
|
process.exit(1);
|
|
@@ -3398,7 +3649,7 @@ async function add(options) {
|
|
|
3398
3649
|
],
|
|
3399
3650
|
{
|
|
3400
3651
|
onCancel: () => {
|
|
3401
|
-
|
|
3652
|
+
logger2.warn("\u5DF2\u53D6\u6D88\u6DFB\u52A0\u63D2\u4EF6");
|
|
3402
3653
|
process.exit(0);
|
|
3403
3654
|
}
|
|
3404
3655
|
}
|
|
@@ -3413,9 +3664,11 @@ async function add(options) {
|
|
|
3413
3664
|
}
|
|
3414
3665
|
const folderName = cleanName.startsWith("plugin-") ? cleanName : `plugin-${cleanName}`;
|
|
3415
3666
|
const pluginDir = path19.resolve(pluginPackagesDir, folderName);
|
|
3416
|
-
|
|
3417
|
-
|
|
3667
|
+
try {
|
|
3668
|
+
await fs16.access(pluginDir);
|
|
3669
|
+
logger2.error(`\u63D2\u4EF6\u76EE\u5F55 ${folderName} \u5DF2\u5B58\u5728\u3002`);
|
|
3418
3670
|
return;
|
|
3671
|
+
} catch {
|
|
3419
3672
|
}
|
|
3420
3673
|
const spinner = createSpinner(`\u6B63\u5728\u6DFB\u52A0\u65B0\u63D2\u4EF6: ${pc12.bold(name)}...`).start();
|
|
3421
3674
|
const targetDir = pluginDir;
|
|
@@ -3451,8 +3704,8 @@ async function add(options) {
|
|
|
3451
3704
|
}
|
|
3452
3705
|
if (process.env.NODE_ENV === "test") {
|
|
3453
3706
|
spinner.succeed(`\u63D2\u4EF6 ${pc12.bold(name)} \u6DFB\u52A0\u6210\u529F\uFF01`);
|
|
3454
|
-
|
|
3455
|
-
|
|
3707
|
+
logger2.success(`\u63D2\u4EF6 ${pc12.bold(name)} \u6DFB\u52A0\u6210\u529F\uFF01`);
|
|
3708
|
+
logger2.success("\u2728 \u63D2\u4EF6\u521B\u5EFA\u6210\u529F!");
|
|
3456
3709
|
return;
|
|
3457
3710
|
}
|
|
3458
3711
|
if (!templateDir || !fs16.existsSync(templateDir)) {
|
|
@@ -4033,58 +4286,72 @@ import fs18 from "fs-extra";
|
|
|
4033
4286
|
import path21 from "path";
|
|
4034
4287
|
import pc14 from "picocolors";
|
|
4035
4288
|
async function doctor(options = {}) {
|
|
4036
|
-
|
|
4289
|
+
logger2.info("\u6B63\u5728\u8BCA\u65AD\u9879\u76EE\u5065\u5EB7\u72B6\u51B5...\n");
|
|
4037
4290
|
const cwd = process.cwd();
|
|
4038
4291
|
let hasIssues = false;
|
|
4039
4292
|
const issues = [];
|
|
4040
|
-
|
|
4293
|
+
logger2.info(pc14.bold("Step 1: \u68C0\u67E5\u57FA\u7840\u73AF\u5883..."));
|
|
4041
4294
|
const nodeVersion = process.version;
|
|
4042
4295
|
if (parseInt(nodeVersion.slice(1).split(".")[0]) < 18) {
|
|
4043
|
-
|
|
4296
|
+
logger2.error(`Node.js \u7248\u672C\u592A\u4F4E: ${nodeVersion} (\u8981\u6C42 >=18)`);
|
|
4044
4297
|
hasIssues = true;
|
|
4045
4298
|
issues.push(`Node.js \u7248\u672C\u8FC7\u4F4E (${nodeVersion})`);
|
|
4046
4299
|
} else {
|
|
4047
|
-
|
|
4300
|
+
logger2.success(`Node.js \u7248\u672C: ${nodeVersion}`);
|
|
4048
4301
|
}
|
|
4049
4302
|
try {
|
|
4050
4303
|
const { execa: execa8 } = await import("execa");
|
|
4051
|
-
const { stdout: pnpmVer } = await execa8("pnpm", ["-v"]
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4304
|
+
const { failed, stdout: pnpmVer } = await execa8("pnpm", ["-v"], {
|
|
4305
|
+
reject: false
|
|
4306
|
+
});
|
|
4307
|
+
if (failed) {
|
|
4308
|
+
logger2.warn("\u672A\u68C0\u6D4B\u5230 pnpm\uFF0C\u5EFA\u8BAE\u5B89\u88C5\u4EE5\u83B7\u5F97\u6700\u4F73\u4F53\u9A8C");
|
|
4309
|
+
} else {
|
|
4310
|
+
logger2.success(`pnpm \u7248\u672C: ${pnpmVer}`);
|
|
4311
|
+
}
|
|
4312
|
+
} catch (e) {
|
|
4313
|
+
logger2.warn(
|
|
4314
|
+
`\u672A\u68C0\u6D4B\u5230 pnpm\uFF0C\u5EFA\u8BAE\u5B89\u88C5\u4EE5\u83B7\u5F97\u6700\u4F73\u4F53\u9A8C: ${e.message}`
|
|
4315
|
+
);
|
|
4055
4316
|
}
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4317
|
+
try {
|
|
4318
|
+
const gitDirPath = path21.join(cwd, ".git");
|
|
4319
|
+
await fs18.access(gitDirPath);
|
|
4320
|
+
const { execa: execa8 } = await import("execa");
|
|
4321
|
+
const { failed, stdout } = await execa8("git", ["status", "--porcelain"], {
|
|
4322
|
+
cwd,
|
|
4323
|
+
reject: false
|
|
4324
|
+
});
|
|
4325
|
+
if (failed) {
|
|
4326
|
+
logger2.warn("Git \u4E0D\u53EF\u7528\u6216\u5DE5\u4F5C\u533A\u635F\u574F");
|
|
4327
|
+
} else if (stdout.trim()) {
|
|
4328
|
+
logger2.warn("Git \u5DE5\u4F5C\u533A\u4E0D\u5E72\u51C0\uFF0C\u5EFA\u8BAE\u5728\u63D0\u4EA4\u540E\u8FDB\u884C\u64CD\u4F5C");
|
|
4329
|
+
} else {
|
|
4330
|
+
logger2.success("Git \u5DE5\u4F5C\u533A\u5E72\u51C0");
|
|
4066
4331
|
}
|
|
4332
|
+
} catch (e) {
|
|
4333
|
+
logger2.debug(`Git \u68C0\u67E5\u8DF3\u8FC7: ${e.message}`);
|
|
4067
4334
|
}
|
|
4068
|
-
|
|
4335
|
+
logger2.info(pc14.bold("\nStep 2: \u68C0\u67E5\u5185\u6838\u6C99\u7BB1\u73AF\u5883..."));
|
|
4069
4336
|
const version = await CoreKit.resolveVersion(cwd);
|
|
4070
4337
|
const versionPath = Sandbox.getVersionPath(version);
|
|
4071
4338
|
if (!fs18.existsSync(versionPath)) {
|
|
4072
|
-
|
|
4073
|
-
|
|
4339
|
+
logger2.error(`\u5185\u6838\u6C99\u7BB1\u7248\u672C ${version} \u5C1A\u672A\u5B89\u88C5`);
|
|
4340
|
+
logger2.info(
|
|
4074
4341
|
pc14.gray(` \u5EFA\u8BAE\u8FD0\u884C 'chatbi sync' \u6216 'chatbi use ${version}' \u8FDB\u884C\u5B89\u88C5\u3002`)
|
|
4075
4342
|
);
|
|
4076
4343
|
hasIssues = true;
|
|
4077
4344
|
issues.push(`\u5185\u6838\u6C99\u7BB1\u672A\u5B89\u88C5 (${version})`);
|
|
4078
4345
|
} else {
|
|
4079
|
-
|
|
4346
|
+
logger2.success(`\u5185\u6838\u6C99\u7BB1\u5C31\u7EEA (\u7248\u672C: ${version})`);
|
|
4080
4347
|
const sandboxNm = path21.join(versionPath, "node_modules");
|
|
4081
4348
|
if (!fs18.existsSync(sandboxNm)) {
|
|
4082
|
-
|
|
4349
|
+
logger2.warn("\u6C99\u7BB1\u4F9D\u8D56\u672A\u5B89\u88C5\uFF0C\u5C06\u5BFC\u81F4\u6784\u5EFA\u5931\u8D25");
|
|
4083
4350
|
hasIssues = true;
|
|
4084
4351
|
issues.push("\u6C99\u7BB1\u4F9D\u8D56\u7F3A\u5931");
|
|
4085
4352
|
}
|
|
4086
4353
|
}
|
|
4087
|
-
|
|
4354
|
+
logger2.info(pc14.bold("\nStep 2.5: \u6DF1\u5EA6\u6C99\u7BB1\u8BCA\u65AD..."));
|
|
4088
4355
|
try {
|
|
4089
4356
|
const sandboxDiagnostics = new SandboxDiagnostics(version, cwd);
|
|
4090
4357
|
const diagResult = await sandboxDiagnostics.runAllDiagnostics();
|
|
@@ -4093,48 +4360,48 @@ async function doctor(options = {}) {
|
|
|
4093
4360
|
(i) => i.severity === "warning"
|
|
4094
4361
|
);
|
|
4095
4362
|
if (diagResult.passed) {
|
|
4096
|
-
|
|
4363
|
+
logger2.success("\u6C99\u7BB1\u6DF1\u5EA6\u8BCA\u65AD\u901A\u8FC7");
|
|
4097
4364
|
} else {
|
|
4098
|
-
|
|
4365
|
+
logger2.warn(`\u6C99\u7BB1\u6DF1\u5EA6\u8BCA\u65AD\u53D1\u73B0\u95EE\u9898 ${diagResult.errorCount} \u4E2A`);
|
|
4099
4366
|
for (const item of errorItems.slice(0, 3)) {
|
|
4100
|
-
|
|
4367
|
+
logger2.error(` \u2022 ${item.title}`);
|
|
4101
4368
|
issues.push(`\u6C99\u7BB1: ${item.title}`);
|
|
4102
4369
|
}
|
|
4103
4370
|
if (errorItems.length > 3) {
|
|
4104
|
-
|
|
4105
|
-
|
|
4371
|
+
logger2.info(pc14.gray(` ... \u8FD8\u6709 ${errorItems.length - 3} \u4E2A\u95EE\u9898`));
|
|
4372
|
+
logger2.info(pc14.gray(` \u8FD0\u884C 'chatbi sandbox diagnose' \u67E5\u770B\u8BE6\u7EC6\u4FE1\u606F`));
|
|
4106
4373
|
}
|
|
4107
4374
|
}
|
|
4108
4375
|
for (const item of warningItems.slice(0, 2)) {
|
|
4109
|
-
|
|
4376
|
+
logger2.warn(` \u2022 ${item.title}`);
|
|
4110
4377
|
}
|
|
4111
4378
|
if (warningItems.length > 2) {
|
|
4112
|
-
|
|
4379
|
+
logger2.info(pc14.gray(` ... \u8FD8\u6709 ${warningItems.length - 2} \u4E2A\u8B66\u544A`));
|
|
4113
4380
|
}
|
|
4114
4381
|
} catch (e) {
|
|
4115
|
-
|
|
4382
|
+
logger2.warn(`\u6C99\u7BB1\u6DF1\u5EA6\u8BCA\u65AD\u5931\u8D25: ${e.message}`);
|
|
4116
4383
|
}
|
|
4117
|
-
|
|
4384
|
+
logger2.info(pc14.bold("\nStep 3: \u68C0\u67E5\u865A\u62DF\u4F9D\u8D56\u6620\u5C04..."));
|
|
4118
4385
|
const workspaceRoot = await SandboxPath.getWorkspaceRoot(cwd);
|
|
4119
4386
|
const chatbiDir = path21.join(workspaceRoot, ".chatbi");
|
|
4120
4387
|
const isMonorepoSub = cwd !== workspaceRoot;
|
|
4121
4388
|
if (isMonorepoSub) {
|
|
4122
|
-
|
|
4389
|
+
logger2.info(
|
|
4123
4390
|
pc14.gray(`\u5F53\u524D\u4F4D\u4E8E\u5B50\u5305\uFF0C\u68C0\u67E5 Monorepo \u6839\u76EE\u5F55\u914D\u7F6E: ${workspaceRoot}`)
|
|
4124
4391
|
);
|
|
4125
4392
|
}
|
|
4126
4393
|
if (!fs18.existsSync(chatbiDir)) {
|
|
4127
|
-
|
|
4394
|
+
logger2.warn("\u672A\u53D1\u73B0\u865A\u62DF\u4F9D\u8D56\u914D\u7F6E (.chatbi \u76EE\u5F55)");
|
|
4128
4395
|
hasIssues = true;
|
|
4129
4396
|
issues.push("\u7F3A\u5931 .chatbi \u76EE\u5F55");
|
|
4130
4397
|
} else {
|
|
4131
4398
|
const pathsJson = path21.join(chatbiDir, "tsconfig.paths.json");
|
|
4132
4399
|
if (!fs18.existsSync(pathsJson)) {
|
|
4133
|
-
|
|
4400
|
+
logger2.warn("\u865A\u62DF\u4F9D\u8D56\u914D\u7F6E\u6587\u4EF6\u4E0D\u5B8C\u6574");
|
|
4134
4401
|
hasIssues = true;
|
|
4135
4402
|
issues.push("\u865A\u62DF\u4F9D\u8D56\u914D\u7F6E\u4E0D\u5B8C\u6574");
|
|
4136
4403
|
} else {
|
|
4137
|
-
|
|
4404
|
+
logger2.success("\u865A\u62DF\u4F9D\u8D56\u914D\u7F6E\u5DF2\u751F\u6210");
|
|
4138
4405
|
}
|
|
4139
4406
|
}
|
|
4140
4407
|
const tsConfigPath = path21.join(cwd, "tsconfig.json");
|
|
@@ -4163,15 +4430,17 @@ async function doctor(options = {}) {
|
|
|
4163
4430
|
);
|
|
4164
4431
|
}
|
|
4165
4432
|
if (!hasExtend) {
|
|
4166
|
-
|
|
4433
|
+
logger2.warn("tsconfig.json \u672A\u7EE7\u627F\u865A\u62DF\u4F9D\u8D56\u914D\u7F6E");
|
|
4167
4434
|
hasIssues = true;
|
|
4168
4435
|
issues.push("tsconfig.json \u914D\u7F6E\u7F3A\u5931");
|
|
4169
4436
|
missingTsExtend = true;
|
|
4170
4437
|
} else {
|
|
4171
|
-
|
|
4438
|
+
logger2.success("tsconfig.json \u914D\u7F6E\u6B63\u5E38");
|
|
4172
4439
|
}
|
|
4173
|
-
} catch {
|
|
4174
|
-
|
|
4440
|
+
} catch (e) {
|
|
4441
|
+
logger2.error(
|
|
4442
|
+
`\u89E3\u6790 tsconfig.json \u5931\u8D25 (${tsConfigPath}): ${e.message}`
|
|
4443
|
+
);
|
|
4175
4444
|
}
|
|
4176
4445
|
}
|
|
4177
4446
|
const viteConfigPath = path21.join(cwd, "vite.config.ts");
|
|
@@ -4180,7 +4449,7 @@ async function doctor(options = {}) {
|
|
|
4180
4449
|
if (!content.includes("vite.alias.json") && !content.includes("CoreKit")) {
|
|
4181
4450
|
}
|
|
4182
4451
|
}
|
|
4183
|
-
|
|
4452
|
+
logger2.info(pc14.bold("\nStep 4: \u626B\u63CF\u4EE3\u7801\u89C4\u5219..."));
|
|
4184
4453
|
const rules = [
|
|
4185
4454
|
{
|
|
4186
4455
|
id: "plugin-lifecycle-init",
|
|
@@ -4261,6 +4530,10 @@ ${pc14.cyan("\u5EFA\u8BAE\u6839\u636E\u63D0\u793A\u8FDB\u884C\u4FEE\u590D")}`,
|
|
|
4261
4530
|
).start();
|
|
4262
4531
|
try {
|
|
4263
4532
|
const tsConfig = await fs18.readJson(tsConfigPath);
|
|
4533
|
+
if (!tsConfig || typeof tsConfig !== "object") {
|
|
4534
|
+
logger2.warn("tsconfig.json \u683C\u5F0F\u65E0\u6548");
|
|
4535
|
+
return;
|
|
4536
|
+
}
|
|
4264
4537
|
let extendsTarget = "./.chatbi/tsconfig.json";
|
|
4265
4538
|
if (isMonorepoSub) {
|
|
4266
4539
|
extendsTarget = path21.relative(
|
|
@@ -4312,9 +4585,9 @@ async function ls() {
|
|
|
4312
4585
|
const versions = await CoreKit.listVersions();
|
|
4313
4586
|
const currentVersion = await CoreKit.resolveVersion(process.cwd());
|
|
4314
4587
|
const globalCurrentVersion = await CoreKit.resolveVersion();
|
|
4315
|
-
|
|
4588
|
+
logger2.info("\u5DF2\u5B89\u88C5\u7684\u5185\u6838\u6C99\u7BB1\u7248\u672C:");
|
|
4316
4589
|
if (versions.length === 0) {
|
|
4317
|
-
|
|
4590
|
+
logger2.warn("\u5C1A\u672A\u5B89\u88C5\u4EFB\u4F55\u7248\u672C\uFF0C\u8BF7\u8FD0\u884C chatbi sync \u8FDB\u884C\u5B89\u88C5\u3002");
|
|
4318
4591
|
} else {
|
|
4319
4592
|
const list = versions.map((v) => {
|
|
4320
4593
|
const isGlobalCurrent = v === globalCurrentVersion;
|
|
@@ -4360,19 +4633,23 @@ __export(use_exports, {
|
|
|
4360
4633
|
import fs19 from "fs-extra";
|
|
4361
4634
|
import path22 from "path";
|
|
4362
4635
|
async function use(version, options = {}) {
|
|
4636
|
+
if (!version || typeof version !== "string" || version.trim() === "") {
|
|
4637
|
+
logger2.error("\u7248\u672C\u53F7\u4E0D\u80FD\u4E3A\u7A7A\u6216\u65E0\u6548");
|
|
4638
|
+
return;
|
|
4639
|
+
}
|
|
4363
4640
|
const versions = await CoreKit.listVersions();
|
|
4364
4641
|
if (!versions.includes(version)) {
|
|
4365
|
-
|
|
4642
|
+
logger2.warn(`\u7248\u672C ${version} \u5C1A\u672A\u5B89\u88C5\uFF0C\u6B63\u5728\u5C1D\u8BD5\u5B89\u88C5...`);
|
|
4366
4643
|
await Sandbox.prepare(version);
|
|
4367
4644
|
}
|
|
4368
4645
|
if (options.global) {
|
|
4369
4646
|
await Sandbox.useVersion(version);
|
|
4370
|
-
|
|
4647
|
+
logger2.success(`\u5DF2\u5207\u6362\u5168\u5C40\u5185\u6838\u7248\u672C\u81F3: ${version}`);
|
|
4371
4648
|
} else {
|
|
4372
4649
|
const cwd = process.cwd();
|
|
4373
4650
|
const versionFilePath = path22.join(cwd, ".chatbi-version");
|
|
4374
4651
|
await fs19.writeFile(versionFilePath, version, "utf-8");
|
|
4375
|
-
|
|
4652
|
+
logger2.success(`\u5DF2\u5207\u6362\u5F53\u524D\u9879\u76EE\u5185\u6838\u7248\u672C\u4E3A: ${version}`);
|
|
4376
4653
|
}
|
|
4377
4654
|
await sync({ version, force: false });
|
|
4378
4655
|
}
|
|
@@ -4401,8 +4678,10 @@ async function gl(options) {
|
|
|
4401
4678
|
const { type: initialType, prompt: initialPrompt } = options;
|
|
4402
4679
|
const cwd = process.cwd();
|
|
4403
4680
|
const pkgPath = path23.join(cwd, "package.json");
|
|
4404
|
-
|
|
4405
|
-
|
|
4681
|
+
try {
|
|
4682
|
+
await fs20.readJson(pkgPath);
|
|
4683
|
+
} catch {
|
|
4684
|
+
logger2.error("\u672A\u627E\u5230 package.json\u3002\u8BF7\u5728 ChatBI-V \u9879\u76EE\u6839\u76EE\u5F55\u4E0B\u8FD0\u884C\u6B64\u547D\u4EE4\u3002");
|
|
4406
4685
|
return;
|
|
4407
4686
|
}
|
|
4408
4687
|
const response = await prompts3(
|
|
@@ -4448,7 +4727,7 @@ async function gl(options) {
|
|
|
4448
4727
|
],
|
|
4449
4728
|
{
|
|
4450
4729
|
onCancel: () => {
|
|
4451
|
-
|
|
4730
|
+
logger2.warn("\u5DF2\u53D6\u6D88 AI \u751F\u6210");
|
|
4452
4731
|
process.exit(0);
|
|
4453
4732
|
}
|
|
4454
4733
|
}
|
|
@@ -4456,10 +4735,10 @@ async function gl(options) {
|
|
|
4456
4735
|
const genType = initialType || response.genType;
|
|
4457
4736
|
const userPrompt = initialPrompt || response.userPrompt;
|
|
4458
4737
|
if (!userPrompt && genType !== "chat") {
|
|
4459
|
-
|
|
4738
|
+
logger2.error("\u9700\u6C42\u63CF\u8FF0\u4E0D\u80FD\u4E3A\u7A7A\u3002");
|
|
4460
4739
|
return;
|
|
4461
4740
|
}
|
|
4462
|
-
|
|
4741
|
+
logger2.info(`\u6B63\u5728\u547C\u53EB AI \u5F15\u64CE [\u6A21\u5F0F: ${pc16.bold(genType)}]...`);
|
|
4463
4742
|
const toolsContext = `
|
|
4464
4743
|
[Available Tools & Capabilities]
|
|
4465
4744
|
- Tool: plugin -> For creating new feature modules. Requires: name, type (business|system).
|
|
@@ -4503,57 +4782,63 @@ If not, use the SLOT_REQUIRED format.`.trim();
|
|
|
4503
4782
|
let retry = true;
|
|
4504
4783
|
while (retry) {
|
|
4505
4784
|
spinner.start();
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4785
|
+
const { stdout, failed, exitCode, stderr } = await execa7(
|
|
4786
|
+
"gemini",
|
|
4787
|
+
[geminiCmd, currentPrompt],
|
|
4788
|
+
{
|
|
4789
|
+
stdio: "pipe",
|
|
4790
|
+
reject: false
|
|
4791
|
+
}
|
|
4792
|
+
);
|
|
4793
|
+
if (failed) {
|
|
4510
4794
|
spinner.stop();
|
|
4511
|
-
if (
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4795
|
+
if (exitCode === "ENOENT" || exitCode === 127 || exitCode === "ENOENT") {
|
|
4796
|
+
logger2.error("\u672A\u5728\u7CFB\u7EDF\u4E2D\u627E\u5230 `gemini-cli` \u547D\u4EE4\u3002");
|
|
4797
|
+
logger2.info(
|
|
4798
|
+
pc16.yellow("\u8BF7\u786E\u4FDD\u5DF2\u5B89\u88C5 gemini-cli \u5E76\u5C06\u5176\u6DFB\u52A0\u5230\u7CFB\u7EDF PATH \u4E2D\u3002")
|
|
4799
|
+
);
|
|
4800
|
+
} else {
|
|
4801
|
+
logger2.error(
|
|
4802
|
+
`AI \u751F\u6210\u8FC7\u7A0B\u4E2D\u51FA\u9519: exitCode=${exitCode}, stderr=${stderr || stdout}`
|
|
4803
|
+
);
|
|
4804
|
+
}
|
|
4805
|
+
return;
|
|
4806
|
+
}
|
|
4807
|
+
spinner.stop();
|
|
4808
|
+
if (stdout.includes("SLOT_REQUIRED:")) {
|
|
4809
|
+
const slots = [];
|
|
4810
|
+
const lines = stdout.split("\n");
|
|
4811
|
+
for (const line of lines) {
|
|
4812
|
+
if (line.includes("SLOT_REQUIRED:")) {
|
|
4813
|
+
const match = line.match(/SLOT_REQUIRED:\s*([^|]+)\|\s*(.+)/);
|
|
4814
|
+
if (match) {
|
|
4815
|
+
slots.push({
|
|
4816
|
+
type: "text",
|
|
4817
|
+
name: match[1].trim(),
|
|
4818
|
+
message: match[2].trim()
|
|
4819
|
+
});
|
|
4524
4820
|
}
|
|
4525
4821
|
}
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4822
|
+
}
|
|
4823
|
+
if (slots.length > 0) {
|
|
4824
|
+
logger2.info(pc16.yellow("\n\u{1F4DD} AI \u9700\u8981\u66F4\u591A\u4FE1\u606F\u4EE5\u7EE7\u7EED:"));
|
|
4825
|
+
const answers = await prompts3(slots, {
|
|
4826
|
+
onCancel: () => process.exit(0)
|
|
4827
|
+
});
|
|
4828
|
+
const answerContext = Object.entries(answers).map(([k, v]) => `[${k}]: ${v}`).join("\n");
|
|
4829
|
+
currentPrompt += `
|
|
4533
4830
|
|
|
4534
4831
|
[User Answers]:
|
|
4535
4832
|
${answerContext}
|
|
4536
4833
|
|
|
4537
4834
|
Please proceed with generation based on these answers.`;
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
}
|
|
4541
|
-
}
|
|
4542
|
-
logger.info("\n" + stdout);
|
|
4543
|
-
retry = false;
|
|
4544
|
-
logger.success(`AI \u547D\u4EE4 [gemini ${geminiCmd}] \u6267\u884C\u5B8C\u6BD5!`);
|
|
4545
|
-
} catch (error) {
|
|
4546
|
-
spinner.stop();
|
|
4547
|
-
if (error.code === "ENOENT") {
|
|
4548
|
-
logger.error("\u672A\u5728\u7CFB\u7EDF\u4E2D\u627E\u5230 `gemini-cli` \u547D\u4EE4\u3002");
|
|
4549
|
-
logger.info(
|
|
4550
|
-
pc16.yellow("\u8BF7\u786E\u4FDD\u5DF2\u5B89\u88C5 gemini-cli \u5E76\u5C06\u5176\u6DFB\u52A0\u5230\u7CFB\u7EDF PATH \u4E2D\u3002")
|
|
4551
|
-
);
|
|
4552
|
-
} else {
|
|
4553
|
-
logger.error(`AI \u751F\u6210\u8FC7\u7A0B\u4E2D\u51FA\u9519: ${error.message}`);
|
|
4835
|
+
logger2.info("\u6B63\u5728\u6839\u636E\u60A8\u7684\u53CD\u9988\u91CD\u65B0\u547C\u53EB AI...");
|
|
4836
|
+
continue;
|
|
4554
4837
|
}
|
|
4555
|
-
throw error;
|
|
4556
4838
|
}
|
|
4839
|
+
logger2.info("\n" + stdout);
|
|
4840
|
+
retry = false;
|
|
4841
|
+
logger2.success(`AI \u547D\u4EE4 [gemini ${geminiCmd}] \u6267\u884C\u5B8C\u6BD5!`);
|
|
4557
4842
|
}
|
|
4558
4843
|
}
|
|
4559
4844
|
var init_gl = __esm({
|
|
@@ -4576,7 +4861,7 @@ async function discover() {
|
|
|
4576
4861
|
const plugins = await CoreKit.discoverPlugins(cwd);
|
|
4577
4862
|
if (plugins.length === 0) {
|
|
4578
4863
|
spinner.warn("\u672A\u53D1\u73B0\u4EFB\u4F55\u63D2\u4EF6");
|
|
4579
|
-
|
|
4864
|
+
logger2.info(
|
|
4580
4865
|
pc17.gray("\u8BF7\u786E\u4FDD\u63D2\u4EF6\u5DF2\u88AB\u5DE5\u4F5C\u533A\u914D\u7F6E\u5305\u542B\uFF0C\u4E14\u76EE\u5F55\u4E2D\u5B58\u5728 package.json\u3002")
|
|
4581
4866
|
);
|
|
4582
4867
|
} else {
|
|
@@ -4623,7 +4908,7 @@ async function clean(options) {
|
|
|
4623
4908
|
// 深度清理默认选否,普通清理默认选是
|
|
4624
4909
|
});
|
|
4625
4910
|
if (!confirm) {
|
|
4626
|
-
|
|
4911
|
+
logger2.warn("\u5DF2\u53D6\u6D88\u6E05\u7406");
|
|
4627
4912
|
return;
|
|
4628
4913
|
}
|
|
4629
4914
|
}
|
|
@@ -4648,7 +4933,7 @@ import os3 from "os";
|
|
|
4648
4933
|
import path24 from "path";
|
|
4649
4934
|
import pc18 from "picocolors";
|
|
4650
4935
|
async function bench() {
|
|
4651
|
-
|
|
4936
|
+
logger2.info("\u6B63\u5728\u542F\u52A8 CLI \u6027\u80FD\u57FA\u51C6\u6D4B\u8BD5...");
|
|
4652
4937
|
const results = [];
|
|
4653
4938
|
const tmpDir = path24.join(os3.tmpdir(), `chatbi-bench-${Date.now()}`);
|
|
4654
4939
|
await fs21.ensureDir(tmpDir);
|
|
@@ -4728,14 +5013,14 @@ import { loadESLint } from "eslint";
|
|
|
4728
5013
|
import fs22 from "fs-extra";
|
|
4729
5014
|
import path25 from "path";
|
|
4730
5015
|
async function lintTheme(options) {
|
|
4731
|
-
const projectRoot = findProjectRoot(process.cwd());
|
|
5016
|
+
const projectRoot = await findProjectRoot(process.cwd());
|
|
4732
5017
|
const cwd = projectRoot;
|
|
4733
5018
|
const target = options.target || ".";
|
|
4734
5019
|
const files = [path25.isAbsolute(target) ? target : path25.resolve(cwd, target)];
|
|
4735
5020
|
if (options.debug) {
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
5021
|
+
logger2.info("Starting Theme Lint...");
|
|
5022
|
+
logger2.info(`Target: ${target}`);
|
|
5023
|
+
logger2.info(`Options: ${JSON.stringify(options)}`);
|
|
4739
5024
|
}
|
|
4740
5025
|
try {
|
|
4741
5026
|
const ESLint = await loadESLint({ useFlatConfig: true });
|
|
@@ -4762,11 +5047,11 @@ async function lintTheme(options) {
|
|
|
4762
5047
|
}
|
|
4763
5048
|
]
|
|
4764
5049
|
});
|
|
4765
|
-
|
|
5050
|
+
logger2.info(`Scanning files in ${target} for theme violations...`);
|
|
4766
5051
|
const results = await eslint.lintFiles(files);
|
|
4767
5052
|
if (options.fix) {
|
|
4768
5053
|
await ESLint.outputFixes(results);
|
|
4769
|
-
|
|
5054
|
+
logger2.success("Auto-fixes applied where possible.");
|
|
4770
5055
|
}
|
|
4771
5056
|
const themeRuleIds = [
|
|
4772
5057
|
"@chatbi-v/theme/no-hardcoded-colors",
|
|
@@ -4799,7 +5084,7 @@ async function lintTheme(options) {
|
|
|
4799
5084
|
if (options.output) {
|
|
4800
5085
|
await fs22.ensureDir(path25.dirname(options.output));
|
|
4801
5086
|
await fs22.outputFile(options.output, resultText);
|
|
4802
|
-
|
|
5087
|
+
logger2.success(`Report generated at ${options.output}`);
|
|
4803
5088
|
} else {
|
|
4804
5089
|
console.log(resultText);
|
|
4805
5090
|
}
|
|
@@ -4812,17 +5097,17 @@ async function lintTheme(options) {
|
|
|
4812
5097
|
0
|
|
4813
5098
|
);
|
|
4814
5099
|
if (errorCount > 0) {
|
|
4815
|
-
|
|
5100
|
+
logger2.error(
|
|
4816
5101
|
`Lint failed with ${errorCount} errors and ${warningCount} warnings.`
|
|
4817
5102
|
);
|
|
4818
5103
|
process.exit(1);
|
|
4819
5104
|
} else if (warningCount > 0) {
|
|
4820
|
-
|
|
5105
|
+
logger2.warn(`Lint finished with ${warningCount} warnings.`);
|
|
4821
5106
|
} else {
|
|
4822
|
-
|
|
5107
|
+
logger2.success("Theme lint passed!");
|
|
4823
5108
|
}
|
|
4824
5109
|
} catch (error) {
|
|
4825
|
-
|
|
5110
|
+
logger2.error("An error occurred during linting:", error);
|
|
4826
5111
|
process.exit(1);
|
|
4827
5112
|
}
|
|
4828
5113
|
}
|
|
@@ -4835,7 +5120,7 @@ var init_lint_theme = __esm({
|
|
|
4835
5120
|
importThemePlugin = async () => {
|
|
4836
5121
|
try {
|
|
4837
5122
|
const { createRequire: createRequire3 } = await import("module");
|
|
4838
|
-
const projectRoot = findProjectRoot(process.cwd());
|
|
5123
|
+
const projectRoot = await findProjectRoot(process.cwd());
|
|
4839
5124
|
const pluginPath = path25.resolve(
|
|
4840
5125
|
projectRoot,
|
|
4841
5126
|
"node_modules/@chatbi-v/eslint-plugin-theme"
|
|
@@ -4843,15 +5128,23 @@ var init_lint_theme = __esm({
|
|
|
4843
5128
|
const require2 = createRequire3(import.meta.url);
|
|
4844
5129
|
return require2(pluginPath);
|
|
4845
5130
|
} catch (e) {
|
|
4846
|
-
|
|
5131
|
+
logger2.error("Failed to load @chatbi-v/eslint-plugin-theme", e);
|
|
4847
5132
|
throw e;
|
|
4848
5133
|
}
|
|
4849
5134
|
};
|
|
4850
|
-
findProjectRoot = (startDir) => {
|
|
5135
|
+
findProjectRoot = async (startDir) => {
|
|
4851
5136
|
let current = startDir;
|
|
4852
5137
|
while (current !== path25.dirname(current)) {
|
|
4853
|
-
|
|
5138
|
+
const pkgJsonPath2 = path25.join(current, "package.json");
|
|
5139
|
+
const workspaceYamlPath = path25.join(current, "pnpm-workspace.yaml");
|
|
5140
|
+
try {
|
|
5141
|
+
await Promise.all([
|
|
5142
|
+
fs22.readFile(pkgJsonPath2, "utf-8"),
|
|
5143
|
+
fs22.readFile(workspaceYamlPath, "utf-8")
|
|
5144
|
+
]);
|
|
4854
5145
|
return current;
|
|
5146
|
+
} catch (e) {
|
|
5147
|
+
logger2.debug(`\u67E5\u627E\u9879\u76EE\u6839\u76EE\u5F55\u5931\u8D25: ${e.message}`);
|
|
4855
5148
|
}
|
|
4856
5149
|
current = path25.dirname(current);
|
|
4857
5150
|
}
|
|
@@ -4937,9 +5230,9 @@ async function pluginCreate(options) {
|
|
|
4937
5230
|
data = PluginCreateSchema.parse(validated);
|
|
4938
5231
|
} catch (error) {
|
|
4939
5232
|
if (error instanceof z2.ZodError) {
|
|
4940
|
-
|
|
5233
|
+
logger2.error(`\u9A8C\u8BC1\u5931\u8D25: ${formatZodError(error)}`);
|
|
4941
5234
|
} else {
|
|
4942
|
-
|
|
5235
|
+
logger2.error(`\u9A8C\u8BC1\u5931\u8D25: ${error.message}`);
|
|
4943
5236
|
}
|
|
4944
5237
|
return;
|
|
4945
5238
|
}
|
|
@@ -4947,9 +5240,8 @@ async function pluginCreate(options) {
|
|
|
4947
5240
|
let cliVersion = "3.1.0";
|
|
4948
5241
|
try {
|
|
4949
5242
|
const pkgPath = path26.join(__dirname, "../../../../package.json");
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
}
|
|
5243
|
+
const pkgContent = fs23.readJsonSync(pkgPath);
|
|
5244
|
+
cliVersion = pkgContent.version || cliVersion;
|
|
4953
5245
|
} catch {
|
|
4954
5246
|
}
|
|
4955
5247
|
const pluginData = {
|
|
@@ -4976,21 +5268,21 @@ async function pluginCreate(options) {
|
|
|
4976
5268
|
}
|
|
4977
5269
|
if (fs23.existsSync(targetDir)) {
|
|
4978
5270
|
if (force) {
|
|
4979
|
-
|
|
5271
|
+
logger2.info("\u5F3A\u5236\u8986\u76D6\u6A21\u5F0F\uFF0C\u6E05\u7406\u76EE\u6807\u76EE\u5F55...");
|
|
4980
5272
|
fs23.removeSync(targetDir);
|
|
4981
5273
|
} else {
|
|
4982
5274
|
throw new Error(`\u76EE\u6807\u76EE\u5F55\u5DF2\u5B58\u5728: ${targetDir}`);
|
|
4983
5275
|
}
|
|
4984
5276
|
}
|
|
4985
|
-
|
|
5277
|
+
logger2.info(`
|
|
4986
5278
|
${pc19.bold("\u63D2\u4EF6\u521B\u5EFA\u9884\u89C8")}`);
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
5279
|
+
logger2.info(`\u540D\u79F0: ${pc19.cyan(pluginData.name)}`);
|
|
5280
|
+
logger2.info(`\u6A21\u677F: ${pc19.yellow(templateMeta.name)}`);
|
|
5281
|
+
logger2.info(`TypeScript: ${pc19.yellow(pluginData.typescript ? "\u662F" : "\u5426")}`);
|
|
4990
5282
|
const files = await listGeneratedFiles();
|
|
4991
|
-
|
|
5283
|
+
logger2.info(`
|
|
4992
5284
|
${pc19.bold("\u5C06\u521B\u5EFA\u4EE5\u4E0B\u6587\u4EF6:")}`);
|
|
4993
|
-
files.forEach((f) =>
|
|
5285
|
+
files.forEach((f) => logger2.info(` ${pc19.green("+")} ${f}`));
|
|
4994
5286
|
let confirmed = true;
|
|
4995
5287
|
if (process.stdout.isTTY) {
|
|
4996
5288
|
const response = await prompts5(
|
|
@@ -5017,7 +5309,9 @@ ${pc19.bold("\u5C06\u521B\u5EFA\u4EE5\u4E0B\u6587\u4EF6:")}`);
|
|
|
5017
5309
|
"templates/plugin",
|
|
5018
5310
|
templateMeta.dir || ""
|
|
5019
5311
|
);
|
|
5020
|
-
|
|
5312
|
+
try {
|
|
5313
|
+
await fs23.access(targetTemplateDir);
|
|
5314
|
+
} catch {
|
|
5021
5315
|
throw new Error(`\u6A21\u677F\u76EE\u5F55\u4E0D\u5B58\u5728: ${targetTemplateDir}`);
|
|
5022
5316
|
}
|
|
5023
5317
|
await fs23.ensureDir(targetDir);
|
|
@@ -5041,9 +5335,9 @@ ${pc19.bold("\u5C06\u521B\u5EFA\u4EE5\u4E0B\u6587\u4EF6:")}`);
|
|
|
5041
5335
|
force: true,
|
|
5042
5336
|
silent: true
|
|
5043
5337
|
});
|
|
5044
|
-
|
|
5338
|
+
logger2.success(`
|
|
5045
5339
|
\u63D2\u4EF6 ${pc19.green(pluginData.name)} \u521B\u5EFA\u6210\u529F!`);
|
|
5046
|
-
|
|
5340
|
+
logger2.info(
|
|
5047
5341
|
`\u8BF7\u8FD0\u884C ${pc19.cyan(`cd ${path26.relative(process.cwd(), targetDir)}`)} \u5F00\u59CB\u5F00\u53D1`
|
|
5048
5342
|
);
|
|
5049
5343
|
}
|
|
@@ -5082,7 +5376,11 @@ async function readPluginManifestFile(pluginRoot) {
|
|
|
5082
5376
|
if (!manifestPath) {
|
|
5083
5377
|
return null;
|
|
5084
5378
|
}
|
|
5085
|
-
|
|
5379
|
+
try {
|
|
5380
|
+
return await fs24.readJson(manifestPath);
|
|
5381
|
+
} catch {
|
|
5382
|
+
return null;
|
|
5383
|
+
}
|
|
5086
5384
|
}
|
|
5087
5385
|
async function writePluginManifestFile(pluginRoot, manifest) {
|
|
5088
5386
|
const manifestPath = await findPluginManifestPath(pluginRoot) || path27.join(pluginRoot, "src", "plugin.json");
|
|
@@ -5119,7 +5417,7 @@ async function pluginBuild(options = {}) {
|
|
|
5119
5417
|
const pkgPath = path28.join(cwd, "package.json");
|
|
5120
5418
|
if (!fs25.existsSync(pkgPath)) {
|
|
5121
5419
|
spinner.fail("\u672A\u627E\u5230 package.json");
|
|
5122
|
-
|
|
5420
|
+
logger2.error("\u8BF7\u5728\u63D2\u4EF6\u76EE\u5F55\u4E2D\u8FD0\u884C\u6B64\u547D\u4EE4");
|
|
5123
5421
|
return;
|
|
5124
5422
|
}
|
|
5125
5423
|
const pkg = await fs25.readJson(pkgPath);
|
|
@@ -5129,7 +5427,7 @@ async function pluginBuild(options = {}) {
|
|
|
5129
5427
|
entry = "src/index.tsx";
|
|
5130
5428
|
} else if (!fs25.existsSync(path28.join(cwd, "src/index.ts"))) {
|
|
5131
5429
|
spinner.fail("\u672A\u627E\u5230\u5165\u53E3\u6587\u4EF6");
|
|
5132
|
-
|
|
5430
|
+
logger2.error("\u671F\u671B src/index.ts \u6216 src/index.tsx");
|
|
5133
5431
|
return;
|
|
5134
5432
|
}
|
|
5135
5433
|
const pluginJsonPath = await findPluginManifestPath(cwd);
|
|
@@ -5178,7 +5476,7 @@ async function pluginBuild(options = {}) {
|
|
|
5178
5476
|
esmSpinner.succeed("ESM \u683C\u5F0F\u6784\u5EFA\u5B8C\u6210");
|
|
5179
5477
|
} catch (e) {
|
|
5180
5478
|
esmSpinner.fail("ESM \u683C\u5F0F\u6784\u5EFA\u5931\u8D25");
|
|
5181
|
-
|
|
5479
|
+
logger2.error(`\u6784\u5EFA\u5931\u8D25: ${e.message}`);
|
|
5182
5480
|
return;
|
|
5183
5481
|
}
|
|
5184
5482
|
const iifeSpinner = createSpinner("\u6B63\u5728\u6784\u5EFA IIFE \u683C\u5F0F...").start();
|
|
@@ -5213,7 +5511,7 @@ async function pluginBuild(options = {}) {
|
|
|
5213
5511
|
iifeSpinner.succeed("IIFE \u683C\u5F0F\u6784\u5EFA\u5B8C\u6210");
|
|
5214
5512
|
} catch (e) {
|
|
5215
5513
|
iifeSpinner.fail("IIFE \u683C\u5F0F\u6784\u5EFA\u5931\u8D25");
|
|
5216
|
-
|
|
5514
|
+
logger2.error(`\u6784\u5EFA\u5931\u8D25: ${e.message}`);
|
|
5217
5515
|
return;
|
|
5218
5516
|
}
|
|
5219
5517
|
const distDir = path28.join(cwd, "dist");
|
|
@@ -5226,7 +5524,7 @@ async function pluginBuild(options = {}) {
|
|
|
5226
5524
|
);
|
|
5227
5525
|
}
|
|
5228
5526
|
if (watch) {
|
|
5229
|
-
|
|
5527
|
+
logger2.info(pc20.gray("\u76D1\u542C\u6A21\u5F0F\u5DF2\u5F00\u542F\uFF0C\u6309 Ctrl+C \u505C\u6B62..."));
|
|
5230
5528
|
}
|
|
5231
5529
|
}
|
|
5232
5530
|
var init_build2 = __esm({
|
|
@@ -5289,25 +5587,25 @@ async function pluginDelete(name, options) {
|
|
|
5289
5587
|
const workspaceRoot = await SandboxPath.getWorkspaceRoot(process.cwd());
|
|
5290
5588
|
const pluginDir = await CoreKit.resolvePluginDirectory(workspaceRoot, name);
|
|
5291
5589
|
if (!pluginDir || !fs26.existsSync(pluginDir)) {
|
|
5292
|
-
|
|
5590
|
+
logger2.error(`\u63D2\u4EF6 ${name} \u4E0D\u5B58\u5728`);
|
|
5293
5591
|
return;
|
|
5294
5592
|
}
|
|
5295
5593
|
const manifest = await readPluginManifest(pluginDir);
|
|
5296
5594
|
if (!manifest) {
|
|
5297
|
-
|
|
5595
|
+
logger2.error(`\u65E0\u6CD5\u8BFB\u53D6\u63D2\u4EF6 ${name} \u7684\u5143\u6570\u636E\uFF0C\u8BF7\u68C0\u67E5 plugin.json \u662F\u5426\u5B58\u5728`);
|
|
5298
5596
|
return;
|
|
5299
5597
|
}
|
|
5300
5598
|
const pluginType = manifest.type || "business";
|
|
5301
5599
|
const pluginId = manifest.id || name;
|
|
5302
5600
|
if (isSystemPlugin(pluginType)) {
|
|
5303
|
-
|
|
5304
|
-
|
|
5601
|
+
logger2.error(`\u65E0\u6CD5\u5220\u9664\u7CFB\u7EDF\u63D2\u4EF6 ${name} (type=${pluginType})`);
|
|
5602
|
+
logger2.info("\u7CFB\u7EDF\u63D2\u4EF6\u53D7\u5230\u4FDD\u62A4\uFF0C\u65E0\u6CD5\u5220\u9664");
|
|
5305
5603
|
return;
|
|
5306
5604
|
}
|
|
5307
5605
|
const dependents = await findDependentPlugins(pluginId);
|
|
5308
5606
|
if (dependents.length > 0) {
|
|
5309
|
-
|
|
5310
|
-
|
|
5607
|
+
logger2.warn(`\u4EE5\u4E0B\u63D2\u4EF6\u4F9D\u8D56\u6B64\u63D2\u4EF6: ${dependents.join(", ")}`);
|
|
5608
|
+
logger2.info("\u5220\u9664\u524D\u8BF7\u786E\u4FDD\u8FD9\u4E9B\u63D2\u4EF6\u5DF2\u66F4\u65B0\u6216\u79FB\u9664\u76F8\u5173\u4F9D\u8D56");
|
|
5311
5609
|
}
|
|
5312
5610
|
if (!options.force) {
|
|
5313
5611
|
const { confirm } = await prompts6(
|
|
@@ -5319,24 +5617,24 @@ async function pluginDelete(name, options) {
|
|
|
5319
5617
|
},
|
|
5320
5618
|
{
|
|
5321
5619
|
onCancel: () => {
|
|
5322
|
-
|
|
5620
|
+
logger2.info("\u5DF2\u53D6\u6D88\u5220\u9664");
|
|
5323
5621
|
return;
|
|
5324
5622
|
}
|
|
5325
5623
|
}
|
|
5326
5624
|
);
|
|
5327
5625
|
if (!confirm) {
|
|
5328
|
-
|
|
5626
|
+
logger2.info("\u5DF2\u53D6\u6D88\u5220\u9664");
|
|
5329
5627
|
return;
|
|
5330
5628
|
}
|
|
5331
5629
|
}
|
|
5332
5630
|
try {
|
|
5333
5631
|
await fs26.remove(pluginDir);
|
|
5334
5632
|
} catch (err) {
|
|
5335
|
-
|
|
5633
|
+
logger2.error(`\u5220\u9664\u63D2\u4EF6 ${name} \u5931\u8D25`, err);
|
|
5336
5634
|
return;
|
|
5337
5635
|
}
|
|
5338
|
-
|
|
5339
|
-
|
|
5636
|
+
logger2.success(`\u63D2\u4EF6 ${name} \u5DF2\u5220\u9664`);
|
|
5637
|
+
logger2.info(`\u5DF2\u79FB\u9664: ${path29.relative(workspaceRoot, pluginDir)}`);
|
|
5340
5638
|
}
|
|
5341
5639
|
var init_delete = __esm({
|
|
5342
5640
|
"src/commands/plugin/delete.ts"() {
|
|
@@ -5367,14 +5665,15 @@ async function pluginValidate(options = {}) {
|
|
|
5367
5665
|
};
|
|
5368
5666
|
const spinner = createSpinner("\u6B63\u5728\u9A8C\u8BC1\u63D2\u4EF6\u914D\u7F6E...").start();
|
|
5369
5667
|
const pkgPath = path30.join(cwd, "package.json");
|
|
5370
|
-
|
|
5371
|
-
|
|
5668
|
+
let pkg = {};
|
|
5669
|
+
try {
|
|
5670
|
+
pkg = await fs27.readJson(pkgPath);
|
|
5671
|
+
} catch {
|
|
5672
|
+
spinner.fail("\u672A\u627E\u5230\u6216\u65E0\u6CD5\u8BFB\u53D6 package.json");
|
|
5372
5673
|
result.valid = false;
|
|
5373
|
-
result.errors.push("\u672A\u627E\u5230 package.json");
|
|
5674
|
+
result.errors.push("\u672A\u627E\u5230\u6216\u65E0\u6CD5\u8BFB\u53D6 package.json");
|
|
5374
5675
|
return result;
|
|
5375
5676
|
}
|
|
5376
|
-
spinner.text = "\u6B63\u5728\u8BFB\u53D6\u63D2\u4EF6\u914D\u7F6E...";
|
|
5377
|
-
const pkg = await fs27.readJson(pkgPath);
|
|
5378
5677
|
const pluginJsonPath = await findPluginManifestPath(cwd);
|
|
5379
5678
|
if (!pluginJsonPath) {
|
|
5380
5679
|
spinner.fail("\u672A\u627E\u5230 src/plugin.json");
|
|
@@ -5398,14 +5697,15 @@ async function pluginValidate(options = {}) {
|
|
|
5398
5697
|
fixSpinner.succeed("\u5DF2\u521B\u5EFA src/plugin.json");
|
|
5399
5698
|
result.errors = result.errors.filter((e) => !e.includes("plugin.json"));
|
|
5400
5699
|
} catch (e) {
|
|
5401
|
-
fixSpinner.fail(
|
|
5700
|
+
fixSpinner.fail(`\u521B\u5EFA\u5931\u8D25: ${e.message}`);
|
|
5402
5701
|
}
|
|
5403
5702
|
}
|
|
5404
5703
|
return result;
|
|
5405
5704
|
}
|
|
5406
5705
|
spinner.text = "\u6B63\u5728\u9A8C\u8BC1 Manifest \u683C\u5F0F...";
|
|
5706
|
+
let pluginJson;
|
|
5407
5707
|
try {
|
|
5408
|
-
|
|
5708
|
+
pluginJson = await fs27.readJson(pluginJsonPath);
|
|
5409
5709
|
const validation = validateManifest(pluginJson);
|
|
5410
5710
|
if (!validation.valid || !validation.data) {
|
|
5411
5711
|
spinner.fail("Manifest \u683C\u5F0F\u9A8C\u8BC1\u5931\u8D25");
|
|
@@ -5417,7 +5717,9 @@ async function pluginValidate(options = {}) {
|
|
|
5417
5717
|
}
|
|
5418
5718
|
if (typeof validation.data.entry === "string") {
|
|
5419
5719
|
const entryPath = path30.join(cwd, validation.data.entry);
|
|
5420
|
-
|
|
5720
|
+
try {
|
|
5721
|
+
await fs27.access(entryPath);
|
|
5722
|
+
} catch {
|
|
5421
5723
|
spinner.fail(`\u5165\u53E3\u6587\u4EF6\u4E0D\u5B58\u5728: ${validation.data.entry}`);
|
|
5422
5724
|
result.valid = false;
|
|
5423
5725
|
result.errors.push(`\u5165\u53E3\u6587\u4EF6\u4E0D\u5B58\u5728: ${validation.data.entry}`);
|
|
@@ -5438,7 +5740,9 @@ async function pluginValidate(options = {}) {
|
|
|
5438
5740
|
continue;
|
|
5439
5741
|
}
|
|
5440
5742
|
const depPath = path30.join(nodeModulesPath, dep);
|
|
5441
|
-
|
|
5743
|
+
try {
|
|
5744
|
+
await fs27.access(depPath);
|
|
5745
|
+
} catch {
|
|
5442
5746
|
result.warnings.push(`\u4F9D\u8D56\u672A\u5B89\u88C5: ${dep}@${version}`);
|
|
5443
5747
|
}
|
|
5444
5748
|
}
|
|
@@ -5477,7 +5781,7 @@ __export(publish_exports, {
|
|
|
5477
5781
|
pluginPublish: () => pluginPublish
|
|
5478
5782
|
});
|
|
5479
5783
|
async function pluginPublish(options) {
|
|
5480
|
-
|
|
5784
|
+
logger2.warn("\u63D2\u4EF6\u53D1\u5E03\u529F\u80FD\u6B63\u5728\u5F00\u53D1\u4E2D...");
|
|
5481
5785
|
}
|
|
5482
5786
|
var init_publish = __esm({
|
|
5483
5787
|
"src/commands/plugin/publish.ts"() {
|
|
@@ -5530,7 +5834,7 @@ async function pluginList(options = {}) {
|
|
|
5530
5834
|
const discoveredPlugins = await CoreKit.discoverPlugins(cwd);
|
|
5531
5835
|
if (discoveredPlugins.length === 0) {
|
|
5532
5836
|
spinner.warn("\u672A\u53D1\u73B0\u4EFB\u4F55\u63D2\u4EF6");
|
|
5533
|
-
|
|
5837
|
+
logger2.info(
|
|
5534
5838
|
pc22.gray("\u8BF7\u786E\u4FDD\u63D2\u4EF6\u5DF2\u88AB\u5DE5\u4F5C\u533A\u914D\u7F6E\u5305\u542B\uFF0C\u4E14\u76EE\u5F55\u4E2D\u5B58\u5728 package.json\u3002")
|
|
5535
5839
|
);
|
|
5536
5840
|
return;
|
|
@@ -5634,7 +5938,7 @@ async function resolveVersion(pluginName, pluginDir, version) {
|
|
|
5634
5938
|
throw new Error(`\u65E0\u6CD5\u8BFB\u53D6\u63D2\u4EF6 ${pluginName} \u7684 package.json`);
|
|
5635
5939
|
}
|
|
5636
5940
|
if (satisfiesVersion(packageJson.version, version)) {
|
|
5637
|
-
|
|
5941
|
+
logger2.info(
|
|
5638
5942
|
`\u63D2\u4EF6 ${pluginName} \u5F53\u524D\u7248\u672C ${packageJson.version} \u5DF2\u6EE1\u8DB3\u8303\u56F4 ${version}`
|
|
5639
5943
|
);
|
|
5640
5944
|
return packageJson.version;
|
|
@@ -5703,43 +6007,43 @@ function checkVersionCompatibility(current, target, compatibility) {
|
|
|
5703
6007
|
return { compatible: true, severity: finalSeverity };
|
|
5704
6008
|
}
|
|
5705
6009
|
function showDryRunPreview(pluginName, currentVersion, targetVersion, compatibility, manifest) {
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
|
|
6010
|
+
logger2.info("=".repeat(50));
|
|
6011
|
+
logger2.info(`\u63D2\u4EF6 ${pluginName} \u66F4\u65B0\u9884\u89C8 (dry-run)`);
|
|
6012
|
+
logger2.info("=".repeat(50));
|
|
6013
|
+
logger2.info(`\u5F53\u524D\u7248\u672C: ${currentVersion}`);
|
|
6014
|
+
logger2.info(`\u76EE\u6807\u7248\u672C: ${targetVersion}`);
|
|
6015
|
+
logger2.info("");
|
|
6016
|
+
logger2.info("\u517C\u5BB9\u6027\u68C0\u67E5:");
|
|
5713
6017
|
if (compatibility.compatible) {
|
|
5714
|
-
|
|
6018
|
+
logger2.success(` \u2713 \u517C\u5BB9 (severity: ${compatibility.severity})`);
|
|
5715
6019
|
} else {
|
|
5716
|
-
|
|
6020
|
+
logger2.error(` \u2717 \u4E0D\u517C\u5BB9: ${compatibility.reason}`);
|
|
5717
6021
|
}
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
6022
|
+
logger2.info("");
|
|
6023
|
+
logger2.info("\u5C06\u8981\u66F4\u65B0\u7684\u5B57\u6BB5:");
|
|
6024
|
+
logger2.info(` - version: ${currentVersion} \u2192 ${targetVersion}`);
|
|
5721
6025
|
if (manifest.compatibility) {
|
|
5722
|
-
|
|
6026
|
+
logger2.info(` - compatibility: ${JSON.stringify(manifest.compatibility)}`);
|
|
5723
6027
|
}
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
6028
|
+
logger2.info("");
|
|
6029
|
+
logger2.info("\u6CE8\u610F: \u8FD9\u662F\u9884\u89C8\u6A21\u5F0F\uFF0C\u672A\u6267\u884C\u5B9E\u9645\u66F4\u65B0");
|
|
6030
|
+
logger2.info("=".repeat(50));
|
|
5727
6031
|
}
|
|
5728
6032
|
async function pluginUpdate(name, options = {}) {
|
|
5729
6033
|
const workspaceRoot = await SandboxPath.getWorkspaceRoot(process.cwd());
|
|
5730
6034
|
const pluginDir = await CoreKit.resolvePluginDirectory(workspaceRoot, name);
|
|
5731
6035
|
if (!pluginDir || !fs29.existsSync(pluginDir)) {
|
|
5732
|
-
|
|
6036
|
+
logger2.error(`\u63D2\u4EF6 ${name} \u4E0D\u5B58\u5728`);
|
|
5733
6037
|
return;
|
|
5734
6038
|
}
|
|
5735
6039
|
const manifest = await readPluginManifest3(pluginDir);
|
|
5736
6040
|
if (!manifest) {
|
|
5737
|
-
|
|
6041
|
+
logger2.error(`\u65E0\u6CD5\u8BFB\u53D6\u63D2\u4EF6 ${name} \u7684\u5143\u6570\u636E\uFF0C\u8BF7\u68C0\u67E5 plugin.json \u662F\u5426\u5B58\u5728`);
|
|
5738
6042
|
return;
|
|
5739
6043
|
}
|
|
5740
6044
|
const packageJson = await readPluginPackageJson(pluginDir);
|
|
5741
6045
|
if (!packageJson) {
|
|
5742
|
-
|
|
6046
|
+
logger2.error(`\u65E0\u6CD5\u8BFB\u53D6\u63D2\u4EF6 ${name} \u7684 package.json`);
|
|
5743
6047
|
return;
|
|
5744
6048
|
}
|
|
5745
6049
|
const currentVersion = packageJson.version;
|
|
@@ -5747,11 +6051,11 @@ async function pluginUpdate(name, options = {}) {
|
|
|
5747
6051
|
try {
|
|
5748
6052
|
targetVersion = await resolveVersion(name, pluginDir, options.version);
|
|
5749
6053
|
} catch (err) {
|
|
5750
|
-
|
|
6054
|
+
logger2.error(err.message);
|
|
5751
6055
|
return;
|
|
5752
6056
|
}
|
|
5753
6057
|
if (targetVersion === currentVersion) {
|
|
5754
|
-
|
|
6058
|
+
logger2.info(`\u63D2\u4EF6 ${name} \u5DF2\u662F\u6700\u65B0\u7248\u672C ${currentVersion}`);
|
|
5755
6059
|
return;
|
|
5756
6060
|
}
|
|
5757
6061
|
if (!options.force) {
|
|
@@ -5761,17 +6065,17 @@ async function pluginUpdate(name, options = {}) {
|
|
|
5761
6065
|
manifest.compatibility
|
|
5762
6066
|
);
|
|
5763
6067
|
if (!compatibility.compatible) {
|
|
5764
|
-
|
|
5765
|
-
|
|
6068
|
+
logger2.error(`\u66F4\u65B0\u5931\u8D25: ${compatibility.reason}`);
|
|
6069
|
+
logger2.info("\u4F7F\u7528 --force \u53EF\u7ED5\u8FC7\u517C\u5BB9\u6027\u68C0\u67E5 (\u53EF\u80FD\u5B58\u5728\u98CE\u9669)");
|
|
5766
6070
|
return;
|
|
5767
6071
|
}
|
|
5768
6072
|
if (compatibility.severity === "major") {
|
|
5769
|
-
|
|
6073
|
+
logger2.warn(
|
|
5770
6074
|
`\u8B66\u544A: \u6B64\u66F4\u65B0\u5305\u542B\u7834\u574F\u6027\u53D8\u66F4 (severity: ${compatibility.severity})`
|
|
5771
6075
|
);
|
|
5772
6076
|
}
|
|
5773
6077
|
} else {
|
|
5774
|
-
|
|
6078
|
+
logger2.warn("\u5F3A\u5236\u6A21\u5F0F: \u8DF3\u8FC7\u517C\u5BB9\u6027\u68C0\u67E5");
|
|
5775
6079
|
}
|
|
5776
6080
|
if (options.dryRun) {
|
|
5777
6081
|
const compatibility = checkVersionCompatibility(
|
|
@@ -5795,13 +6099,13 @@ async function pluginUpdate(name, options = {}) {
|
|
|
5795
6099
|
try {
|
|
5796
6100
|
await writePluginManifestFile(pluginDir, updatedManifest);
|
|
5797
6101
|
} catch (err) {
|
|
5798
|
-
|
|
6102
|
+
logger2.error(`\u66F4\u65B0\u63D2\u4EF6 ${name} \u5931\u8D25`, err);
|
|
5799
6103
|
return;
|
|
5800
6104
|
}
|
|
5801
|
-
|
|
5802
|
-
|
|
6105
|
+
logger2.success(`\u63D2\u4EF6 ${name} \u5DF2\u66F4\u65B0`);
|
|
6106
|
+
logger2.info(` ${currentVersion} \u2192 ${targetVersion}`);
|
|
5803
6107
|
if (manifest.compatibility) {
|
|
5804
|
-
|
|
6108
|
+
logger2.info(` \u517C\u5BB9\u6027\u8981\u6C42: ${JSON.stringify(manifest.compatibility)}`);
|
|
5805
6109
|
}
|
|
5806
6110
|
}
|
|
5807
6111
|
var init_update = __esm({
|
|
@@ -5827,8 +6131,12 @@ async function themeCreate(options) {
|
|
|
5827
6131
|
const { name, base = "standard", css = false } = options;
|
|
5828
6132
|
const targetDir = path33.join(process.cwd(), "themes", name);
|
|
5829
6133
|
const baseTheme = BASE_THEMES[base];
|
|
5830
|
-
|
|
5831
|
-
|
|
6134
|
+
if (!baseTheme) {
|
|
6135
|
+
logger2.error(`\u65E0\u6548\u7684\u57FA\u7840\u4E3B\u9898: ${base}\uFF0C\u53EF\u9009\u503C: standard, nebula, glass`);
|
|
6136
|
+
return;
|
|
6137
|
+
}
|
|
6138
|
+
logger2.info(`\u6B63\u5728\u521B\u5EFA\u4E3B\u9898: ${pc23.cyan(name)}`);
|
|
6139
|
+
logger2.info(`\u57FA\u7840\u4E3B\u9898: ${pc23.yellow(baseTheme.name)}`);
|
|
5832
6140
|
await fs30.ensureDir(targetDir);
|
|
5833
6141
|
if (css) {
|
|
5834
6142
|
const cssContent = `:root {
|
|
@@ -5868,7 +6176,7 @@ async function themeCreate(options) {
|
|
|
5868
6176
|
await fs30.writeJson(path33.join(targetDir, "theme.json"), themeJson, {
|
|
5869
6177
|
spaces: 2
|
|
5870
6178
|
});
|
|
5871
|
-
|
|
6179
|
+
logger2.success(`\u4E3B\u9898 ${pc23.green(name)} \u521B\u5EFA\u6210\u529F!`);
|
|
5872
6180
|
}
|
|
5873
6181
|
var BASE_THEMES;
|
|
5874
6182
|
var init_create2 = __esm({
|
|
@@ -5908,13 +6216,24 @@ async function scaffold(options) {
|
|
|
5908
6216
|
typescript = true,
|
|
5909
6217
|
theme = "standard"
|
|
5910
6218
|
} = options;
|
|
6219
|
+
if (name.includes("..") || path34.isAbsolute(name)) {
|
|
6220
|
+
logger2.error(`\u65E0\u6548\u7684\u9879\u76EE\u540D\u79F0: ${name}\uFF0C\u4E0D\u80FD\u5305\u542B\u8DEF\u5F84\u904D\u5386\u5E8F\u5217\u6216\u7EDD\u5BF9\u8DEF\u5F84`);
|
|
6221
|
+
return;
|
|
6222
|
+
}
|
|
5911
6223
|
const targetDir = path34.join(process.cwd(), name);
|
|
5912
|
-
|
|
5913
|
-
|
|
6224
|
+
try {
|
|
6225
|
+
await fs31.access(targetDir);
|
|
6226
|
+
logger2.error(`\u76EE\u5F55 ${name} \u5DF2\u5B58\u5728`);
|
|
6227
|
+
return;
|
|
6228
|
+
} catch {
|
|
6229
|
+
}
|
|
6230
|
+
const templateMeta = TEMPLATES2[template];
|
|
6231
|
+
if (!templateMeta) {
|
|
6232
|
+
logger2.error(`\u65E0\u6548\u7684\u6A21\u677F\u7C7B\u578B: ${template}\uFF0C\u53EF\u9009\u503C: full, minimal, empty`);
|
|
5914
6233
|
return;
|
|
5915
6234
|
}
|
|
5916
|
-
|
|
5917
|
-
|
|
6235
|
+
logger2.info(`\u6B63\u5728\u521B\u5EFA\u9879\u76EE: ${pc24.cyan(name)}`);
|
|
6236
|
+
logger2.info(`\u6A21\u677F: ${pc24.yellow(templateMeta.name)}`);
|
|
5918
6237
|
await fs31.ensureDir(targetDir);
|
|
5919
6238
|
const packageJson = {
|
|
5920
6239
|
name,
|
|
@@ -5955,8 +6274,8 @@ export default defineConfig({
|
|
|
5955
6274
|
`;
|
|
5956
6275
|
await fs31.writeFile(path34.join(targetDir, "vite.config.ts"), viteConfig);
|
|
5957
6276
|
}
|
|
5958
|
-
|
|
5959
|
-
|
|
6277
|
+
logger2.success(`\u9879\u76EE ${pc24.green(name)} \u521B\u5EFA\u6210\u529F!`);
|
|
6278
|
+
logger2.info(`\u8BF7\u8FD0\u884C ${pc24.cyan(`cd ${name} && pnpm install`)} \u5B89\u88C5\u4F9D\u8D56`);
|
|
5960
6279
|
}
|
|
5961
6280
|
var TEMPLATES2;
|
|
5962
6281
|
var init_scaffold = __esm({
|
|
@@ -5990,33 +6309,33 @@ import { execSync } from "child_process";
|
|
|
5990
6309
|
import pc25 from "picocolors";
|
|
5991
6310
|
async function upgrade(targetVersion) {
|
|
5992
6311
|
const currentVersion = package_default.version;
|
|
5993
|
-
|
|
6312
|
+
logger2.info(`\u5F53\u524D\u7248\u672C: ${pc25.cyan(currentVersion)}`);
|
|
5994
6313
|
if (targetVersion) {
|
|
5995
|
-
|
|
6314
|
+
logger2.info(`\u6B63\u5728\u5347\u7EA7\u5230\u7248\u672C: ${pc25.yellow(targetVersion)}`);
|
|
5996
6315
|
try {
|
|
5997
6316
|
execSync(`pnpm add -g @chatbi-v/cli@${targetVersion}`, {
|
|
5998
6317
|
stdio: "inherit"
|
|
5999
6318
|
});
|
|
6000
|
-
|
|
6319
|
+
logger2.success("\u5347\u7EA7\u6210\u529F!");
|
|
6001
6320
|
} catch (error) {
|
|
6002
|
-
|
|
6321
|
+
logger2.error("\u5347\u7EA7\u5931\u8D25", error);
|
|
6003
6322
|
}
|
|
6004
6323
|
} else {
|
|
6005
|
-
|
|
6324
|
+
logger2.info("\u6B63\u5728\u68C0\u67E5\u6700\u65B0\u7248\u672C...");
|
|
6006
6325
|
try {
|
|
6007
6326
|
const latestVersion = execSync("npm view @chatbi-v/cli version", {
|
|
6008
6327
|
encoding: "utf-8"
|
|
6009
6328
|
}).trim();
|
|
6010
6329
|
if (latestVersion > currentVersion) {
|
|
6011
|
-
|
|
6012
|
-
|
|
6330
|
+
logger2.info(`\u6700\u65B0\u7248\u672C: ${pc25.green(latestVersion)}`);
|
|
6331
|
+
logger2.info(
|
|
6013
6332
|
`\u8BF7\u8FD0\u884C ${pc25.cyan(`pnpm add -g @chatbi-v/cli@${latestVersion}`)} \u5347\u7EA7`
|
|
6014
6333
|
);
|
|
6015
6334
|
} else {
|
|
6016
|
-
|
|
6335
|
+
logger2.success("\u5F53\u524D\u5DF2\u662F\u6700\u65B0\u7248\u672C!");
|
|
6017
6336
|
}
|
|
6018
6337
|
} catch {
|
|
6019
|
-
|
|
6338
|
+
logger2.warn("\u65E0\u6CD5\u68C0\u67E5\u6700\u65B0\u7248\u672C");
|
|
6020
6339
|
}
|
|
6021
6340
|
}
|
|
6022
6341
|
}
|
|
@@ -6042,16 +6361,22 @@ async function devtoolsTypes(options) {
|
|
|
6042
6361
|
const { input = "src/plugin.json", output, type = "full" } = options;
|
|
6043
6362
|
const inputPath = path35.resolve(process.cwd(), input);
|
|
6044
6363
|
if (!fs32.existsSync(inputPath)) {
|
|
6045
|
-
|
|
6364
|
+
logger2.error(`\u627E\u4E0D\u5230 plugin.json \u6587\u4EF6: ${inputPath}`);
|
|
6046
6365
|
return;
|
|
6047
6366
|
}
|
|
6048
|
-
|
|
6367
|
+
logger2.info(`\u8BFB\u53D6\u63D2\u4EF6\u6E05\u5355: ${pc26.cyan(inputPath)}`);
|
|
6049
6368
|
try {
|
|
6050
|
-
|
|
6369
|
+
let pluginJson;
|
|
6370
|
+
try {
|
|
6371
|
+
pluginJson = await fs32.readJson(inputPath);
|
|
6372
|
+
} catch {
|
|
6373
|
+
logger2.error(`\u8BFB\u53D6 plugin.json \u5931\u8D25: ${inputPath}`);
|
|
6374
|
+
return;
|
|
6375
|
+
}
|
|
6051
6376
|
const validation = validateManifest2(pluginJson);
|
|
6052
6377
|
if (!validation.valid || !validation.data) {
|
|
6053
6378
|
validation.errors?.forEach((error) => {
|
|
6054
|
-
|
|
6379
|
+
logger2.error(`[${error.path.join(".")}] ${error.message}`);
|
|
6055
6380
|
});
|
|
6056
6381
|
return;
|
|
6057
6382
|
}
|
|
@@ -6061,12 +6386,12 @@ async function devtoolsTypes(options) {
|
|
|
6061
6386
|
const outputPath = path35.resolve(process.cwd(), output);
|
|
6062
6387
|
await fs32.ensureDir(path35.dirname(outputPath));
|
|
6063
6388
|
await fs32.writeFile(outputPath, typeCode, "utf-8");
|
|
6064
|
-
|
|
6389
|
+
logger2.success(`\u7C7B\u578B\u5B9A\u4E49\u5DF2\u751F\u6210: ${pc26.green(outputPath)}`);
|
|
6065
6390
|
} else {
|
|
6066
6391
|
console.log(typeCode);
|
|
6067
6392
|
}
|
|
6068
6393
|
} catch (error) {
|
|
6069
|
-
|
|
6394
|
+
logger2.error("\u751F\u6210\u7C7B\u578B\u5B9A\u4E49\u5931\u8D25", error);
|
|
6070
6395
|
}
|
|
6071
6396
|
}
|
|
6072
6397
|
function generateTypeDefinition(manifest, type) {
|
|
@@ -6197,17 +6522,17 @@ __export(diagnose_exports, {
|
|
|
6197
6522
|
import pc27 from "picocolors";
|
|
6198
6523
|
async function diagnose(options = {}) {
|
|
6199
6524
|
const cwd = process.cwd();
|
|
6200
|
-
|
|
6525
|
+
logger2.info("\u6B63\u5728\u6267\u884C\u6C99\u7BB1\u8BCA\u65AD...\n");
|
|
6201
6526
|
try {
|
|
6202
6527
|
const version = await Sandbox.resolveVersion("current");
|
|
6203
|
-
|
|
6528
|
+
logger2.info(`\u5F53\u524D\u5185\u6838\u7248\u672C: ${pc27.cyan(version)}
|
|
6204
6529
|
`);
|
|
6205
6530
|
const diagnostics = new SandboxDiagnostics(version, cwd);
|
|
6206
6531
|
const result = await diagnostics.runAllDiagnostics();
|
|
6207
|
-
|
|
6532
|
+
logger2.info(SandboxDiagnostics.formatResults(result));
|
|
6208
6533
|
const fixableIssues = SandboxDiagnostics.getFixableIssues(result);
|
|
6209
6534
|
if (fixableIssues.length > 0) {
|
|
6210
|
-
|
|
6535
|
+
logger2.info("");
|
|
6211
6536
|
const suggestions = fixableIssues.map(
|
|
6212
6537
|
(issue) => ` ${pc27.red("\u2022")} ${pc27.bold(issue.title)}
|
|
6213
6538
|
${pc27.gray(issue.description)}
|
|
@@ -6221,23 +6546,23 @@ ${suggestions}`,
|
|
|
6221
6546
|
);
|
|
6222
6547
|
}
|
|
6223
6548
|
if (options.fix && fixableIssues.length > 0) {
|
|
6224
|
-
|
|
6549
|
+
logger2.info(pc27.bold("\n\u6B63\u5728\u6267\u884C\u81EA\u52A8\u4FEE\u590D...\n"));
|
|
6225
6550
|
const { sync: sync2 } = await Promise.resolve().then(() => (init_sync(), sync_exports));
|
|
6226
6551
|
for (const issue of fixableIssues) {
|
|
6227
6552
|
if (issue.fixCommand?.startsWith("chatbi sync")) {
|
|
6228
|
-
|
|
6553
|
+
logger2.info(`${pc27.cyan("\u2192")} \u6267\u884C: ${issue.fixCommand}`);
|
|
6229
6554
|
try {
|
|
6230
6555
|
await sync2({ force: true });
|
|
6231
|
-
|
|
6556
|
+
logger2.success(`\u4FEE\u590D\u5B8C\u6210: ${issue.title}`);
|
|
6232
6557
|
} catch (e) {
|
|
6233
|
-
|
|
6558
|
+
logger2.error(`\u4FEE\u590D\u5931\u8D25: ${e.message}`);
|
|
6234
6559
|
}
|
|
6235
6560
|
}
|
|
6236
6561
|
}
|
|
6237
6562
|
}
|
|
6238
6563
|
return result;
|
|
6239
6564
|
} catch (e) {
|
|
6240
|
-
|
|
6565
|
+
logger2.error(`\u8BCA\u65AD\u5931\u8D25: ${e.message}`);
|
|
6241
6566
|
throw e;
|
|
6242
6567
|
}
|
|
6243
6568
|
}
|
|
@@ -6263,19 +6588,19 @@ import pc28 from "picocolors";
|
|
|
6263
6588
|
async function update(options = {}) {
|
|
6264
6589
|
const { force = true, clean: clean2 = false, version } = options;
|
|
6265
6590
|
const cwd = process.cwd();
|
|
6266
|
-
|
|
6591
|
+
logger2.info(pc28.bold("\u6C99\u7BB1\u66F4\u65B0\u5DE5\u5177\n"));
|
|
6267
6592
|
try {
|
|
6268
6593
|
const targetVersion = version || await Sandbox.resolveVersion("latest");
|
|
6269
|
-
|
|
6594
|
+
logger2.info(`\u76EE\u6807\u7248\u672C: ${pc28.cyan(targetVersion)}`);
|
|
6270
6595
|
const currentVersion = await Sandbox.resolveVersion("current");
|
|
6271
6596
|
if (currentVersion !== targetVersion) {
|
|
6272
|
-
|
|
6597
|
+
logger2.info(
|
|
6273
6598
|
`\u5F53\u524D\u7248\u672C: ${pc28.yellow(currentVersion)} \u2192 ${pc28.cyan(targetVersion)}`
|
|
6274
6599
|
);
|
|
6275
6600
|
} else {
|
|
6276
|
-
|
|
6601
|
+
logger2.info(`\u5F53\u524D\u7248\u672C: ${pc28.green(currentVersion)} (\u5DF2\u662F\u6700\u65B0)`);
|
|
6277
6602
|
}
|
|
6278
|
-
|
|
6603
|
+
logger2.info("");
|
|
6279
6604
|
if (clean2) {
|
|
6280
6605
|
const spinner2 = createSpinner("\u6B63\u5728\u6E05\u7406\u65E7\u7248\u672C...").start();
|
|
6281
6606
|
try {
|
|
@@ -6284,7 +6609,7 @@ async function update(options = {}) {
|
|
|
6284
6609
|
} catch (e) {
|
|
6285
6610
|
spinner2.fail(`\u6E05\u7406\u5931\u8D25: ${e.message}`);
|
|
6286
6611
|
}
|
|
6287
|
-
|
|
6612
|
+
logger2.info("");
|
|
6288
6613
|
}
|
|
6289
6614
|
const spinner = createSpinner(`\u6B63\u5728\u66F4\u65B0\u6C99\u7BB1\u5230 ${targetVersion}...`).start();
|
|
6290
6615
|
try {
|
|
@@ -6294,22 +6619,22 @@ async function update(options = {}) {
|
|
|
6294
6619
|
spinner.fail(`\u6C99\u7BB1\u66F4\u65B0\u5931\u8D25: ${e.message}`);
|
|
6295
6620
|
throw e;
|
|
6296
6621
|
}
|
|
6297
|
-
|
|
6298
|
-
|
|
6622
|
+
logger2.info("");
|
|
6623
|
+
logger2.info(pc28.bold("\u9A8C\u8BC1\u5B89\u88C5...\n"));
|
|
6299
6624
|
const diagnostics = new (await Promise.resolve().then(() => (init_SandboxDiagnostics(), SandboxDiagnostics_exports))).SandboxDiagnostics(targetVersion, cwd);
|
|
6300
6625
|
const result = await diagnostics.runAllDiagnostics();
|
|
6301
6626
|
if (result.passed) {
|
|
6302
|
-
|
|
6627
|
+
logger2.success("\u5B89\u88C5\u9A8C\u8BC1\u901A\u8FC7");
|
|
6303
6628
|
} else {
|
|
6304
|
-
|
|
6629
|
+
logger2.warn(
|
|
6305
6630
|
`\u5B89\u88C5\u9A8C\u8BC1\u53D1\u73B0\u95EE\u9898 ${result.errorCount} \u4E2A\uFF0C\u5EFA\u8BAE\u8FD0\u884C ${pc28.cyan("chatbi sandbox diagnose")} \u67E5\u770B\u8BE6\u60C5`
|
|
6306
6631
|
);
|
|
6307
6632
|
}
|
|
6308
|
-
|
|
6309
|
-
|
|
6633
|
+
logger2.info("");
|
|
6634
|
+
logger2.success(pc28.green("\u2728 \u6C99\u7BB1\u66F4\u65B0\u5B8C\u6210\uFF01"));
|
|
6310
6635
|
return { version: targetVersion, success: true };
|
|
6311
6636
|
} catch (e) {
|
|
6312
|
-
|
|
6637
|
+
logger2.error(`\u66F4\u65B0\u5931\u8D25: ${e.message}`);
|
|
6313
6638
|
throw e;
|
|
6314
6639
|
}
|
|
6315
6640
|
}
|
|
@@ -6333,6 +6658,7 @@ var init_ModuleResolver = __esm({
|
|
|
6333
6658
|
"src/sandbox/ModuleResolver.ts"() {
|
|
6334
6659
|
"use strict";
|
|
6335
6660
|
init_esm_shims();
|
|
6661
|
+
init_utils();
|
|
6336
6662
|
init_SandboxPath();
|
|
6337
6663
|
ModuleResolver = class {
|
|
6338
6664
|
projectRoot;
|
|
@@ -6367,15 +6693,14 @@ var init_ModuleResolver = __esm({
|
|
|
6367
6693
|
".chatbi",
|
|
6368
6694
|
"resolution.json"
|
|
6369
6695
|
);
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
this.config
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
}
|
|
6696
|
+
try {
|
|
6697
|
+
const config4 = fs33.readJsonSync(resolutionPath);
|
|
6698
|
+
this.config = {
|
|
6699
|
+
...this.config,
|
|
6700
|
+
...config4
|
|
6701
|
+
};
|
|
6702
|
+
} catch (e) {
|
|
6703
|
+
logger2.debug(`\u52A0\u8F7D resolution.json \u5931\u8D25: ${e.message}`);
|
|
6379
6704
|
}
|
|
6380
6705
|
}
|
|
6381
6706
|
/**
|
|
@@ -6387,12 +6712,13 @@ var init_ModuleResolver = __esm({
|
|
|
6387
6712
|
const pkgPath = path36.join(this.sandboxNodeModules, name);
|
|
6388
6713
|
let actualVersion = overrideVersion;
|
|
6389
6714
|
try {
|
|
6390
|
-
const
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6715
|
+
const pkgJsonPath2 = path36.join(pkgPath, "package.json");
|
|
6716
|
+
const pkg = await fs33.readJson(pkgJsonPath2);
|
|
6717
|
+
actualVersion = pkg.version || overrideVersion;
|
|
6718
|
+
} catch (e) {
|
|
6719
|
+
logger2.debug(
|
|
6720
|
+
`\u8BFB\u53D6 package.json \u5931\u8D25: ${pkgJsonPath}: ${e.message}`
|
|
6721
|
+
);
|
|
6396
6722
|
}
|
|
6397
6723
|
return {
|
|
6398
6724
|
name,
|
|
@@ -6470,12 +6796,9 @@ var init_ModuleResolver = __esm({
|
|
|
6470
6796
|
*/
|
|
6471
6797
|
async checkInLocation(name, nodeModulesPath, source) {
|
|
6472
6798
|
const pkgPath = path36.join(nodeModulesPath, name);
|
|
6473
|
-
const
|
|
6474
|
-
if (!fs33.existsSync(pkgJsonPath)) {
|
|
6475
|
-
return null;
|
|
6476
|
-
}
|
|
6799
|
+
const pkgJsonPath2 = path36.join(pkgPath, "package.json");
|
|
6477
6800
|
try {
|
|
6478
|
-
const pkg = await fs33.readJson(
|
|
6801
|
+
const pkg = await fs33.readJson(pkgJsonPath2);
|
|
6479
6802
|
return {
|
|
6480
6803
|
name,
|
|
6481
6804
|
version: pkg.version || "unknown",
|
|
@@ -6483,7 +6806,8 @@ var init_ModuleResolver = __esm({
|
|
|
6483
6806
|
source,
|
|
6484
6807
|
isConflicted: false
|
|
6485
6808
|
};
|
|
6486
|
-
} catch {
|
|
6809
|
+
} catch (e) {
|
|
6810
|
+
logger2.debug(`\u68C0\u67E5\u5305\u4F4D\u7F6E\u5931\u8D25: ${name}: ${e.message}`);
|
|
6487
6811
|
return null;
|
|
6488
6812
|
}
|
|
6489
6813
|
}
|
|
@@ -6530,15 +6854,13 @@ var init_ModuleResolver = __esm({
|
|
|
6530
6854
|
* 列出 node_modules 中的包
|
|
6531
6855
|
*/
|
|
6532
6856
|
async listPackages(nodeModulesPath) {
|
|
6533
|
-
if (!fs33.existsSync(nodeModulesPath)) {
|
|
6534
|
-
return [];
|
|
6535
|
-
}
|
|
6536
6857
|
try {
|
|
6537
6858
|
const entries = await fs33.readdir(nodeModulesPath, {
|
|
6538
6859
|
withFileTypes: true
|
|
6539
6860
|
});
|
|
6540
6861
|
return entries.filter((e) => e.isDirectory() && !e.name.startsWith(".")).map((e) => e.name);
|
|
6541
|
-
} catch {
|
|
6862
|
+
} catch (e) {
|
|
6863
|
+
logger2.debug(`\u5217\u51FA\u5305\u5931\u8D25: ${nodeModulesPath}: ${e.message}`);
|
|
6542
6864
|
return [];
|
|
6543
6865
|
}
|
|
6544
6866
|
}
|
|
@@ -6550,8 +6872,13 @@ var init_ModuleResolver = __esm({
|
|
|
6550
6872
|
if (!result.path) {
|
|
6551
6873
|
return false;
|
|
6552
6874
|
}
|
|
6553
|
-
const
|
|
6554
|
-
|
|
6875
|
+
const pkgJsonPath2 = path36.join(result.path, "package.json");
|
|
6876
|
+
try {
|
|
6877
|
+
const stats = fs33.statSync(pkgJsonPath2);
|
|
6878
|
+
return stats.isFile();
|
|
6879
|
+
} catch {
|
|
6880
|
+
return false;
|
|
6881
|
+
}
|
|
6555
6882
|
}
|
|
6556
6883
|
/**
|
|
6557
6884
|
* 格式化解析结果
|
|
@@ -6583,12 +6910,12 @@ __export(resolve_exports, {
|
|
|
6583
6910
|
import pc30 from "picocolors";
|
|
6584
6911
|
async function resolve(packageName, options = {}) {
|
|
6585
6912
|
if (!packageName) {
|
|
6586
|
-
|
|
6587
|
-
|
|
6913
|
+
logger2.error("\u8BF7\u6307\u5B9A\u8981\u89E3\u6790\u7684\u5305\u540D");
|
|
6914
|
+
logger2.info("\u7528\u6CD5: chatbi sandbox resolve <pkg>");
|
|
6588
6915
|
return;
|
|
6589
6916
|
}
|
|
6590
6917
|
const cwd = process.cwd();
|
|
6591
|
-
|
|
6918
|
+
logger2.info(`\u6B63\u5728\u89E3\u6790\u5305: ${pc30.cyan(packageName)}
|
|
6592
6919
|
`);
|
|
6593
6920
|
try {
|
|
6594
6921
|
const version = await Sandbox.resolveVersion("current");
|
|
@@ -6605,54 +6932,54 @@ async function resolve(packageName, options = {}) {
|
|
|
6605
6932
|
unknown: pc30.gray
|
|
6606
6933
|
};
|
|
6607
6934
|
const colorFn = sourceColors[result.source] || pc30.gray;
|
|
6608
|
-
|
|
6935
|
+
logger2.info(
|
|
6609
6936
|
"\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557"
|
|
6610
6937
|
);
|
|
6611
|
-
|
|
6938
|
+
logger2.info(
|
|
6612
6939
|
"\u2551 Package Resolution \u2551"
|
|
6613
6940
|
);
|
|
6614
|
-
|
|
6941
|
+
logger2.info(
|
|
6615
6942
|
"\u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563"
|
|
6616
6943
|
);
|
|
6617
|
-
|
|
6618
|
-
|
|
6944
|
+
logger2.info(`\u2551 \u5305\u540D: ${pc30.cyan(result.name.padEnd(52))}\u2551`);
|
|
6945
|
+
logger2.info(
|
|
6619
6946
|
`\u2551 \u7248\u672C: ${(result.version ? pc30.green(result.version) : pc30.red("\u672A\u627E\u5230")).padEnd(52)}\u2551`
|
|
6620
6947
|
);
|
|
6621
|
-
|
|
6622
|
-
|
|
6948
|
+
logger2.info(`\u2551 \u6765\u6E90: ${colorFn(result.source.padEnd(52))}\u2551`);
|
|
6949
|
+
logger2.info(
|
|
6623
6950
|
"\u2551 \u2551"
|
|
6624
6951
|
);
|
|
6625
|
-
|
|
6952
|
+
logger2.info(`\u2551 \u8DEF\u5F84:`);
|
|
6626
6953
|
const pathLines = wrapText(result.path || "\u672A\u627E\u5230", 56);
|
|
6627
6954
|
for (const line of pathLines) {
|
|
6628
|
-
|
|
6955
|
+
logger2.info(`\u2551 ${pc30.gray(line.padEnd(56))}\u2551`);
|
|
6629
6956
|
}
|
|
6630
|
-
|
|
6957
|
+
logger2.info(
|
|
6631
6958
|
"\u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563"
|
|
6632
6959
|
);
|
|
6633
6960
|
if (result.isConflicted) {
|
|
6634
|
-
|
|
6635
|
-
|
|
6961
|
+
logger2.info(`\u2551 ${pc30.yellow("\u26A0\uFE0F \u5B58\u5728\u51B2\u7A81").padEnd(57)}\u2551`);
|
|
6962
|
+
logger2.info(
|
|
6636
6963
|
"\u2551 \u2551"
|
|
6637
6964
|
);
|
|
6638
6965
|
if (result.conflictDescription) {
|
|
6639
6966
|
const descLines = wrapText(result.conflictDescription, 56);
|
|
6640
6967
|
for (const line of descLines) {
|
|
6641
|
-
|
|
6968
|
+
logger2.info(`\u2551 ${line.padEnd(57)}\u2551`);
|
|
6642
6969
|
}
|
|
6643
6970
|
}
|
|
6644
6971
|
} else {
|
|
6645
|
-
|
|
6972
|
+
logger2.info(`\u2551 ${pc30.green("\u2713 \u65E0\u51B2\u7A81").padEnd(57)}\u2551`);
|
|
6646
6973
|
}
|
|
6647
|
-
|
|
6974
|
+
logger2.info(
|
|
6648
6975
|
"\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D"
|
|
6649
6976
|
);
|
|
6650
6977
|
if (options.conflicts) {
|
|
6651
|
-
|
|
6652
|
-
|
|
6978
|
+
logger2.info("");
|
|
6979
|
+
logger2.info(pc30.bold("\u68C0\u6D4B\u6240\u6709\u5305\u51B2\u7A81...\n"));
|
|
6653
6980
|
const conflicts = await resolver.detectConflicts();
|
|
6654
6981
|
if (conflicts.length === 0) {
|
|
6655
|
-
|
|
6982
|
+
logger2.success("\u672A\u68C0\u6D4B\u5230\u7248\u672C\u51B2\u7A81");
|
|
6656
6983
|
} else {
|
|
6657
6984
|
printBox(
|
|
6658
6985
|
conflicts.map(
|
|
@@ -6664,7 +6991,7 @@ async function resolve(packageName, options = {}) {
|
|
|
6664
6991
|
}
|
|
6665
6992
|
return result;
|
|
6666
6993
|
} catch (e) {
|
|
6667
|
-
|
|
6994
|
+
logger2.error(`\u89E3\u6790\u5931\u8D25: ${e.message}`);
|
|
6668
6995
|
throw e;
|
|
6669
6996
|
}
|
|
6670
6997
|
}
|
|
@@ -6714,8 +7041,8 @@ import pc31 from "picocolors";
|
|
|
6714
7041
|
var cli = cac("chatbi-cli");
|
|
6715
7042
|
var showHeader = () => {
|
|
6716
7043
|
const title = figlet.textSync("ChatBI-V CLI", { font: "Standard" });
|
|
6717
|
-
|
|
6718
|
-
|
|
7044
|
+
logger2.info(gradient.pastel.multiline(title));
|
|
7045
|
+
logger2.info(
|
|
6719
7046
|
boxen2(pc31.cyan(`ChatBI-V \u7EDF\u4E00\u5F00\u53D1\u5DE5\u5177 v${package_default.version}`), {
|
|
6720
7047
|
padding: 0,
|
|
6721
7048
|
margin: { top: 1, bottom: 1 },
|
|
@@ -6732,13 +7059,13 @@ var wrapAction = (action, commandName) => {
|
|
|
6732
7059
|
const options = args[args.length - 1];
|
|
6733
7060
|
if (options && options.debug) {
|
|
6734
7061
|
setDebugMode(true);
|
|
6735
|
-
|
|
7062
|
+
logger2.debug("Debug mode enabled");
|
|
6736
7063
|
}
|
|
6737
7064
|
showHeader();
|
|
6738
7065
|
try {
|
|
6739
7066
|
await action(...args);
|
|
6740
7067
|
} catch (e) {
|
|
6741
|
-
|
|
7068
|
+
logger2.error(`${commandName} \u6267\u884C\u5931\u8D25`, e);
|
|
6742
7069
|
process.exit(1);
|
|
6743
7070
|
} finally {
|
|
6744
7071
|
const latestVersion = await updateCheckPromise;
|
|
@@ -6802,7 +7129,7 @@ cli.command("update [targetVersion]", "\u66F4\u65B0\u5185\u6838\u7248\u672C").al
|
|
|
6802
7129
|
wrapAction(async (targetVersion) => {
|
|
6803
7130
|
const { sync: sync2 } = await Promise.resolve().then(() => (init_sync(), sync_exports));
|
|
6804
7131
|
await sync2({ version: targetVersion, force: true });
|
|
6805
|
-
|
|
7132
|
+
logger2.success("\u66F4\u65B0\u5B8C\u6210\uFF01");
|
|
6806
7133
|
}, "update")
|
|
6807
7134
|
);
|
|
6808
7135
|
cli.command("sync", "\u540C\u6B65\u5185\u6838\u4F9D\u8D56\u4E0E\u89C4\u8303").alias("s").option("-v, --core-version <version>", "\u6307\u5B9A\u5185\u6838\u7248\u672C").option("-f, --force", "\u5F3A\u5236\u91CD\u65B0\u521D\u59CB\u5316\u5185\u6838\u6C99\u7BB1").option("--clean", "\u6E05\u7406\u5E76\u91CD\u7F6E\u6C99\u7BB1").action(
|
|
@@ -6810,7 +7137,7 @@ cli.command("sync", "\u540C\u6B65\u5185\u6838\u4F9D\u8D56\u4E0E\u89C4\u8303").al
|
|
|
6810
7137
|
const { sync: sync2 } = await Promise.resolve().then(() => (init_sync(), sync_exports));
|
|
6811
7138
|
const { doctor: doctor2 } = await Promise.resolve().then(() => (init_doctor(), doctor_exports));
|
|
6812
7139
|
await sync2({ ...options, version: options.coreVersion });
|
|
6813
|
-
|
|
7140
|
+
logger2.info("");
|
|
6814
7141
|
await doctor2({ fix: false });
|
|
6815
7142
|
}, "sync")
|
|
6816
7143
|
);
|
|
@@ -6962,14 +7289,14 @@ cli.command("devtools types", "\u4ECE plugin.json \u751F\u6210 TypeScript \u7C7B
|
|
|
6962
7289
|
}, "devtools types")
|
|
6963
7290
|
);
|
|
6964
7291
|
cli.command("sandbox", "\u6C99\u7BB1\u7BA1\u7406\u547D\u4EE4").action(() => {
|
|
6965
|
-
|
|
7292
|
+
logger2.warn(
|
|
6966
7293
|
"\u8BF7\u4F7F\u7528 sandbox \u5B50\u547D\u4EE4: sandbox-diagnose, sandbox-update, sandbox-resolve"
|
|
6967
7294
|
);
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
7295
|
+
logger2.info("\u7528\u6CD5: chatbi <\u5B50\u547D\u4EE4>");
|
|
7296
|
+
logger2.info("\u5B50\u547D\u4EE4:");
|
|
7297
|
+
logger2.info(" sandbox-diagnose - \u8BCA\u65AD\u6C99\u7BB1\u95EE\u9898");
|
|
7298
|
+
logger2.info(" sandbox-update - \u66F4\u65B0\u6C99\u7BB1");
|
|
7299
|
+
logger2.info(" sandbox-resolve - \u89E3\u6790\u5305\u7248\u672C");
|
|
6973
7300
|
});
|
|
6974
7301
|
cli.command("sandbox-diagnose", "\u8BCA\u65AD\u6C99\u7BB1\u73AF\u5883\u95EE\u9898\u5E76\u63D0\u4F9B\u4FEE\u590D\u5EFA\u8BAE").option("--fix", "\u81EA\u52A8\u4FEE\u590D\u53D1\u73B0\u7684\u95EE\u9898").option("--verbose", "\u663E\u793A\u8BE6\u7EC6\u4FE1\u606F").action(
|
|
6975
7302
|
wrapAction(async (options) => {
|