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

Function generateCommand

packages/bumpy/src/commands/generate.ts:41–173  ·  view source on GitHub ↗
(rootDir: string, opts: GenerateOptions)

Source from the content-addressed store, hash-verified

39};
40
41export async function generateCommand(rootDir: string, opts: GenerateOptions): Promise<void> {
42 const config = await loadConfig(rootDir);
43 const packages = await discoverPackages(rootDir, config);
44
45 // Get commits — either from explicit ref or from branch divergence point
46 let commits: { hash: string; subject: string; body: string }[];
47
48 if (opts.from) {
49 log.step(`Scanning commits from ${colorize(opts.from, 'cyan')}...`);
50 const rawLog = tryRunArgs(['git', 'log', `${opts.from}..HEAD`, '--format=%H%n%s%n%b%n---END---'], { cwd: rootDir });
51 if (!rawLog) {
52 log.info('No commits found since ' + opts.from);
53 return;
54 }
55 commits = parseGitLog(rawLog);
56 } else {
57 log.step(`Scanning commits on this branch (vs ${colorize(config.baseBranch, 'cyan')})...`);
58 commits = getBranchCommits(rootDir, config.baseBranch);
59 }
60
61 if (commits.length === 0) {
62 log.info('No commits found on this branch.');
63 return;
64 }
65
66 log.dim(` Found ${commits.length} commit(s)`);
67
68 // Build scope → package name mapping for CC resolution
69 const scopeMap = buildScopeMap(packages, config);
70
71 // Packages with directBump: false only receive propagated bumps — never suggest them
72 const isDirectlyBumpable = (name: string) => packages.get(name)?.bumpy?.directBump !== false;
73
74 // Collect releases from all commits
75 const releaseMap = new Map<string, { type: BumpType; messages: string[] }>();
76
77 let ccCount = 0;
78 let fileBasedCount = 0;
79
80 for (const commit of commits) {
81 const cc = parseConventionalCommit(commit);
82
83 if (cc) {
84 // Conventional commit — use type/scope for bump level
85 ccCount++;
86 const bump: BumpType = cc.breaking ? 'major' : BUMP_MAP[cc.type] || 'patch';
87
88 let pkgNames: string[] = [];
89 if (cc.scope) {
90 const resolved = resolveScope(cc.scope, scopeMap, packages).filter(isDirectlyBumpable);
91 if (resolved.length > 0) {
92 pkgNames = resolved;
93 }
94 // If scope didn't resolve, fall through to file-based detection below
95 }
96
97 if (pkgNames.length > 0) {
98 for (const name of pkgNames) {

Callers 1

mainFunction · 0.85

Calls 15

loadConfigFunction · 0.90
discoverPackagesFunction · 0.90
colorizeFunction · 0.90
tryRunArgsFunction · 0.90
getBranchCommitsFunction · 0.90
getFilesChangedInCommitFunction · 0.90
ensureDirFunction · 0.90
getBumpyDirFunction · 0.90
slugifyFunction · 0.90
randomNameFunction · 0.90
writeBumpFileFunction · 0.90
parseGitLogFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…