Write HTML. Render video. Built for agents.
JavaScript aiai-agentsanimationclaude-codeffmpegframeworkgsaphtmlhtml-to-videomcpmotion-graphicspuppeteerrenderingtypescriptvideo-editor
fix(cli): ask to log in when publishing needs an account (#5670)
Miguel Ángel917ee5d31342
diff --git a/packages/cli/src/utils/publishProject.test.ts b/packages/cli/src/utils/publishProject.test.tsindex da3ea5421c..2679a3915f 100644--- a/packages/cli/src/utils/publishProject.test.ts+++ b/packages/cli/src/utils/publishProject.test.ts@@ -1124,6 +1124,22 @@ describe("publishProjectArchive with a credential the server rejects", () => {await publishExpecting(fetchMock, EXPIRED);});+ it("asks a signed-out publish to log in when the upload route answers 401, with no fallback", async () => {+ const fetchMock = vi.fn().mockResolvedValueOnce(unauthorized());+ vi.stubGlobal("fetch", fetchMock);+ const dir = makeProjectDir();+ try {+ writeFileSync(join(dir, "index.html"), "<html></html>", "utf-8");+ await expect(publishProjectArchive(dir)).rejects.toThrow(+ "Publishing needs an account. Run hyperframes auth login to publish.",+ );+ } finally {+ rmSync(dir, { recursive: true, force: true });+ }+ expect(fetchMock).toHaveBeenCalledTimes(1);+ expect(fetchMock.mock.calls[0]![0]).toMatch(/\/publish\/upload$/);+ });+it("does not blame the login for a 401 from the storage upload, which carries no credential", async () => {const fetchMock = vi.fn()diff --git a/packages/cli/src/utils/publishProject.ts b/packages/cli/src/utils/publishProject.tsindex 339cbf7cbf..c8ad5f958b 100644--- a/packages/cli/src/utils/publishProject.ts+++ b/packages/cli/src/utils/publishProject.ts@@ -166,6 +166,7 @@ async function metadataRequestError(response: Response, fallback: string): Promi}const LOGIN_EXPIRED = "Your login expired. Run hyperframes auth login, then publish again.";+const LOGIN_REQUIRED = "Publishing needs an account. Run hyperframes auth login to publish.";const LOGIN_CHANGED = "Your login changed during publish. Run publish again.";function rejectedCredentialMessage(credential: ResolvedCredential): string {const envVar = envCredentialVar(credential.source);@@ -797,8 +798,8 @@ export async function publishProjectArchive(throw new CredentialRejectedError("unclaimed publish");}} catch (error) {- if (error instanceof CredentialRejectedError && credential) {- throw new Error(rejectedCredentialMessage(credential));+ if (error instanceof CredentialRejectedError) {+ throw new Error(credential ? rejectedCredentialMessage(credential) : LOGIN_REQUIRED);}throw error;}