Rename style order manifest

This commit is contained in:
murashit 2026-05-31 20:26:11 +09:00
parent 3de5315612
commit 58c2d947b6
5 changed files with 15 additions and 15 deletions

View file

@ -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.

View file

@ -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);
}

View file

@ -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 () => {

View file

@ -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", () => {