@@ -103,74 +103,91 @@ function createServer({
103
103
version : '1.0.0' ,
104
104
} )
105
105
106
- server . tool ( 'listTanStackReactAddOns' , { } , ( ) => {
107
- return {
108
- content : [ { type : 'text' , text : JSON . stringify ( tanStackReactAddOns ) } ] ,
109
- }
110
- } )
106
+ server . tool (
107
+ 'listTanStackReactAddOns' ,
108
+ 'List the available add-ons for creating TanStack React applications' ,
109
+ { } ,
110
+ ( ) => {
111
+ const framework = getFrameworkById ( 'react-cra' ) !
112
+ return {
113
+ content : [
114
+ {
115
+ type : 'text' ,
116
+ text : JSON . stringify (
117
+ framework
118
+ . getAddOns ( )
119
+ . filter ( ( addOn ) => addOn . templates . includes ( 'file-router' ) )
120
+ . map ( ( addOn ) => ( {
121
+ id : addOn . id ,
122
+ description : addOn . description ,
123
+ } ) ) ,
124
+ ) ,
125
+ } ,
126
+ ] ,
127
+ }
128
+ } ,
129
+ )
111
130
112
131
server . tool (
113
132
'createTanStackReactApplication' ,
133
+ 'Create a new TanStack React application' ,
114
134
{
115
135
projectName : z
116
136
. string ( )
117
137
. describe (
118
138
'The package.json module name of the application (will also be the directory name)' ,
119
139
) ,
120
140
cwd : z . string ( ) . describe ( 'The directory to create the application in' ) ,
121
- addOns : z
122
- . array (
123
- z . enum ( [
124
- 'clerk' ,
125
- 'convex' ,
126
- 'form' ,
127
- 'netlify' ,
128
- 'sentry' ,
129
- 'shadcn' ,
130
- 'start' ,
131
- 'store' ,
132
- 'tanstack-query' ,
133
- 'tanchat' ,
134
- ] ) ,
135
- )
136
- . describe ( 'The IDs of the add-ons to install' ) ,
141
+ addOns : z . array ( z . string ( ) ) . describe ( 'The IDs of the add-ons to install' ) ,
137
142
targetDir : z
138
143
. string ( )
139
144
. describe (
140
145
'The directory to create the application in. Use the absolute path of the directory you want the application to be created in' ,
141
146
) ,
142
147
} ,
143
148
async ( { projectName, addOns, cwd, targetDir } ) => {
144
- const framework = getFrameworkById ( 'react' ) !
149
+ const framework = getFrameworkById ( 'react-cra ' ) !
145
150
try {
146
151
process . chdir ( cwd )
147
- const chosenAddOns = await finalizeAddOns (
148
- framework ,
149
- 'file-router' ,
150
- Array . from (
151
- new Set ( [ ...( addOns as unknown as Array < string > ) , ...forcedAddOns ] ) ,
152
- ) ,
153
- )
154
- await createApp (
155
- {
156
- projectName : projectName . replace ( / ^ \/ / , './' ) ,
152
+ try {
153
+ const chosenAddOns = await finalizeAddOns (
157
154
framework ,
158
- typescript : true ,
159
- tailwind : true ,
160
- packageManager : 'pnpm' ,
161
- mode : 'file-router' ,
162
- addOns : true ,
163
- chosenAddOns,
164
- git : true ,
165
- variableValues : { } ,
166
- } ,
167
- {
168
- silent : true ,
169
- environment : createDefaultEnvironment ( ) ,
170
- name,
171
- cwd : targetDir ,
172
- } ,
173
- )
155
+ 'file-router' ,
156
+ Array . from (
157
+ new Set ( [
158
+ ...( addOns as unknown as Array < string > ) ,
159
+ ...forcedAddOns ,
160
+ ] ) ,
161
+ ) ,
162
+ )
163
+ await createApp (
164
+ {
165
+ projectName : projectName . replace ( / ^ \/ / , './' ) ,
166
+ framework,
167
+ typescript : true ,
168
+ tailwind : true ,
169
+ packageManager : 'pnpm' ,
170
+ mode : 'file-router' ,
171
+ addOns : true ,
172
+ chosenAddOns,
173
+ git : true ,
174
+ variableValues : { } ,
175
+ } ,
176
+ {
177
+ silent : true ,
178
+ environment : createDefaultEnvironment ( ) ,
179
+ name,
180
+ cwd : targetDir ,
181
+ } ,
182
+ )
183
+ } catch ( error ) {
184
+ console . error ( error )
185
+ return {
186
+ content : [
187
+ { type : 'text' , text : `Error creating application: ${ error } ` } ,
188
+ ] ,
189
+ }
190
+ }
174
191
return {
175
192
content : [ { type : 'text' , text : 'Application created successfully' } ] ,
176
193
}
@@ -184,33 +201,42 @@ function createServer({
184
201
} ,
185
202
)
186
203
187
- server . tool ( 'listTanStackSolidAddOns' , { } , ( ) => {
188
- return {
189
- content : [ { type : 'text' , text : JSON . stringify ( tanStackSolidAddOns ) } ] ,
190
- }
191
- } )
204
+ server . tool (
205
+ 'listTanStackSolidAddOns' ,
206
+ 'List the available add-ons for creating TanStack Solid applications' ,
207
+ { } ,
208
+ ( ) => {
209
+ const framework = getFrameworkById ( 'solid' ) !
210
+ return {
211
+ content : [
212
+ {
213
+ type : 'text' ,
214
+ text : JSON . stringify (
215
+ framework
216
+ . getAddOns ( )
217
+ . filter ( ( addOn ) => addOn . templates . includes ( 'file-router' ) )
218
+ . map ( ( addOn ) => ( {
219
+ id : addOn . id ,
220
+ description : addOn . description ,
221
+ } ) ) ,
222
+ ) ,
223
+ } ,
224
+ ] ,
225
+ }
226
+ } ,
227
+ )
192
228
193
229
server . tool (
194
230
'createTanStackSolidApplication' ,
231
+ 'Create a new TanStack Solid application' ,
195
232
{
196
233
projectName : z
197
234
. string ( )
198
235
. describe (
199
236
'The package.json module name of the application (will also be the directory name)' ,
200
237
) ,
201
238
cwd : z . string ( ) . describe ( 'The directory to create the application in' ) ,
202
- addOns : z
203
- . array (
204
- z . enum ( [
205
- 'solid-ui' ,
206
- 'form' ,
207
- 'sentry' ,
208
- 'store' ,
209
- 'tanstack-query' ,
210
- 'tanchat' ,
211
- ] ) ,
212
- )
213
- . describe ( 'The IDs of the add-ons to install' ) ,
239
+ addOns : z . array ( z . string ( ) ) . describe ( 'The IDs of the add-ons to install' ) ,
214
240
targetDir : z
215
241
. string ( )
216
242
. describe (
@@ -221,33 +247,44 @@ function createServer({
221
247
const framework = getFrameworkById ( 'solid' ) !
222
248
try {
223
249
process . chdir ( cwd )
224
- const chosenAddOns = await finalizeAddOns (
225
- framework ,
226
- 'file-router' ,
227
- Array . from (
228
- new Set ( [ ...( addOns as unknown as Array < string > ) , ...forcedAddOns ] ) ,
229
- ) ,
230
- )
231
- await createApp (
232
- {
233
- projectName : projectName . replace ( / ^ \/ / , './' ) ,
250
+ try {
251
+ const chosenAddOns = await finalizeAddOns (
234
252
framework ,
235
- typescript : true ,
236
- tailwind : true ,
237
- packageManager : 'pnpm' ,
238
- mode : 'file-router' ,
239
- addOns : true ,
240
- chosenAddOns,
241
- git : true ,
242
- variableValues : { } ,
243
- } ,
244
- {
245
- silent : true ,
246
- environment : createDefaultEnvironment ( ) ,
247
- name,
248
- cwd : targetDir ,
249
- } ,
250
- )
253
+ 'file-router' ,
254
+ Array . from (
255
+ new Set ( [
256
+ ...( addOns as unknown as Array < string > ) ,
257
+ ...forcedAddOns ,
258
+ ] ) ,
259
+ ) ,
260
+ )
261
+ await createApp (
262
+ {
263
+ projectName : projectName . replace ( / ^ \/ / , './' ) ,
264
+ framework,
265
+ typescript : true ,
266
+ tailwind : true ,
267
+ packageManager : 'pnpm' ,
268
+ mode : 'file-router' ,
269
+ addOns : true ,
270
+ chosenAddOns,
271
+ git : true ,
272
+ variableValues : { } ,
273
+ } ,
274
+ {
275
+ silent : true ,
276
+ environment : createDefaultEnvironment ( ) ,
277
+ name,
278
+ cwd : targetDir ,
279
+ } ,
280
+ )
281
+ } catch ( error ) {
282
+ return {
283
+ content : [
284
+ { type : 'text' , text : `Error creating application: ${ error } ` } ,
285
+ ] ,
286
+ }
287
+ }
251
288
return {
252
289
content : [ { type : 'text' , text : 'Application created successfully' } ] ,
253
290
}
0 commit comments