diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 52c9baf..1932b8e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,5 +33,6 @@ jobs: - run: npm run lint # --check builds twice and fails when the two outputs differ - run: node scripts/build.mjs --check + - run: npm run contract:check - name: Package contents run: npm pack --dry-run diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6c6d6eb..8ff3b64 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,6 +33,7 @@ jobs: - run: npm run typecheck - run: npm run lint - run: node scripts/build.mjs --check + - run: npm run contract:check - name: Check the tag against package.json if: startsWith(github.ref, 'refs/tags/v') diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index da9d80d..1da4e4f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,10 +22,13 @@ npm run typecheck # type-checks tests/types/ against types/ npm run lint # ESLint's recommended rules (eslint.config.js) npm run build # dist/: ESM, minified ESM and IIFE bundles with source maps node scripts/build.mjs --check # builds twice and fails if the outputs differ +npm run contract:check # package.json, entry points, types, schemas and docs agree (after a build) ``` The source is plain JavaScript ES modules (`src/`), with type declarations in `types/`. Keep both in step when the -public API changes, and document it in [docs/api.md](docs/api.md). +public API changes, and document it in the entry points table of [docs/api.md](docs/api.md) (or of the entry's own +document); `npm run contract:check` compares the three, and checks the documents' links, the format ids and the +schemas. ### Tests diff --git a/README.en.md b/README.en.md index d7f04cb..fba517f 100644 --- a/README.en.md +++ b/README.en.md @@ -233,6 +233,7 @@ npm test # unit tests (node --test, synthetic inputs only) npm run build # browser bundles in dist/ npm run typecheck # checks the type declarations in types/ npm run lint # ESLint (eslint.config.js) +npm run contract:check # package.json, entry exports, types, schemas and docs agree npm run validate-data -- [chart id ...] # validates a site against the data format node scripts/story-author.mjs help # the commands of the story script tool (experimental) OURNOTES_DATA= npm run test:data # opt-in: runs the player in Node on real chart data diff --git a/README.md b/README.md index 3c15568..a8ef75c 100644 --- a/README.md +++ b/README.md @@ -182,6 +182,7 @@ npm test # 单元测试(node --test,仅使用合成输入 npm run build # 构建 dist/ 下的浏览器包 npm run typecheck # 检查 types/ 下的类型声明 npm run lint # ESLint 检查(eslint.config.js) +npm run contract:check # 核对 package.json、入口导出、类型声明、schema 与文档是否一致 npm run validate-data -- <站点目录> [谱面 id ...] # 按数据格式校验一个站点 node scripts/story-author.mjs help # 自写剧情工具(实验功能)的命令 OURNOTES_DATA=<站点目录> npm run test:data # 可选:用真实谱面数据在 Node 中运行播放器 diff --git a/docs/api.md b/docs/api.md index d28f4a5..1cd7265 100644 --- a/docs/api.md +++ b/docs/api.md @@ -10,7 +10,7 @@ live UI, with the chart's music and sound effects, auto-played at Perfect. The d |---|---| | `ournotes-player` | `ChartPlayer`, `ChartSession`, `AssetStore`, `defineOurnotesPlayer`, `OurnotesPlayerElement`, `LIVE_SPEEDS`, `LIVE_OPTIONS`, `LIVE_OPTION_GROUPS`, `LiveSettingsError`, `PLAYER_LANGUAGES`, `formatTime` | | `ournotes-player/element` | the same exports; importing it defines `` | -| `ournotes-player/ui` (experimental) | `UILibrary`, `UISession`, `UIPlayer`, `OurnotesUIElement`, `defineOurnotesUI`; [prefab preview API and limits](ui-preview.md) | +| `ournotes-player/ui` (experimental) | `UILibrary`, `UISession`, `UIPlayer`, `OurnotesUIElement`, `defineOurnotesUI`, `cameraProjection`; [prefab preview API and limits](ui-preview.md) | | `ournotes-player/ui/element` (experimental) | the same UI exports; importing it defines `` | | `ournotes-player/replay/preset` | `parseJustJudgementTypes`, `applyAccuracyPreset`, `applySegmentPreset`: declared input plans that set the judgement grades of an `ournotes.replay/1` request in place | diff --git a/docs/story-author.md b/docs/story-author.md index e9d464a..2d91e83 100644 --- a/docs/story-author.md +++ b/docs/story-author.md @@ -33,6 +33,7 @@ node scripts/story-author.mjs new stories/10002.json $S > story.json # 4. a st node scripts/story-author.mjs check story.json $S # 5. errors and warnings with JSON pointers node scripts/story-author.mjs render story.json $S --out shots # 6. one picture per line, and a contact sheet # look at shots/sheet.png (and shots/line-*.png), fix, repeat 5-6 +# (--fix on check and render writes the script with the fixes the tool knows applied) node scripts/story-author.mjs build story.json $S --name my-story # 7. into the site node scripts/story-author.mjs serve $S # 8. URLs to watch it in examples/story ``` @@ -42,8 +43,10 @@ Look at the pictures after each render: the contact sheet shows every line with ## Commands -All commands take `--site `. Exit status: 0 done, 1 the script has errors or the job failed (the JSON has -`"ok": false` and the errors, or `error`), 2 a usage error (message on stderr). +All commands take `--site `. The commands that draw pictures take `--chrome`, `--gpu` and `--core` (see +[Requirements](#requirements)) and give up a picture job that has not finished after `--timeout ` seconds (default +600). Exit status: 0 done, 1 the script has errors or the job failed (the JSON has `"ok": false` and the errors, or +`error`), 2 a usage error (message on stderr). ### bases @@ -98,15 +101,16 @@ stage, three lines). Redirect it to a file and edit it. ### check -`check