@chatbi-v/cli 1.0.14 → 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
CHANGED
|
@@ -6303,14 +6303,6 @@ var init_sandbox = __esm({
|
|
|
6303
6303
|
if (version) return version;
|
|
6304
6304
|
}
|
|
6305
6305
|
}
|
|
6306
|
-
const currentLinkPath = import_path2.default.join(this.BASE_DIR, "versions", "current");
|
|
6307
|
-
if (import_fs_extra2.default.existsSync(currentLinkPath)) {
|
|
6308
|
-
try {
|
|
6309
|
-
const realPath = await import_fs_extra2.default.realpath(currentLinkPath);
|
|
6310
|
-
return import_path2.default.basename(realPath);
|
|
6311
|
-
} catch (e) {
|
|
6312
|
-
}
|
|
6313
|
-
}
|
|
6314
6306
|
try {
|
|
6315
6307
|
const cliRoot = await getCliRoot();
|
|
6316
6308
|
const cliVersionFile = import_path2.default.join(cliRoot, ".chatbi-version");
|
|
@@ -6320,6 +6312,14 @@ var init_sandbox = __esm({
|
|
|
6320
6312
|
}
|
|
6321
6313
|
} catch (e) {
|
|
6322
6314
|
}
|
|
6315
|
+
const currentLinkPath = import_path2.default.join(this.BASE_DIR, "versions", "current");
|
|
6316
|
+
if (import_fs_extra2.default.existsSync(currentLinkPath)) {
|
|
6317
|
+
try {
|
|
6318
|
+
const realPath = await import_fs_extra2.default.realpath(currentLinkPath);
|
|
6319
|
+
return import_path2.default.basename(realPath);
|
|
6320
|
+
} catch (e) {
|
|
6321
|
+
}
|
|
6322
|
+
}
|
|
6323
6323
|
const versions = await this.listVersions();
|
|
6324
6324
|
if (versions.length > 0) {
|
|
6325
6325
|
return versions[0];
|
|
@@ -6448,12 +6448,11 @@ var init_sandbox = __esm({
|
|
|
6448
6448
|
try {
|
|
6449
6449
|
const cliRoot = await getCliRoot();
|
|
6450
6450
|
const projectRoot = import_path2.default.resolve(cliRoot, "../../..");
|
|
6451
|
-
const
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
}
|
|
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...`));
|
|
6457
6456
|
const localPackages = {};
|
|
6458
6457
|
const scanDir = async (currentDir) => {
|
|
6459
6458
|
if (!import_fs_extra2.default.existsSync(currentDir)) return;
|
|
@@ -6472,14 +6471,20 @@ var init_sandbox = __esm({
|
|
|
6472
6471
|
} catch (e) {
|
|
6473
6472
|
}
|
|
6474
6473
|
}
|
|
6475
|
-
const
|
|
6476
|
-
|
|
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
6477
|
await scanDir(fullPath);
|
|
6478
6478
|
}
|
|
6479
6479
|
}
|
|
6480
6480
|
}
|
|
6481
6481
|
};
|
|
6482
|
-
|
|
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
|
+
}
|
|
6483
6488
|
if (Object.keys(localPackages).length === 0) {
|
|
6484
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`));
|
|
6485
6490
|
return false;
|
|
@@ -6572,7 +6577,7 @@ var init_sandbox = __esm({
|
|
|
6572
6577
|
await import_fs_extra2.default.writeJson(import_path2.default.join(chatbiDir, "vite.alias.json"), viteAlias, { spaces: 2 });
|
|
6573
6578
|
const projectNodeModules = import_path2.default.join(projectRoot, "node_modules");
|
|
6574
6579
|
const projectChatbiDir = import_path2.default.join(projectNodeModules, "@chatbi-v");
|
|
6575
|
-
|
|
6580
|
+
try {
|
|
6576
6581
|
await import_fs_extra2.default.ensureDir(projectChatbiDir);
|
|
6577
6582
|
for (const pkgName of _Sandbox.CORE_PACKAGES) {
|
|
6578
6583
|
const shortName = pkgName.replace("@chatbi-v/", "");
|
|
@@ -6587,6 +6592,8 @@ var init_sandbox = __esm({
|
|
|
6587
6592
|
} catch (e) {
|
|
6588
6593
|
}
|
|
6589
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}`));
|
|
6590
6597
|
}
|
|
6591
6598
|
const dtsContent = _Sandbox.CORE_PACKAGES.map((pkg) => `/// <reference types="${import_path2.default.join(sandboxNodeModules, pkg)}" />`).join("\n");
|
|
6592
6599
|
await import_fs_extra2.default.writeFile(import_path2.default.join(chatbiDir, "env.d.ts"), dtsContent);
|
|
@@ -6656,7 +6663,27 @@ async function build(options) {
|
|
|
6656
6663
|
\u{1F4E6} \u6B63\u5728\u6784\u5EFA\u9879\u76EE (\u5185\u6838\u7248\u672C: ${version})...`));
|
|
6657
6664
|
await Sandbox.ensureDir();
|
|
6658
6665
|
await Sandbox.prepareSandbox(version);
|
|
6659
|
-
|
|
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
|
+
}
|
|
6660
6687
|
if (pkg.scripts && pkg.scripts.build && !process.env.CHATBI_CLI_INTERNAL) {
|
|
6661
6688
|
console.log(import_picocolors2.default.cyan(`Running "npm run build" for ${pkg.name}...`));
|
|
6662
6689
|
try {
|
|
@@ -17706,7 +17733,12 @@ async function init(options) {
|
|
|
17706
17733
|
try {
|
|
17707
17734
|
const myCliRoot = await getCliRoot();
|
|
17708
17735
|
const cliPkg = await import_fs_extra7.default.readJson(import_path7.default.join(myCliRoot, "package.json"));
|
|
17709
|
-
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
|
+
}
|
|
17710
17742
|
const renderTemplate = async (templateName, destDir, extraData = {}) => {
|
|
17711
17743
|
const srcDir = import_path7.default.join(myCliRoot, "templates", templateName);
|
|
17712
17744
|
if (!import_fs_extra7.default.existsSync(srcDir)) {
|
|
@@ -17717,8 +17749,10 @@ async function init(options) {
|
|
|
17717
17749
|
name: import_path7.default.basename(destDir),
|
|
17718
17750
|
projectName: name,
|
|
17719
17751
|
// Original project name from CLI argument
|
|
17720
|
-
version,
|
|
17721
|
-
//
|
|
17752
|
+
version: kernelVersion,
|
|
17753
|
+
// 使用内核版本作为依赖版本
|
|
17754
|
+
cliVersion,
|
|
17755
|
+
// CLI 自身版本
|
|
17722
17756
|
pluginType,
|
|
17723
17757
|
theme,
|
|
17724
17758
|
isNebula: theme === "nebula",
|
|
@@ -17808,7 +17842,7 @@ async function init(options) {
|
|
|
17808
17842
|
}
|
|
17809
17843
|
console.log(import_picocolors6.default.blue("\u2699\uFE0F \u751F\u6210\u9879\u76EE\u914D\u7F6E..."));
|
|
17810
17844
|
const cliConfig = {
|
|
17811
|
-
coreVersion:
|
|
17845
|
+
coreVersion: kernelVersion
|
|
17812
17846
|
};
|
|
17813
17847
|
await import_fs_extra7.default.writeJson(import_path7.default.join(targetDir, "chatbi.config.json"), cliConfig, { spaces: 2 });
|
|
17814
17848
|
console.log(import_picocolors6.default.green(`
|
|
@@ -23090,7 +23124,27 @@ async function dev(options = {}) {
|
|
|
23090
23124
|
\u{1F680} \u542F\u52A8\u5F00\u53D1\u670D\u52A1\u5668 (\u5185\u6838\u7248\u672C: ${version})...`));
|
|
23091
23125
|
await Sandbox.ensureDir();
|
|
23092
23126
|
await Sandbox.prepareSandbox(version);
|
|
23093
|
-
|
|
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
|
+
}
|
|
23094
23148
|
if (pkg.scripts && pkg.scripts.dev && !process.env.CHATBI_CLI_INTERNAL) {
|
|
23095
23149
|
try {
|
|
23096
23150
|
await execa("npm", ["run", "dev"], {
|
|
@@ -23732,7 +23786,7 @@ async function use(version, options = {}) {
|
|
|
23732
23786
|
// package.json
|
|
23733
23787
|
var package_default = {
|
|
23734
23788
|
name: "@chatbi-v/cli",
|
|
23735
|
-
version: "
|
|
23789
|
+
version: "2.0.1",
|
|
23736
23790
|
description: "Standardized CLI tooling for ChatBI Monorepo",
|
|
23737
23791
|
main: "dist/index.js",
|
|
23738
23792
|
bin: {
|
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
|
+
}
|
|
@@ -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": [
|
package/dist/app/.env
DELETED
package/dist/app/.env.hbs
DELETED