diff --git a/docs/development.md b/docs/development.md index 9d796506..2f2a77d6 100644 --- a/docs/development.md +++ b/docs/development.md @@ -7,8 +7,8 @@ npm run check npm run build ``` -Run `npm run format` after edits and before `npm run check` so Prettier-only issues are fixed upfront. `npm run check` runs TypeScript type checking, unit tests, ESLint, Prettier check, and a production esbuild bundle. -The local `npm run check` path runs checks in parallel and uses local caches for TypeScript, Vitest, ESLint, and Prettier. Use `npm run check:ci` when you need to reproduce the sequential, non-cached CI validation path. +Run `npm run format` after edits and before `npm run check` so Prettier-only issues are fixed upfront. `npm run check` runs TypeScript type checking, unit tests, lint checks, Prettier check, CSS build verification, and a production esbuild bundle. +The local `npm run check` path runs checks in parallel and uses local caches where available. Use `npm run check:ci` when you need to reproduce the sequential, non-cached CI validation path. `main.js`, `styles.css`, `data.json`, and `node_modules/` are ignored by Git. `main.js` and `styles.css` are still the files Obsidian loads, so run `npm run build` after source changes. CSS is authored in `src/styles/` and generated into the ignored root `styles.css` release asset. Use `npm run build:styles` when only regenerating CSS, or `npm run build:styles:check` to verify that the authored CSS can be rendered. diff --git a/package.json b/package.json index 0619acb1..086f384f 100644 --- a/package.json +++ b/package.json @@ -14,33 +14,32 @@ }, "homepage": "https://github.com/murashit/codex-panel#readme", "scripts": { + "api:baseline": "node scripts/api-baseline.mjs", + "api:baseline:check": "node scripts/api-baseline.mjs --check", + "build": "node esbuild.config.mjs", "build:styles": "node scripts/build-styles.mjs", "build:styles:check": "node scripts/build-styles.mjs --check", - "build": "node esbuild.config.mjs", + "check": "node scripts/check.mjs", + "check:ci": "node scripts/check.mjs --ci", "format": "node scripts/format.mjs", "format:check": "node scripts/format.mjs --check --cache", "format:check:ci": "node scripts/format.mjs --check", - "api:baseline": "node scripts/api-baseline.mjs", - "api:baseline:check": "node scripts/api-baseline.mjs --check", "generate:app-server-types": "node scripts/generate-app-server-types.mjs", - "lint": "node scripts/run-parallel.mjs lint:ts lint:css", + "lint": "node scripts/run-parallel.mjs lint:ts lint:css lint:css-usage lint:deps lint:unused", + "lint:ci": "node scripts/run-parallel.mjs lint:ts:ci lint:css lint:css-usage lint:deps lint:unused", "lint:css": "stylelint \"src/**/*.css\" --max-warnings=0", - "lint:css:usage": "node scripts/check-css-usage.mjs", - "lint:css:usage:check": "node scripts/check-css-usage.mjs --fail-on-candidates", - "lint:deps": "node scripts/check-import-cycles.mjs", + "lint:css-usage": "node scripts/lint/check-css-usage.mjs --fail-on-candidates", + "lint:deps": "node scripts/lint/check-import-cycles.mjs", "lint:ts": "eslint src tests scripts \"*.config.ts\" \"*.config.mjs\" --max-warnings=0", "lint:ts:ci": "eslint src tests scripts \"*.config.ts\" \"*.config.mjs\" --max-warnings=0", + "lint:unused": "knip --no-progress", "release:check": "node scripts/release/check.mjs", "release:preflight": "node scripts/release/preflight.mjs", "release:prepare": "node scripts/release/prepare.mjs", "test": "vitest run --cache", "test:ci": "vitest run", "typecheck": "tsc -p tsconfig.json --noEmit --incremental --tsBuildInfoFile node_modules/.cache/typescript/tsconfig.tsbuildinfo", - "typecheck:ci": "tsc -p tsconfig.json --noEmit", - "unused": "npm run unused:exports", - "unused:exports": "knip --no-progress", - "check": "node scripts/check.mjs", - "check:ci": "node scripts/check.mjs --ci" + "typecheck:ci": "tsc -p tsconfig.json --noEmit" }, "devDependencies": { "@eslint/js": "^10.0.1", diff --git a/scripts/api-baseline.mjs b/scripts/api-baseline.mjs index 99fa62af..234650ce 100644 --- a/scripts/api-baseline.mjs +++ b/scripts/api-baseline.mjs @@ -1,6 +1,6 @@ import { readFile } from "node:fs/promises"; import { spawnSync } from "node:child_process"; -import { readJson } from "./release/utils.mjs"; +import { readJson } from "./utils.mjs"; const args = new Set(process.argv.slice(2)); const shouldCheck = args.has("--check"); diff --git a/scripts/check.mjs b/scripts/check.mjs index 422bd87d..349c37e2 100644 --- a/scripts/check.mjs +++ b/scripts/check.mjs @@ -5,13 +5,9 @@ const npmCommand = process.platform === "win32" ? "npm.cmd" : "npm"; const checks = [ { local: "typecheck", ci: "typecheck:ci", localPhase: "parallel" }, { local: "test", ci: "test:ci", localPhase: "parallel" }, - { local: "lint:ts", ci: "lint:ts:ci", localPhase: "parallel" }, - { local: "lint:css", ci: "lint:css", localPhase: "parallel" }, - { local: "lint:css:usage:check", ci: null, localPhase: "parallel" }, - { local: "lint:deps", ci: "lint:deps", localPhase: "parallel" }, + { local: "lint", ci: "lint:ci", localPhase: "parallel" }, { local: "format:check", ci: "format:check:ci", localPhase: "parallel" }, { local: "build:styles:check", ci: "build:styles:check", localPhase: "parallel" }, - { local: "unused", ci: "unused", localPhase: "parallel" }, { local: "build", ci: "build", localPhase: "sequential" }, ]; diff --git a/scripts/check-css-usage.mjs b/scripts/lint/check-css-usage.mjs similarity index 98% rename from scripts/check-css-usage.mjs rename to scripts/lint/check-css-usage.mjs index d6269d4b..583546f8 100644 --- a/scripts/check-css-usage.mjs +++ b/scripts/lint/check-css-usage.mjs @@ -9,7 +9,7 @@ const validArgs = new Set(["--fail-on-candidates"]); for (const arg of args) { if (!validArgs.has(arg)) { - console.error("Usage: node scripts/check-css-usage.mjs [--fail-on-candidates]"); + console.error("Usage: node scripts/lint/check-css-usage.mjs [--fail-on-candidates]"); process.exit(1); } } diff --git a/scripts/check-import-cycles.mjs b/scripts/lint/check-import-cycles.mjs similarity index 98% rename from scripts/check-import-cycles.mjs rename to scripts/lint/check-import-cycles.mjs index ba4bfaaf..b28636d2 100644 --- a/scripts/check-import-cycles.mjs +++ b/scripts/lint/check-import-cycles.mjs @@ -2,7 +2,7 @@ import path from "node:path"; import ts from "typescript"; if (process.argv.length > 2) { - console.error("Usage: node scripts/check-import-cycles.mjs"); + console.error("Usage: node scripts/lint/check-import-cycles.mjs"); process.exit(1); } diff --git a/scripts/stylelint-no-specificity-where.mjs b/scripts/lint/stylelint-no-specificity-where.mjs similarity index 100% rename from scripts/stylelint-no-specificity-where.mjs rename to scripts/lint/stylelint-no-specificity-where.mjs diff --git a/scripts/release/check.mjs b/scripts/release/check.mjs index e9d40199..2178d6a6 100644 --- a/scripts/release/check.mjs +++ b/scripts/release/check.mjs @@ -1,6 +1,6 @@ import { readFile } from "node:fs/promises"; import path from "node:path"; -import { compareVersions, isExpectedNextVersion, parseVersion, readJson } from "./utils.mjs"; +import { compareVersions, isExpectedNextVersion, parseVersion, readJson } from "../utils.mjs"; function fail(message) { console.error(`release check failed: ${message}`); diff --git a/scripts/release/prepare.mjs b/scripts/release/prepare.mjs index b9f8edba..7f1cfefc 100644 --- a/scripts/release/prepare.mjs +++ b/scripts/release/prepare.mjs @@ -1,6 +1,6 @@ import { mkdir, readFile, writeFile } from "node:fs/promises"; import path from "node:path"; -import { compareVersions, isExpectedNextVersion, parseVersion, readJson, writeJson } from "./utils.mjs"; +import { compareVersions, isExpectedNextVersion, parseVersion, readJson, writeJson } from "../utils.mjs"; function fail(message) { console.error(`release prepare failed: ${message}`); diff --git a/scripts/release/utils.mjs b/scripts/utils.mjs similarity index 100% rename from scripts/release/utils.mjs rename to scripts/utils.mjs diff --git a/stylelint.config.mjs b/stylelint.config.mjs index 7153f807..a48496e3 100644 --- a/stylelint.config.mjs +++ b/stylelint.config.mjs @@ -1,4 +1,4 @@ -import noSpecificityWhere from "./scripts/stylelint-no-specificity-where.mjs"; +import noSpecificityWhere from "./scripts/lint/stylelint-no-specificity-where.mjs"; export default { extends: ["stylelint-config-standard"], diff --git a/tests/scripts/development-scripts.test.ts b/tests/scripts/development-scripts.test.ts index 745698c2..782b1122 100644 --- a/tests/scripts/development-scripts.test.ts +++ b/tests/scripts/development-scripts.test.ts @@ -14,9 +14,7 @@ describe("development scripts", () => { scripts: { "typecheck:ci": "node fail.mjs", "test:ci": 'node -e "process.exit(0)"', - "lint:ts:ci": 'node -e "process.exit(0)"', - "lint:css": 'node -e "process.exit(0)"', - "lint:deps": 'node -e "process.exit(0)"', + "lint:ci": 'node -e "process.exit(0)"', "format:check:ci": 'node -e "process.exit(0)"', build: 'node -e "process.exit(0)"', }, @@ -164,7 +162,7 @@ describe("development scripts", () => { "src/b.ts": 'import { a } from "./a";\nexport const b = a;\n', }); - const result = runNodeScript("scripts/check-import-cycles.mjs", [], cwd); + const result = runNodeScript("scripts/lint/check-import-cycles.mjs", [], cwd); expect(result.status).toBe(1); expect(result.stderr).toContain("found 1 cycle"); @@ -178,7 +176,7 @@ describe("development scripts", () => { "src/b.ts": 'import type { A } from "./a";\nexport interface B { a?: A }\n', }); - const result = runNodeScript("scripts/check-import-cycles.mjs", [], cwd); + const result = runNodeScript("scripts/lint/check-import-cycles.mjs", [], cwd); expect(result.status).toBe(0); expect(result.stdout).toContain("No import cycles found."); @@ -191,7 +189,7 @@ describe("development scripts", () => { "src/b.ts": 'import { a, type A } from "./a";\nexport interface B { a?: A }\nexport const b = a;\n', }); - const result = runNodeScript("scripts/check-import-cycles.mjs", [], cwd); + const result = runNodeScript("scripts/lint/check-import-cycles.mjs", [], cwd); expect(result.status).toBe(1); expect(result.stderr).toContain("found 1 cycle");