|
1 | 1 | import { basename, resolve } from 'node:path'
|
2 | 2 |
|
3 | 3 | import {
|
4 |
| - FILE_ROUTER, |
5 | 4 | copyAddOnFile,
|
6 | 5 | jsSafeName,
|
7 | 6 | packageManagerExecute,
|
@@ -33,10 +32,6 @@ export async function createApp(
|
33 | 32 |
|
34 | 33 | const projectBaseDir = resolve(options.framework.baseDirectory)
|
35 | 34 | const templateDirBase = resolve(options.framework.baseDirectory, 'base')
|
36 |
| - const templateDirRouter = resolve( |
37 |
| - options.framework.baseDirectory, |
38 |
| - options.mode, |
39 |
| - ) |
40 | 35 |
|
41 | 36 | let targetDir: string = cwd || ''
|
42 | 37 | if (!targetDir.length) {
|
@@ -166,7 +161,6 @@ export async function createApp(
|
166 | 161 | options.projectName,
|
167 | 162 | options,
|
168 | 163 | projectBaseDir,
|
169 |
| - templateDirRouter, |
170 | 164 | targetDir,
|
171 | 165 | options.chosenAddOns.map((addOn) => addOn.packageAdditions),
|
172 | 166 | )
|
@@ -299,76 +293,35 @@ export async function createApp(
|
299 | 293 | }
|
300 | 294 | }
|
301 | 295 |
|
302 |
| - // Create the main entry point |
303 |
| - if (!isAddOnEnabled('start')) { |
304 |
| - if (options.typescript) { |
305 |
| - await templateFile( |
306 |
| - templateDirRouter, |
307 |
| - './src/main.tsx.ejs', |
308 |
| - './src/main.tsx', |
309 |
| - { |
310 |
| - routes, |
311 |
| - integrations, |
312 |
| - }, |
313 |
| - ) |
314 |
| - } else { |
315 |
| - await templateFile( |
316 |
| - templateDirRouter, |
317 |
| - './src/main.tsx.ejs', |
318 |
| - './src/main.jsx', |
319 |
| - { |
320 |
| - routes, |
321 |
| - integrations, |
322 |
| - }, |
323 |
| - ) |
324 |
| - } |
325 |
| - } |
326 |
| - |
327 |
| - // Setup the app component. There are four variations, typescript/javascript and tailwind/non-tailwind. |
328 |
| - if (options.mode === FILE_ROUTER) { |
329 |
| - await templateFile( |
330 |
| - templateDirRouter, |
331 |
| - './src/routes/__root.tsx.ejs', |
332 |
| - './src/routes/__root.tsx', |
333 |
| - { |
334 |
| - integrations, |
335 |
| - }, |
336 |
| - ) |
337 |
| - await templateFile( |
338 |
| - templateDirBase, |
339 |
| - './src/App.tsx.ejs', |
340 |
| - './src/routes/index.tsx', |
341 |
| - ) |
342 |
| - } else { |
343 |
| - await templateFile( |
344 |
| - templateDirBase, |
345 |
| - './src/App.tsx.ejs', |
346 |
| - options.typescript ? undefined : './src/App.jsx', |
347 |
| - ) |
348 |
| - // TODO: This is a bit of a hack to check if the framework is react |
349 |
| - if (options.framework.id === 'react-cra') { |
350 |
| - await templateFile( |
351 |
| - templateDirBase, |
352 |
| - './src/App.test.tsx.ejs', |
353 |
| - options.typescript ? undefined : './src/App.test.jsx', |
354 |
| - ) |
355 |
| - } |
356 |
| - } |
| 296 | + await templateFile(templateDirBase, './src/main.tsx.ejs', './src/main.tsx', { |
| 297 | + routes, |
| 298 | + integrations, |
| 299 | + }) |
| 300 | + |
| 301 | + await templateFile( |
| 302 | + templateDirBase, |
| 303 | + './src/routes/__root.tsx.ejs', |
| 304 | + './src/routes/__root.tsx', |
| 305 | + { |
| 306 | + integrations, |
| 307 | + }, |
| 308 | + ) |
357 | 309 |
|
358 |
| - if ( |
359 |
| - routes.length > 0 || |
360 |
| - options.chosenAddOns.length > 0 || |
361 |
| - integrations.length > 0 |
362 |
| - ) { |
363 |
| - await templateFile( |
364 |
| - templateDirBase, |
365 |
| - './src/components/Header.tsx.ejs', |
366 |
| - './src/components/Header.tsx', |
367 |
| - { |
368 |
| - integrations, |
369 |
| - }, |
370 |
| - ) |
| 310 | + if (options.framework.id === 'react-cra') { |
| 311 | + await templateFile(templateDirBase, './src/App.test.tsx.ejs') |
371 | 312 | }
|
| 313 | + await templateFile(templateDirBase, './src/App.tsx.ejs') |
| 314 | + await templateFile(templateDirBase, './src/routes/index.tsx.ejs') |
| 315 | + |
| 316 | + await templateFile( |
| 317 | + templateDirBase, |
| 318 | + './src/components/Header.tsx.ejs', |
| 319 | + './src/components/Header.tsx', |
| 320 | + { |
| 321 | + integrations, |
| 322 | + routes, |
| 323 | + }, |
| 324 | + ) |
372 | 325 |
|
373 | 326 | const warnings: Array<string> = []
|
374 | 327 | for (const addOn of options.chosenAddOns) {
|
@@ -398,10 +351,7 @@ export async function createApp(
|
398 | 351 |
|
399 | 352 | if (warnings.length > 0) {
|
400 | 353 | if (!silent) {
|
401 |
| - environment.warn( |
402 |
| - 'The following will be overwritten:', |
403 |
| - warnings.join('\n'), |
404 |
| - ) |
| 354 | + environment.warn('Warnings', warnings.join('\n')) |
405 | 355 | }
|
406 | 356 | }
|
407 | 357 |
|
|
0 commit comments