@mindbase/cli 1.0.4 → 1.0.8

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.
@@ -0,0 +1,140 @@
1
+ export interface BackendModule {
2
+ name: string;
3
+ required?: boolean;
4
+ description: string;
5
+ package: string;
6
+ dependencies?: string[];
7
+ }
8
+
9
+ /**
10
+ * 后端模块定义
11
+ */
12
+ export const BACKEND_MODULES: BackendModule[] = [
13
+ { name: "auth", required: true, description: "认证权限", package: "@mindbase/express-auth" },
14
+ { name: "kv", description: "键值存储", package: "@mindbase/express-kv" },
15
+ { name: "admin", dependencies: ["auth"], description: "用户管理", package: "@mindbase/express-admin" },
16
+ { name: "storage", dependencies: ["auth", "kv"], description: "文件存储", package: "@mindbase/express-storage" },
17
+ { name: "explorer", description: "文件管理", package: "@mindbase/express-explorer" },
18
+ { name: "knowledge", dependencies: ["auth"], description: "知识库", package: "@mindbase/express-knowledge" },
19
+ { name: "commandRunner", description: "命令管理", package: "@mindbase/express-command-runner" },
20
+ ];
21
+
22
+ /**
23
+ * 前端应用形态定义
24
+ */
25
+ export interface FrontendAppType {
26
+ name: string;
27
+ description: string;
28
+ package: string;
29
+ available: boolean;
30
+ dependencies?: string[];
31
+ }
32
+
33
+ export const FRONTEND_APP_TYPES: FrontendAppType[] = [
34
+ {
35
+ name: "admin-app",
36
+ description: "管理后台 - 完整的管理界面",
37
+ package: "@mindbase/vue3-admin-app",
38
+ available: true,
39
+ dependencies: ["@mindbase/vue3-auth", "@mindbase/vue3-kv", "@mindbase/vue3-client"],
40
+ },
41
+ ];
42
+
43
+ /**
44
+ * 解析模块依赖关系
45
+ * @param selectedModules 用户选择的模块列表
46
+ * @returns 包含所有依赖的完整模块列表
47
+ */
48
+ export function resolveDependencies(selectedModules: string[]): BackendModule[] {
49
+ const result = new Map<string, BackendModule>();
50
+
51
+ function addModule(name: string) {
52
+ if (result.has(name)) return;
53
+
54
+ const module = BACKEND_MODULES.find((m) => m.name === name);
55
+ if (!module) return;
56
+
57
+ // 先添加依赖
58
+ if (module.dependencies) {
59
+ for (const dep of module.dependencies) {
60
+ addModule(dep);
61
+ }
62
+ }
63
+
64
+ // 再添加自己
65
+ result.set(module.name, module);
66
+ }
67
+
68
+ for (const name of selectedModules) {
69
+ addModule(name);
70
+ }
71
+
72
+ return Array.from(result.values());
73
+ }
74
+
75
+ /**
76
+ * 获取前端应用的包名
77
+ * @param appType 应用类型
78
+ * @returns npm 包名
79
+ */
80
+ export function getFrontendPackage(appType: string): string | undefined {
81
+ const app = FRONTEND_APP_TYPES.find((a) => a.name === appType);
82
+ return app?.package;
83
+ }
84
+
85
+ /**
86
+ * 获取可用的前端应用列表
87
+ * @returns 可用的应用类型列表
88
+ */
89
+ export function getAvailableFrontendApps() {
90
+ return FRONTEND_APP_TYPES.filter((app) => app.available);
91
+ }
92
+
93
+ /**
94
+ * 已知包的依赖关系(来自 sdk-meta.json)
95
+ */
96
+ const KNOWN_PACKAGE_DEPS: Record<string, string[]> = {
97
+ "@mindbase/vue3-auth": ["@mindbase/vue3-kit", "@mindbase/vue3-client"],
98
+ "@mindbase/vue3-kv": ["@mindbase/vue3-kit", "@mindbase/vue3-client"],
99
+ "@mindbase/vue3-storage": ["@mindbase/vue3-kit", "@mindbase/vue3-client", "spark-md5"],
100
+ "@mindbase/vue3-command": ["@mindbase/vue3-kit", "@mindbase/vue3-client"],
101
+ "@mindbase/vue3-explorer": ["@mindbase/vue3-kit", "@mindbase/vue3-client"],
102
+ };
103
+
104
+ /**
105
+ * 解析前端应用依赖的包
106
+ * @param appType 应用类型
107
+ * @returns 包含所有依赖的完整包列表
108
+ */
109
+ export function resolveFrontendDependencies(appType: string): string[] {
110
+ const packages = new Set<string>();
111
+
112
+ function addPackage(packageName: string) {
113
+ if (packages.has(packageName)) return;
114
+
115
+ // 添加当前包
116
+ packages.add(packageName);
117
+
118
+ // 查找是否有应用定义了这个包
119
+ const app = FRONTEND_APP_TYPES.find((a) => a.package === packageName);
120
+ if (app?.dependencies) {
121
+ for (const dep of app.dependencies) {
122
+ addPackage(dep);
123
+ }
124
+ }
125
+
126
+ // 处理已知的基础依赖关系
127
+ if (KNOWN_PACKAGE_DEPS[packageName]) {
128
+ for (const dep of KNOWN_PACKAGE_DEPS[packageName]) {
129
+ addPackage(dep);
130
+ }
131
+ }
132
+ }
133
+
134
+ const app = FRONTEND_APP_TYPES.find((a) => a.name === appType);
135
+ if (app) {
136
+ addPackage(app.package);
137
+ }
138
+
139
+ return Array.from(packages);
140
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "esModuleInterop": true,
7
+ "skipLibCheck": true,
8
+ "strict": true,
9
+ "outDir": "dist",
10
+ "declaration": true,
11
+ "declarationMap": true
12
+ },
13
+ "include": ["src/**/*"],
14
+ "exclude": ["node_modules", "dist"]
15
+ }
@@ -1 +0,0 @@
1
- #!/usr/bin/env node
@@ -1,40 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- init
4
- } from "../chunk-U3UDAQCW.js";
5
-
6
- // src/bin/mindbase.ts
7
- var args = process.argv.slice(2);
8
- var command = args[0];
9
- var type = args[1];
10
- async function main() {
11
- switch (command) {
12
- case "init":
13
- await init(type);
14
- break;
15
- default:
16
- showHelp();
17
- break;
18
- }
19
- }
20
- function showHelp() {
21
- console.log(`
22
- \u7528\u6CD5: mindbase <command> [type]
23
-
24
- \u547D\u4EE4:
25
- init [type] \u521D\u59CB\u5316\u65B0\u9879\u76EE
26
- backend \u540E\u7AEF\u9879\u76EE
27
- frontend \u524D\u7AEF\u9879\u76EE
28
- admin \u7BA1\u7406\u540E\u53F0\u524D\u540E\u7AEF
29
-
30
- \u793A\u4F8B:
31
- mindbase init backend # \u4EA4\u4E92\u5F0F\u9009\u62E9\u540E\u7AEF\u6A21\u5757
32
- mindbase init frontend # \u4EA4\u4E92\u5F0F\u9009\u62E9\u524D\u7AEF\u5E94\u7528\u5F62\u6001
33
- mindbase init admin # \u4E00\u952E\u521D\u59CB\u5316\u5B8C\u6574\u7BA1\u7406\u540E\u53F0
34
- `);
35
- }
36
- main().catch((err) => {
37
- console.error("\u274C \u6267\u884C\u5931\u8D25:", err);
38
- process.exit(1);
39
- });
40
- //# sourceMappingURL=mindbase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/bin/mindbase.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { init } from \"../commands/init\";\n\nconst args = process.argv.slice(2);\nconst command = args[0];\nconst type = args[1];\n\nasync function main() {\n switch (command) {\n case \"init\":\n await init(type);\n break;\n default:\n showHelp();\n break;\n }\n}\n\nfunction showHelp() {\n console.log(`\n用法: mindbase <command> [type]\n\n命令:\n init [type] 初始化新项目\n backend 后端项目\n frontend 前端项目\n admin 管理后台前后端\n\n示例:\n mindbase init backend # 交互式选择后端模块\n mindbase init frontend # 交互式选择前端应用形态\n mindbase init admin # 一键初始化完整管理后台\n `);\n}\n\nmain().catch((err) => {\n console.error(\"❌ 执行失败:\", err);\n process.exit(1);\n});\n"],"mappings":";;;;;;AAGA,IAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,IAAM,UAAU,KAAK,CAAC;AACtB,IAAM,OAAO,KAAK,CAAC;AAEnB,eAAe,OAAO;AACpB,UAAQ,SAAS;AAAA,IACf,KAAK;AACH,YAAM,KAAK,IAAI;AACf;AAAA,IACF;AACE,eAAS;AACT;AAAA,EACJ;AACF;AAEA,SAAS,WAAW;AAClB,UAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAaX;AACH;AAEA,KAAK,EAAE,MAAM,CAAC,QAAQ;AACpB,UAAQ,MAAM,oCAAW,GAAG;AAC5B,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}