Skip to content
Open
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
1 change: 1 addition & 0 deletions apps/desktop/src/app/DesktopConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const DesktopConfig = Config.all({
otlpProtocol: Config.schema(OtlpProtocol, "T3CODE_OTLP_PROTOCOL").pipe(
Config.withDefault("http/json"),
),
resourcesPathOverride: trimmedString("T3CODE_DESKTOP_RESOURCES_PATH"),
appImagePath: trimmedString("APPIMAGE"),
disableAutoUpdate: optionalBoolean("T3CODE_DISABLE_AUTO_UPDATE"),
mockUpdates: optionalBoolean("T3CODE_DESKTOP_MOCK_UPDATES"),
Expand Down
21 changes: 21 additions & 0 deletions apps/desktop/src/app/DesktopEnvironment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,27 @@ describe("DesktopEnvironment", () => {
}),
);

it.effect("reads resources from a distribution package instead of the shared Electron", () =>
Effect.gen(function* () {
const environment = yield* makeEnvironment(
{
platform: "linux",
isPackaged: true,
appPath: "/usr/lib/t3code/app.asar",
resourcesPath: "/usr/lib/electron44/resources",
},
{ T3CODE_DESKTOP_RESOURCES_PATH: " /usr/lib/t3code/resources " },
);

assert.equal(environment.resourcesPath, "/usr/lib/t3code/resources");
assert.equal(environment.appUpdateYmlPath, "/usr/lib/t3code/resources/app-update.yml");
assert.include(
environment.resolveResourcePathCandidates("icon.png"),
"/usr/lib/t3code/resources/icon.png",
);
}),
);

it.effect("keeps implicit development state separate from production state", () =>
Effect.gen(function* () {
const development = yield* makeEnvironment(
Expand Down
11 changes: 8 additions & 3 deletions apps/desktop/src/app/DesktopEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,16 @@ const make = Effect.fn("desktop.environment.make")(function* (
});
const rootDir = path.resolve(input.dirname, "../../..");
const appRoot = input.isPackaged ? input.appPath : rootDir;
// Electron places the resources directory next to its own executable.
// Distribution packages that run the app on a shared Electron keep the
// app's resources elsewhere and point here instead.
const resourcesPath = Option.match(config.resourcesPathOverride, {
onNone: () => input.resourcesPath,
onSome: (override) => path.resolve(override),
});
const serverRoot =
input.isPackaged && input.platform === "win32"
? path.join(input.resourcesPath, "server.asar")
? path.join(resourcesPath, "server.asar")
: appRoot;
const branding = resolveDesktopAppBranding({
isDevelopment,
Expand All @@ -194,8 +201,6 @@ const make = Effect.fn("desktop.environment.make")(function* (
Option.getOrElse(config.xdgDataHome, () => path.join(homeDirectory, ".local", "share")),
"applications",
);
const resourcesPath = input.resourcesPath;

return DesktopEnvironment.of({
path,
dirname: input.dirname,
Expand Down
6 changes: 6 additions & 0 deletions docs/operations/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ DMGs default to the host architecture. Use `--arch` to choose another target and
to retain packaging files for inspection. Run `vp run dist:desktop:artifact --help` for other
options.

### Distribution packages

Packages that run the app on a shared Electron, such as `electron /usr/lib/t3code/app.asar`, set
`T3CODE_DESKTOP_RESOURCES_PATH` to the directory holding the app's resources. Otherwise the app
looks in Electron's own resources directory and finds none of its helpers.

### Linux AppImage prerequisites

Build on Linux because the browser-secret helper links against the host's libsecret. Install
Expand Down
Loading