Open History to see the last commit
1import * as NodeServices from "@effect/platform-node/NodeServices";
2import { assert, it } from "@effect/vitest";
3import { ConfigProvider, Effect, Option } from "effect";
4
5import {
6 resolveBuildOptions,
7 resolveDesktopBuildIconAssets,
8 resolveDesktopProductName,
9 resolveDesktopUpdateChannel,
10 resolveMockUpdateServerPort,
11 resolveMockUpdateServerUrl,
12} from "./build-desktop-artifact.ts";
13import { BRAND_ASSET_PATHS } from "./lib/brand-assets.ts";
14
15it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
16 it("resolves the dedicated nightly updater channel from nightly versions", () => {
17 assert.equal(resolveDesktopUpdateChannel("0.0.17-nightly.20260413.42"), "nightly");
18 assert.equal(resolveDesktopUpdateChannel("0.0.17"), "latest");
19 });
20
21 it("switches desktop packaging product names to nightly for nightly builds", () => {
22 assert.equal(resolveDesktopProductName("0.0.17"), "T3 Code (Alpha)");
23 assert.equal(resolveDesktopProductName("0.0.17-nightly.20260413.42"), "T3 Code (Nightly)");
24 });
25
26 it("switches desktop packaging icons to the nightly artwork for nightly versions", () => {
27 assert.deepStrictEqual(resolveDesktopBuildIconAssets("0.0.17"), {
28 macIconPng: BRAND_ASSET_PATHS.productionMacIconPng,
29 linuxIconPng: BRAND_ASSET_PATHS.productionLinuxIconPng,
30 windowsIconIco: BRAND_ASSET_PATHS.productionWindowsIconIco,
31 });
32
33 assert.deepStrictEqual(resolveDesktopBuildIconAssets("0.0.17-nightly.20260413.42"), {
34 macIconPng: BRAND_ASSET_PATHS.nightlyMacIconPng,
35 linuxIconPng: BRAND_ASSET_PATHS.nightlyLinuxIconPng,
36 windowsIconIco: BRAND_ASSET_PATHS.nightlyWindowsIconIco,
37 });
38 });
39
40 it("falls back to the default mock update port when the configured port is blank", () => {
41 assert.equal(resolveMockUpdateServerUrl(undefined), "http://localhost:3000");
42 assert.equal(resolveMockUpdateServerUrl(4123), "http://localhost:4123");
43 });
44
45 it.effect("normalizes mock update server ports from env-style strings", () =>
46 Effect.gen(function* () {
47 assert.equal(yield* resolveMockUpdateServerPort(undefined), undefined);
48 assert.equal(yield* resolveMockUpdateServerPort(""), undefined);
49 assert.equal(yield* resolveMockUpdateServerPort(" "), undefined);
50 assert.equal(yield* resolveMockUpdateServerPort("4123"), 4123);
51 }),
52 );
53
54 it.effect("rejects non-numeric or out-of-range mock update ports", () =>
55 Effect.gen(function* () {
56 const invalidPorts = ["abc", "12.5", "0", "65536"];
57 for (const port of invalidPorts) {
58 const exit = yield* Effect.exit(resolveMockUpdateServerPort(port));
59 assert.equal(exit._tag, "Failure");
60 }
61 }),
62 );
63
64 it.effect("preserves explicit false boolean flags over true env defaults", () =>
65 Effect.gen(function* () {
66 const resolved = yield* resolveBuildOptions({
67 platform: Option.some("mac"),
68 target: Option.none(),
69 arch: Option.some("arm64"),
70 buildVersion: Option.none(),
71 outputDir: Option.some("release-test"),
72 skipBuild: Option.some(false),
73 keepStage: Option.some(false),
74 signed: Option.some(false),
75 verbose: Option.some(false),
76 mockUpdates: Option.some(false),
77 mockUpdateServerPort: Option.none(),
78 }).pipe(
79 Effect.provide(
80 ConfigProvider.layer(
81 ConfigProvider.fromEnv({
82 env: {
83 T3CODE_DESKTOP_SKIP_BUILD: "true",
84 T3CODE_DESKTOP_KEEP_STAGE: "true",
85 T3CODE_DESKTOP_SIGNED: "true",
86 T3CODE_DESKTOP_VERBOSE: "true",
87 T3CODE_DESKTOP_MOCK_UPDATES: "true",
88 },
89 }),
90 ),
91 ),
92 );
93
94 assert.equal(resolved.skipBuild, false);
95 assert.equal(resolved.keepStage, false);
96 assert.equal(resolved.signed, false);
97 assert.equal(resolved.verbose, false);
98 assert.equal(resolved.mockUpdates, false);
99 }),
100 );
101});