From b4bd1f2dcaa92cddcbdbd7bd0a7c6eb48b673dca Mon Sep 17 00:00:00 2001 From: lvyanpu Date: Wed, 25 Nov 2026 15:16:44 +0800 Subject: [PATCH 1/2] fix(cli): accept uppercase JSON theme file extensions --- apps/server/src/cli/theme.test.ts | 44 ++++++++++++++++++++----------- apps/server/src/cli/theme.ts | 5 ++-- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/apps/server/src/cli/theme.test.ts b/apps/server/src/cli/theme.test.ts index d2e72dd7e1cc..14f4f841b3a9 100644 --- a/apps/server/src/cli/theme.test.ts +++ b/apps/server/src/cli/theme.test.ts @@ -129,22 +129,34 @@ describe("t3 theme", () => { }), ); - it.effect("publishes a theme file under its filename and sets it", () => - Effect.gen(function* () { - const baseDir = makeBaseDir(); - const themeFile = NodePath.join(baseDir, "nightfall.json"); - NodeFS.writeFileSync(themeFile, NIGHTFALL_THEME_JSON); - - yield* runCli(["theme", "set", themeFile, "--base-dir", baseDir]); - - const published = NodePath.join(baseDir, "userdata", "themes", "nightfall.json"); - assert.equal(NodeFS.existsSync(published), true); - assert.equal(readSettings(baseDir).defaultTheme, "nightfall"); - const residue = NodeFS.readdirSync(NodePath.dirname(published)).filter( - (entry) => !entry.endsWith(".json"), - ); - assert.deepEqual(residue, []); - }), + it.effect.each([ + { extension: "json", relativePath: null }, + { extension: "JSON", relativePath: "nightfall.JSON" }, + { extension: "JsOn", relativePath: "./nightfall.JsOn" }, + ])( + "publishes a .$extension theme file under its filename and sets it", + ({ extension, relativePath }) => + Effect.gen(function* () { + const baseDir = makeBaseDir(); + const themeFile = NodePath.join(baseDir, `nightfall.${extension}`); + NodeFS.writeFileSync(themeFile, NIGHTFALL_THEME_JSON); + + yield* runCliIn(baseDir, [ + "theme", + "set", + relativePath ?? themeFile, + "--base-dir", + baseDir, + ]); + + const published = NodePath.join(baseDir, "userdata", "themes", "nightfall.json"); + assert.equal(NodeFS.readFileSync(published, "utf8"), NIGHTFALL_THEME_JSON); + assert.equal(readSettings(baseDir).defaultTheme, "nightfall"); + const residue = NodeFS.readdirSync(NodePath.dirname(published)).filter( + (entry) => !entry.endsWith(".json"), + ); + assert.deepEqual(residue, []); + }), ); it.effect("publishes the file named with a leading space, not its trimmed sibling", () => diff --git a/apps/server/src/cli/theme.ts b/apps/server/src/cli/theme.ts index ba9e89c17a2b..c6f0f97f8e17 100644 --- a/apps/server/src/cli/theme.ts +++ b/apps/server/src/cli/theme.ts @@ -40,6 +40,7 @@ const decodeThemeFileJsonExit = Schema.decodeUnknownExit( Schema.fromJsonString(EnvironmentThemeFile), ); const isEnvironmentThemeId = Schema.is(EnvironmentThemeId); +const THEME_JSON_SUFFIX = /\.json$/i; export class ThemeSettingsUnreadableError extends Schema.TaggedError()( "ThemeSettingsUnreadableError", @@ -311,7 +312,7 @@ const publishThemeFile = Effect.fn(function* (input: { return yield* new ThemeFileColorlessError({ filePath: input.filePath }); } - const fileBasename = path.basename(input.filePath, ".json"); + const fileBasename = path.basename(input.filePath).replace(THEME_JSON_SUFFIX, ""); const themeId = Option.getOrElse(input.explicitId, () => fileBasename); // Match watcher validation so published files will not be skipped. if (!isEnvironmentThemeId(themeId) || UNPUBLISHABLE_THEME_IDS.has(themeId)) { @@ -464,7 +465,7 @@ const themeSetCommand = Command.make("set", { // A bare theme id must not publish a same-named file that happens to exist in cwd. const looksLikePath = - target.endsWith(".json") || + THEME_JSON_SUFFIX.test(target) || target.includes("/") || target.includes("\\") || target.startsWith("~"); From c27eb9fae018097f2b244fee9fc32b1d0d24cf2c Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Wed, 25 Nov 2026 07:26:23 +0000 Subject: [PATCH 2/2] test(cli): drop redundant mixed-case theme extension case Co-Authored-By: Claude Opus 5.5 --- apps/server/src/cli/theme.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/server/src/cli/theme.test.ts b/apps/server/src/cli/theme.test.ts index 14f4f841b3a9..7a503498efde 100644 --- a/apps/server/src/cli/theme.test.ts +++ b/apps/server/src/cli/theme.test.ts @@ -132,7 +132,6 @@ describe("t3 theme", () => { it.effect.each([ { extension: "json", relativePath: null }, { extension: "JSON", relativePath: "nightfall.JSON" }, - { extension: "JsOn", relativePath: "./nightfall.JsOn" }, ])( "publishes a .$extension theme file under its filename and sets it", ({ extension, relativePath }) =>