@devries-cameron20 / t3code-1 / commits / 1288909b66
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(release): surface desktop packaging subprocess output (#2937)

Co-authored-by: Julius Marminge <julius@mac.lan>

Julius Marminge committed Jun 3, 2026 at 20:47 UTC 1288909b6611436e8cb2c4084f9e197408caa8b4
1 file changed +82 -31
scripts/build-desktop-artifact.ts
+82 -31
@@ -121,6 +121,36 @@ const collectStreamAsString = <E>(stream: Stream.Stream<Uint8Array, E>): Effect.
121 ),
122 );
123
124 +const COMMAND_OUTPUT_TAIL_LENGTH = 20_000;
125 +
126 +function appendOutputTail(acc: string, chunk: string): string {
127 + const next = acc + chunk;
128 + return next.length > COMMAND_OUTPUT_TAIL_LENGTH ? next.slice(-COMMAND_OUTPUT_TAIL_LENGTH) : next;
129 +}
130 +
131 +function formatOutputSection(label: string, output: string): string | undefined {
132 + const trimmed = output.trim();
133 + if (!trimmed) return undefined;
134 + return `${label} tail:\n${trimmed}`;
135 +}
136 +
137 +const collectCommandStream = <E>(
138 + stream: Stream.Stream<Uint8Array, E>,
139 + output: NodeJS.WriteStream,
140 + verbose: boolean,
141 +): Effect.Effect<string, E> =>
142 + stream.pipe(
143 + Stream.decodeText(),
144 + Stream.runFoldEffect(
145 + () => "",
146 + (acc, chunk) =>
147 + Effect.as(
148 + verbose ? Effect.sync(() => output.write(chunk)) : Effect.void,
149 + appendOutputTail(acc, chunk),
150 + ),
151 + ),
152 + );
153 +
154 const spawnAndCollectOutput = Effect.fn("spawnAndCollectOutput")(function* (
155 command: ChildProcess.Command,
156 ) {
@@ -353,20 +383,33 @@ export const resolveBuildOptions = Effect.fn("resolveBuildOptions")(function* (
383 } satisfies ResolvedBuildOptions;
384 });
385
356 -const commandOutputOptions = (verbose: boolean) =>
357 - ({
358 - stdout: verbose ? "inherit" : "ignore",
359 - stderr: "inherit",
360 - }) as const;
361 -
362 -const runCommand = Effect.fn("runCommand")(function* (command: ChildProcess.Command) {
386 +const runCommand = Effect.fn("runCommand")(function* (
387 + command: ChildProcess.Command,
388 + options: {
389 + readonly label?: string;
390 + readonly verbose: boolean;
391 + },
392 +) {
393 const commandSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
394 const child = yield* commandSpawner.spawn(command);
365 - const exitCode = yield* child.exitCode;
395 + const [stdout, stderr, exitCode] = yield* Effect.all(
396 + [
397 + collectCommandStream(child.stdout, process.stdout, options.verbose),
398 + collectCommandStream(child.stderr, process.stderr, options.verbose),
399 + child.exitCode.pipe(Effect.map(Number)),
400 + ],
401 + { concurrency: "unbounded" },
402 + );
403
404 if (exitCode !== 0) {
405 + const outputSections = [
406 + options.label ? `Command: ${options.label}` : undefined,
407 + formatOutputSection("stdout", stdout),
408 + formatOutputSection("stderr", stderr),
409 + ].filter((section): section is string => section !== undefined);
410 + const outputSuffix = outputSections.length > 0 ? `\n\n${outputSections.join("\n\n")}` : "";
411 return yield* new BuildScriptError({
369 - message: `Command exited with non-zero exit code (${exitCode})`,
412 + message: `Command exited with non-zero exit code (${exitCode})${outputSuffix}`,
413 });
414 }
415 });
@@ -386,24 +429,25 @@ function generateMacIconSet(
429 const iconSizes = [16, 32, 128, 256, 512] as const;
430 for (const size of iconSizes) {
431 yield* runCommand(
389 - ChildProcess.make({
390 - ...commandOutputOptions(verbose),
391 - })`sips -z ${size} ${size} ${sourcePng} --out ${path.join(iconsetDir, `icon_${size}x${size}.png`)}`,
432 + ChildProcess.make(
433 + {},
434 + )`sips -z ${size} ${size} ${sourcePng} --out ${path.join(iconsetDir, `icon_${size}x${size}.png`)}`,
435 + { label: `sips icon ${size}x${size}`, verbose },
436 );
437
438 const retinaSize = size * 2;
439 yield* runCommand(
396 - ChildProcess.make({
397 - ...commandOutputOptions(verbose),
398 - })`sips -z ${retinaSize} ${retinaSize} ${sourcePng} --out ${path.join(iconsetDir, `icon_${size}x${size}@2x.png`)}`,
440 + ChildProcess.make(
441 + {},
442 + )`sips -z ${retinaSize} ${retinaSize} ${sourcePng} --out ${path.join(iconsetDir, `icon_${size}x${size}@2x.png`)}`,
443 + { label: `sips icon ${size}x${size}@2x`, verbose },
444 );
445 }
446
402 - yield* runCommand(
403 - ChildProcess.make({
404 - ...commandOutputOptions(verbose),
405 - })`iconutil -c icns ${iconsetDir} -o ${targetIcns}`,
406 - );
447 + yield* runCommand(ChildProcess.make({})`iconutil -c icns ${iconsetDir} -o ${targetIcns}`, {
448 + label: "iconutil icns",
449 + verbose,
450 + });
451 });
452 }
453
@@ -424,11 +468,10 @@ function stageMacIcons(stageResourcesDir: string, sourcePng: string, verbose: bo
468 const iconPngPath = path.join(stageResourcesDir, "icon.png");
469 const iconIcnsPath = path.join(stageResourcesDir, "icon.icns");
470
427 - yield* runCommand(
428 - ChildProcess.make({
429 - ...commandOutputOptions(verbose),
430 - })`sips -z 512 512 ${sourcePng} --out ${iconPngPath}`,
431 - );
471 + yield* runCommand(ChildProcess.make({})`sips -z 512 512 ${sourcePng} --out ${iconPngPath}`, {
472 + label: "sips mac icon",
473 + verbose,
474 + });
475
476 yield* generateMacIconSet(sourcePng, iconIcnsPath, tmpRoot, path, verbose);
477 });
@@ -468,9 +511,8 @@ function stageLinuxIconSize(
511 ) {
512 const resize = (command: string) =>
513 runCommand(
471 - ChildProcess.make(command, [sourcePng, "-resize", `${iconSize}x${iconSize}`, targetPng], {
472 - ...commandOutputOptions(verbose),
473 - }),
514 + ChildProcess.make(command, [sourcePng, "-resize", `${iconSize}x${iconSize}`, targetPng]),
515 + { label: `${command} linux icon ${iconSize}x${iconSize}`, verbose },
516 );
517
518 return resize("magick").pipe(
@@ -778,10 +820,10 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
820 yield* runCommand(
821 ChildProcess.make({
822 cwd: repoRoot,
781 - ...commandOutputOptions(options.verbose),
823 // Windows needs shell mode to resolve .cmd shims (e.g. vp.cmd).
824 shell: process.platform === "win32",
825 })`vp run build:desktop`,
826 + { label: "vp run build:desktop", verbose: options.verbose },
827 );
828 }
829
@@ -858,10 +900,10 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
900 yield* runCommand(
901 ChildProcess.make({
902 cwd: stageAppDir,
861 - ...commandOutputOptions(options.verbose),
903 // Windows needs shell mode to resolve .cmd shims (e.g. vp.cmd).
904 shell: process.platform === "win32",
905 })`vp install --prod --no-optional`,
906 + { label: "vp install --prod --no-optional", verbose: options.verbose },
907 );
908
909 const buildEnv: NodeJS.ProcessEnv = {
@@ -890,6 +932,12 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
932 buildEnv.npm_config_msvs_version = buildEnv.npm_config_msvs_version ?? "2022";
933 buildEnv.GYP_MSVS_VERSION = buildEnv.GYP_MSVS_VERSION ?? "2022";
934 }
935 + if (options.verbose) {
936 + buildEnv.DEBUG =
937 + buildEnv.DEBUG === undefined || buildEnv.DEBUG === ""
938 + ? "electron-builder,electron-builder:*"
939 + : `${buildEnv.DEBUG},electron-builder,electron-builder:*`;
940 + }
941
942 yield* Effect.log(
943 `[desktop-artifact] Building ${options.platform}/${options.target} (arch=${options.arch}, version=${appVersion})...`,
@@ -898,10 +946,13 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
946 ChildProcess.make({
947 cwd: stageAppDir,
948 env: buildEnv,
901 - ...commandOutputOptions(options.verbose),
949 // Windows needs shell mode to resolve .cmd shims.
950 shell: process.platform === "win32",
951 })`vp dlx electron-builder ${platformConfig.cliFlag} --${options.arch} --publish never`,
952 + {
953 + label: `vp dlx electron-builder ${platformConfig.cliFlag} --${options.arch} --publish never`,
954 + verbose: options.verbose,
955 + },
956 );
957
958 const stageDistDir = path.join(stageAppDir, "dist");