Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

build-desktop-artifact.test.ts

648 lines23.8 KB

1import * as NodeServices from "@effect/platform-node/NodeServices";
2import { assert, it } from "@effect/vitest";
3import * as ConfigProvider from "effect/ConfigProvider";
4import * as Effect from "effect/Effect";
5import * as Layer from "effect/Layer";
6import * as Option from "effect/Option";
7import * as Sink from "effect/Sink";
8import * as Stream from "effect/Stream";
9import { ChildProcessSpawner } from "effect/unstable/process";
10​
11import {
12 BuildCommandFailedError,
13 createStageWorkspaceConfig,
14 createStagePatchedDependencies,
15 createBuildConfig,
16 DESKTOP_ASAR_UNPACK,
17 InvalidMacPasskeyRpDomainError,
18 InvalidMacPasskeyPublishableKeyError,
19 InvalidMockUpdateServerPortError,
20 isMacPasskeySigningConfigurationError,
21 LinuxIconResizeError,
22 MacPasskeySigningConfigurationResolutionError,
23 MissingMacPasskeyProvisioningProfileError,
24 renderMacPasskeyEntitlements,
25 resolveClerkPasskeyNativeArtifacts,
26 resolveMacPasskeySigningConfiguration,
27 resolveDesktopRuntimeDependencies,
28 resolveFffNativeDependencies,
29 resolveBuildOptions,
30 resolveDesktopBuildIconAssets,
31 resolveDesktopProductName,
32 resolveDesktopUpdateChannel,
33 resolveGitHubPublishConfig,
34 resolveMockUpdateServerPort,
35 resolveMockUpdateServerUrl,
36 stageLinuxIconSize,
37 STAGE_INSTALL_ARGS,
38} from "./build-desktop-artifact.ts";
39import { BRAND_ASSET_PATHS } from "./lib/brand-assets.ts";
40import { HostProcessArchitecture, HostProcessPlatform } from "@t3tools/shared/hostProcess";
41​
42function mockProcess(exitCode: number) {
43 return ChildProcessSpawner.makeHandle({
44 pid: ChildProcessSpawner.ProcessId(1),
45 exitCode: Effect.succeed(ChildProcessSpawner.ExitCode(exitCode)),
46 isRunning: Effect.succeed(false),
47 kill: () => Effect.void,
48 unref: Effect.succeed(Effect.void),
49 stdin: Sink.drain,
50 stdout: Stream.empty,
51 stderr: Stream.empty,
52 all: Stream.empty,
53 getInputFd: () => Sink.drain,
54 getOutputFd: () => Stream.empty,
55 });
57​
58function iconResizeSpawnerLayer(
59 commands: Array<{ readonly command: string; readonly args: ReadonlyArray<string> }>,
60 exitCodes: ReadonlyArray<number>,
61) {
62 let commandIndex = 0;
63 return Layer.succeed(
64 ChildProcessSpawner.ChildProcessSpawner,
65 ChildProcessSpawner.make((command) => {
66 const childProcess = command as unknown as {
67 readonly command: string;
68 readonly args: ReadonlyArray<string>;
69 };
70 commands.push({
71 command: childProcess.command,
72 args: childProcess.args,
73 });
74 return Effect.succeed(mockProcess(exitCodes[commandIndex++] ?? 0));
75 }),
76 );
78​
79it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
80 it("resolves the dedicated nightly updater channel from nightly versions", () => {
81 assert.equal(resolveDesktopUpdateChannel("0.0.17-nightly.20260413.42"), "nightly");
82 assert.equal(resolveDesktopUpdateChannel("0.0.17"), "latest");
83 });
84​
85 it("switches desktop packaging product names to nightly for nightly builds", () => {
86 assert.equal(resolveDesktopProductName("0.0.17"), "T3 Code (Alpha)");
87 assert.equal(resolveDesktopProductName("0.0.17-nightly.20260413.42"), "T3 Code (Nightly)");
88 });
89​
90 it("switches desktop packaging icons to the nightly artwork for nightly versions", () => {
91 assert.deepStrictEqual(resolveDesktopBuildIconAssets("0.0.17"), {
92 macIconPng: BRAND_ASSET_PATHS.productionMacIconPng,
93 linuxIconPng: BRAND_ASSET_PATHS.productionLinuxIconPng,
94 windowsIconIco: BRAND_ASSET_PATHS.productionWindowsIconIco,
95 });
96​
97 assert.deepStrictEqual(resolveDesktopBuildIconAssets("0.0.17-nightly.20260413.42"), {
98 macIconPng: BRAND_ASSET_PATHS.nightlyMacIconPng,
99 linuxIconPng: BRAND_ASSET_PATHS.nightlyLinuxIconPng,
100 windowsIconIco: BRAND_ASSET_PATHS.nightlyWindowsIconIco,
101 });
102 });
103​
104 it.effect("resolves GitHub desktop publish config from Effect config", () =>
105 Effect.gen(function* () {
106 const latestConfig = yield* resolveGitHubPublishConfig("latest").pipe(
107 Effect.provide(
108 ConfigProvider.layer(
109 ConfigProvider.fromEnv({
110 env: {
111 T3CODE_DESKTOP_UPDATE_REPOSITORY: "pingdotgg/t3code",
112 },
113 }),
114 ),
115 ),
116 );
117 const nightlyConfig = yield* resolveGitHubPublishConfig("nightly").pipe(
118 Effect.provide(
119 ConfigProvider.layer(
120 ConfigProvider.fromEnv({
121 env: {
122 GITHUB_REPOSITORY: "pingdotgg/t3code",
123 },
124 }),
125 ),
126 ),
127 );
128​
129 assert.deepStrictEqual(latestConfig, {
130 provider: "github",
131 owner: "pingdotgg",
132 repo: "t3code",
133 releaseType: "release",
134 });
135 assert.deepStrictEqual(nightlyConfig, {
136 provider: "github",
137 owner: "pingdotgg",
138 repo: "t3code",
139 releaseType: "prerelease",
140 channel: "nightly",
141 });
142 }),
143 );
144​
145 it("omits bundled workspace packages from staged desktop dependencies", () => {
146 assert.deepStrictEqual(
147 resolveDesktopRuntimeDependencies(
148 {
149 "@effect/platform-node": "catalog:",
150 "@t3tools/contracts": "workspace:*",
151 "@t3tools/shared": "workspace:*",
152 "@t3tools/ssh": "workspace:*",
153 "@t3tools/tailscale": "workspace:*",
154 effect: "catalog:",
155 electron: "41.5.0",
156 },
157 {
158 "@effect/platform-node": "4.0.0-beta.59",
159 effect: "4.0.0-beta.59",
160 },
161 ),
162 {
163 "@effect/platform-node": "4.0.0-beta.59",
164 effect: "4.0.0-beta.59",
165 },
166 );
167 });
168​
169 it("carries only staged dependency patch metadata into staged desktop installs", () => {
170 assert.deepStrictEqual(
171 createStagePatchedDependencies(
172 {
173 "@expo/metro-config@56.0.13": "patches/@expo%2Fmetro-config@56.0.13.patch",
174 "@ff-labs/fff-node@0.9.4": "patches/@ff-labs__fff-node@0.9.4.patch",
175 "@pierre/diffs@1.1.20": "patches/@pierre%2Fdiffs@1.1.20.patch",
176 "alchemy@2.0.0-beta.49": "patches/alchemy@2.0.0-beta.49.patch",
177 "effect@4.0.0-beta.73": "patches/effect@4.0.0-beta.73.patch",
178 },
179 {
180 "@ff-labs/fff-node": "0.9.4",
181 "@pierre/diffs": "1.1.20",
182 effect: "4.0.0-beta.73",
183 },
184 ),
185 {
186 "@ff-labs/fff-node@0.9.4": "patches/@ff-labs__fff-node@0.9.4.patch",
187 "@pierre/diffs@1.1.20": "patches/@pierre%2Fdiffs@1.1.20.patch",
188 "effect@4.0.0-beta.73": "patches/effect@4.0.0-beta.73.patch",
189 },
190 );
191​
192 assert.deepStrictEqual(
193 createStagePatchedDependencies(
194 {
195 "@expo/metro-config@56.0.13": "patches/@expo%2Fmetro-config@56.0.13.patch",
196 },
197 { effect: "4.0.0-beta.73" },
198 ),
199 {},
200 );
201 });
202​
203 it("installs optional native dependencies for the target desktop architecture", () => {
204 assert.deepStrictEqual(STAGE_INSTALL_ARGS, ["install", "--prod"]);
205 assert.deepStrictEqual(createStageWorkspaceConfig({ platform: "mac", arch: "x64" }), {
206 supportedArchitectures: {
207 os: ["darwin"],
208 cpu: ["x64"],
209 },
210 });
211 // Windows artifacts also bundle the same-architecture WSL (Linux, glibc) backend, so the
212 // staged install must fetch its native optional deps (e.g. ffi-rs) too.
213 assert.deepStrictEqual(createStageWorkspaceConfig({ platform: "win", arch: "x64" }), {
214 supportedArchitectures: {
215 os: ["win32", "linux"],
216 cpu: ["x64"],
217 libc: ["glibc"],
218 },
219 });
220 assert.deepStrictEqual(createStageWorkspaceConfig({ platform: "win", arch: "arm64" }), {
221 supportedArchitectures: {
222 os: ["win32", "linux"],
223 cpu: ["arm64"],
224 libc: ["glibc"],
225 },
226 });
227 assert.deepStrictEqual(createStageWorkspaceConfig({ platform: "mac", arch: "universal" }), {
228 supportedArchitectures: {
229 os: ["darwin"],
230 cpu: ["arm64", "x64"],
231 },
232 });
233 });
234​
235 it("stages pnpm 11 allowBuilds and patchedDependencies in the workspace yaml", () => {
236 assert.deepStrictEqual(
237 createStageWorkspaceConfig({
238 platform: "linux",
239 arch: "x64",
240 allowBuilds: {
241 electron: true,
242 "node-pty": true,
243 "browser-tabs-lock": false,
244 },
245 patchedDependencies: {
246 "effect@4.0.0-beta.73": "patches/effect@4.0.0-beta.73.patch",
247 },
248 overrides: {
249 effect: "4.0.0-beta.73",
250 },
251 }),
252 {
253 supportedArchitectures: {
254 os: ["linux"],
255 cpu: ["x64"],
256 },
257 allowBuilds: {
258 electron: true,
259 "node-pty": true,
260 "browser-tabs-lock": false,
261 },
262 patchedDependencies: {
263 "effect@4.0.0-beta.73": "patches/effect@4.0.0-beta.73.patch",
264 },
265 overrides: {
266 effect: "4.0.0-beta.73",
267 },
268 },
269 );
270​
271 // Empty maps must not be written — pnpm would still require reviewed
272 // packages if allowBuilds is present but incomplete, and omitting empty
273 // patchedDependencies keeps the stage yaml minimal.
274 assert.deepStrictEqual(
275 createStageWorkspaceConfig({
276 platform: "mac",
277 arch: "arm64",
278 allowBuilds: {},
279 patchedDependencies: {},
280 overrides: {},
281 }),
282 {
283 supportedArchitectures: {
284 os: ["darwin"],
285 cpu: ["arm64"],
286 },
287 },
288 );
289 });
290​
291 it("unpacks the fff shared library for filesystem and FFI access", () => {
292 assert.deepStrictEqual(DESKTOP_ASAR_UNPACK, ["node_modules/@ff-labs/fff-bin-*/**/*"]);
293 });
294​
295 it.effect("preserves both Linux icon resize failures with structural context", () => {
296 const commands: Array<{ readonly command: string; readonly args: ReadonlyArray<string> }> = [];
297​
298 return Effect.gen(function* () {
299 const error = yield* stageLinuxIconSize("source.png", "target.png", 512, false).pipe(
300 Effect.provide(iconResizeSpawnerLayer(commands, [1, 2])),
301 Effect.flip,
302 );
303​
304 assert.instanceOf(error, LinuxIconResizeError);
305 assert.equal(error.operation, "resize");
306 assert.equal(error.iconSize, 512);
307 assert.equal(error.primaryTool, "magick");
308 assert.equal(error.fallbackTool, "convert");
309 assert.include(error.message, "512x512");
310 assert.include(error.message, "`magick`");
311 assert.include(error.message, "`convert`");
312 assert.notInclude(error.message, "non-zero exit code");
313​
314 assert.instanceOf(error.cause, AggregateError);
315 const aggregateCause = error.cause as AggregateError;
316 assert.lengthOf(aggregateCause.errors, 2);
317 assert.strictEqual(aggregateCause.cause, aggregateCause.errors[0]);
318 assert.instanceOf(aggregateCause.errors[0], BuildCommandFailedError);
319 assert.instanceOf(aggregateCause.errors[1], BuildCommandFailedError);
320 const primaryError = aggregateCause.errors[0] as BuildCommandFailedError;
321 const fallbackError = aggregateCause.errors[1] as BuildCommandFailedError;
322 assert.equal(primaryError.command, "magick linux icon 512x512");
323 assert.equal(primaryError.exitCode, 1);
324 assert.include(primaryError.message, "magick linux icon");
325 assert.equal(fallbackError.command, "convert linux icon 512x512");
326 assert.equal(fallbackError.exitCode, 2);
327 assert.include(fallbackError.message, "convert linux icon");
328 assert.deepStrictEqual(
329 commands.map(({ command }) => command),
330 ["magick", "convert"],
331 );
332 });
333 });
334​
335 it("derives macOS passkey signing configuration from the Clerk publishable key", () => {
336 const configuration = resolveMacPasskeySigningConfiguration({
337 T3CODE_APPLE_TEAM_ID: "abc1234567",
338 T3CODE_MACOS_PROVISIONING_PROFILE: "/tmp/t3code.provisionprofile",
339 T3CODE_CLERK_PUBLISHABLE_KEY: `pk_test_${btoa("example.clerk.accounts.dev$")}`,
340 });
341​
342 assert.deepStrictEqual(configuration, {
343 appId: "com.t3tools.t3code",
344 teamId: "ABC1234567",
345 rpDomains: ["example.clerk.accounts.dev"],
346 provisioningProfilePath: "/tmp/t3code.provisionprofile",
347 });
348 });
349​
350 it("normalizes explicit macOS passkey RP domains and renders required entitlements", () => {
351 const configuration = resolveMacPasskeySigningConfiguration({
352 T3CODE_APPLE_TEAM_ID: "ABC1234567",
353 T3CODE_MACOS_PROVISIONING_PROFILE: "/tmp/t3code.provisionprofile",
354 T3CODE_CLERK_PASSKEY_RP_DOMAINS:
355 " Clerk.Example.com,example.clerk.accounts.dev,clerk.example.com ",
356 });
357 const entitlements = renderMacPasskeyEntitlements(configuration);
358​
359 assert.deepStrictEqual(configuration.rpDomains, [
360 "clerk.example.com",
361 "example.clerk.accounts.dev",
362 ]);
363 assert.include(entitlements, "<string>ABC1234567.com.t3tools.t3code</string>");
364 assert.include(entitlements, "<string>webcredentials:clerk.example.com</string>");
365 assert.include(entitlements, "<string>webcredentials:example.clerk.accounts.dev</string>");
366 assert.include(entitlements, "<key>com.apple.security.cs.allow-jit</key>");
367 });
368​
369 it("rejects incomplete macOS passkey signing configuration", () => {
370 const captureError = (env: Readonly<Record<string, string | undefined>>) => {
371 try {
372 resolveMacPasskeySigningConfiguration(env);
373 } catch (error) {
374 return error;
375 }
376 return assert.fail("Expected passkey signing configuration to fail.");
377 };
378​
379 const missingProfileError = captureError({
380 T3CODE_APPLE_TEAM_ID: "ABC1234567",
381 T3CODE_CLERK_PASSKEY_RP_DOMAINS: "example.clerk.accounts.dev",
382 });
383 assert.instanceOf(missingProfileError, MissingMacPasskeyProvisioningProfileError);
384 assert.equal(
385 missingProfileError.message,
386 "T3CODE_MACOS_PROVISIONING_PROFILE must point to an Associated Domains provisioning profile.",
387 );
388​
389 const unsafeDomain =
390 "https://domain-user:domain-secret@example.clerk.accounts.dev/path?token=query-secret";
391 const invalidDomainError = captureError({
392 T3CODE_APPLE_TEAM_ID: "ABC1234567",
393 T3CODE_MACOS_PROVISIONING_PROFILE: "/tmp/t3code.provisionprofile",
394 T3CODE_CLERK_PASSKEY_RP_DOMAINS: unsafeDomain,
395 });
396 assert.instanceOf(invalidDomainError, InvalidMacPasskeyRpDomainError);
397 assert.equal(invalidDomainError.reason, "scheme-not-allowed");
398 assert.equal(invalidDomainError.inputLength, unsafeDomain.length);
399 assert.equal(invalidDomainError.message, "Invalid passkey RP domain (scheme-not-allowed).");
400 assert.notProperty(invalidDomainError, "domain");
401 assert.notProperty(invalidDomainError, "cause");
402 const serializedInvalidDomainError = JSON.stringify(invalidDomainError);
403 assert.notInclude(serializedInvalidDomainError, unsafeDomain);
404 assert.notInclude(serializedInvalidDomainError, "domain-user");
405 assert.notInclude(serializedInvalidDomainError, "domain-secret");
406 assert.notInclude(serializedInvalidDomainError, "query-secret");
407 assert.throws(
408 () =>
409 resolveMacPasskeySigningConfiguration({
410 T3CODE_APPLE_TEAM_ID: "ABC1234567",
411 T3CODE_MACOS_PROVISIONING_PROFILE: "/tmp/t3code.provisionprofile",
412 T3CODE_CLERK_PASSKEY_RP_DOMAINS: "example.clerk.accounts.dev:8443",
413 }),
414 /Invalid passkey RP domain/u,
415 );
416 const invalidPublishableKeyError = captureError({
417 T3CODE_APPLE_TEAM_ID: "ABC1234567",
418 T3CODE_MACOS_PROVISIONING_PROFILE: "/tmp/t3code.provisionprofile",
419 T3CODE_CLERK_PUBLISHABLE_KEY: "pk_test_%",
420 });
421 assert.instanceOf(invalidPublishableKeyError, InvalidMacPasskeyPublishableKeyError);
422 assert.ok(invalidPublishableKeyError.cause);
423 assert.equal(invalidPublishableKeyError.message, "T3CODE_CLERK_PUBLISHABLE_KEY is invalid.");
424 assert.notProperty(invalidPublishableKeyError, "publishableKey");
425 assert.notInclude(invalidPublishableKeyError.message, "pk_test_%");
426 });
427​
428 it("preserves known passkey signing configuration errors at the build boundary", () => {
429 const decodingCause = new Error("publishable-key-decode-failed");
430 const knownError = new InvalidMacPasskeyPublishableKeyError({ cause: decodingCause });
431 const error = MacPasskeySigningConfigurationResolutionError.fromCause(knownError);
432​
433 assert.strictEqual(error, knownError);
434 assert.instanceOf(error, InvalidMacPasskeyPublishableKeyError);
435 assert.strictEqual(error.cause, decodingCause);
436 assert.isTrue(isMacPasskeySigningConfigurationError(error));
437 });
438​
439 it("wraps unknown passkey signing configuration defects without copying cause text", () => {
440 const secret = "pk_test_do-not-retain";
441 const cause = new Error(secret);
442 const error = MacPasskeySigningConfigurationResolutionError.fromCause(cause);
443​
444 assert.instanceOf(error, MacPasskeySigningConfigurationResolutionError);
445 assert.strictEqual(error.cause, cause);
446 assert.equal(error.message, "Failed to resolve macOS passkey signing configuration.");
447 assert.notInclude(error.message, secret);
448 });
449​
450 it.effect("adds passkey entitlements and both renderer protocols to signed macOS builds", () =>
451 Effect.gen(function* () {
452 const config = yield* createBuildConfig("mac", "dmg", "1.2.3", true, false, undefined, {
453 entitlementsPath: "/tmp/entitlements.mac.plist",
454 provisioningProfilePath: "/tmp/t3code.provisionprofile",
455 });
456​
457 const mac = config.mac as Record<string, unknown>;
458 assert.equal(config.appId, "com.t3tools.t3code");
459 assert.equal(mac.entitlements, "/tmp/entitlements.mac.plist");
460 assert.equal(mac.provisioningProfile, "/tmp/t3code.provisionprofile");
461 assert.deepStrictEqual(mac.protocols, [
462 { name: "T3 Code", schemes: ["t3code", "t3code-dev"] },
463 ]);
464 }).pipe(Effect.provide(ConfigProvider.layer(ConfigProvider.fromEnv({ env: {} })))),
465 );
466​
467 it.effect("keeps executable resource editing enabled for unsigned Windows builds", () =>
468 Effect.gen(function* () {
469 const config = yield* createBuildConfig(
470 "win",
471 "nsis",
472 "1.2.3",
473 false,
474 false,
475 undefined,
476 undefined,
477 );
478​
479 const win = config.win as Record<string, unknown>;
480 assert.equal(win.icon, "icon.ico");
481 assert.equal(win.signAndEditExecutable, true);
482 assert.notProperty(win, "azureSignOptions");
483 }).pipe(Effect.provide(ConfigProvider.layer(ConfigProvider.fromEnv({ env: {} })))),
484 );
485​
486 it("promotes target fff binaries to direct staged dependencies", () => {
487 assert.deepStrictEqual(resolveFffNativeDependencies("mac", "arm64", "0.9.4"), {
488 "@ff-labs/fff-bin-darwin-arm64": "0.9.4",
489 });
490 assert.deepStrictEqual(resolveFffNativeDependencies("mac", "universal", "0.9.4"), {
491 "@ff-labs/fff-bin-darwin-arm64": "0.9.4",
492 "@ff-labs/fff-bin-darwin-x64": "0.9.4",
493 });
494 assert.deepStrictEqual(resolveFffNativeDependencies("win", "x64", "0.9.4"), {
495 "@ff-labs/fff-bin-win32-x64": "0.9.4",
496 });
497 assert.deepStrictEqual(resolveFffNativeDependencies("linux", "x64", "0.9.4"), {
498 "@ff-labs/fff-bin-linux-x64-gnu": "0.9.4",
499 "@ff-labs/fff-bin-linux-x64-musl": "0.9.4",
500 });
501 assert.deepStrictEqual(resolveFffNativeDependencies("linux", "arm64", "0.9.4"), {
502 "@ff-labs/fff-bin-linux-arm64-gnu": "0.9.4",
503 "@ff-labs/fff-bin-linux-arm64-musl": "0.9.4",
504 });
505 });
506​
507 it("resolves target Clerk passkey native artifacts", () => {
508 assert.deepStrictEqual(resolveClerkPasskeyNativeArtifacts("mac", "universal"), [
509 {
510 packageName: "@clerk/electron-passkeys-darwin-arm64",
511 binaryFileName: "electron-passkeys.darwin-arm64.node",
512 },
513 {
514 packageName: "@clerk/electron-passkeys-darwin-x64",
515 binaryFileName: "electron-passkeys.darwin-x64.node",
516 },
517 ]);
518 assert.deepStrictEqual(resolveClerkPasskeyNativeArtifacts("win", "x64"), [
519 {
520 packageName: "@clerk/electron-passkeys-win32-x64-msvc",
521 binaryFileName: "electron-passkeys.win32-x64-msvc.node",
522 },
523 ]);
524 assert.deepStrictEqual(resolveClerkPasskeyNativeArtifacts("linux", "x64"), []);
525 });
526​
527 it("falls back to the default mock update port when the configured port is blank", () => {
528 assert.equal(resolveMockUpdateServerUrl(undefined), "http://localhost:3000");
529 assert.equal(resolveMockUpdateServerUrl(4123), "http://localhost:4123");
530 });
531​
532 it.effect("normalizes mock update server ports from env-style strings", () =>
533 Effect.gen(function* () {
534 assert.equal(yield* resolveMockUpdateServerPort(undefined), undefined);
535 assert.equal(yield* resolveMockUpdateServerPort(""), undefined);
536 assert.equal(yield* resolveMockUpdateServerPort(" "), undefined);
537 assert.equal(yield* resolveMockUpdateServerPort("4123"), 4123);
538 }),
539 );
540​
541 it.effect("rejects non-numeric or out-of-range mock update ports", () =>
542 Effect.gen(function* () {
543 const invalidPorts = ["abc", "12.5", "0", "65536"];
544 for (const port of invalidPorts) {
545 const exit = yield* Effect.exit(resolveMockUpdateServerPort(port));
546 assert.equal(exit._tag, "Failure");
547 }
548 }),
549 );
550​
551 it("classifies invalid configured ports with the decoder's number grammar", () => {
552 const cause = new Error("invalid configured port");
553​
554 assert.equal(
555 InvalidMockUpdateServerPortError.fromConfigValue("0x10", cause).reason,
556 "not-numeric",
557 );
558 assert.equal(
559 InvalidMockUpdateServerPortError.fromConfigValue("12.5", cause).reason,
560 "not-integer",
561 );
562 assert.equal(
563 InvalidMockUpdateServerPortError.fromConfigValue("65536", cause).reason,
564 "out-of-range",
565 );
566 assert.strictEqual(
567 InvalidMockUpdateServerPortError.fromConfigValue("0x10", cause).cause,
568 cause,
569 );
570 });
571​
572 it.effect("resolves default platform and architecture from host references", () =>
573 Effect.gen(function* () {
574 const resolved = yield* resolveBuildOptions({
575 platform: Option.none(),
576 target: Option.none(),
577 arch: Option.none(),
578 buildVersion: Option.none(),
579 outputDir: Option.none(),
580 skipBuild: Option.none(),
581 keepStage: Option.none(),
582 signed: Option.none(),
583 verbose: Option.none(),
584 mockUpdates: Option.none(),
585 mockUpdateServerPort: Option.none(),
586 wslPrebuild: Option.none(),
587 }).pipe(
588 Effect.provide(
589 Layer.mergeAll(
590 Layer.succeed(HostProcessPlatform, "win32"),
591 Layer.succeed(HostProcessArchitecture, "x64"),
592 ConfigProvider.layer(
593 ConfigProvider.fromEnv({
594 env: {
595 PROCESSOR_ARCHITECTURE: "AMD64",
596 PROCESSOR_ARCHITEW6432: "ARM64",
597 },
598 }),
599 ),
600 ),
601 ),
602 );
603​
604 assert.equal(resolved.platform, "win");
605 assert.equal(resolved.target, "nsis");
606 assert.equal(resolved.arch, "arm64");
607 }),
608 );
609​
610 it.effect("preserves explicit false boolean flags over true env defaults", () =>
611 Effect.gen(function* () {
612 const resolved = yield* resolveBuildOptions({
613 platform: Option.some("mac"),
614 target: Option.none(),
615 arch: Option.some("arm64"),
616 buildVersion: Option.none(),
617 outputDir: Option.some("release-test"),
618 skipBuild: Option.some(false),
619 keepStage: Option.some(false),
620 signed: Option.some(false),
621 verbose: Option.some(false),
622 mockUpdates: Option.some(false),
623 mockUpdateServerPort: Option.none(),
624 wslPrebuild: Option.none(),
625 }).pipe(
626 Effect.provide(
627 ConfigProvider.layer(
628 ConfigProvider.fromEnv({
629 env: {
630 T3CODE_DESKTOP_SKIP_BUILD: "true",
631 T3CODE_DESKTOP_KEEP_STAGE: "true",
632 T3CODE_DESKTOP_SIGNED: "true",
633 T3CODE_DESKTOP_VERBOSE: "true",
634 T3CODE_DESKTOP_MOCK_UPDATES: "true",
635 },
636 }),
637 ),
638 ),
639 );
640​
641 assert.equal(resolved.skipBuild, false);
642 assert.equal(resolved.keepStage, false);
643 assert.equal(resolved.signed, false);
644 assert.equal(resolved.verbose, false);
645 assert.equal(resolved.mockUpdates, false);
646 }),
647 );
648});