From aa01a5ea7d76695f4a672abeed0fabf87399b2fe Mon Sep 17 00:00:00 2001 From: gnzjgo Date: Tue, 31 Mar 2026 11:19:15 +0200 Subject: [PATCH] Update local workspace build output label and URL format Change 'Local workspace' label to 'Tinybird Local branch'. Update local dashboard URL from cloud.tinybird.co/local/{port} to cloud.tinybird.co/{provider}/{region}/{ws}~local~{branch}. Amp-Thread-ID: https://ampcode.com/threads/T-019d4316-f38c-76c9-b714-2438ab77c79f Co-authored-by: Amp --- src/api/dashboard.test.ts | 26 ++++++++++++++++++-------- src/api/dashboard.ts | 22 +++++++++++++++------- src/cli/commands/build.ts | 15 +++++++++------ src/cli/commands/dev.ts | 15 +++++++++------ src/cli/commands/info.ts | 2 +- src/cli/commands/open-dashboard.ts | 2 +- src/cli/output.ts | 4 ++-- 7 files changed, 55 insertions(+), 31 deletions(-) diff --git a/src/api/dashboard.test.ts b/src/api/dashboard.test.ts index b14b0d2..807aadd 100644 --- a/src/api/dashboard.test.ts +++ b/src/api/dashboard.test.ts @@ -98,18 +98,28 @@ describe("getBranchDashboardUrl", () => { }); describe("getLocalDashboardUrl", () => { - it("generates local dashboard URL with default port", () => { - const result = getLocalDashboardUrl("my_local_workspace"); - expect(result).toBe("https://cloud.tinybird.co/local/7181/my_local_workspace"); + it("generates local dashboard URL with region info", () => { + const result = getLocalDashboardUrl("https://api.tinybird.co", "my_cloud_workspace", "my_local_workspace"); + expect(result).toBe("https://cloud.tinybird.co/gcp/europe-west3/my_cloud_workspace~local~my_local_workspace"); }); - it("generates local dashboard URL with custom port", () => { - const result = getLocalDashboardUrl("my_local_workspace", 8080); - expect(result).toBe("https://cloud.tinybird.co/local/8080/my_local_workspace"); + it("generates local dashboard URL for US East GCP", () => { + const result = getLocalDashboardUrl("https://api.us-east.tinybird.co", "my_cloud_workspace", "feature_branch"); + expect(result).toBe("https://cloud.tinybird.co/gcp/us-east4/my_cloud_workspace~local~feature_branch"); + }); + + it("generates local dashboard URL for AWS", () => { + const result = getLocalDashboardUrl("https://api.us-west-2.aws.tinybird.co", "my_cloud_workspace", "feature_branch"); + expect(result).toBe("https://cloud.tinybird.co/aws/us-west-2/my_cloud_workspace~local~feature_branch"); + }); + + it("returns null for unknown regions", () => { + const result = getLocalDashboardUrl("https://api.unknown.tinybird.co", "my_cloud_workspace", "feature_branch"); + expect(result).toBeNull(); }); it("handles workspace names with underscores", () => { - const result = getLocalDashboardUrl("dublin_feature_branch"); - expect(result).toBe("https://cloud.tinybird.co/local/7181/dublin_feature_branch"); + const result = getLocalDashboardUrl("https://api.tinybird.co", "tssdkgnzinit", "dublin_feature_branch"); + expect(result).toBe("https://cloud.tinybird.co/gcp/europe-west3/tssdkgnzinit~local~dublin_feature_branch"); }); }); diff --git a/src/api/dashboard.ts b/src/api/dashboard.ts index 984b5c5..21b9bbe 100644 --- a/src/api/dashboard.ts +++ b/src/api/dashboard.ts @@ -106,16 +106,24 @@ export function getBranchDashboardUrl( /** * Generate a local Tinybird dashboard URL * - * @param workspaceName - The local workspace name - * @param port - The local Tinybird port (default: 7181) - * @returns Local dashboard URL + * The URL follows the format: https://cloud.tinybird.co/{provider}/{region}/{cloudWorkspaceName}~local~{localWorkspaceName} + * + * @param apiUrl - The Tinybird API base URL (e.g., "https://api.tinybird.co") + * @param cloudWorkspaceName - The cloud workspace name (e.g., "tssdkgnzinit") + * @param localWorkspaceName - The local workspace/branch name (e.g., "rama_nuria") + * @returns Local dashboard URL or null if the API URL is not recognized * * @example * ```ts - * getLocalDashboardUrl("my_local_workspace") - * // => "https://cloud.tinybird.co/local/7181/my_local_workspace" + * getLocalDashboardUrl("https://api.tinybird.co", "tssdkgnzinit", "rama_nuria") + * // => "https://cloud.tinybird.co/gcp/europe-west3/tssdkgnzinit~local~rama_nuria" * ``` */ -export function getLocalDashboardUrl(workspaceName: string, port = 7181): string { - return `https://cloud.tinybird.co/local/${port}/${workspaceName}`; +export function getLocalDashboardUrl(apiUrl: string, cloudWorkspaceName: string, localWorkspaceName: string): string | null { + const regionInfo = parseApiUrl(apiUrl); + if (!regionInfo) { + return null; + } + + return `https://cloud.tinybird.co/${regionInfo.provider}/${regionInfo.region}/${cloudWorkspaceName}~local~${localWorkspaceName}`; } diff --git a/src/cli/commands/build.ts b/src/cli/commands/build.ts index 24a364b..842123f 100644 --- a/src/cli/commands/build.ts +++ b/src/cli/commands/build.ts @@ -135,16 +135,19 @@ export async function runBuild(options: BuildCommandOptions = {}): Promise