{"file":"client/src/export.ts","version":45,"total":152,"from":1,"to":152,"lines":[{"n":1,"text":"// abso export <dir> [--version N]: one published version of this folder's","atom":"a0","author":"init","version":0},{"n":2,"text":"// space, written to a folder of its own, for a build that doesn't move while","atom":"a0","author":"init","version":0},{"n":3,"text":"// shared does (#37). The folder gets .abso-export naming the","atom":"a386","author":"infra-split","version":39},{"n":4,"text":"// version, to stamp the build with: JSON on one line, in a file with no","atom":"a250","author":"pinch","version":29},{"n":5,"text":"// extension, so the exported project's own formatter and linter pass it by.","atom":"a250","author":"pinch","version":29},{"n":6,"text":"// Exporting again replaces the folder, keeping node_modules (and what --keep","atom":"a250","author":"pinch","version":29},{"n":7,"text":"// names) so a build needs no new install.","atom":"a250","author":"pinch","version":29},{"n":8,"text":"//","atom":"a0","author":"init","version":0},{"n":9,"text":"// The version is rebuilt as `abso run --at` rebuilds it (at.ts), from the","atom":"a0","author":"init","version":0},{"n":10,"text":"// known copies and one compare; the server's listing of that version (#37)","atom":"a386","author":"infra-split","version":39},{"n":11,"text":"// then checks that no file is left out.","atom":"a386","author":"infra-split","version":39},{"n":12,"text":"","atom":"a0","author":"init","version":0},{"n":13,"text":"import { chmodSync, existsSync, mkdirSync, readdirSync, rmSync, statSync, writeFileSync } from \"node:fs\";","atom":"a0","author":"init","version":0},{"n":14,"text":"import { dirname, join, resolve } from \"node:path\";","atom":"a0","author":"init","version":0},{"n":15,"text":"import type { Where } from \"./api.ts\";","atom":"a0","author":"init","version":0},{"n":16,"text":"import { type Parsed, str, UsageError } from \"./args.ts\";","atom":"a0","author":"init","version":0},{"n":17,"text":"import { globTest, snapshotAt, snapshotEntries } from \"./at.ts\";","atom":"a0","author":"init","version":0},{"n":18,"text":"import { type Env, type Output, open, plural } from \"./commands.ts\";","atom":"a0","author":"init","version":0},{"n":19,"text":"import { ignoredHere } from \"./fetch.ts\";","atom":"a0","author":"init","version":0},{"n":20,"text":"import { loadIgnore, relativeTo } from \"./folder.ts\";","atom":"a0","author":"init","version":0},{"n":21,"text":"import { type Refused, unsafePath } from \"./safety.ts\";","atom":"a0","author":"init","version":0},{"n":22,"text":"","atom":"a0","author":"init","version":0},{"n":23,"text":"/** The file an export leaves in its folder: what it holds, and the sign that the folder is one export may replace. */","atom":"a0","author":"init","version":0},{"n":24,"text":"export const EXPORT_STAMP = \".abso-export\";","atom":"a250","author":"pinch","version":29},{"n":25,"text":"/** Its earlier names: an export made then still counts as one. A .json name drew the project's formatter. */","atom":"a250","author":"pinch","version":29},{"n":26,"text":"const OLD_EXPORT_STAMPS = [\".abso-export.json\", \".avcs-export.json\"];","atom":"a250","author":"pinch","version":29},{"n":27,"text":"","atom":"a0","author":"init","version":0},{"n":28,"text":"/** Where an export may go: outside the abso folder, or in a part of it abso leaves out. Empty, or an earlier export. */","atom":"a0","author":"init","version":0},{"n":29,"text":"function checkTarget(root: string, target: string): void {","atom":"a0","author":"init","version":0},{"n":30,"text":"\tconst inside = relativeTo(root, target);","atom":"a0","author":"init","version":0},{"n":31,"text":"\tif (inside === undefined && (target === root || relativeTo(target, root) !== undefined)) {","atom":"a0","author":"init","version":0},{"n":32,"text":"\t\tthrow new UsageError(`${target} holds this abso folder; export to a folder of its own`);","atom":"a0","author":"init","version":0},{"n":33,"text":"\t}","atom":"a0","author":"init","version":0},{"n":34,"text":"\tif (inside !== undefined && !ignoredHere(loadIgnore(root), inside, true)) {","atom":"a0","author":"init","version":0},{"n":35,"text":"\t\tthrow new UsageError(","atom":"a0","author":"init","version":0},{"n":36,"text":"\t\t\t`${inside} is inside this abso folder, so abso would record the export as your edits. Export outside the folder, or into a folder .absoignore leaves out`,","atom":"a204","author":"review","version":27},{"n":37,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":38,"text":"\t}","atom":"a0","author":"init","version":0},{"n":39,"text":"\tif (!existsSync(target)) return;","atom":"a0","author":"init","version":0},{"n":40,"text":"\tif (!statSync(target).isDirectory()) throw new UsageError(`${target} is a file; export to a folder`);","atom":"a0","author":"init","version":0},{"n":41,"text":"\tif (","atom":"a204","author":"review","version":27},{"n":42,"text":"\t\treaddirSync(target).length > 0 &&","atom":"a204","author":"review","version":27},{"n":43,"text":"\t\t![EXPORT_STAMP, ...OLD_EXPORT_STAMPS].some((n) => existsSync(join(target, n)))","atom":"a250","author":"pinch","version":29},{"n":44,"text":"\t) {","atom":"a204","author":"review","version":27},{"n":45,"text":"\t\tthrow new UsageError(","atom":"a0","author":"init","version":0},{"n":46,"text":"\t\t\t`${target} has files in it; export to an empty folder (an export replaces only a folder an earlier export made)`,","atom":"a0","author":"init","version":0},{"n":47,"text":"\t\t);","atom":"a0","author":"init","version":0},{"n":48,"text":"\t}","atom":"a0","author":"init","version":0},{"n":49,"text":"}","atom":"a0","author":"init","version":0},{"n":50,"text":"","atom":"a0","author":"init","version":0},{"n":51,"text":"/**","atom":"a0","author":"init","version":0},{"n":52,"text":" * Empties an earlier export for the next, except what `keep` names: node_modules","atom":"a0","author":"init","version":0},{"n":53,"text":" * always (abso never exports it, and an install takes a while), and --keep's","atom":"a0","author":"init","version":0},{"n":54,"text":" * globs. Returns the kept paths, the top-most of each.","atom":"a0","author":"init","version":0},{"n":55,"text":" */","atom":"a0","author":"init","version":0},{"n":56,"text":"function clearExport(dir: string, keep: (rel: string) => boolean, rel = \"\"): string[] {","atom":"a0","author":"init","version":0},{"n":57,"text":"\tconst kept: string[] = [];","atom":"a0","author":"init","version":0},{"n":58,"text":"\tfor (const e of readdirSync(join(dir, ...rel.split(\"/\").filter(Boolean)), { withFileTypes: true })) {","atom":"a0","author":"init","version":0},{"n":59,"text":"\t\tconst path = rel === \"\" ? e.name : `${rel}/${e.name}`;","atom":"a0","author":"init","version":0},{"n":60,"text":"\t\tconst full = join(dir, ...path.split(\"/\"));","atom":"a0","author":"init","version":0},{"n":61,"text":"\t\tif (e.name === \"node_modules\" || keep(path)) {","atom":"a0","author":"init","version":0},{"n":62,"text":"\t\t\tkept.push(path);","atom":"a0","author":"init","version":0},{"n":63,"text":"\t\t\tcontinue;","atom":"a0","author":"init","version":0},{"n":64,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":65,"text":"\t\tif (e.isDirectory() && !e.isSymbolicLink()) {","atom":"a0","author":"init","version":0},{"n":66,"text":"\t\t\tconst inner = clearExport(dir, keep, path);","atom":"a0","author":"init","version":0},{"n":67,"text":"\t\t\tkept.push(...inner);","atom":"a0","author":"init","version":0},{"n":68,"text":"\t\t\tif (inner.length > 0) continue;","atom":"a0","author":"init","version":0},{"n":69,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":70,"text":"\t\trmSync(full, { recursive: true, force: true });","atom":"a0","author":"init","version":0},{"n":71,"text":"\t}","atom":"a0","author":"init","version":0},{"n":72,"text":"\treturn kept;","atom":"a0","author":"init","version":0},{"n":73,"text":"}","atom":"a0","author":"init","version":0},{"n":74,"text":"","atom":"a0","author":"init","version":0},{"n":75,"text":"export async function runExport(args: Parsed, env: Env): Promise<Output> {","atom":"a0","author":"init","version":0},{"n":76,"text":"\tif (args.positionals.length !== 1)","atom":"a0","author":"init","version":0},{"n":77,"text":"\t\tthrow new UsageError(\"export takes the folder to write: abso export <dir> [--version <N>]\");","atom":"a0","author":"init","version":0},{"n":78,"text":"\tconst { root, config, api } = open(env);","atom":"a0","author":"init","version":0},{"n":79,"text":"\tconst target = resolve(env.cwd, args.positionals[0]!);","atom":"a0","author":"init","version":0},{"n":80,"text":"\tcheckTarget(root, target);","atom":"a0","author":"init","version":0},{"n":81,"text":"\tconst rawVersion = str(args, \"version\");","atom":"a0","author":"init","version":0},{"n":82,"text":"\tif (rawVersion !== undefined && !/^\\d+$/.test(rawVersion))","atom":"a0","author":"init","version":0},{"n":83,"text":"\t\tthrow new UsageError(`--version is a version number (got ${JSON.stringify(rawVersion)})`);","atom":"a0","author":"init","version":0},{"n":84,"text":"\tconst diff = await api.diff();","atom":"a0","author":"init","version":0},{"n":85,"text":"\tconst where: Where = { draft: diff.draft };","atom":"a0","author":"init","version":0},{"n":86,"text":"\t// The listing names the version (the newest by default) and every file it holds; a server from before it answers 404.","atom":"a0","author":"init","version":0},{"n":87,"text":"\tconst listing = await api","atom":"a0","author":"init","version":0},{"n":88,"text":"\t\t.filesAt(diff.draft, rawVersion === undefined ? undefined : Number(rawVersion))","atom":"a0","author":"init","version":0},{"n":89,"text":"\t\t.catch(() => undefined);","atom":"a0","author":"init","version":0},{"n":90,"text":"\tconst version =","atom":"a0","author":"init","version":0},{"n":91,"text":"\t\trawVersion !== undefined ? Number(rawVersion) : (listing?.version ?? (await api.log(where, 1)).version);","atom":"a0","author":"init","version":0},{"n":92,"text":"\tconst snap = await snapshotAt(root, api, version);","atom":"a0","author":"init","version":0},{"n":93,"text":"\tconst skipped: Refused[] = [];","atom":"a0","author":"init","version":0},{"n":94,"text":"\tif (listing !== undefined) {","atom":"a0","author":"init","version":0},{"n":95,"text":"\t\tconst holds = new Set(listing.files);","atom":"a0","author":"init","version":0},{"n":96,"text":"\t\tfor (const rel of [...snap.files.keys()]) if (!holds.has(rel)) snap.files.delete(rel);","atom":"a0","author":"init","version":0},{"n":97,"text":"\t\t// Files the known copies lack (a folder that missed some, #37): asked for one by one.","atom":"a0","author":"init","version":0},{"n":98,"text":"\t\tfor (const rel of listing.files) {","atom":"a0","author":"init","version":0},{"n":99,"text":"\t\t\tif (snap.files.has(rel)) continue;","atom":"a0","author":"init","version":0},{"n":100,"text":"\t\t\tconst file = await api.fileAt(rel, version, where);","atom":"a0","author":"init","version":0},{"n":101,"text":"\t\t\tif (file.text !== null) snap.files.set(rel, { text: file.text });","atom":"a0","author":"init","version":0},{"n":102,"text":"\t\t\telse","atom":"a0","author":"init","version":0},{"n":103,"text":"\t\t\t\tskipped.push({","atom":"a0","author":"init","version":0},{"n":104,"text":"\t\t\t\t\tpath: rel,","atom":"a0","author":"init","version":0},{"n":105,"text":"\t\t\t\t\twhy: \"a binary file this folder has no copy of; abso sync --full, then export again\",","atom":"a0","author":"init","version":0},{"n":106,"text":"\t\t\t\t});","atom":"a0","author":"init","version":0},{"n":107,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":108,"text":"\t}","atom":"a0","author":"init","version":0},{"n":109,"text":"\tconst entries = await snapshotEntries(api, snap);","atom":"a0","author":"init","version":0},{"n":110,"text":"\t// Built before anything is removed, so a failed export leaves an earlier one whole.","atom":"a0","author":"init","version":0},{"n":111,"text":"\tconst keepGlob = str(args, \"keep\");","atom":"a0","author":"init","version":0},{"n":112,"text":"\tconst kept = existsSync(target) ? clearExport(target, keepGlob === undefined ? () => false : globTest(keepGlob)) : [];","atom":"a0","author":"init","version":0},{"n":113,"text":"\tmkdirSync(target, { recursive: true });","atom":"a0","author":"init","version":0},{"n":114,"text":"\tlet written = 0;","atom":"a0","author":"init","version":0},{"n":115,"text":"\tfor (const e of entries) {","atom":"a0","author":"init","version":0},{"n":116,"text":"\t\tconst why = unsafePath(e.path) ?? (e.link !== undefined ? \"it is a link; export makes none\" : undefined);","atom":"a0","author":"init","version":0},{"n":117,"text":"\t\tif (why !== undefined) {","atom":"a0","author":"init","version":0},{"n":118,"text":"\t\t\tskipped.push({ path: e.path, why });","atom":"a0","author":"init","version":0},{"n":119,"text":"\t\t\tcontinue;","atom":"a0","author":"init","version":0},{"n":120,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":121,"text":"\t\tconst path = join(target, ...e.path.split(\"/\"));","atom":"a0","author":"init","version":0},{"n":122,"text":"\t\tmkdirSync(dirname(path), { recursive: true });","atom":"a0","author":"init","version":0},{"n":123,"text":"\t\twriteFileSync(path, e.data);","atom":"a0","author":"init","version":0},{"n":124,"text":"\t\tif (e.mode !== undefined) {","atom":"a0","author":"init","version":0},{"n":125,"text":"\t\t\ttry {","atom":"a0","author":"init","version":0},{"n":126,"text":"\t\t\t\tchmodSync(path, e.mode);","atom":"a0","author":"init","version":0},{"n":127,"text":"\t\t\t} catch {","atom":"a0","author":"init","version":0},{"n":128,"text":"\t\t\t\t// The bit is a convenience here.","atom":"a0","author":"init","version":0},{"n":129,"text":"\t\t\t}","atom":"a0","author":"init","version":0},{"n":130,"text":"\t\t}","atom":"a0","author":"init","version":0},{"n":131,"text":"\t\twritten++;","atom":"a0","author":"init","version":0},{"n":132,"text":"\t}","atom":"a0","author":"init","version":0},{"n":133,"text":"\tconst space = diff.draft === null ? \"shared\" : `draft ${diff.draft}`;","atom":"a0","author":"init","version":0},{"n":134,"text":"\tconst stamp = {","atom":"a0","author":"init","version":0},{"n":135,"text":"\t\tproject: config.project,","atom":"a0","author":"init","version":0},{"n":136,"text":"\t\tspace: diff.draft ?? \"shared\",","atom":"a0","author":"init","version":0},{"n":137,"text":"\t\tversion,","atom":"a0","author":"init","version":0},{"n":138,"text":"\t\tfiles: written,","atom":"a0","author":"init","version":0},{"n":139,"text":"\t\texportedAt: new Date().toISOString(),","atom":"a0","author":"init","version":0},{"n":140,"text":"\t};","atom":"a0","author":"init","version":0},{"n":141,"text":"\twriteFileSync(join(target, EXPORT_STAMP), `${JSON.stringify(stamp)}\\n`);","atom":"a251","author":"pinch","version":29},{"n":142,"text":"\treturn {","atom":"a0","author":"init","version":0},{"n":143,"text":"\t\ttext: [","atom":"a0","author":"init","version":0},{"n":144,"text":"\t\t\t`Exported version ${version} of ${space} to ${target}: ${plural(written, \"file\")}. ${EXPORT_STAMP} there names the version; abso export to the same folder replaces it.`,","atom":"a0","author":"init","version":0},{"n":145,"text":"\t\t\t...(kept.length > 0 ? [`Kept from the earlier export: ${kept.join(\", \")}.`] : []),","atom":"a0","author":"init","version":0},{"n":146,"text":"\t\t\t...(skipped.length > 0","atom":"a0","author":"init","version":0},{"n":147,"text":"\t\t\t\t? [`Not exported (${skipped.length}):`, ...skipped.map((s) => `  ${s.path}: ${s.why}`)]","atom":"a0","author":"init","version":0},{"n":148,"text":"\t\t\t\t: []),","atom":"a0","author":"init","version":0},{"n":149,"text":"\t\t].join(\"\\n\"),","atom":"a0","author":"init","version":0},{"n":150,"text":"\t\tjson: { ...stamp, dir: target, kept, skipped },","atom":"a0","author":"init","version":0},{"n":151,"text":"\t};","atom":"a0","author":"init","version":0},{"n":152,"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":"a204","author":"review","message":"","time":1791533506483,"timeIso":"2026-10-09T08:11:46.483Z","publish":{"draft":null,"version":27,"agent":"review","message":"Client: ABSO_ environment names (AVCS_ still read), .absoignore (.avcsignore still read), .abso-export.json, shot files; READMEs say abso (abso 224)","time":1791533840174,"timeIso":"2026-10-09T08:17:20.174Z"}},{"atom":"a250","author":"pinch","message":"","time":1791539664482,"timeIso":"2026-10-09T09:54:24.482Z","publish":{"draft":null,"version":29,"agent":"pinch","message":"Client: abso issue N --save-attachments <dir> saves each attachment on an issue and its comments once (an SVG's own file beside its drawing), outside the abso folder unless the place is ignored; MCP confines the folder like attach. abso export now stamps its folder with .abso-export, one line of JSON in a file with no extension, so the exported project's own formatter and linter pass it by; a folder stamped .abso-export.json or .avcs-export.json still counts as an export.","time":1791540340754,"timeIso":"2026-10-09T10:05:40.754Z"}},{"atom":"a251","author":"pinch","message":"","time":1791539666315,"timeIso":"2026-10-09T09:54:26.315Z","publish":{"draft":null,"version":29,"agent":"pinch","message":"Client: abso issue N --save-attachments <dir> saves each attachment on an issue and its comments once (an SVG's own file beside its drawing), outside the abso folder unless the place is ignored; MCP confines the folder like attach. abso export now stamps its folder with .abso-export, one line of JSON in a file with no extension, so the exported project's own formatter and linter pass it by; a folder stamped .abso-export.json or .avcs-export.json still counts as an export.","time":1791540340754,"timeIso":"2026-10-09T10:05:40.754Z"}},{"atom":"a386","author":"infra-split","message":"","time":1791548567277,"timeIso":"2026-10-09T12:22:47.277Z","publish":{"draft":null,"version":39,"agent":"infra-split","message":"More comments and test names give their reason without naming who raised it\n\nThe same cleanup as version 37, for notes it missed because they were wrapped or worded differently: \"(#37, Playtester 1)\" becomes \"(#37)\", \"(#39, agreed with Engine)\" becomes \"(#39)\", and a commit hash after a name goes with the name. Issue numbers stay. No behavior changes.","time":1791548569542,"timeIso":"2026-10-09T12:22:49.542Z"}}]}