@devries-cameron20 / t3code-1 / commits / edb12401e5
Fork 0

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

fix(cli): publish nightly branded favicons (#4372)

maria committed Jul 23, 2026 at 17:36 UTC edb12401e547be4806836077f336295c58097c9b
3 files changed +53 -61
apps/server/scripts/cli.ts
+41 -56
@@ -12,7 +12,8 @@ import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
12
13 import {
14 DEVELOPMENT_ICON_OVERRIDES,
15 - PUBLISH_ICON_OVERRIDES,
15 + resolveWebAssetBrandForPackageVersion,
16 + resolveWebIconOverrides,
17 } from "../../../scripts/lib/brand-assets.ts";
18 import { resolveCatalogDependencies } from "../../../scripts/lib/resolve-catalog.ts";
19 import { fromJsonStringPretty } from "@t3tools/shared/schemaJson";
@@ -81,50 +82,34 @@ const runCommand = Effect.fn("runCommand")(function* (command: ChildProcess.Stan
82 }
83 });
84
84 -interface PublishIconBackup {
85 - readonly targetPath: string;
86 - readonly backupPath: string;
87 -}
88 -
89 -const applyPublishIconOverrides = Effect.fn("applyPublishIconOverrides")(function* (
85 +const preparePublishIcons = Effect.fn("preparePublishIcons")(function* (
86 repoRoot: string,
87 serverDir: string,
88 + version: string,
89 ) {
90 const path = yield* Path.Path;
91 const fs = yield* FileSystem.FileSystem;
95 - const backups: PublishIconBackup[] = [];
96 -
97 - for (const override of PUBLISH_ICON_OVERRIDES) {
98 - const sourcePath = path.join(repoRoot, override.sourceRelativePath);
99 - const targetPath = path.join(serverDir, override.targetRelativePath);
100 - const backupPath = `${targetPath}.publish-bak`;
101 -
102 - if (!(yield* fs.exists(sourcePath))) {
103 - return yield* new ServerCliPublishIconSourceMissingError({ sourcePath });
92 + const brand = resolveWebAssetBrandForPackageVersion(version);
93 + const icons = resolveWebIconOverrides(brand, "dist/client").map((override) => ({
94 + sourcePath: path.join(repoRoot, override.sourceRelativePath),
95 + targetPath: path.join(serverDir, override.targetRelativePath),
96 + }));
97 +
98 + for (const icon of icons) {
99 + if (!(yield* fs.exists(icon.sourcePath))) {
100 + return yield* new ServerCliPublishIconSourceMissingError({ sourcePath: icon.sourcePath });
101 }
105 - if (!(yield* fs.exists(targetPath))) {
106 - return yield* new ServerCliPublishIconTargetMissingError({ targetPath });
102 + if (!(yield* fs.exists(icon.targetPath))) {
103 + return yield* new ServerCliPublishIconTargetMissingError({ targetPath: icon.targetPath });
104 }
108 -
109 - yield* fs.copyFile(targetPath, backupPath);
110 - yield* fs.copyFile(sourcePath, targetPath);
111 - backups.push({ targetPath, backupPath });
105 }
106
114 - yield* Effect.log("[cli] Applied publish icon overrides to dist/client");
115 - return backups as ReadonlyArray<PublishIconBackup>;
116 -});
117 -
118 -const restorePublishIconOverrides = Effect.fn("restorePublishIconOverrides")(function* (
119 - backups: ReadonlyArray<PublishIconBackup>,
120 -) {
121 - const fs = yield* FileSystem.FileSystem;
122 - for (const backup of backups) {
123 - if (!(yield* fs.exists(backup.backupPath))) {
124 - continue;
125 - }
126 - yield* fs.rename(backup.backupPath, backup.targetPath);
127 - }
107 + return yield* Effect.forEach(icons, (icon) =>
108 + Effect.all({
109 + original: fs.readFile(icon.targetPath),
110 + publish: fs.readFile(icon.sourcePath),
111 + }).pipe(Effect.map((contents) => ({ ...icon, ...contents }))),
112 + );
113 });
114
115 const applyDevelopmentIconOverrides = Effect.fn("applyDevelopmentIconOverrides")(function* (
@@ -236,7 +221,6 @@ const publishCmd = Command.make(
221 const repoRoot = yield* RepoRoot;
222 const serverDir = path.join(repoRoot, "apps/server");
223 const packageJsonPath = path.join(serverDir, "package.json");
239 - const backupPath = `${packageJsonPath}.bak`;
224
225 // Assert build assets exist
226 for (const relPath of ["dist/bin.mjs", "dist/client/index.html"]) {
@@ -247,7 +231,7 @@ const publishCmd = Command.make(
231 }
232
233 yield* Effect.acquireUseRelease(
250 - // Acquire: backup package.json, resolve catalog dependencies, and strip devDependencies/scripts
234 + // Acquire: resolve publish metadata and read every original before mutation.
235 Effect.gen(function* () {
236 const version = Option.getOrElse(config.appVersion, () => serverPackageJson.version);
237 const workspaceConfig = yield* readWorkspaceConfig();
@@ -273,19 +257,22 @@ const publishCmd = Command.make(
257 ),
258 };
259
276 - const original = yield* fs.readFileString(packageJsonPath);
277 - const packageJsonString = yield* encodePackageJson(pkg);
278 - yield* fs.writeFileString(backupPath, original);
279 - yield* fs.writeFileString(packageJsonPath, `${packageJsonString}\n`);
280 - yield* Effect.log("[cli] Prepared package.json for publish");
281 -
282 - const iconBackups = yield* applyPublishIconOverrides(repoRoot, serverDir);
283 - return { iconBackups };
260 + return {
261 + packageJsonString: yield* encodePackageJson(pkg),
262 + originalPackageJson: yield* fs.readFile(packageJsonPath),
263 + icons: yield* preparePublishIcons(repoRoot, serverDir, version),
264 + };
265 }),
266 // Use: pnpm publish from the workspace root so pnpm-only workspace
267 // config, including override selectors, is interpreted correctly.
287 - () =>
268 + (resource) =>
269 Effect.gen(function* () {
270 + yield* fs.writeFileString(packageJsonPath, `${resource.packageJsonString}\n`);
271 + for (const icon of resource.icons) {
272 + yield* fs.writeFile(icon.targetPath, icon.publish);
273 + }
274 + yield* Effect.log("[cli] Applied package metadata and publish icon overrides");
275 +
276 const args = createVpPmPublishArgs(config);
277 const spawnCommand = yield* resolveSpawnCommand("vp", ["pm", ...args]);
278
@@ -299,16 +286,14 @@ const publishCmd = Command.make(
286 }),
287 );
288 }),
302 - // Release: restore
303 - (resource: { readonly iconBackups: ReadonlyArray<PublishIconBackup> }) =>
289 + // Release: restore every file even if applying overrides or publishing fails.
290 + (resource) =>
291 Effect.gen(function* () {
305 - yield* restorePublishIconOverrides(resource.iconBackups).pipe(
306 - Effect.catch((error) =>
307 - Effect.logError(`[cli] Failed to restore publish icon overrides: ${String(error)}`),
308 - ),
309 - );
310 - yield* fs.rename(backupPath, packageJsonPath);
311 - if (config.verbose) yield* Effect.log("[cli] Restored original package.json");
292 + yield* fs.writeFile(packageJsonPath, resource.originalPackageJson);
293 + for (const icon of resource.icons) {
294 + yield* fs.writeFile(icon.targetPath, icon.original);
295 + }
296 + if (config.verbose) yield* Effect.log("[cli] Restored original publish assets");
297 }),
298 );
299 }),
scripts/lib/brand-assets.test.ts
+8 -3
@@ -4,14 +4,14 @@ import {
4 BRAND_ASSET_PATHS,
5 DEVELOPMENT_ICON_OVERRIDES,
6 DEVELOPMENT_PUBLIC_ICON_OVERRIDES,
7 - PUBLISH_ICON_OVERRIDES,
7 resolveWebAssetBrandForChannel,
8 + resolveWebAssetBrandForPackageVersion,
9 resolveWebIconOverrides,
10 } from "./brand-assets.ts";
11
12 describe("brand-assets", () => {
13 - it("maps server publish web assets to production icons", () => {
14 - expect(PUBLISH_ICON_OVERRIDES).toEqual([
13 + it("maps production web assets into the server package", () => {
14 + expect(resolveWebIconOverrides("production", "dist/client")).toEqual([
15 {
16 sourceRelativePath: BRAND_ASSET_PATHS.productionWebFaviconIco,
17 targetRelativePath: "dist/client/favicon.ico",
@@ -78,6 +78,11 @@ describe("brand-assets", () => {
78 expect(resolveWebAssetBrandForChannel("nightly")).toBe("nightly");
79 });
80
81 + it("maps package versions to web asset brands", () => {
82 + expect(resolveWebAssetBrandForPackageVersion("0.0.29")).toBe("production");
83 + expect(resolveWebAssetBrandForPackageVersion("0.0.29-nightly.20260723.882")).toBe("nightly");
84 + });
85 +
86 it("keeps development, nightly, and production icon families separate", () => {
87 expect([
88 BRAND_ASSET_PATHS.developmentIconComposerProject,
scripts/lib/brand-assets.ts
+4 -2
@@ -41,6 +41,10 @@ export function resolveWebAssetBrandForChannel(channel: WebAssetChannel): WebAss
41 return channel === "nightly" ? "nightly" : "production";
42 }
43
44 +export function resolveWebAssetBrandForPackageVersion(version: string): WebAssetBrand {
45 + return version.includes("-nightly.") ? "nightly" : "production";
46 +}
47 +
48 export interface IconOverride {
49 readonly sourceRelativePath: string;
50 readonly targetRelativePath: string;
@@ -105,5 +109,3 @@ export const DEVELOPMENT_PUBLIC_ICON_OVERRIDES = resolveWebIconOverrides(
109 "development",
110 "apps/web/public",
111 );
108 -
109 -export const PUBLISH_ICON_OVERRIDES = resolveWebIconOverrides("production", "dist/client");