Skip to content
Merged
Show file tree
Hide file tree
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
25 changes: 25 additions & 0 deletions packages/cli/src/utils/desktopApp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ import {
previewStopCommandFor,
} from "./desktopApp.js";

// Only the distro probe is faked, so each Linux case says which family it runs on.
let linuxFamily = "fedora";
vi.mock("../browser/linuxDeps.js", async (importOriginal) => ({
...(await importOriginal<typeof import("../browser/linuxDeps.js")>()),
detectLinuxDistro: () => ({ family: linuxFamily, isWsl: false }),
}));
afterEach(() => {
linuxFamily = "fedora";
});

const LIVE = { ready: true, platform: "darwin" as const, env: {}, installed: () => true };
const MAC_DOWNLOAD = "https://hyperframes.studio/studio/download?src=cli";
const MAC_HINT = `Keep editing by chatting with Framey in the HyperFrames desktop app → ${MAC_DOWNLOAD}`;
Expand Down Expand Up @@ -579,6 +589,21 @@ describe("desktopHint", () => {
expect(desktopHint(process.cwd(), { ...mac, ready: true, installed: false })).toBe(MAC_HINT);
});

it("offers Debian and Ubuntu the .deb, other Linux systems the AppImage", () => {
const hint = (family: string) => {
linuxFamily = family;
return desktopHint(process.cwd(), {
env: {},
platform: "linux",
installed: false,
tty: true,
});
};
expect(hint("debian")).toContain("/studio/download?os=deb&src=cli");
expect(hint("arch")).toContain("/studio/download?os=linux&src=cli");
expect(hint("unknown")).toContain("/studio/download?os=linux&src=cli");
});

it("offers the Linux and Windows builds there, and nothing where there is no build", () => {
expect(
desktopHint(process.cwd(), { env: {}, platform: "linux", installed: false, tty: true }),
Expand Down
6 changes: 4 additions & 2 deletions packages/cli/src/utils/desktopApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { isAgentDriven } from "../telemetry/agent_runtime.js";
import { readRecord, removeRecord, writeRecord } from "./projectRecords.js";
import { shellArg } from "./shellArg.js";
import { projectEnvDir } from "./dotEnv.js";
import { detectLinuxDistro } from "../browser/linuxDeps.js";

// The HyperFrames desktop app, then builds named in HYPERFRAMES_DESKTOP_BUNDLE_IDS / _APP_NAMES (comma-separated).
const list = (name: string): string[] =>
Expand All @@ -26,9 +27,10 @@ const DEFAULT_APP = "the HyperFrames desktop app";
const STUDIO_PAGE = "https://hyperframes.studio/studio";
const DOWNLOADS: Partial<Record<NodeJS.Platform, string>> = {
darwin: `${STUDIO_PAGE}/download`,
linux: `${STUDIO_PAGE}/download?os=linux`,
win32: `${STUDIO_PAGE}/download?os=windows`,
};
const debOnDebianFamilyElseAppImage = () =>
`${STUDIO_PAGE}/download?os=${detectLinuxDistro().family === "debian" ? "deb" : "linux"}`;

export type DownloadSource = "cli" | "browser-editor";

Expand All @@ -40,7 +42,7 @@ export const desktopDownloadUrl = (
platform = process.platform,
src: DownloadSource = "cli",
): string | null => {
const url = DOWNLOADS[platform];
const url = platform === "linux" ? debOnDebianFamilyElseAppImage() : DOWNLOADS[platform];
return url ? tagged(url, src) : null;
};

Expand Down
Loading