Skip to content

Commit 756dbbb

Browse files
committed
feat(vuetify): add version selection for Vuetify 3 and 4
Add support for selecting Vuetify version (3.x or 4.x beta) during project creation. This includes: - New prompt in CLI and VSCode extension - Updated i18n strings for English and Russian locales - Version-specific dependency resolution in scaffold function - Propagation of version selection through the create pipeline Allows users to opt into the Vuetify 4 beta while maintaining 3.x as the default.
1 parent 32cb9f8 commit 756dbbb

6 files changed

Lines changed: 60 additions & 0 deletions

File tree

packages/shared/src/functions/create.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ export async function createVuetify (options: CreateVuetifyOptions, commandOptio
156156
name: context.name,
157157
platform: context.platform as 'vue' | 'nuxt',
158158
type: context.type as 'vuetify' | 'vuetify0',
159+
vuetifyVersion: context.vuetifyVersion,
159160
features: context.features,
160161
typescript: !!context.typescript,
161162
packageManager: context.packageManager,

packages/shared/src/functions/scaffold.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface ScaffoldOptions {
1212
name: string
1313
platform: 'vue' | 'nuxt'
1414
type: 'vuetify' | 'vuetify0'
15+
vuetifyVersion?: '3.x' | '4.x'
1516
features: string[]
1617
typescript: boolean
1718
packageManager?: string
@@ -41,6 +42,7 @@ export async function scaffold (options: ScaffoldOptions, callbacks: ScaffoldCal
4142
features,
4243
typescript,
4344
type,
45+
vuetifyVersion,
4446
packageManager,
4547
install,
4648
force,
@@ -105,6 +107,10 @@ export async function scaffold (options: ScaffoldOptions, callbacks: ScaffoldCal
105107
let pkg
106108
pkg = await readPackageJSON(join(projectRoot, 'package.json'))
107109

110+
if (vuetifyVersion === '4.x' && pkg.dependencies && pkg.dependencies.vuetify) {
111+
pkg.dependencies.vuetify = '^4.0.0-beta.1'
112+
}
113+
108114
callbacks.onConfigStart?.()
109115
if (features && features.length > 0) {
110116
await applyFeatures(projectRoot, features, pkg, !!typescript, platform === 'nuxt', clientHints, type)

packages/shared/src/i18n/locales/en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@
128128
"hint": "Headless Component Library"
129129
}
130130
},
131+
"vuetify_version": {
132+
"select": "Select Vuetify version:",
133+
"3_x": "Vuetify 3 (latest)",
134+
"4_x": "Vuetify 4 (beta)"
135+
},
131136
"css_framework": {
132137
"select": "Which CSS framework?",
133138
"unocss": {

packages/shared/src/i18n/locales/ru.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@
123123
"hint": "Библиотека headless компонентов"
124124
}
125125
},
126+
"vuetify_version": {
127+
"select": "Выберите версию Vuetify:",
128+
"3_x": "Vuetify 3 (стабильная)",
129+
"4_x": "Vuetify 4 (бета)"
130+
},
126131
"css_framework": {
127132
"select": "Какой фреймворк CSS вы хотите использовать?",
128133
"none": "Никакой",

packages/shared/src/prompts.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface ProjectOptions {
2121
interactive?: boolean
2222
css?: 'unocss' | 'tailwindcss' | 'none'
2323
router?: 'router' | 'file-router' | 'none'
24+
vuetifyVersion?: '3.x' | '4.x'
2425
}
2526

2627
export async function prompt (args: Partial<ProjectOptions>, cwd = process.cwd()): Promise<ProjectOptions> {
@@ -98,6 +99,29 @@ export async function prompt (args: Partial<ProjectOptions>, cwd = process.cwd()
9899
],
99100
})
100101
},
102+
vuetifyVersion: ({ results }) => {
103+
const type = (results.type as string) || args.type
104+
if (type !== 'vuetify') {
105+
return Promise.resolve(undefined)
106+
}
107+
108+
if (args.vuetifyVersion) {
109+
return Promise.resolve(args.vuetifyVersion)
110+
}
111+
112+
if (!args.interactive) {
113+
return Promise.resolve('3.x')
114+
}
115+
116+
return select({
117+
message: i18n.t('prompts.vuetify_version.select'),
118+
initialValue: '3.x',
119+
options: [
120+
{ label: i18n.t('prompts.vuetify_version.3_x'), value: '3.x' },
121+
{ label: i18n.t('prompts.vuetify_version.4_x'), value: '4.x' },
122+
],
123+
})
124+
},
101125
cssFramework: ({ results }) => {
102126
const type = (results.type as string) || args.type
103127
if (type !== 'vuetify0') {

packages/vscode/src/commands/create.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export async function createProject () {
7373
? {
7474
platform: preset.platform || 'vue',
7575
type: preset.type || 'vuetify',
76+
vuetifyVersion: preset.vuetifyVersion,
7677
features: preset.features || [],
7778
typescript: preset.typescript ?? true,
7879
packageManager: preset.packageManager || 'npm',
@@ -135,6 +136,7 @@ export async function createProject () {
135136
interface ProjectConfig {
136137
platform: 'vue' | 'nuxt'
137138
type: 'vuetify' | 'vuetify0'
139+
vuetifyVersion?: '3.x' | '4.x'
138140
features: string[]
139141
typescript: boolean
140142
packageManager: string
@@ -228,6 +230,22 @@ async function collectManualOptions (): Promise<ProjectConfig | undefined> {
228230
}
229231
const type = templateItem.value
230232

233+
// Select Vuetify Version
234+
let vuetifyVersion: '3.x' | '4.x' | undefined
235+
if (type === 'vuetify') {
236+
const versionItem = await window.showQuickPick<StringItem>(
237+
[
238+
{ label: 'Vuetify 3 (Latest)', value: '3.x', picked: true },
239+
{ label: 'Vuetify 4 (Beta)', value: '4.x' },
240+
],
241+
{ placeHolder: 'Select Vuetify Version' },
242+
)
243+
if (!versionItem) {
244+
return
245+
}
246+
vuetifyVersion = versionItem.value as '3.x' | '4.x'
247+
}
248+
231249
// CSS Framework (only for Vuetify 0)
232250
let cssFramework = 'none'
233251
if (type === 'vuetify0') {
@@ -361,6 +379,7 @@ async function collectManualOptions (): Promise<ProjectConfig | undefined> {
361379
return {
362380
platform,
363381
type,
382+
vuetifyVersion,
364383
features,
365384
typescript,
366385
packageManager,

0 commit comments

Comments
 (0)