Skip to content

Commit

Permalink
feat(create-vite): support create-vite-extra (#10214)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy authored Oct 14, 2022
1 parent e793df3 commit 8116cbd
Showing 1 changed file with 18 additions and 4 deletions.
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

0 comments on commit 8116cbd

Please sign in to comment.