super-dev 2.0.0__py3-none-any.whl
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.
- super_dev/__init__.py +11 -0
- super_dev/analyzer/__init__.py +34 -0
- super_dev/analyzer/analyzer.py +440 -0
- super_dev/analyzer/detectors.py +511 -0
- super_dev/analyzer/models.py +285 -0
- super_dev/cli.py +3257 -0
- super_dev/config/__init__.py +11 -0
- super_dev/config/frontend.py +557 -0
- super_dev/config/manager.py +281 -0
- super_dev/creators/__init__.py +26 -0
- super_dev/creators/creator.py +134 -0
- super_dev/creators/document_generator.py +2473 -0
- super_dev/creators/frontend_builder.py +371 -0
- super_dev/creators/implementation_builder.py +789 -0
- super_dev/creators/prompt_generator.py +289 -0
- super_dev/creators/requirement_parser.py +354 -0
- super_dev/creators/spec_builder.py +195 -0
- super_dev/deployers/__init__.py +20 -0
- super_dev/deployers/cicd.py +1269 -0
- super_dev/deployers/delivery.py +229 -0
- super_dev/deployers/migration.py +1032 -0
- super_dev/design/__init__.py +74 -0
- super_dev/design/aesthetics.py +530 -0
- super_dev/design/charts.py +396 -0
- super_dev/design/codegen.py +379 -0
- super_dev/design/engine.py +528 -0
- super_dev/design/generator.py +395 -0
- super_dev/design/landing.py +422 -0
- super_dev/design/tech_stack.py +524 -0
- super_dev/design/tokens.py +269 -0
- super_dev/design/ux_guide.py +391 -0
- super_dev/exceptions.py +119 -0
- super_dev/experts/__init__.py +19 -0
- super_dev/experts/service.py +161 -0
- super_dev/integrations/__init__.py +7 -0
- super_dev/integrations/manager.py +264 -0
- super_dev/orchestrator/__init__.py +12 -0
- super_dev/orchestrator/engine.py +958 -0
- super_dev/orchestrator/experts.py +423 -0
- super_dev/orchestrator/knowledge.py +352 -0
- super_dev/orchestrator/quality.py +356 -0
- super_dev/reviewers/__init__.py +17 -0
- super_dev/reviewers/code_review.py +471 -0
- super_dev/reviewers/quality_gate.py +964 -0
- super_dev/reviewers/redteam.py +881 -0
- super_dev/skills/__init__.py +7 -0
- super_dev/skills/manager.py +307 -0
- super_dev/specs/__init__.py +44 -0
- super_dev/specs/generator.py +264 -0
- super_dev/specs/manager.py +428 -0
- super_dev/specs/models.py +348 -0
- super_dev/specs/validator.py +415 -0
- super_dev/utils/__init__.py +11 -0
- super_dev/utils/logger.py +133 -0
- super_dev/web/api.py +1402 -0
- super_dev-2.0.0.dist-info/METADATA +252 -0
- super_dev-2.0.0.dist-info/RECORD +61 -0
- super_dev-2.0.0.dist-info/WHEEL +5 -0
- super_dev-2.0.0.dist-info/entry_points.txt +2 -0
- super_dev-2.0.0.dist-info/licenses/LICENSE +21 -0
- super_dev-2.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
"""
|
|
2
|
+
开发:Excellent(11964948@qq.com)
|
|
3
|
+
功能:前端配置系统 - 商业级前端技术栈配置
|
|
4
|
+
作用:提供全面的前端框架、组件库、工具链配置
|
|
5
|
+
创建时间:2025-12-30
|
|
6
|
+
最后修改:2025-12-30
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from dataclasses import dataclass, field
|
|
10
|
+
from enum import Enum
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class FrameworkCategory(str, Enum):
|
|
15
|
+
"""前端框架类别"""
|
|
16
|
+
REACT = "react"
|
|
17
|
+
VUE = "vue"
|
|
18
|
+
ANGULAR = "angular"
|
|
19
|
+
SVELTE = "svelte"
|
|
20
|
+
ASTRO = "astro"
|
|
21
|
+
SOLID = "solid"
|
|
22
|
+
QWIK = "qwik"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class BuildTool(str, Enum):
|
|
26
|
+
"""构建工具"""
|
|
27
|
+
VITE = "vite"
|
|
28
|
+
WEBPACK = "webpack"
|
|
29
|
+
ESBUILD = "esbuild"
|
|
30
|
+
SWC = "swc"
|
|
31
|
+
ROLLUP = "rollup"
|
|
32
|
+
TURBOPACK = "turbo"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class TestingFramework(str, Enum):
|
|
36
|
+
"""测试框架"""
|
|
37
|
+
VITEST = "vitest"
|
|
38
|
+
JEST = "jest"
|
|
39
|
+
PLAYWRIGHT = "playwright"
|
|
40
|
+
CYPRESS = "cypress"
|
|
41
|
+
TESTING_LIBRARY = "testing-library"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class StyleSolution(str, Enum):
|
|
45
|
+
"""样式方案"""
|
|
46
|
+
TAILWIND = "tailwind"
|
|
47
|
+
CSS_MODULES = "css-modules"
|
|
48
|
+
STYLED_COMPONENTS = "styled-components"
|
|
49
|
+
EMOTION = "emotion"
|
|
50
|
+
SCSS = "scss"
|
|
51
|
+
LESS = "less"
|
|
52
|
+
UNOCSS = "unocss"
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class StateManagement(str, Enum):
|
|
56
|
+
"""状态管理"""
|
|
57
|
+
# Server State
|
|
58
|
+
REACT_QUERY = "react-query"
|
|
59
|
+
SWR = "swr"
|
|
60
|
+
VUE_QUERY = "vue-query"
|
|
61
|
+
VUEUSE = "vueuse"
|
|
62
|
+
|
|
63
|
+
# Client State
|
|
64
|
+
ZUSTAND = "zustand"
|
|
65
|
+
PINIA = "pinia"
|
|
66
|
+
REDUX_TOOLKIT = "redux-toolkit"
|
|
67
|
+
JOTAI = "jotai"
|
|
68
|
+
RECOIL = "recoil"
|
|
69
|
+
XSTATE = "xstate"
|
|
70
|
+
VALTIO = "valtio"
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# 前端框架定义
|
|
74
|
+
FRAMEWORKS: dict[str, dict[str, Any]] = {
|
|
75
|
+
# React 生态
|
|
76
|
+
"next": {
|
|
77
|
+
"name": "Next.js",
|
|
78
|
+
"category": FrameworkCategory.REACT,
|
|
79
|
+
"description": "React 全栈框架,支持 SSR/SSG",
|
|
80
|
+
"features": ["ssr", "ssg", " isr", "api-routes", "file-routing"],
|
|
81
|
+
"build_tool": BuildTool.TURBOPACK,
|
|
82
|
+
"recommended_for": ["seo-critical", "fullstack", "ecommerce"],
|
|
83
|
+
},
|
|
84
|
+
"remix": {
|
|
85
|
+
"name": "Remix",
|
|
86
|
+
"category": FrameworkCategory.REACT,
|
|
87
|
+
"description": "专注于 Web 标准和渐进增强的 React 框架",
|
|
88
|
+
"features": ["ssr", "nested-routes", "forms", "progressive-enhancement"],
|
|
89
|
+
"build_tool": BuildTool.ESBUILD,
|
|
90
|
+
"recommended_for": ["web-standards", "progressive-enhancement"],
|
|
91
|
+
},
|
|
92
|
+
"react-vite": {
|
|
93
|
+
"name": "React + Vite",
|
|
94
|
+
"category": FrameworkCategory.REACT,
|
|
95
|
+
"description": "使用 Vite 的现代 React SPA",
|
|
96
|
+
"features": ["spa", "hmr", "fast-build"],
|
|
97
|
+
"build_tool": BuildTool.VITE,
|
|
98
|
+
"recommended_for": ["spa", "dashboard", "admin-panel"],
|
|
99
|
+
},
|
|
100
|
+
"gatsby": {
|
|
101
|
+
"name": "Gatsby",
|
|
102
|
+
"category": FrameworkCategory.REACT,
|
|
103
|
+
"description": "基于 React 的静态站点生成器",
|
|
104
|
+
"features": ["ssg", "graphql", "content-aggregation"],
|
|
105
|
+
"build_tool": BuildTool.WEBPACK,
|
|
106
|
+
"recommended_for": ["blog", "marketing-site", "documentation"],
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
# Vue 生态
|
|
110
|
+
"nuxt": {
|
|
111
|
+
"name": "Nuxt",
|
|
112
|
+
"category": FrameworkCategory.VUE,
|
|
113
|
+
"description": "Vue 全栈框架,支持 SSR/SSG",
|
|
114
|
+
"features": ["ssr", "ssg", "file-routing", "auto-imports"],
|
|
115
|
+
"build_tool": BuildTool.VITE,
|
|
116
|
+
"recommended_for": ["seo-critical", "fullstack", "universal-app"],
|
|
117
|
+
},
|
|
118
|
+
"vue-vite": {
|
|
119
|
+
"name": "Vue + Vite",
|
|
120
|
+
"category": FrameworkCategory.VUE,
|
|
121
|
+
"description": "使用 Vite 的现代 Vue SPA",
|
|
122
|
+
"features": ["spa", "hmr", "fast-build"],
|
|
123
|
+
"build_tool": BuildTool.VITE,
|
|
124
|
+
"recommended_for": ["spa", "dashboard", "admin-panel"],
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
# Angular
|
|
128
|
+
"angular": {
|
|
129
|
+
"name": "Angular",
|
|
130
|
+
"category": FrameworkCategory.ANGULAR,
|
|
131
|
+
"description": "Google 维护的企业级前端框架",
|
|
132
|
+
"features": ["ssr", "cli", "di", "rxjs", "http-client"],
|
|
133
|
+
"build_tool": BuildTool.ESBUILD,
|
|
134
|
+
"recommended_for": ["enterprise", "large-scale"],
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
# Svelte
|
|
138
|
+
"sveltekit": {
|
|
139
|
+
"name": "SvelteKit",
|
|
140
|
+
"category": FrameworkCategory.SVELTE,
|
|
141
|
+
"description": "Svelte 全栈框架",
|
|
142
|
+
"features": ["ssr", "ssg", "file-routing", "no-build-step"],
|
|
143
|
+
"build_tool": BuildTool.VITE,
|
|
144
|
+
"recommended_for": ["performance", "seo-critical", "universal-app"],
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
# 其他
|
|
148
|
+
"astro": {
|
|
149
|
+
"name": "Astro",
|
|
150
|
+
"category": FrameworkCategory.ASTRO,
|
|
151
|
+
"description": "内容优先的 Web 框架,零 JS 默认",
|
|
152
|
+
"features": ["ssg", "islands", "multi-framework", "content-focused"],
|
|
153
|
+
"build_tool": BuildTool.VITE,
|
|
154
|
+
"recommended_for": ["blog", "documentation", "marketing", "content-site"],
|
|
155
|
+
},
|
|
156
|
+
"solid": {
|
|
157
|
+
"name": "Solid.js",
|
|
158
|
+
"category": FrameworkCategory.SOLID,
|
|
159
|
+
"description": "高性能响应式库,类似 React 语法的细粒度响应式",
|
|
160
|
+
"features": ["reactive", "jsx", "no-virtual-dom"],
|
|
161
|
+
"build_tool": BuildTool.VITE,
|
|
162
|
+
"recommended_for": ["performance-critical", "react-alternative"],
|
|
163
|
+
},
|
|
164
|
+
"qwik": {
|
|
165
|
+
"name": "Qwik",
|
|
166
|
+
"category": FrameworkCategory.QWIK,
|
|
167
|
+
"description": "可_resume 的框架,极致性能优化",
|
|
168
|
+
"features": ["resumable", "lazy-load-everything", "no-hydration"],
|
|
169
|
+
"build_tool": BuildTool.VITE,
|
|
170
|
+
"recommended_for": ["performance-critical", "edge-caching"],
|
|
171
|
+
},
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
# UI 组件库
|
|
175
|
+
UI_LIBRARIES: dict[str, dict[str, Any]] = {
|
|
176
|
+
# React 组件库
|
|
177
|
+
"mui": {
|
|
178
|
+
"name": "Material-UI (MUI)",
|
|
179
|
+
"framework": FrameworkCategory.REACT,
|
|
180
|
+
"description": "Google Material Design 实现",
|
|
181
|
+
"features": ["components", "theming", "icons"],
|
|
182
|
+
"bundle_size": "large",
|
|
183
|
+
},
|
|
184
|
+
"ant-design": {
|
|
185
|
+
"name": "Ant Design",
|
|
186
|
+
"framework": FrameworkCategory.REACT,
|
|
187
|
+
"description": "企业级 UI 设计语言",
|
|
188
|
+
"features": ["components", "templates", "pro-components"],
|
|
189
|
+
"bundle_size": "large",
|
|
190
|
+
"recommended_for": ["enterprise", "admin-panel"],
|
|
191
|
+
},
|
|
192
|
+
"chakra-ui": {
|
|
193
|
+
"name": "Chakra UI",
|
|
194
|
+
"framework": FrameworkCategory.REACT,
|
|
195
|
+
"description": "简单、模块化、可访问的组件库",
|
|
196
|
+
"features": ["components", "theming", "dark-mode", "a11y"],
|
|
197
|
+
"bundle_size": "medium",
|
|
198
|
+
"style": ["emotion"],
|
|
199
|
+
},
|
|
200
|
+
"mantine": {
|
|
201
|
+
"name": "Mantine",
|
|
202
|
+
"framework": FrameworkCategory.REACT,
|
|
203
|
+
"description": "功能丰富的 React 组件库",
|
|
204
|
+
"features": ["components", "hooks", "form", "modals"],
|
|
205
|
+
"bundle_size": "medium",
|
|
206
|
+
"style": ["emotion", "scss"],
|
|
207
|
+
},
|
|
208
|
+
"shadcn-ui": {
|
|
209
|
+
"name": "shadcn/ui",
|
|
210
|
+
"framework": FrameworkCategory.REACT,
|
|
211
|
+
"description": "基于 Radix UI 的可复制组件",
|
|
212
|
+
"features": ["components", "copy-paste", "customizable"],
|
|
213
|
+
"bundle_size": "small",
|
|
214
|
+
"style": ["tailwind"],
|
|
215
|
+
"recommended_for": ["custom-design", "tailwind-users"],
|
|
216
|
+
},
|
|
217
|
+
"radix-ui": {
|
|
218
|
+
"name": "Radix UI",
|
|
219
|
+
"framework": FrameworkCategory.REACT,
|
|
220
|
+
"description": "无样式、无障碍的原始组件",
|
|
221
|
+
"features": ["a11y", "unstyled", "headless"],
|
|
222
|
+
"bundle_size": "small",
|
|
223
|
+
"recommended_for": ["custom-design", "a11y-critical"],
|
|
224
|
+
},
|
|
225
|
+
"react-aria": {
|
|
226
|
+
"name": "React Aria",
|
|
227
|
+
"framework": FrameworkCategory.REACT,
|
|
228
|
+
"description": "Adobe 开发的无障碍组件库",
|
|
229
|
+
"features": ["a11y", "internationalization", "unstyled"],
|
|
230
|
+
"bundle_size": "small",
|
|
231
|
+
"recommended_for": ["a11y-critical", "i18n"],
|
|
232
|
+
},
|
|
233
|
+
|
|
234
|
+
# Vue 组件库
|
|
235
|
+
"element-plus": {
|
|
236
|
+
"name": "Element Plus",
|
|
237
|
+
"framework": FrameworkCategory.VUE,
|
|
238
|
+
"description": "Vue 3 组件库",
|
|
239
|
+
"features": ["components", "i18n", "theme"],
|
|
240
|
+
"bundle_size": "large",
|
|
241
|
+
"recommended_for": ["admin-panel", "enterprise"],
|
|
242
|
+
},
|
|
243
|
+
"naive-ui": {
|
|
244
|
+
"name": "Naive UI",
|
|
245
|
+
"framework": FrameworkCategory.VUE,
|
|
246
|
+
"description": " Vue 3 组件库,TypeScript 友好",
|
|
247
|
+
"features": ["components", "themes", "tree-shaking"],
|
|
248
|
+
"bundle_size": "medium",
|
|
249
|
+
"recommended_for": ["typescript-project"],
|
|
250
|
+
},
|
|
251
|
+
"vuetify": {
|
|
252
|
+
"name": "Vuetify",
|
|
253
|
+
"framework": FrameworkCategory.VUE,
|
|
254
|
+
"description": "Material Design 组件库",
|
|
255
|
+
"features": ["components", "material-design", "cli"],
|
|
256
|
+
"bundle_size": "large",
|
|
257
|
+
"style": ["scss"],
|
|
258
|
+
},
|
|
259
|
+
"primevue": {
|
|
260
|
+
"name": "PrimeVue",
|
|
261
|
+
"framework": FrameworkCategory.VUE,
|
|
262
|
+
"description": "完整的 Vue UI 组件套件",
|
|
263
|
+
"features": ["components", "themes", "icons"],
|
|
264
|
+
"bundle_size": "medium",
|
|
265
|
+
},
|
|
266
|
+
"arco-design": {
|
|
267
|
+
"name": "Arco Design",
|
|
268
|
+
"framework": FrameworkCategory.VUE,
|
|
269
|
+
"description": "字节跳动企业级设计系统",
|
|
270
|
+
"features": ["components", "themes", "enterprise"],
|
|
271
|
+
"bundle_size": "medium",
|
|
272
|
+
"recommended_for": ["enterprise", "chinese-market"],
|
|
273
|
+
},
|
|
274
|
+
|
|
275
|
+
# Angular 组件库
|
|
276
|
+
"angular-material": {
|
|
277
|
+
"name": "Angular Material",
|
|
278
|
+
"framework": FrameworkCategory.ANGULAR,
|
|
279
|
+
"description": "Material Design for Angular",
|
|
280
|
+
"features": ["components", "cdk", "theming"],
|
|
281
|
+
"bundle_size": "medium",
|
|
282
|
+
},
|
|
283
|
+
"primeng": {
|
|
284
|
+
"name": "PrimeNG",
|
|
285
|
+
"framework": FrameworkCategory.ANGULAR,
|
|
286
|
+
"description": "完整的 Angular UI 组件套件",
|
|
287
|
+
"features": ["components", "themes", "templates"],
|
|
288
|
+
"bundle_size": "medium",
|
|
289
|
+
},
|
|
290
|
+
|
|
291
|
+
# Svelte 组件库
|
|
292
|
+
"skeleton-ui": {
|
|
293
|
+
"name": "Skeleton UI",
|
|
294
|
+
"framework": FrameworkCategory.SVELTE,
|
|
295
|
+
"description": "Svelte 的 Tailwind CSS 组件库",
|
|
296
|
+
"features": ["components", "themes", "dark-mode"],
|
|
297
|
+
"bundle_size": "small",
|
|
298
|
+
"style": ["tailwind"],
|
|
299
|
+
},
|
|
300
|
+
"svelte-material-ui": {
|
|
301
|
+
"name": "Svelte Material UI",
|
|
302
|
+
"framework": FrameworkCategory.SVELTE,
|
|
303
|
+
"description": "Material Design for Svelte",
|
|
304
|
+
"features": ["components", "material-design"],
|
|
305
|
+
"bundle_size": "medium",
|
|
306
|
+
},
|
|
307
|
+
|
|
308
|
+
# 跨框架
|
|
309
|
+
"tailwind": {
|
|
310
|
+
"name": "Tailwind CSS",
|
|
311
|
+
"framework": "any",
|
|
312
|
+
"description": "实用优先的 CSS 框架",
|
|
313
|
+
"features": ["utility-first", "responsive", "dark-mode"],
|
|
314
|
+
"bundle_size": "small",
|
|
315
|
+
"recommended_for": ["custom-design", "rapid-development"],
|
|
316
|
+
},
|
|
317
|
+
"daisyui": {
|
|
318
|
+
"name": "DaisyUI",
|
|
319
|
+
"framework": "any",
|
|
320
|
+
"description": "基于 Tailwind 的组件库",
|
|
321
|
+
"features": ["components", "themes", "tailwind"],
|
|
322
|
+
"bundle_size": "small",
|
|
323
|
+
"style": ["tailwind"],
|
|
324
|
+
},
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
# 状态管理方案
|
|
328
|
+
STATE_MANAGEMENT_OPTIONS: dict[str, dict[str, Any]] = {
|
|
329
|
+
"react-query": {
|
|
330
|
+
"name": "React Query (TanStack Query)",
|
|
331
|
+
"framework": FrameworkCategory.REACT,
|
|
332
|
+
"type": "server-state",
|
|
333
|
+
"description": "强大的服务端状态管理",
|
|
334
|
+
"features": ["caching", "synchronization", "background-updates"],
|
|
335
|
+
"recommended_for": ["api-heavy", "server-state"],
|
|
336
|
+
},
|
|
337
|
+
"swr": {
|
|
338
|
+
"name": "SWR",
|
|
339
|
+
"framework": FrameworkCategory.REACT,
|
|
340
|
+
"type": "server-state",
|
|
341
|
+
"description": "轻量级数据获取库",
|
|
342
|
+
"features": ["caching", "revalidation", "stale-while-revalidate"],
|
|
343
|
+
"recommended_for": ["simple-api", "lightweight"],
|
|
344
|
+
},
|
|
345
|
+
"zustand": {
|
|
346
|
+
"name": "Zustand",
|
|
347
|
+
"framework": FrameworkCategory.REACT,
|
|
348
|
+
"type": "client-state",
|
|
349
|
+
"description": "轻量级状态管理",
|
|
350
|
+
"features": ["simple", "no-boilerplate", "devtools"],
|
|
351
|
+
"recommended_for": ["client-state", "simple-store"],
|
|
352
|
+
},
|
|
353
|
+
"redux-toolkit": {
|
|
354
|
+
"name": "Redux Toolkit",
|
|
355
|
+
"framework": FrameworkCategory.REACT,
|
|
356
|
+
"type": "client-state",
|
|
357
|
+
"description": "Redux 官方推荐工具集",
|
|
358
|
+
"features": ["immutable", "middleware", "devtools"],
|
|
359
|
+
"recommended_for": ["large-scale", "complex-state"],
|
|
360
|
+
},
|
|
361
|
+
"jotai": {
|
|
362
|
+
"name": "Jotai",
|
|
363
|
+
"framework": FrameworkCategory.REACT,
|
|
364
|
+
"type": "client-state",
|
|
365
|
+
"description": "原始且灵活的原子状态管理",
|
|
366
|
+
"features": ["atoms", "atom-families", "typescript"],
|
|
367
|
+
"recommended_for": ["modular-state", "bottom-up"],
|
|
368
|
+
},
|
|
369
|
+
"pinia": {
|
|
370
|
+
"name": "Pinia",
|
|
371
|
+
"framework": FrameworkCategory.VUE,
|
|
372
|
+
"type": "client-state",
|
|
373
|
+
"description": "Vue 官方状态管理库",
|
|
374
|
+
"features": ["composition-api", "typescript", "devtools"],
|
|
375
|
+
"recommended_for": ["vue3", "typescript"],
|
|
376
|
+
},
|
|
377
|
+
"xstate": {
|
|
378
|
+
"name": "XState",
|
|
379
|
+
"framework": "any",
|
|
380
|
+
"type": "client-state",
|
|
381
|
+
"description": "状态机和状态图",
|
|
382
|
+
"features": ["state-machines", "visualization", "actors"],
|
|
383
|
+
"recommended_for": ["complex-flows", "state-machines"],
|
|
384
|
+
},
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
# 测试工具
|
|
388
|
+
TESTING_TOOLS: dict[str, dict[str, Any]] = {
|
|
389
|
+
"vitest": {
|
|
390
|
+
"name": "Vitest",
|
|
391
|
+
"description": "由 Vite 驱动的单元测试框架",
|
|
392
|
+
"features": ["fast", "jest-compatible", "esm"],
|
|
393
|
+
"recommended_for": ["unit", "vite-projects"],
|
|
394
|
+
},
|
|
395
|
+
"jest": {
|
|
396
|
+
"name": "Jest",
|
|
397
|
+
"description": "JavaScript 测试框架",
|
|
398
|
+
"features": ["zero-config", "snapshot", "coverage"],
|
|
399
|
+
"recommended_for": ["unit", "legacy-projects"],
|
|
400
|
+
},
|
|
401
|
+
"playwright": {
|
|
402
|
+
"name": "Playwright",
|
|
403
|
+
"description": "跨浏览器端到端测试",
|
|
404
|
+
"features": ["cross-browser", "auto-waiting", "trace"],
|
|
405
|
+
"recommended_for": ["e2e", "cross-browser-testing"],
|
|
406
|
+
},
|
|
407
|
+
"cypress": {
|
|
408
|
+
"name": "Cypress",
|
|
409
|
+
"description": "前端测试工具",
|
|
410
|
+
"features": ["e2e", "component-testing", "time-travel"],
|
|
411
|
+
"recommended_for": ["e2e", "component-testing"],
|
|
412
|
+
},
|
|
413
|
+
"testing-library": {
|
|
414
|
+
"name": "Testing Library",
|
|
415
|
+
"description": "简单且完整的 DOM 测试",
|
|
416
|
+
"features": ["user-centric", "accessibility", "framework-agnostic"],
|
|
417
|
+
"recommended_for": ["component", "integration"],
|
|
418
|
+
},
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
# 工具链配置
|
|
422
|
+
DEV_TOOLS: dict[str, dict[str, Any]] = {
|
|
423
|
+
"typescript": {
|
|
424
|
+
"name": "TypeScript",
|
|
425
|
+
"description": "JavaScript 类型系统",
|
|
426
|
+
"features": ["type-checking", "intellisense", "refactoring"],
|
|
427
|
+
"recommended": True,
|
|
428
|
+
},
|
|
429
|
+
"eslint": {
|
|
430
|
+
"name": "ESLint",
|
|
431
|
+
"description": "JavaScript 代码检查工具",
|
|
432
|
+
"features": ["linting", "auto-fix", "plugins"],
|
|
433
|
+
"recommended": True,
|
|
434
|
+
},
|
|
435
|
+
"prettier": {
|
|
436
|
+
"name": "Prettier",
|
|
437
|
+
"description": "代码格式化工具",
|
|
438
|
+
"features": ["formatting", "opinionated"],
|
|
439
|
+
"recommended": True,
|
|
440
|
+
},
|
|
441
|
+
"postcss": {
|
|
442
|
+
"name": "PostCSS",
|
|
443
|
+
"description": "CSS 转换工具",
|
|
444
|
+
"features": ["autoprefixer", "nesting", "variables"],
|
|
445
|
+
"recommended": True,
|
|
446
|
+
},
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
@dataclass
|
|
451
|
+
class FrontendConfig:
|
|
452
|
+
"""前端配置"""
|
|
453
|
+
|
|
454
|
+
# 框架
|
|
455
|
+
framework: str = "next" # 默认 Next.js
|
|
456
|
+
framework_version: str = "latest"
|
|
457
|
+
|
|
458
|
+
# UI 库
|
|
459
|
+
ui_library: str | None = None
|
|
460
|
+
ui_library_version: str = "latest"
|
|
461
|
+
|
|
462
|
+
# 样式
|
|
463
|
+
style_solution: list[StyleSolution] = field(default_factory=lambda: [StyleSolution.TAILWIND])
|
|
464
|
+
|
|
465
|
+
# 状态管理
|
|
466
|
+
state_management: list[StateManagement] = field(default_factory=list)
|
|
467
|
+
|
|
468
|
+
# 构建工具
|
|
469
|
+
build_tool: BuildTool | None = None
|
|
470
|
+
|
|
471
|
+
# 测试
|
|
472
|
+
testing_frameworks: list[TestingFramework] = field(default_factory=list)
|
|
473
|
+
|
|
474
|
+
# 开发工具
|
|
475
|
+
dev_tools: list[str] = field(default_factory=lambda: ["typescript", "eslint", "prettier"])
|
|
476
|
+
|
|
477
|
+
# 性能优化
|
|
478
|
+
enable_bundle_analysis: bool = True
|
|
479
|
+
enable_code_splitting: bool = True
|
|
480
|
+
enable_tree_shaking: bool = True
|
|
481
|
+
enable_compression: bool = True
|
|
482
|
+
|
|
483
|
+
# PWA
|
|
484
|
+
enable_pwa: bool = False
|
|
485
|
+
|
|
486
|
+
# 国际化
|
|
487
|
+
enable_i18n: bool = False
|
|
488
|
+
i18n_locales: list[str] = field(default_factory=lambda: ["en", "zh"])
|
|
489
|
+
|
|
490
|
+
# 无障碍
|
|
491
|
+
a11y_level: str = "aa" # none, a, aa, aaa
|
|
492
|
+
|
|
493
|
+
def get_framework_info(self) -> dict[str, Any]:
|
|
494
|
+
"""获取框架信息"""
|
|
495
|
+
return FRAMEWORKS.get(self.framework, {})
|
|
496
|
+
|
|
497
|
+
def get_ui_library_info(self) -> dict[str, Any]:
|
|
498
|
+
"""获取 UI 库信息"""
|
|
499
|
+
if not self.ui_library:
|
|
500
|
+
return {}
|
|
501
|
+
return UI_LIBRARIES.get(self.ui_library, {})
|
|
502
|
+
|
|
503
|
+
def get_recommended_stack(self) -> dict[str, Any]:
|
|
504
|
+
"""获取推荐的技术栈"""
|
|
505
|
+
framework_info = self.get_framework_info()
|
|
506
|
+
stack = {
|
|
507
|
+
"framework": framework_info.get("name", self.framework),
|
|
508
|
+
"build_tool": self.build_tool or framework_info.get("build_tool"),
|
|
509
|
+
"recommended_for": framework_info.get("recommended_for", []),
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
if self.ui_library:
|
|
513
|
+
ui_info = self.get_ui_library_info()
|
|
514
|
+
stack["ui_library"] = ui_info.get("name", self.ui_library)
|
|
515
|
+
|
|
516
|
+
return stack
|
|
517
|
+
|
|
518
|
+
def validate(self) -> list[str]:
|
|
519
|
+
"""验证配置"""
|
|
520
|
+
errors = []
|
|
521
|
+
|
|
522
|
+
if self.framework not in FRAMEWORKS:
|
|
523
|
+
errors.append(f"不支持的框架: {self.framework}")
|
|
524
|
+
|
|
525
|
+
if self.ui_library and self.ui_library not in UI_LIBRARIES:
|
|
526
|
+
errors.append(f"不支持的 UI 库: {self.ui_library}")
|
|
527
|
+
|
|
528
|
+
framework_info = self.get_framework_info()
|
|
529
|
+
if self.ui_library:
|
|
530
|
+
ui_info = self.get_ui_library_info()
|
|
531
|
+
framework_cat = framework_info.get("category")
|
|
532
|
+
ui_framework = ui_info.get("framework")
|
|
533
|
+
if ui_framework != "any" and ui_framework != framework_cat:
|
|
534
|
+
errors.append(
|
|
535
|
+
f"UI 库 {self.ui_library} 不兼容框架 {self.framework}"
|
|
536
|
+
)
|
|
537
|
+
|
|
538
|
+
return errors
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
@dataclass
|
|
542
|
+
class MobileFrontendConfig(FrontendConfig):
|
|
543
|
+
"""移动端前端配置"""
|
|
544
|
+
|
|
545
|
+
platform: str = "mobile" # mobile, ios, android
|
|
546
|
+
|
|
547
|
+
# 移动端框架
|
|
548
|
+
mobile_framework: str = "react-native" # react-native, flutter
|
|
549
|
+
|
|
550
|
+
# 移动端 UI 库
|
|
551
|
+
mobile_ui_library: str | None = None
|
|
552
|
+
|
|
553
|
+
# 原生模块
|
|
554
|
+
enable_native_modules: bool = False
|
|
555
|
+
|
|
556
|
+
# 性能
|
|
557
|
+
enable_hermes: bool = True # React Native Hermes 引擎
|