From 4188f8d3a2323873ef760aa2fe5b7b5faca22959 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Tue, 2 Jul 2024 18:11:37 +0200 Subject: [PATCH] fix: use `ofetch` for `fast-npm-meta` --- packages/devtools/src/npm/index.ts | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/packages/devtools/src/npm/index.ts b/packages/devtools/src/npm/index.ts index 0c3975a36c..052332de7b 100644 --- a/packages/devtools/src/npm/index.ts +++ b/packages/devtools/src/npm/index.ts @@ -2,6 +2,7 @@ import { createRequire } from 'node:module' import { logger, useNuxt } from '@nuxt/kit' import { readPackageJSON } from 'pkg-types' import semver from 'semver' +import { fetch } from 'ofetch' import { getPackageInfo } from 'local-pkg' import type { PackageUpdateInfo } from '../types' @@ -9,28 +10,6 @@ export async function getMainPackageJSON(nuxt = useNuxt()) { return readPackageJSON(nuxt.options.rootDir) } -export interface Packument { - 'name': string - /** - * An object where each key is a version, and each value is the manifest for - * that version. - */ - 'versions': Record> - /** - * An object mapping dist-tags to version numbers. This is how `foo@latest` - * gets turned into `foo@1.2.3`. - */ - 'dist-tags': { latest: string } & Record - /** - * In the full packument, an object mapping version numbers to publication - * times, for the `opts.before` functionality. - */ - 'time': Record & { - created: string - modified: string - } -} - export async function checkForUpdateOf(name: string, current?: string, nuxt = useNuxt()): Promise { try { if (!current) { @@ -45,7 +24,9 @@ export async function checkForUpdateOf(name: string, current?: string, nuxt = us return const { getLatestVersion } = await import('fast-npm-meta') - const { version: latest } = await getLatestVersion(name) + const { version: latest } = await getLatestVersion(name, { + fetch, + }) const needsUpdate = !!latest && latest !== current && semver.lt(current, latest)