{"file":"client/src/ci.ts","version":2,"draft":"login-timeout","total":161,"from":1,"to":161,"lines":[{"n":1,"text":"// What the project's CI says (#39): the server runs abso.json's setup, build","atom":"a233","author":"review","version":28},{"n":2,"text":"// and check on each new version of shared. status and log show it; abso ci","atom":"a0","author":"init","version":0},{"n":3,"text":"// shows it whole, and one version's job with the end of its output.","atom":"a0","author":"init","version":0},{"n":4,"text":"","atom":"a0","author":"init","version":0},{"n":5,"text":"import { ApiError, type CiJob, type CiMark, type CiStatus } from \"./api.ts\";","atom":"a0","author":"init","version":0},{"n":6,"text":"import { bool, type Parsed, str, UsageError } from \"./args.ts\";","atom":"a0","author":"init","version":0},{"n":7,"text":"import { type Env, type Output, open, plural } from \"./commands.ts\";","atom":"a0","author":"init","version":0},{"n":8,"text":"import { when } from \"./history.ts\";","atom":"a0","author":"init","version":0},{"n":9,"text":"","atom":"a0","author":"init","version":0},{"n":10,"text":"/** Seconds since an ISO time, as \"35 s\" or \"4 min\". */","atom":"a0","author":"init","version":0},{"n":11,"text":"function ago(iso: string, now: number): string {","atom":"a0","author":"init","version":0},{"n":12,"text":"\tconst s = Math.max(0, Math.round((now - Date.parse(iso)) / 1000));","atom":"a0","author":"init","version":0},{"n":13,"text":"\treturn s < 120 ? `${s} s` : `${Math.round(s / 60)} min`;","atom":"a0","author":"init","version":0},{"n":14,"text":"}","atom":"a0","author":"init","version":0},{"n":15,"text":"","atom":"a0","author":"init","version":0},{"n":16,"text":"/** An ISO time as HH:MM UTC, with the date when it isn't today. */","atom":"a0","author":"init","version":0},{"n":17,"text":"function clock(iso: string, now: number): string {","atom":"a0","author":"init","version":0},{"n":18,"text":"\tconst t = new Date(iso).toISOString();","atom":"a0","author":"init","version":0},{"n":19,"text":"\treturn t.slice(0, 10) === new Date(now).toISOString().slice(0, 10)","atom":"a0","author":"init","version":0},{"n":20,"text":"\t\t? `${t.slice(11, 16)} UTC`","atom":"a0","author":"init","version":0},{"n":21,"text":"\t\t: `${t.slice(0, 16).replace(\"T\", \" \")} UTC`;","atom":"a0","author":"init","version":0},{"n":22,"text":"}","atom":"a0","author":"init","version":0},{"n":23,"text":"","atom":"a0","author":"init","version":0},{"n":24,"text":"/** The lines status shows about CI: is shared green or red, and where the preview is. Nothing from a server without CI. */","atom":"a0","author":"init","version":0},{"n":25,"text":"export function ciText(ci: CiStatus | undefined, shared: number, now = Date.now()): string[] {","atom":"a0","author":"init","version":0},{"n":26,"text":"\tif (ci === undefined) return [];","atom":"a0","author":"init","version":0},{"n":27,"text":"\tconst lines: string[] = [];","atom":"a0","author":"init","version":0},{"n":28,"text":"\tconst running =","atom":"a0","author":"init","version":0},{"n":29,"text":"\t\tci.running === null","atom":"a0","author":"init","version":0},{"n":30,"text":"\t\t\t? \"\"","atom":"a0","author":"init","version":0},{"n":31,"text":"\t\t\t: ` Version ${ci.running.version} is being checked (${ago(ci.running.since, now)} so far${ci.running.bisect ? \", a bisect step\" : \"\"}).`;","atom":"a0","author":"init","version":0},{"n":32,"text":"\tconst red = ci.red;","atom":"a0","author":"init","version":0},{"n":33,"text":"\tif (red !== null) {","atom":"a0","author":"init","version":0},{"n":34,"text":"\t\tif (red.bisecting) {","atom":"a0","author":"init","version":0},{"n":35,"text":"\t\t\tlines.push(","atom":"a0","author":"init","version":0},{"n":36,"text":"\t\t\t\t`Shared is red: version ${red.version} fails its check, and CI is bisecting for the version that broke it${red.lastGood === null ? \"\" : ` (version ${red.lastGood} passed)`}.${running}`,","atom":"a0","author":"init","version":0},{"n":37,"text":"\t\t\t);","atom":"a0","author":"init","version":0},{"n":38,"text":"\t\t} else if (red.agent !== null) {","atom":"a0","author":"init","version":0},{"n":39,"text":"\t\t\tlines.push(","atom":"a0","author":"init","version":0},{"n":40,"text":"\t\t\t\t`Shared is red since version ${red.version}, by ${red.agent}${red.message === null ? \"\" : ` (\"${red.message}\")`}${red.lastGood === null ? \"\" : `; version ${red.lastGood} was the last to pass`}. abso ci ${red.version} shows why.${running}`,","atom":"a0","author":"init","version":0},{"n":41,"text":"\t\t\t);","atom":"a0","author":"init","version":0},{"n":42,"text":"\t\t} else {","atom":"a0","author":"init","version":0},{"n":43,"text":"\t\t\tlines.push(","atom":"a0","author":"init","version":0},{"n":44,"text":"\t\t\t\t`Shared is red: version ${red.version} fails its check${red.lastGood === null ? \", and no version has passed yet\" : `; version ${red.lastGood} was the last to pass`}. abso ci ${red.version} shows why.${running}`,","atom":"a0","author":"init","version":0},{"n":45,"text":"\t\t\t);","atom":"a0","author":"init","version":0},{"n":46,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":47,"text":"\t} else if (ci.checked !== null) {","atom":"a0","author":"init","version":0},{"n":48,"text":"\t\tconst v = ci.checked.version;","atom":"a0","author":"init","version":0},{"n":49,"text":"\t\t// Newer versions with no job running: skipped (said below) or not reached yet.","atom":"a0","author":"init","version":0},{"n":50,"text":"\t\tconst newer =","atom":"a0","author":"init","version":0},{"n":51,"text":"\t\t\tshared > v ? (ci.running !== null ? running : ci.skipped ? \"\" : ` Versions after ${v} aren't checked yet.`) : \"\";","atom":"a0","author":"init","version":0},{"n":52,"text":"\t\tif (ci.checked.result === \"pass\") lines.push(`Shared is green: version ${v} passed its check.${newer}`);","atom":"a0","author":"init","version":0},{"n":53,"text":"\t\telse if (ci.checked.result === \"fail\") lines.push(`Version ${v} failed its check. abso ci ${v} shows why.${newer}`);","atom":"a0","author":"init","version":0},{"n":54,"text":"\t\telse lines.push(`CI couldn't check version ${v} (the box failed twice, or abso.json has nothing to run).${newer}`);","atom":"a233","author":"review","version":28},{"n":55,"text":"\t} else {","atom":"a0","author":"init","version":0},{"n":56,"text":"\t\tlines.push(","atom":"a0","author":"init","version":0},{"n":57,"text":"\t\t\tci.running === null","atom":"a0","author":"init","version":0},{"n":58,"text":"\t\t\t\t? \"Not checked yet: CI has not finished a job on this project.\"","atom":"a0","author":"init","version":0},{"n":59,"text":"\t\t\t\t: `Not checked yet.${running}`,","atom":"a0","author":"init","version":0},{"n":60,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":61,"text":"\t}","atom":"a0","author":"init","version":0},{"n":62,"text":"\t// Not running, and not queued either (#39, GAME - CEO: \"aren't checked yet\" read as queued while CI was off).","atom":"a0","author":"init","version":0},{"n":63,"text":"\tif (ci.skipped) {","atom":"a0","author":"init","version":0},{"n":64,"text":"\t\tconst s = ci.skipped;","atom":"a0","author":"init","version":0},{"n":65,"text":"\t\tlines.push(","atom":"a0","author":"init","version":0},{"n":66,"text":"\t\t\t`CI didn't run ${s.from < s.version ? `versions ${s.from}-${s.version}` : `version ${s.version}`}: ${s.reason}. ${s.from < s.version ? \"They\" : \"It\"} won't be checked unless a later version's job covers ${s.from < s.version ? \"them\" : \"it\"}.`,","atom":"a0","author":"init","version":0},{"n":67,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":68,"text":"\t}","atom":"a0","author":"init","version":0},{"n":69,"text":"\tif (ci.waiting) lines.push(`CI is waiting: ${ci.waiting.reason}; next try ${clock(ci.waiting.until, now)}.`);","atom":"a0","author":"init","version":0},{"n":70,"text":"\tif (ci.latest?.url) {","atom":"a0","author":"init","version":0},{"n":71,"text":"\t\tconst behind =","atom":"a0","author":"init","version":0},{"n":72,"text":"\t\t\tci.behind === null || ci.behind === 0 ? \"shared itself\" : `${plural(ci.behind, \"version\")} behind shared`;","atom":"a0","author":"init","version":0},{"n":73,"text":"\t\tlines.push(","atom":"a0","author":"init","version":0},{"n":74,"text":"\t\t\t`Preview of the newest passing build (version ${ci.latest.version}, ${behind}), no token needed: ${ci.latest.url}`,","atom":"a0","author":"init","version":0},{"n":75,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":76,"text":"\t}","atom":"a0","author":"init","version":0},{"n":77,"text":"\treturn lines;","atom":"a0","author":"init","version":0},{"n":78,"text":"}","atom":"a0","author":"init","version":0},{"n":79,"text":"","atom":"a0","author":"init","version":0},{"n":80,"text":"/** A shared version's mark in abso log; \"not checked\" says nothing, since most versions in a busy hour are covered by a newer one's job. */","atom":"a0","author":"init","version":0},{"n":81,"text":"export function ciMarkText(mark: CiMark | undefined): string {","atom":"a0","author":"init","version":0},{"n":82,"text":"\tswitch (mark) {","atom":"a0","author":"init","version":0},{"n":83,"text":"\t\tcase \"pass\":","atom":"a0","author":"init","version":0},{"n":84,"text":"\t\t\treturn \", check passed\";","atom":"a0","author":"init","version":0},{"n":85,"text":"\t\tcase \"fail\":","atom":"a0","author":"init","version":0},{"n":86,"text":"\t\t\treturn \", check FAILED\";","atom":"a0","author":"init","version":0},{"n":87,"text":"\t\tcase \"running\":","atom":"a0","author":"init","version":0},{"n":88,"text":"\t\t\treturn \", being checked\";","atom":"a0","author":"init","version":0},{"n":89,"text":"\t\tcase \"waiting\":","atom":"a0","author":"init","version":0},{"n":90,"text":"\t\t\treturn \", waiting for CI\";","atom":"a0","author":"init","version":0},{"n":91,"text":"\t\tdefault:","atom":"a0","author":"init","version":0},{"n":92,"text":"\t\t\treturn \"\";","atom":"a0","author":"init","version":0},{"n":93,"text":"\t}","atom":"a0","author":"init","version":0},{"n":94,"text":"}","atom":"a0","author":"init","version":0},{"n":95,"text":"","atom":"a0","author":"init","version":0},{"n":96,"text":"function jobText(job: CiJob): string[] {","atom":"a0","author":"init","version":0},{"n":97,"text":"\tif (job.result === \"running\") return [`Version ${job.version} is being checked now.`];","atom":"a0","author":"init","version":0},{"n":98,"text":"\tif (job.result === \"waiting\") return [`Version ${job.version} isn't checked yet: CI hasn't reached it.`];","atom":"a0","author":"init","version":0},{"n":99,"text":"\tif (job.result === \"not checked\")","atom":"a0","author":"init","version":0},{"n":100,"text":"\t\treturn [","atom":"a0","author":"init","version":0},{"n":101,"text":"\t\t\t`Version ${job.version} had no job of its own: a newer version's job covered it, or none ran. abso bisect checks it in your box.`,","atom":"a0","author":"init","version":0},{"n":102,"text":"\t\t];","atom":"a0","author":"init","version":0},{"n":103,"text":"\tconst covered =","atom":"a0","author":"init","version":0},{"n":104,"text":"\t\tjob.from !== undefined && job.from < job.version ? ` (standing in for versions ${job.from}-${job.version})` : \"\";","atom":"a0","author":"init","version":0},{"n":105,"text":"\tconst took = [","atom":"a0","author":"init","version":0},{"n":106,"text":"\t\tjob.seconds === undefined ? \"\" : `${job.seconds} s`,","atom":"a0","author":"init","version":0},{"n":107,"text":"\t\tjob.cold ? \"cold box\" : \"\",","atom":"a0","author":"init","version":0},{"n":108,"text":"\t\tjob.bisect ? \"a bisect step\" : \"\",","atom":"a0","author":"init","version":0},{"n":109,"text":"\t]","atom":"a0","author":"init","version":0},{"n":110,"text":"\t\t.filter((w) => w !== \"\")","atom":"a0","author":"init","version":0},{"n":111,"text":"\t\t.join(\", \");","atom":"a0","author":"init","version":0},{"n":112,"text":"\tconst head =","atom":"a0","author":"init","version":0},{"n":113,"text":"\t\tjob.result === \"pass\"","atom":"a0","author":"init","version":0},{"n":114,"text":"\t\t\t? `Version ${job.version} passed${covered}${took === \"\" ? \"\" : ` (${took})`}${job.built ? \"; its build is kept for the preview\" : \"\"}.`","atom":"a0","author":"init","version":0},{"n":115,"text":"\t\t\t: job.result === \"fail\"","atom":"a0","author":"init","version":0},{"n":116,"text":"\t\t\t\t? `Version ${job.version} failed at ${job.step ?? \"a step\"}${job.exit === undefined || job.exit === null ? \"\" : ` (exit ${job.exit})`}${covered}${took === \"\" ? \"\" : `, ${took}`}.`","atom":"a0","author":"init","version":0},{"n":117,"text":"\t\t\t\t: `Version ${job.version} wasn't checked${job.step === undefined ? \"\" : ` (${job.step})`}: the box failed twice, or abso.json has nothing to run.`;","atom":"a233","author":"review","version":28},{"n":118,"text":"\tconst output = job.output?.trimEnd() ?? \"\";","atom":"a0","author":"init","version":0},{"n":119,"text":"\treturn [","atom":"a0","author":"init","version":0},{"n":120,"text":"\t\thead,","atom":"a0","author":"init","version":0},{"n":121,"text":"\t\t...(output === \"\" ? [] : [`The end of its output${job.at ? `, ${when(Date.parse(job.at))}` : \"\"}:`, output]),","atom":"a0","author":"init","version":0},{"n":122,"text":"\t];","atom":"a0","author":"init","version":0},{"n":123,"text":"}","atom":"a0","author":"init","version":0},{"n":124,"text":"","atom":"a0","author":"init","version":0},{"n":125,"text":"export async function runCi(args: Parsed, env: Env): Promise<Output> {","atom":"a0","author":"init","version":0},{"n":126,"text":"\tif (args.positionals.length > 1)","atom":"a0","author":"init","version":0},{"n":127,"text":"\t\tthrow new UsageError(\"ci takes at most one version: abso ci [<version>] | abso ci --revoke\");","atom":"a0","author":"init","version":0},{"n":128,"text":"\tconst { api } = open(env);","atom":"a0","author":"init","version":0},{"n":129,"text":"\tconst typed = args.positionals[0] ?? str(args, \"version\");","atom":"a0","author":"init","version":0},{"n":130,"text":"\ttry {","atom":"a0","author":"init","version":0},{"n":131,"text":"\t\tif (bool(args, \"revoke\")) {","atom":"a0","author":"init","version":0},{"n":132,"text":"\t\t\tif (typed !== undefined) throw new UsageError(\"--revoke takes no version\");","atom":"a0","author":"init","version":0},{"n":133,"text":"\t\t\tconst ci = await api.ciRevoke();","atom":"a0","author":"init","version":0},{"n":134,"text":"\t\t\treturn {","atom":"a0","author":"init","version":0},{"n":135,"text":"\t\t\t\ttext: [","atom":"a0","author":"init","version":0},{"n":136,"text":"\t\t\t\t\t`Every preview link handed out so far is ended.${ci.latest?.url ? ` The new one: ${ci.latest.url}` : \" A new one comes with the next passing build.\"}`,","atom":"a0","author":"init","version":0},{"n":137,"text":"\t\t\t\t].join(\"\\n\"),","atom":"a0","author":"init","version":0},{"n":138,"text":"\t\t\t\tjson: { ...ci },","atom":"a0","author":"init","version":0},{"n":139,"text":"\t\t\t};","atom":"a0","author":"init","version":0},{"n":140,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":141,"text":"\t\tif (typed !== undefined) {","atom":"a0","author":"init","version":0},{"n":142,"text":"\t\t\tif (!/^\\d+$/.test(typed)) throw new UsageError(`a version is a number (got ${JSON.stringify(typed)})`);","atom":"a0","author":"init","version":0},{"n":143,"text":"\t\t\tconst job = await api.ci(Number(typed));","atom":"a0","author":"init","version":0},{"n":144,"text":"\t\t\treturn { text: jobText(job).join(\"\\n\"), json: { ...job } };","atom":"a0","author":"init","version":0},{"n":145,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":146,"text":"\t\tconst [ci, status] = await Promise.all([api.ci(), api.status()]);","atom":"a0","author":"init","version":0},{"n":147,"text":"\t\tconst lines = ciText(ci, status.version);","atom":"a0","author":"init","version":0},{"n":148,"text":"\t\treturn {","atom":"a0","author":"init","version":0},{"n":149,"text":"\t\t\ttext: [","atom":"a0","author":"init","version":0},{"n":150,"text":"\t\t\t\t`shared is at version ${status.version}.`,","atom":"a0","author":"init","version":0},{"n":151,"text":"\t\t\t\t...lines,","atom":"a0","author":"init","version":0},{"n":152,"text":"\t\t\t\t\"abso ci <version> shows one version's job and the end of its output.\",","atom":"a0","author":"init","version":0},{"n":153,"text":"\t\t\t].join(\"\\n\"),","atom":"a0","author":"init","version":0},{"n":154,"text":"\t\t\tjson: { ...ci, version: status.version },","atom":"a0","author":"init","version":0},{"n":155,"text":"\t\t};","atom":"a0","author":"init","version":0},{"n":156,"text":"\t} catch (e) {","atom":"a0","author":"init","version":0},{"n":157,"text":"\t\tif (e instanceof ApiError && e.status === 404)","atom":"a0","author":"init","version":0},{"n":158,"text":"\t\t\tthrow new ApiError(\"this server has no CI yet (#39); abso serve still builds a preview of a version\", 404);","atom":"a0","author":"init","version":0},{"n":159,"text":"\t\tthrow e;","atom":"a0","author":"init","version":0},{"n":160,"text":"\t}","atom":"a0","author":"init","version":0},{"n":161,"text":"}","atom":"a0","author":"init","version":0}],"atoms":[{"atom":"a0","author":"init","message":"Start the project","time":1791506895507,"timeIso":"2026-10-09T00:48:15.507Z","publish":{"draft":null,"version":0,"agent":"init","message":"Start the project","time":1791506895507,"timeIso":"2026-10-09T00:48:15.507Z"}},{"atom":"a233","author":"review","message":"","time":1791539181105,"timeIso":"2026-10-09T09:46:21.105Z","publish":{"draft":null,"version":28,"agent":"review","message":"Client: abso.json is the project file (avcs.json still read; a new project gets abso.json unless it has either); new folders get .abso when no installed mod is older than 0.2.0; both mods are 0.2.0 (abso 253, 224)","time":1791539181568,"timeIso":"2026-10-09T09:46:21.568Z"}}]}