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

Function writeTransientVersionsInPlace

packages/bumpy/src/core/prerelease.ts:201–232  ·  view source on GitHub ↗
(
  plan: ReleasePlan,
  packages: Map<string, WorkspacePackage>,
)

Source from the content-addressed store, hash-verified

199 * combination of packages installed from the dist-tag resolves to the
200 * coherent set it was published with.
201 */
202export async function writeTransientVersionsInPlace(
203 plan: ReleasePlan,
204 packages: Map<string, WorkspacePackage>,
205): Promise<() => Promise<void>> {
206 const releaseMap = new Map(plan.releases.map((r) => [r.name, r]));
207 const originals = new Map<string, string>();
208
209 for (const release of plan.releases) {
210 const pkg = packages.get(release.name);
211 if (!pkg) continue;
212 const pkgJsonPath = resolve(pkg.dir, 'package.json');
213 originals.set(pkgJsonPath, await readText(pkgJsonPath));
214
215 await updateJsonFields(pkgJsonPath, { version: release.newVersion });
216
217 // Exact-pin in-cycle deps (dev deps excluded — not installed by consumers)
218 for (const depField of ['dependencies', 'peerDependencies', 'optionalDependencies'] as const) {
219 const deps = pkg[depField];
220 for (const depName of Object.keys(deps)) {
221 const depRelease = releaseMap.get(depName);
222 if (!depRelease) continue;
223 await updateJsonNestedField(pkgJsonPath, depField, depName, depRelease.newVersion);
224 }
225 }
226 }
227
228 return async () => {
229 for (const [path, content] of originals) {
230 await writeText(path, content);
231 }
232 };
233}
234
235/**

Callers 3

prerelease.test.tsFile · 0.90
publishChannelFunction · 0.90
publishSnapshotFunction · 0.90

Calls 4

readTextFunction · 0.90
updateJsonFieldsFunction · 0.90
updateJsonNestedFieldFunction · 0.90
writeTextFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…