MCPcopy Create free account
hub / github.com/codename-co/stack / main

Function main

packages/scripts/maintenance/sync-metadata.ts:252–370  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

250}
251
252async function main() {
253 // `--reject` is a bookkeeping operation, not a sync: record and stop.
254 if (REJECTED.length) {
255 if (!REASON) {
256 console.error("--reject requires --reason (an unexplained override is unmaintainable)");
257 process.exit(1);
258 }
259 for (const target of REJECTED) {
260 const [slug, field] = target.split(":");
261 if (!slug || !field) {
262 console.error(`--reject expects <slug>:<field>, got "${target}"`);
263 process.exit(1);
264 }
265 const entry = listStacks("hub", [slug])[0];
266 if (!entry) {
267 console.error(`unknown app: ${slug}`);
268 process.exit(1);
269 }
270 // Pin the rejection to the value upstream reports right now, so a later,
271 // different value is surfaced again instead of being silently swallowed.
272 const result = await syncEntry(entry).catch(() => null);
273 const upstream = result?.suggestions.find((s) => s.field === field);
274 recordRejection(slug, field, String(upstream?.to ?? ""), REASON);
275 console.log(`recorded: ${slug}.${field} stays curated (${REASON})`);
276 }
277 console.log(`updated ${OVERRIDES_FILE}`);
278 return;
279 }
280
281 const stacks = listStacks("hub", ONLY);
282 if (!stacks.length) {
283 console.error("no stacks matched");
284 process.exit(1);
285 }
286 console.error(
287 `syncing metadata for ${stacks.length} stacks (concurrency ${CONCURRENCY})${
288 CHECK ? " [check only]" : ""
289 }`
290 );
291
292 let done = 0;
293 const results = await pool(stacks, CONCURRENCY, async (entry) => {
294 let result: Result;
295 try {
296 result = await syncEntry(entry);
297 } catch (e) {
298 result = {
299 slug: entry.slug,
300 changes: [],
301 suggestions: [],
302 notes: [`error: ${(e as Error).message}`],
303 };
304 }
305 done++;
306 if (done % 25 === 0) console.error(` ${done}/${stacks.length}`);
307 return result;
308 });
309

Callers 1

sync-metadata.tsFile · 0.70

Calls 5

listStacksFunction · 0.90
recordRejectionFunction · 0.90
poolFunction · 0.90
syncEntryFunction · 0.85
logMethod · 0.80

Tested by

no test coverage detected