From 3c4b087620790f3fc481bb0fc48a8c349b29cb4c Mon Sep 17 00:00:00 2001 From: Edjan Michiles Date: Tue, 15 Sep 2026 12:02:25 +0100 Subject: [PATCH 1/2] feat(monorepo-tools): allow single repo --- .../src/utils/get-packages-in-topological-order.spec.ts | 6 ++++-- .../src/utils/get-packages-in-topological-order.ts | 7 +++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/monorepo-tools/src/utils/get-packages-in-topological-order.spec.ts b/packages/monorepo-tools/src/utils/get-packages-in-topological-order.spec.ts index 4338dd40b..c5c070ffe 100644 --- a/packages/monorepo-tools/src/utils/get-packages-in-topological-order.spec.ts +++ b/packages/monorepo-tools/src/utils/get-packages-in-topological-order.spec.ts @@ -200,14 +200,16 @@ describe('getPackagesInTopologicalOrder', function () { ); }); - it('returns empty array when there are no workspaces', async function () { + it('supports single repo without workspace', async function () { await fs.writeFile( path.join(tmpDir, 'package.json'), JSON.stringify({ name: 'root' }), ); const result = await getPackagesInTopologicalOrder(tmpDir); + const names = result.map((p) => p.name); - assert.deepStrictEqual(result, []); + assert.strictEqual(names.length, 1); + assert.ok(names.includes('root')); }); }); diff --git a/packages/monorepo-tools/src/utils/get-packages-in-topological-order.ts b/packages/monorepo-tools/src/utils/get-packages-in-topological-order.ts index d5ae643e9..fbad87561 100644 --- a/packages/monorepo-tools/src/utils/get-packages-in-topological-order.ts +++ b/packages/monorepo-tools/src/utils/get-packages-in-topological-order.ts @@ -19,10 +19,9 @@ export interface PackageInfo { export async function getPackagesInTopologicalOrder( monorepoRoot: string, ): Promise { - const patterns: string[] = - JSON.parse( - await fs.readFile(path.join(monorepoRoot, `package.json`), 'utf8'), - ).workspaces || []; + const patterns: string[] = JSON.parse( + await fs.readFile(path.join(monorepoRoot, `package.json`), 'utf8'), + ).workspaces || ['.']; // <---- default value that considers monorepo root as a "workspace" for further analysis const packageJsonPaths = await glob( // NOTE: glob patterns should always use forward slashes, From 0a5d7e4fee75bdeebd9ea572d852b282c510439e Mon Sep 17 00:00:00 2001 From: Edjan Michiles Date: Tue, 15 Sep 2026 12:05:51 +0100 Subject: [PATCH 2/2] Apply suggestion from @esvm --- .../src/utils/get-packages-in-topological-order.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/monorepo-tools/src/utils/get-packages-in-topological-order.ts b/packages/monorepo-tools/src/utils/get-packages-in-topological-order.ts index fbad87561..0f936570d 100644 --- a/packages/monorepo-tools/src/utils/get-packages-in-topological-order.ts +++ b/packages/monorepo-tools/src/utils/get-packages-in-topological-order.ts @@ -21,7 +21,7 @@ export async function getPackagesInTopologicalOrder( ): Promise { const patterns: string[] = JSON.parse( await fs.readFile(path.join(monorepoRoot, `package.json`), 'utf8'), - ).workspaces || ['.']; // <---- default value that considers monorepo root as a "workspace" for further analysis + ).workspaces || ['.']; // default value that considers monorepo root as a "workspace" for further analysis const packageJsonPaths = await glob( // NOTE: glob patterns should always use forward slashes,