@botim/botim-cli 0.1.3 → 0.1.6
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/dist/cli.js +18 -2
- package/dist/cli.mjs +6 -6
- package/dist/templates/react/.botim/app.json5 +12 -0
- package/dist/templates/react/.botim/ci/post-version.sh +7 -0
- package/dist/templates/react/.cursorrules +37 -0
- package/dist/templates/react/scripts/.gitkeep +0 -0
- package/dist/templates/react/src/assets/animation/.gitkeep +0 -0
- package/dist/templates/react/src/assets/fonts/.gitkeep +0 -0
- package/dist/templates/react/src/assets/images/.gitkeep +0 -0
- package/dist/templates/templates/react/.botim/app.json5 +12 -0
- package/dist/templates/templates/react/.botim/ci/post-version.sh +7 -0
- package/dist/templates/templates/react/.cursorrules +37 -0
- package/dist/templates/templates/react/README.md +48 -0
- package/dist/templates/templates/react/docs/code-patterns.md +139 -0
- package/dist/templates/templates/react/docs/core-rules.md +69 -0
- package/dist/templates/templates/react/docs/figma-workflow.md +81 -0
- package/dist/templates/templates/react/docs/validation.md +59 -0
- package/dist/templates/templates/react/eslint.config.ts +57 -0
- package/dist/templates/templates/react/index.html +12 -0
- package/dist/templates/templates/react/package-lock.json +12197 -0
- package/dist/templates/templates/react/package.json +102 -0
- package/dist/templates/templates/react/scripts/.gitkeep +0 -0
- package/dist/templates/templates/react/scripts/setup.sh +304 -0
- package/dist/templates/templates/react/src/api/http-client.ts +8 -0
- package/dist/templates/templates/react/src/api/modules/example.ts +12 -0
- package/dist/templates/templates/react/src/app.tsx +27 -0
- package/dist/templates/templates/react/src/assets/animation/.gitkeep +0 -0
- package/dist/templates/templates/react/src/assets/fonts/.gitkeep +0 -0
- package/dist/templates/templates/react/src/assets/images/.gitkeep +0 -0
- package/dist/templates/templates/react/src/components/not-found-content/index.ts +2 -0
- package/dist/templates/templates/react/src/components/not-found-content/not-found-content.tsx +24 -0
- package/dist/templates/templates/react/src/components/welcome-card/index.ts +1 -0
- package/dist/templates/templates/react/src/components/welcome-card/welcome-card.tsx +10 -0
- package/dist/templates/templates/react/src/hooks/use-document-title.ts +11 -0
- package/dist/templates/templates/react/src/i18n/index.ts +40 -0
- package/dist/templates/templates/react/src/i18n/languages/en.json +10 -0
- package/dist/templates/templates/react/src/main.tsx +27 -0
- package/dist/templates/templates/react/src/modules/common/README.md +7 -0
- package/dist/templates/templates/react/src/modules/common/constants.ts +3 -0
- package/dist/templates/templates/react/src/modules/core/README.md +7 -0
- package/dist/templates/templates/react/src/modules/core/api/error.ts +6 -0
- package/dist/templates/templates/react/src/modules/core/app-providers.tsx +18 -0
- package/dist/templates/templates/react/src/modules/core/index.ts +2 -0
- package/dist/templates/templates/react/src/pages/home/index.tsx +13 -0
- package/dist/templates/templates/react/src/pages/not-found/index.tsx +7 -0
- package/dist/templates/templates/react/src/routes.tsx +18 -0
- package/dist/templates/templates/react/src/stores/home-store.ts +11 -0
- package/dist/templates/templates/react/src/styles/font.css +1 -0
- package/dist/templates/templates/react/src/styles/global-style.tsx +27 -0
- package/dist/templates/templates/react/src/styles/tailwind.css +4 -0
- package/dist/templates/templates/react/src/styles/utility-classes.ts +13 -0
- package/dist/templates/templates/react/src/theme/index.tsx +24 -0
- package/dist/templates/templates/react/src/theme/types.ts +10 -0
- package/dist/templates/templates/react/src/types/global.d.ts +139 -0
- package/dist/templates/templates/react/src/types/shims-global.d.ts +97 -0
- package/dist/templates/templates/react/src/utils/currency.ts +6 -0
- package/dist/templates/templates/react/src/utils/date.ts +5 -0
- package/dist/templates/templates/react/src/utils/guard.ts +4 -0
- package/dist/templates/templates/react/src/vite-env.d.ts +1 -0
- package/dist/templates/templates/react/tsconfig.json +39 -0
- package/dist/templates/templates/react/tsconfig.node.json +11 -0
- package/dist/templates/templates/react/types/global.d.ts +131 -0
- package/dist/templates/templates/react/vite.config.ts +179 -0
- package/dist/templates/templates/vue/README.md +19 -0
- package/dist/templates/templates/vue/eslint.config.ts +44 -0
- package/dist/templates/templates/vue/index.html +12 -0
- package/dist/templates/templates/vue/package-lock.json +5774 -0
- package/dist/templates/templates/vue/package.json +39 -0
- package/dist/templates/templates/vue/src/api/http-client.ts +11 -0
- package/dist/templates/templates/vue/src/api/modules/example.ts +12 -0
- package/dist/templates/templates/vue/src/app.vue +23 -0
- package/dist/templates/templates/vue/src/components/card/index.vue +14 -0
- package/dist/templates/templates/vue/src/components/layout/index.ts +1 -0
- package/dist/templates/templates/vue/src/components/layout/page-layout.vue +43 -0
- package/dist/templates/templates/vue/src/components/layout/styles.ts +5 -0
- package/dist/templates/templates/vue/src/components/typography/heading.vue +21 -0
- package/dist/templates/templates/vue/src/components/typography/index.ts +1 -0
- package/dist/templates/templates/vue/src/hooks/use-document-title.ts +23 -0
- package/dist/templates/templates/vue/src/i18n/index.ts +31 -0
- package/dist/templates/templates/vue/src/i18n/languages/en.json +10 -0
- package/dist/templates/templates/vue/src/main.ts +12 -0
- package/dist/templates/templates/vue/src/modules/common/README.md +7 -0
- package/dist/templates/templates/vue/src/modules/common/constants.ts +3 -0
- package/dist/templates/templates/vue/src/modules/core/README.md +7 -0
- package/dist/templates/templates/vue/src/modules/core/api/error.ts +6 -0
- package/dist/templates/templates/vue/src/modules/core/app-providers.ts +17 -0
- package/dist/templates/templates/vue/src/modules/core/index.ts +2 -0
- package/dist/templates/templates/vue/src/pages/home/index.vue +28 -0
- package/dist/templates/templates/vue/src/pages/not-found/index.vue +13 -0
- package/dist/templates/templates/vue/src/routes.ts +19 -0
- package/dist/templates/templates/vue/src/stores/home-store.ts +12 -0
- package/dist/templates/templates/vue/src/styles/font.css +1 -0
- package/dist/templates/templates/vue/src/styles/global-style.ts +63 -0
- package/dist/templates/templates/vue/src/styles/utility-classes.ts +1 -0
- package/dist/templates/templates/vue/src/theme/index.ts +33 -0
- package/dist/templates/templates/vue/src/theme/types.ts +10 -0
- package/dist/templates/templates/vue/src/types/global.d.ts +9 -0
- package/dist/templates/templates/vue/src/utils/currency.ts +6 -0
- package/dist/templates/templates/vue/src/utils/date.ts +5 -0
- package/dist/templates/templates/vue/src/utils/guard.ts +4 -0
- package/dist/templates/templates/vue/src/vite-env.d.ts +1 -0
- package/dist/templates/templates/vue/tsconfig.json +36 -0
- package/dist/templates/templates/vue/tsconfig.node.json +9 -0
- package/dist/templates/templates/vue/types/global.d.ts +7 -0
- package/dist/templates/templates/vue/vite.config.ts +74 -0
- package/package.json +3 -2
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Mini Program Starter Template - AI Rules
|
|
2
|
+
|
|
3
|
+
## Error Handling Rules
|
|
4
|
+
|
|
5
|
+
1. **Async API Call Errors**:
|
|
6
|
+
- Async API call errors should throw `AppError`
|
|
7
|
+
- Use `logger.error` to record all async API call errors
|
|
8
|
+
|
|
9
|
+
2. **Event Handler Errors**:
|
|
10
|
+
- Errors in event handlers should not happen (prevent with proper validation)
|
|
11
|
+
- If an error occurs, it should be caught and logged appropriately
|
|
12
|
+
|
|
13
|
+
3. **Error Boundary**:
|
|
14
|
+
- The error boundary itself cannot throw any errors
|
|
15
|
+
- Must be robust and handle all error scenarios gracefully
|
|
16
|
+
|
|
17
|
+
4. **React Component Errors**:
|
|
18
|
+
- Errors in React component render should be caught by ErrorBoundary
|
|
19
|
+
- Errors in component lifecycle should be caught by ErrorBoundary
|
|
20
|
+
- Errors in constructor should be caught by ErrorBoundary
|
|
21
|
+
|
|
22
|
+
## Code Quality
|
|
23
|
+
|
|
24
|
+
- Follow TypeScript strict mode
|
|
25
|
+
- Use ESLint rules as configured
|
|
26
|
+
- Maintain consistent code style (4 spaces indentation)
|
|
27
|
+
- Use i18next for all user-facing strings
|
|
28
|
+
- Follow React hooks rules
|
|
29
|
+
|
|
30
|
+
## Architecture
|
|
31
|
+
|
|
32
|
+
- Use Zustand for state management
|
|
33
|
+
- Use React Router for routing
|
|
34
|
+
- Use Emotion for styling
|
|
35
|
+
- Follow the established folder structure
|
|
36
|
+
- Keep components reusable and modular
|
|
37
|
+
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Mini Program Starter Template - AI Rules
|
|
2
|
+
|
|
3
|
+
## Error Handling Rules
|
|
4
|
+
|
|
5
|
+
1. **Async API Call Errors**:
|
|
6
|
+
- Async API call errors should throw `AppError`
|
|
7
|
+
- Use `logger.error` to record all async API call errors
|
|
8
|
+
|
|
9
|
+
2. **Event Handler Errors**:
|
|
10
|
+
- Errors in event handlers should not happen (prevent with proper validation)
|
|
11
|
+
- If an error occurs, it should be caught and logged appropriately
|
|
12
|
+
|
|
13
|
+
3. **Error Boundary**:
|
|
14
|
+
- The error boundary itself cannot throw any errors
|
|
15
|
+
- Must be robust and handle all error scenarios gracefully
|
|
16
|
+
|
|
17
|
+
4. **React Component Errors**:
|
|
18
|
+
- Errors in React component render should be caught by ErrorBoundary
|
|
19
|
+
- Errors in component lifecycle should be caught by ErrorBoundary
|
|
20
|
+
- Errors in constructor should be caught by ErrorBoundary
|
|
21
|
+
|
|
22
|
+
## Code Quality
|
|
23
|
+
|
|
24
|
+
- Follow TypeScript strict mode
|
|
25
|
+
- Use ESLint rules as configured
|
|
26
|
+
- Maintain consistent code style (4 spaces indentation)
|
|
27
|
+
- Use i18next for all user-facing strings
|
|
28
|
+
- Follow React hooks rules
|
|
29
|
+
|
|
30
|
+
## Architecture
|
|
31
|
+
|
|
32
|
+
- Use Zustand for state management
|
|
33
|
+
- Use React Router for routing
|
|
34
|
+
- Use Emotion for styling
|
|
35
|
+
- Follow the established folder structure
|
|
36
|
+
- Keep components reusable and modular
|
|
37
|
+
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# React + Vite Mini Program Template
|
|
2
|
+
|
|
3
|
+
This template captures the reusable project structure, tooling, and architectural patterns from the original repository without including product-specific business logic. Use it as the starting point for new React + Vite micro-applications that rely on Emotion, Zustand, routing, and i18n.
|
|
4
|
+
|
|
5
|
+
## What's Included
|
|
6
|
+
|
|
7
|
+
- Vite + React + TypeScript baseline
|
|
8
|
+
- Emotion styling with global theme helpers
|
|
9
|
+
- React Router with centralized route definitions
|
|
10
|
+
- i18n setup with lazy-loaded namespaces
|
|
11
|
+
- Zustand-powered state management scaffold
|
|
12
|
+
- Modular folder structure for APIs, modules, pages, and shared UI components
|
|
13
|
+
- ESLint + TypeScript configs aligned with the original code style
|
|
14
|
+
|
|
15
|
+
## Getting Started
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install
|
|
19
|
+
npm run dev
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Project Structure
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
src/
|
|
26
|
+
api/ # API modules and service wrappers
|
|
27
|
+
components/ # Reusable UI components
|
|
28
|
+
hooks/ # Custom React hooks
|
|
29
|
+
i18n/ # Localization configuration
|
|
30
|
+
modules/ # Domain modules composed from core + common utilities
|
|
31
|
+
pages/ # Route-level views
|
|
32
|
+
stores/ # Zustand stores
|
|
33
|
+
styles/ # Global styles and utility classes
|
|
34
|
+
theme/ # Theme tokens and helpers
|
|
35
|
+
utils/ # General-purpose utilities
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Customization Checklist
|
|
39
|
+
|
|
40
|
+
1. Update `package.json` metadata (`name`, `version`, `description`).
|
|
41
|
+
2. Replace placeholder assets and translations in `src/assets` and `src/i18n/languages`.
|
|
42
|
+
3. Flesh out routes inside `src/routes.tsx`.
|
|
43
|
+
4. Extend stores, modules, and API clients as needed.
|
|
44
|
+
5. Adjust ESLint rules or tooling to match team conventions.
|
|
45
|
+
|
|
46
|
+
## Optional Integrations
|
|
47
|
+
|
|
48
|
+
The original project integrates several proprietary Botim packages (MP bridge, Buckit resolver, Sentry plugin, etc.). Add them back in `vite.config.ts` or `package.json` if the consuming project requires them.
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Code Patterns
|
|
2
|
+
|
|
3
|
+
## Generation Order
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
Types → API → Hooks → Components → Page → Routes
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
src/
|
|
11
|
+
├── types/{feature}.types.ts
|
|
12
|
+
├── api/modules/{feature}.api.ts
|
|
13
|
+
├── hooks/use{Feature}.ts
|
|
14
|
+
├── pages/{feature}/
|
|
15
|
+
│ ├── index.tsx
|
|
16
|
+
│ └── components/
|
|
17
|
+
└── routes.tsx
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Hook Patterns
|
|
23
|
+
|
|
24
|
+
### Data Fetching
|
|
25
|
+
```typescript
|
|
26
|
+
export function useItems() {
|
|
27
|
+
const [items, setItems] = useState<Item[]>([]);
|
|
28
|
+
const [loading, setLoading] = useState(true);
|
|
29
|
+
const [error, setError] = useState<string | null>(null);
|
|
30
|
+
|
|
31
|
+
const fetchItems = useCallback(async () => {
|
|
32
|
+
try {
|
|
33
|
+
setLoading(true);
|
|
34
|
+
const data = await itemApi.getAll();
|
|
35
|
+
setItems(data);
|
|
36
|
+
} catch (err) {
|
|
37
|
+
setError(err.message);
|
|
38
|
+
} finally {
|
|
39
|
+
setLoading(false);
|
|
40
|
+
}
|
|
41
|
+
}, []);
|
|
42
|
+
|
|
43
|
+
useEffect(() => { fetchItems(); }, []);
|
|
44
|
+
return { items, loading, error, refetch: fetchItems };
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Form Hook
|
|
49
|
+
```typescript
|
|
50
|
+
export function useForm<T>(initial: T) {
|
|
51
|
+
const [data, setData] = useState(initial);
|
|
52
|
+
const [errors, setErrors] = useState({});
|
|
53
|
+
|
|
54
|
+
const handleChange = (field: keyof T, value: T[keyof T]) => {
|
|
55
|
+
setData(prev => ({ ...prev, [field]: value }));
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const handleSubmit = async (submitFn: (data: T) => Promise<void>) => {
|
|
59
|
+
try {
|
|
60
|
+
await submitFn(data);
|
|
61
|
+
return true;
|
|
62
|
+
} catch (err) {
|
|
63
|
+
setErrors({ submit: err.message });
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
return { data, errors, handleChange, handleSubmit };
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Bridge API Hook
|
|
73
|
+
```typescript
|
|
74
|
+
import { useBOT } from '@botim/framework';
|
|
75
|
+
|
|
76
|
+
export function useLocation() {
|
|
77
|
+
const BOT = useBOT();
|
|
78
|
+
const [location, setLocation] = useState(null);
|
|
79
|
+
const [loading, setLoading] = useState(false);
|
|
80
|
+
|
|
81
|
+
const getLocation = useCallback(() => {
|
|
82
|
+
setLoading(true);
|
|
83
|
+
BOT.getLocation({
|
|
84
|
+
success: (res) => setLocation(res),
|
|
85
|
+
fail: (err) => console.error(err),
|
|
86
|
+
complete: () => setLoading(false)
|
|
87
|
+
});
|
|
88
|
+
}, [BOT]);
|
|
89
|
+
|
|
90
|
+
return { location, loading, getLocation };
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Component Pattern
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
// ComponentName.tsx
|
|
100
|
+
import React from 'react';
|
|
101
|
+
import { Container } from './ComponentName.styles';
|
|
102
|
+
import type { ComponentNameProps } from './ComponentName.types';
|
|
103
|
+
|
|
104
|
+
export const ComponentName: React.FC<ComponentNameProps> = ({ title }) => {
|
|
105
|
+
return <Container>{title}</Container>;
|
|
106
|
+
};
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### List with States
|
|
110
|
+
```typescript
|
|
111
|
+
const ItemList = () => {
|
|
112
|
+
const { items, loading, error } = useItems();
|
|
113
|
+
if (loading) return <LoadingSpinner />;
|
|
114
|
+
if (error) return <ErrorMessage message={error} />;
|
|
115
|
+
return <List>{items.map(item => <ItemCard key={item.id} {...item} />)}</List>;
|
|
116
|
+
};
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Custom Component Structure
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
ComponentName/
|
|
125
|
+
├── index.ts
|
|
126
|
+
├── ComponentName.tsx
|
|
127
|
+
├── ComponentName.styles.ts
|
|
128
|
+
└── ComponentName.types.ts
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Validation Commands
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
npm run type-check
|
|
137
|
+
npm run build
|
|
138
|
+
npm run lint:fix
|
|
139
|
+
```
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Core Rules
|
|
2
|
+
|
|
3
|
+
## Rule 1: Code Connect Components
|
|
4
|
+
|
|
5
|
+
When Code Connect provides a mapping, use the component directly from code-connect components
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
// Check Code Connect first
|
|
9
|
+
const codeConnect = await mcp__botim-figma-mcp__get_code_connect_map({ fileKey, nodeId });
|
|
10
|
+
|
|
11
|
+
// Use library components directly
|
|
12
|
+
Use code connect components
|
|
13
|
+
|
|
14
|
+
// For spacing, use wrapper div
|
|
15
|
+
<div style={{ padding: 16 }}><Header /></div>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Rule 2: Mobile-First
|
|
21
|
+
|
|
22
|
+
- Viewport: 375-428px
|
|
23
|
+
- Touch targets: 44x44px minimum
|
|
24
|
+
- Base styles for mobile, media queries for larger screens
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
const Container = styled.div`
|
|
28
|
+
padding: 16px;
|
|
29
|
+
@media (min-width: 768px) { padding: 24px; }
|
|
30
|
+
`;
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Rule 3: Layer Separation
|
|
36
|
+
|
|
37
|
+
| Layer | Location | Purpose |
|
|
38
|
+
|-------|----------|---------|
|
|
39
|
+
| UI | `pages/`, `components/` | JSX only |
|
|
40
|
+
| Hooks | `hooks/` | Logic, data fetching |
|
|
41
|
+
| API | `api/modules/` | HTTP calls |
|
|
42
|
+
| Types | `*.types.ts` | Interfaces |
|
|
43
|
+
| Styles | `*.styles.ts` | Styled components |
|
|
44
|
+
|
|
45
|
+
**Components never call APIs directly** - use hooks.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Rule 4: File Limits
|
|
50
|
+
|
|
51
|
+
- Components: **100 lines max**
|
|
52
|
+
- Split into: `.tsx`, `.styles.ts`, `.types.ts`
|
|
53
|
+
- Use `@/` for cross-directory imports
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Rule 5: TypeScript
|
|
58
|
+
|
|
59
|
+
- No `any` types
|
|
60
|
+
- Type-only imports: `import type { T } from '@/types'`
|
|
61
|
+
- All hook returns must be typed
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Rule 6: Styling
|
|
66
|
+
|
|
67
|
+
- Emotion styled-components only
|
|
68
|
+
- No inline styles, no CSS files
|
|
69
|
+
- Transient props use `$` prefix
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Figma Workflow
|
|
2
|
+
|
|
3
|
+
## MCP Servers
|
|
4
|
+
|
|
5
|
+
### botim-figma-mcp
|
|
6
|
+
- `get_design_context`: Layout, styles, structure
|
|
7
|
+
- `get_screenshot`: Visual reference
|
|
8
|
+
- `get_variable_defs`: Design tokens
|
|
9
|
+
- `get_code_connect_map`: Component mappings
|
|
10
|
+
|
|
11
|
+
### botim-mp-mcp
|
|
12
|
+
- `get_doc_content('botim-components')`: Component docs
|
|
13
|
+
- `get_icons_library()`: Icons catalog
|
|
14
|
+
- `get_all_sdk_methods()`: Native bridge APIs
|
|
15
|
+
- `search_docs()` / `list_docs()`: Backend API docs
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Implementation Workflow
|
|
20
|
+
|
|
21
|
+
### Step 1: Fetch Design
|
|
22
|
+
```typescript
|
|
23
|
+
const design = await mcp__botim-figma-mcp__get_design_context({ fileKey, nodeId });
|
|
24
|
+
const screenshot = await mcp__botim-figma-mcp__get_screenshot({ fileKey, nodeId });
|
|
25
|
+
const variables = await mcp__botim-figma-mcp__get_variable_defs({ fileKey, nodeId });
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Step 2: Check Code Connect (Required)
|
|
29
|
+
```typescript
|
|
30
|
+
const codeConnect = await mcp__botim-figma-mcp__get_code_connect_map({ fileKey, nodeId });
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Step 3: Get Component Details
|
|
34
|
+
```typescript
|
|
35
|
+
await mcp__botim-mp-mcp__get_doc_content('botim-components');
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Step 4: Apply Design Tokens
|
|
39
|
+
Extract exact values from Figma:
|
|
40
|
+
- Colors (hex values)
|
|
41
|
+
- Typography (font-size, weight, line-height)
|
|
42
|
+
- Spacing (padding, margin, gap)
|
|
43
|
+
- Border radius, shadows
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
const styles = {
|
|
47
|
+
background: '#F5F7FA',
|
|
48
|
+
padding: '16px 24px',
|
|
49
|
+
borderRadius: '12px',
|
|
50
|
+
};
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Component Priority
|
|
56
|
+
|
|
57
|
+
1. **Code Connect mapped** → Use those first
|
|
58
|
+
2. **Not available** → Create custom (rare)
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Import Pattern
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
|
|
66
|
+
// Bridge APIs
|
|
67
|
+
import { useBOT } from '@botim/framework';
|
|
68
|
+
const BOT = useBOT();
|
|
69
|
+
|
|
70
|
+
// Backend APIs
|
|
71
|
+
import { httpClient } from '@/api/http-client';
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Visual Match Target: 95%+
|
|
77
|
+
|
|
78
|
+
Validate against Figma:
|
|
79
|
+
- Colors, typography, spacing
|
|
80
|
+
- Layout, alignment, icons
|
|
81
|
+
- Shadows, borders
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Validation
|
|
2
|
+
|
|
3
|
+
## Quick Validation
|
|
4
|
+
|
|
5
|
+
### Step 1: Code Check
|
|
6
|
+
```bash
|
|
7
|
+
npm run type-check && npm run build && npm run lint:fix
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
### Step 2: Visual Validation
|
|
11
|
+
```typescript
|
|
12
|
+
// Mobile viewport required
|
|
13
|
+
mcp__playwright__browser_resize({ width: 375, height: 667 })
|
|
14
|
+
|
|
15
|
+
// Navigate and screenshot
|
|
16
|
+
mcp__playwright__browser_navigate({ url: "http://localhost:5173/route" })
|
|
17
|
+
mcp__playwright__browser_wait_for({ time: 2 })
|
|
18
|
+
mcp__playwright__browser_take_screenshot({ fullPage: true })
|
|
19
|
+
|
|
20
|
+
// Compare with Figma
|
|
21
|
+
mcp__botim-figma-mcp__get_screenshot({ fileKey, nodeId })
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Step 3: Use Implementation Validator
|
|
25
|
+
```typescript
|
|
26
|
+
Task({
|
|
27
|
+
subagent_type: "implementation-validator",
|
|
28
|
+
prompt: "Validate PRD requirements, routes, visual match with Figma"
|
|
29
|
+
})
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Match Threshold
|
|
35
|
+
|
|
36
|
+
| Match % | Action |
|
|
37
|
+
|---------|--------|
|
|
38
|
+
| < 98% | Fix spacing/margins |
|
|
39
|
+
| 98%+ | Pass |
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Spacing Checklist
|
|
44
|
+
|
|
45
|
+
- Container padding
|
|
46
|
+
- Margin between elements
|
|
47
|
+
- Gap in flex/grid
|
|
48
|
+
- Text spacing from borders
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Common Fixes
|
|
53
|
+
|
|
54
|
+
| Error | Fix |
|
|
55
|
+
|-------|-----|
|
|
56
|
+
| `Cannot find module 'X'` | `npm install X` |
|
|
57
|
+
| `Property 'X' does not exist` | Check interface |
|
|
58
|
+
| `Type 'X' is not assignable` | Fix type |
|
|
59
|
+
| `'X' defined but never used` | Remove import |
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import eslintPluginReact from 'eslint-plugin-react';
|
|
3
|
+
import eslintPluginReactHooks from 'eslint-plugin-react-hooks';
|
|
4
|
+
import eslintPluginImport from 'eslint-plugin-import';
|
|
5
|
+
// jsx-a11y plugin ships without TS types
|
|
6
|
+
import eslintPluginJsxA11y from 'eslint-plugin-jsx-a11y';
|
|
7
|
+
import eslintPluginSimpleImportSort from 'eslint-plugin-simple-import-sort';
|
|
8
|
+
import tseslint from 'typescript-eslint';
|
|
9
|
+
|
|
10
|
+
export default tseslint.config(
|
|
11
|
+
{
|
|
12
|
+
ignores: [
|
|
13
|
+
'dist',
|
|
14
|
+
'coverage'
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
js.configs.recommended,
|
|
18
|
+
...tseslint.configs.recommended,
|
|
19
|
+
{
|
|
20
|
+
files: [ '**/*.ts', '**/*.tsx' ],
|
|
21
|
+
languageOptions: {
|
|
22
|
+
parserOptions: {
|
|
23
|
+
ecmaVersion: 'latest',
|
|
24
|
+
sourceType: 'module'
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
plugins: {
|
|
28
|
+
react: eslintPluginReact,
|
|
29
|
+
'react-hooks': eslintPluginReactHooks,
|
|
30
|
+
import: eslintPluginImport,
|
|
31
|
+
'jsx-a11y': eslintPluginJsxA11y as unknown as import('eslint').ESLint.Plugin,
|
|
32
|
+
'simple-import-sort': eslintPluginSimpleImportSort
|
|
33
|
+
},
|
|
34
|
+
settings: {
|
|
35
|
+
react: {
|
|
36
|
+
version: 'detect'
|
|
37
|
+
},
|
|
38
|
+
'import/resolver': {
|
|
39
|
+
typescript: true,
|
|
40
|
+
node: {
|
|
41
|
+
extensions: [ '.js', '.jsx', '.ts', '.tsx' ]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
rules: {
|
|
46
|
+
'react/react-in-jsx-scope': 'off',
|
|
47
|
+
'react/prop-types': 'off',
|
|
48
|
+
'react/jsx-uses-react': 'off',
|
|
49
|
+
'react/jsx-uses-vars': 'error',
|
|
50
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
51
|
+
'react-hooks/exhaustive-deps': 'warn',
|
|
52
|
+
'import/order': 'off',
|
|
53
|
+
'simple-import-sort/imports': 'error',
|
|
54
|
+
'simple-import-sort/exports': 'error'
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<title>React Mini App</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="root"></div>
|
|
10
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|