Skip to content

Commit e7fe2b7

Browse files
authored
fix: consolidate messages for unpublished packages (#1761)
We currently send a message per unpublished version. However, a package that has many versions unpublished will pollute the logs with many messages. This PR consolidates those messages into one message that can be collapsed so that the logs are much easier to parse. No tests; this only affects logging ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 42103e7 commit e7fe2b7

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

src/__tests__/__snapshots__/construct-hub.test.ts.snap

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/__tests__/devapp/__snapshots__/snapshot.test.ts.snap

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/package-sources/npmjs/npm-js-follower.lambda.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,16 +529,15 @@ function getRelevantVersionInfos(
529529
Unit.Count
530530
);
531531

532+
const unpublishedVersions: string[] = [];
532533
for (const [version, modified] of packageVersionUpdates) {
533534
const knownKey = `${change.doc.name}@${version}`;
534535
const known = knownVersions.get(knownKey);
535536
if (known == null || known < modified) {
536537
const infos = change.doc.versions[version];
537538
if (infos == null) {
538539
// Could be the version in question was un-published.
539-
console.log(
540-
`[${change.seq}] Could not find info for "${change.doc.name}@${version}". Was it un-published?`
541-
);
540+
unpublishedVersions.push(knownKey);
542541
} else if (isConstructLibrary(infos)) {
543542
// skip if this package is denied
544543
const denied = denyList.lookup(infos.name, infos.version);
@@ -579,6 +578,16 @@ function getRelevantVersionInfos(
579578
// Else this is not a construct library, so we'll just ignore it...
580579
}
581580
}
581+
582+
if (unpublishedVersions.length > 0) {
583+
console.log(
584+
`[${
585+
change.seq
586+
}] Could not find info for the following versions. Were they un-published?\n${unpublishedVersions.join(
587+
',\n'
588+
)}`
589+
);
590+
}
582591
}
583592
return result;
584593

0 commit comments

Comments
 (0)