Repository: vitejs/vite
File: packages/create-vite/src/index.ts (TypeScript)

Code before:
  if (immediate === undefined) {
    // In test mode, default to false to avoid prompts
    if (process.env._VITE_TEST_CLI) {
      immediate = false
    } else {
      const immediateResult = await prompts.confirm({
        message: 'Install and start now?',
      })
      if (prompts.isCancel(immediateResult)) return cancel()
      immediate = immediateResult
    }
  }

  const pkgManager = pkgInfo ? pkgInfo.name : 'npm'
  let agent = argAgent
  if (immediate && !agent) {
    const agentResult = await prompts.select({
      message: 'Select a package manager:',
      options: [
        { label: 'npm', value: 'npm' },
        { label: 'yarn', value: 'yarn' },
        { label: 'pnpm', value: 'pnpm' },
        { label: 'bun', value: 'bun' },
      ],
      initialValue: pkgManager,
    })
    if (prompts.isCancel(agentResult)) return cancel()
    agent = agentResult
  }

  const root = path.join(cwd, targetDir)
  fs.mkdirSync(root, { recursive: true })

  // determine template
  let isReactSwc = false
  if (template.includes('-swc')) {
    isReactSwc = true
    template = template.replace('-swc', '')
  }

  const { customCommand } =
    FRAMEWORKS.flatMap((f) => f.variants).find((v) => v.name === template) ?? {}

  if (customCommand) {
    const fullCustomCommand = getFullCustomCommand(customCommand, pkgInfo)

    const [command, ...args] = fullCustomCommand.split(' ')
    // we replace TARGET_DIR here because targetDir may include a space
    const replacedArgs = args.map((arg) =>
      arg.replace('TARGET_DIR', () => targetDir),
    )

Review comment (suggestion):
Perhaps here there's an opportunity to combine as a single prompt for most cases. Could we ask in the first prompt something like this?

```
> Install with <detected-pm> and start now?
- Yes
- Select a different package manager
- No
```

Alternatively I'm also thinking we could skip the package manager prompt altogether and rely on the one used to execute `create-vite`. We already provided the [package manager-specific `create-vite` commands](https://vite.dev/guide/#scaffolding-your-first-vite-project), and worst case if they forgot to change they'd just have to manually execute the commands.

Code after:
          const command = variant.customCommand
            ? getFullCustomCommand(variant.customCommand, pkgInfo).replace(
                / TARGET_DIR$/,
                '',
              )
            : undefined
          return {
            label: variantColor(variant.display || variant.name),
            value: variant.name,
            hint: command,
          }
        }),
      })
      if (prompts.isCancel(variant)) return cancel()

      template = variant
    } else {
      template = 'vanilla-ts'
    }
  }

  const pkgManager = pkgInfo ? pkgInfo.name : 'npm'

  // 5. Ask about immediate install and package manager
  let immediate = argImmediate
  if (immediate === undefined) {
    if (interactive) {
      const immediateResult = await prompts.confirm({
        message: `Install with ${pkgManager} and start now?`,
      })
      if (prompts.isCancel(immediateResult)) return cancel()
      immediate = immediateResult
    } else {
      immediate = false
    }
  }

  const root = path.join(cwd, targetDir)
  fs.mkdirSync(root, { recursive: true })

  // determine template
  let isReactSwc = false
  if (template.includes('-swc')) {
    isReactSwc = true
    template = template.replace('-swc', '')
  }

  const { customCommand } =
    FRAMEWORKS.flatMap((f) => f.variants).find((v) => v.name === template) ?? {}

  if (customCommand) {