@nitpicker/core 0.11.0 → 0.13.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
@@ -1,14 +1,10 @@
1
1
  # @nitpicker/core
2
2
 
3
- プラグインベースのページ分析エンジン。
3
+ `.nitpicker` アーカイブ内のページに対して analyze プラグインを実行する内部パッケージです。
4
4
 
5
- ## 概要
5
+ プラグインの読み込み、実行、結果の書き戻しを担当します。通常は [@nitpicker/cli](../cli/README.md) の `analyze` コマンドから利用します。
6
6
 
7
- `.nitpicker` アーカイブ内の各ページに対して、analyze プラグインを並列実行するためのエンジンです。プラグインの検出・読み込み・Worker スレッドプールでの実行を担当します。
8
-
9
- このパッケージは [Nitpicker](../../README.md) モノレポの内部パッケージです。単体での利用は想定していません。
10
-
11
- ## プラグイン作者向け
7
+ ## プラグイン作者向けAPI
12
8
 
13
9
  analyze プラグインは `definePlugin()` で定義します。
14
10
 
@@ -23,14 +19,14 @@ export default definePlugin((options: Options) => {
23
19
  return {
24
20
  label: 'キーワード検索',
25
21
  // 並列度を宣言できる。省略時は os.cpus().length
26
- // 重いプラグイン(Chrome 起動など)は小さく設定する
22
+ // 重いプラグインは小さく設定する
27
23
  concurrency: 4,
28
24
  headers: {
29
25
  found: 'Keywords Found',
30
26
  },
31
27
  async eachPage({ window }) {
32
28
  const text = window.document.body.textContent ?? '';
33
- const count = options.keywords.filter((k) => text.includes(k)).length;
29
+ const count = options.keywords.filter((keyword) => text.includes(keyword)).length;
34
30
  return {
35
31
  page: { found: { value: count } },
36
32
  };
@@ -39,12 +35,14 @@ export default definePlugin((options: Options) => {
39
35
  });
40
36
  ```
41
37
 
42
- ### `concurrency` の指針
38
+ `concurrency` を省略するとCPUコア数が使われます。ChromeやPuppeteerなど重いプロセスを起動するプラグインでは、2〜4程度に絞ることを推奨します。
43
39
 
44
- - **省略**: `os.cpus().length`(CPU コア数)が使われる。軽量な DOM 解析のみのプラグインはこのままで良い
45
- - **小さく設定すべきケース**: Chrome や Puppeteer などの重いプロセスを起動するプラグインは 2〜4 程度に絞る。例えば `@nitpicker/analyze-lighthouse` は Chrome 1 プロセス ≒ 300〜500MB を消費するため `concurrency: 2`
40
+ ## 関連リンク
46
41
 
47
- 詳細は [CONTRIBUTING.md](../../../CONTRIBUTING.md) と [ARCHITECTURE.md](../../../ARCHITECTURE.md) を参照。
42
+ - [Nitpicker README](../../../README.md)
43
+ - [CLI analyze docs](../cli/docs/analyze.md)
44
+ - [CONTRIBUTING.md](../../../CONTRIBUTING.md)
45
+ - [ARCHITECTURE.md](../../../ARCHITECTURE.md)
48
46
 
49
47
  ## ライセンス
50
48
 
@@ -8,7 +8,8 @@ export { definePlugin } from './hooks/define-plugin.js';
8
8
  * Nitpicker opens an existing archive (produced by the crawler), loads the
9
9
  * user's plugin configuration via cosmiconfig, then runs each plugin against
10
10
  * every page in the archive. Results are stored back into the archive as
11
- * `analysis/report`, `analysis/table`, and `analysis/violations`.
11
+ * `analysis/report`, `analysis/table`, and SQL-backed analysis violation
12
+ * tables via the archive facade.
12
13
  *
13
14
  * ## Architecture decisions
14
15
  *
@@ -76,9 +77,9 @@ export declare class Nitpicker extends EventEmitter<NitpickerEvent> {
76
77
  * that don't need DOM access.
77
78
  *
78
79
  * On completion, three data entries are stored in the archive:
79
- * - `analysis/report` - Full {@link Report} with headers, data, and violations
80
+ * - `analysis/report` - Full {@link Report} with headers and data
80
81
  * - `analysis/table` - The raw {@link Table} instance (serialized)
81
- * - `analysis/violations` - Flat array of all {@link Violation} records
82
+ * - SQL-backed analysis violation tables - Flat {@link Violation} records
82
83
  * @param filter - Optional list of plugin module names to run.
83
84
  * If omitted, all configured plugins are executed.
84
85
  * @param options - Optional settings for progress display.
package/lib/nitpicker.js CHANGED
@@ -35,7 +35,8 @@ const DEFAULT_CONCURRENCY = Math.max(1, os.cpus().length);
35
35
  * Nitpicker opens an existing archive (produced by the crawler), loads the
36
36
  * user's plugin configuration via cosmiconfig, then runs each plugin against
37
37
  * every page in the archive. Results are stored back into the archive as
38
- * `analysis/report`, `analysis/table`, and `analysis/violations`.
38
+ * `analysis/report`, `analysis/table`, and SQL-backed analysis violation
39
+ * tables via the archive facade.
39
40
  *
40
41
  * ## Architecture decisions
41
42
  *
@@ -122,9 +123,9 @@ export class Nitpicker extends EventEmitter {
122
123
  * that don't need DOM access.
123
124
  *
124
125
  * On completion, three data entries are stored in the archive:
125
- * - `analysis/report` - Full {@link Report} with headers, data, and violations
126
+ * - `analysis/report` - Full {@link Report} with headers and data
126
127
  * - `analysis/table` - The raw {@link Table} instance (serialized)
127
- * - `analysis/violations` - Flat array of all {@link Violation} records
128
+ * - SQL-backed analysis violation tables - Flat {@link Violation} records
128
129
  * @param filter - Optional list of plugin module names to run.
129
130
  * If omitted, all configured plugins are executed.
130
131
  * @param options - Optional settings for progress display.
@@ -356,11 +357,10 @@ export class Nitpicker extends EventEmitter {
356
357
  const report = {
357
358
  name: 'general',
358
359
  pageData: table.toJSON(),
359
- violations: allViolations,
360
360
  };
361
361
  await this.archive.setData('analysis/report', report);
362
362
  await this.archive.setData('analysis/table', table);
363
- await this.archive.setData('analysis/violations', allViolations);
363
+ await this.archive.replaceAnalysisViolations(allViolations);
364
364
  }
365
365
  /**
366
366
  * Loads and caches the plugin configuration from the user's config file.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nitpicker/core",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "description": "Plugin-based page analysis engine for Nitpicker",
5
5
  "author": "D-ZERO",
6
6
  "license": "Apache-2.0",
@@ -27,13 +27,13 @@
27
27
  "clean": "tsc --build --clean"
28
28
  },
29
29
  "dependencies": {
30
- "@d-zero/dealer": "1.9.0",
31
- "@d-zero/shared": "0.20.1",
32
- "@nitpicker/crawler": "0.11.0",
33
- "@nitpicker/types": "0.11.0",
30
+ "@d-zero/dealer": "1.9.4",
31
+ "@d-zero/shared": "0.22.2",
32
+ "@nitpicker/crawler": "0.13.0",
33
+ "@nitpicker/types": "0.13.0",
34
34
  "ansi-colors": "4.1.3",
35
- "cosmiconfig": "9.0.0",
36
- "jsdom": "28.1.0"
35
+ "cosmiconfig": "9.0.2",
36
+ "jsdom": "29.1.1"
37
37
  },
38
- "gitHead": "b11dbe3691746b3cb980476808d1f745bc6d0e98"
38
+ "gitHead": "2cd462ea6b183f4462b7caba27b4db04aaba7c70"
39
39
  }