flu-cli-core 1.0.0
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/README.md +60 -0
- package/dist/chunk-FOMWV2YP.js +378 -0
- package/dist/chunk-SW6YDKXI.js +112 -0
- package/dist/factory-6DDXZYQP.js +6 -0
- package/dist/index.cjs +4668 -0
- package/dist/index.d.cts +644 -0
- package/dist/index.d.ts +644 -0
- package/dist/index.js +4037 -0
- package/dist/upgrade_snippets-XFR7Q444.js +8 -0
- package/locales/en-US.json +59 -0
- package/locales/zh-CN.json +59 -0
- package/package.json +52 -0
- package/templates/README.md +129 -0
- package/templates/core_files/base/base_list_page.dart.template +225 -0
- package/templates/core_files/base/base_list_viewmodel.dart.template +164 -0
- package/templates/core_files/base/base_page.dart.template +252 -0
- package/templates/core_files/base/base_viewmodel.dart.template +68 -0
- package/templates/core_files/base/index.dart.template +5 -0
- package/templates/core_files/config/app_config.dart.template +142 -0
- package/templates/core_files/config/app_initializer.dart.template +74 -0
- package/templates/core_files/config/index.dart.template +3 -0
- package/templates/core_files/index.dart.template +8 -0
- package/templates/core_files/network/README.md +378 -0
- package/templates/core_files/network/app_error_code.dart.template +49 -0
- package/templates/core_files/network/app_http.dart.template +306 -0
- package/templates/core_files/network/app_response.dart.template +81 -0
- package/templates/core_files/network/index.dart.template +12 -0
- package/templates/core_files/network/interceptors/app_response_interceptor.dart.template +44 -0
- package/templates/core_files/network/interceptors/auth_interceptor.dart.template +30 -0
- package/templates/core_files/network/interceptors/error_interceptor.dart.template +48 -0
- package/templates/core_files/network/interceptors/index.dart.template +6 -0
- package/templates/core_files/network/interceptors/log_interceptor.dart.template +97 -0
- package/templates/core_files/network/interceptors/network_error_interceptor.dart.template +58 -0
- package/templates/core_files/network/interceptors/retry_interceptor.dart.template +69 -0
- package/templates/core_files/network/response_adapter.dart.template +69 -0
- package/templates/core_files/router/app_routes.dart.template +32 -0
- package/templates/core_files/router/index.dart.template +3 -0
- package/templates/core_files/router/navigator_util_getx.dart.template +131 -0
- package/templates/core_files/router/navigator_util_material.dart.template +191 -0
- package/templates/core_files/storage/index.dart.template +3 -0
- package/templates/core_files/storage/storage_keys.dart.template +34 -0
- package/templates/core_files/storage/storage_util.dart.template +102 -0
- package/templates/core_files/theme/app_theme.dart.template +37 -0
- package/templates/core_files/theme/index.dart.template +3 -0
- package/templates/core_files/theme/status_views_theme.dart.template +40 -0
- package/templates/core_files/utils/index.dart.template +2 -0
- package/templates/core_files/utils/loading_util.dart.template +55 -0
- package/templates/core_files/utils/toast_util.dart.template +128 -0
- package/templates/examples/eg_list_page.dart.template +340 -0
- package/templates/examples/eg_list_viewmodel.dart.template +31 -0
- package/templates/examples/eg_service.dart.template +78 -0
- package/templates/examples/mock_data.dart.template +50388 -0
- package/templates/examples/tu_chong_model.dart.template +633 -0
- package/templates/request_helper.dart.template +59 -0
- package/templates/snippets/flu-cli.code-snippets +268 -0
- package/templates/snippets/flu-cli.code-snippets.backup +268 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,644 @@
|
|
|
1
|
+
interface Logger {
|
|
2
|
+
info(message: string): void;
|
|
3
|
+
success(message: string): void;
|
|
4
|
+
warn(message: string): void;
|
|
5
|
+
error(message: string): void;
|
|
6
|
+
title(message: string): void;
|
|
7
|
+
newLine(): void;
|
|
8
|
+
}
|
|
9
|
+
declare class ConsoleLogger implements Logger {
|
|
10
|
+
info(message: string): void;
|
|
11
|
+
success(message: string): void;
|
|
12
|
+
warn(message: string): void;
|
|
13
|
+
error(message: string): void;
|
|
14
|
+
title(message: string): void;
|
|
15
|
+
newLine(): void;
|
|
16
|
+
}
|
|
17
|
+
declare const logger: ConsoleLogger;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 字符串工具函数
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* 转换为 PascalCase
|
|
24
|
+
* home_page -> HomePage
|
|
25
|
+
*/
|
|
26
|
+
declare function toPascalCase(str: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* 转换为 snake_case
|
|
29
|
+
* HomePage -> home_page
|
|
30
|
+
*/
|
|
31
|
+
declare function toSnakeCase(str: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* 转换为 camelCase
|
|
34
|
+
* home_page -> homePage
|
|
35
|
+
*/
|
|
36
|
+
declare function toCamelCase(str: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* 转换为 Title Case
|
|
39
|
+
* home_page -> Home Page
|
|
40
|
+
*/
|
|
41
|
+
declare function toTitleCase(str: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* 转换为 kebab-case
|
|
44
|
+
* HomePage -> home-page
|
|
45
|
+
*/
|
|
46
|
+
declare function toKebabCase(str: string): string;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 项目类型检测工具
|
|
50
|
+
* 职责:基于目录结构识别 lite/modular/clean 模板,并提供生成路径解析
|
|
51
|
+
*/
|
|
52
|
+
/**
|
|
53
|
+
* 检测项目模板类型
|
|
54
|
+
* @param {string} projectDir - 项目目录
|
|
55
|
+
* @returns {'lite'|'modular'|'clean'|string|null} 模板类型
|
|
56
|
+
*/
|
|
57
|
+
type ProjectTemplate$1 = 'lite' | 'modular' | 'clean' | string;
|
|
58
|
+
declare function detectProjectTemplate(projectDir?: string): ProjectTemplate$1 | null;
|
|
59
|
+
/**
|
|
60
|
+
* 检测是否为自定义模板项目
|
|
61
|
+
* @param {string} projectDir - 项目目录
|
|
62
|
+
* @returns {boolean} 是否为自定义模板项目
|
|
63
|
+
*/
|
|
64
|
+
declare function isCustomTemplateProject(projectDir?: string): boolean;
|
|
65
|
+
declare function getStateManager(projectDir?: string): 'default' | 'provider' | 'getx' | 'riverpod';
|
|
66
|
+
/**
|
|
67
|
+
* 获取页面生成路径
|
|
68
|
+
* @param {string} projectDir - 项目目录
|
|
69
|
+
* @param {string} moduleName - 模块名称
|
|
70
|
+
* @returns {string} 页面目录路径
|
|
71
|
+
*/
|
|
72
|
+
declare function getPagePath(projectDir: string, moduleName: string): string;
|
|
73
|
+
/**
|
|
74
|
+
* 获取 ViewModel 生成路径
|
|
75
|
+
*/
|
|
76
|
+
declare function getViewModelPath(projectDir: string, moduleName: string): string;
|
|
77
|
+
/**
|
|
78
|
+
* 获取 Widget 生成路径
|
|
79
|
+
*/
|
|
80
|
+
declare function getWidgetPath(projectDir: string, moduleName?: string | null): string;
|
|
81
|
+
/**
|
|
82
|
+
* 获取 Service 生成路径
|
|
83
|
+
*/
|
|
84
|
+
declare function getServicePath(projectDir: string, moduleName?: string | null): string;
|
|
85
|
+
/**
|
|
86
|
+
* 获取 Model 生成路径
|
|
87
|
+
*/
|
|
88
|
+
declare function getModelPath(projectDir: string, moduleName?: string | null): string;
|
|
89
|
+
/**
|
|
90
|
+
* 获取相对导入路径
|
|
91
|
+
* @param {string} fromPath - 源文件路径
|
|
92
|
+
* @param {string} toPath - 目标文件路径
|
|
93
|
+
* @returns {string} 相对路径
|
|
94
|
+
*/
|
|
95
|
+
declare function getRelativeImportPath(fromPath: string, toPath: string): string;
|
|
96
|
+
|
|
97
|
+
declare function loadProjectSnippets(projectDir: string): any;
|
|
98
|
+
declare function renderSnippet(bodyLines: string[] | string, variables: Record<string, any>): string;
|
|
99
|
+
declare function getSnippetContent(projectDir: string, key: string, variables: Record<string, any>): string | null;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 模板生成器
|
|
103
|
+
* 负责生成各种类型的代码内容,供 Generator 和 Snippets 复用
|
|
104
|
+
*/
|
|
105
|
+
declare class TemplateGenerator {
|
|
106
|
+
/**
|
|
107
|
+
* 生成 Stateful Page (BasePage)
|
|
108
|
+
*/
|
|
109
|
+
/**
|
|
110
|
+
* 生成 Stateful Page (BasePage)
|
|
111
|
+
*/
|
|
112
|
+
static generateStatefulPageWithBase(namePascal: string, nameTitle: string, options?: {
|
|
113
|
+
vmImportPath?: string;
|
|
114
|
+
coreImportPath?: string;
|
|
115
|
+
baseClass?: string;
|
|
116
|
+
extraImports?: string[];
|
|
117
|
+
}): string;
|
|
118
|
+
/**
|
|
119
|
+
* 生成 Simple Stateful Page
|
|
120
|
+
*/
|
|
121
|
+
static generateSimpleStatefulPage(namePascal: string, nameTitle: string): string;
|
|
122
|
+
/**
|
|
123
|
+
* 生成 Simple Stateless Page
|
|
124
|
+
*/
|
|
125
|
+
static generateSimpleStatelessPage(namePascal: string, nameTitle: string): string;
|
|
126
|
+
/**
|
|
127
|
+
* 生成 ViewModel
|
|
128
|
+
*/
|
|
129
|
+
static generateViewModel(namePascal: string, options?: {
|
|
130
|
+
coreImportPath?: string;
|
|
131
|
+
baseClass?: string;
|
|
132
|
+
extraImports?: string[];
|
|
133
|
+
}): string;
|
|
134
|
+
/**
|
|
135
|
+
* 生成 Service
|
|
136
|
+
*/
|
|
137
|
+
static generateService(namePascal: string): string;
|
|
138
|
+
/**
|
|
139
|
+
* 生成 Widget (Stateful)
|
|
140
|
+
*/
|
|
141
|
+
static generateStatefulWidget(namePascal: string): string;
|
|
142
|
+
/**
|
|
143
|
+
* 生成 Widget (Stateless)
|
|
144
|
+
*/
|
|
145
|
+
static generateStatelessWidget(namePascal: string): string;
|
|
146
|
+
/**
|
|
147
|
+
* 生成 Component (Stateless)
|
|
148
|
+
*/
|
|
149
|
+
static generateComponent(namePascal: string): string;
|
|
150
|
+
/**
|
|
151
|
+
* 生成 Component (Stateful)
|
|
152
|
+
*/
|
|
153
|
+
static generateStatefulComponent(namePascal: string): string;
|
|
154
|
+
/**
|
|
155
|
+
* 生成 Model
|
|
156
|
+
*/
|
|
157
|
+
static generateModel(namePascal: string): string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* index.dart 更新工具
|
|
162
|
+
* 自动更新目录的 index.dart 导出文件
|
|
163
|
+
*/
|
|
164
|
+
/**
|
|
165
|
+
* 更新 index.dart 文件
|
|
166
|
+
* @param {string} dirPath - 目录路径
|
|
167
|
+
* @param {string} fileName - 要添加的文件名
|
|
168
|
+
*/
|
|
169
|
+
declare function updateIndexFile(dirPath: string, fileName: string): boolean;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* 获取模板根目录
|
|
173
|
+
* 兼容 ESM 和打包后的场景
|
|
174
|
+
*/
|
|
175
|
+
declare function getTemplatesRootDir(): string;
|
|
176
|
+
/**
|
|
177
|
+
* 获取 core_files 模板目录
|
|
178
|
+
*/
|
|
179
|
+
declare function getCoreFilesDir(): string;
|
|
180
|
+
/**
|
|
181
|
+
* 复制 core 文件到项目
|
|
182
|
+
* @param projectPath 项目根目录
|
|
183
|
+
* @param options 配置选项
|
|
184
|
+
*/
|
|
185
|
+
declare function copyCoreFiles(projectPath: string, options?: {
|
|
186
|
+
includeNetworkLayer?: boolean;
|
|
187
|
+
templateType?: 'lite' | 'modular' | 'clean';
|
|
188
|
+
projectName?: string;
|
|
189
|
+
stateManager?: string;
|
|
190
|
+
}): Promise<void>;
|
|
191
|
+
/**
|
|
192
|
+
* 获取 network 模板目录
|
|
193
|
+
*/
|
|
194
|
+
declare function getNetworkDir(): string;
|
|
195
|
+
/**
|
|
196
|
+
* 复制 network 文件到项目
|
|
197
|
+
* @param projectPath 项目根目录
|
|
198
|
+
* @param targetDir 目标目录(相对于项目根目录),默认为 'lib/core/network'
|
|
199
|
+
* @param includeExamples 是否包含示例文件,默认为 false
|
|
200
|
+
*/
|
|
201
|
+
declare function copyNetworkFiles(projectPath: string, options?: {
|
|
202
|
+
targetDir?: string;
|
|
203
|
+
includeExamples?: boolean;
|
|
204
|
+
}): Promise<void>;
|
|
205
|
+
/**
|
|
206
|
+
* 复制完整的基础设施层(core files)
|
|
207
|
+
* @param projectPath 项目根目录
|
|
208
|
+
* @param includeExamples 是否包含示例文件(已废弃,保留兼容性)
|
|
209
|
+
* @param includeNetwork 是否包含网络层
|
|
210
|
+
*/
|
|
211
|
+
declare function copyInfrastructure(projectPath: string, includeExamples?: boolean, includeNetworkLayer?: boolean, templateType?: 'lite' | 'modular' | 'clean'): Promise<void>;
|
|
212
|
+
/**
|
|
213
|
+
* 移除模板后缀并复制模板
|
|
214
|
+
*/
|
|
215
|
+
declare function copyTemplate(templatePath: string, targetPath: string, options?: {
|
|
216
|
+
excludes?: string[];
|
|
217
|
+
}): Promise<boolean>;
|
|
218
|
+
/**
|
|
219
|
+
* 注入网络层示例代码
|
|
220
|
+
* @param projectPath 项目根目录
|
|
221
|
+
* @param contextData 渲染上下文数据
|
|
222
|
+
*/
|
|
223
|
+
declare function injectNetworkExamples(projectPath: string, contextData?: any): Promise<void>;
|
|
224
|
+
/**
|
|
225
|
+
* 自动生成目录下的 index.dart 导出文件
|
|
226
|
+
*/
|
|
227
|
+
declare function generateIndexFile(dir: string): Promise<void>;
|
|
228
|
+
/**
|
|
229
|
+
* 复制自定义模板(仅 lib, assets, .vscode 等)
|
|
230
|
+
*/
|
|
231
|
+
declare function copyCustomTemplate(templatePath: string, targetPath: string): Promise<boolean>;
|
|
232
|
+
/**
|
|
233
|
+
* 变量替换
|
|
234
|
+
*/
|
|
235
|
+
declare function replaceVariables(projectDir: string, variables: any): Promise<boolean>;
|
|
236
|
+
/**
|
|
237
|
+
* 递归移除目录中所有文件的 .template 后缀
|
|
238
|
+
*/
|
|
239
|
+
declare function removeTemplateSuffix(dir: string): Promise<void>;
|
|
240
|
+
/**
|
|
241
|
+
* 强制校正 pubspec.yaml 的 name 字段为项目名
|
|
242
|
+
*/
|
|
243
|
+
declare function ensurePubspecName(projectDir: string, projectName: string): Promise<void>;
|
|
244
|
+
/**
|
|
245
|
+
* 清理模板特有文件
|
|
246
|
+
*/
|
|
247
|
+
declare function cleanupTemplateFiles(projectDir: string): Promise<void>;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* 页面生成器
|
|
251
|
+
*/
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* 生成页面文件
|
|
255
|
+
*/
|
|
256
|
+
declare function generatePage(name: string, options?: any, logger?: Logger): Promise<boolean>;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* ViewModel 生成器
|
|
260
|
+
*/
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* 生成 ViewModel 文件
|
|
264
|
+
*/
|
|
265
|
+
declare function generateViewModel(name: string, options?: any, logger?: Logger): Promise<boolean>;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Model 生成器
|
|
269
|
+
*/
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* 生成 Model 文件
|
|
273
|
+
*/
|
|
274
|
+
declare function generateModel(name: string, options?: any, logger?: Logger): Promise<boolean>;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Widget 生成器
|
|
278
|
+
*/
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* 生成 Widget 文件
|
|
282
|
+
*/
|
|
283
|
+
declare function generateWidget(name: string, options?: any, logger?: Logger): Promise<boolean>;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Component 生成器
|
|
287
|
+
*/
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* 生成 Component 文件
|
|
291
|
+
*/
|
|
292
|
+
declare function generateComponent(name: string, options?: any, logger?: Logger): Promise<boolean>;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Service 生成器
|
|
296
|
+
*/
|
|
297
|
+
/**
|
|
298
|
+
* 生成 Service 文件
|
|
299
|
+
*/
|
|
300
|
+
declare function generateService(name: string, options?: any, customLogger?: any): Promise<boolean>;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* 模块生成器
|
|
304
|
+
* 用于创建完整的功能模块结构
|
|
305
|
+
*/
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* 生成模块
|
|
309
|
+
*/
|
|
310
|
+
declare function generateModule(name: string, options?: any, logger?: Logger): Promise<boolean>;
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* 升级项目中的 snippets 文件
|
|
314
|
+
*/
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* 升级项目中的 snippets
|
|
318
|
+
*/
|
|
319
|
+
declare function upgradeSnippets(options?: {
|
|
320
|
+
projectDir?: string;
|
|
321
|
+
force?: boolean;
|
|
322
|
+
}, logger?: Logger): Promise<boolean>;
|
|
323
|
+
/**
|
|
324
|
+
* 检查项目 snippets 是否需要更新
|
|
325
|
+
*/
|
|
326
|
+
declare function checkSnippetsVersion(projectDir?: string): 'up-to-date' | 'outdated' | 'missing';
|
|
327
|
+
|
|
328
|
+
interface CustomTemplate {
|
|
329
|
+
id: string;
|
|
330
|
+
name: string;
|
|
331
|
+
type: 'git' | 'local';
|
|
332
|
+
url?: string;
|
|
333
|
+
path?: string;
|
|
334
|
+
branch?: string;
|
|
335
|
+
description?: string;
|
|
336
|
+
lastUsedAt?: number;
|
|
337
|
+
}
|
|
338
|
+
interface FluConfig {
|
|
339
|
+
templates: CustomTemplate[];
|
|
340
|
+
authorName?: string;
|
|
341
|
+
defaultTemplate?: {
|
|
342
|
+
type: 'builtin' | 'custom';
|
|
343
|
+
idOrName: string;
|
|
344
|
+
};
|
|
345
|
+
locale?: string;
|
|
346
|
+
}
|
|
347
|
+
declare class ConfigManager {
|
|
348
|
+
private static instance;
|
|
349
|
+
private configPath;
|
|
350
|
+
private config;
|
|
351
|
+
private constructor();
|
|
352
|
+
static getInstance(): ConfigManager;
|
|
353
|
+
private loadConfig;
|
|
354
|
+
private saveConfig;
|
|
355
|
+
getTemplates(): CustomTemplate[];
|
|
356
|
+
addTemplate(template: CustomTemplate): void;
|
|
357
|
+
removeTemplate(id: string): boolean;
|
|
358
|
+
getTemplate(id: string): CustomTemplate | undefined;
|
|
359
|
+
getAuthorName(): string;
|
|
360
|
+
setAuthorName(name: string): void;
|
|
361
|
+
getDefaultTemplate(): {
|
|
362
|
+
type: "builtin" | "custom";
|
|
363
|
+
idOrName: string;
|
|
364
|
+
};
|
|
365
|
+
setDefaultTemplate(type: 'builtin' | 'custom', idOrName: string): void;
|
|
366
|
+
getLocale(): string;
|
|
367
|
+
setLocale(locale: string): void;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
type ProjectTemplate = string | CustomTemplate;
|
|
371
|
+
interface ProjectOptions {
|
|
372
|
+
templateType?: string;
|
|
373
|
+
template?: string;
|
|
374
|
+
stateManager: 'default' | 'provider' | 'getx' | 'riverpod';
|
|
375
|
+
packageName: string;
|
|
376
|
+
outputDir: string;
|
|
377
|
+
includeNetworkLayer?: boolean;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* ProjectGenerator (V6.0)
|
|
381
|
+
* 采用 Task Pipeline 架构,极简核心,逻辑拆分至各原子 Task。
|
|
382
|
+
*/
|
|
383
|
+
declare class ProjectGenerator {
|
|
384
|
+
/**
|
|
385
|
+
* 生成项目
|
|
386
|
+
* @param {string} name 项目名称
|
|
387
|
+
* @param {object} options 选项
|
|
388
|
+
* @param {Logger} logger 日志工具
|
|
389
|
+
*/
|
|
390
|
+
generate(name: string, options?: any, logger?: Logger): Promise<boolean>;
|
|
391
|
+
/**
|
|
392
|
+
* 检查项目目录是否存在
|
|
393
|
+
*/
|
|
394
|
+
checkProjectExists(projectPath: string): boolean;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* 项目配置管理器
|
|
399
|
+
* 职责:读取和管理项目级别的 .flu-cli.json 配置文件
|
|
400
|
+
*/
|
|
401
|
+
/**
|
|
402
|
+
* 生成器配置接口
|
|
403
|
+
*/
|
|
404
|
+
interface GeneratorConfig {
|
|
405
|
+
path?: string;
|
|
406
|
+
defaultType?: 'stateful' | 'stateless';
|
|
407
|
+
fileSuffix?: string;
|
|
408
|
+
fileName?: string;
|
|
409
|
+
withBasePage?: boolean;
|
|
410
|
+
basePageClass?: string;
|
|
411
|
+
basePageImport?: string;
|
|
412
|
+
withViewModel?: boolean;
|
|
413
|
+
viewModelPath?: string;
|
|
414
|
+
withBaseViewModel?: boolean;
|
|
415
|
+
baseViewModelClass?: string;
|
|
416
|
+
baseViewModelImport?: string;
|
|
417
|
+
withBaseWidget?: boolean;
|
|
418
|
+
baseWidgetClass?: string;
|
|
419
|
+
baseWidgetImport?: string;
|
|
420
|
+
withBaseModel?: boolean;
|
|
421
|
+
baseModelClass?: string;
|
|
422
|
+
baseModelImport?: string;
|
|
423
|
+
template?: 'network' | 'simple' | 'auto' | string;
|
|
424
|
+
snippetKey?: string;
|
|
425
|
+
mockLevel?: 'global' | 'instance';
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* 项目配置接口
|
|
429
|
+
*/
|
|
430
|
+
interface ProjectConfig {
|
|
431
|
+
template?: 'lite' | 'modular' | 'clean' | string;
|
|
432
|
+
packageName?: string;
|
|
433
|
+
generators?: {
|
|
434
|
+
page?: GeneratorConfig;
|
|
435
|
+
viewModel?: GeneratorConfig;
|
|
436
|
+
widget?: GeneratorConfig;
|
|
437
|
+
model?: GeneratorConfig;
|
|
438
|
+
component?: GeneratorConfig;
|
|
439
|
+
service?: GeneratorConfig;
|
|
440
|
+
module?: {
|
|
441
|
+
path?: string;
|
|
442
|
+
};
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* 项目配置管理器
|
|
447
|
+
*/
|
|
448
|
+
declare class ProjectConfigManager {
|
|
449
|
+
private static CONFIG_FILE_NAME;
|
|
450
|
+
/**
|
|
451
|
+
* 加载项目配置
|
|
452
|
+
* @param projectDir 项目目录
|
|
453
|
+
* @returns 配置对象,如果不存在则返回 null
|
|
454
|
+
*/
|
|
455
|
+
static loadConfig(projectDir: string): ProjectConfig | null;
|
|
456
|
+
/**
|
|
457
|
+
* 检查项目是否有配置文件
|
|
458
|
+
* @param projectDir 项目目录
|
|
459
|
+
* @returns 是否存在配置文件
|
|
460
|
+
*/
|
|
461
|
+
static hasConfig(projectDir: string): boolean;
|
|
462
|
+
/**
|
|
463
|
+
* 获取指定生成器的配置
|
|
464
|
+
* @param projectDir 项目目录
|
|
465
|
+
* @param generatorType 生成器类型
|
|
466
|
+
* @returns 生成器配置,如果不存在则返回 null
|
|
467
|
+
*/
|
|
468
|
+
static getGeneratorConfig(projectDir: string, generatorType: 'page' | 'viewModel' | 'widget' | 'model' | 'component'): GeneratorConfig | null;
|
|
469
|
+
/**
|
|
470
|
+
* 获取默认配置模板
|
|
471
|
+
* @param templateType 模板类型
|
|
472
|
+
* @returns 配置模板对象
|
|
473
|
+
*/
|
|
474
|
+
static getDefaultConfigTemplate(templateType: 'lite' | 'modular' | 'clean' | 'custom' | string): ProjectConfig;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* 应用资源选择接口
|
|
479
|
+
*/
|
|
480
|
+
interface AppAssetConfig {
|
|
481
|
+
appIcon?: string;
|
|
482
|
+
splashLogo?: string;
|
|
483
|
+
splashBackground?: string;
|
|
484
|
+
splashBackgroundColor?: string;
|
|
485
|
+
enableDarkMode?: boolean;
|
|
486
|
+
splashLogoDark?: string;
|
|
487
|
+
splashBackgroundDark?: string;
|
|
488
|
+
splashBackgroundColorDark?: string;
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* 应用资源管理器
|
|
492
|
+
* 负责配置应用图标和启动图
|
|
493
|
+
*/
|
|
494
|
+
declare class AppAssetsManager {
|
|
495
|
+
/**
|
|
496
|
+
* 设置应用资源
|
|
497
|
+
* @param projectPath 项目路径
|
|
498
|
+
* @param assets 资源配置
|
|
499
|
+
* @param logger 日志工具
|
|
500
|
+
*/
|
|
501
|
+
setupAppAssets(projectPath: string, assets: AppAssetConfig, logger: Logger): Promise<boolean>;
|
|
502
|
+
/**
|
|
503
|
+
* 复制文件(当源路径与目标路径相同时跳过)
|
|
504
|
+
*/
|
|
505
|
+
private copyIfDifferent;
|
|
506
|
+
/**
|
|
507
|
+
* 更新 pubspec.yaml
|
|
508
|
+
*/
|
|
509
|
+
private updatePubspec;
|
|
510
|
+
/**
|
|
511
|
+
* 移除已存在的配置块(如 flutter_launcher_icons:, flutter_native_splash:)
|
|
512
|
+
*/
|
|
513
|
+
private removeExistingConfigBlocks;
|
|
514
|
+
/**
|
|
515
|
+
* 执行命令
|
|
516
|
+
*/
|
|
517
|
+
private runCommand;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* 模板元数据接口
|
|
522
|
+
*/
|
|
523
|
+
interface TemplateMetadata {
|
|
524
|
+
name: string;
|
|
525
|
+
displayName: string;
|
|
526
|
+
description: string;
|
|
527
|
+
repo: string;
|
|
528
|
+
branch: string;
|
|
529
|
+
complexity: number;
|
|
530
|
+
teamSize: string;
|
|
531
|
+
codeSize: string;
|
|
532
|
+
features: string[];
|
|
533
|
+
structure: string;
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* 模板类型定义
|
|
537
|
+
*/
|
|
538
|
+
type TemplateType = 'builtin' | 'git' | 'local';
|
|
539
|
+
/**
|
|
540
|
+
* 内置模板配置
|
|
541
|
+
*/
|
|
542
|
+
declare const BUILTIN_TEMPLATES: Record<string, TemplateMetadata>;
|
|
543
|
+
/**
|
|
544
|
+
* 模板管理器:负责模板的下载、缓存、管理
|
|
545
|
+
*/
|
|
546
|
+
declare class TemplateManager {
|
|
547
|
+
private static instance;
|
|
548
|
+
private configManager;
|
|
549
|
+
private cacheDir;
|
|
550
|
+
private constructor();
|
|
551
|
+
static getInstance(): TemplateManager;
|
|
552
|
+
/**
|
|
553
|
+
* 获取模板缓存目录
|
|
554
|
+
*/
|
|
555
|
+
getCacheDir(): string;
|
|
556
|
+
/**
|
|
557
|
+
* 确保缓存目录存在
|
|
558
|
+
*/
|
|
559
|
+
private ensureCacheDir;
|
|
560
|
+
/**
|
|
561
|
+
* 获取模板本地路径
|
|
562
|
+
* @param templateName 模板名称
|
|
563
|
+
* @param isCustom 是否为自定义模板
|
|
564
|
+
*/
|
|
565
|
+
getTemplatePath(templateName: string, isCustom?: boolean): string;
|
|
566
|
+
/**
|
|
567
|
+
* 准备模板(确保已缓存且为最新)
|
|
568
|
+
*
|
|
569
|
+
* 支持以下模板源(优先级从高到低):
|
|
570
|
+
* 1. 环境变量指定的本地模板目录 (FLU_CLI_USE_LOCAL_TEMPLATES=true + FLU_CLI_LOCAL_TEMPLATES_DIR)
|
|
571
|
+
* 2. 自定义模板配置 (ConfigManager)
|
|
572
|
+
* 3. 内置模板 (lite/modular/clean)
|
|
573
|
+
*/
|
|
574
|
+
prepareTemplate(templateId: string, logger?: Logger, forceUpdate?: boolean): Promise<string | undefined>;
|
|
575
|
+
/**
|
|
576
|
+
* 通用 Git 仓库缓存逻辑
|
|
577
|
+
*/
|
|
578
|
+
private ensureGitRepoCached;
|
|
579
|
+
/**
|
|
580
|
+
* 克隆仓库
|
|
581
|
+
*/
|
|
582
|
+
private cloneRepo;
|
|
583
|
+
/**
|
|
584
|
+
* 检查模板更新状态
|
|
585
|
+
*/
|
|
586
|
+
checkUpdate(templateId: string): Promise<{
|
|
587
|
+
hasUpdate: boolean;
|
|
588
|
+
message: string;
|
|
589
|
+
}>;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
declare class I18nManager {
|
|
593
|
+
private static instance;
|
|
594
|
+
private locales;
|
|
595
|
+
private locale;
|
|
596
|
+
private localesDir;
|
|
597
|
+
private constructor();
|
|
598
|
+
private resolveLocalesDir;
|
|
599
|
+
static getInstance(): I18nManager;
|
|
600
|
+
private loadLocales;
|
|
601
|
+
setLocale(locale: string): void;
|
|
602
|
+
getLocale(): string;
|
|
603
|
+
t(key: string, params?: Record<string, any>): string;
|
|
604
|
+
}
|
|
605
|
+
declare const t: (key: string, params?: Record<string, any>) => string;
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* Flutter 辅助工具
|
|
609
|
+
* 职责:封装 flutter create/pub get/版本检测等命令调用
|
|
610
|
+
*/
|
|
611
|
+
/**
|
|
612
|
+
* 运行 flutter create 命令
|
|
613
|
+
* @param {string} projectDir - 项目目录
|
|
614
|
+
* @param {string} projectName - 项目名称
|
|
615
|
+
* @param {string} packageName - 包名
|
|
616
|
+
* @returns {Promise<boolean>} 是否成功
|
|
617
|
+
*/
|
|
618
|
+
/**
|
|
619
|
+
* 运行 flutter create 命令
|
|
620
|
+
* @param {string} projectDir - 项目目录
|
|
621
|
+
* @param {string} projectName - 项目名称
|
|
622
|
+
* @param {string} packageName - 包名
|
|
623
|
+
* @param {string} flutterTemplate - Flutter 官方模板 (app, module, package, plugin)
|
|
624
|
+
* @returns {Promise<boolean>} 是否成功
|
|
625
|
+
*/
|
|
626
|
+
declare function runFlutterCreate(projectDir: string, projectName: string, packageName: string, flutterTemplate?: string): Promise<boolean>;
|
|
627
|
+
/**
|
|
628
|
+
* 运行 flutter pub get
|
|
629
|
+
* @param {string} projectDir - 项目目录
|
|
630
|
+
* @returns {Promise<boolean>} 是否成功
|
|
631
|
+
*/
|
|
632
|
+
declare function runFlutterPubGet(projectDir: string): Promise<boolean>;
|
|
633
|
+
/**
|
|
634
|
+
* 检查 Flutter 是否安装
|
|
635
|
+
* @returns {Promise<boolean>} 是否已安装
|
|
636
|
+
*/
|
|
637
|
+
declare function checkFlutterInstalled(): Promise<boolean>;
|
|
638
|
+
/**
|
|
639
|
+
* 获取 Flutter 版本
|
|
640
|
+
* @returns {Promise<string|null>} Flutter 版本
|
|
641
|
+
*/
|
|
642
|
+
declare function getFlutterVersion(): Promise<string | null>;
|
|
643
|
+
|
|
644
|
+
export { type AppAssetConfig, AppAssetsManager, BUILTIN_TEMPLATES, ConfigManager, ConsoleLogger, type CustomTemplate, type FluConfig, type GeneratorConfig, I18nManager, type Logger, type ProjectConfig, ProjectConfigManager, ProjectGenerator, type ProjectOptions, type ProjectTemplate, TemplateGenerator, TemplateManager, type TemplateType, checkFlutterInstalled, checkSnippetsVersion, cleanupTemplateFiles, copyCoreFiles, copyCustomTemplate, copyInfrastructure, copyNetworkFiles, copyTemplate, detectProjectTemplate, ensurePubspecName, generateComponent, generateIndexFile, generateModel, generateModule, generatePage, generateService, generateViewModel, generateWidget, getCoreFilesDir, getFlutterVersion, getModelPath, getNetworkDir, getPagePath, getRelativeImportPath, getServicePath, getSnippetContent, getStateManager, getTemplatesRootDir, getViewModelPath, getWidgetPath, injectNetworkExamples, isCustomTemplateProject, loadProjectSnippets, logger, removeTemplateSuffix, renderSnippet, replaceVariables, runFlutterCreate, runFlutterPubGet, t, toCamelCase, toKebabCase, toPascalCase, toSnakeCase, toTitleCase, updateIndexFile, upgradeSnippets };
|