294 lines
10 KiB
TypeScript
294 lines
10 KiB
TypeScript
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
import { assert, it } from "@effect/vitest";
|
|
import * as ConfigProvider from "effect/ConfigProvider";
|
|
import * as Effect from "effect/Effect";
|
|
import * as Layer from "effect/Layer";
|
|
import * as Option from "effect/Option";
|
|
|
|
import {
|
|
createStageWorkspaceConfig,
|
|
createStagePnpmConfig,
|
|
DESKTOP_ASAR_UNPACK,
|
|
resolveDesktopRuntimeDependencies,
|
|
resolveFffNativeDependencies,
|
|
resolveBuildOptions,
|
|
resolveDesktopBuildIconAssets,
|
|
resolveDesktopProductName,
|
|
resolveDesktopUpdateChannel,
|
|
resolveGitHubPublishConfig,
|
|
resolveMockUpdateServerPort,
|
|
resolveMockUpdateServerUrl,
|
|
STAGE_INSTALL_ARGS,
|
|
} from "./build-desktop-artifact.ts";
|
|
import { BRAND_ASSET_PATHS } from "./lib/brand-assets.ts";
|
|
import { HostProcessArchitecture, HostProcessPlatform } from "@t3tools/shared/hostProcess";
|
|
|
|
it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
|
|
it("resolves the dedicated nightly updater channel from nightly versions", () => {
|
|
assert.equal(resolveDesktopUpdateChannel("0.0.17-nightly.20260413.42"), "nightly");
|
|
assert.equal(resolveDesktopUpdateChannel("0.0.17"), "latest");
|
|
});
|
|
|
|
it("switches desktop packaging product names to nightly for nightly builds", () => {
|
|
assert.equal(resolveDesktopProductName("0.0.17"), "T3 Code (Alpha)");
|
|
assert.equal(resolveDesktopProductName("0.0.17-nightly.20260413.42"), "T3 Code (Nightly)");
|
|
});
|
|
|
|
it("switches desktop packaging icons to the nightly artwork for nightly versions", () => {
|
|
assert.deepStrictEqual(resolveDesktopBuildIconAssets("0.0.17"), {
|
|
macIconPng: BRAND_ASSET_PATHS.productionMacIconPng,
|
|
linuxIconPng: BRAND_ASSET_PATHS.productionLinuxIconPng,
|
|
windowsIconIco: BRAND_ASSET_PATHS.productionWindowsIconIco,
|
|
});
|
|
|
|
assert.deepStrictEqual(resolveDesktopBuildIconAssets("0.0.17-nightly.20260413.42"), {
|
|
macIconPng: BRAND_ASSET_PATHS.nightlyMacIconPng,
|
|
linuxIconPng: BRAND_ASSET_PATHS.nightlyLinuxIconPng,
|
|
windowsIconIco: BRAND_ASSET_PATHS.nightlyWindowsIconIco,
|
|
});
|
|
});
|
|
|
|
it.effect("resolves GitHub desktop publish config from Effect config", () =>
|
|
Effect.gen(function* () {
|
|
const latestConfig = yield* resolveGitHubPublishConfig("latest").pipe(
|
|
Effect.provide(
|
|
ConfigProvider.layer(
|
|
ConfigProvider.fromEnv({
|
|
env: {
|
|
T3CODE_DESKTOP_UPDATE_REPOSITORY: "pingdotgg/t3code",
|
|
},
|
|
}),
|
|
),
|
|
),
|
|
);
|
|
const nightlyConfig = yield* resolveGitHubPublishConfig("nightly").pipe(
|
|
Effect.provide(
|
|
ConfigProvider.layer(
|
|
ConfigProvider.fromEnv({
|
|
env: {
|
|
GITHUB_REPOSITORY: "pingdotgg/t3code",
|
|
},
|
|
}),
|
|
),
|
|
),
|
|
);
|
|
|
|
assert.deepStrictEqual(latestConfig, {
|
|
provider: "github",
|
|
owner: "pingdotgg",
|
|
repo: "t3code",
|
|
releaseType: "release",
|
|
});
|
|
assert.deepStrictEqual(nightlyConfig, {
|
|
provider: "github",
|
|
owner: "pingdotgg",
|
|
repo: "t3code",
|
|
releaseType: "prerelease",
|
|
channel: "nightly",
|
|
});
|
|
}),
|
|
);
|
|
|
|
it("omits bundled workspace packages from staged desktop dependencies", () => {
|
|
assert.deepStrictEqual(
|
|
resolveDesktopRuntimeDependencies(
|
|
{
|
|
"@effect/platform-node": "catalog:",
|
|
"@t3tools/contracts": "workspace:*",
|
|
"@t3tools/shared": "workspace:*",
|
|
"@t3tools/ssh": "workspace:*",
|
|
"@t3tools/tailscale": "workspace:*",
|
|
effect: "catalog:",
|
|
electron: "41.5.0",
|
|
},
|
|
{
|
|
"@effect/platform-node": "4.0.0-beta.59",
|
|
effect: "4.0.0-beta.59",
|
|
},
|
|
),
|
|
{
|
|
"@effect/platform-node": "4.0.0-beta.59",
|
|
effect: "4.0.0-beta.59",
|
|
},
|
|
);
|
|
});
|
|
|
|
it("carries only staged dependency patch metadata into staged desktop installs", () => {
|
|
assert.deepStrictEqual(
|
|
createStagePnpmConfig(
|
|
{
|
|
"@expo/[email protected]": "patches/@expo%[email protected]",
|
|
"@ff-labs/[email protected]": "patches/@[email protected]",
|
|
"@pierre/[email protected]": "patches/@pierre%[email protected]",
|
|
"[email protected]": "patches/[email protected]",
|
|
"[email protected]": "patches/[email protected]",
|
|
},
|
|
{
|
|
"@ff-labs/fff-node": "0.9.4",
|
|
"@pierre/diffs": "1.1.20",
|
|
effect: "4.0.0-beta.73",
|
|
},
|
|
),
|
|
{
|
|
patchedDependencies: {
|
|
"@ff-labs/[email protected]": "patches/@[email protected]",
|
|
"@pierre/[email protected]": "patches/@pierre%[email protected]",
|
|
"[email protected]": "patches/[email protected]",
|
|
},
|
|
},
|
|
);
|
|
|
|
assert.equal(
|
|
createStagePnpmConfig(
|
|
{
|
|
"@expo/[email protected]": "patches/@expo%[email protected]",
|
|
},
|
|
{ effect: "4.0.0-beta.73" },
|
|
),
|
|
undefined,
|
|
);
|
|
});
|
|
|
|
it("installs optional native dependencies for the target desktop architecture", () => {
|
|
assert.deepStrictEqual(STAGE_INSTALL_ARGS, ["install", "--prod"]);
|
|
assert.deepStrictEqual(createStageWorkspaceConfig("mac", "x64"), {
|
|
supportedArchitectures: {
|
|
os: ["darwin"],
|
|
cpu: ["x64"],
|
|
},
|
|
});
|
|
assert.deepStrictEqual(createStageWorkspaceConfig("win", "arm64"), {
|
|
supportedArchitectures: {
|
|
os: ["win32"],
|
|
cpu: ["arm64"],
|
|
},
|
|
});
|
|
assert.deepStrictEqual(createStageWorkspaceConfig("mac", "universal"), {
|
|
supportedArchitectures: {
|
|
os: ["darwin"],
|
|
cpu: ["arm64", "x64"],
|
|
},
|
|
});
|
|
});
|
|
|
|
it("unpacks the fff shared library for filesystem and FFI access", () => {
|
|
assert.deepStrictEqual(DESKTOP_ASAR_UNPACK, ["node_modules/@ff-labs/fff-bin-*/**/*"]);
|
|
});
|
|
|
|
it("promotes target fff binaries to direct staged dependencies", () => {
|
|
assert.deepStrictEqual(resolveFffNativeDependencies("mac", "arm64", "0.9.4"), {
|
|
"@ff-labs/fff-bin-darwin-arm64": "0.9.4",
|
|
});
|
|
assert.deepStrictEqual(resolveFffNativeDependencies("mac", "universal", "0.9.4"), {
|
|
"@ff-labs/fff-bin-darwin-arm64": "0.9.4",
|
|
"@ff-labs/fff-bin-darwin-x64": "0.9.4",
|
|
});
|
|
assert.deepStrictEqual(resolveFffNativeDependencies("win", "x64", "0.9.4"), {
|
|
"@ff-labs/fff-bin-win32-x64": "0.9.4",
|
|
});
|
|
assert.deepStrictEqual(resolveFffNativeDependencies("linux", "arm64", "0.9.4"), {
|
|
"@ff-labs/fff-bin-linux-arm64-gnu": "0.9.4",
|
|
"@ff-labs/fff-bin-linux-arm64-musl": "0.9.4",
|
|
});
|
|
});
|
|
|
|
it("falls back to the default mock update port when the configured port is blank", () => {
|
|
assert.equal(resolveMockUpdateServerUrl(undefined), "http://localhost:3000");
|
|
assert.equal(resolveMockUpdateServerUrl(4123), "http://localhost:4123");
|
|
});
|
|
|
|
it.effect("normalizes mock update server ports from env-style strings", () =>
|
|
Effect.gen(function* () {
|
|
assert.equal(yield* resolveMockUpdateServerPort(undefined), undefined);
|
|
assert.equal(yield* resolveMockUpdateServerPort(""), undefined);
|
|
assert.equal(yield* resolveMockUpdateServerPort(" "), undefined);
|
|
assert.equal(yield* resolveMockUpdateServerPort("4123"), 4123);
|
|
}),
|
|
);
|
|
|
|
it.effect("rejects non-numeric or out-of-range mock update ports", () =>
|
|
Effect.gen(function* () {
|
|
const invalidPorts = ["abc", "12.5", "0", "65536"];
|
|
for (const port of invalidPorts) {
|
|
const exit = yield* Effect.exit(resolveMockUpdateServerPort(port));
|
|
assert.equal(exit._tag, "Failure");
|
|
}
|
|
}),
|
|
);
|
|
|
|
it.effect("resolves default platform and architecture from host references", () =>
|
|
Effect.gen(function* () {
|
|
const resolved = yield* resolveBuildOptions({
|
|
platform: Option.none(),
|
|
target: Option.none(),
|
|
arch: Option.none(),
|
|
buildVersion: Option.none(),
|
|
outputDir: Option.none(),
|
|
skipBuild: Option.none(),
|
|
keepStage: Option.none(),
|
|
signed: Option.none(),
|
|
verbose: Option.none(),
|
|
mockUpdates: Option.none(),
|
|
mockUpdateServerPort: Option.none(),
|
|
}).pipe(
|
|
Effect.provide(
|
|
Layer.mergeAll(
|
|
Layer.succeed(HostProcessPlatform, "win32"),
|
|
Layer.succeed(HostProcessArchitecture, "x64"),
|
|
ConfigProvider.layer(
|
|
ConfigProvider.fromEnv({
|
|
env: {
|
|
PROCESSOR_ARCHITECTURE: "AMD64",
|
|
PROCESSOR_ARCHITEW6432: "ARM64",
|
|
},
|
|
}),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
assert.equal(resolved.platform, "win");
|
|
assert.equal(resolved.target, "nsis");
|
|
assert.equal(resolved.arch, "arm64");
|
|
}),
|
|
);
|
|
|
|
it.effect("preserves explicit false boolean flags over true env defaults", () =>
|
|
Effect.gen(function* () {
|
|
const resolved = yield* resolveBuildOptions({
|
|
platform: Option.some("mac"),
|
|
target: Option.none(),
|
|
arch: Option.some("arm64"),
|
|
buildVersion: Option.none(),
|
|
outputDir: Option.some("release-test"),
|
|
skipBuild: Option.some(false),
|
|
keepStage: Option.some(false),
|
|
signed: Option.some(false),
|
|
verbose: Option.some(false),
|
|
mockUpdates: Option.some(false),
|
|
mockUpdateServerPort: Option.none(),
|
|
}).pipe(
|
|
Effect.provide(
|
|
ConfigProvider.layer(
|
|
ConfigProvider.fromEnv({
|
|
env: {
|
|
T3CODE_DESKTOP_SKIP_BUILD: "true",
|
|
T3CODE_DESKTOP_KEEP_STAGE: "true",
|
|
T3CODE_DESKTOP_SIGNED: "true",
|
|
T3CODE_DESKTOP_VERBOSE: "true",
|
|
T3CODE_DESKTOP_MOCK_UPDATES: "true",
|
|
},
|
|
}),
|
|
),
|
|
),
|
|
);
|
|
|
|
assert.equal(resolved.skipBuild, false);
|
|
assert.equal(resolved.keepStage, false);
|
|
assert.equal(resolved.signed, false);
|
|
assert.equal(resolved.verbose, false);
|
|
assert.equal(resolved.mockUpdates, false);
|
|
}),
|
|
);
|
|
});
|