Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion .github/MAINTENANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ Anyone with write access to the main branch of both this repository and [create-

To do so, follow these steps:

1. Run `pnpm release <patch|minor|major|x.y.z>` locally and follow the prompts. The release script will bump the version number, create the release commit / tag, and push the changes to the repository.
1. Run `pnpm release` locally. The script keeps the current major and uses the UTC date for the minor version. The first release on November 11, 2026 would be `3.20261111.0`, and a second release that day would be `3.20261111.1`. The script commits the release and pushes the same version tag to both repositories. To set an exact version, run `pnpm release <version>`.
2. The release will be automatically published to npm by GitHub Actions once approved by an _administrator_.
3. Go to <https://github.com/vuejs/create-vue/releases/new> and create a new release with the tag that was just created. Describe the notable changes in the release notes.
30 changes: 30 additions & 0 deletions __test__/releaseVersion.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { describe, expect, it } from 'vite-plus/test'
import { nextReleaseVersion } from '../scripts/release-version.mjs'

describe('nextReleaseVersion', () => {
const now = new Date('2026-11-12T08:59:59+09:00')

it('uses the UTC date when migrating from the previous version scheme', () => {
expect(nextReleaseVersion('3.24.0', now)).toBe('3.20261111.0')
})

it('increments the revision for another release on the same UTC day', () => {
expect(nextReleaseVersion('3.20261111.9', now)).toBe('3.20261111.10')
})

it('resets the revision at midnight UTC and keeps the major', () => {
const midnight = new Date('2026-11-12T09:00:00+09:00')
expect(nextReleaseVersion('4.20261111.2', midnight)).toBe('4.20261112.0')
})

it.each(['3.20261111.0-beta.1', '3.20261111.0--canary'])(
'promotes %s to its stable version on the same date',
(prerelease) => {
expect(nextReleaseVersion(prerelease, now)).toBe('3.20261111.0')
},
)

it('rejects a UTC date earlier than the current release', () => {
expect(() => nextReleaseVersion('3.20261112.0', now)).toThrow(/ahead of the UTC release date/)
})
})
107 changes: 64 additions & 43 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
} from './utils/directoryTraverse'
import generateReadme from './utils/generateReadme'
import getCommand from './utils/getCommand'
import getLanguage from './utils/getLanguage'
import { detectLocale, loadMessages } from './utils/locale'
import { trimBoilerplate, removeCSSImport, emptyRouterConfig } from './utils/trimBoilerplate'
import applyOverrides from './utils/applyOverrides'
import {
Expand All @@ -42,7 +42,9 @@ import { resolveNeedsTypeScript } from './utils/resolveFeatures'

import cliPackageJson from './package.json' with { type: 'json' }

const language = await getLanguage(fileURLToPath(new URL('./locales', import.meta.url)))
const versionInfo = `${cliPackageJson.name} v${cliPackageJson.version}`
const locale = detectLocale()
const messages = await loadMessages(fileURLToPath(new URL('./locales', import.meta.url)), locale)

const FEATURE_FLAGS = [
'default',
Expand Down Expand Up @@ -71,45 +73,45 @@ const FEATURE_FLAGS = [
const FEATURE_OPTIONS = [
{
value: 'jsx',
label: language.needsJsx.message,
label: messages.needsJsx.message,
},
{
value: 'router',
label: language.needsRouter.message,
label: messages.needsRouter.message,
},
{
value: 'pinia',
label: language.needsPinia.message,
label: messages.needsPinia.message,
},
{
value: 'vitest',
label: language.needsVitest.message,
label: messages.needsVitest.message,
},
{
value: 'e2e',
label: language.needsE2eTesting.message,
label: messages.needsE2eTesting.message,
},
{
value: 'eslint',
label: language.needsEslint.message,
label: messages.needsEslint.message,
},
{
value: 'prettier',
label: language.needsPrettier.message,
label: messages.needsPrettier.message,
},
] as const
const EXPERIMENTAL_FEATURE_OPTIONS = [
{
value: 'oxfmt',
label: language.needsOxfmt.message,
label: messages.needsOxfmt.message,
},
{
value: 'vue-rc',
label: language.needsVueRc.message,
label: messages.needsVueRc.message,
},
{
value: 'tsgo',
label: language.needsTsgo.message,
label: messages.needsTsgo.message,
},
] as const

Expand Down Expand Up @@ -171,7 +173,7 @@ async function unwrapPrompt<T>(maybeCancelPromise: Promise<T | typeof CANCEL_SYM
const result = await maybeCancelPromise

if (isCancel(result)) {
cancel(red('✖') + ` ${language.errors.operationCancelled}`)
cancel(red('✖') + ` ${messages.errors.operationCancelled}`)
process.exit(0)
}

Expand Down Expand Up @@ -236,6 +238,27 @@ Deprecated feature flags:
Oxlint is now always included when ESLint is selected.
`

function formatReleaseInfo() {
const match = /^\d+\.(\d{4})(\d{2})(\d{2})\./.exec(cliPackageJson.version)
if (!match) return versionInfo

const [, year, month, day] = match
const date = new Date(`${year}-${month}-${day}`)
// Explicit versions can have an eight-digit minor that isn't a calendar date.
if (date.getUTCDate() !== Number(day)) return versionInfo

try {
const formattedDate = new Intl.DateTimeFormat(locale, {
dateStyle: 'medium',
timeZone: 'UTC',
}).format(date)
return messages.infos.released.replace('{date}', `${formattedDate} (UTC)`)
} catch {
// Some runtimes ship without locale-aware date formatting.
return versionInfo
}
}

async function init() {
const cwd = process.cwd()
const args = process.argv.slice(2)
Expand All @@ -260,7 +283,7 @@ async function init() {
}

if (argv.version) {
console.log(`${cliPackageJson.name} v${cliPackageJson.version}`)
console.log(versionInfo)
process.exit(0)
}

Expand Down Expand Up @@ -292,16 +315,16 @@ async function init() {
? banners.gradientBanner
: banners.defaultBanner,
)
log.message(dim(`${cliPackageJson.name} v${cliPackageJson.version}`), { spacing: 0 })
log.message(dim(formatReleaseInfo()), { spacing: 0 })

if (!targetDir) {
const _result = await unwrapPrompt(
text({
message: language.projectName.message,
message: messages.projectName.message,
placeholder: defaultProjectName,
defaultValue: defaultProjectName,
validate: (value) =>
!value || value.trim().length > 0 ? undefined : language.projectName.invalidMessage,
!value || value.trim().length > 0 ? undefined : messages.projectName.invalidMessage,
}),
)
const projectName = _result?.trim() || defaultProjectName
Expand All @@ -313,19 +336,19 @@ async function init() {
select({
message: `${
targetDir === '.'
? language.shouldOverwrite.dirForPrompts.current
: `${language.shouldOverwrite.dirForPrompts.target} "${targetDir}"`
} ${language.shouldOverwrite.message}`,
? messages.shouldOverwrite.dirForPrompts.current
: `${messages.shouldOverwrite.dirForPrompts.target} "${targetDir}"`
} ${messages.shouldOverwrite.message}`,
options: [
{ value: 'remove', label: language.shouldOverwrite.selectOptions!.remove.title },
{ value: 'cancel', label: language.shouldOverwrite.selectOptions!.cancel.title },
{ value: 'ignore', label: language.shouldOverwrite.selectOptions!.ignore.title },
{ value: 'remove', label: messages.shouldOverwrite.selectOptions!.remove.title },
{ value: 'cancel', label: messages.shouldOverwrite.selectOptions!.cancel.title },
{ value: 'ignore', label: messages.shouldOverwrite.selectOptions!.ignore.title },
],
}),
)

if (overwrite === 'cancel') {
cancel(red('✖') + ` ${language.errors.operationCancelled}`)
cancel(red('✖') + ` ${messages.errors.operationCancelled}`)
process.exit(0)
}

Expand All @@ -336,10 +359,10 @@ async function init() {
if (!isValidPackageName(defaultPackageName)) {
result.packageName = await unwrapPrompt(
text({
message: language.packageName.message,
message: messages.packageName.message,
initialValue: toValidPackageName(defaultPackageName),
validate: (value) =>
isValidPackageName(value) ? undefined : language.packageName.invalidMessage,
isValidPackageName(value) ? undefined : messages.packageName.invalidMessage,
}),
)
} else {
Expand All @@ -349,15 +372,14 @@ async function init() {
if (!isFeatureFlagsUsed) {
result.needsTypeScript = await unwrapPrompt(
confirm({
message: language.needsTypeScript.message,
message: messages.needsTypeScript.message,
initialValue: true,
}),
)

result.features = await unwrapPrompt(
multiselect({
message: `${language.featureSelection.message} ${dim(language.featureSelection.hint)}`,
// @ts-expect-error @clack/prompt's type doesn't support readonly array yet
message: `${messages.featureSelection.message} ${dim(messages.featureSelection.hint)}`,
options: FEATURE_OPTIONS,
required: false,
}),
Expand All @@ -367,19 +389,19 @@ async function init() {
const hasVitest = result.features.includes('vitest')
result.e2eFramework = await unwrapPrompt(
select({
message: `${language.e2eSelection.message} ${dim(language.e2eSelection.hint)}`,
message: `${messages.e2eSelection.message} ${dim(messages.e2eSelection.hint)}`,
options: [
{
value: 'playwright',
label: language.e2eSelection.selectOptions.playwright.title,
hint: language.e2eSelection.selectOptions.playwright.desc,
label: messages.e2eSelection.selectOptions.playwright.title,
hint: messages.e2eSelection.selectOptions.playwright.desc,
},
{
value: 'cypress',
label: language.e2eSelection.selectOptions.cypress.title,
label: messages.e2eSelection.selectOptions.cypress.title,
hint: hasVitest
? language.e2eSelection.selectOptions.cypress.desc
: language.e2eSelection.selectOptions.cypress.hintOnComponentTesting!,
? messages.e2eSelection.selectOptions.cypress.desc
: messages.e2eSelection.selectOptions.cypress.hintOnComponentTesting!,
},
],
}),
Expand All @@ -391,8 +413,7 @@ async function init() {
: EXPERIMENTAL_FEATURE_OPTIONS.filter(({ value }) => value !== 'tsgo')
result.experimentFeatures = await unwrapPrompt(
multiselect({
message: `${language.needsExperimentalFeatures.message} ${dim(language.needsExperimentalFeatures.hint)}`,
// @ts-expect-error @clack/prompt's type doesn't support readonly array yet
message: `${messages.needsExperimentalFeatures.message} ${dim(messages.needsExperimentalFeatures.hint)}`,
options: experimentalFeatureOptions,
required: false,
}),
Expand All @@ -410,7 +431,7 @@ async function init() {

result.packageManager = await unwrapPrompt(
select({
message: `${language.packageManagerSelection.message} ${dim(language.packageManagerSelection.hint)}`,
message: `${messages.packageManagerSelection.message} ${dim(messages.packageManagerSelection.hint)}`,
options: packageManagerOptions,
}),
)
Expand All @@ -422,7 +443,7 @@ async function init() {
} else if (!isFeatureFlagsUsed) {
result.needsBareboneTemplates = await unwrapPrompt(
confirm({
message: language.needsBareboneTemplates.message,
message: messages.needsBareboneTemplates.message,
// TODO: default to true sometime in the future
initialValue: false,
}),
Expand Down Expand Up @@ -458,7 +479,7 @@ async function init() {
fs.mkdirSync(root)
}

console.log(`\n${language.infos.scaffolding} ${root}...`)
console.log(`\n${messages.infos.scaffolding} ${root}...`)

const pkg = { name: result.packageName, version: '0.0.0' }
fs.writeFileSync(path.resolve(root, 'package.json'), JSON.stringify(pkg, null, 2))
Expand Down Expand Up @@ -728,7 +749,7 @@ async function init() {
}),
)

let outroMessage = `${language.infos.done}\n\n`
let outroMessage = `${messages.infos.done}\n\n`
if (root !== cwd) {
const cdProjectName = path.relative(cwd, root)
outroMessage += ` ${bold(green(`cd ${cdProjectName.includes(' ') ? `"${cdProjectName}"` : cdProjectName}`))}\n`
Expand All @@ -741,13 +762,13 @@ async function init() {

if (needsTsgo && packageManager === 'nub') {
outroMessage += `
${dim('|')} ${language.warnings.tsgoNubReleaseAge}
${dim('|')} ${messages.warnings.tsgoNubReleaseAge}
`
}

if (!dotGitDirectoryState.hasDotGitDirectory) {
outroMessage += `
${dim('|')} ${language.infos.optionalGitCommand}
${dim('|')} ${messages.infos.optionalGitCommand}

${bold(green('git init && git add -A && git commit -m "initial commit"'))}`
}
Expand Down
1 change: 1 addition & 0 deletions locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"inactive": "No"
},
"infos": {
"released": "Released {date}",
"scaffolding": "Scaffolding project in",
"done": "Done. Now run:",
"optionalGitCommand": "Optional: Initialize Git in your project directory with:"
Expand Down
1 change: 1 addition & 0 deletions locales/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"inactive": "Non"
},
"infos": {
"released": "Publié le {date}",
"scaffolding": "Génération du projet dans",
"done": "Terminé. Exécutez maintenant\u00a0:",
"optionalGitCommand": "Optionnel\u00a0: Initialisez Git dans votre répertoire de projet avec\u00a0:"
Expand Down
1 change: 1 addition & 0 deletions locales/tr-TR.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"inactive": "Hayır"
},
"infos": {
"released": "Yayın tarihi: {date}",
"scaffolding": "İskele projesi",
"done": "Tamamlandı. Şimdi bunu çalıştır:",
"optionalGitCommand": "İsteğe bağlı: Proje dizininizde Git'i şununla başlatın:"
Expand Down
1 change: 1 addition & 0 deletions locales/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"inactive": "否"
},
"infos": {
"released": "发布于 {date}",
"scaffolding": "正在初始化项目",
"done": "项目初始化完成,可执行以下命令:",
"optionalGitCommand": "可选:使用以下命令在项目目录中初始化 Git:"
Expand Down
1 change: 1 addition & 0 deletions locales/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"inactive": "否"
},
"infos": {
"released": "發布於 {date}",
"scaffolding": "正在建置專案",
"done": "專案建置完成,可執行以下命令:",
"optionalGitCommand": "可選:使用以下命令在專案目錄中初始化 Git:"
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"picocolors": "^1.1.1",
"rolldown": "1.3.1",
"rollup-plugin-license": "^3.7.2",
"semver": "^7.8.6",
"vite-plus": "catalog:",
"zx": "^8.8.5"
},
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading