From c4fb9ced03bccbf18ecb3a920b18101ee9c3509d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 1 Mar 2025 14:46:54 +0000 Subject: [PATCH] chore(deps): update dependency pkg-types to v2 (main) (#31122) --- 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 | 64 ++++++++++++------------------ 8 files changed, 68 insertions(+), 56 deletions(-) diff --git a/packages/kit/package.json b/packages/kit/package.json index 35b11b8f4a..3074d707e3 100644 --- a/packages/kit/package.json +++ b/packages/kit/package.json @@ -40,7 +40,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 a7a5568ad0..e643f28cb9 100644 --- a/packages/kit/src/compatibility.ts +++ b/packages/kit/src/compatibility.ts @@ -47,12 +47,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 f803cdd929..c9e6950e0d 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 bcc8657643..b15e8c3a81 100644 --- a/packages/nuxt/package.json +++ b/packages/nuxt/package.json @@ -108,7 +108,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 99a1cdd2a2..8384d8ffd7 100644 --- a/packages/schema/package.json +++ b/packages/schema/package.json @@ -58,7 +58,7 @@ "mini-css-extract-plugin": "2.9.2", "nitro": "npm:nitro-nightly@3.0.0-beta-28969273.f7aa9de6", "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 7de1eb0ab6..115984967a 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -48,7 +48,7 @@ "magic-string": "^0.30.17", "mlly": "^1.7.4", "pathe": "^2.0.3", - "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 7780efd137..ae068ed13d 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 @@ -459,8 +459,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 @@ -777,8 +777,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 @@ -924,8 +924,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 postcss: specifier: 8.5.3 version: 8.5.3 @@ -3354,10 +3354,6 @@ packages: resolution: {integrity: sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==} engines: {node: '>=12'} - ansis@3.15.0: - resolution: {integrity: sha512-zIcWDJ+Kwqxfdnogx66Gxzr0kVmCcRAdat9nlY2IHsshqTN4fBH6tMeRMPA/2w0rpBayIJvjQAaa2/4RDrNqwg==} - engines: {node: '>=14'} - ansis@3.16.0: resolution: {integrity: sha512-sU7d/tfZiYrsIAXbdL/CNZld5bCkruzwT5KmqmadCJYxuLxHAOBjidxD5+iLmN/6xEfjcQq1l7OpsiCBlc4LzA==} engines: {node: '>=14'} @@ -5353,10 +5349,6 @@ packages: resolution: {integrity: sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==} engines: {node: '>=8.9.0'} - local-pkg@1.0.0: - resolution: {integrity: sha512-bbgPw/wmroJsil/GgL4qjDzs5YLTBMQ99weRsok1XCDccQeehbHA/I1oRvk2NPtr7KGZgT/Y5tPRnAtMqeG2Kg==} - engines: {node: '>=14'} - local-pkg@1.1.0: resolution: {integrity: sha512-xbZBuX6gYIWrlLmZG43aAVer4ocntYO09vPy9lxd6Ns8DnR4U7N+IIeDkubinqFOHHzoMlPxTxwo0jhE7oYjAw==} engines: {node: '>=14'} @@ -6091,8 +6083,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==} @@ -8503,7 +8495,7 @@ snapshots: debug: 4.4.0(supports-color@9.4.0) globals: 15.15.0 kolorist: 1.8.0 - local-pkg: 1.0.0 + local-pkg: 1.1.0 mlly: 1.7.4 transitivePeerDependencies: - supports-color @@ -8717,7 +8709,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 @@ -8745,7 +8737,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 @@ -8782,7 +8774,7 @@ snapshots: eslint-plugin-vue: 9.32.0(eslint@9.21.0(jiti@2.4.2)) eslint-processor-vue-blocks: 2.0.0(@vue/compiler-sfc@3.5.13)(eslint@9.21.0(jiti@2.4.2)) globals: 15.15.0 - local-pkg: 1.0.0 + local-pkg: 1.1.0 pathe: 2.0.3 vue-eslint-parser: 9.4.3(eslint@9.21.0(jiti@2.4.2)) transitivePeerDependencies: @@ -8880,7 +8872,7 @@ snapshots: fake-indexeddb: 6.0.0 get-port-please: 3.1.2 h3: h3-nightly@1.15.1-20250222-111608-d1c00fc - local-pkg: 1.0.0 + local-pkg: 1.1.0 magic-string: 0.30.17 node-fetch-native: 1.6.6 ofetch: 1.4.1 @@ -10026,7 +10018,7 @@ snapshots: dependencies: '@vue/compiler-sfc': 3.5.13 ast-kit: 1.4.0 - local-pkg: 1.0.0 + local-pkg: 1.1.0 magic-string-ast: 0.7.0 pathe: 2.0.3 picomatch: 4.0.2 @@ -10378,8 +10370,6 @@ snapshots: ansi-styles@6.2.1: {} - ansis@3.15.0: {} - ansis@3.16.0: {} any-promise@1.3.0: {} @@ -10564,7 +10554,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 @@ -10630,7 +10620,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 @@ -12576,11 +12566,6 @@ snapshots: emojis-list: 3.0.0 json5: 2.2.3 - local-pkg@1.0.0: - dependencies: - mlly: 1.7.4 - pkg-types: 1.3.1 - local-pkg@1.1.0: dependencies: mlly: 1.7.4 @@ -13373,7 +13358,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: {} @@ -13610,9 +13595,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: {} @@ -14859,7 +14845,7 @@ snapshots: mkdist: 2.2.0(typescript@5.8.2)(vue-tsc@2.2.6(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) @@ -14928,7 +14914,7 @@ snapshots: acorn: 8.14.0 escape-string-regexp: 5.0.0 estree-walker: 3.0.3 - local-pkg: 1.0.0 + local-pkg: 1.1.0 magic-string: 0.30.17 mlly: 1.7.4 pathe: 2.0.3 @@ -15012,7 +14998,7 @@ snapshots: chokidar: 3.6.0 fast-glob: 3.3.3 json5: 2.2.3 - local-pkg: 1.0.0 + local-pkg: 1.1.0 magic-string: 0.30.17 mlly: 1.7.4 pathe: 2.0.3 @@ -15521,7 +15507,7 @@ snapshots: webpackbar@7.0.0(@rspack/core@1.2.6)(webpack@5.98.0): dependencies: - ansis: 3.15.0 + ansis: 3.16.0 consola: 3.4.0 pretty-time: 1.1.0 std-env: 3.8.0