MCPcopy Create free account
hub / github.com/decaporg/decap-cms / main

Function main

scripts/verify-published-packages.mjs:316–399  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

314}
315
316async function main() {
317 const { registry, allowMissing, expectTag, allowUnattested } = parseArgs(process.argv.slice(2));
318 const head = git(['rev-parse', 'HEAD']);
319 const packages = getPublishablePackages().map(pkg => ({
320 ...pkg,
321 releasedAtHead: releasedAtHead(pkg.name, pkg.version),
322 }));
323 const context = { head, expectTag, allowUnattested };
324
325 log(`Verifying ${packages.length} publishable packages against ${registry}`);
326 log(
327 `Provenance must name ${head} for the ${
328 packages.filter(p => p.releasedAtHead).length
329 } released at HEAD` + (expectTag ? `; dist-tags.${expectTag} must equal the tree version` : ''),
330 );
331
332 const broken = [];
333 let missing = [];
334 const settling = [];
335
336 for (const pkg of packages) {
337 const { name, version } = pkg;
338 const { status, issues } = await checkPackage(registry, pkg, context);
339
340 if (status === 'broken') {
341 broken.push({ name, version, issues });
342 error(`${name}@${version} failed verification:`);
343 for (const issue of issues) {
344 error(` ${issue}`);
345 }
346 } else if (status === 'missing') {
347 // The whole pkg, so the re-check still knows whether to demand provenance.
348 missing.push({ ...pkg, status });
349 log(` ${name}@${version} is not on the registry yet`);
350 } else if (status === 'settling') {
351 settling.push({ ...pkg, status, issues });
352 log(` ${name}@${version} is published, its provenance is not readable yet`);
353 } else {
354 log(` ${name}@${version} OK`);
355 }
356 }
357
358 // Absent versions and provenance may simply not have propagated yet, so give
359 // the registry time to catch up before calling the release broken.
360 const pending = [...(allowMissing ? [] : missing), ...settling];
361 if (pending.length > 0) {
362 log(`\nWaiting up to ${PROPAGATION_SETTLE_MS / 60000} minutes for the registry to catch up`);
363 const settled = await waitForPropagation(registry, pending, context);
364 if (!allowMissing) {
365 missing = settled.missing;
366 }
367 broken.push(...settled.broken);
368 }
369
370 log('\n=== Summary ===');
371 log(`verified: ${packages.length - broken.length - missing.length}`);
372 log(`missing: ${missing.length}`);
373 log(`broken: ${broken.length}`);

Callers 1

Calls 10

gitFunction · 0.85
releasedAtHeadFunction · 0.85
checkPackageFunction · 0.85
waitForPropagationFunction · 0.85
mapMethod · 0.80
filterMethod · 0.80
parseArgsFunction · 0.70
getPublishablePackagesFunction · 0.70
logFunction · 0.70
errorFunction · 0.70

Tested by

no test coverage detected