@devries-cameron20 / t3code Mirror · read-only / commits / 771afdac8d
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 10:45 UTC

fix(build): preserve directory desktop artifacts and framework symlinks (#24434)

Co-authored-by: Zayd <iam@zayd.wtf> Co-authored-by: maria-rcks <maria@kuuro.net>

zayd / cold committed Oct 30, 2026 at 14:05 UTC 771afdac8d5fa1a0f35e668567e9e55129a66883
2 files changed +95 -13
scripts/build-desktop-artifact.test.ts
+55
@@ -22,6 +22,7 @@ import { ChildProcess, ChildProcessSpawner } from "effect/process";
22
23 import {
24 buildDesktopBundles,
25 + copyDesktopBuildArtifacts,
26 DesktopBuildManifestRestoreError,
27 BundleNotSelfContainedError,
28 BuildCommandFailedError,
@@ -1745,3 +1746,57 @@ it.effect.skipIf(!symlinksSupported)("rebases packaged links into the isolated t
1746 );
1747 }).pipe(Effect.provide(NodeServices.layer)),
1748 );
1749 +
1750 +it.effect("preserves packaged app directories from the dir target", () =>
1751 + Effect.gen(function* () {
1752 + const fs = yield* FileSystem.FileSystem;
1753 + const path = yield* Path.Path;
1754 + const root = yield* fs.makeTempDirectoryScoped({ prefix: "t3-dir-artifact-" });
1755 + const stage = path.join(root, "stage");
1756 + const output = path.join(root, "output");
1757 + const app = path.join("mac-arm64", "T3 Code.app", "Contents");
1758 + yield* fs.makeDirectory(path.join(stage, app), { recursive: true });
1759 + yield* fs.writeFileString(path.join(stage, app, "Info.plist"), "built-app");
1760 + yield* fs.writeFileString(path.join(stage, "builder-debug.yml"), "debug");
1761 + const copied = yield* copyDesktopBuildArtifacts(stage, output, true);
1762 + assert.include(copied, path.join(output, "mac-arm64"));
1763 + assert.equal(yield* fs.readFileString(path.join(output, app, "Info.plist")), "built-app");
1764 + assert.equal(yield* fs.readFileString(path.join(stage, app, "Info.plist")), "built-app");
1765 + yield* fs.remove(path.join(stage, app, "Info.plist"));
1766 + yield* fs.writeFileString(path.join(stage, app, "New.plist"), "rebuilt-app");
1767 + yield* copyDesktopBuildArtifacts(stage, output, true);
1768 + assert.isFalse(yield* fs.exists(path.join(output, app, "Info.plist")));
1769 + assert.equal(yield* fs.readFileString(path.join(output, app, "New.plist")), "rebuilt-app");
1770 + const filesOnly = yield* copyDesktopBuildArtifacts(stage, path.join(root, "files-only"));
1771 + assert.deepEqual(filesOnly, [path.join(root, "files-only", "builder-debug.yml")]);
1772 + assert.isFalse(yield* fs.exists(path.join(root, "files-only", "mac-arm64")));
1773 + yield* fs.remove(path.join(stage, "mac-arm64"), { recursive: true });
1774 + yield* fs.writeFileString(path.join(stage, "mac-arm64"), "flattened");
1775 + yield* copyDesktopBuildArtifacts(stage, output, true);
1776 + assert.equal(yield* fs.readFileString(path.join(output, "mac-arm64")), "flattened");
1777 + }).pipe(Effect.provide(NodeServices.layer), Effect.scoped),
1778 +);
1779 +
1780 +it.effect.skipIf(!symlinksSupported)("preserves relative links when replacing dir artifacts", () =>
1781 + Effect.gen(function* () {
1782 + const fs = yield* FileSystem.FileSystem;
1783 + const path = yield* Path.Path;
1784 + const root = yield* fs.makeTempDirectoryScoped({ prefix: "t3-dir-artifact-links-" });
1785 + const stage = path.join(root, "stage");
1786 + const output = path.join(root, "output");
1787 + const app = path.join("mac-arm64", "T3 Code.app", "Contents");
1788 + yield* fs.makeDirectory(path.join(stage, app), { recursive: true });
1789 + yield* fs.writeFileString(path.join(stage, app, "Info.plist"), "built-app");
1790 + yield* fs.symlink("Info.plist", path.join(stage, app, "Current"));
1791 + yield* copyDesktopBuildArtifacts(stage, output, true);
1792 + assert.equal(yield* fs.readLink(path.join(output, app, "Current")), "Info.plist");
1793 + assert.equal(yield* fs.readFileString(path.join(output, app, "Current")), "built-app");
1794 +
1795 + yield* fs.remove(path.join(stage, app, "Current"));
1796 + yield* fs.writeFileString(path.join(stage, app, "New.plist"), "rebuilt-app");
1797 + yield* fs.symlink("New.plist", path.join(stage, app, "Current"));
1798 + yield* copyDesktopBuildArtifacts(stage, output, true);
1799 + assert.equal(yield* fs.readLink(path.join(output, app, "Current")), "New.plist");
1800 + assert.equal(yield* fs.readFileString(path.join(output, app, "Current")), "rebuilt-app");
1801 + }).pipe(Effect.provide(NodeServices.layer), Effect.scoped),
1802 +);
scripts/build-desktop-artifact.ts
+40 -13
@@ -4057,19 +4057,11 @@ const buildDesktopArtifactUnlocked = Effect.fn("buildDesktopArtifactUnlocked")(f
4057 yield* validateMacPackagedPayload({ stageDistDir, verbose: options.verbose });
4058 }
4059
4060 - const stageEntries = yield* fs.readDirectory(stageDistDir);
4061 - yield* fs.makeDirectory(options.outputDir, { recursive: true });
4062 -
4063 - const copiedArtifacts: string[] = [];
4064 - for (const entry of stageEntries) {
4065 - const from = path.join(stageDistDir, entry);
4066 - const stat = yield* fs.stat(from).pipe(Effect.orElseSucceed(() => null));
4067 - if (!stat || stat.type !== "File") continue;
4068 -
4069 - const to = path.join(options.outputDir, entry);
4070 - yield* fs.copyFile(from, to);
4071 - copiedArtifacts.push(to);
4072 - }
4060 + const copiedArtifacts = yield* copyDesktopBuildArtifacts(
4061 + stageDistDir,
4062 + options.outputDir,
4063 + options.target === "dir",
4064 + );
4065
4066 if (copiedArtifacts.length === 0) {
4067 return yield* new DesktopBuildNoArtifactsProducedError({
@@ -4091,6 +4083,41 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
4083 return yield* withDesktopBuildLock(repoRoot, buildDesktopArtifactUnlocked(options));
4084 });
4085
4086 +export const copyDesktopBuildArtifacts = Effect.fn("copyDesktopBuildArtifacts")(function* (
4087 + stageDistDir: string,
4088 + outputDir: string,
4089 + includeDirectories = false,
4090 +) {
4091 + const fs = yield* FileSystem.FileSystem;
4092 + const path = yield* Path.Path;
4093 + const stageEntries = yield* fs.readDirectory(stageDistDir);
4094 + yield* fs.makeDirectory(outputDir, { recursive: true });
4095 +
4096 + const copiedArtifacts: string[] = [];
4097 + for (const entry of stageEntries) {
4098 + const from = path.join(stageDistDir, entry);
4099 + const stat = yield* fs.stat(from).pipe(Effect.orElseSucceed(() => null));
4100 + if (!stat || (stat.type !== "File" && !(includeDirectories && stat.type === "Directory")))
4101 + continue;
4102 +
4103 + const to = path.join(outputDir, entry);
4104 + // Replace whatever a reused output dir already holds at this path. fs.cp refuses to
4105 + // overwrite a directory with a file or a file with a directory, and only merges into
4106 + // an existing directory, so a stale entry of either type must go first.
4107 + yield* fs.remove(to, { recursive: true, force: true });
4108 + yield* Effect.tryPromise(() =>
4109 + NodeFSP.cp(from, to, {
4110 + recursive: true,
4111 + force: true,
4112 + verbatimSymlinks: true,
4113 + }),
4114 + );
4115 + copiedArtifacts.push(to);
4116 + }
4117 +
4118 + return copiedArtifacts;
4119 +});
4120 +
4121 const buildDesktopArtifactCli = Command.make("build-desktop-artifact", {
4122 platform: Flag.Literals("platform", BuildPlatform.literals).pipe(
4123 Flag.withDescription("Build platform (env: T3CODE_DESKTOP_PLATFORM)."),