Blap README + curl-based release uploads
- Replace the element-web README with a Blap one (downloads/updating/building). - release-codeberg: upload assets via curl instead of Node fetch, which times out (UND_ERR_HEADERS_TIMEOUT) on 300MB+ files. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
* resolves to it (that's what the updater feed URL points at).
|
||||
*/
|
||||
import { readFile, readdir } from "node:fs/promises";
|
||||
import { statSync } from "node:fs";
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { basename, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
@@ -84,15 +86,27 @@ async function main() {
|
||||
method: "DELETE",
|
||||
});
|
||||
}
|
||||
const data = await readFile(join(distDir, file));
|
||||
const form = new FormData();
|
||||
form.append("attachment", new Blob([data]), name);
|
||||
const res = await fetch(
|
||||
`${API}/repos/${OWNER}/${REPO}/releases/${release.id}/assets?name=${encodeURIComponent(name)}`,
|
||||
{ method: "POST", headers: authHeaders, body: form },
|
||||
const filePath = join(distDir, file);
|
||||
const sizeMB = (statSync(filePath).size / 1e6).toFixed(0);
|
||||
process.stdout.write(`Uploading ${name} (${sizeMB} MB)... `);
|
||||
// Upload via curl: Node's built-in fetch (undici) times out on large files
|
||||
// (UND_ERR_HEADERS_TIMEOUT). curl streams from disk with no such limit.
|
||||
execFileSync(
|
||||
"curl",
|
||||
[
|
||||
"-sS",
|
||||
"--fail-with-body",
|
||||
"-X",
|
||||
"POST",
|
||||
"-H",
|
||||
`Authorization: token ${token}`,
|
||||
"-F",
|
||||
`attachment=@${filePath}`,
|
||||
`${API}/repos/${OWNER}/${REPO}/releases/${release.id}/assets?name=${encodeURIComponent(name)}`,
|
||||
],
|
||||
{ stdio: ["ignore", "ignore", "inherit"] },
|
||||
);
|
||||
if (!res.ok) throw new Error(`upload ${name} -> ${res.status} ${await res.text()}`);
|
||||
console.log(`Uploaded ${name}`);
|
||||
console.log("done");
|
||||
}
|
||||
|
||||
console.log(`\nDone. Updater feed: https://codeberg.org/${OWNER}/${REPO}/releases/latest/download/latest.yml`);
|
||||
|
||||
Reference in New Issue
Block a user