MCPcopy Create free account
hub / github.com/dmno-dev/bumpy / buildSnapshotReleasePlan

Function buildSnapshotReleasePlan

packages/bumpy/src/core/snapshot.ts:117–153  ·  view source on GitHub ↗
(
  stablePlan: ReleasePlan,
  snapshot: ResolvedSnapshot,
  packages: Map<string, WorkspacePackage>,
)

Source from the content-addressed store, hash-verified

115 * re-running on the same commit is a no-op; `timestamp` versions essentially never collide.
116 */
117export async function buildSnapshotReleasePlan(
118 stablePlan: ReleasePlan,
119 snapshot: ResolvedSnapshot,
120 packages: Map<string, WorkspacePackage>,
121): Promise<SnapshotReleasePlanResult> {
122 const warnings = [...stablePlan.warnings];
123 const alreadyPublished: Array<{ name: string; version: string }> = [];
124 const releases: PlannedRelease[] = [];
125
126 await Promise.all(
127 stablePlan.releases.map(async (release) => {
128 const pkg = packages.get(release.name);
129 if (!pkg) return;
130 // Unpublishable packages can't be installed from a dist-tag — nothing to snapshot
131 if (pkg.private && !pkg.bumpy?.publishCommand) return;
132
133 const target = release.newVersion; // stable target from the bump files
134 const version = snapshotVersion(target, snapshot);
135
136 // The version embeds its own uniqueness (sha/timestamp), so a collision means we
137 // already published this exact snapshot — skip to stay idempotent (re-run on the
138 // same commit). Only registry-backed packages can be checked this way.
139 if (usesNpmRegistry(pkg)) {
140 const versions = await fetchPublishedVersions(pkg.name, pkg.bumpy?.registry);
141 if (versions.includes(version)) {
142 alreadyPublished.push({ name: release.name, version });
143 return;
144 }
145 }
146
147 releases.push({ ...release, newVersion: version });
148 }),
149 );
150
151 releases.sort((a, b) => a.name.localeCompare(b.name));
152 return { plan: { bumpFiles: stablePlan.bumpFiles, releases, warnings }, alreadyPublished, warnings };
153}
154
155/** One-line summary of a snapshot plan's versions, for logs and PR comments */
156export function formatSnapshotVersionSummary(releases: PlannedRelease[]): string {

Callers 2

snapshot.test.tsFile · 0.90
publishSnapshotFunction · 0.90

Calls 3

usesNpmRegistryFunction · 0.90
fetchPublishedVersionsFunction · 0.90
snapshotVersionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…