(
cliOptions: CliOptions,
forcedAddOns?: Array<string>,
opts?: {
disableNameCheck?: boolean
forcedDeployment?: string
},
)
| 398 | } |
| 399 | |
| 400 | export async function normalizeOptions( |
| 401 | cliOptions: CliOptions, |
| 402 | forcedAddOns?: Array<string>, |
| 403 | opts?: { |
| 404 | disableNameCheck?: boolean |
| 405 | forcedDeployment?: string |
| 406 | }, |
| 407 | ): Promise<Options | undefined> { |
| 408 | const projectLocation = resolveProjectLocation({ |
| 409 | projectName: cliOptions.projectName, |
| 410 | targetDir: cliOptions.targetDir, |
| 411 | }) |
| 412 | |
| 413 | if (!projectLocation && !opts?.disableNameCheck) { |
| 414 | return undefined |
| 415 | } |
| 416 | |
| 417 | const projectName = projectLocation?.projectName ?? '' |
| 418 | const targetDir = projectLocation?.targetDir ?? resolve(process.cwd()) |
| 419 | |
| 420 | if (projectName) { |
| 421 | const { valid, error } = validateProjectName(projectName) |
| 422 | if (!valid) { |
| 423 | console.error(error) |
| 424 | process.exit(1) |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | // Mode is always file-router (TanStack Start) |
| 429 | let mode = 'file-router' |
| 430 | let routerOnly = !!cliOptions.routerOnly |
| 431 | |
| 432 | const legacyTemplate = getLegacyTemplateValue(cliOptions.template) |
| 433 | |
| 434 | if (!cliOptions.starter) { |
| 435 | if (cliOptions.template && !legacyTemplate) { |
| 436 | cliOptions.starter = cliOptions.template |
| 437 | } else if (cliOptions.templateId) { |
| 438 | cliOptions.starter = cliOptions.templateId |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | const template = legacyTemplate |
| 443 | if (template && template !== 'file-router') { |
| 444 | routerOnly = true |
| 445 | } |
| 446 | |
| 447 | if (!cliOptions.starter && cliOptions.templateId) { |
| 448 | cliOptions.starter = cliOptions.templateId |
| 449 | } |
| 450 | |
| 451 | const preferredFramework = (cliOptions.framework || 'react').toLowerCase() |
| 452 | |
| 453 | const starter = !routerOnly && cliOptions.starter |
| 454 | ? await loadStarter( |
| 455 | await resolveStarterSpecifier(cliOptions.starter, preferredFramework), |
| 456 | ) |
| 457 | : undefined |
no test coverage detected