@chatbi-v/cli 1.0.13 → 1.0.14
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 +109 -79
- package/package.json +1 -1
- package/templates/app/package.json.hbs +3 -0
- package/templates/plugin/package.json.hbs +5 -2
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
|
*/
|
|
@@ -6296,6 +6311,15 @@ var init_sandbox = __esm({
|
|
|
6296
6311
|
} catch (e) {
|
|
6297
6312
|
}
|
|
6298
6313
|
}
|
|
6314
|
+
try {
|
|
6315
|
+
const cliRoot = await getCliRoot();
|
|
6316
|
+
const cliVersionFile = import_path2.default.join(cliRoot, ".chatbi-version");
|
|
6317
|
+
if (import_fs_extra2.default.existsSync(cliVersionFile)) {
|
|
6318
|
+
const version = (await import_fs_extra2.default.readFile(cliVersionFile, "utf-8")).trim();
|
|
6319
|
+
if (version) return version;
|
|
6320
|
+
}
|
|
6321
|
+
} catch (e) {
|
|
6322
|
+
}
|
|
6299
6323
|
const versions = await this.listVersions();
|
|
6300
6324
|
if (versions.length > 0) {
|
|
6301
6325
|
return versions[0];
|
|
@@ -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);
|
|
@@ -6422,24 +6454,49 @@ var init_sandbox = __esm({
|
|
|
6422
6454
|
console.log(import_picocolors.default.gray(` \u274C \u672A\u627E\u5230 packages \u76EE\u5F55`));
|
|
6423
6455
|
return false;
|
|
6424
6456
|
}
|
|
6425
|
-
const categories = ["", "tooling", "plugins", "libs"];
|
|
6426
6457
|
const localPackages = {};
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
const
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6458
|
+
const scanDir = async (currentDir) => {
|
|
6459
|
+
if (!import_fs_extra2.default.existsSync(currentDir)) return;
|
|
6460
|
+
const entries = await import_fs_extra2.default.readdir(currentDir, { withFileTypes: true });
|
|
6461
|
+
for (const entry of entries) {
|
|
6462
|
+
const fullPath = import_path2.default.join(currentDir, entry.name);
|
|
6463
|
+
if (entry.isDirectory()) {
|
|
6464
|
+
if (entry.name === "node_modules" || entry.name === ".git") continue;
|
|
6465
|
+
const pkgJsonPath = import_path2.default.join(fullPath, "package.json");
|
|
6466
|
+
if (import_fs_extra2.default.existsSync(pkgJsonPath)) {
|
|
6467
|
+
try {
|
|
6468
|
+
const pkgJson = await import_fs_extra2.default.readJson(pkgJsonPath);
|
|
6469
|
+
if (this.CORE_PACKAGES.includes(pkgJson.name)) {
|
|
6470
|
+
localPackages[pkgJson.name] = fullPath;
|
|
6471
|
+
}
|
|
6472
|
+
} catch (e) {
|
|
6473
|
+
}
|
|
6474
|
+
}
|
|
6475
|
+
const relative = import_path2.default.relative(projectRoot, fullPath);
|
|
6476
|
+
if (relative.split(import_path2.default.sep).length < 4) {
|
|
6477
|
+
await scanDir(fullPath);
|
|
6438
6478
|
}
|
|
6439
6479
|
}
|
|
6440
6480
|
}
|
|
6481
|
+
};
|
|
6482
|
+
await scanDir(projectRoot);
|
|
6483
|
+
if (Object.keys(localPackages).length === 0) {
|
|
6484
|
+
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`));
|
|
6485
|
+
return false;
|
|
6486
|
+
}
|
|
6487
|
+
console.log(import_picocolors.default.gray(` \u{1F517} \u5DF2\u627E\u5230\u672C\u5730\u6838\u5FC3\u5305: ${Object.keys(localPackages).join(", ")}`));
|
|
6488
|
+
const sandboxNodeModules = import_path2.default.join(versionPath, "node_modules");
|
|
6489
|
+
await import_fs_extra2.default.ensureDir(sandboxNodeModules);
|
|
6490
|
+
for (const [name, pkgPath] of Object.entries(localPackages)) {
|
|
6491
|
+
const targetLinkPath = import_path2.default.join(sandboxNodeModules, name);
|
|
6492
|
+
await import_fs_extra2.default.ensureDir(import_path2.default.dirname(targetLinkPath));
|
|
6493
|
+
try {
|
|
6494
|
+
await import_fs_extra2.default.remove(targetLinkPath);
|
|
6495
|
+
} catch (e) {
|
|
6496
|
+
}
|
|
6497
|
+
await import_fs_extra2.default.symlink(pkgPath, targetLinkPath, "dir");
|
|
6498
|
+
console.log(import_picocolors.default.gray(` \u{1F517} \u5DF2\u94FE\u63A5\u672C\u5730\u5305: ${name} -> ${pkgPath}`));
|
|
6441
6499
|
}
|
|
6442
|
-
if (Object.keys(localPackages).length === 0) return false;
|
|
6443
6500
|
const sandboxPkgJsonPath = import_path2.default.join(versionPath, "package.json");
|
|
6444
6501
|
const sandboxPkgJson = await import_fs_extra2.default.readJson(sandboxPkgJsonPath);
|
|
6445
6502
|
const sections = ["dependencies", "devDependencies"];
|
|
@@ -6500,49 +6557,17 @@ var init_sandbox = __esm({
|
|
|
6500
6557
|
],
|
|
6501
6558
|
paths: {
|
|
6502
6559
|
...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
|
-
]
|
|
6560
|
+
...projectPaths
|
|
6539
6561
|
}
|
|
6540
|
-
}
|
|
6562
|
+
},
|
|
6563
|
+
// 增加调试标识
|
|
6564
|
+
_cli_sync_time: (/* @__PURE__ */ new Date()).toISOString()
|
|
6541
6565
|
};
|
|
6542
6566
|
await import_fs_extra2.default.writeJson(import_path2.default.join(chatbiDir, "tsconfig.paths.json"), tsConfigPaths, { spaces: 2 });
|
|
6543
6567
|
const viteAlias = {};
|
|
6544
6568
|
for (const pkgName of _Sandbox.CORE_PACKAGES) {
|
|
6545
|
-
|
|
6569
|
+
const pkgDir = import_path2.default.join(sandboxNodeModules, pkgName);
|
|
6570
|
+
viteAlias[pkgName] = pkgDir;
|
|
6546
6571
|
}
|
|
6547
6572
|
await import_fs_extra2.default.writeJson(import_path2.default.join(chatbiDir, "vite.alias.json"), viteAlias, { spaces: 2 });
|
|
6548
6573
|
const projectNodeModules = import_path2.default.join(projectRoot, "node_modules");
|
|
@@ -6573,12 +6598,11 @@ var init_sandbox = __esm({
|
|
|
6573
6598
|
static getCoreAlias(version) {
|
|
6574
6599
|
const versionPath = this.getVersionPath(version);
|
|
6575
6600
|
const sandboxNodeModules = import_path2.default.join(versionPath, "node_modules");
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
6581
|
-
};
|
|
6601
|
+
const aliases3 = {};
|
|
6602
|
+
for (const pkg of this.CORE_PACKAGES) {
|
|
6603
|
+
aliases3[pkg] = import_path2.default.join(sandboxNodeModules, pkg);
|
|
6604
|
+
}
|
|
6605
|
+
return aliases3;
|
|
6582
6606
|
}
|
|
6583
6607
|
/**
|
|
6584
6608
|
* 清理特定版本的沙箱
|
|
@@ -6644,11 +6668,10 @@ async function build(options) {
|
|
|
6644
6668
|
stdio: "inherit",
|
|
6645
6669
|
env: { ...process.env, CHATBI_CLI_INTERNAL: "true" }
|
|
6646
6670
|
});
|
|
6647
|
-
return;
|
|
6648
6671
|
} catch (e) {
|
|
6649
|
-
console.error(import_picocolors2.default.red("\u274C Build script failed"));
|
|
6650
6672
|
process.exit(1);
|
|
6651
6673
|
}
|
|
6674
|
+
return;
|
|
6652
6675
|
}
|
|
6653
6676
|
console.log(import_picocolors2.default.cyan(`Building ${pkg.name || "package"}...`));
|
|
6654
6677
|
let entry = ["src/index.ts"];
|
|
@@ -6788,17 +6811,23 @@ async function build(options) {
|
|
|
6788
6811
|
} else if (import_fs_extra3.default.existsSync(sandboxTsc)) {
|
|
6789
6812
|
tscBin = sandboxTsc;
|
|
6790
6813
|
} else {
|
|
6791
|
-
|
|
6792
|
-
|
|
6814
|
+
try {
|
|
6815
|
+
if (import_fs_extra3.default.existsSync(import_path3.default.join(cwd, "pnpm-lock.yaml"))) {
|
|
6816
|
+
await execa2("pnpm", ["exec", "tsc", "--build", "tsconfig.json"], { stdio: "inherit" });
|
|
6817
|
+
console.log(import_picocolors2.default.green("Type definitions generated."));
|
|
6818
|
+
return;
|
|
6819
|
+
}
|
|
6820
|
+
await execa2("npx", ["-p", "typescript", "tsc", "--build", "tsconfig.json"], { stdio: "inherit" });
|
|
6793
6821
|
console.log(import_picocolors2.default.green("Type definitions generated."));
|
|
6794
6822
|
return;
|
|
6823
|
+
} catch (e) {
|
|
6824
|
+
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
6825
|
}
|
|
6796
6826
|
}
|
|
6797
6827
|
await execa2(tscBin, ["--build", "tsconfig.json"], { stdio: "inherit" });
|
|
6798
6828
|
console.log(import_picocolors2.default.green("Type definitions generated."));
|
|
6799
6829
|
} catch (e) {
|
|
6800
|
-
console.error(import_picocolors2.default.red("
|
|
6801
|
-
throw e;
|
|
6830
|
+
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
6831
|
}
|
|
6803
6832
|
}
|
|
6804
6833
|
}
|
|
@@ -17688,6 +17717,8 @@ async function init(options) {
|
|
|
17688
17717
|
name: import_path7.default.basename(destDir),
|
|
17689
17718
|
projectName: name,
|
|
17690
17719
|
// Original project name from CLI argument
|
|
17720
|
+
version,
|
|
17721
|
+
// CLI version to be used in package.json
|
|
17691
17722
|
pluginType,
|
|
17692
17723
|
theme,
|
|
17693
17724
|
isNebula: theme === "nebula",
|
|
@@ -23701,7 +23732,7 @@ async function use(version, options = {}) {
|
|
|
23701
23732
|
// package.json
|
|
23702
23733
|
var package_default = {
|
|
23703
23734
|
name: "@chatbi-v/cli",
|
|
23704
|
-
version: "1.0.
|
|
23735
|
+
version: "1.0.14",
|
|
23705
23736
|
description: "Standardized CLI tooling for ChatBI Monorepo",
|
|
23706
23737
|
main: "dist/index.js",
|
|
23707
23738
|
bin: {
|
|
@@ -23821,7 +23852,6 @@ cli.command("update [targetVersion]", "\u66F4\u65B0\u5185\u6838\u7248\u672C").al
|
|
|
23821
23852
|
console.log(import_picocolors15.default.green("\u2705 \u66F4\u65B0\u5B8C\u6210\uFF01"));
|
|
23822
23853
|
} catch (e) {
|
|
23823
23854
|
console.error(import_picocolors15.default.red("\u274C \u66F4\u65B0\u5931\u8D25"));
|
|
23824
|
-
console.error(e);
|
|
23825
23855
|
process.exit(1);
|
|
23826
23856
|
}
|
|
23827
23857
|
});
|
package/package.json
CHANGED
|
@@ -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",
|
|
@@ -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"
|