This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

at main 1.5 kB View raw
1import { pool, withClient } from "./db.js"; 2 3async function main() { 4 const rows = await withClient((c) => c.query(` 5 select knot_hostname, record_raw->>'repoDid' as repodid, record_raw->>'name' as name 6 from tangled_repos 7 where knot_hostname='knot1.tangled.sh' and coalesce(record_raw->>'repoDid','')<>'' 8 limit 6`).then(r => r.rows)); 9 for (const r of rows) { 10 const url = `https://${r.knot_hostname}/xrpc/sh.tangled.git.temp.getTree?repo=${encodeURIComponent(r.repodid)}&ref=HEAD&path=`; 11 try { 12 const ctrl = new AbortController(); 13 const t = setTimeout(() => ctrl.abort(), 12000); 14 const resp = await fetch(url, { signal: ctrl.signal, headers: { accept: "application/json" } }); 15 clearTimeout(t); 16 const txt = await resp.text(); 17 let j: any; try { j = JSON.parse(txt); } catch { j = null; } 18 const fileNames = (j?.files || []).map((f: any) => f.name); 19 const readmeInTree = fileNames.some((n: string) => /^readme/i.test(n)); 20 console.log(`\n[${resp.status}] ${r.name ?? "(no name)"} ${r.repodid}`); 21 console.log(` readme field: ${j?.readme ? JSON.stringify(Object.keys(j.readme)) : "none"} | readmeInTree=${readmeInTree}`); 22 console.log(` files: ${JSON.stringify(fileNames).slice(0, 200)}`); 23 if (!j) console.log(` raw: ${txt.slice(0, 200)}`); 24 } catch (e: any) { 25 console.log(`\n[ERR] ${r.repodid}: ${e.message}`); 26 } 27 } 28 await pool.end(); 29} 30main().catch((e) => { console.error(e); process.exit(1); });