@a11y-skills/audit 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to `@a11y-skills/audit` are documented here. This project
4
4
  adheres to [Semantic Versioning](https://semver.org/).
5
5
 
6
+ ## 0.4.1 — 2026-06-12
7
+
8
+ ### Fixed
9
+
10
+ - CLI: `orientation-check` and `time-limit-detector` were failing with
11
+ "No target URL provided" because the registry entries did not pass `targetUrl`
12
+ to the underlying check functions. Both checks own their own navigation, so the
13
+ CLI's redundant pre-navigation step is now skipped for these two entries via the
14
+ new `ownsNavigation: true` flag on `CheckEntry`.
15
+
6
16
  ## 0.4.0 — 2026-06-12
7
17
 
8
18
  ### Added
package/README.ja.md CHANGED
@@ -114,6 +114,57 @@ exit コードが非 0 でも、完了したチェックの JSON は必ず書き
114
114
  未インストールの場合はそのチェックだけ `SKIPPED` となり、終了コードには影響しません。
115
115
  他の 9 検査は通常通り実行されます。
116
116
 
117
+ ### GitHub Actions
118
+
119
+ 手動トリガーで監査を実行するコピー&ペースト用ワークフロー。violations があるとジョブは fail する(終了コード 1)。結果を情報提供のみにしたい場合は監査ステップに `continue-on-error: true` を付ける。
120
+
121
+ ```yaml
122
+ # .github/workflows/a11y-audit.yml
123
+ name: A11y Audit
124
+
125
+ on:
126
+ workflow_dispatch:
127
+ inputs:
128
+ target_url:
129
+ description: 'Audit target URL'
130
+ required: true
131
+ default: 'https://example.com'
132
+
133
+ jobs:
134
+ a11y-audit:
135
+ runs-on: ubuntu-latest
136
+ steps:
137
+ - name: Setup Node.js
138
+ uses: actions/setup-node@v6
139
+ with:
140
+ node-version: '24'
141
+
142
+ - name: Install audit package
143
+ run: npm install --no-save @a11y-skills/audit @playwright/test @axe-core/playwright
144
+
145
+ - name: Install Playwright browsers
146
+ run: npx playwright install --with-deps chromium
147
+
148
+ - name: Run a11y audit
149
+ run: npx a11y-audit --url "$TARGET_URL" --output-dir a11y-audit-results
150
+ env:
151
+ TARGET_URL: ${{ inputs.target_url }}
152
+
153
+ - name: Upload audit results
154
+ uses: actions/upload-artifact@v7
155
+ if: always()
156
+ with:
157
+ name: a11y-audit-results
158
+ path: a11y-audit-results/
159
+ retention-days: 30
160
+ ```
161
+
162
+ Notes:
163
+
164
+ - `push` / `schedule` トリガー(URL はハードコード)を追加すると、定期的なゲートとして実行できる。
165
+ - 結果 JSON ファイル(`--screenshot` 指定時はフォーカスインジケーターのスクリーンショットも含む)はビルドアーティファクトとしてアップロードされる。
166
+ - 繰り返し実行を高速化するには、インストール済みの `@playwright/test` バージョンをキーに `~/.cache/ms-playwright` をキャッシュする — パターンはこのリポジトリの `ci.yml` を参照。
167
+
117
168
  ## 使い方 — 関数 API(推奨)
118
169
 
119
170
  ページの遷移は呼び出し側で行い、関数は検査の実行・結果 JSON の書き出し・結果オブジェクトの
package/README.md CHANGED
@@ -116,6 +116,63 @@ resolvable. If they are not found, the CLI exits 2 with an install hint.
116
116
  check is skipped with a `SKIPPED` message and does not affect the exit code.
117
117
  The other nine checks continue normally.
118
118
 
119
+ ### GitHub Actions
120
+
121
+ Copy-paste workflow for a manually triggered audit. Violations fail the job
122
+ (exit code 1); add `continue-on-error: true` to the audit step if you want the
123
+ result to be informational only.
124
+
125
+ ```yaml
126
+ # .github/workflows/a11y-audit.yml
127
+ name: A11y Audit
128
+
129
+ on:
130
+ workflow_dispatch:
131
+ inputs:
132
+ target_url:
133
+ description: 'Audit target URL'
134
+ required: true
135
+ default: 'https://example.com'
136
+
137
+ jobs:
138
+ a11y-audit:
139
+ runs-on: ubuntu-latest
140
+ steps:
141
+ - name: Setup Node.js
142
+ uses: actions/setup-node@v6
143
+ with:
144
+ node-version: '24'
145
+
146
+ - name: Install audit package
147
+ run: npm install --no-save @a11y-skills/audit @playwright/test @axe-core/playwright
148
+
149
+ - name: Install Playwright browsers
150
+ run: npx playwright install --with-deps chromium
151
+
152
+ - name: Run a11y audit
153
+ run: npx a11y-audit --url "$TARGET_URL" --output-dir a11y-audit-results
154
+ env:
155
+ TARGET_URL: ${{ inputs.target_url }}
156
+
157
+ - name: Upload audit results
158
+ uses: actions/upload-artifact@v7
159
+ if: always()
160
+ with:
161
+ name: a11y-audit-results
162
+ path: a11y-audit-results/
163
+ retention-days: 30
164
+ ```
165
+
166
+ Notes:
167
+
168
+ - Add `push` / `schedule` triggers (with a hardcoded URL) to run the audit as
169
+ a recurring gate.
170
+ - Result JSON files (and the focus-indicator screenshot when `--screenshot`
171
+ is set) are uploaded as a build artifact.
172
+ - To speed up repeat runs, cache `~/.cache/ms-playwright` keyed on the
173
+ installed `@playwright/test` version — see this repository's `ci.yml` for
174
+ the pattern.
175
+
119
176
  ## Usage — function API (recommended)
120
177
 
121
178
  You navigate the page; the function runs the check, writes a result JSON, and
package/dist/cli.js CHANGED
@@ -69,10 +69,12 @@ const CHECK_REGISTRY = [
69
69
  {
70
70
  name: 'orientation-check',
71
71
  kind: 'page',
72
- async run({ page, outputDir }) {
72
+ ownsNavigation: true,
73
+ async run({ page, outputDir, url }) {
73
74
  const { runOrientationCheck } = await import('./playwright/runOrientationCheck.js');
74
75
  return (await runOrientationCheck({
75
76
  page,
77
+ targetUrl: url,
76
78
  outputDir,
77
79
  }));
78
80
  },
@@ -91,10 +93,12 @@ const CHECK_REGISTRY = [
91
93
  {
92
94
  name: 'time-limit-detector',
93
95
  kind: 'page',
94
- async run({ page, outputDir }) {
96
+ ownsNavigation: true,
97
+ async run({ page, outputDir, url }) {
95
98
  const { runTimeLimitDetector } = await import('./playwright/runTimeLimitDetector.js');
96
99
  return (await runTimeLimitDetector({
97
100
  page,
101
+ targetUrl: url,
98
102
  outputDir,
99
103
  }));
100
104
  },
@@ -285,22 +289,24 @@ async function main() {
285
289
  if (check.kind === 'page') {
286
290
  context = await browser.newContext();
287
291
  page = await context.newPage();
288
- // Use 'load' for file: URLs to avoid networkidle hanging
289
- const waitUntil = url.startsWith('file:') ? 'load' : 'networkidle';
290
- try {
291
- await page.goto(url, { waitUntil });
292
- }
293
- catch (navErr) {
294
- const msg = navErr instanceof Error ? navErr.message : String(navErr);
295
- process.stderr.write(`[${check.name}] Navigation failed: ${msg}\n`);
296
- summaries.push({
297
- name: check.name,
298
- status: 'ERROR',
299
- durationMs: Date.now() - start,
300
- error: msg,
301
- });
302
- hasErrors = true;
303
- continue;
292
+ if (!check.ownsNavigation) {
293
+ // Use 'load' for file: URLs to avoid networkidle hanging
294
+ const waitUntil = url.startsWith('file:') ? 'load' : 'networkidle';
295
+ try {
296
+ await page.goto(url, { waitUntil });
297
+ }
298
+ catch (navErr) {
299
+ const msg = navErr instanceof Error ? navErr.message : String(navErr);
300
+ process.stderr.write(`[${check.name}] Navigation failed: ${msg}\n`);
301
+ summaries.push({
302
+ name: check.name,
303
+ status: 'ERROR',
304
+ durationMs: Date.now() - start,
305
+ error: msg,
306
+ });
307
+ hasErrors = true;
308
+ continue;
309
+ }
304
310
  }
305
311
  }
306
312
  const result = await check.run({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a11y-skills/audit",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Playwright + axe-core based WCAG 2.2 accessibility audit functions (axe, focus indicator, reflow, target size, text spacing, zoom, orientation, autocomplete, time limit, auto-play).",
5
5
  "type": "module",
6
6
  "license": "MIT",