From 201a868e6bbc1238916b603fc02a92d119f862cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20Magyar?= Date: Sat, 10 Oct 2026 15:00:48 +0300 Subject: [PATCH] fix(deps): normalize audited peers to the exact runtime --- gitnexus/scripts/prepare-tree-sitter-bundle.cjs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gitnexus/scripts/prepare-tree-sitter-bundle.cjs b/gitnexus/scripts/prepare-tree-sitter-bundle.cjs index 927843ce4..66adbac50 100644 --- a/gitnexus/scripts/prepare-tree-sitter-bundle.cjs +++ b/gitnexus/scripts/prepare-tree-sitter-bundle.cjs @@ -1,6 +1,6 @@ #!/usr/bin/env node /** - * Prepare the tested native parser bundle for npm pack/publish. + * Prepare the tested native parser dependencies for installation and publication. * * A dependency's npm overrides do not apply in a consumer project. Several * ABI-compatible grammars still advertise older runtime peers, so bundling @@ -11,6 +11,7 @@ const fs = require('node:fs'); const path = require('node:path'); const RUNTIME = '0.25.1'; +// Upstream metadata is an input to validate, never the peer range we ship. const AUDITED_PEERS = new Map([ ['tree-sitter-c@0.23.6', '^0.22.1'], ['tree-sitter-cpp@0.23.4', '^0.21.1'], @@ -60,11 +61,13 @@ function prepareTreeSitterBundle(packageRoot = path.resolve(__dirname, '..')) { const pkg = readJson(file); const original = AUDITED_PEERS.get(`${pkg.name}@${pkg.version}`); if (original) { - const peer = `${original} || ${RUNTIME}`; - if (![original, peer].includes(pkg.peerDependencies?.['tree-sitter'])) { + // Also accept bundles prepared before peers were pinned exactly, so + // an existing checkout can migrate through ordinary npm install. + const accepted = [original, `${original} || ${RUNTIME}`, RUNTIME]; + if (!accepted.includes(pkg.peerDependencies?.['tree-sitter'])) { throw new Error(`Unexpected tree-sitter peer metadata for ${pkg.name}@${pkg.version}`); } - pkg.peerDependencies['tree-sitter'] = peer; + pkg.peerDependencies['tree-sitter'] = RUNTIME; patches.push({ file, pkg }); } }