mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-10 02:30:39 +01:00
Every image the API returns now goes through one persistence path (design/src/persist.ts): mkdir, exclusive `wx` claim that bumps x.png -> x-2.png ... x-999.png, write, fsync, close. A failure after the bytes arrived removes the claimed file and keeps a 0600 recovery copy in the temp dir; empty image data is a failure, never a 0-byte PNG. The API call is the only thing inside each retry loop, so a local save failure never buys a second image (variants, iterate fallback, generate --retry). generate, iterate, evolve and variants (both branches) print the same run fields (requested, saved, selected, failures, recovered) on every exit, with exit 0 / 2 (nothing saved) / 3 (stopped after saving). Each generate --retry attempt is its own saved image listed in `attempts`. compare accepts --images-file and JSON-array --images. The gallery lists bumped names, orders history by mtime then board-images.json, and marks approvals by approved_path. New bin/gstack-design-claim publishes staged images without clobbering; bin/gstack-design-approved resolves an approval record (legacy letter-only records still resolve; a missing approved_path is an error, never a substitute). Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
25 lines
803 B
TypeScript
Executable File
25 lines
803 B
TypeScript
Executable File
#!/usr/bin/env bun
|
|
// gstack-design-approved — print the absolute path of the image an
|
|
// approved.json names.
|
|
//
|
|
// Usage: gstack-design-approved <approved.json>
|
|
//
|
|
// Prefers approved_path (relative to approved.json's directory). Legacy
|
|
// records with only approved_variant resolve to variant-<letter>.png. When the
|
|
// named image is missing, exits 1 with "approved image <path> is missing;
|
|
// reselect from the board" and never substitutes another image.
|
|
|
|
import { resolveApprovedImage } from '../design/src/approval';
|
|
|
|
const file = process.argv[2];
|
|
if (!file) {
|
|
console.error('Usage: gstack-design-approved <approved.json>');
|
|
process.exit(1);
|
|
}
|
|
const resolved = resolveApprovedImage(file);
|
|
if (!resolved.ok) {
|
|
console.error(resolved.error);
|
|
process.exit(1);
|
|
}
|
|
console.log(resolved.path);
|