diff --git a/docs/development.md b/docs/development.md index 7c4ed1cf..fdb3777b 100644 --- a/docs/development.md +++ b/docs/development.md @@ -26,7 +26,7 @@ The source tree is organized by responsibility rather than by the original singl - `src/shared/` contains feature-neutral helpers, including reusable DOM pieces and unified diff display helpers shared by chat and selection rewrite. - `src/settings/` contains Obsidian settings models, settings-tab rendering, and app-server-backed dynamic settings data. - `src/domain/threads/` contains thread title, reference, and archive export helpers shared outside the chat feature. -- `src/styles/` contains the authored CSS modules and `manifest.json` concatenation order. `scripts/build-styles.mjs` concatenates them into the ignored root `styles.css`, which remains the Obsidian release asset. +- `src/styles/` contains the authored CSS modules and `order.json` concatenation order. `scripts/build-styles.mjs` concatenates them into the ignored root `styles.css`, which remains the Obsidian release asset. Keep new code near the state or API it owns. Feature code should not import from another feature directly; move shared behavior to `src/shared/`, `src/domain/`, `src/app-server/`, or `src/runtime/` when more than one feature needs it. diff --git a/scripts/build-styles.mjs b/scripts/build-styles.mjs index 5f79c697..442fcc86 100644 --- a/scripts/build-styles.mjs +++ b/scripts/build-styles.mjs @@ -3,7 +3,7 @@ import path from "node:path"; import { fileURLToPath } from "node:url"; const sourceDir = path.join("src", "styles"); -const manifestPath = path.join(sourceDir, "manifest.json"); +const orderPath = path.join(sourceDir, "order.json"); const outputPath = "styles.css"; const checkMode = process.argv.includes("--check"); const validArgs = new Set(["--check"]); @@ -29,14 +29,14 @@ export async function buildStyles() { } async function checkStyles() { - await checkStyleManifest(); + await checkStyleOrder(); await renderStyles(); } export async function renderStyles() { const parts = []; - const sourceFiles = await readStyleManifest(); + const sourceFiles = await readStyleOrder(); for (const file of sourceFiles) { const content = await readFile(path.join(sourceDir, file), "utf8"); parts.push(content.trimEnd()); @@ -45,16 +45,16 @@ export async function renderStyles() { return `${parts.join("\n\n")}\n`; } -async function readStyleManifest() { - const value = JSON.parse(await readFile(manifestPath, "utf8")); +async function readStyleOrder() { + const value = JSON.parse(await readFile(orderPath, "utf8")); if (!Array.isArray(value) || !value.every((item) => typeof item === "string")) { - throw new Error(`${manifestPath} must be a JSON array of CSS file names.`); + throw new Error(`${orderPath} must be a JSON array of CSS file names.`); } return value; } -async function checkStyleManifest() { - const sourceFiles = await readStyleManifest(); +async function checkStyleOrder() { + const sourceFiles = await readStyleOrder(); const listed = new Set(sourceFiles); const duplicates = sourceFiles.filter((file, index) => sourceFiles.indexOf(file) !== index); const actual = (await readdir(sourceDir)).filter((file) => file.endsWith(".css")).sort((left, right) => left.localeCompare(right)); @@ -64,8 +64,8 @@ async function checkStyleManifest() { if (duplicates.length === 0 && missing.length === 0 && unlisted.length === 0) return; - if (duplicates.length > 0) console.error(`Duplicate entries in ${manifestPath}: ${[...new Set(duplicates)].join(", ")}`); + if (duplicates.length > 0) console.error(`Duplicate entries in ${orderPath}: ${[...new Set(duplicates)].join(", ")}`); if (missing.length > 0) console.error(`Listed CSS files missing from ${sourceDir}: ${missing.join(", ")}`); - if (unlisted.length > 0) console.error(`CSS files missing from ${manifestPath}: ${unlisted.join(", ")}`); + if (unlisted.length > 0) console.error(`CSS files missing from ${orderPath}: ${unlisted.join(", ")}`); process.exit(1); } diff --git a/src/styles/manifest.json b/src/styles/order.json similarity index 100% rename from src/styles/manifest.json rename to src/styles/order.json diff --git a/tests/scripts/development-scripts.test.ts b/tests/scripts/development-scripts.test.ts index e9eb6431..cf77b3a3 100644 --- a/tests/scripts/development-scripts.test.ts +++ b/tests/scripts/development-scripts.test.ts @@ -26,17 +26,17 @@ describe("development scripts", () => { expect(result.status).toBe(7); }); - it("fails style builds when CSS files are missing from the style manifest", async () => { + it("fails style builds when CSS files are missing from the style order file", async () => { const cwd = await tempWorkspace(); await mkdir(path.join(cwd, "src", "styles"), { recursive: true }); - await writeJson(path.join(cwd, "src", "styles", "manifest.json"), ["00-tokens.css"]); + await writeJson(path.join(cwd, "src", "styles", "order.json"), ["00-tokens.css"]); await writeFile(path.join(cwd, "src", "styles", "00-tokens.css"), ".codex-panel { color: var(--text-normal); }\n"); await writeFile(path.join(cwd, "src", "styles", "10-unlisted.css"), ".codex-panel__extra { display: block; }\n"); const result = runNodeScript("scripts/build-styles.mjs", ["--check"], cwd); expect(result.status).toBe(1); - expect(result.stderr).toContain("CSS files missing from src/styles/manifest.json: 10-unlisted.css"); + expect(result.stderr).toContain("CSS files missing from src/styles/order.json: 10-unlisted.css"); }); it("passes the expected codex generate-ts arguments", async () => { diff --git a/tests/styles.test.ts b/tests/styles.test.ts index 2dd43961..62116fc5 100644 --- a/tests/styles.test.ts +++ b/tests/styles.test.ts @@ -4,7 +4,7 @@ import path from "node:path"; import { describe, expect, it } from "vitest"; const sourceDir = path.join("src", "styles"); -const sourceFiles = JSON.parse(readFileSync(path.join(sourceDir, "manifest.json"), "utf8")) as string[]; +const sourceFiles = JSON.parse(readFileSync(path.join(sourceDir, "order.json"), "utf8")) as string[]; const styles = `${sourceFiles.map((file) => readFileSync(path.join(sourceDir, file), "utf8").trimEnd()).join("\n\n")}\n`; describe("panel CSS token scope", () => {