fix(nuxi): properly detect hash and tag for upgrade changelog (#6708)

This commit is contained in:
Harlan Wilton 2022-08-17 23:45:45 +10:00 committed by GitHub
parent e93f88c1e4
commit 99c960fb05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -4,7 +4,7 @@ import { resolve } from 'pathe'
import { readPackageJSON } from 'pkg-types'
import { getPackageManager, packageManagerLocks } from '../utils/packageManagers'
import { rmRecursive, touchFile } from '../utils/fs'
import { cleanupNuxtDirs } from '../utils/nuxt'
import { cleanupNuxtDirs, nuxtVersionToGitIdentifier } from '../utils/nuxt'
import { defineNuxtCommand } from './index'
async function getNuxtVersion (path: string): Promise<string|null> {
@ -64,8 +64,8 @@ export default defineNuxtCommand({
consola.success('You\'re already using the latest version of nuxt.')
} else {
consola.success('Successfully upgraded nuxt from', currentVersion, 'to', upgradedVersion)
const commitA = currentVersion.split('.').pop()
const commitB = upgradedVersion.split('.').pop()
const commitA = nuxtVersionToGitIdentifier(currentVersion)
const commitB = nuxtVersionToGitIdentifier(upgradedVersion)
if (commitA && commitB) {
consola.info('Changelog:', `https://github.com/nuxt/framework/compare/${commitA}...${commitB}`)
}

View File

@ -27,6 +27,16 @@ export async function cleanupNuxtDirs (rootDir: string) {
].map(dir => resolve(rootDir, dir)))
}
export function nuxtVersionToGitIdentifier (version: string) {
// match the git identifier in the release, for example: 3.0.0-rc.8-27677607.a3a8706
const id = /\.([0-9a-f]{7})$/.exec(version)
if (id?.[1]) {
return id[1]
}
// match github tag, for example 3.0.0-rc.8
return `v${version}`
}
export function resolveNuxtManifest (nuxt: Nuxt): NuxtProjectManifest {
const manifest: NuxtProjectManifest = {
_hash: null,