()
| 314 | } |
| 315 | |
| 316 | async 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}`); |
no test coverage detected