@react-spa-scaffold/mcp 1.2.0 → 2.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 +36 -123
- package/dist/constants.d.ts +35 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +35 -0
- package/dist/constants.js.map +1 -0
- package/dist/features/definitions/api.d.ts.map +1 -1
- package/dist/features/definitions/api.js +0 -1
- package/dist/features/definitions/api.js.map +1 -1
- package/dist/features/definitions/ci.d.ts.map +1 -1
- package/dist/features/definitions/ci.js +0 -1
- package/dist/features/definitions/ci.js.map +1 -1
- package/dist/features/definitions/core.d.ts.map +1 -1
- package/dist/features/definitions/core.js +0 -1
- package/dist/features/definitions/core.js.map +1 -1
- package/dist/features/definitions/devtools.d.ts.map +1 -1
- package/dist/features/definitions/devtools.js +0 -1
- package/dist/features/definitions/devtools.js.map +1 -1
- package/dist/features/definitions/forms.d.ts.map +1 -1
- package/dist/features/definitions/forms.js +0 -1
- package/dist/features/definitions/forms.js.map +1 -1
- package/dist/features/definitions/i18n.d.ts.map +1 -1
- package/dist/features/definitions/i18n.js +0 -1
- package/dist/features/definitions/i18n.js.map +1 -1
- package/dist/features/definitions/mobile.d.ts.map +1 -1
- package/dist/features/definitions/mobile.js +0 -1
- package/dist/features/definitions/mobile.js.map +1 -1
- package/dist/features/definitions/observability.d.ts.map +1 -1
- package/dist/features/definitions/observability.js +0 -1
- package/dist/features/definitions/observability.js.map +1 -1
- package/dist/features/definitions/performance.d.ts.map +1 -1
- package/dist/features/definitions/performance.js +0 -1
- package/dist/features/definitions/performance.js.map +1 -1
- package/dist/features/definitions/routing.d.ts.map +1 -1
- package/dist/features/definitions/routing.js +0 -1
- package/dist/features/definitions/routing.js.map +1 -1
- package/dist/features/definitions/state.d.ts.map +1 -1
- package/dist/features/definitions/state.js +0 -1
- package/dist/features/definitions/state.js.map +1 -1
- package/dist/features/definitions/testing.d.ts.map +1 -1
- package/dist/features/definitions/testing.js +0 -3
- package/dist/features/definitions/testing.js.map +1 -1
- package/dist/features/definitions/theming.js +2 -2
- package/dist/features/definitions/theming.js.map +1 -1
- package/dist/features/definitions/ui.d.ts.map +1 -1
- package/dist/features/definitions/ui.js +0 -1
- package/dist/features/definitions/ui.js.map +1 -1
- package/dist/features/types.d.ts +14 -20
- package/dist/features/types.d.ts.map +1 -1
- package/dist/features/types.js +4 -21
- package/dist/features/types.js.map +1 -1
- package/dist/features/types.test.d.ts +5 -0
- package/dist/features/types.test.d.ts.map +1 -0
- package/dist/features/types.test.js +32 -0
- package/dist/features/types.test.js.map +1 -0
- package/dist/resources/docs.d.ts +2 -8
- package/dist/resources/docs.d.ts.map +1 -1
- package/dist/resources/docs.js +27 -49
- package/dist/resources/docs.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +9 -8
- package/dist/server.js.map +1 -1
- package/dist/tools/get-features.d.ts +15 -9
- package/dist/tools/get-features.d.ts.map +1 -1
- package/dist/tools/get-features.js +12 -0
- package/dist/tools/get-features.js.map +1 -1
- package/dist/tools/get-file.d.ts +23 -0
- package/dist/tools/get-file.d.ts.map +1 -0
- package/dist/tools/get-file.js +57 -0
- package/dist/tools/get-file.js.map +1 -0
- package/dist/tools/get-file.test.d.ts +5 -0
- package/dist/tools/get-file.test.d.ts.map +1 -0
- package/dist/tools/get-file.test.js +63 -0
- package/dist/tools/get-file.test.js.map +1 -0
- package/dist/tools/get-scaffold.d.ts +11 -33
- package/dist/tools/get-scaffold.d.ts.map +1 -1
- package/dist/tools/get-scaffold.js +31 -44
- package/dist/tools/get-scaffold.js.map +1 -1
- package/dist/tools/get-scaffold.test.js +29 -22
- package/dist/tools/get-scaffold.test.js.map +1 -1
- package/dist/tools/index.d.ts +2 -2
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/registry.d.ts +4 -0
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/registry.js +26 -16
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/types.d.ts +24 -6
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +3 -0
- package/dist/tools/types.js.map +1 -1
- package/dist/utils/cache.d.ts +9 -5
- package/dist/utils/cache.d.ts.map +1 -1
- package/dist/utils/cache.js +21 -5
- package/dist/utils/cache.js.map +1 -1
- package/dist/utils/docs.d.ts +1 -3
- package/dist/utils/docs.d.ts.map +1 -1
- package/dist/utils/docs.js +3 -8
- package/dist/utils/docs.js.map +1 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/paths.d.ts +9 -0
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +19 -1
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/paths.test.js +22 -1
- package/dist/utils/paths.test.js.map +1 -1
- package/dist/utils/scaffold/claude-md/index.d.ts +7 -0
- package/dist/utils/scaffold/claude-md/index.d.ts.map +1 -0
- package/dist/utils/scaffold/claude-md/index.js +23 -0
- package/dist/utils/scaffold/claude-md/index.js.map +1 -0
- package/dist/utils/scaffold/claude-md/sections.d.ts +16 -0
- package/dist/utils/scaffold/claude-md/sections.d.ts.map +1 -0
- package/dist/utils/scaffold/claude-md/sections.js +269 -0
- package/dist/utils/scaffold/claude-md/sections.js.map +1 -0
- package/dist/utils/scaffold/commands.d.ts +2 -6
- package/dist/utils/scaffold/commands.d.ts.map +1 -1
- package/dist/utils/scaffold/commands.js +9 -12
- package/dist/utils/scaffold/commands.js.map +1 -1
- package/dist/utils/scaffold/compute.d.ts +5 -8
- package/dist/utils/scaffold/compute.d.ts.map +1 -1
- package/dist/utils/scaffold/compute.js +26 -41
- package/dist/utils/scaffold/compute.js.map +1 -1
- package/dist/utils/scaffold/dependencies.d.ts +10 -17
- package/dist/utils/scaffold/dependencies.d.ts.map +1 -1
- package/dist/utils/scaffold/dependencies.js +28 -34
- package/dist/utils/scaffold/dependencies.js.map +1 -1
- package/dist/utils/scaffold/generators.d.ts +3 -11
- package/dist/utils/scaffold/generators.d.ts.map +1 -1
- package/dist/utils/scaffold/generators.js +20 -288
- package/dist/utils/scaffold/generators.js.map +1 -1
- package/dist/utils/scaffold/index.d.ts +2 -3
- package/dist/utils/scaffold/index.d.ts.map +1 -1
- package/dist/utils/scaffold/index.js +1 -3
- package/dist/utils/scaffold/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/tools/get-example.d.ts +0 -49
- package/dist/tools/get-example.d.ts.map +0 -1
- package/dist/tools/get-example.js +0 -91
- package/dist/tools/get-example.js.map +0 -1
- package/dist/tools/get-example.test.d.ts +0 -5
- package/dist/tools/get-example.test.d.ts.map +0 -1
- package/dist/tools/get-example.test.js +0 -63
- package/dist/tools/get-example.test.js.map +0 -1
- package/dist/utils/examples/api-patterns.d.ts +0 -3
- package/dist/utils/examples/api-patterns.d.ts.map +0 -1
- package/dist/utils/examples/api-patterns.js +0 -19
- package/dist/utils/examples/api-patterns.js.map +0 -1
- package/dist/utils/examples/component-patterns.d.ts +0 -3
- package/dist/utils/examples/component-patterns.d.ts.map +0 -1
- package/dist/utils/examples/component-patterns.js +0 -71
- package/dist/utils/examples/component-patterns.js.map +0 -1
- package/dist/utils/examples/context-patterns.d.ts +0 -3
- package/dist/utils/examples/context-patterns.d.ts.map +0 -1
- package/dist/utils/examples/context-patterns.js +0 -32
- package/dist/utils/examples/context-patterns.js.map +0 -1
- package/dist/utils/examples/hook-patterns.d.ts +0 -3
- package/dist/utils/examples/hook-patterns.d.ts.map +0 -1
- package/dist/utils/examples/hook-patterns.js +0 -55
- package/dist/utils/examples/hook-patterns.js.map +0 -1
- package/dist/utils/examples/i18n-patterns.d.ts +0 -3
- package/dist/utils/examples/i18n-patterns.d.ts.map +0 -1
- package/dist/utils/examples/i18n-patterns.js +0 -43
- package/dist/utils/examples/i18n-patterns.js.map +0 -1
- package/dist/utils/examples/index.d.ts +0 -12
- package/dist/utils/examples/index.d.ts.map +0 -1
- package/dist/utils/examples/index.js +0 -69
- package/dist/utils/examples/index.js.map +0 -1
- package/dist/utils/examples/mobile-patterns.d.ts +0 -3
- package/dist/utils/examples/mobile-patterns.d.ts.map +0 -1
- package/dist/utils/examples/mobile-patterns.js +0 -38
- package/dist/utils/examples/mobile-patterns.js.map +0 -1
- package/dist/utils/examples/page-patterns.d.ts +0 -3
- package/dist/utils/examples/page-patterns.d.ts.map +0 -1
- package/dist/utils/examples/page-patterns.js +0 -34
- package/dist/utils/examples/page-patterns.js.map +0 -1
- package/dist/utils/examples/store-patterns.d.ts +0 -3
- package/dist/utils/examples/store-patterns.d.ts.map +0 -1
- package/dist/utils/examples/store-patterns.js +0 -40
- package/dist/utils/examples/store-patterns.js.map +0 -1
- package/dist/utils/examples/test-patterns.d.ts +0 -3
- package/dist/utils/examples/test-patterns.d.ts.map +0 -1
- package/dist/utils/examples/test-patterns.js +0 -58
- package/dist/utils/examples/test-patterns.js.map +0 -1
- package/dist/utils/examples/types.d.ts +0 -17
- package/dist/utils/examples/types.d.ts.map +0 -1
- package/dist/utils/examples/types.js +0 -2
- package/dist/utils/examples/types.js.map +0 -1
- package/dist/utils/examples/utility-patterns.d.ts +0 -3
- package/dist/utils/examples/utility-patterns.d.ts.map +0 -1
- package/dist/utils/examples/utility-patterns.js +0 -77
- package/dist/utils/examples/utility-patterns.js.map +0 -1
|
@@ -1,289 +1,24 @@
|
|
|
1
1
|
// noinspection JSUnresolvedReference
|
|
2
|
-
/** Generates CLAUDE.md content based on selected features. */
|
|
3
|
-
export function generateClaudeMd(featureIds, projectName, scripts) {
|
|
4
|
-
const sections = [];
|
|
5
|
-
// Header
|
|
6
|
-
sections.push(`# CLAUDE.md
|
|
7
|
-
|
|
8
|
-
AI assistant guidance for **${projectName}** - a React 19 + TypeScript + Vite 7 codebase.`);
|
|
9
|
-
// Commands section - based on actual scripts
|
|
10
|
-
const commandLines = [];
|
|
11
|
-
const scriptDescriptions = {
|
|
12
|
-
dev: 'Dev server at localhost:5173',
|
|
13
|
-
build: 'Production build (typecheck + bundle)',
|
|
14
|
-
preview: 'Preview production build',
|
|
15
|
-
typecheck: 'TypeScript only',
|
|
16
|
-
lint: 'ESLint check',
|
|
17
|
-
'lint:fix': 'ESLint auto-fix',
|
|
18
|
-
format: 'Prettier format',
|
|
19
|
-
'format:check': 'Prettier check',
|
|
20
|
-
test: 'Vitest once',
|
|
21
|
-
'test:watch': 'Vitest watch mode',
|
|
22
|
-
'test:coverage': 'Coverage (80% threshold)',
|
|
23
|
-
e2e: 'Playwright E2E',
|
|
24
|
-
'e2e:ui': 'Playwright UI mode',
|
|
25
|
-
'i18n:extract': 'Extract translations to .po',
|
|
26
|
-
prepare: 'Initialize Husky hooks',
|
|
27
|
-
};
|
|
28
|
-
for (const script of Object.keys(scripts).sort()) {
|
|
29
|
-
const desc = scriptDescriptions[script] || '';
|
|
30
|
-
const padding = ' '.repeat(Math.max(1, 20 - script.length));
|
|
31
|
-
commandLines.push(`npm run ${script}${padding}# ${desc}`);
|
|
32
|
-
}
|
|
33
|
-
sections.push(`
|
|
34
|
-
## Commands
|
|
35
|
-
|
|
36
|
-
\`\`\`bash
|
|
37
|
-
${commandLines.join('\n')}
|
|
38
|
-
\`\`\``);
|
|
39
|
-
// Project Structure - dynamic based on features
|
|
40
|
-
const structureParts = ['src/', '├── components/ # ui/ (primitives), layout/, shared/ (features)'];
|
|
41
|
-
if (featureIds.includes('api') || featureIds.includes('i18n') || featureIds.includes('mobile')) {
|
|
42
|
-
structureParts.push('├── contexts/ # React Context providers');
|
|
43
|
-
}
|
|
44
|
-
structureParts.push('├── hooks/ # Custom hooks');
|
|
45
|
-
structureParts.push('├── lib/ # config, utils, format' +
|
|
46
|
-
(featureIds.includes('api') ? ', api' : '') +
|
|
47
|
-
(featureIds.includes('routing') ? ', routes' : '') +
|
|
48
|
-
(featureIds.includes('state') ? ', storage' : ''));
|
|
49
|
-
if (featureIds.includes('routing')) {
|
|
50
|
-
structureParts.push('├── pages/ # Lazy-loaded route components');
|
|
51
|
-
}
|
|
52
|
-
if (featureIds.includes('state')) {
|
|
53
|
-
structureParts.push('├── stores/ # Zustand stores');
|
|
54
|
-
}
|
|
55
|
-
if (featureIds.includes('i18n')) {
|
|
56
|
-
structureParts.push('├── i18n/ # LinguiJS config and catalogs');
|
|
57
|
-
structureParts.push('├── locales/ # Translation files (.po)');
|
|
58
|
-
}
|
|
59
|
-
structureParts.push('└── types/ # TypeScript definitions');
|
|
60
|
-
if (featureIds.includes('testing')) {
|
|
61
|
-
structureParts.push('');
|
|
62
|
-
structureParts.push('# Unit tests co-located: *.test.ts/tsx next to source');
|
|
63
|
-
structureParts.push('e2e/tests/ # Playwright functional E2E tests');
|
|
64
|
-
if (featureIds.includes('performance')) {
|
|
65
|
-
structureParts.push('e2e/performance/ # Performance regression tests');
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
sections.push(`
|
|
69
|
-
## Project Structure
|
|
70
|
-
|
|
71
|
-
See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) for full structure and data flow.
|
|
72
|
-
|
|
73
|
-
\`\`\`
|
|
74
|
-
${structureParts.join('\n')}
|
|
75
|
-
\`\`\``);
|
|
76
|
-
// Code Patterns - always included
|
|
77
|
-
const stateHierarchy = [];
|
|
78
|
-
if (featureIds.includes('state'))
|
|
79
|
-
stateHierarchy.push('Zustand (persisted)');
|
|
80
|
-
if (featureIds.includes('api'))
|
|
81
|
-
stateHierarchy.push('TanStack Query (server)');
|
|
82
|
-
stateHierarchy.push('Context (UI)', 'useState (local)');
|
|
83
|
-
sections.push(`
|
|
84
|
-
## Code Patterns
|
|
85
|
-
|
|
86
|
-
**Imports**: Always use \`@/\` path alias
|
|
87
|
-
|
|
88
|
-
**Components**: Named exports + \`Props\` interface. Pages use default exports for lazy loading.
|
|
89
|
-
|
|
90
|
-
**TypeScript**: \`type\` for unions, \`interface\` for objects
|
|
91
|
-
|
|
92
|
-
**State hierarchy**: ${stateHierarchy.join(' → ')}
|
|
93
|
-
|
|
94
|
-
See [docs/CODING_STANDARDS.md](docs/CODING_STANDARDS.md) and [docs/COMPONENT_GUIDELINES.md](docs/COMPONENT_GUIDELINES.md).`);
|
|
95
|
-
// UI Components section - only if ui feature
|
|
96
|
-
if (featureIds.includes('ui')) {
|
|
97
|
-
sections.push(`
|
|
98
|
-
## UI Components (Shadcn/UI)
|
|
99
|
-
|
|
100
|
-
This project uses **Shadcn/UI** with radix-nova style. Components live in \`src/components/ui/\`.
|
|
101
|
-
|
|
102
|
-
### Adding New Components
|
|
103
|
-
|
|
104
|
-
\`\`\`bash
|
|
105
|
-
npx shadcn@latest add button # Single component
|
|
106
|
-
npx shadcn@latest add dialog card input # Multiple components
|
|
107
|
-
\`\`\`
|
|
108
|
-
|
|
109
|
-
**Pattern**: Import directly (no barrel exports for UI):
|
|
110
|
-
|
|
111
|
-
\`\`\`tsx
|
|
112
|
-
import { Button } from '@/components/ui/button';
|
|
113
|
-
import { cn } from '@/lib/utils';
|
|
114
|
-
\`\`\``);
|
|
115
|
-
}
|
|
116
|
-
// Mobile section - only if mobile feature
|
|
117
|
-
if (featureIds.includes('mobile')) {
|
|
118
|
-
sections.push(`
|
|
119
|
-
## Mobile & Responsive Design
|
|
120
|
-
|
|
121
|
-
This project includes mobile-first responsive utilities.
|
|
122
|
-
|
|
123
|
-
### Viewport Detection
|
|
124
|
-
|
|
125
|
-
\`\`\`tsx
|
|
126
|
-
import { MobileProvider, useMobileContext } from '@/contexts/mobileContext';
|
|
127
|
-
|
|
128
|
-
// Wrap app with MobileProvider
|
|
129
|
-
<MobileProvider>{children}</MobileProvider>
|
|
130
|
-
|
|
131
|
-
// Use in components
|
|
132
|
-
const { isMobile, isTablet, isDesktop, width } = useMobileContext();
|
|
133
|
-
\`\`\`
|
|
134
|
-
|
|
135
|
-
### Breakpoints
|
|
136
|
-
|
|
137
|
-
\`\`\`tsx
|
|
138
|
-
import { BREAKPOINTS, useIsMobile, useIsDesktop } from '@/hooks/useMediaQuery';
|
|
139
|
-
|
|
140
|
-
// BREAKPOINTS: sm (640), md (768), lg (1024), xl (1280)
|
|
141
|
-
const isMobile = useIsMobile(); // width < 768px
|
|
142
|
-
const isDesktop = useIsDesktop(); // width >= 1024px
|
|
143
|
-
\`\`\`
|
|
144
|
-
|
|
145
|
-
### Touch-Aware Sizing
|
|
146
|
-
|
|
147
|
-
\`\`\`tsx
|
|
148
|
-
import { useTouchSizes } from '@/hooks/useTouchSizes';
|
|
149
|
-
|
|
150
|
-
const sizes = useTouchSizes();
|
|
151
|
-
<Button size={sizes.button}>Click</Button> // 'touch' on mobile, 'default' on desktop
|
|
152
|
-
\`\`\``);
|
|
153
|
-
}
|
|
154
|
-
// Theming section - only if theming feature
|
|
155
|
-
if (featureIds.includes('theming')) {
|
|
156
|
-
sections.push(`
|
|
157
|
-
## Theming
|
|
158
|
-
|
|
159
|
-
Light/dark/system theme support with Zustand persistence.
|
|
160
|
-
|
|
161
|
-
### Usage
|
|
162
|
-
|
|
163
|
-
\`\`\`tsx
|
|
164
|
-
import { usePreferencesStore } from '@/stores/preferencesStore';
|
|
165
|
-
|
|
166
|
-
// Get current theme
|
|
167
|
-
const theme = usePreferencesStore((s) => s.theme);
|
|
168
|
-
|
|
169
|
-
// Toggle theme
|
|
170
|
-
const toggleTheme = usePreferencesStore((s) => s.toggleTheme);
|
|
171
|
-
|
|
172
|
-
// Get resolved theme (actual light/dark value when 'system')
|
|
173
|
-
const getResolvedTheme = usePreferencesStore((s) => s.getResolvedTheme);
|
|
174
|
-
\`\`\`
|
|
175
|
-
|
|
176
|
-
The \`useThemeEffect\` hook automatically applies the \`.dark\` class to the document.
|
|
177
|
-
The ThemeToggle component provides a UI for switching between light, dark, and system themes.`);
|
|
178
|
-
}
|
|
179
|
-
// MCP Servers section - always helpful
|
|
180
|
-
sections.push(`
|
|
181
|
-
## MCP Servers (PREFER OVER WebSearch)
|
|
182
|
-
|
|
183
|
-
Use MCP servers for documentation lookup. They provide **structured, version-accurate data** directly from source.`);
|
|
184
|
-
if (featureIds.includes('ui')) {
|
|
185
|
-
sections.push(`
|
|
186
|
-
### Shadcn MCP (UI Components)
|
|
187
|
-
|
|
188
|
-
| Need | Tool |
|
|
189
|
-
| ------------------- | ------------------------------------------------ |
|
|
190
|
-
| Find component | \`mcp__shadcn__search_items_in_registries\` |
|
|
191
|
-
| View component code | \`mcp__shadcn__view_items_in_registries\` |
|
|
192
|
-
| Usage examples | \`mcp__shadcn__get_item_examples_from_registries\` |
|
|
193
|
-
| CLI add command | \`mcp__shadcn__get_add_command_for_items\` |`);
|
|
194
|
-
}
|
|
195
|
-
sections.push(`
|
|
196
|
-
### Context7 MCP (All Libraries)
|
|
197
|
-
|
|
198
|
-
Use for **any npm package** documentation:
|
|
199
|
-
|
|
200
|
-
\`\`\`
|
|
201
|
-
resolve-library-id → get-library-docs
|
|
202
|
-
\`\`\`
|
|
203
|
-
|
|
204
|
-
**Examples**: react-hook-form, @tanstack/react-query, zustand, zod, date-fns
|
|
205
|
-
|
|
206
|
-
### Decision Flow
|
|
207
|
-
|
|
208
|
-
\`\`\`
|
|
209
|
-
Need UI component? → Shadcn MCP
|
|
210
|
-
Need library docs? → Context7 MCP (any npm package)
|
|
211
|
-
Need general info? → WebSearch (fallback only)
|
|
212
|
-
\`\`\``);
|
|
213
|
-
// Translations section - only if i18n feature
|
|
214
|
-
if (featureIds.includes('i18n')) {
|
|
215
|
-
sections.push(`
|
|
216
|
-
## Translations (CRITICAL)
|
|
217
|
-
|
|
218
|
-
All user-facing text MUST have translator comments. ESLint enforces this.
|
|
219
|
-
|
|
220
|
-
\`\`\`tsx
|
|
221
|
-
<Trans comment="Dashboard heading">Welcome back</Trans>
|
|
222
|
-
t({ message: 'Close', comment: 'Close button' })
|
|
223
|
-
\`\`\`
|
|
224
|
-
|
|
225
|
-
See [docs/INTERNATIONALIZATION.md](docs/INTERNATIONALIZATION.md).`);
|
|
226
|
-
}
|
|
227
|
-
// Testing section - only if testing feature
|
|
228
|
-
if (featureIds.includes('testing')) {
|
|
229
|
-
sections.push(`
|
|
230
|
-
## Testing
|
|
231
|
-
|
|
232
|
-
See [docs/TESTING.md](docs/TESTING.md) and [docs/E2E_TESTING.md](docs/E2E_TESTING.md).
|
|
233
|
-
|
|
234
|
-
Unit tests are **co-located** with source files (\`*.test.ts/tsx\`). 80% coverage required.
|
|
235
|
-
|
|
236
|
-
\`\`\`typescript
|
|
237
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
238
|
-
import { screen, renderHook } from '@testing-library/react';
|
|
239
|
-
import { render, mockMatchMedia, server } from '@/test';
|
|
240
|
-
\`\`\`
|
|
241
|
-
|
|
242
|
-
MSW handlers auto-reset after each test.`);
|
|
243
|
-
}
|
|
244
|
-
// Common Gotchas - filtered by features
|
|
245
|
-
const gotchas = [];
|
|
246
|
-
if (featureIds.includes('devtools')) {
|
|
247
|
-
gotchas.push('**Node.js >= 22.0.0** required (check `.nvmrc`)');
|
|
248
|
-
gotchas.push('**Conventional commits** enforced by commitlint');
|
|
249
|
-
}
|
|
250
|
-
if (featureIds.includes('mobile')) {
|
|
251
|
-
gotchas.push('**Context hooks throw** outside provider (e.g., `useMobileContext()`)');
|
|
252
|
-
}
|
|
253
|
-
gotchas.push('**Barrel exports** in each directory via `index.ts`');
|
|
254
|
-
if (featureIds.includes('ui')) {
|
|
255
|
-
gotchas.push('**UI components** import directly: `@/components/ui/button` (no barrel)');
|
|
256
|
-
}
|
|
257
|
-
sections.push(`
|
|
258
|
-
## Common Gotchas
|
|
259
|
-
|
|
260
|
-
${gotchas.map((g, i) => `${i + 1}. ${g}`).join('\n')}
|
|
261
|
-
`);
|
|
262
|
-
return sections.join('\n');
|
|
263
|
-
}
|
|
264
2
|
/**
|
|
265
|
-
*
|
|
3
|
+
* Content generators for env.ts, routes.ts, vite-env.d.ts.
|
|
4
|
+
* CLAUDE.md generation moved to ./claude-md/
|
|
266
5
|
*/
|
|
6
|
+
import { FEATURE } from '../../constants.js';
|
|
7
|
+
export { generateClaudeMd } from './claude-md/index.js';
|
|
8
|
+
/** Generate vite-env.d.ts content based on selected features. */
|
|
267
9
|
export function generateViteEnvDts(featureIds) {
|
|
268
10
|
const sections = [];
|
|
269
|
-
|
|
270
|
-
if (featureIds.includes('i18n')) {
|
|
11
|
+
if (featureIds.includes(FEATURE.I18N)) {
|
|
271
12
|
sections.push(`declare module '*.po' {
|
|
272
13
|
import type { Messages } from '@lingui/core';
|
|
273
14
|
export const messages: Messages;
|
|
274
15
|
}`);
|
|
275
16
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
// Core env vars (always included)
|
|
279
|
-
envVars.push(' readonly VITE_APP_NAME: string;');
|
|
280
|
-
envVars.push(' readonly VITE_APP_URL: string;');
|
|
281
|
-
// API feature env vars
|
|
282
|
-
if (featureIds.includes('api')) {
|
|
17
|
+
const envVars = [' readonly VITE_APP_NAME: string;', ' readonly VITE_APP_URL: string;'];
|
|
18
|
+
if (featureIds.includes(FEATURE.API)) {
|
|
283
19
|
envVars.push(' readonly VITE_API_URL: string;');
|
|
284
20
|
}
|
|
285
|
-
|
|
286
|
-
if (featureIds.includes('observability')) {
|
|
21
|
+
if (featureIds.includes(FEATURE.OBSERVABILITY)) {
|
|
287
22
|
envVars.push(' readonly VITE_SENTRY_DSN: string;');
|
|
288
23
|
envVars.push(' readonly VITE_SENTRY_ENABLED: string;');
|
|
289
24
|
}
|
|
@@ -298,24 +33,21 @@ interface ImportMeta {
|
|
|
298
33
|
}`);
|
|
299
34
|
return sections.join('\n\n') + '\n';
|
|
300
35
|
}
|
|
301
|
-
/**
|
|
302
|
-
* Generate env.ts content based on selected features
|
|
303
|
-
*/
|
|
36
|
+
/** Generate env.ts content based on selected features. */
|
|
304
37
|
export function generateEnvTs(featureIds) {
|
|
305
|
-
const schemaFields = [
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
if (featureIds.includes(
|
|
38
|
+
const schemaFields = [
|
|
39
|
+
' VITE_APP_NAME: z.string().min(1).optional(),',
|
|
40
|
+
' VITE_APP_URL: z.string().url().optional(),',
|
|
41
|
+
];
|
|
42
|
+
const envFields = [
|
|
43
|
+
' VITE_APP_NAME: import.meta.env.VITE_APP_NAME,',
|
|
44
|
+
' VITE_APP_URL: import.meta.env.VITE_APP_URL,',
|
|
45
|
+
];
|
|
46
|
+
if (featureIds.includes(FEATURE.API)) {
|
|
314
47
|
schemaFields.push(' VITE_API_URL: z.string().url().optional(),');
|
|
315
48
|
envFields.push(' VITE_API_URL: import.meta.env.VITE_API_URL,');
|
|
316
49
|
}
|
|
317
|
-
|
|
318
|
-
if (featureIds.includes('observability')) {
|
|
50
|
+
if (featureIds.includes(FEATURE.OBSERVABILITY)) {
|
|
319
51
|
schemaFields.push(' VITE_SENTRY_DSN: z.string().url().optional(),');
|
|
320
52
|
schemaFields.push(' VITE_SENTRY_ENABLED: z.string().optional(),');
|
|
321
53
|
envFields.push(' VITE_SENTRY_DSN: import.meta.env.VITE_SENTRY_DSN,');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generators.js","sourceRoot":"","sources":["../../../src/utils/scaffold/generators.ts"],"names":[],"mappings":"AAAA,qCAAqC;
|
|
1
|
+
{"version":3,"file":"generators.js","sourceRoot":"","sources":["../../../src/utils/scaffold/generators.ts"],"names":[],"mappings":"AAAA,qCAAqC;AAErC;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,iEAAiE;AACjE,MAAM,UAAU,kBAAkB,CAAC,UAAuB;IACxD,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,IAAI,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACtC,QAAQ,CAAC,IAAI,C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AA+D,CAAC,CAAC;IAClF,CAAC;IAED,2CAA2C;IAC3C,YAAY,CAAC,IAAI,CAAC,+EAA+E,CAAC,CAAC;IACnG,YAAY,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;IACxD,YAAY,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;IACzD,SAAS,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;IAClD,SAAS,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;IAChD,SAAS,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;IAElD,OAAO;;;;;;;;EAQP,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;;;;;;EAWvB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;CAsBrB,CAAC;AACF,CAAC;AAED,mCAAmC;AACnC,MAAM,UAAU,gBAAgB;IAC9B,OAAO;;;;;;;;;;;CAWR,CAAC;AACF,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Scaffold utilities
|
|
3
|
-
*
|
|
4
|
-
* Re-exports all scaffold-related functions for convenient importing.
|
|
2
|
+
* Scaffold utilities - re-exports for convenient importing.
|
|
5
3
|
*/
|
|
6
4
|
export { resolveFeatureDependencies, mergeDependencies, mergeScripts } from './dependencies.js';
|
|
5
|
+
export type { MergeDependenciesResult } from './dependencies.js';
|
|
7
6
|
export { computeFileStructure, getConfigFiles, readConfigFileContent } from './file-structure.js';
|
|
8
7
|
export { getSetupCommands } from './commands.js';
|
|
9
8
|
export { generateClaudeMd, generateViteEnvDts, generateEnvTs, generateRoutesTs } from './generators.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/scaffold/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/scaffold/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAChG,YAAY,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAClG,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxG,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Scaffold utilities
|
|
3
|
-
*
|
|
4
|
-
* Re-exports all scaffold-related functions for convenient importing.
|
|
2
|
+
* Scaffold utilities - re-exports for convenient importing.
|
|
5
3
|
*/
|
|
6
4
|
export { resolveFeatureDependencies, mergeDependencies, mergeScripts } from './dependencies.js';
|
|
7
5
|
export { computeFileStructure, getConfigFiles, readConfigFileContent } from './file-structure.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/scaffold/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/scaffold/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEhG,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAClG,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxG,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-spa-scaffold/mcp",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "MCP server for scaffolding projects based on react-spa-scaffold template",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"zod": "^4.2.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@types/node": "^22.15.0",
|
|
47
46
|
"@react-spa-scaffold/tsconfig": "*",
|
|
47
|
+
"@types/node": "^22.15.0",
|
|
48
48
|
"typescript": "~5.9.0",
|
|
49
49
|
"vitest": "^4.0.16"
|
|
50
50
|
},
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* get_example tool
|
|
3
|
-
*
|
|
4
|
-
* Returns real code examples for specific pattern types.
|
|
5
|
-
* AI agents use this to understand how to generate code
|
|
6
|
-
* that matches react-spa-scaffold conventions.
|
|
7
|
-
*/
|
|
8
|
-
import { z } from 'zod';
|
|
9
|
-
export declare const getExampleSchema: z.ZodObject<{
|
|
10
|
-
pattern: z.ZodEnum<{
|
|
11
|
-
[x: string]: string;
|
|
12
|
-
}>;
|
|
13
|
-
}, z.core.$strip>;
|
|
14
|
-
export type GetExampleInput = z.infer<typeof getExampleSchema>;
|
|
15
|
-
export declare function getExample(input: GetExampleInput): Promise<{
|
|
16
|
-
error: string;
|
|
17
|
-
hint: string;
|
|
18
|
-
pattern?: undefined;
|
|
19
|
-
description?: undefined;
|
|
20
|
-
filePath?: undefined;
|
|
21
|
-
keyPoints?: undefined;
|
|
22
|
-
code?: undefined;
|
|
23
|
-
usage?: undefined;
|
|
24
|
-
} | {
|
|
25
|
-
pattern: string;
|
|
26
|
-
description: string;
|
|
27
|
-
filePath: string;
|
|
28
|
-
keyPoints: string[];
|
|
29
|
-
code: string;
|
|
30
|
-
usage: string;
|
|
31
|
-
error?: undefined;
|
|
32
|
-
hint?: undefined;
|
|
33
|
-
}>;
|
|
34
|
-
export declare const getExampleToolDefinition: {
|
|
35
|
-
name: string;
|
|
36
|
-
description: string;
|
|
37
|
-
inputSchema: {
|
|
38
|
-
type: "object";
|
|
39
|
-
properties: {
|
|
40
|
-
pattern: {
|
|
41
|
-
type: "string";
|
|
42
|
-
description: string;
|
|
43
|
-
enum: [string, ...string[]];
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
required: string[];
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
//# sourceMappingURL=get-example.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-example.d.ts","sourceRoot":"","sources":["../../src/tools/get-example.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,gBAAgB;;;;iBAI3B,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE/D,wBAAsB,UAAU,CAAC,KAAK,EAAE,eAAe;;;;;;;;;;;;;;;;;;GAoBtD;AAwBD,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;CAoCpC,CAAC"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* get_example tool
|
|
3
|
-
*
|
|
4
|
-
* Returns real code examples for specific pattern types.
|
|
5
|
-
* AI agents use this to understand how to generate code
|
|
6
|
-
* that matches react-spa-scaffold conventions.
|
|
7
|
-
*/
|
|
8
|
-
import { z } from 'zod';
|
|
9
|
-
import { getCodeExample, getAvailablePatterns } from '../utils/index.js';
|
|
10
|
-
const AVAILABLE_PATTERNS = getAvailablePatterns();
|
|
11
|
-
export const getExampleSchema = z.object({
|
|
12
|
-
pattern: z.enum(AVAILABLE_PATTERNS, {
|
|
13
|
-
error: `Invalid pattern. Available: ${AVAILABLE_PATTERNS.join(', ')}`,
|
|
14
|
-
}),
|
|
15
|
-
});
|
|
16
|
-
export async function getExample(input) {
|
|
17
|
-
const { pattern } = input;
|
|
18
|
-
const example = await getCodeExample(pattern);
|
|
19
|
-
if (!example) {
|
|
20
|
-
return {
|
|
21
|
-
error: `Could not load example for pattern: ${pattern}`,
|
|
22
|
-
hint: 'Ensure MCP server is running from react-spa-scaffold directory',
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
return {
|
|
26
|
-
pattern: example.pattern,
|
|
27
|
-
description: example.description,
|
|
28
|
-
filePath: example.filePath,
|
|
29
|
-
keyPoints: example.keyPoints,
|
|
30
|
-
code: example.code,
|
|
31
|
-
usage: generateUsageHint(pattern),
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function generateUsageHint(pattern) {
|
|
35
|
-
const hints = {
|
|
36
|
-
'component-ui': 'Place in src/components/ui/ with kebab-case filename',
|
|
37
|
-
'component-shared': 'Create subdirectory in src/components/shared/ with index.ts barrel',
|
|
38
|
-
'component-layout': 'Place in src/components/layout/',
|
|
39
|
-
'hook-state': 'Place in src/hooks/ with useXxx.ts naming',
|
|
40
|
-
'hook-query': 'Place in src/hooks/ - define fetchFn outside hook',
|
|
41
|
-
'hook-form': 'Place in src/hooks/ - import schema from lib/validations',
|
|
42
|
-
'hook-effect': 'Place in src/hooks/ - no return value',
|
|
43
|
-
'zustand-store': 'Place in src/stores/ with xxxStore.ts naming',
|
|
44
|
-
'page-component': 'Place in src/pages/ with XxxPage named export',
|
|
45
|
-
'context-provider': 'Place in src/contexts/ - export both Provider and hook',
|
|
46
|
-
'test-component': 'Co-locate with component: ComponentName.test.tsx next to ComponentName.tsx',
|
|
47
|
-
'test-hook': 'Co-locate with hook: useXxx.test.ts next to useXxx.ts',
|
|
48
|
-
'test-store': 'Co-locate with store: xxxStore.test.ts next to xxxStore.ts',
|
|
49
|
-
'msw-handler': 'Place in src/mocks/handlers/',
|
|
50
|
-
'zod-schema': 'Add to src/lib/validations.ts',
|
|
51
|
-
};
|
|
52
|
-
return hints[pattern] || 'Follow the file path shown in the example';
|
|
53
|
-
}
|
|
54
|
-
export const getExampleToolDefinition = {
|
|
55
|
-
name: 'get_example',
|
|
56
|
-
description: `Get real code example for a specific pattern type.
|
|
57
|
-
|
|
58
|
-
Returns actual code from the react-spa-scaffold repository, not templates.
|
|
59
|
-
Use this to understand exact patterns when generating new files.
|
|
60
|
-
|
|
61
|
-
Available patterns:
|
|
62
|
-
- Components: component-ui, component-shared, component-layout
|
|
63
|
-
- Hooks: hook-state, hook-query, hook-form, hook-effect, use-language-hook
|
|
64
|
-
- Store: zustand-store
|
|
65
|
-
- Pages: page-component, lazy-page
|
|
66
|
-
- Context: context-provider, query-provider
|
|
67
|
-
- API: api-client
|
|
68
|
-
- Tests: test-component, test-hook, test-store, msw-handler
|
|
69
|
-
- Validation: zod-schema, form-error-component
|
|
70
|
-
- i18n: trans-component, t-function, language-switcher
|
|
71
|
-
- Utils: storage-utility
|
|
72
|
-
- Theme: theme-toggle
|
|
73
|
-
- SEO: seo-component
|
|
74
|
-
|
|
75
|
-
Each example includes:
|
|
76
|
-
- Actual working code
|
|
77
|
-
- Key points explaining the pattern
|
|
78
|
-
- File path where it should be placed`,
|
|
79
|
-
inputSchema: {
|
|
80
|
-
type: 'object',
|
|
81
|
-
properties: {
|
|
82
|
-
pattern: {
|
|
83
|
-
type: 'string',
|
|
84
|
-
description: 'Pattern type to get example for',
|
|
85
|
-
enum: AVAILABLE_PATTERNS,
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
required: ['pattern'],
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
//# sourceMappingURL=get-example.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-example.js","sourceRoot":"","sources":["../../src/tools/get-example.ts"],"names":[],"mappings":"AAAA;;;;;;GAM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EAAE,+CAA+C;QACjE,kBAAkB,EAAE,wDAAwD;QAC5E,gBAAgB,EAAE,4EAA4E;QAC9F,WAAW,EAAE,uDAAuD;QACpE,YAAY,EAAE,4DAA4D;QAC1E,aAAa,EAAE,8BAA8B;QAC7C,YAAY,EAAE,+BAA+B;KAC9C,CAAC;IAEF,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,2CAA2C,CAAC;AACvE,CAAC;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;;sCAsBuB;IACpC,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,OAAO,EAAE;gBACP,IAAI,EAAE,QAAiB;gBACvB,WAAW,EAAE,iCAAiC;gBAC9C,IAAI,EAAE,kBAAkB;aACzB;SACF;QACD,QAAQ,EAAE,CAAC,SAAS,CAAC;KACtB;CACF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-example.test.d.ts","sourceRoot":"","sources":["../../src/tools/get-example.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for get_example tool
|
|
3
|
-
*/
|
|
4
|
-
import { describe, it, expect } from 'vitest';
|
|
5
|
-
import { getExample, getExampleSchema } from './get-example.js';
|
|
6
|
-
describe('get_example tool', () => {
|
|
7
|
-
it('rejects unknown pattern via schema', () => {
|
|
8
|
-
const result = getExampleSchema.safeParse({ pattern: 'unknown-pattern' });
|
|
9
|
-
expect(result.success).toBe(false);
|
|
10
|
-
if (!result.success) {
|
|
11
|
-
expect(result.error.message).toContain('Invalid pattern');
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
it('returns code for valid pattern', async () => {
|
|
15
|
-
const result = await getExample({ pattern: 'zustand-store' });
|
|
16
|
-
expect(result).not.toHaveProperty('error');
|
|
17
|
-
expect(result).toHaveProperty('code');
|
|
18
|
-
expect(result).toHaveProperty('filePath');
|
|
19
|
-
expect(result).toHaveProperty('description');
|
|
20
|
-
expect(result).toHaveProperty('keyPoints');
|
|
21
|
-
});
|
|
22
|
-
it('returns usage hint', async () => {
|
|
23
|
-
const result = await getExample({ pattern: 'zustand-store' });
|
|
24
|
-
expect(result).toHaveProperty('usage');
|
|
25
|
-
expect(typeof result.usage).toBe('string');
|
|
26
|
-
});
|
|
27
|
-
it('returns actual code content', async () => {
|
|
28
|
-
const result = await getExample({ pattern: 'hook-state' });
|
|
29
|
-
expect(result.code).toBeTruthy();
|
|
30
|
-
expect(result.code?.length).toBeGreaterThan(50);
|
|
31
|
-
});
|
|
32
|
-
it('works for component patterns', async () => {
|
|
33
|
-
const result = await getExample({ pattern: 'component-ui' });
|
|
34
|
-
expect(result).not.toHaveProperty('error');
|
|
35
|
-
expect(result.code).toContain('export');
|
|
36
|
-
});
|
|
37
|
-
it('works for test patterns', async () => {
|
|
38
|
-
const result = await getExample({ pattern: 'test-component' });
|
|
39
|
-
expect(result).not.toHaveProperty('error');
|
|
40
|
-
expect(result.code).toContain('describe');
|
|
41
|
-
});
|
|
42
|
-
it('works for mobile-context pattern', async () => {
|
|
43
|
-
const result = await getExample({ pattern: 'mobile-context' });
|
|
44
|
-
expect(result).not.toHaveProperty('error');
|
|
45
|
-
expect(result.code).toContain('MobileProvider');
|
|
46
|
-
expect(result.code).toContain('useMobileContext');
|
|
47
|
-
expect(result.filePath).toBe('src/contexts/mobileContext.tsx');
|
|
48
|
-
});
|
|
49
|
-
it('works for use-media-query pattern', async () => {
|
|
50
|
-
const result = await getExample({ pattern: 'use-media-query' });
|
|
51
|
-
expect(result).not.toHaveProperty('error');
|
|
52
|
-
expect(result.code).toContain('BREAKPOINTS');
|
|
53
|
-
expect(result.code).toContain('useMediaQuery');
|
|
54
|
-
expect(result.filePath).toBe('src/hooks/useMediaQuery.ts');
|
|
55
|
-
});
|
|
56
|
-
it('works for use-touch-sizes pattern', async () => {
|
|
57
|
-
const result = await getExample({ pattern: 'use-touch-sizes' });
|
|
58
|
-
expect(result).not.toHaveProperty('error');
|
|
59
|
-
expect(result.code).toContain('useTouchSizes');
|
|
60
|
-
expect(result.filePath).toBe('src/hooks/useTouchSizes.ts');
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
//# sourceMappingURL=get-example.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-example.test.js","sourceRoot":"","sources":["../../src/tools/get-example.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEhE,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,MAAM,MAAM,GAAG,gBAAgB,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC,CAAC;QAE1E,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gCAAgC,EAAE,KAAK,IAAI,EAAE;QAC9C,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC;QAE9D,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC3C,MAAM,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,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