@chatbi-v/cli 2.0.1 → 2.0.2

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-ACSHVGHE.mjs +77 -0
  3. package/dist/build-UB4D3WNI.mjs +11 -0
  4. package/dist/chunk-4OD6C56P.mjs +89 -0
  5. package/dist/chunk-7A54IJI5.mjs +6368 -0
  6. package/dist/chunk-LJFX6MNO.mjs +255 -0
  7. package/dist/chunk-SBGVKO4C.mjs +2255 -0
  8. package/dist/chunk-TX5M36S5.mjs +55 -0
  9. package/dist/chunk-V7IEPMC4.mjs +52 -0
  10. package/dist/chunk-WCPZB47I.mjs +262 -0
  11. package/dist/chunk-WIVHOK75.mjs +5292 -0
  12. package/dist/chunk-Y24V4GQG.mjs +9577 -0
  13. package/dist/commands/add.js +182 -0
  14. package/dist/commands/bench.js +100 -0
  15. package/dist/commands/build.js +290 -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 +370 -0
  28. package/dist/execa-METROS6Z.mjs +17 -0
  29. package/dist/fetch-7X2UFWIV.mjs +10 -0
  30. package/dist/index.cjs +27278 -0
  31. package/dist/index.js +193 -23981
  32. package/dist/index.mjs +2769 -0
  33. package/dist/init-QFRFYEA5.mjs +12 -0
  34. package/dist/sandbox.js +522 -0
  35. package/dist/sync-7HPKGVFY.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 +4 -15
  67. package/templates/app/src/services/api/modules/auth.ts.hbs +0 -18
@@ -1,90 +1,57 @@
1
- import React from 'react'
2
- import { Plugin, PluginContext, Slot } from '@chatbi-v/core'
3
- import { MessageOutlined } from '@ant-design/icons'
1
+ import { RocketOutlined } from '@ant-design/icons';
2
+ import { createLogger, definePlugin, type PluginContext, Slot } from '@chatbi-v/core';
3
+ import React from 'react';
4
+ import pkg from '../package.json';
5
+
6
+ const logger = createLogger('{{pluginName}}');
4
7
 
5
8
  /**
6
- * 插件入口类
7
- * 必须实现 Plugin 接口,并导出为 default
8
- *
9
- * 生命周期说明:
10
- * - onLoad: 插件加载时调用,用于初始化状态、注册服务等
11
- * - onUnload: 插件卸载时调用,用于清理资源
9
+ * {{pluginDescription}}
12
10
  */
13
- export class {{className}} implements Plugin {
14
- // 插件唯一标识,必须与 metadata.id 保持一致
15
- id = '{{pluginId}}'
16
-
17
- // 插件元数据定义
18
- metadata = {
19
- id: '{{pluginId}}',
20
- name: '{{pluginId}} Plugin',
21
- version: '1.0.0',
22
- type: '{{pluginType}}' as const, // business | system
23
-
24
- /**
25
- * 路由配置 (可选)
26
- * 如果插件需要注册页面路由,在此处定义
27
- */
11
+ export const {{pluginClassName}} = definePlugin({
12
+ /** 插件元数据 */
13
+ metadata: {
14
+ id: pkg.name,
15
+ name: '{{pluginDisplayName}}',
16
+ version: pkg.version,
17
+ type: '{{pluginType}}', // business | system | renderer
18
+ description: '{{pluginDescription}}',
19
+ capabilities: {
20
+ configurable: true
21
+ },
28
22
  routes: [
29
23
  {
30
- path: '/{{pluginId}}',
31
- // 路由对应的组件
32
- component: () => <div style=\{{ padding: '20px', background: '#f5f5f5', borderRadius: '8px' }}>
33
- <h3>Hello from {{pluginId}} Plugin!</h3>
34
- <p>This is a {{pluginType}} plugin generated by ChatBI CLI.</p>
35
- </div>,
24
+ path: '/{{pluginPath}}',
25
+ component: React.lazy(() => import('./components/MainView')),
36
26
  meta: {
37
- title: '{{pluginId}}',
38
- icon: 'MessageOutlined' // 对应 AntD Icon 名称
27
+ title: '{{pluginDisplayName}}',
28
+ icon: 'RocketOutlined'
39
29
  }
40
30
  }
41
31
  ],
42
-
43
- /**
44
- * 扩展插槽配置 (可选)
45
- * 用于将组件注入到系统的各个位置 (如侧边栏、顶部栏等)
46
- */
47
32
  extensions: [
48
33
  {
49
- slot: Slot.Sidebar, // 注入到侧边栏
50
- component: () => null, // 侧边栏通常不需要组件实体,只需要 meta 信息
51
- order: 10, // 排序权重,越小越靠前
34
+ slot: Slot.Sidebar,
35
+ component: () => null,
36
+ order: 10,
52
37
  meta: {
53
- title: '{{pluginId}}',
54
- icon: <MessageOutlined />, // 直接传入 ReactNode
55
- path: '/{{pluginId}}' // 点击跳转的路径
38
+ icon: <RocketOutlined />,
39
+ label: '{{pluginDisplayName}}',
40
+ path: '/{{pluginPath}}'
56
41
  }
57
42
  }
58
- // 示例:注入到顶部栏
59
- // {
60
- // slot: Slot.TopBar,
61
- // component: () => <MyTopBarComponent />,
62
- // order: 5
63
- // }
43
+ ],
44
+ configuration: [
45
+ // 在此定义插件配置项
46
+ ],
47
+ storage: [
48
+ // 在此定义插件持久化状态
64
49
  ]
65
- }
50
+ },
66
51
 
67
- /**
68
- * 插件加载回调
69
- * @param context 插件上下文,包含 logger, eventBus, serviceRegistry 等
70
- */
71
- onLoad(context: PluginContext) {
72
- context.logger.info('{{className}} Loaded!')
73
-
74
- // 示例:监听事件
75
- // context.eventBus.on('some-event', () => { ... })
76
-
77
- // 示例:注册服务
78
- // context.serviceRegistry.register('myService', new MyService())
79
- }
80
-
81
- /**
82
- * 插件卸载回调 (可选)
83
- */
84
- onUnload() {
85
- // 清理资源
86
- console.log('{{className}} Unloaded')
52
+ async onLoad(context: PluginContext) {
53
+ logger.info('{{pluginDisplayName}} loaded');
87
54
  }
88
- }
55
+ });
89
56
 
90
- export default {{className}}
57
+ export default {{pluginClassName}};
@@ -1,21 +1,10 @@
1
1
  {
2
2
  "extends": "{{tsconfigPath}}",
3
3
  "compilerOptions": {
4
- "target": "ESNext",
5
- "lib": ["DOM", "DOM.Iterable", "ESNext"],
6
- "module": "ESNext",
7
- "skipLibCheck": true,
8
- "moduleResolution": "bundler",
9
- "allowImportingTsExtensions": true,
10
- "resolveJsonModule": true,
11
- "isolatedModules": true,
12
- "noEmit": false,
13
- "declaration": true,
14
- "emitDeclarationOnly": true,
15
- "declarationDir": "./dist",
16
- "jsx": "react-jsx",
17
- "esModuleInterop": true,
18
- "baseUrl": "."
4
+ "outDir": "./dist",
5
+ "rootDir": "./src",
6
+ "moduleResolution": "node",
7
+ "composite": true
19
8
  },
20
9
  "include": ["src"]
21
10
  }
@@ -1,18 +0,0 @@
1
- export default {
2
- login: {
3
- url: '/auth/login',
4
- method: 'POST',
5
- desc: '用户登录',
6
- mock: true,
7
- mockData: {
8
- code: 0,
9
- message: 'success',
10
- data: { token: 'mock-token-123', user: { id: 1, name: 'Admin' } },
11
- },
12
- },
13
- logout: {
14
- url: '/auth/logout',
15
- method: 'POST',
16
- desc: '用户登出',
17
- },
18
- };