overlay-factory-worker 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/overlay-worker.ts +11 -2
- package/scripts/series.ts +8 -1
package/package.json
CHANGED
|
@@ -180,8 +180,17 @@ type Job = {
|
|
|
180
180
|
const ROOT = join(__dirname, "..");
|
|
181
181
|
const PUBLIC = join(ROOT, "public");
|
|
182
182
|
|
|
183
|
-
/**
|
|
184
|
-
|
|
183
|
+
/**
|
|
184
|
+
* A one-off's directory name — the same for its preview and its burn.
|
|
185
|
+
*
|
|
186
|
+
* The id comes from the server, and the result is a folder the worker later
|
|
187
|
+
* deletes, so anything that isn't a plain job id is refused rather than
|
|
188
|
+
* trusted to stay inside series/.
|
|
189
|
+
*/
|
|
190
|
+
const singleSlug = (id: string) => {
|
|
191
|
+
if (!/^[0-9a-f]{8}-[0-9a-f-]{4,}$/i.test(id)) throw new Error("Bad one-off id");
|
|
192
|
+
return `single-${id.slice(0, 8).toLowerCase()}`;
|
|
193
|
+
};
|
|
185
194
|
|
|
186
195
|
/**
|
|
187
196
|
* Run a script, and on failure raise the part a human wrote.
|
package/scripts/series.ts
CHANGED
|
@@ -450,6 +450,8 @@ const draftFiles = async (
|
|
|
450
450
|
};
|
|
451
451
|
|
|
452
452
|
const NOTES_FILE = "notes.md";
|
|
453
|
+
/** Marks a one-off's folder, so the sweep never touches a real series. */
|
|
454
|
+
const ONE_OFF_MARKER = ".one-off";
|
|
453
455
|
const HISTORY_DIR = join(SERIES_DIR, ".history");
|
|
454
456
|
const KEEP_VERSIONS = 5;
|
|
455
457
|
|
|
@@ -474,7 +476,7 @@ const writeSeries = (
|
|
|
474
476
|
const out = join(SERIES_DIR, slug);
|
|
475
477
|
const notes = readNotes(slug);
|
|
476
478
|
|
|
477
|
-
if (existsSync(join(out, "series.json")) && !
|
|
479
|
+
if (existsSync(join(out, "series.json")) && !existsSync(join(out, ONE_OFF_MARKER))) {
|
|
478
480
|
const hist = join(HISTORY_DIR, slug);
|
|
479
481
|
mkdirSync(hist, { recursive: true });
|
|
480
482
|
cpSync(out, join(hist, new Date().toISOString().replace(/[:.]/g, "-")), {
|
|
@@ -925,6 +927,10 @@ export const sweepSingles = (maxAgeMs = 24 * 60 * 60 * 1000) => {
|
|
|
925
927
|
for (const d of readdirSync(SERIES_DIR, { withFileTypes: true })) {
|
|
926
928
|
if (!d.isDirectory() || !d.name.startsWith("single-")) continue;
|
|
927
929
|
const p = join(SERIES_DIR, d.name);
|
|
930
|
+
// Only folders generateSingle marked. A real series can have a single-
|
|
931
|
+
// slug (the site now refuses new ones, but older ones may exist), and
|
|
932
|
+
// this deletes without a backup.
|
|
933
|
+
if (!existsSync(join(p, ONE_OFF_MARKER))) continue;
|
|
928
934
|
try {
|
|
929
935
|
if (Date.now() - statSync(p).mtimeMs > maxAgeMs) {
|
|
930
936
|
rmSync(p, { recursive: true, force: true });
|
|
@@ -974,6 +980,7 @@ export const generateSingle = async (input: {
|
|
|
974
980
|
}),
|
|
975
981
|
"Overlay generation",
|
|
976
982
|
);
|
|
983
|
+
writeFileSync(join(SERIES_DIR, input.slug, ONE_OFF_MARKER), "");
|
|
977
984
|
return {
|
|
978
985
|
layers: seriesLayers(input.slug, {}, input.durationSec, input.brand ?? null),
|
|
979
986
|
cleanup,
|