Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/publish/browser-workflow.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { rootLogger } from "../util/logger.js";
import { mkdir, writeFile } from "node:fs/promises";
import { dirname } from "node:path";
import { createStoredSession, loadSession, saveSession } from "../auth/session-store.js";
Expand Down Expand Up @@ -26,6 +27,8 @@ import {
type TransportResolution,
} from "./transport.js";

const log = rootLogger.child({ component: "browser-workflow" });

export interface WorkflowStep {
name: string;
status: "ok" | "error";
Expand Down Expand Up @@ -127,13 +130,13 @@ export async function runBrowserWorkflow(
);
await maybeWriteTrace(result, options.traceOut);
await maybeWriteWorkflowRunLog(options, requirePublicationUrl(config), prepared, result);
console.log(JSON.stringify(result, null, 2));
log.info(result);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep successful workflow results on stdout

When draft, publish, or schedule uses the local browser path (and likewise the Browserbase path at line 169), this replaces the command's only JSON result with a Pino info event; createLogger writes exclusively to stderr and can suppress the event through LOG_LEVEL. Consequently, successful browser-backed commands now leave stdout empty, breaking command substitution and consumers that need the status, draft ID, or published URL after a live write. Keep the workflow result as command output and reserve the logger for diagnostics.

Useful? React with 👍 / 👎.

} catch (error) {
if (error instanceof LocalWorkflowError) {
const result = buildFailedWorkflowResult(error, prepared, transport);
await maybeWriteTrace(result, options.traceOut);
await maybeWriteWorkflowRunLog(options, requirePublicationUrl(config), prepared, result);
console.error(JSON.stringify(result, null, 2));
log.error(result);
}
throw error;
}
Expand Down Expand Up @@ -163,7 +166,7 @@ export async function runBrowserWorkflow(
const result = await createDraftInBrowser(session, prepared, options, transport);
await maybeWriteTrace(result, options.traceOut);
await maybeWriteWorkflowRunLog(options, session.publicationUrl, prepared, result);
console.log(JSON.stringify(result, null, 2));
log.info(result);
} catch (error) {
if (error instanceof BrowserWorkflowError) {
const result = {
Expand All @@ -176,7 +179,7 @@ export async function runBrowserWorkflow(
};
await maybeWriteTrace(result, options.traceOut);
await maybeWriteWorkflowRunLog(options, session.publicationUrl, prepared, result);
console.error(JSON.stringify(result, null, 2));
log.error(result);
}

throw error;
Expand Down Expand Up @@ -291,7 +294,7 @@ async function createDraftInBrowser(
);

if (options.experimentalInjectState) {
console.warn(
log.warn(
"Experimental editor-state injection is planned but not yet implemented. Falling back to the paste-based default path.",
);
}
Expand Down Expand Up @@ -447,7 +450,7 @@ async function createDraftInBrowser(
const url = await session.page.url();
const isReviewUrl = /\/publish\//.test(url) || /\/post\//.test(url);
if (!isReviewUrl) {
console.warn(
log.warn(
`Warning: Current URL "${url}" does not look like a publish review screen. Expected URL containing "/publish/" or "/post/".`,
);
}
Expand Down
Loading