From eefe781506f99e274a91f1aca2d31d0488b6a1dc Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 1 Mar 2025 21:13:08 +0000 Subject: [PATCH] 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 --- packages/kit/package.json | 2 +- packages/kit/src/compatibility.ts | 17 +++++++++----- packages/kit/src/template.ts | 29 +++++++++++++++++++---- packages/nuxt/package.json | 2 +- packages/nuxt/src/core/features.ts | 6 +++-- packages/schema/package.json | 2 +- packages/vite/package.json | 2 +- pnpm-lock.yaml | 37 +++++++++++++++--------------- 8 files changed, 62 insertions(+), 35 deletions(-) diff --git a/packages/kit/package.json b/packages/kit/package.json index f215af9044..c6ca747994 100644 --- a/packages/kit/package.json +++ b/packages/kit/package.json @@ -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", diff --git a/packages/kit/src/compatibility.ts b/packages/kit/src/compatibility.ts index 2b24d932f1..9caa0ef75d 100644 --- a/packages/kit/src/compatibility.ts +++ b/packages/kit/src/compatibility.ts @@ -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 + } } } } diff --git a/packages/kit/src/template.ts b/packages/kit/src/template.ts index 3a6946d421..e315783043 100644 --- a/packages/kit/src/template.ts +++ b/packages/kit/src/template.ts @@ -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[] = [] diff --git a/packages/nuxt/package.json b/packages/nuxt/package.json index e3da3b0cf4..575fd218b1 100644 --- a/packages/nuxt/package.json +++ b/packages/nuxt/package.json @@ -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", diff --git a/packages/nuxt/src/core/features.ts b/packages/nuxt/src/core/features.ts index d19b4021c0..4ad8d18bae 100644 --- a/packages/nuxt/src/core/features.ts +++ b/packages/nuxt/src/core/features.ts @@ -13,8 +13,10 @@ interface EnsurePackageInstalledOptions { } async function promptToInstall (name: string, installCommand: () => Promise, 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`) diff --git a/packages/schema/package.json b/packages/schema/package.json index d8a0f7fab3..74f0518052 100644 --- a/packages/schema/package.json +++ b/packages/schema/package.json @@ -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", diff --git a/packages/vite/package.json b/packages/vite/package.json index 535f08f2b5..2bc36a67bc 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e6b0994ecd..c5a23f1230 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -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)