#!/usr/bin/env node // Package the confirmed clips nobody has been sent yet. // // node bin/share-batch.mjs --project --name // // Spawned by the Deliver panel through lib/jobs.ts, for the reason every other // long step is spawned: a 53-clip batch is two encodes per clip, its ffmpeg // children have to be killable as a group, and its progress has to be a log // somebody can read while it runs. // // The work is lib/report/deliver.mjs's, so `umtool` and the button cannot // produce different batches. import process from "node:process"; import { resolveProject } from "../lib/projects/core.mjs"; import { buildShareBatch } from "../lib/report/deliver.mjs"; import { isDeliverableName } from "../lib/report/storage.mjs"; const argv = process.argv.slice(2); const val = (flag) => { const i = argv.indexOf(flag); return i < 0 ? null : argv[i + 1]; }; const projectArg = val("--project"); const name = val("--name"); if (!projectArg || !name) { console.error("usage: share-batch.mjs --project --name "); process.exit(2); } if (!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(name) || !isDeliverableName(`share-${name}`)) { // The second test: `x.incoming` and `x.moved-` are what a cut move of // share-x leaves behind (release 17), so a batch may not be called that. console.error(`"${name}" is not a batch name: letters, digits, dot, dash and underscore, not ending .incoming or .moved-…`); process.exit(2); } const r = await resolveProject(projectArg); if (!r.project) { console.error(`no project matches "${projectArg}"`); process.exit(2); } try { await buildShareBatch(r.project, name, { log: (l) => console.log(l) }); } catch (e) { console.error(e instanceof Error ? e.message : String(e)); process.exit(1); }