Skip to content

Commit 044c6ff

Browse files
committed
Surface failed web builds in CLI
1 parent 2fc3110 commit 044c6ff

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

src/projects/cli.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,24 @@ describe("runProjectSubcommand", () => {
237237
expect(result.stdout.join("\n")).toContain("preview: https://codebase.design/preview/proj-1");
238238
});
239239

240+
it("fails a terminal build and prints the server reason", async () => {
241+
const result = await runProject(
242+
["project", "build", "--wait", "Build", "a", "demo"],
243+
fakeClient({
244+
status: {
245+
sessionId: "sess-1",
246+
status: "failed",
247+
projectId: "proj-1",
248+
error: "active-project cap reached (1)",
249+
},
250+
}),
251+
);
252+
253+
expect(result.code).toBe(1);
254+
expect(result.stdout.join("\n")).toContain("build sess-1: failed");
255+
expect(result.stdout.join("\n")).toContain("error: active-project cap reached (1)");
256+
});
257+
240258
it("streams deduplicated file and phase progress while waiting", async () => {
241259
let calls = 0;
242260
const statuses: BuildStatusResponse[] = [

src/projects/cli.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ async function buildCmd(
330330
if (previewUrl) handoffStore?.update({ sessionId: started.sessionId, previewUrl });
331331
return 0;
332332
}
333-
return status.status === "failed" ? 1 : 0;
333+
return 1;
334334
}
335335

336336
async function waitForBuild(
@@ -408,7 +408,7 @@ async function statusCmd(
408408
const status = await client.getBuildStatus(resolved.sessionId);
409409
handoffStore?.update({ sessionId: resolved.sessionId, status: status.status, model: status.model });
410410
printBuildStatus(status, out);
411-
return status.status === "failed" ? 1 : 0;
411+
return status.status === "completed" || status.status === "building" ? 0 : 1;
412412
}
413413

414414
async function previewCmd(
@@ -472,6 +472,7 @@ function resolveBuildSessionId(
472472

473473
function printBuildStatus(status: BuildStatusResponse, out: (msg: string) => void): void {
474474
out(`build ${status.sessionId}: ${status.status}`);
475+
if (status.error) out(` error: ${status.error}`);
475476
if (status.projectId) out(` project: ${status.projectId}`);
476477
if (status.model) out(` model: ${status.model}`);
477478
const files = uniqueStrings(status.filesCreated);

src/projects/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export interface BuildStartResponse {
4141
export interface BuildStatusResponse {
4242
sessionId: string;
4343
status: string;
44+
error?: string;
4445
projectId?: string;
4546
filesCreated?: string[];
4647
model?: string;

0 commit comments

Comments
 (0)