Files
hanzo.ai/scripts/prebuild.ts
Cursor Agentandz af4d1337b7 oss: count commits and merges for each repo, org, and zeekay
The past year is kept per public repository and rolled up per organization.
zeekay's commits and merged pull requests sit inside those totals and on a
line of their own. Private repository names stay off the record. The daily
build refreshes the slices with the global census.

Co-authored-by: z <[email protected]>
2026-10-27 08:24:20 +00:00

56 lines
1.8 KiB
JavaScript

#!/usr/bin/env node
// What `next build` reads, regenerated before it runs.
//
// The first group each write files of their own and read none the others
// write, so they run at once: one after another they were 23 s of every
// deploy, most of it waiting on the network. The last three read what the
// first group wrote (the route tree's policy joins the catalog, and
// keep-stamps compares every snapshot), so they run after it, in order.
//
// Every script runs to its end before the build is refused, so one failure
// does not hide another.
import { spawn } from 'node:child_process'
import { existsSync } from 'node:fs'
const AT_ONCE = [
'gen-gui-css',
'rooms-assets',
'sync-mark',
'brands',
'zen',
'kai',
'coding',
'tools',
'sync-catalog',
'sync-models',
'sync-papers',
'sync-blog',
'sync-oss',
'sync-releases',
'sync-menu',
]
// velocity reads the census sync-oss just wrote, so it waits for that group.
// The daily deploy is the schedule: a snapshot younger than 20 hours is kept.
const AFTER = ['velocity', 'velocity-slices', 'sync-rooms', 'sync-pages', 'keep-stamps']
// A script is TypeScript (`.ts`, run by Node's own type stripping) or a `.mjs` not yet converted.
const run = (name: string) =>
new Promise<string | null>((done) => {
spawn(process.execPath, [existsSync(`scripts/${name}.ts`) ? `scripts/${name}.ts` : `scripts/${name}.mjs`], { stdio: 'inherit' })
.on('error', (err) => done(`${name}: ${err.message}`))
.on('exit', (code, signal) => done(code === 0 ? null : `${name} exited ${signal ?? code}`))
})
const failed = (await Promise.all(AT_ONCE.map(run))).filter(Boolean)
if (failed.length) {
for (const f of failed) console.error(`prebuild: ${f}`)
process.exit(1)
}
for (const name of AFTER) {
const f = await run(name)
if (f) {
console.error(`prebuild: ${f}`)
process.exit(1)
}
}