Skip to content

Commit b76b529

Browse files
committed
feat(cli): offer the HyperFrames app download on Windows
The CLI and Studio now point Windows to the app download. Studio names the Windows download in its install steps.
1 parent acd0bc3 commit b76b529

5 files changed

Lines changed: 63 additions & 14 deletions

File tree

‎packages/cli/src/server/desktopRoutes.test.ts‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,41 @@ describe("open-in-desktop routes", () => {
4545
});
4646
});
4747

48-
it("shows the button where the app is installed even without a download (Windows)", async () => {
48+
it("shows the button where the app is installed even without a download (FreeBSD)", async () => {
4949
const get = async (installed: boolean) =>
5050
(
51-
await server(true, { platform: "win32", installed: () => installed }).app.request(
51+
await server(true, { platform: "freebsd", installed: () => installed }).app.request(
5252
"/api/open-in-desktop",
5353
)
5454
).json();
5555
expect(await get(true)).toEqual({
5656
available: true,
5757
handoff: true,
5858
downloadUrl: null,
59-
os: "win32",
59+
os: "freebsd",
6060
installed: true,
6161
});
6262
expect(await get(false)).toMatchObject({ available: false });
6363
});
6464

65+
it("offers the Windows download, and the hand-off once the app is installed", async () => {
66+
const get = async (installed: boolean) =>
67+
(
68+
await server(true, { platform: "win32", installed: () => installed }).app.request(
69+
"/api/open-in-desktop",
70+
)
71+
).json();
72+
const downloadUrl = "https://hyperframes.dev/studio/download?os=windows";
73+
expect(await get(false)).toEqual({
74+
available: true,
75+
handoff: false,
76+
downloadUrl,
77+
os: "win32",
78+
installed: false,
79+
});
80+
expect(await get(true)).toMatchObject({ available: true, handoff: true, downloadUrl });
81+
});
82+
6583
it("offers the hand-off only where the app is installed, so a press without it goes to the download", async () => {
6684
const get = async (installed: boolean) =>
6785
(

‎packages/cli/src/utils/desktopApp.test.ts‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ describe("openInDesktop on Windows", () => {
143143
expect(missing).toEqual({
144144
opened: false,
145145
reason: "not-installed",
146-
downloadUrl: "https://hyperframes.dev/studio",
146+
downloadUrl: `${MAC_DOWNLOAD}?os=windows`,
147147
});
148148
const failed = openInDesktop(FILM, { ...WIN, exists: () => true, launch: () => false });
149149
expect(failed).toMatchObject({ opened: false, reason: "open-failed" });
@@ -327,12 +327,20 @@ describe("desktopHint", () => {
327327
expect(desktopHint(process.cwd(), { ...mac, ready: true, installed: false })).toBe(MAC_HINT);
328328
});
329329

330-
it("offers the Linux build on Linux, and nothing on Windows without the app", () => {
330+
it("offers the Linux and Windows builds there, and nothing where there is no build", () => {
331331
expect(desktopHint(process.cwd(), { env: {}, platform: "linux", installed: false })).toBe(
332332
`Keep editing by chatting with Framey in the HyperFrames desktop app → ${MAC_DOWNLOAD}?os=linux`,
333333
);
334-
expect(desktopHint(process.cwd(), { env: {}, platform: "win32", installed: false })).toBeNull();
335-
expect(desktopHint(process.cwd(), { env: {}, platform: "win32", ready: true })).toBeNull();
334+
const windowsHint = `Keep editing by chatting with Framey in the HyperFrames desktop app → ${MAC_DOWNLOAD}?os=windows`;
335+
expect(desktopHint(process.cwd(), { env: {}, platform: "win32", installed: false })).toBe(
336+
windowsHint,
337+
);
338+
expect(desktopHint(process.cwd(), { env: {}, platform: "win32", ready: true })).toBe(
339+
windowsHint,
340+
);
341+
expect(
342+
desktopHint(process.cwd(), { env: {}, platform: "freebsd", installed: false }),
343+
).toBeNull();
336344
});
337345

338346
it("points an installed Windows app to `hyperframes open`", () => {

‎packages/cli/src/utils/desktopApp.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ const STUDIO_PAGE = "https://hyperframes.dev/studio";
1515
const DOWNLOADS: Partial<Record<NodeJS.Platform, string>> = {
1616
darwin: `${STUDIO_PAGE}/download`,
1717
linux: `${STUDIO_PAGE}/download?os=linux`,
18+
win32: `${STUDIO_PAGE}/download?os=windows`,
1819
};
1920

20-
/** This machine's build of the app; null where there is none yet (Windows). */
21+
/** This machine's build of the app; null where there is none. */
2122
export const desktopDownloadUrl = (platform = process.platform): string | null =>
2223
DOWNLOADS[platform] ?? null;
2324

‎packages/studio/src/components/DesktopGuideCard.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export type DesktopRoute = {
1515

1616
/** The OS for the download, and what "this …" calls the machine. */
1717
const platformName = (os: string): string =>
18-
os === "darwin" ? "Mac" : os === "linux" ? "Linux" : "your computer";
18+
os === "darwin" ? "Mac" : os === "linux" ? "Linux" : os === "win32" ? "Windows" : "your computer";
1919
const deviceName = (os: string): string => (os === "darwin" ? "Mac" : "computer");
2020

2121
const NOTE = "mt-0.5 text-step-12 text-text-2 text-pretty";

‎packages/studio/src/components/OpenInDesktopButton.dom.test.tsx‎

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,19 +103,19 @@ it("stays hidden where the server has no hand-off (the desktop's own Studio)", a
103103
expect(button()).toBeNull();
104104
});
105105

106-
it("stays hidden when the app has no build for this machine (Windows)", async () => {
106+
it("stays hidden when the app has no build for this machine (FreeBSD)", async () => {
107107
serve(Response.json({ available: false, handoff: true, downloadUrl: null }));
108108
await mount();
109109
expect(button()).toBeNull();
110110
});
111111

112-
it("with the app installed but no download (Windows), shows only once the app can take the project", async () => {
112+
it("with the app installed but no download (FreeBSD), shows only once the app can take the project", async () => {
113113
serve(Response.json({ available: true, handoff: false, downloadUrl: null }));
114114
await mount();
115115
expect(button()).toBeNull();
116116
});
117117

118-
it("opens the project in an installed app that has no download (Windows)", async () => {
118+
it("opens the project in an installed app that has no download (FreeBSD)", async () => {
119119
serve(Response.json({ available: true, handoff: true, downloadUrl: null }), {
120120
opened: true,
121121
app: "the HyperFrames desktop app",
@@ -381,6 +381,28 @@ it("where the app is installed but cannot take a project (Linux), step 3 shows t
381381
expect(posts).toBe(0);
382382
});
383383

384+
it("on Windows, step 1 names the Windows download and opens it tagged", async () => {
385+
const opened: string[] = [];
386+
vi.stubGlobal("open", (url: string) => (opened.push(url), { opener: {} }));
387+
serve(
388+
Response.json({
389+
available: true,
390+
handoff: false,
391+
downloadUrl: `${DOWNLOAD}?os=windows`,
392+
os: "win32",
393+
installed: false,
394+
}),
395+
);
396+
await mount();
397+
expect(button()).not.toBeNull();
398+
await act(async () => button()!.click());
399+
await act(async () => cardButton("Download for Windows")!.click());
400+
expect(opened).toEqual([tagged(`${DOWNLOAD}?os=windows`)]);
401+
expect(events("desktop_cta_eligibility")).toEqual([
402+
{ eligibility: "download", os: "win32", app_installed: false, download_available: true },
403+
]);
404+
});
405+
384406
it("counts where the button can show, the app here, and platforms with no app", async () => {
385407
serve(
386408
Response.json({
@@ -402,7 +424,7 @@ it("counts where the button can show, the app here, and platforms with no app",
402424
available: false,
403425
handoff: false,
404426
downloadUrl: null,
405-
os: "win32",
427+
os: "freebsd",
406428
installed: false,
407429
}),
408430
);
@@ -411,7 +433,7 @@ it("counts where the button can show, the app here, and platforms with no app",
411433
expect(events("desktop_cta_eligibility")).toEqual([
412434
{
413435
eligibility: "no_app_for_platform",
414-
os: "win32",
436+
os: "freebsd",
415437
app_installed: false,
416438
download_available: false,
417439
},

0 commit comments

Comments
 (0)