Skip to content

Commit 4188f8d

Browse files
committedJul 2, 2024··
fix: use ofetch for fast-npm-meta
1 parent 418a22e commit 4188f8d

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed
 

‎packages/devtools/src/npm/index.ts

+4-23
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,14 @@ import { createRequire } from 'node:module'
22
import { logger, useNuxt } from '@nuxt/kit'
33
import { readPackageJSON } from 'pkg-types'
44
import semver from 'semver'
5+
import { fetch } from 'ofetch'
56
import { getPackageInfo } from 'local-pkg'
67
import type { PackageUpdateInfo } from '../types'
78

89
export async function getMainPackageJSON(nuxt = useNuxt()) {
910
return readPackageJSON(nuxt.options.rootDir)
1011
}
1112

12-
export interface Packument {
13-
'name': string
14-
/**
15-
* An object where each key is a version, and each value is the manifest for
16-
* that version.
17-
*/
18-
'versions': Record<string, Omit<Packument, 'versions'>>
19-
/**
20-
* An object mapping dist-tags to version numbers. This is how `foo@latest`
21-
* gets turned into `foo@1.2.3`.
22-
*/
23-
'dist-tags': { latest: string } & Record<string, string>
24-
/**
25-
* In the full packument, an object mapping version numbers to publication
26-
* times, for the `opts.before` functionality.
27-
*/
28-
'time': Record<string, string> & {
29-
created: string
30-
modified: string
31-
}
32-
}
33-
3413
export async function checkForUpdateOf(name: string, current?: string, nuxt = useNuxt()): Promise<PackageUpdateInfo | undefined> {
3514
try {
3615
if (!current) {
@@ -45,7 +24,9 @@ export async function checkForUpdateOf(name: string, current?: string, nuxt = us
4524
return
4625

4726
const { getLatestVersion } = await import('fast-npm-meta')
48-
const { version: latest } = await getLatestVersion(name)
27+
const { version: latest } = await getLatestVersion(name, {
28+
fetch,
29+
})
4930

5031
const needsUpdate = !!latest && latest !== current && semver.lt(current, latest)
5132

0 commit comments

Comments
 (0)
Please sign in to comment.