MCPcopy Index your code
hub / github.com/dmno-dev/bumpy / versionCommand

Function versionCommand

packages/bumpy/src/commands/version.ts:20–99  ·  view source on GitHub ↗
(rootDir: string, opts: VersionOptions = {})

Source from the content-addressed store, hash-verified

18}
19
20export async function versionCommand(rootDir: string, opts: VersionOptions = {}): Promise<void> {
21 const config = await loadConfig(rootDir);
22
23 const channel = resolveActiveChannel(rootDir, config, opts.channel);
24 if (channel) {
25 await channelVersion(rootDir, config, channel, { commit: opts.commit });
26 return;
27 }
28
29 const packages = await discoverPackages(rootDir, config);
30 const depGraph = new DependencyGraph(packages);
31 // Include channel subdirs — bump files that shipped as prereleases are pending
32 // for the stable release (promotion consumes them).
33 const { bumpFiles, errors: parseErrors } = await readBumpFiles(rootDir, { channels: channelNames(config) });
34
35 if (parseErrors.length > 0) {
36 for (const err of parseErrors) {
37 log.error(err);
38 }
39 throw new Error('Bump file parse errors must be fixed before versioning.');
40 }
41
42 if (bumpFiles.length === 0) {
43 log.info('No pending bump files.');
44 return;
45 }
46
47 const plan = assembleReleasePlan(bumpFiles, packages, depGraph, config);
48
49 if (plan.releases.length === 0) {
50 log.warn('Bump files found but no packages would be released.');
51 return;
52 }
53
54 // Show warnings from the release plan
55 if (plan.warnings.length > 0) {
56 for (const w of plan.warnings) {
57 log.warn(w);
58 }
59 console.log();
60 }
61
62 // Show what will happen
63 log.step('Applying version bumps:');
64 for (const r of plan.releases) {
65 const tag = r.isDependencyBump ? ' (dep)' : r.isCascadeBump ? ' (cascade)' : '';
66 console.log(` ${r.name}: ${r.oldVersion} → ${colorize(r.newVersion, 'cyan')}${tag}`);
67 }
68
69 // Apply the plan
70 await applyReleasePlan(plan, packages, rootDir, config);
71
72 log.success(`🐸 Updated ${plan.releases.length} package(s)`);
73 log.dim(` Deleted ${bumpFiles.length} bump file(s)`);
74
75 // Update lockfile so it stays in sync with bumped versions
76 await updateLockfile(rootDir);
77

Callers 3

mainFunction · 0.85
autoPublishFunction · 0.85
createVersionPrFunction · 0.85

Calls 13

loadConfigFunction · 0.90
resolveActiveChannelFunction · 0.90
discoverPackagesFunction · 0.90
readBumpFilesFunction · 0.90
channelNamesFunction · 0.90
assembleReleasePlanFunction · 0.90
colorizeFunction · 0.90
applyReleasePlanFunction · 0.90
runArgsFunction · 0.90
tryRunArgsFunction · 0.90
resolveCommitMessageFunction · 0.90
channelVersionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…