chore(deps): update dependency pkg-types to v2 (3.x) (#31123)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Daniel Roe <daniel@roe.dev>
This commit is contained in:
renovate[bot] 2025-03-01 21:13:08 +00:00 committed by GitHub
parent ee040eea3d
commit eefe781506
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 62 additions and 35 deletions

View File

@ -41,7 +41,7 @@
"mlly": "^1.7.4",
"ohash": "^2.0.7",
"pathe": "^2.0.3",
"pkg-types": "^1.3.1",
"pkg-types": "^2.0.1",
"scule": "^1.3.0",
"semver": "^7.7.1",
"std-env": "^3.8.0",

View File

@ -64,12 +64,17 @@ export async function checkNuxtCompatibility (constraints: NuxtCompatibility, nu
message: `Not compatible with \`${nuxt.options.builder}\`.`,
})
} else {
const builderVersion = await readPackageJSON(nuxt.options.builder, { url: nuxt.options.modulesDir }).then(r => r.version).catch(() => undefined)
if (builderVersion && !satisfies(normalizeSemanticVersion(builderVersion), constraint, { includePrerelease: true })) {
issues.push({
name: 'builder',
message: `Not compatible with \`${builderVersion}\` of \`${currentBuilder}\`. This module requires \`${constraint}\`.`,
})
for (const parent of [nuxt.options.rootDir, nuxt.options.workspaceDir, import.meta.url]) {
const builderVersion = await readPackageJSON(nuxt.options.builder, { parent }).then(r => r.version).catch(() => undefined)
if (builderVersion) {
if (!satisfies(normalizeSemanticVersion(builderVersion), constraint, { includePrerelease: true })) {
issues.push({
name: 'builder',
message: `Not compatible with \`${builderVersion}\` of \`${currentBuilder}\`. This module requires \`${constraint}\`.`,
})
}
break
}
}
}
}

View File

@ -201,9 +201,21 @@ export async function _generateTypes (nuxt: Nuxt) {
}
const isV4 = nuxt.options.future?.compatibilityVersion === 4
const hasTypescriptVersionWithModulePreserve = await readPackageJSON('typescript', { url: nuxt.options.modulesDir })
.then(r => r?.version && gte(r.version, '5.4.0'))
.catch(() => isV4)
const nestedModulesDirs: string[] = []
for (const dir of [...nuxt.options.modulesDir].sort()) {
const withSlash = withTrailingSlash(dir)
if (nestedModulesDirs.every(d => !d.startsWith(withSlash))) {
nestedModulesDirs.push(withSlash)
}
}
let hasTypescriptVersionWithModulePreserve
for (const parent of nestedModulesDirs) {
hasTypescriptVersionWithModulePreserve ??= await readPackageJSON('typescript', { parent })
.then(r => r?.version && gte(r.version, '5.4.0'))
.catch(() => undefined)
}
hasTypescriptVersionWithModulePreserve ??= isV4
const useDecorators = Boolean(nuxt.options.experimental?.decorators)
@ -311,8 +323,15 @@ export async function _generateTypes (nuxt: Nuxt) {
await Promise.all([...nuxt.options.modules, ...nuxt.options._modules].map(async (id) => {
if (typeof id !== 'string') { return }
const pkg = await readPackageJSON(id, { url: nuxt.options.modulesDir }).catch(() => null)
references.push(({ types: pkg?.name || id }))
for (const parent of nestedModulesDirs) {
const pkg = await readPackageJSON(id, { parent }).catch(() => null)
if (pkg) {
references.push(({ types: pkg.name ?? id }))
return
}
}
references.push(({ types: id }))
}))
const declarations: string[] = []

View File

@ -113,7 +113,7 @@
"on-change": "^5.0.1",
"pathe": "^2.0.3",
"perfect-debounce": "^1.0.0",
"pkg-types": "^1.3.1",
"pkg-types": "^2.0.1",
"radix3": "^1.1.2",
"scule": "^1.3.0",
"semver": "^7.7.1",

View File

@ -13,8 +13,10 @@ interface EnsurePackageInstalledOptions {
}
async function promptToInstall (name: string, installCommand: () => Promise<void>, options: EnsurePackageInstalledOptions) {
if (await resolvePackageJSON(name, { url: options.searchPaths }).catch(() => null)) {
return true
for (const parent of options.searchPaths || []) {
if (await resolvePackageJSON(name, { parent }).catch(() => null)) {
return true
}
}
logger.info(`Package ${name} is missing`)

View File

@ -58,7 +58,7 @@
"mini-css-extract-plugin": "2.9.2",
"nitropack": "2.10.4",
"ofetch": "1.4.1",
"pkg-types": "1.3.1",
"pkg-types": "2.0.1",
"postcss": "8.5.3",
"rollup-plugin-visualizer": "5.14.0",
"sass-loader": "16.0.5",

View File

@ -51,7 +51,7 @@
"ohash": "^2.0.7",
"pathe": "^2.0.3",
"perfect-debounce": "^1.0.0",
"pkg-types": "^1.3.1",
"pkg-types": "^2.0.1",
"postcss": "^8.5.3",
"rollup-plugin-visualizer": "^5.14.0",
"std-env": "^3.8.0",

View File

@ -272,8 +272,8 @@ importers:
specifier: ^2.0.3
version: 2.0.3
pkg-types:
specifier: ^1.3.1
version: 1.3.1
specifier: ^2.0.1
version: 2.0.1
scule:
specifier: ^1.3.0
version: 1.3.0
@ -465,8 +465,8 @@ importers:
specifier: ^1.0.0
version: 1.0.0
pkg-types:
specifier: ^1.3.1
version: 1.3.1
specifier: ^2.0.1
version: 2.0.1
radix3:
specifier: ^1.1.2
version: 1.1.2
@ -783,8 +783,8 @@ importers:
specifier: 1.4.1
version: 1.4.1
pkg-types:
specifier: 1.3.1
version: 1.3.1
specifier: 2.0.1
version: 2.0.1
postcss:
specifier: 8.5.3
version: 8.5.3
@ -945,8 +945,8 @@ importers:
specifier: ^1.0.0
version: 1.0.0
pkg-types:
specifier: ^1.3.1
version: 1.3.1
specifier: ^2.0.1
version: 2.0.1
postcss:
specifier: 8.5.3
version: 8.5.3
@ -6084,8 +6084,8 @@ packages:
pkg-types@1.3.1:
resolution: {integrity: sha512-/Jm5M4RvtBFVkKWRu2BLUTNP8/M2a+UwuAX+ae4770q1qVGtfjG+WTCupoZixokjmHiry8uI+dlY8KXYV5HVVQ==}
pkg-types@2.0.0:
resolution: {integrity: sha512-W+831FxieJW1CIAh3JMmHaMhK/SiSeyCqbSWqLjjvbjaPDDY0cRkspIfOx4vLkFNgfxnzSxxGFUiMHMm6QpvYA==}
pkg-types@2.0.1:
resolution: {integrity: sha512-LdDk/hlFeVBoEZqlkJ2bsxwq5fjKQg7i422zu78IC16CSR2XBe7kYxxBx0mkU8kLX6nh50Zp80lZHveKnsHTpQ==}
playwright-core@1.50.1:
resolution: {integrity: sha512-ra9fsNWayuYumt+NiM069M6OkcRb1FZSK8bgi66AtpFoWkg2+y0bJSNmkFrWhMbEBbVKC/EruAHH3g0zmtwGmQ==}
@ -8719,7 +8719,7 @@ snapshots:
execa: 9.5.2
magicast: 0.3.5
pathe: 2.0.3
pkg-types: 2.0.0
pkg-types: 2.0.1
prompts: 2.4.2
semver: 7.7.1
@ -8747,7 +8747,7 @@ snapshots:
ohash: 2.0.7
pathe: 2.0.3
perfect-debounce: 1.0.0
pkg-types: 2.0.0
pkg-types: 2.0.1
semver: 7.7.1
simple-git: 3.27.0
sirv: 3.0.1
@ -10574,7 +10574,7 @@ snapshots:
ohash: 2.0.7
pathe: 2.0.3
perfect-debounce: 1.0.0
pkg-types: 2.0.0
pkg-types: 2.0.1
rc9: 2.1.2
optionalDependencies:
magicast: 0.3.5
@ -10591,7 +10591,7 @@ snapshots:
ohash: 2.0.7
pathe: 2.0.3
perfect-debounce: 1.0.0
pkg-types: 2.0.0
pkg-types: 2.0.1
rc9: 2.1.2
optionalDependencies:
magicast: 0.3.5
@ -10657,7 +10657,7 @@ snapshots:
ofetch: 1.4.1
open: 10.1.0
pathe: 2.0.3
pkg-types: 2.0.0
pkg-types: 2.0.1
scule: 1.3.0
semver: 7.7.1
std-env: 3.8.0
@ -13429,7 +13429,7 @@ snapshots:
citty: 0.1.6
consola: 3.4.0
pathe: 2.0.3
pkg-types: 2.0.0
pkg-types: 2.0.1
tinyexec: 0.3.2
object-assign@4.1.1: {}
@ -13664,9 +13664,10 @@ snapshots:
mlly: 1.7.4
pathe: 2.0.3
pkg-types@2.0.0:
pkg-types@2.0.1:
dependencies:
confbox: 0.1.8
exsolve: 1.0.1
pathe: 2.0.3
playwright-core@1.50.1: {}
@ -14939,7 +14940,7 @@ snapshots:
mkdist: 2.2.0(typescript@5.8.2)(vue-tsc@2.2.4(typescript@5.8.2))(vue@3.5.13(typescript@5.8.2))
mlly: 1.7.4
pathe: 2.0.3
pkg-types: 2.0.0
pkg-types: 2.0.1
pretty-bytes: 6.1.1
rollup: 4.34.9
rollup-plugin-dts: 6.1.1(rollup@4.34.9)(typescript@5.8.2)