From 4f4b00fa50a23294b058423032188a2846b086c4 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Tue, 8 Sep 2026 18:09:34 +0000 Subject: [PATCH] fix: bootstrap root publish locations --- src/publish/__tests__/discover-location.js | 32 ++++++++++++++++++++++ src/publish/discover-location.js | 4 +++ 2 files changed, 36 insertions(+) diff --git a/src/publish/__tests__/discover-location.js b/src/publish/__tests__/discover-location.js index 7b522a6..6276c6c 100644 --- a/src/publish/__tests__/discover-location.js +++ b/src/publish/__tests__/discover-location.js @@ -16,6 +16,38 @@ test("retains checkout-path behavior when the root config is absent", () => { ).toEqual({ path: "./packages/cli" }); }); +test("does not discover workspaces for the checkout root", () => { + const execFile = vi.fn(() => { + throw new Error("workspace list is unavailable"); + }); + + expect( + discoverLocation({ + input: { path: "." }, + repositoryDirectory: "__repo__", + exists: () => true, + execFile, + }) + ).toEqual({ path: "." }); + expect(execFile).not.toHaveBeenCalled(); +}); + +test("fails closed when non-root workspace discovery is unavailable", () => { + const execFile = vi.fn(() => { + throw new Error("workspace list is unavailable"); + }); + + expect(() => + discoverLocation({ + input: { path: "./packages/cli" }, + repositoryDirectory: "__repo__", + exists: () => true, + execFile, + }) + ).toThrow("workspace list is unavailable"); + expect(execFile).toHaveBeenCalledOnce(); +}); + test("discovers exact workspace paths using the released Craft image", () => { const execFile = vi.fn(() => '["packages/CLI"]'); diff --git a/src/publish/discover-location.js b/src/publish/discover-location.js index 5885443..e013c10 100644 --- a/src/publish/discover-location.js +++ b/src/publish/discover-location.js @@ -48,6 +48,10 @@ function discoverLocation({ exists, execFile, }) { + if (input.path === ".") { + return { path: "." }; + } + return resolvePublishLocation({ path: input.path, workspaceNames: getWorkspaceNames({ repositoryDirectory, exists, execFile }),