Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

Commit 99c960f

Browse files
authored
fix(nuxi): properly detect hash and tag for upgrade changelog (#6708)
1 parent e93f88c commit 99c960f

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

packages/nuxi/src/commands/upgrade.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { resolve } from 'pathe'
44
import { readPackageJSON } from 'pkg-types'
55
import { getPackageManager, packageManagerLocks } from '../utils/packageManagers'
66
import { rmRecursive, touchFile } from '../utils/fs'
7-
import { cleanupNuxtDirs } from '../utils/nuxt'
7+
import { cleanupNuxtDirs, nuxtVersionToGitIdentifier } from '../utils/nuxt'
88
import { defineNuxtCommand } from './index'
99

1010
async function getNuxtVersion (path: string): Promise<string|null> {
@@ -64,8 +64,8 @@ export default defineNuxtCommand({
6464
consola.success('You\'re already using the latest version of nuxt.')
6565
} else {
6666
consola.success('Successfully upgraded nuxt from', currentVersion, 'to', upgradedVersion)
67-
const commitA = currentVersion.split('.').pop()
68-
const commitB = upgradedVersion.split('.').pop()
67+
const commitA = nuxtVersionToGitIdentifier(currentVersion)
68+
const commitB = nuxtVersionToGitIdentifier(upgradedVersion)
6969
if (commitA && commitB) {
7070
consola.info('Changelog:', `https://github.com/nuxt/framework/compare/${commitA}...${commitB}`)
7171
}

packages/nuxi/src/utils/nuxt.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ export async function cleanupNuxtDirs (rootDir: string) {
2727
].map(dir => resolve(rootDir, dir)))
2828
}
2929

30+
export function nuxtVersionToGitIdentifier (version: string) {
31+
// match the git identifier in the release, for example: 3.0.0-rc.8-27677607.a3a8706
32+
const id = /\.([0-9a-f]{7})$/.exec(version)
33+
if (id?.[1]) {
34+
return id[1]
35+
}
36+
// match github tag, for example 3.0.0-rc.8
37+
return `v${version}`
38+
}
39+
3040
export function resolveNuxtManifest (nuxt: Nuxt): NuxtProjectManifest {
3141
const manifest: NuxtProjectManifest = {
3242
_hash: null,

0 commit comments

Comments
 (0)