@@ -10,6 +10,7 @@ import { generateProjectName } from '../../utils/project.js';
10
10
import { assertNotCanceled } from '../../utils/tasks.js' ;
11
11
import { updateWorkspaceVersions } from '../../utils/workspace-version.js' ;
12
12
import { setupEnterpriseConfig } from './enterprise.js' ;
13
+ import { generateHostingConfig } from './generate-hosting-config.js' ;
13
14
import { initGitRepo } from './git.js' ;
14
15
import { installAndStart } from './install-start.js' ;
15
16
import { DEFAULT_VALUES , type CreateOptions } from './options.js' ;
@@ -337,76 +338,3 @@ function verifyFlags(flags: CreateOptions) {
337
338
throw new Error ( 'Cannot start project without installing dependencies.' ) ;
338
339
}
339
340
}
340
-
341
- async function generateHostingConfig ( dest : string , providers : string [ ] ) {
342
- const resolvedDest = path . resolve ( dest ) ;
343
-
344
- if ( ! fs . existsSync ( resolvedDest ) ) {
345
- console . log ( `Directory does not exist. Creating directory: ${ resolvedDest } ` ) ;
346
- fs . mkdirSync ( resolvedDest , { recursive : true } ) ;
347
- } else {
348
- console . log ( `Directory already exists: ${ resolvedDest } ` ) ;
349
- }
350
-
351
- const templateDir = path . resolve ( __dirname , '_template' ) ;
352
- console . log ( 'Looking for template directory at:' , templateDir ) ;
353
-
354
- if ( ! fs . existsSync ( templateDir ) ) {
355
- console . error ( 'Template directory does not exist at:' , templateDir ) ;
356
- } else {
357
- console . log ( 'Template directory found at:' , templateDir ) ;
358
- }
359
-
360
- if ( providers . includes ( 'Vercel' ) ) {
361
- const vercelConfigPath = path . join ( resolvedDest , 'vercel.json' ) ;
362
- console . log ( 'Vercel config file will be written to:' , vercelConfigPath ) ;
363
- fs . writeFileSync (
364
- vercelConfigPath ,
365
- JSON . stringify (
366
- {
367
- headers : [ { source : '/(.*)' , headers : [ { key : 'Access-Control-Allow-Origin' , value : '*' } ] } ] ,
368
- } ,
369
- null ,
370
- 2 ,
371
- ) ,
372
- ) ;
373
- }
374
-
375
- if ( providers . includes ( 'Netlify' ) ) {
376
- const netlifyConfigPath = path . join ( resolvedDest , 'netlify.toml' ) ;
377
- console . log ( 'Netlify config file will be written to:' , netlifyConfigPath ) ;
378
- fs . writeFileSync (
379
- netlifyConfigPath ,
380
- `[build]
381
- publish = "build"
382
- command = "npm run build"
383
-
384
- [[headers]]
385
- for = "/*"
386
- [headers.values]
387
- Access-Control-Allow-Origin = "*"` ,
388
- ) ;
389
- }
390
-
391
- if ( providers . includes ( 'Cloudflare' ) ) {
392
- const cloudflareConfigPath = path . join ( resolvedDest , '_headers' ) ;
393
- console . log ( 'Cloudflare config file will be written to:' , cloudflareConfigPath ) ;
394
- fs . writeFileSync (
395
- cloudflareConfigPath ,
396
- `/*
397
- Access-Control-Allow-Origin: *` ,
398
- ) ;
399
- }
400
-
401
- if ( fs . existsSync ( templateDir ) ) {
402
- const gitignoreTemplatePath = path . join ( templateDir , '.gitignore' ) ;
403
-
404
- if ( fs . existsSync ( gitignoreTemplatePath ) ) {
405
- const gitignoreDestPath = path . join ( resolvedDest , '.gitignore' ) ;
406
- console . log ( 'Copying .gitignore to:' , gitignoreDestPath ) ;
407
- fs . copyFileSync ( gitignoreTemplatePath , gitignoreDestPath ) ;
408
- } else {
409
- console . warn ( 'No .gitignore file found in template directory, skipping copy.' ) ;
410
- }
411
- }
412
- }
0 commit comments