@d-zero/a11y-check 0.7.5 → 0.8.0

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/README.md CHANGED
@@ -23,6 +23,7 @@ npx @d-zero/a11y-check <url>... [options]
23
23
  - `<url>`: 対象のURL(複数指定可能)
24
24
  - `-s, --screenshot`: スクリーンショットを撮影する(デフォルト: false)
25
25
  - `-o, --out <url>`: GoogleスプレッドシートのURL(デフォルト: 標準出力)
26
+ - `-c, --credentials <file>`: Google認証用のクレデンシャルJSONファイルのパス(または環境変数`GOOGLE_AUTH_CREDENTIALS`で指定)
26
27
  - `--scenarios <scenarios>`: チェックシナリオ(カンマ区切り、利用可能: axe,01,02、デフォルト: axe)
27
28
  - `--cache <true|false>`: キャッシュを使用する(デフォルト: true)
28
29
  - `--cacheDir <dir>`: キャッシュディレクトリ(デフォルト: .cache)
@@ -120,14 +121,25 @@ export default async function (page, { name, width, resolution, log }) {
120
121
 
121
122
  `-o`オプションでGoogleスプレッドシートのURLを指定すると、詳細なレポートが出力されます。
122
123
 
123
- ### 必要な環境変数
124
+ ### クレデンシャルの設定
124
125
 
125
- Googleスプレッドシートに出力するには、以下の環境変数が必要です:
126
+ Googleスプレッドシートに出力するには、クレデンシャルファイルが必要です。以下のいずれかの方法で指定します:
127
+
128
+ **方法1: CLIオプションで指定**
129
+
130
+ ```bash
131
+ npx @d-zero/a11y-check -f urls.txt -o https://docs.google.com/spreadsheets/d/xxx/edit -c /path/to/credential.json
132
+ ```
133
+
134
+ **方法2: 環境変数で指定**
126
135
 
127
136
  ```bash
128
137
  export GOOGLE_AUTH_CREDENTIALS='/path/to/credential.json'
138
+ npx @d-zero/a11y-check -f urls.txt -o https://docs.google.com/spreadsheets/d/xxx/edit
129
139
  ```
130
140
 
141
+ CLIオプション`-c`が優先され、未指定の場合は環境変数`GOOGLE_AUTH_CREDENTIALS`が使用されます。
142
+
131
143
  クレデンシャルファイルは、Google Cloud Consoleの[APIとサービス](https://console.cloud.google.com/apis/credentials)から**OAuth 2.0 クライアント ID**(アプリケーションの種類は**デスクトップ**)を発行してダウンロードします。
132
144
 
133
145
  ### 出力されるレポート項目
@@ -16,7 +16,7 @@ export async function a11yCheck(urlList, out, options) {
16
16
  if (options?.debug) {
17
17
  sheetName += `-debug-${Date.now()}`;
18
18
  }
19
- sheet = await SpreadsheetReporter.setup(out, sheetName);
19
+ sheet = await SpreadsheetReporter.setup(out, sheetName, options?.credentials);
20
20
  }
21
21
  const scenarioList = options?.scenarios ?? ['axe'];
22
22
  const scenarios = scenarioList.map((s) => {
package/dist/cli.js CHANGED
@@ -12,6 +12,7 @@ const { options, args, hasConfigFile } = createCLI({
12
12
  f: 'listfile',
13
13
  s: 'screenshot',
14
14
  o: 'out',
15
+ c: 'credentials',
15
16
  },
16
17
  usage: [
17
18
  'Usage:',
@@ -20,6 +21,7 @@ const { options, args, hasConfigFile } = createCLI({
20
21
  'Options:',
21
22
  '\t-f, --listfile <file> File containing URLs to check',
22
23
  '\t-o, --out <file> Output file path',
24
+ '\t-c, --credentials <file> Google credentials JSON file path (or set GOOGLE_AUTH_CREDENTIALS env)',
23
25
  '\t--limit <number> Limit concurrent processes',
24
26
  '\t--interval <ms> Interval between parallel executions (default: none)',
25
27
  '\t Format: number or "min-max" for random range',
@@ -36,6 +38,7 @@ const { options, args, hasConfigFile } = createCLI({
36
38
  locale: cli.locale,
37
39
  screenshot: !!cli.screenshot,
38
40
  out: cli.out?.trim() || undefined,
41
+ credentials: cli.credentials?.trim() || undefined,
39
42
  }),
40
43
  validateArgs: (options, cli) => {
41
44
  return !!(options.listfile?.length || cli._.length > 0);
@@ -52,6 +55,7 @@ let a11yOptions = {
52
55
  cacheDir: options.cacheDir,
53
56
  debug: options.debug,
54
57
  verbose: options.verbose,
58
+ credentials: options.credentials,
55
59
  };
56
60
  if (hasConfigFile) {
57
61
  const { urlList, hooks } = await readConfig(options.listfile);
@@ -3,5 +3,5 @@ export declare class SpreadsheetReporter {
3
3
  #private;
4
4
  private constructor();
5
5
  report(results: readonly Violation[]): Promise<void>;
6
- static setup(sheetUrl: string, sheetName: string): Promise<SpreadsheetReporter>;
6
+ static setup(sheetUrl: string, sheetName: string, credentialFilePath?: string): Promise<SpreadsheetReporter>;
7
7
  }
@@ -107,12 +107,9 @@ export class SpreadsheetReporter {
107
107
  },
108
108
  });
109
109
  }
110
- static async setup(sheetUrl, sheetName) {
110
+ static async setup(sheetUrl, sheetName, credentialFilePath) {
111
111
  dotenv.config();
112
- if (!process.env.GOOGLE_AUTH_CREDENTIALS) {
113
- throw new Error('GOOGLE_AUTH_CREDENTIALS is not set');
114
- }
115
- const auth = await authentication(process.env.GOOGLE_AUTH_CREDENTIALS, [
112
+ const auth = await authentication(credentialFilePath ?? null, [
116
113
  'https://www.googleapis.com/auth/spreadsheets',
117
114
  ]);
118
115
  const reporter = new SpreadsheetReporter();
package/dist/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { CoreOptions, ScenarioRunnerOptions } from '@d-zero/a11y-check-core';
2
2
  export type A11yCheckOptions = {
3
3
  readonly scenarios?: readonly string[];
4
+ readonly credentials?: string;
4
5
  } & CoreOptions & ScenarioRunnerOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d-zero/a11y-check",
3
- "version": "0.7.5",
3
+ "version": "0.8.0",
4
4
  "description": "Accessibility Checker CLI",
5
5
  "author": "D-ZERO",
6
6
  "license": "MIT",
@@ -24,20 +24,20 @@
24
24
  "clean": "tsc --build --clean"
25
25
  },
26
26
  "dependencies": {
27
- "@d-zero/a11y-check-axe-scenario": "0.5.10",
28
- "@d-zero/a11y-check-core": "0.6.10",
29
- "@d-zero/a11y-check-scenarios": "0.4.24",
30
- "@d-zero/cli-core": "1.3.3",
31
- "@d-zero/google-auth": "0.5.6",
32
- "@d-zero/google-sheets": "0.6.0",
33
- "@d-zero/puppeteer-page-scan": "4.4.4",
34
- "@d-zero/readtext": "1.1.18",
35
- "@d-zero/shared": "0.20.0",
27
+ "@d-zero/a11y-check-axe-scenario": "0.5.12",
28
+ "@d-zero/a11y-check-core": "0.6.12",
29
+ "@d-zero/a11y-check-scenarios": "0.4.26",
30
+ "@d-zero/cli-core": "1.3.4",
31
+ "@d-zero/google-auth": "0.6.0",
32
+ "@d-zero/google-sheets": "0.6.1",
33
+ "@d-zero/puppeteer-page-scan": "4.4.5",
34
+ "@d-zero/readtext": "1.1.19",
35
+ "@d-zero/shared": "0.20.1",
36
36
  "ansi-colors": "4.1.3",
37
37
  "dayjs": "1.11.19",
38
38
  "dotenv": "17.3.1",
39
39
  "front-matter": "4.0.2",
40
40
  "minimist": "1.2.8"
41
41
  },
42
- "gitHead": "1830747a6fee6194c897d54966c25ada5237645e"
42
+ "gitHead": "a6b5eb0a0a327c003053f7c25be4c075ed319c76"
43
43
  }