@codebakers/mcp 5.4.2 → 5.4.3

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.
@@ -26,134 +26,134 @@ export async function generateComponent(args) {
26
26
  const filePath = path.join(cwd, `src/components/${name}.tsx`);
27
27
  await fs.mkdir(path.dirname(filePath), { recursive: true });
28
28
  await fs.writeFile(filePath, code, 'utf-8');
29
- return `🍞 CodeBakers: Component Generated
30
-
31
- **File:** src/components/${name}.tsx
32
- **Type:** ${type}
33
- **Entity:** ${entity}
34
-
35
- Includes:
36
- ✅ All states (loading/error/empty/success)
37
- ✅ TypeScript types
38
- ✅ Store integration
39
- ✅ Error handling
29
+ return `🍞 CodeBakers: Component Generated
30
+
31
+ **File:** src/components/${name}.tsx
32
+ **Type:** ${type}
33
+ **Entity:** ${entity}
34
+
35
+ Includes:
36
+ ✅ All states (loading/error/empty/success)
37
+ ✅ TypeScript types
38
+ ✅ Store integration
39
+ ✅ Error handling
40
40
  ✅ Accessibility (ARIA labels)`;
41
41
  }
42
42
  function generateListComponent(name, entity) {
43
43
  const storeName = `use${entity}Store`;
44
44
  const entityLower = entity.toLowerCase();
45
- return `'use client';
46
-
47
- import { useEffect } from 'react';
48
- import { ${storeName} } from '@/stores/${entityLower}-store';
49
-
50
- export function ${name}() {
51
- const { ${entityLower}s, loading, error, fetch${entity}s } = ${storeName}();
52
-
53
- useEffect(() => {
54
- fetch${entity}s();
55
- }, [fetch${entity}s]);
56
-
57
- // LOADING STATE
58
- if (loading) {
59
- return (
60
- <div className="space-y-4" role="status" aria-label="Loading ${entityLower}s">
61
- <div className="h-20 bg-gray-200 animate-pulse rounded" />
62
- <div className="h-20 bg-gray-200 animate-pulse rounded" />
63
- <div className="h-20 bg-gray-200 animate-pulse rounded" />
64
- </div>
65
- );
66
- }
67
-
68
- // ERROR STATE
69
- if (error) {
70
- return (
71
- <div className="p-4 bg-red-50 border border-red-200 rounded" role="alert">
72
- <h3 className="font-semibold text-red-900">Failed to load ${entityLower}s</h3>
73
- <p className="text-sm text-red-700">{error}</p>
74
- <button
75
- onClick={() => fetch${entity}s()}
76
- className="mt-2 px-4 py-2 bg-red-600 text-white rounded hover:bg-red-700"
77
- >
78
- Retry
79
- </button>
80
- </div>
81
- );
82
- }
83
-
84
- // EMPTY STATE
85
- if (${entityLower}s.length === 0) {
86
- return (
87
- <div className="text-center p-8">
88
- <p className="text-gray-500">No ${entityLower}s yet</p>
89
- <button className="mt-4 px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700">
90
- Create ${entity}
91
- </button>
92
- </div>
93
- );
94
- }
95
-
96
- // SUCCESS STATE
97
- return (
98
- <div className="space-y-4">
99
- {${entityLower}s.map((item) => (
100
- <div key={item.id} className="p-4 border rounded hover:bg-gray-50">
101
- <div className="flex justify-between items-center">
102
- <div>
103
- <h3 className="font-medium">{item.id}</h3>
104
- <p className="text-sm text-gray-500">
105
- {new Date(item.created_at).toLocaleDateString()}
106
- </p>
107
- </div>
108
- <button
109
- className="text-red-600 hover:text-red-700"
110
- aria-label="Delete ${entityLower}"
111
- >
112
- Delete
113
- </button>
114
- </div>
115
- </div>
116
- ))}
117
- </div>
118
- );
119
- }
45
+ return `'use client';
46
+
47
+ import { useEffect } from 'react';
48
+ import { ${storeName} } from '@/stores/${entityLower}-store';
49
+
50
+ export function ${name}() {
51
+ const { ${entityLower}s, loading, error, fetch${entity}s } = ${storeName}();
52
+
53
+ useEffect(() => {
54
+ fetch${entity}s();
55
+ }, [fetch${entity}s]);
56
+
57
+ // LOADING STATE
58
+ if (loading) {
59
+ return (
60
+ <div className="space-y-4" role="status" aria-label="Loading ${entityLower}s">
61
+ <div className="h-20 bg-gray-200 animate-pulse rounded" />
62
+ <div className="h-20 bg-gray-200 animate-pulse rounded" />
63
+ <div className="h-20 bg-gray-200 animate-pulse rounded" />
64
+ </div>
65
+ );
66
+ }
67
+
68
+ // ERROR STATE
69
+ if (error) {
70
+ return (
71
+ <div className="p-4 bg-red-50 border border-red-200 rounded" role="alert">
72
+ <h3 className="font-semibold text-red-900">Failed to load ${entityLower}s</h3>
73
+ <p className="text-sm text-red-700">{error}</p>
74
+ <button
75
+ onClick={() => fetch${entity}s()}
76
+ className="mt-2 px-4 py-2 bg-red-600 text-white rounded hover:bg-red-700"
77
+ >
78
+ Retry
79
+ </button>
80
+ </div>
81
+ );
82
+ }
83
+
84
+ // EMPTY STATE
85
+ if (${entityLower}s.length === 0) {
86
+ return (
87
+ <div className="text-center p-8">
88
+ <p className="text-gray-500">No ${entityLower}s yet</p>
89
+ <button className="mt-4 px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700">
90
+ Create ${entity}
91
+ </button>
92
+ </div>
93
+ );
94
+ }
95
+
96
+ // SUCCESS STATE
97
+ return (
98
+ <div className="space-y-4">
99
+ {${entityLower}s.map((item) => (
100
+ <div key={item.id} className="p-4 border rounded hover:bg-gray-50">
101
+ <div className="flex justify-between items-center">
102
+ <div>
103
+ <h3 className="font-medium">{item.id}</h3>
104
+ <p className="text-sm text-gray-500">
105
+ {new Date(item.created_at).toLocaleDateString()}
106
+ </p>
107
+ </div>
108
+ <button
109
+ className="text-red-600 hover:text-red-700"
110
+ aria-label="Delete ${entityLower}"
111
+ >
112
+ Delete
113
+ </button>
114
+ </div>
115
+ </div>
116
+ ))}
117
+ </div>
118
+ );
119
+ }
120
120
  `;
121
121
  }
122
122
  function generateDetailComponent(name, entity) {
123
- return `'use client';
124
-
125
- export function ${name}({ id }: { id: string }) {
126
- return <div>Detail view for ${entity} {id}</div>;
127
- }
123
+ return `'use client';
124
+
125
+ export function ${name}({ id }: { id: string }) {
126
+ return <div>Detail view for ${entity} {id}</div>;
127
+ }
128
128
  `;
129
129
  }
130
130
  function generateFormComponent(name, entity) {
131
- return `'use client';
132
-
133
- import { useState } from 'react';
134
- import { use${entity}Store } from '@/stores/${entity.toLowerCase()}-store';
135
-
136
- export function ${name}() {
137
- const [formData, setFormData] = useState({});
138
- const { create${entity}, loading } = use${entity}Store();
139
-
140
- const handleSubmit = async (e: React.FormEvent) => {
141
- e.preventDefault();
142
- await create${entity}(formData);
143
- };
144
-
145
- return (
146
- <form onSubmit={handleSubmit} className="space-y-4">
147
- <button
148
- type="submit"
149
- disabled={loading}
150
- className="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50"
151
- >
152
- {loading ? 'Creating...' : 'Create ${entity}'}
153
- </button>
154
- </form>
155
- );
156
- }
131
+ return `'use client';
132
+
133
+ import { useState } from 'react';
134
+ import { use${entity}Store } from '@/stores/${entity.toLowerCase()}-store';
135
+
136
+ export function ${name}() {
137
+ const [formData, setFormData] = useState({});
138
+ const { create${entity}, loading } = use${entity}Store();
139
+
140
+ const handleSubmit = async (e: React.FormEvent) => {
141
+ e.preventDefault();
142
+ await create${entity}(formData);
143
+ };
144
+
145
+ return (
146
+ <form onSubmit={handleSubmit} className="space-y-4">
147
+ <button
148
+ type="submit"
149
+ disabled={loading}
150
+ className="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50"
151
+ >
152
+ {loading ? 'Creating...' : 'Create ${entity}'}
153
+ </button>
154
+ </form>
155
+ );
156
+ }
157
157
  `;
158
158
  }
159
159
  //# sourceMappingURL=generate-component.js.map