@chatbi-v/cli 1.0.13 → 2.0.1
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 +174 -90
- package/package.json +7 -7
- package/templates/app/package.json.hbs +5 -2
- package/templates/monorepo/package.json.hbs +2 -2
- package/templates/plugin/package.json.hbs +5 -2
- package/dist/app/.env +0 -8
- package/dist/app/.env.hbs +0 -8
- package/dist/default/.gitignore.hbs +0 -3
- package/dist/monorepo/.gitignore.hbs +0 -3
package/dist/index.js
CHANGED
|
@@ -6250,7 +6250,7 @@ var init_sandbox = __esm({
|
|
|
6250
6250
|
Sandbox = class _Sandbox {
|
|
6251
6251
|
static BASE_DIR = import_path2.default.join(import_os.default.homedir(), ".chatbi-v-core");
|
|
6252
6252
|
/**
|
|
6253
|
-
* 核心依赖清单
|
|
6253
|
+
* 核心依赖清单 (由 CLI 统一管控,项目中零显式依赖)
|
|
6254
6254
|
*/
|
|
6255
6255
|
static CORE_PACKAGES = [
|
|
6256
6256
|
"@chatbi-v/core",
|
|
@@ -6261,6 +6261,21 @@ var init_sandbox = __esm({
|
|
|
6261
6261
|
"@chatbi-v/plugin-layout-transform",
|
|
6262
6262
|
"@chatbi-v/plugin-system-monitor"
|
|
6263
6263
|
];
|
|
6264
|
+
/**
|
|
6265
|
+
* 沙箱运行时必要的公共依赖 (安装在沙箱中供 Shell 运行或提供类型)
|
|
6266
|
+
*/
|
|
6267
|
+
static RUNTIME_DEPS = [
|
|
6268
|
+
"@ant-design/x",
|
|
6269
|
+
"@ant-design/icons",
|
|
6270
|
+
"antd",
|
|
6271
|
+
"react",
|
|
6272
|
+
"react-dom",
|
|
6273
|
+
"lucide-react",
|
|
6274
|
+
"framer-motion",
|
|
6275
|
+
"clsx",
|
|
6276
|
+
"tailwind-merge",
|
|
6277
|
+
"vite"
|
|
6278
|
+
];
|
|
6264
6279
|
/**
|
|
6265
6280
|
* 获取沙箱根目录
|
|
6266
6281
|
*/
|
|
@@ -6288,6 +6303,15 @@ var init_sandbox = __esm({
|
|
|
6288
6303
|
if (version) return version;
|
|
6289
6304
|
}
|
|
6290
6305
|
}
|
|
6306
|
+
try {
|
|
6307
|
+
const cliRoot = await getCliRoot();
|
|
6308
|
+
const cliVersionFile = import_path2.default.join(cliRoot, ".chatbi-version");
|
|
6309
|
+
if (import_fs_extra2.default.existsSync(cliVersionFile)) {
|
|
6310
|
+
const version = (await import_fs_extra2.default.readFile(cliVersionFile, "utf-8")).trim();
|
|
6311
|
+
if (version) return version;
|
|
6312
|
+
}
|
|
6313
|
+
} catch (e) {
|
|
6314
|
+
}
|
|
6291
6315
|
const currentLinkPath = import_path2.default.join(this.BASE_DIR, "versions", "current");
|
|
6292
6316
|
if (import_fs_extra2.default.existsSync(currentLinkPath)) {
|
|
6293
6317
|
try {
|
|
@@ -6380,25 +6404,33 @@ var init_sandbox = __esm({
|
|
|
6380
6404
|
for (const pkgName of _Sandbox.CORE_PACKAGES) {
|
|
6381
6405
|
rootPkgJson.dependencies[pkgName] = version;
|
|
6382
6406
|
}
|
|
6407
|
+
for (const pkgName of _Sandbox.RUNTIME_DEPS) {
|
|
6408
|
+
if (!rootPkgJson.dependencies[pkgName]) {
|
|
6409
|
+
rootPkgJson.dependencies[pkgName] = "latest";
|
|
6410
|
+
}
|
|
6411
|
+
}
|
|
6412
|
+
rootPkgJson.dependencies["react"] = "^18.3.1";
|
|
6413
|
+
rootPkgJson.dependencies["react-dom"] = "^18.3.1";
|
|
6414
|
+
rootPkgJson.dependencies["antd"] = "^5.20.0";
|
|
6415
|
+
rootPkgJson.dependencies["@ant-design/x"] = "^2.1.0";
|
|
6383
6416
|
await import_fs_extra2.default.writeJson(import_path2.default.join(versionPath, "package.json"), rootPkgJson, { spaces: 2 });
|
|
6384
6417
|
await import_fs_extra2.default.writeFile(import_path2.default.join(versionPath, ".npmrc"), "shamefully-hoist=true\nauto-install-peers=true\n");
|
|
6385
6418
|
const isLocalDev = await this.tryLinkLocalPackages(versionPath);
|
|
6386
6419
|
try {
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
});
|
|
6420
|
+
const installArgs = ["install"];
|
|
6421
|
+
if (isLocalDev) {
|
|
6422
|
+
installArgs.push("--no-frozen-lockfile");
|
|
6423
|
+
}
|
|
6424
|
+
console.log(import_picocolors.default.gray(` \u23F3 \u6267\u884C pnpm ${installArgs.join(" ")}...`));
|
|
6425
|
+
const result = await execa("pnpm", installArgs, {
|
|
6426
|
+
cwd: versionPath,
|
|
6427
|
+
stdio: "inherit"
|
|
6428
|
+
});
|
|
6429
|
+
if (result.exitCode !== 0) {
|
|
6430
|
+
throw new Error(`pnpm install \u9000\u51FA\u7801\u4E3A ${result.exitCode}`);
|
|
6399
6431
|
}
|
|
6400
6432
|
} catch (e) {
|
|
6401
|
-
console.warn(import_picocolors.default.yellow(` \u26A0\uFE0F \u4F9D\u8D56\u5B89\u88C5\
|
|
6433
|
+
console.warn(import_picocolors.default.yellow(` \u26A0\uFE0F \u4F9D\u8D56\u5B89\u88C5\u5F02\u5E38\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u6216 pnpm \u73AF\u5883\u3002`));
|
|
6402
6434
|
console.warn(import_picocolors.default.gray(` \u9519\u8BEF\u4FE1\u606F: ${e.message}`));
|
|
6403
6435
|
}
|
|
6404
6436
|
await this.syncShellToSandbox(version, force);
|
|
@@ -6416,30 +6448,60 @@ var init_sandbox = __esm({
|
|
|
6416
6448
|
try {
|
|
6417
6449
|
const cliRoot = await getCliRoot();
|
|
6418
6450
|
const projectRoot = import_path2.default.resolve(cliRoot, "../../..");
|
|
6419
|
-
const
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
}
|
|
6425
|
-
const categories = ["", "tooling", "plugins", "libs"];
|
|
6451
|
+
const possiblePackagesDirs = [
|
|
6452
|
+
import_path2.default.join(projectRoot, "packages"),
|
|
6453
|
+
import_path2.default.resolve(projectRoot, "../chatbi-v/packages")
|
|
6454
|
+
];
|
|
6455
|
+
console.log(import_picocolors.default.gray(` \u{1F50D} \u68C0\u67E5\u672C\u5730\u5F00\u53D1\u73AF\u5883...`));
|
|
6426
6456
|
const localPackages = {};
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
const
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6457
|
+
const scanDir = async (currentDir) => {
|
|
6458
|
+
if (!import_fs_extra2.default.existsSync(currentDir)) return;
|
|
6459
|
+
const entries = await import_fs_extra2.default.readdir(currentDir, { withFileTypes: true });
|
|
6460
|
+
for (const entry of entries) {
|
|
6461
|
+
const fullPath = import_path2.default.join(currentDir, entry.name);
|
|
6462
|
+
if (entry.isDirectory()) {
|
|
6463
|
+
if (entry.name === "node_modules" || entry.name === ".git") continue;
|
|
6464
|
+
const pkgJsonPath = import_path2.default.join(fullPath, "package.json");
|
|
6465
|
+
if (import_fs_extra2.default.existsSync(pkgJsonPath)) {
|
|
6466
|
+
try {
|
|
6467
|
+
const pkgJson = await import_fs_extra2.default.readJson(pkgJsonPath);
|
|
6468
|
+
if (this.CORE_PACKAGES.includes(pkgJson.name)) {
|
|
6469
|
+
localPackages[pkgJson.name] = fullPath;
|
|
6470
|
+
}
|
|
6471
|
+
} catch (e) {
|
|
6472
|
+
}
|
|
6473
|
+
}
|
|
6474
|
+
const relativeToProject = import_path2.default.relative(projectRoot, fullPath);
|
|
6475
|
+
const depth = relativeToProject.split(import_path2.default.sep).filter((p) => p !== "..").length;
|
|
6476
|
+
if (depth < 5) {
|
|
6477
|
+
await scanDir(fullPath);
|
|
6438
6478
|
}
|
|
6439
6479
|
}
|
|
6440
6480
|
}
|
|
6481
|
+
};
|
|
6482
|
+
for (const dir of possiblePackagesDirs) {
|
|
6483
|
+
if (import_fs_extra2.default.existsSync(dir)) {
|
|
6484
|
+
console.log(import_picocolors.default.gray(` - \u626B\u63CF\u76EE\u5F55: ${dir}`));
|
|
6485
|
+
await scanDir(dir);
|
|
6486
|
+
}
|
|
6487
|
+
}
|
|
6488
|
+
if (Object.keys(localPackages).length === 0) {
|
|
6489
|
+
console.log(import_picocolors.default.gray(` \u2139\uFE0F \u672A\u5728\u672C\u5730\u627E\u5230\u4EFB\u4F55\u6838\u5FC3\u5305\uFF0C\u5C06\u4ECE NPM \u4E0B\u8F7D`));
|
|
6490
|
+
return false;
|
|
6491
|
+
}
|
|
6492
|
+
console.log(import_picocolors.default.gray(` \u{1F517} \u5DF2\u627E\u5230\u672C\u5730\u6838\u5FC3\u5305: ${Object.keys(localPackages).join(", ")}`));
|
|
6493
|
+
const sandboxNodeModules = import_path2.default.join(versionPath, "node_modules");
|
|
6494
|
+
await import_fs_extra2.default.ensureDir(sandboxNodeModules);
|
|
6495
|
+
for (const [name, pkgPath] of Object.entries(localPackages)) {
|
|
6496
|
+
const targetLinkPath = import_path2.default.join(sandboxNodeModules, name);
|
|
6497
|
+
await import_fs_extra2.default.ensureDir(import_path2.default.dirname(targetLinkPath));
|
|
6498
|
+
try {
|
|
6499
|
+
await import_fs_extra2.default.remove(targetLinkPath);
|
|
6500
|
+
} catch (e) {
|
|
6501
|
+
}
|
|
6502
|
+
await import_fs_extra2.default.symlink(pkgPath, targetLinkPath, "dir");
|
|
6503
|
+
console.log(import_picocolors.default.gray(` \u{1F517} \u5DF2\u94FE\u63A5\u672C\u5730\u5305: ${name} -> ${pkgPath}`));
|
|
6441
6504
|
}
|
|
6442
|
-
if (Object.keys(localPackages).length === 0) return false;
|
|
6443
6505
|
const sandboxPkgJsonPath = import_path2.default.join(versionPath, "package.json");
|
|
6444
6506
|
const sandboxPkgJson = await import_fs_extra2.default.readJson(sandboxPkgJsonPath);
|
|
6445
6507
|
const sections = ["dependencies", "devDependencies"];
|
|
@@ -6500,54 +6562,22 @@ var init_sandbox = __esm({
|
|
|
6500
6562
|
],
|
|
6501
6563
|
paths: {
|
|
6502
6564
|
...corePaths,
|
|
6503
|
-
...projectPaths
|
|
6504
|
-
// 增加常用第三方依赖的映射,优先使用 @types
|
|
6505
|
-
"react": [
|
|
6506
|
-
import_path2.default.join(sandboxNodeModules, "@types/react"),
|
|
6507
|
-
import_path2.default.join(sandboxNodeModules, "react")
|
|
6508
|
-
],
|
|
6509
|
-
"react/*": [
|
|
6510
|
-
import_path2.default.join(sandboxNodeModules, "@types/react/*"),
|
|
6511
|
-
import_path2.default.join(sandboxNodeModules, "react/*")
|
|
6512
|
-
],
|
|
6513
|
-
"react-dom": [
|
|
6514
|
-
import_path2.default.join(sandboxNodeModules, "@types/react-dom"),
|
|
6515
|
-
import_path2.default.join(sandboxNodeModules, "react-dom")
|
|
6516
|
-
],
|
|
6517
|
-
"react-dom/*": [
|
|
6518
|
-
import_path2.default.join(sandboxNodeModules, "@types/react-dom/*"),
|
|
6519
|
-
import_path2.default.join(sandboxNodeModules, "react-dom/*")
|
|
6520
|
-
],
|
|
6521
|
-
"antd": [
|
|
6522
|
-
import_path2.default.join(sandboxNodeModules, "antd")
|
|
6523
|
-
],
|
|
6524
|
-
"antd/*": [
|
|
6525
|
-
import_path2.default.join(sandboxNodeModules, "antd/*")
|
|
6526
|
-
],
|
|
6527
|
-
"@ant-design/icons": [import_path2.default.join(sandboxNodeModules, "@ant-design/icons")],
|
|
6528
|
-
"@ant-design/icons/*": [import_path2.default.join(sandboxNodeModules, "@ant-design/icons/*")],
|
|
6529
|
-
"@ant-design/x": [import_path2.default.join(sandboxNodeModules, "@ant-design/x")],
|
|
6530
|
-
"@ant-design/x/*": [import_path2.default.join(sandboxNodeModules, "@ant-design/x/*")],
|
|
6531
|
-
// 增加 Vite 客户端类型支持
|
|
6532
|
-
"vite/client": [import_path2.default.join(sandboxNodeModules, "vite/client.d.ts")],
|
|
6533
|
-
// 增加全局 @types 映射
|
|
6534
|
-
"*": [
|
|
6535
|
-
"./node_modules/*",
|
|
6536
|
-
import_path2.default.join(sandboxNodeModules, "*"),
|
|
6537
|
-
import_path2.default.join(sandboxNodeModules, "@types/*")
|
|
6538
|
-
]
|
|
6565
|
+
...projectPaths
|
|
6539
6566
|
}
|
|
6540
|
-
}
|
|
6567
|
+
},
|
|
6568
|
+
// 增加调试标识
|
|
6569
|
+
_cli_sync_time: (/* @__PURE__ */ new Date()).toISOString()
|
|
6541
6570
|
};
|
|
6542
6571
|
await import_fs_extra2.default.writeJson(import_path2.default.join(chatbiDir, "tsconfig.paths.json"), tsConfigPaths, { spaces: 2 });
|
|
6543
6572
|
const viteAlias = {};
|
|
6544
6573
|
for (const pkgName of _Sandbox.CORE_PACKAGES) {
|
|
6545
|
-
|
|
6574
|
+
const pkgDir = import_path2.default.join(sandboxNodeModules, pkgName);
|
|
6575
|
+
viteAlias[pkgName] = pkgDir;
|
|
6546
6576
|
}
|
|
6547
6577
|
await import_fs_extra2.default.writeJson(import_path2.default.join(chatbiDir, "vite.alias.json"), viteAlias, { spaces: 2 });
|
|
6548
6578
|
const projectNodeModules = import_path2.default.join(projectRoot, "node_modules");
|
|
6549
6579
|
const projectChatbiDir = import_path2.default.join(projectNodeModules, "@chatbi-v");
|
|
6550
|
-
|
|
6580
|
+
try {
|
|
6551
6581
|
await import_fs_extra2.default.ensureDir(projectChatbiDir);
|
|
6552
6582
|
for (const pkgName of _Sandbox.CORE_PACKAGES) {
|
|
6553
6583
|
const shortName = pkgName.replace("@chatbi-v/", "");
|
|
@@ -6562,6 +6592,8 @@ var init_sandbox = __esm({
|
|
|
6562
6592
|
} catch (e) {
|
|
6563
6593
|
}
|
|
6564
6594
|
}
|
|
6595
|
+
} catch (err) {
|
|
6596
|
+
console.warn(import_picocolors.default.yellow(` \u26A0\uFE0F \u65E0\u6CD5\u5728 ${projectNodeModules} \u521B\u5EFA\u6838\u5FC3\u5305\u8F6F\u94FE\u63A5: ${err.message}`));
|
|
6565
6597
|
}
|
|
6566
6598
|
const dtsContent = _Sandbox.CORE_PACKAGES.map((pkg) => `/// <reference types="${import_path2.default.join(sandboxNodeModules, pkg)}" />`).join("\n");
|
|
6567
6599
|
await import_fs_extra2.default.writeFile(import_path2.default.join(chatbiDir, "env.d.ts"), dtsContent);
|
|
@@ -6573,12 +6605,11 @@ var init_sandbox = __esm({
|
|
|
6573
6605
|
static getCoreAlias(version) {
|
|
6574
6606
|
const versionPath = this.getVersionPath(version);
|
|
6575
6607
|
const sandboxNodeModules = import_path2.default.join(versionPath, "node_modules");
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
6581
|
-
};
|
|
6608
|
+
const aliases3 = {};
|
|
6609
|
+
for (const pkg of this.CORE_PACKAGES) {
|
|
6610
|
+
aliases3[pkg] = import_path2.default.join(sandboxNodeModules, pkg);
|
|
6611
|
+
}
|
|
6612
|
+
return aliases3;
|
|
6582
6613
|
}
|
|
6583
6614
|
/**
|
|
6584
6615
|
* 清理特定版本的沙箱
|
|
@@ -6632,7 +6663,27 @@ async function build(options) {
|
|
|
6632
6663
|
\u{1F4E6} \u6B63\u5728\u6784\u5EFA\u9879\u76EE (\u5185\u6838\u7248\u672C: ${version})...`));
|
|
6633
6664
|
await Sandbox.ensureDir();
|
|
6634
6665
|
await Sandbox.prepareSandbox(version);
|
|
6635
|
-
|
|
6666
|
+
if (pkg.workspaces || import_fs_extra3.default.existsSync(import_path3.default.join(cwd, "pnpm-workspace.yaml"))) {
|
|
6667
|
+
console.log(import_picocolors2.default.gray(" \u{1F50D} \u68C0\u6D4B\u5230 Monorepo\uFF0C\u6B63\u5728\u4E3A\u5B50\u5305\u540C\u6B65\u865A\u62DF\u4E0A\u4E0B\u6587..."));
|
|
6668
|
+
await Sandbox.ensureVirtualContext(cwd, version);
|
|
6669
|
+
const subDirs = ["apps", "plugins"];
|
|
6670
|
+
for (const dir of subDirs) {
|
|
6671
|
+
const dirPath = import_path3.default.join(cwd, dir);
|
|
6672
|
+
if (import_fs_extra3.default.existsSync(dirPath)) {
|
|
6673
|
+
const entries = await import_fs_extra3.default.readdir(dirPath, { withFileTypes: true });
|
|
6674
|
+
for (const entry2 of entries) {
|
|
6675
|
+
if (entry2.isDirectory()) {
|
|
6676
|
+
const subPkgPath = import_path3.default.join(dirPath, entry2.name);
|
|
6677
|
+
if (import_fs_extra3.default.existsSync(import_path3.default.join(subPkgPath, "package.json"))) {
|
|
6678
|
+
await Sandbox.ensureVirtualContext(subPkgPath, version);
|
|
6679
|
+
}
|
|
6680
|
+
}
|
|
6681
|
+
}
|
|
6682
|
+
}
|
|
6683
|
+
}
|
|
6684
|
+
} else {
|
|
6685
|
+
await Sandbox.ensureVirtualContext(cwd, version);
|
|
6686
|
+
}
|
|
6636
6687
|
if (pkg.scripts && pkg.scripts.build && !process.env.CHATBI_CLI_INTERNAL) {
|
|
6637
6688
|
console.log(import_picocolors2.default.cyan(`Running "npm run build" for ${pkg.name}...`));
|
|
6638
6689
|
try {
|
|
@@ -6644,11 +6695,10 @@ async function build(options) {
|
|
|
6644
6695
|
stdio: "inherit",
|
|
6645
6696
|
env: { ...process.env, CHATBI_CLI_INTERNAL: "true" }
|
|
6646
6697
|
});
|
|
6647
|
-
return;
|
|
6648
6698
|
} catch (e) {
|
|
6649
|
-
console.error(import_picocolors2.default.red("\u274C Build script failed"));
|
|
6650
6699
|
process.exit(1);
|
|
6651
6700
|
}
|
|
6701
|
+
return;
|
|
6652
6702
|
}
|
|
6653
6703
|
console.log(import_picocolors2.default.cyan(`Building ${pkg.name || "package"}...`));
|
|
6654
6704
|
let entry = ["src/index.ts"];
|
|
@@ -6788,17 +6838,23 @@ async function build(options) {
|
|
|
6788
6838
|
} else if (import_fs_extra3.default.existsSync(sandboxTsc)) {
|
|
6789
6839
|
tscBin = sandboxTsc;
|
|
6790
6840
|
} else {
|
|
6791
|
-
|
|
6792
|
-
|
|
6841
|
+
try {
|
|
6842
|
+
if (import_fs_extra3.default.existsSync(import_path3.default.join(cwd, "pnpm-lock.yaml"))) {
|
|
6843
|
+
await execa2("pnpm", ["exec", "tsc", "--build", "tsconfig.json"], { stdio: "inherit" });
|
|
6844
|
+
console.log(import_picocolors2.default.green("Type definitions generated."));
|
|
6845
|
+
return;
|
|
6846
|
+
}
|
|
6847
|
+
await execa2("npx", ["-p", "typescript", "tsc", "--build", "tsconfig.json"], { stdio: "inherit" });
|
|
6793
6848
|
console.log(import_picocolors2.default.green("Type definitions generated."));
|
|
6794
6849
|
return;
|
|
6850
|
+
} catch (e) {
|
|
6851
|
+
console.warn(import_picocolors2.default.yellow("\u26A0\uFE0F \u81EA\u52A8\u5C1D\u8BD5\u8FD0\u884C tsc \u5931\u8D25\uFF0C\u8BF7\u786E\u4FDD\u9879\u76EE\u4E2D\u5DF2\u5B89\u88C5 typescript"));
|
|
6795
6852
|
}
|
|
6796
6853
|
}
|
|
6797
6854
|
await execa2(tscBin, ["--build", "tsconfig.json"], { stdio: "inherit" });
|
|
6798
6855
|
console.log(import_picocolors2.default.green("Type definitions generated."));
|
|
6799
6856
|
} catch (e) {
|
|
6800
|
-
console.error(import_picocolors2.default.red("
|
|
6801
|
-
throw e;
|
|
6857
|
+
console.error(import_picocolors2.default.red("\u274C \u7C7B\u578B\u751F\u6210\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u9879\u76EE\u4E2D\u7684 tsconfig.json \u914D\u7F6E\u3002"));
|
|
6802
6858
|
}
|
|
6803
6859
|
}
|
|
6804
6860
|
}
|
|
@@ -17677,7 +17733,12 @@ async function init(options) {
|
|
|
17677
17733
|
try {
|
|
17678
17734
|
const myCliRoot = await getCliRoot();
|
|
17679
17735
|
const cliPkg = await import_fs_extra7.default.readJson(import_path7.default.join(myCliRoot, "package.json"));
|
|
17680
|
-
const
|
|
17736
|
+
const cliVersion = cliPkg.version;
|
|
17737
|
+
let kernelVersion = cliVersion;
|
|
17738
|
+
const kernelVersionFile = import_path7.default.join(myCliRoot, ".chatbi-version");
|
|
17739
|
+
if (import_fs_extra7.default.existsSync(kernelVersionFile)) {
|
|
17740
|
+
kernelVersion = (await import_fs_extra7.default.readFile(kernelVersionFile, "utf-8")).trim();
|
|
17741
|
+
}
|
|
17681
17742
|
const renderTemplate = async (templateName, destDir, extraData = {}) => {
|
|
17682
17743
|
const srcDir = import_path7.default.join(myCliRoot, "templates", templateName);
|
|
17683
17744
|
if (!import_fs_extra7.default.existsSync(srcDir)) {
|
|
@@ -17688,6 +17749,10 @@ async function init(options) {
|
|
|
17688
17749
|
name: import_path7.default.basename(destDir),
|
|
17689
17750
|
projectName: name,
|
|
17690
17751
|
// Original project name from CLI argument
|
|
17752
|
+
version: kernelVersion,
|
|
17753
|
+
// 使用内核版本作为依赖版本
|
|
17754
|
+
cliVersion,
|
|
17755
|
+
// CLI 自身版本
|
|
17691
17756
|
pluginType,
|
|
17692
17757
|
theme,
|
|
17693
17758
|
isNebula: theme === "nebula",
|
|
@@ -17777,7 +17842,7 @@ async function init(options) {
|
|
|
17777
17842
|
}
|
|
17778
17843
|
console.log(import_picocolors6.default.blue("\u2699\uFE0F \u751F\u6210\u9879\u76EE\u914D\u7F6E..."));
|
|
17779
17844
|
const cliConfig = {
|
|
17780
|
-
coreVersion:
|
|
17845
|
+
coreVersion: kernelVersion
|
|
17781
17846
|
};
|
|
17782
17847
|
await import_fs_extra7.default.writeJson(import_path7.default.join(targetDir, "chatbi.config.json"), cliConfig, { spaces: 2 });
|
|
17783
17848
|
console.log(import_picocolors6.default.green(`
|
|
@@ -23059,7 +23124,27 @@ async function dev(options = {}) {
|
|
|
23059
23124
|
\u{1F680} \u542F\u52A8\u5F00\u53D1\u670D\u52A1\u5668 (\u5185\u6838\u7248\u672C: ${version})...`));
|
|
23060
23125
|
await Sandbox.ensureDir();
|
|
23061
23126
|
await Sandbox.prepareSandbox(version);
|
|
23062
|
-
|
|
23127
|
+
if (pkg.workspaces || import_fs_extra5.default.existsSync(import_path5.default.join(cwd, "pnpm-workspace.yaml"))) {
|
|
23128
|
+
console.log(import_picocolors4.default.gray(" \u{1F50D} \u68C0\u6D4B\u5230 Monorepo\uFF0C\u6B63\u5728\u4E3A\u5B50\u5305\u540C\u6B65\u865A\u62DF\u4E0A\u4E0B\u6587..."));
|
|
23129
|
+
await Sandbox.ensureVirtualContext(cwd, version);
|
|
23130
|
+
const subDirs = ["apps", "plugins"];
|
|
23131
|
+
for (const dir of subDirs) {
|
|
23132
|
+
const dirPath = import_path5.default.join(cwd, dir);
|
|
23133
|
+
if (import_fs_extra5.default.existsSync(dirPath)) {
|
|
23134
|
+
const entries = await import_fs_extra5.default.readdir(dirPath, { withFileTypes: true });
|
|
23135
|
+
for (const entry of entries) {
|
|
23136
|
+
if (entry.isDirectory()) {
|
|
23137
|
+
const subPkgPath = import_path5.default.join(dirPath, entry.name);
|
|
23138
|
+
if (import_fs_extra5.default.existsSync(import_path5.default.join(subPkgPath, "package.json"))) {
|
|
23139
|
+
await Sandbox.ensureVirtualContext(subPkgPath, version);
|
|
23140
|
+
}
|
|
23141
|
+
}
|
|
23142
|
+
}
|
|
23143
|
+
}
|
|
23144
|
+
}
|
|
23145
|
+
} else {
|
|
23146
|
+
await Sandbox.ensureVirtualContext(cwd, version);
|
|
23147
|
+
}
|
|
23063
23148
|
if (pkg.scripts && pkg.scripts.dev && !process.env.CHATBI_CLI_INTERNAL) {
|
|
23064
23149
|
try {
|
|
23065
23150
|
await execa("npm", ["run", "dev"], {
|
|
@@ -23701,7 +23786,7 @@ async function use(version, options = {}) {
|
|
|
23701
23786
|
// package.json
|
|
23702
23787
|
var package_default = {
|
|
23703
23788
|
name: "@chatbi-v/cli",
|
|
23704
|
-
version: "
|
|
23789
|
+
version: "2.0.1",
|
|
23705
23790
|
description: "Standardized CLI tooling for ChatBI Monorepo",
|
|
23706
23791
|
main: "dist/index.js",
|
|
23707
23792
|
bin: {
|
|
@@ -23821,7 +23906,6 @@ cli.command("update [targetVersion]", "\u66F4\u65B0\u5185\u6838\u7248\u672C").al
|
|
|
23821
23906
|
console.log(import_picocolors15.default.green("\u2705 \u66F4\u65B0\u5B8C\u6210\uFF01"));
|
|
23822
23907
|
} catch (e) {
|
|
23823
23908
|
console.error(import_picocolors15.default.red("\u274C \u66F4\u65B0\u5931\u8D25"));
|
|
23824
|
-
console.error(e);
|
|
23825
23909
|
process.exit(1);
|
|
23826
23910
|
}
|
|
23827
23911
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chatbi-v/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Standardized CLI tooling for ChatBI Monorepo",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -14,11 +14,6 @@
|
|
|
14
14
|
"publishConfig": {
|
|
15
15
|
"access": "public"
|
|
16
16
|
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"build": "tsup",
|
|
19
|
-
"dev": "tsup --watch",
|
|
20
|
-
"test": "vitest"
|
|
21
|
-
},
|
|
22
17
|
"dependencies": {
|
|
23
18
|
"boxen": "^8.0.1",
|
|
24
19
|
"cac": "^6.7.14",
|
|
@@ -45,5 +40,10 @@
|
|
|
45
40
|
"@types/prompts": "^2.4.9",
|
|
46
41
|
"tsup": "^8.5.1",
|
|
47
42
|
"vitest": "^1.0.0"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsup",
|
|
46
|
+
"dev": "tsup --watch",
|
|
47
|
+
"test": "vitest"
|
|
48
48
|
}
|
|
49
|
-
}
|
|
49
|
+
}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
"version": "0.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"dev": "
|
|
7
|
-
"build": "
|
|
6
|
+
"dev": "chatbi-cli dev",
|
|
7
|
+
"build": "chatbi-cli build",
|
|
8
8
|
"preview": "vite preview",
|
|
9
9
|
"test": "vitest",
|
|
10
10
|
"sync": "chatbi-cli sync"
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@ant-design/icons": "^5.2.6",
|
|
14
14
|
"@ant-design/x": "^2.1.1",
|
|
15
|
+
"@chatbi-v/core": "^{{version}}",
|
|
16
|
+
"@chatbi-v/mocks": "^{{version}}",
|
|
17
|
+
"@chatbi-v/tailwind-config": "^{{version}}",
|
|
15
18
|
"antd": "^5.29.3",
|
|
16
19
|
"react": "^18.3.1",
|
|
17
20
|
"react-dom": "^18.3.1",
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"description": "ChatBI-V {{#if isBusiness}}Business{{else}}System{{/if}} Plugin Project",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"dev": "
|
|
9
|
-
"build": "
|
|
8
|
+
"dev": "chatbi-cli dev",
|
|
9
|
+
"build": "chatbi-cli build",
|
|
10
10
|
"create:plugin": "node scripts/create-plugin.js"
|
|
11
11
|
},
|
|
12
12
|
"workspaces": [
|
|
@@ -16,10 +16,13 @@
|
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@ant-design/icons": "^5.2.6",
|
|
18
18
|
"@types/react": "^18.3.1",
|
|
19
|
-
"@types/react-dom": "^18.3.1"
|
|
19
|
+
"@types/react-dom": "^18.3.1",
|
|
20
|
+
"react": "^18.3.1",
|
|
21
|
+
"react-dom": "^18.3.1",
|
|
22
|
+
"antd": "^5.20.0",
|
|
23
|
+
"typescript": "^5.3.3"
|
|
20
24
|
},
|
|
21
25
|
"peerDependencies": {
|
|
22
|
-
"@chatbi-v/core": "^1.0.4",
|
|
23
26
|
"react": ">=18.0.0",
|
|
24
27
|
"react-dom": ">=18.0.0",
|
|
25
28
|
"antd": ">=5.0.0"
|
package/dist/app/.env
DELETED
package/dist/app/.env.hbs
DELETED