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

Function addCommand

packages/bumpy/src/commands/add.ts:24–174  ·  view source on GitHub ↗
(rootDir: string, opts: AddOptions)

Source from the content-addressed store, hash-verified

22}
23
24export async function addCommand(rootDir: string, opts: AddOptions): Promise<void> {
25 const config = await loadConfig(rootDir);
26 const bumpyDir = getBumpyDir(rootDir);
27 await ensureDir(bumpyDir);
28
29 // Handle --empty flag
30 if (opts.empty) {
31 const filename = opts.name ? slugify(opts.name) : randomName();
32 const filePath = resolve(bumpyDir, `${filename}.md`);
33 const { writeText } = await import('../utils/fs.ts');
34 await writeText(filePath, '---\n---\n');
35 log.success(`🐸 Created empty bump file: .bumpy/${filename}.md`);
36 return;
37 }
38
39 // Handle --none flag: create bump file with all changed packages set to none
40 if (opts.none) {
41 const { packages } = await discoverWorkspace(rootDir, config);
42 const changedFiles = getChangedFiles(rootDir, config.baseBranch);
43 const changedPackages = await findChangedPackages(changedFiles, packages, rootDir, config);
44
45 if (changedPackages.length === 0) {
46 log.info('No changed packages detected.');
47 return;
48 }
49
50 const releases: BumpFileRelease[] = changedPackages.map((name) => ({ name, type: 'none' as const }));
51 const summary = opts.message || '';
52 const filename = opts.name ? slugify(opts.name) : randomName();
53
54 if (await exists(resolve(bumpyDir, `${filename}.md`))) {
55 await writeBumpFile(rootDir, `${filename}-${Date.now()}`, releases, summary);
56 } else {
57 await writeBumpFile(rootDir, filename, releases, summary);
58 }
59
60 log.success(`🐸 Created bump file with ${changedPackages.length} package(s) set to none: .bumpy/${filename}.md`);
61 for (const name of changedPackages) {
62 log.dim(` ${name}: none`);
63 }
64 return;
65 }
66
67 let releases: BumpFileRelease[];
68 let summary: string;
69 let filename: string;
70
71 if (opts.packages) {
72 // Non-interactive mode
73 releases = parsePackagesFlag(opts.packages);
74 summary = opts.message || '';
75 filename = opts.name ? slugify(opts.name) : randomName();
76 } else {
77 // Interactive mode
78 p.intro(pc.bgCyan(pc.black(' bumpy add ')));
79
80 const { packages: pkgs } = await discoverWorkspace(rootDir, config);
81 if (pkgs.size === 0) {

Callers 1

mainFunction · 0.85

Calls 15

loadConfigFunction · 0.90
getBumpyDirFunction · 0.90
ensureDirFunction · 0.90
slugifyFunction · 0.90
randomNameFunction · 0.90
discoverWorkspaceFunction · 0.90
getChangedFilesFunction · 0.90
findChangedPackagesFunction · 0.90
existsFunction · 0.90
writeBumpFileFunction · 0.90
readBumpFilesFunction · 0.90
filterBranchBumpFilesFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…