Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(cli): browser setup installs missing fonts #17570

Mergedadrilasar(GitHub profile, opens in a new tab)merged 5 commits intomain fromrefs/pull/17570/headmerged by juliusmarminge View on GitHub

Showing 3 changed files with 179 additions and 5 deletions (loading 1).

x
0 of 3 viewed, 3 left
118 additions and 0 deletionsapps/server/src/cli/browser.test.tsModified
View file
@@ -4,11 +4,94 @@
import * as Effect from "effect/Effect";
import * as FileSystem from "effect/FileSystem";
import * as Layer from "effect/Layer";
+import * as PlatformError from "effect/PlatformError";
+import * as Sink from "effect/Sink";
+import * as Stream from "effect/Stream";
import * as TestConsole from "effect/testing/TestConsole";
import { Command } from "effect/cli";
+import * as ChildProcess from "effect/process/ChildProcess";
+import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
​
import { browserCommand } from "./browser.ts";
​
+const BROWSER = "/t3/tools/chrome-headless-shell/linux64/154/chrome-headless-shell";
+const FONT = "/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf";
+​
+/**
+ * Records every command. `fc-match` is missing until fonts are installed, unless
+ * the host starts with a font; the browser fails to load libnss3 when asked to.
+ */
+const fakeSpawner = (host: { readonly font?: string; readonly missingLibrary?: boolean }) => {
+ const commands: Array<ReadonlyArray<string>> = [];
+ let font = host.font;
+ const spawner = ChildProcessSpawner.make((command) =>
+ Effect.gen(function* () {
+ if (!ChildProcess.isStandardCommand(command)) return yield* Effect.die("Unexpected pipeline");
+ commands.push([command.command, ...command.args]);
+ if (command.command === "apt-get" && command.args.includes("fonts-liberation")) font = FONT;
+ if (command.command === "fc-match" && font === undefined) {