@chatbi-v/cli 2.0.1 → 2.0.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.
Files changed (67) hide show
  1. package/README.md +45 -0
  2. package/dist/bench-NMQTZVQF.mjs +77 -0
  3. package/dist/build-66EM7X52.mjs +11 -0
  4. package/dist/chunk-2IR4PJIP.mjs +2255 -0
  5. package/dist/chunk-2REG4NIZ.mjs +9577 -0
  6. package/dist/chunk-6YO7P2EG.mjs +55 -0
  7. package/dist/chunk-7DA7PT2X.mjs +271 -0
  8. package/dist/chunk-AQNFMKFL.mjs +5292 -0
  9. package/dist/chunk-B6J5VVNN.mjs +52 -0
  10. package/dist/chunk-BMUJH4OW.mjs +255 -0
  11. package/dist/chunk-DRBLMVU7.mjs +6368 -0
  12. package/dist/chunk-WUWYFYMG.mjs +89 -0
  13. package/dist/commands/add.js +182 -0
  14. package/dist/commands/bench.js +100 -0
  15. package/dist/commands/build.js +297 -0
  16. package/dist/commands/dev.js +8 -0
  17. package/dist/commands/discover.js +25 -0
  18. package/dist/commands/doctor.js +231 -0
  19. package/dist/commands/fetch.js +41 -0
  20. package/dist/commands/gl.js +151 -0
  21. package/dist/commands/init.js +253 -0
  22. package/dist/commands/install.js +85 -0
  23. package/dist/commands/ls.js +46 -0
  24. package/dist/commands/sync.js +78 -0
  25. package/dist/commands/use.js +31 -0
  26. package/dist/config.js +70 -0
  27. package/dist/corekit.js +371 -0
  28. package/dist/execa-GD72AH35.mjs +17 -0
  29. package/dist/fetch-4EUKQD7S.mjs +10 -0
  30. package/dist/index.cjs +27287 -0
  31. package/dist/index.js +193 -23981
  32. package/dist/index.mjs +2769 -0
  33. package/dist/init-P2UCTRNH.mjs +12 -0
  34. package/dist/sandbox.js +522 -0
  35. package/dist/sync-JWHGYK34.mjs +11 -0
  36. package/dist/utils.js +99 -0
  37. package/package.json +4 -3
  38. package/templates/app/.env.hbs +2 -2
  39. package/templates/app/README.md.hbs +29 -11
  40. package/templates/app/chatbi.config.ts.hbs +10 -33
  41. package/templates/app/index.html.hbs +1 -1
  42. package/templates/app/package.json.hbs +12 -14
  43. package/templates/app/postcss.config.cjs.hbs +5 -1
  44. package/templates/app/src/App.tsx.hbs +66 -36
  45. package/templates/app/src/components/GlobalSettingsModal.tsx.hbs +11 -1
  46. package/templates/app/src/hooks/useAppRoutes.ts.hbs +3 -6
  47. package/templates/app/src/hooks/usePluginLoader.ts.hbs +54 -7
  48. package/templates/app/src/hooks/usePluginStateSync.ts.hbs +81 -0
  49. package/templates/app/src/hooks/useThemeSync.ts.hbs +25 -74
  50. package/templates/app/src/layouts/MainContent.tsx.hbs +1 -1
  51. package/templates/app/src/layouts/SidebarNav.tsx.hbs +15 -14
  52. package/templates/app/src/main.tsx.hbs +2 -9
  53. package/templates/app/src/providers/AppProviders.tsx.hbs +2 -0
  54. package/templates/app/src/stores/useSessionStore.ts.hbs +1 -1
  55. package/templates/app/src/stores/useUIStore.ts.hbs +22 -3
  56. package/templates/app/src/vite-env.d.ts.hbs +1 -0
  57. package/templates/app/tailwind.config.cjs.hbs +26 -7
  58. package/templates/app/tsconfig.json.hbs +2 -5
  59. package/templates/app/vite.config.ts.hbs +67 -52
  60. package/templates/monorepo/package.json.hbs +1 -1
  61. package/templates/plugin/README.md.hbs +36 -0
  62. package/templates/plugin/package.json.hbs +26 -21
  63. package/templates/plugin/src/api/index.ts.hbs +3 -0
  64. package/templates/plugin/src/components/MainView.tsx.hbs +12 -0
  65. package/templates/plugin/src/index.tsx.hbs +39 -72
  66. package/templates/plugin/tsconfig.json.hbs +3 -14
  67. package/templates/app/src/services/api/modules/auth.ts.hbs +0 -18
package/README.md CHANGED
@@ -2,6 +2,44 @@
2
2
 
3
3
  > ChatBI-V 统一开发工具。基于 **沙箱 (Sandbox)** 与 **零显式依赖 (Zero-Install)** 架构设计,助力开发者快速构建、预览和部署 ChatBI 插件与应用。
4
4
 
5
+ ## 模块功能说明
6
+
7
+ - **项目初始化**: 快速生成 App、Plugin 或 Monorepo 模板。
8
+ - **环境编排**: 自动管理内核版本,支持项目级版本锁定。
9
+ - **开发预览**: 内置热更新开发服务器,支持沙箱环境下的实时预览。
10
+ - **依赖同步**: 自动化同步内核定义,解决开发环境配置难题。
11
+
12
+ ## 安装和使用方法
13
+
14
+ ### 安装 CLI
15
+ ```bash
16
+ npm install -g @chatbi-v/cli
17
+ # 或使用 pnpm
18
+ pnpm add -g @chatbi-v/cli
19
+ ```
20
+
21
+ ### 初始化项目
22
+ ```bash
23
+ chatbi-cli init my-app --project-type app
24
+ ```
25
+
26
+ ### 启动开发环境
27
+ ```bash
28
+ chatbi-cli dev
29
+ ```
30
+
31
+ ## API 文档链接
32
+
33
+ 请访问 [CLI 详细文档](https://github.com/your-repo/docs/cli/index.md) 或运行 `chatbi-cli --help` 查看指令详情。
34
+
35
+ ## 开发注意事项
36
+
37
+ - **权限说明**: 部分命令涉及全局目录 (`~/.chatbi-v-core`) 的读写。
38
+ - **Node 版本**: 建议使用 Node.js >= 18.0.0。
39
+ - **沙箱隔离**: 开发过程中请勿手动修改 `.chatbi-v-core` 目录内容。
40
+
41
+ ---
42
+
5
43
  ## 核心理念
6
44
 
7
45
  ### 1. 零显式依赖 (Zero-Install)
@@ -36,6 +74,11 @@ chatbi-cli init my-app --project-type app
36
74
  chatbi-cli init my-plugin --project-type plugin
37
75
  ```
38
76
 
77
+ #### 创建一个 Monorepo 工作空间
78
+ ```bash
79
+ chatbi-cli init my-workspace --project-type monorepo
80
+ ```
81
+
39
82
  ### 启动开发环境
40
83
  进入项目目录后执行:
41
84
  ```bash
@@ -43,6 +86,8 @@ npm run dev
43
86
  # 或者直接使用 cli
44
87
  chatbi-cli dev
45
88
  ```
89
+ - **App/Plugin 模式**: 直接启动当前项目。
90
+ - **Monorepo 模式**: 自动扫描并提供交互式菜单,选择要启动的子应用或插件。
46
91
 
47
92
  ---
48
93
 
@@ -0,0 +1,77 @@
1
+ import {
2
+ createSpinner,
3
+ logger,
4
+ printBox,
5
+ require_lib,
6
+ require_picocolors
7
+ } from "./chunk-2REG4NIZ.mjs";
8
+ import {
9
+ __toESM,
10
+ init_esm_shims
11
+ } from "./chunk-6YO7P2EG.mjs";
12
+
13
+ // src/commands/bench.ts
14
+ init_esm_shims();
15
+ var import_picocolors = __toESM(require_picocolors());
16
+ var import_fs_extra = __toESM(require_lib());
17
+ import path from "path";
18
+ import os from "os";
19
+ async function bench() {
20
+ logger.info("\u6B63\u5728\u542F\u52A8 CLI \u6027\u80FD\u57FA\u51C6\u6D4B\u8BD5...");
21
+ const results = [];
22
+ const tmpDir = path.join(os.tmpdir(), `chatbi-bench-${Date.now()}`);
23
+ await import_fs_extra.default.ensureDir(tmpDir);
24
+ try {
25
+ const initSpinner = createSpinner("\u6B63\u5728\u6D4B\u8BD5: \u521D\u59CB\u5316\u63D2\u4EF6\u9879\u76EE (init)...").start();
26
+ const startInit = Date.now();
27
+ const { init } = await import("./init-P2UCTRNH.mjs");
28
+ const testProjDir = path.join(tmpDir, "bench-proj");
29
+ await init({ name: "bench-proj", projectType: "plugin", cwd: tmpDir });
30
+ const endInit = Date.now();
31
+ const initTime = (endInit - startInit) / 1e3;
32
+ initSpinner.succeed(`\u521D\u59CB\u5316\u5B8C\u6210: ${import_picocolors.default.cyan(initTime.toFixed(2) + "s")}`);
33
+ results.push({
34
+ scene: "\u521D\u59CB\u5316\u63D2\u4EF6\u9879\u76EE (init)",
35
+ target: "\u2264 5.0 s",
36
+ actual: `${initTime.toFixed(2)} s`
37
+ });
38
+ const syncSpinner = createSpinner("\u6B63\u5728\u6D4B\u8BD5: \u6C99\u7BB1\u73AF\u5883\u540C\u6B65 (sync)...").start();
39
+ const startSync = Date.now();
40
+ const { sync } = await import("./sync-JWHGYK34.mjs");
41
+ await sync({ cwd: testProjDir });
42
+ const endSync = Date.now();
43
+ const syncTime = (endSync - startSync) / 1e3;
44
+ syncSpinner.succeed(`\u540C\u6B65\u5B8C\u6210: ${import_picocolors.default.cyan(syncTime.toFixed(2) + "s")}`);
45
+ results.push({
46
+ scene: "\u6C99\u7BB1\u73AF\u5883\u540C\u6B65 (sync)",
47
+ target: "\u2264 2.0 s",
48
+ actual: `${syncTime.toFixed(2)} s`
49
+ });
50
+ const buildSpinner = createSpinner("\u6B63\u5728\u6D4B\u8BD5: \u63D2\u4EF6\u9879\u76EE\u6784\u5EFA (build)...").start();
51
+ const startBuild = Date.now();
52
+ const { build } = await import("./build-66EM7X52.mjs");
53
+ const originalCwd = process.cwd();
54
+ process.chdir(testProjDir);
55
+ await build({ watch: false });
56
+ process.chdir(originalCwd);
57
+ const endBuild = Date.now();
58
+ const buildTime = (endBuild - startBuild) / 1e3;
59
+ buildSpinner.succeed(`\u6784\u5EFA\u5B8C\u6210: ${import_picocolors.default.cyan(buildTime.toFixed(2) + "s")}`);
60
+ results.push({
61
+ scene: "\u63D2\u4EF6\u9879\u76EE\u6784\u5EFA (build)",
62
+ target: "\u2264 10.0 s",
63
+ actual: `${buildTime.toFixed(2)} s`
64
+ });
65
+ printBox(
66
+ `${import_picocolors.default.green(import_picocolors.default.bold("\u2728 \u57FA\u51C6\u6D4B\u8BD5\u5B8C\u6210!"))}
67
+
68
+ ` + results.map((r) => `${import_picocolors.default.white(r.scene.padEnd(20))}: ${import_picocolors.default.cyan(r.actual)} (\u76EE\u6807 ${r.target})`).join("\n"),
69
+ "Benchmark Results"
70
+ );
71
+ } finally {
72
+ await import_fs_extra.default.remove(tmpDir);
73
+ }
74
+ }
75
+ export {
76
+ bench
77
+ };
@@ -0,0 +1,11 @@
1
+ import {
2
+ build
3
+ } from "./chunk-7DA7PT2X.mjs";
4
+ import "./chunk-AQNFMKFL.mjs";
5
+ import "./chunk-DRBLMVU7.mjs";
6
+ import "./chunk-2IR4PJIP.mjs";
7
+ import "./chunk-2REG4NIZ.mjs";
8
+ import "./chunk-6YO7P2EG.mjs";
9
+ export {
10
+ build
11
+ };