Versions 157 to 318
new file, 58 lines
1+import { createHash } from "node:crypto"; 2+import { readFileSync, writeFileSync } from "node:fs"; 3+import { join } from "node:path"; 5+const root = "capacity-git-dependency-sandbox/node_modules/isomorphic-git"; 7+ "index.js": "eebe6911fa660d4b95857768ea2308be74435dd5f9a796bb7b2491a31bdd109d", 8+ "index.cjs": "33364e3ed7f3a1a6cf17a1ecabbfc5d6de6a8494f31a524d8ac293402ad4e447", 10+const hash = (value) => createHash("sha256").update(value).digest("hex"); 11+const queue = readFileSync("capacity-git-bounded-fifo.mjs", "utf8").replace("export class", "class"); 12+function once(source, before, after) { 13+ if (source.split(before).length !== 2) throw Error(`Sideband anchor mismatch: ${before}`); 14+ return source.replace(before, after); 17+for (const [file, expected] of Object.entries(inputs)) { 18+ let source = readFileSync(join(root, file), "utf8"); 19+ if (hash(source) !== expected) throw Error(`Unrecognized input: ${file}`); 20+ source = once(source, "class GitSideBand {", `${queue}\nclass GitSideBand {`); 21+ source = once(source, " static demux(input) {", " static demux(input, bounded = false) {"); 24+ " const packfile = new FIFO();", 25+ " const packfile = bounded ? new BoundedPackFIFO(async () => { await getIterator(input).return?.(); }) : new FIFO();", 27+ source = once(source, " packfile.write(line.slice(1));", " await packfile.write(line.slice(1));"); 30+ " nextBit();\n };\n nextBit();", 33+ nextBit().catch(error => { packetlines.destroy(error); progress.destroy(error); packfile.destroy(error); });`, 37+ "async function parseUploadPackResponse(stream) {\n const { packetlines, packfile, progress } = GitSideBand.demux(stream);", 38+ "async function parseUploadPackResponse(stream, bounded = false) {\n const { packetlines, packfile, progress } = GitSideBand.demux(stream, bounded);", 42+ " const response = await parseUploadPackResponse(raw.body);", 43+ " const response = await parseUploadPackResponse(raw.body, Boolean(cache && cache[Symbol.for('abso.git.disk-pack')]));", 45+ outputs.push({ file, source, sha256: hash(source) }); 47+if (!process.argv.includes("--check")) { 48+ for (const { file, source } of outputs) writeFileSync(join(root, file), source); 50+ "capacity-git-sideband-patch-manifest.json", 52+ outputs.map(({ file, sha256 }) => ({ file, sha256 })), 58+console.log(JSON.stringify(outputs.map(({ file, sha256 }) => ({ file, sha256 }))));