()
| 250 | } |
| 251 | |
| 252 | async 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 |
no test coverage detected