Skip to content

Commit deca5eb

Browse files
committed
Support single-package (non-monorepo) repos
Instead of throwing "No workspace globs found" when no workspace configuration is detected, treat the root directory as the only package. Also default relativeDir to "." for root packages.
1 parent d7c5b71 commit deca5eb

1 file changed

Lines changed: 19 additions & 12 deletions

File tree

packages/bumpy/src/core/workspace.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,31 @@ export interface WorkspaceDiscoveryResult {
1010
catalogs: CatalogMap;
1111
}
1212

13-
/** Discover all workspace packages and catalogs in a monorepo */
13+
/** Discover all workspace packages and catalogs in a monorepo or single-package repo */
1414
export async function discoverWorkspace(rootDir: string, config: BumpyConfig): Promise<WorkspaceDiscoveryResult> {
1515
const { globs, catalogs } = await detectWorkspaces(rootDir);
16-
if (globs.length === 0) {
17-
throw new Error('No workspace globs found. Is this a monorepo?');
18-
}
1916

2017
const packages = new Map<string, WorkspacePackage>();
21-
for (const glob of globs) {
22-
const dirs = await resolveGlob(rootDir, glob);
23-
for (const dir of dirs) {
24-
const pkg = await loadWorkspacePackage(dir, rootDir, config);
25-
if (pkg) {
26-
if (!isPackageManaged(pkg.name, pkg.private, config, pkg.bumpy)) continue;
27-
packages.set(pkg.name, pkg);
18+
19+
if (globs.length === 0) {
20+
// Single-package repo — treat the root as the only package
21+
const pkg = await loadWorkspacePackage(rootDir, rootDir, config);
22+
if (pkg && isPackageManaged(pkg.name, pkg.private, config, pkg.bumpy)) {
23+
packages.set(pkg.name, pkg);
24+
}
25+
} else {
26+
for (const glob of globs) {
27+
const dirs = await resolveGlob(rootDir, glob);
28+
for (const dir of dirs) {
29+
const pkg = await loadWorkspacePackage(dir, rootDir, config);
30+
if (pkg) {
31+
if (!isPackageManaged(pkg.name, pkg.private, config, pkg.bumpy)) continue;
32+
packages.set(pkg.name, pkg);
33+
}
2834
}
2935
}
3036
}
37+
3138
return { packages, catalogs };
3239
}
3340

@@ -131,7 +138,7 @@ async function loadWorkspacePackage(
131138
name,
132139
version: (pkg.version as string) || '0.0.0',
133140
dir: resolve(dir),
134-
relativeDir: relative(rootDir, dir),
141+
relativeDir: relative(rootDir, dir) || '.',
135142
packageJson: pkg,
136143
private: !!pkg.private,
137144
dependencies: (pkg.dependencies as Record<string, string>) || {},

0 commit comments

Comments
 (0)