@@ -21,6 +21,12 @@ import generateReadme from './utils/generateReadme'
2121import getCommand from './utils/getCommand'
2222import getLanguage from './utils/getLanguage'
2323import { trimBoilerplate , removeCSSImport , emptyRouterConfig } from './utils/trimBoilerplate'
24+ import applyVueBeta from './utils/applyVueBeta'
25+ import {
26+ inferPackageManager ,
27+ getPackageManagerOptions ,
28+ type PackageManager ,
29+ } from './utils/packageManager'
2430
2531import cliPackageJson from './package.json' with { type : 'json' }
2632
@@ -45,6 +51,7 @@ const FEATURE_FLAGS = [
4551 'eslint-with-prettier' ,
4652 'oxlint' ,
4753 'vite-beta' ,
54+ 'vue-beta' ,
4855] as const
4956
5057const FEATURE_OPTIONS = [
@@ -90,6 +97,10 @@ const EXPERIMENTAL_FEATURE_OPTIONS = [
9097 value : 'vite-beta' ,
9198 label : language . needsViteBeta . message ,
9299 } ,
100+ {
101+ value : 'vue-beta' ,
102+ label : language . needsVueBeta . message ,
103+ } ,
93104] as const
94105
95106type PromptResult = {
@@ -100,6 +111,7 @@ type PromptResult = {
100111 e2eFramework ?: 'cypress' | 'nightwatch' | 'playwright'
101112 experimentFeatures ?: ( typeof EXPERIMENTAL_FEATURE_OPTIONS ) [ number ] [ 'value' ] [ ]
102113 needsBareboneTemplates ? : boolean
114+ packageManager ? : PackageManager
103115}
104116
105117function isValidPackageName ( projectName ) {
@@ -199,6 +211,8 @@ Available feature flags:
199211 Add Oxfmt for code formatting.
200212 --vite-beta
201213 Use Vite 8 Beta instead of Vite for building the project.
214+ --vue-beta
215+ Use Vue 3.6 Beta. Requires specifying a package manager in interactive mode.
202216
203217Unstable feature flags:
204218 --tests, --with-tests
@@ -250,6 +264,9 @@ async function init() {
250264
251265 const forceOverwrite = argv . force
252266
267+ // Infer package manager from user agent early so we can use it in prompts
268+ const inferredPackageManager = inferPackageManager ( )
269+
253270 const result : PromptResult = {
254271 projectName : defaultProjectName ,
255272 shouldOverwrite : forceOverwrite ,
@@ -359,6 +376,21 @@ async function init() {
359376 required : false ,
360377 } ) ,
361378 )
379+
380+ // Ask for package manager if Vue 3.6 beta is selected (needed for correct overrides)
381+ if ( result . experimentFeatures . includes ( 'vue-beta' ) ) {
382+ const packageManagerOptions = getPackageManagerOptions ( inferredPackageManager ) . map ( ( pm ) => ( {
383+ value : pm ,
384+ label : pm ,
385+ } ) )
386+
387+ result . packageManager = await unwrapPrompt (
388+ select ( {
389+ message : `${ language . packageManagerSelection . message } ${ dim ( language . packageManagerSelection . hint ) } ` ,
390+ options : packageManagerOptions ,
391+ } ) ,
392+ )
393+ }
362394 }
363395
364396 if ( argv . bare ) {
@@ -386,6 +418,7 @@ async function init() {
386418 const needsOxfmt = experimentFeatures . includes ( 'oxfmt' ) || argv [ 'oxfmt' ]
387419 const needsViteBeta =
388420 experimentFeatures . includes ( 'vite-beta' ) || argv [ 'vite-beta' ] || argv [ 'rolldown-vite' ] // keep `rolldown-vite` for backward compatibility
421+ const needsVueBeta = experimentFeatures . includes ( 'vue-beta' ) || argv [ 'vue-beta' ]
389422
390423 const { e2eFramework } = result
391424 const needsCypress = argv . cypress || argv . tests || e2eFramework === 'cypress'
@@ -677,16 +710,16 @@ async function init() {
677710 }
678711 }
679712
680- // Instructions:
681- // Supported package managers: pnpm > yarn > bun > npm
682- const userAgent = process . env . npm_config_user_agent ?? ''
683- const packageManager = / p n p m / . test ( userAgent )
684- ? 'pnpm'
685- : / y a r n / . test ( userAgent )
686- ? 'yarn'
687- : / b u n / . test ( userAgent )
688- ? 'bun'
689- : 'npm'
713+ // Use the package manager selected by user for Vue 3.6 beta, or inferred from user agent
714+ const packageManager = result . packageManager ?? inferredPackageManager
715+
716+ // Apply Vue 3.6 Beta overrides if the feature is enabled
717+ if ( needsVueBeta ) {
718+ const pkgPath = path . resolve ( root , 'package.json' )
719+ const pkg = JSON . parse ( fs . readFileSync ( pkgPath , 'utf-8' ) )
720+ applyVueBeta ( root , packageManager , pkg )
721+ fs . writeFileSync ( pkgPath , JSON . stringify ( pkg , null , 2 ) + '\n' )
722+ }
690723
691724 // README generation
692725 fs . writeFileSync (
0 commit comments