Skip to content

Commit c2fc2d9

Browse files
committed
fix(publish-smoke): de-duplicate the registry-leak diagnostic across lockfile sections
A name is keyed in both `packages:` and `snapshots:`, so counting lines listed every offender twice and inflated the tarball-resolved total. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c42d740 commit c2fc2d9

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

scripts/publish-smoke.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -539,29 +539,33 @@ const names = Object.keys(JSON.parse(readFileSync(overridesPath, 'utf8')));
539539
const lock = readFileSync(lockPath, 'utf8').split(/\r?\n/);
540540
541541
const esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
542-
const leaked = [];
543-
let pinnedCount = 0;
542+
// Sets, not arrays: a name is keyed in BOTH the `packages:` and `snapshots:`
543+
// sections, so counting lines would report every package twice.
544+
const leaked = new Set();
545+
const pinned = new Set();
544546
for (const name of names) {
545547
// Lockfile key lines: optional quote, the exact package name, '@', spec.
546548
const key = new RegExp(`^\\s*'?${esc(name)}@([^']+?)'?:\\s*$`);
547549
for (const line of lock) {
548550
const m = key.exec(line);
549551
if (!m) continue;
550-
if (m[1].startsWith('file:')) pinnedCount += 1;
551-
else if (/^[0-9]/.test(m[1])) leaked.push(`${name}@${m[1]}`);
552+
if (m[1].startsWith('file:')) pinned.add(name);
553+
else if (/^[0-9]/.test(m[1])) leaked.add(`${name}@${m[1]}`);
552554
}
553555
}
554556
555-
if (leaked.length > 0) {
557+
if (leaked.size > 0) {
556558
console.error('::error::these PINNED packages resolved from the npm registry:');
557-
for (const l of leaked.sort()) console.error(` ${l}`);
559+
for (const l of [...leaked].sort()) console.error(` ${l}`);
558560
console.error(
559561
'The publish-smoke-pack.mjs override map has a hole, so the smoke tested ' +
560562
'PUBLISHED code instead of the release candidate.',
561563
);
562564
process.exit(1);
563565
}
564-
console.log(` ok — ${pinnedCount} tarball-resolved lockfile entries, 0 registry leaks (${names.length} names checked)`);
566+
console.log(
567+
` ok — ${pinned.size}/${names.length} pinned packages resolved from tarballs, 0 registry leaks`,
568+
);
565569
EOF
566570
else
567571
log "Scaffolding $APP_NAME with published create-objectstack@latest"

0 commit comments

Comments
 (0)