{"draft":null,"from":148,"to":318,"files":[{"path":"server/scripts/capacity-patch-git-progress.mjs","added":53,"removed":0,"diff":"--- /dev/null\n+++ b/server/scripts/capacity-patch-git-progress.mjs\n@@ -0,0 +1,53 @@\n+import { createHash } from \"node:crypto\";\n+import { readFileSync, writeFileSync } from \"node:fs\";\n+import { join } from \"node:path\";\n+\n+const root = \"capacity-git-dependency-sandbox/node_modules/isomorphic-git\";\n+const inputs = {\n+\t\"index.js\": \"20512aae32eb8dd64b798c0dd4ba666ea801bec6c9de37d259527c93ce3e48ec\",\n+\t\"index.cjs\": \"b4cd8c52f3fa945b553dbb7a740c965b48b93dfc2469f10849e111abd00c7460\",\n+};\n+const hash = (value) => createHash(\"sha256\").update(value).digest(\"hex\");\n+function once(source, before, after) {\n+\tif (source.split(before).length !== 2) throw Error(`Progress anchor mismatch: ${before}`);\n+\treturn source.replace(before, after);\n+}\n+const outputs = [];\n+for (const [file, expected] of Object.entries(inputs)) {\n+\tlet source = readFileSync(join(root, file), \"utf8\");\n+\tif (hash(source) !== expected) throw Error(`Unrecognized input: ${file}`);\n+\tsource = once(\n+\t\tsource,\n+\t\t\"  static demux(input, bounded = false) {\",\n+\t\t\"  static demux(input, bounded = false, discardProgress = false) {\",\n+\t);\n+\tsource = once(\n+\t\tsource,\n+\t\t\"          progress.write(line.slice(1));\",\n+\t\t\"          if (!discardProgress) progress.write(line.slice(1));\",\n+\t);\n+\tsource = once(source, \"          progress.write(error);\", \"          if (!discardProgress) progress.write(error);\");\n+\tsource = once(\n+\t\tsource,\n+\t\t\"async function parseUploadPackResponse(stream, bounded = false) {\\n  const { packetlines, packfile, progress } = GitSideBand.demux(stream, bounded);\",\n+\t\t\"async function parseUploadPackResponse(stream, bounded = false, discardProgress = false) {\\n  const { packetlines, packfile, progress } = GitSideBand.demux(stream, bounded, discardProgress);\",\n+\t);\n+\tsource = once(\n+\t\tsource,\n+\t\t\"  const response = await parseUploadPackResponse(raw.body, Boolean(cache && cache[Symbol.for('abso.git.disk-pack')]));\",\n+\t\t\"  const response = await parseUploadPackResponse(raw.body, Boolean(cache && cache[Symbol.for('abso.git.disk-pack')]), Boolean(cache && cache[Symbol.for('abso.git.disk-pack')]) && !onProgress && !onMessage);\",\n+\t);\n+\toutputs.push({ file, source, sha256: hash(source) });\n+}\n+if (!process.argv.includes(\"--check\")) {\n+\tfor (const { file, source } of outputs) writeFileSync(join(root, file), source);\n+\twriteFileSync(\n+\t\t\"capacity-git-progress-patch-manifest.json\",\n+\t\tJSON.stringify(\n+\t\t\toutputs.map(({ file, sha256 }) => ({ file, sha256 })),\n+\t\t\tnull,\n+\t\t\t2,\n+\t\t),\n+\t);\n+}\n+console.log(JSON.stringify(outputs.map(({ file, sha256 }) => ({ file, sha256 }))));"}],"unmatched":[]}