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
29 changes: 4 additions & 25 deletions scripts/build-desktop-artifact.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {
resolveDesktopProductName,
resolveDesktopUpdateChannel,
resolveDesktopWebAssetBrand,
renderLinuxHeadlessLauncher,
resolveLinuxTargets,
resolveResourceMonitorRustTargets,
resourceMonitorExecutableName,
Expand Down Expand Up @@ -570,7 +569,6 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
false,
undefined,
undefined,
"/tmp/t3",
);
const appImageOnly = yield* createBuildConfig(
"linux",
Expand All @@ -587,10 +585,9 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
"deb",
"rpm",
]);
// Both fpm-backed formats are configured from the one run, each with its
// own dependency list and the headless launcher.
assert.deepStrictEqual((all.deb as Record<string, unknown>).fpm, ["/tmp/t3=/usr/bin/t3"]);
assert.deepStrictEqual((all.rpm as Record<string, unknown>).fpm, ["/tmp/t3=/usr/bin/t3"]);
// Both fpm-backed formats are configured from the one run.
assert.property(all, "deb");
assert.property(all, "rpm");

// An AppImage-only build stays free of package-format sections.
assert.notProperty(appImageOnly, "deb");
Expand All @@ -608,7 +605,6 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
false,
undefined,
undefined,
"/tmp/t3",
);

const linux = config.linux as Record<string, unknown>;
Expand All @@ -633,11 +629,10 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
"libsecret-1-0",
"libasound2t64 | libasound2",
]);
assert.deepStrictEqual(deb.fpm, ["/tmp/t3=/usr/bin/t3"]);
}).pipe(Effect.provide(ConfigProvider.layer(ConfigProvider.fromEnv({ env: {} })))),
);

it.effect("includes runtime dependencies and the headless launcher in RPM packages", () =>
it.effect("includes runtime dependencies in RPM packages", () =>
Effect.gen(function* () {
const config = yield* createBuildConfig(
"linux",
Expand All @@ -647,7 +642,6 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
false,
undefined,
undefined,
"/tmp/t3",
);

const rpm = config.rpm as Record<string, unknown>;
Expand All @@ -664,24 +658,9 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
"libsecret",
"mesa-libgbm",
]);
assert.deepStrictEqual(rpm.fpm, ["/tmp/t3=/usr/bin/t3"]);
}).pipe(Effect.provide(ConfigProvider.layer(ConfigProvider.fromEnv({ env: {} })))),
);

it("renders a headless launcher for production and nightly packages", () => {
assert.equal(
renderLinuxHeadlessLauncher("1.2.3"),
[
"#!/bin/sh",
"set -eu",
"export ELECTRON_RUN_AS_NODE=1",
`exec '/opt/T3 Code (Alpha)/t3code' '/opt/T3 Code (Alpha)/resources/app.asar.unpacked/apps/server/dist/bin.mjs' "$@"`,
"",
].join("\n"),
);
assert.match(renderLinuxHeadlessLauncher("1.2.3-nightly.20260720.1"), /T3 Code \(Nightly\)/);
});

it("stages the resource monitor as an external executable resource", () => {
assert.deepStrictEqual(DESKTOP_EXTRA_RESOURCES, [
{
Expand Down
33 changes: 0 additions & 33 deletions scripts/build-desktop-artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1551,10 +1551,6 @@ export function resolveDesktopProductName(version: string): string {
: (desktopPackageJson.productName ?? "T3 Code");
}

function quotePosixShellArgument(value: string): string {
return `'${value.replaceAll("'", `'\\''`)}'`;
}

/**
* Splits a comma-separated Linux target string, for example "AppImage,deb,rpm",
* so one electron-builder run emits every package from the same staged app.
Expand All @@ -1572,20 +1568,6 @@ export function resolveLinuxTargets(target: string): ReadonlyArray<string> {
.filter((entry) => entry.length > 0);
}

export function renderLinuxHeadlessLauncher(version: string): string {
const installDir = `/opt/${resolveDesktopProductName(version)}`;
const desktopExecutable = `${installDir}/t3code`;
const serverEntry = `${installDir}/resources/app.asar.unpacked/apps/server/dist/bin.mjs`;

return [
"#!/bin/sh",
"set -eu",
"export ELECTRON_RUN_AS_NODE=1",
`exec ${quotePosixShellArgument(desktopExecutable)} ${quotePosixShellArgument(serverEntry)} "$@"`,
"",
].join("\n");
}

export const createBuildConfig = Effect.fn("createBuildConfig")(function* (
platform: typeof BuildPlatform.Type,
target: string,
Expand All @@ -1599,7 +1581,6 @@ export const createBuildConfig = Effect.fn("createBuildConfig")(function* (
readonly provisioningProfilePath: string;
}
| undefined,
linuxHeadlessLauncherPath?: string,
) {
const buildConfig: Record<string, unknown> = {
appId: DESKTOP_APP_ID,
Expand Down Expand Up @@ -1679,14 +1660,12 @@ export const createBuildConfig = Effect.fn("createBuildConfig")(function* (
if (linuxTargets.includes("deb")) {
buildConfig.deb = {
depends: [...DEB_DEPENDENCIES],
...(linuxHeadlessLauncherPath ? { fpm: [`${linuxHeadlessLauncherPath}=/usr/bin/t3`] } : {}),
};
}

if (linuxTargets.includes("rpm")) {
buildConfig.rpm = {
depends: [...RPM_DEPENDENCIES],
...(linuxHeadlessLauncherPath ? { fpm: [`${linuxHeadlessLauncherPath}=/usr/bin/t3`] } : {}),
};
}
}
Expand Down Expand Up @@ -1972,17 +1951,6 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
yield* fs.writeFileString(macEntitlementsPath, renderMacPasskeyEntitlements(macPasskeySigning));
}

const linuxPackageTargets = resolveLinuxTargets(options.target);
const linuxHeadlessLauncherPath =
options.platform === "linux" &&
(linuxPackageTargets.includes("deb") || linuxPackageTargets.includes("rpm"))
? path.join(stageRoot, "t3")
: undefined;
if (linuxHeadlessLauncherPath) {
yield* fs.writeFileString(linuxHeadlessLauncherPath, renderLinuxHeadlessLauncher(appVersion));
yield* fs.chmod(linuxHeadlessLauncherPath, 0o755);
}

const stageDependencies = {
...resolvedServerDependencies,
...resolvedDesktopRuntimeDependencies,
Expand Down Expand Up @@ -2033,7 +2001,6 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
provisioningProfilePath: macPasskeySigning.provisioningProfilePath,
}
: undefined,
linuxHeadlessLauncherPath,
),
dependencies: stageDependencies,
devDependencies: {
Expand Down
Loading