@@ -2,35 +2,14 @@ import { createRequire } from 'node:module'
2
2
import { logger , useNuxt } from '@nuxt/kit'
3
3
import { readPackageJSON } from 'pkg-types'
4
4
import semver from 'semver'
5
+ import { fetch } from 'ofetch'
5
6
import { getPackageInfo } from 'local-pkg'
6
7
import type { PackageUpdateInfo } from '../types'
7
8
8
9
export async function getMainPackageJSON ( nuxt = useNuxt ( ) ) {
9
10
return readPackageJSON ( nuxt . options . rootDir )
10
11
}
11
12
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
-
34
13
export async function checkForUpdateOf ( name : string , current ?: string , nuxt = useNuxt ( ) ) : Promise < PackageUpdateInfo | undefined > {
35
14
try {
36
15
if ( ! current ) {
@@ -45,7 +24,9 @@ export async function checkForUpdateOf(name: string, current?: string, nuxt = us
45
24
return
46
25
47
26
const { getLatestVersion } = await import ( 'fast-npm-meta' )
48
- const { version : latest } = await getLatestVersion ( name )
27
+ const { version : latest } = await getLatestVersion ( name , {
28
+ fetch,
29
+ } )
49
30
50
31
const needsUpdate = ! ! latest && latest !== current && semver . lt ( current , latest )
51
32
0 commit comments