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

Function readBumpFiles

packages/bumpy/src/core/bump-file.ts:43–89  ·  view source on GitHub ↗
(rootDir: string, opts: ReadBumpFilesOptions = {})

Source from the content-addressed store, hash-verified

41
42/** Read all bump files from .bumpy/ (and optionally channel subdirs), sorted by git creation order */
43export async function readBumpFiles(rootDir: string, opts: ReadBumpFilesOptions = {}): Promise<ReadBumpFilesResult> {
44 const dir = getBumpyDir(rootDir);
45 const bumpFiles: BumpFile[] = [];
46 const errors: string[] = [];
47
48 const files = await listFiles(dir, '.md');
49 for (const file of files) {
50 if (file === 'README.md') continue;
51 const result = await parseBumpFileFromPath(resolve(dir, file));
52 if (result.bumpFile) bumpFiles.push(result.bumpFile);
53 errors.push(...result.errors);
54 }
55
56 for (const channel of opts.channels ?? []) {
57 const channelDir = resolve(dir, channel);
58 const channelFiles = await listFiles(channelDir, '.md');
59 for (const file of channelFiles) {
60 if (file === 'README.md') continue;
61 const result = await parseBumpFileFromPath(resolve(channelDir, file));
62 if (result.bumpFile) {
63 const duplicate = bumpFiles.find((bf) => bf.id === result.bumpFile!.id);
64 if (duplicate) {
65 errors.push(
66 `Bump file "${result.bumpFile.id}" exists both ${duplicate.channel ? `in .bumpy/${duplicate.channel}/` : 'at .bumpy/ root'} and in .bumpy/${channel}/ — ` +
67 'remove one copy (the change likely already shipped on one of them).',
68 );
69 continue;
70 }
71 bumpFiles.push({ ...result.bumpFile, channel });
72 }
73 errors.push(...result.errors);
74 }
75 }
76
77 // Sort by the commit date when each bump file was first added to git.
78 // Falls back to filename order for uncommitted bump files.
79 const creationOrder = getBumpFileCreationOrder(rootDir);
80 if (creationOrder.size > 0) {
81 bumpFiles.sort((a, b) => {
82 const aOrder = creationOrder.get(a.id) ?? Infinity;
83 const bOrder = creationOrder.get(b.id) ?? Infinity;
84 return aOrder - bOrder || a.id.localeCompare(b.id);
85 });
86 }
87
88 return { bumpFiles, errors };
89}
90
91/**
92 * Use `git log` to get the commit timestamp when each bump file was first added.

Callers 13

checkCommandFunction · 0.90
statusCommandFunction · 0.90
channelStatusFunction · 0.90
addCommandFunction · 0.90
versionCommandFunction · 0.90
channelVersionFunction · 0.90
ciCheckCommandFunction · 0.90
ciPlanCommandFunction · 0.90
ciReleaseCommandFunction · 0.90
ciChannelReleaseFunction · 0.90
publishChannelFunction · 0.90

Calls 4

getBumpyDirFunction · 0.90
listFilesFunction · 0.90
parseBumpFileFromPathFunction · 0.85
getBumpFileCreationOrderFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…