Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(create-vite): support create-vite-extra #10214

Merged
merged 4 commits into from
Oct 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions packages/create-vite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ const FRAMEWORKS: Framework[] = [
},
{
name: 'custom-create-vue',
display: 'Customize with create-vue',
display: 'Customize with create-vue',
color: green,
customCommand: 'npm create vue@latest TARGET_DIR'
},
{
name: 'custom-nuxt',
display: 'Nuxt',
display: 'Nuxt',
color: lightGreen,
customCommand: 'npm exec nuxi init TARGET_DIR'
}
Expand Down Expand Up @@ -153,11 +153,24 @@ const FRAMEWORKS: Framework[] = [
},
{
name: 'custom-svelte-kit',
display: 'SvelteKit',
display: 'SvelteKit',
color: red,
customCommand: 'npm create svelte@latest TARGET_DIR'
}
]
},
{
name: 'others',
display: 'Others',
color: reset,
variants: [
{
name: 'create-vite-extra',
display: 'create-vite-extra ↗',
color: reset,
customCommand: 'npm create vite-extra@latest TARGET_DIR'
}
]
}
]

Expand Down Expand Up @@ -279,14 +292,15 @@ async function init() {
}

// determine template
const template: string = variant || framework || argTemplate
const template: string = variant || framework?.name || argTemplate

const pkgInfo = pkgFromUserAgent(process.env.npm_config_user_agent)
const pkgManager = pkgInfo ? pkgInfo.name : 'npm'
const isYarn1 = pkgManager === 'yarn' && pkgInfo?.version.startsWith('1.')

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

if (customCommand) {
const fullCustomCommand = customCommand
.replace('TARGET_DIR', targetDir)
Expand Down