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

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

Merged
merged 2 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions packages/nuxi/src/commands/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { resolve } from 'pathe'
import { resolveModule } from '../utils/cjs'
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 (paths: string | string[]): Promise<string|null> {
Expand Down Expand Up @@ -66,8 +66,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}`)
}
Expand Down
10 changes: 10 additions & 0 deletions packages/nuxi/src/utils/nuxt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down