mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-15 04:18:05 +00:00
fix(deps): normalize audited peers to the exact runtime
This commit is contained in:
parent
7a418580a9
commit
201a868e6b
1 changed files with 7 additions and 4 deletions
|
|
@ -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 });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue