Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ scrapeStart → openPage → loadDOMContent → getHTML → waitNetworkIdle
```
crawler/src/
├── utils/ # 型定義 + ユーティリティ
│ ├── types/ # ExURL, PageData, ParseURLOptions
│ ├── types/ # ExURL, PageData, Link, CrawlerError
│ ├── array/ # eachSplitted
│ ├── object/ # cleanObject
│ └── error/ # DOMEvaluationError, ErrorEmitter
├── archive/ # SQLite アーカイブストレージ
│ ├── filesystem/ # 1関数1ファイル(16ファイル)+ tar, untar
│ └── ... # archive, archive-accessor, database, page, resource
│ └── ... # archive, archive-accessor, database, page, resource, safe-path, types
├── crawler/ # Crawler エンジン
│ ├── crawler.ts # Crawler クラス
│ ├── link-list.ts # URL キュー管理
Expand All @@ -143,7 +143,11 @@ crawler/src/
│ ├── fetch-robots-txt.ts # robots.txt 取得・パース
│ ├── robots-checker.ts # robots.txt 準拠チェッカー(origin 別キャッシュ)
│ └── ... # link-to-page-data, protocol-agnostic-key, net-timeout-error
├── crawler.ts # バレルエクスポート(パッケージ公開 API)
├── crawler-orchestrator.ts # CrawlerOrchestrator
├── debug.ts # デバッグログユーティリティ
├── resolve-output-path.ts # 出力パス解決・検証
├── types.ts # CrawlEvent インターフェース
└── write-queue.ts # Archive 書き込み直列化キュー
```

Expand Down Expand Up @@ -592,7 +596,7 @@ CrawlAggregateError
```
packages/test-server/
├── src/
│ ├── index.ts # createApp(), startServer()
│ ├── server.ts # createApp(), startServer()
│ ├── routes/
│ │ ├── basic.ts # /, /about
│ │ ├── recursive.ts # /recursive/**
Expand Down
4 changes: 2 additions & 2 deletions packages/@nitpicker/analyze-axe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"type": "module",
"exports": {
".": {
"import": "./lib/index.js",
"types": "./lib/index.d.ts"
"import": "./lib/axe-plugin.js",
"types": "./lib/axe-plugin.d.ts"
}
},
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ vi.mock('axe-core', () => ({
}));

// eslint-disable-next-line @typescript-eslint/consistent-type-imports
let pluginFactory: typeof import('./index.js').default;
let pluginFactory: typeof import('./axe-plugin.js').default;

beforeEach(async () => {
vi.clearAllMocks();
const mod = await import('./index.js');
const mod = await import('./axe-plugin.js');
pluginFactory = mod.default;
});

Expand Down
4 changes: 2 additions & 2 deletions packages/@nitpicker/analyze-lighthouse/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"type": "module",
"exports": {
".": {
"import": "./lib/index.js",
"types": "./lib/index.d.ts"
"import": "./lib/lighthouse-plugin.js",
"types": "./lib/lighthouse-plugin.d.ts"
}
},
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ vi.mock('lighthouse/report/renderer/report-utils.js', () => ({
}));

// eslint-disable-next-line @typescript-eslint/consistent-type-imports
let pluginFactory: typeof import('./index.js').default;
let pluginFactory: typeof import('./lighthouse-plugin.js').default;

beforeEach(async () => {
vi.clearAllMocks();
launchMock.mockResolvedValue({ port: 9222, kill: killMock });
const mod = await import('./index.js');
const mod = await import('./lighthouse-plugin.js');
pluginFactory = mod.default;
});

Expand Down
4 changes: 2 additions & 2 deletions packages/@nitpicker/analyze-main-contents/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"type": "module",
"exports": {
".": {
"import": "./lib/index.js",
"types": "./lib/index.d.ts"
"import": "./lib/main-contents-plugin.js",
"types": "./lib/main-contents-plugin.d.ts"
}
},
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ vi.mock('@medv/finder', () => ({
}));

// eslint-disable-next-line @typescript-eslint/consistent-type-imports
let pluginFactory: typeof import('./index.js').default;
let pluginFactory: typeof import('./main-contents-plugin.js').default;

beforeEach(async () => {
vi.clearAllMocks();
const mod = await import('./index.js');
const mod = await import('./main-contents-plugin.js');
pluginFactory = mod.default;
});

Expand Down
4 changes: 2 additions & 2 deletions packages/@nitpicker/analyze-markuplint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"type": "module",
"exports": {
".": {
"import": "./lib/index.js",
"types": "./lib/index.d.ts"
"import": "./lib/markuplint-plugin.js",
"types": "./lib/markuplint-plugin.d.ts"
}
},
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ vi.mock('markuplint', () => ({
}));

// eslint-disable-next-line @typescript-eslint/consistent-type-imports
let pluginFactory: typeof import('./index.js').default;
let pluginFactory: typeof import('./markuplint-plugin.js').default;

beforeEach(async () => {
vi.clearAllMocks();
const mod = await import('./index.js');
const mod = await import('./markuplint-plugin.js');
pluginFactory = mod.default;
});

Expand Down
4 changes: 2 additions & 2 deletions packages/@nitpicker/analyze-search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"type": "module",
"exports": {
".": {
"import": "./lib/index.js",
"types": "./lib/index.d.ts"
"import": "./lib/search-plugin.js",
"types": "./lib/search-plugin.d.ts"
}
},
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { JSDOM } from 'jsdom';
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';

// eslint-disable-next-line @typescript-eslint/consistent-type-imports
let pluginFactory: typeof import('./index.js').default;
let pluginFactory: typeof import('./search-plugin.js').default;

beforeEach(async () => {
vi.clearAllMocks();
const mod = await import('./index.js');
const mod = await import('./search-plugin.js');
pluginFactory = mod.default;
});

Expand Down
4 changes: 2 additions & 2 deletions packages/@nitpicker/analyze-textlint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"type": "module",
"exports": {
".": {
"import": "./lib/index.js",
"types": "./lib/index.d.ts"
"import": "./lib/textlint-plugin.js",
"types": "./lib/textlint-plugin.d.ts"
}
},
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ vi.mock('@textlint-ja/textlint-rule-no-synonyms', () => ({ default: {} }));
vi.mock('textlint-plugin-html', () => ({ default: {} }));

// eslint-disable-next-line @typescript-eslint/consistent-type-imports
let pluginFactory: typeof import('./index.js').default;
let pluginFactory: typeof import('./textlint-plugin.js').default;

beforeEach(async () => {
vi.clearAllMocks();
const mod = await import('./index.js');
const mod = await import('./textlint-plugin.js');
pluginFactory = mod.default;
});

Expand Down
2 changes: 1 addition & 1 deletion packages/@nitpicker/cli/bin/nitpicker.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env node

import '../lib/index.js';
import '../lib/cli.js';
4 changes: 2 additions & 2 deletions packages/@nitpicker/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"type": "module",
"exports": {
".": {
"import": "./lib/index.js",
"types": "./lib/index.d.ts"
"import": "./lib/cli.js",
"types": "./lib/cli.d.ts"
}
},
"bin": {
Expand Down
4 changes: 2 additions & 2 deletions packages/@nitpicker/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"type": "module",
"exports": {
".": {
"import": "./lib/index.js",
"types": "./lib/index.d.ts"
"import": "./lib/core.js",
"types": "./lib/core.d.ts"
}
},
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { Nitpicker } from './nitpicker.js';
export { definePlugin } from './hooks/index.js';
export { definePlugin } from './hooks/define-plugin.js';
export { readPluginLabels } from './read-plugin-labels.js';
export { runInWorker } from './worker/run-in-worker.js';
export * from './types.js';
1 change: 0 additions & 1 deletion packages/@nitpicker/core/src/hooks/index.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/@nitpicker/crawler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"type": "module",
"exports": {
".": {
"import": "./lib/index.js",
"types": "./lib/index.d.ts"
"import": "./lib/crawler.js",
"types": "./lib/crawler.d.ts"
}
},
"scripts": {
Expand Down
15 changes: 6 additions & 9 deletions packages/@nitpicker/crawler/src/archive/archive-accessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@ import type { ParseURLOptions } from '@d-zero/shared/parse-url';

import path from 'node:path';

import { extractZip, unzip } from '@d-zero/fs/zip';
import { TypedAwaitEventEmitter as EventEmitter } from '@d-zero/shared/typed-await-event-emitter';

import { log } from './debug.js';
import {
exists,
extractZip,
outputJSON,
outputText,
readJSON,
readText,
unzip,
} from './filesystem/index.js';
import { exists } from './filesystem/exists.js';
import { outputJSON } from './filesystem/output-json.js';
import { outputText } from './filesystem/output-text.js';
import { readJSON } from './filesystem/read-json.js';
import { readText } from './filesystem/read-text.js';
import Page from './page.js';
import Resource from './resource.js';
import { safePath } from './safe-path.js';
Expand Down
10 changes: 5 additions & 5 deletions packages/@nitpicker/crawler/src/archive/archive.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import { afterAll, describe, expect, it, vi, type MockInstance } from 'vitest';

import Archive from './archive.js';
import { Database } from './database.js';
import { remove } from './filesystem/index.js';
import { remove } from './filesystem/remove.js';

const __filename = new URL(import.meta.url).pathname;
const __dirname = path.dirname(__filename);
const workingDir = path.resolve(__dirname, '__mock__');

vi.mock('./filesystem/index.js', async (importOriginal) => {
vi.mock('./filesystem/output-text.js', async (importOriginal) => {
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
const original = await importOriginal<typeof import('./filesystem/index.js')>();
const original = await importOriginal<typeof import('./filesystem/output-text.js')>();
return {
...original,
outputText: vi.fn(original.outputText),
Expand All @@ -33,7 +33,7 @@ describe('setPage', () => {
});

it('スナップショット書き込み失敗時にDB上のHTMLパスがクリアされエラーが伝搬する', async () => {
const fsIndex = await import('./filesystem/index.js');
const fsIndex = await import('./filesystem/output-text.js');
const mockedOutputText = vi.mocked(fsIndex.outputText);
mockedOutputText.mockRejectedValueOnce(new Error('Disk write failure'));

Expand Down Expand Up @@ -86,7 +86,7 @@ describe('setPage', () => {
});

it('clearHtmlPath失敗時も元のスナップショットエラーが伝搬する', async () => {
const fsIndex = await import('./filesystem/index.js');
const fsIndex = await import('./filesystem/output-text.js');
const mockedOutputText = vi.mocked(fsIndex.outputText);
mockedOutputText.mockRejectedValueOnce(new Error('Disk full'));

Expand Down
23 changes: 11 additions & 12 deletions packages/@nitpicker/crawler/src/archive/archive.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import type { Config } from './types.js';
import type { PageData, CrawlerError, Resource } from '../utils/index.js';
import type { PageData, CrawlerError, Resource } from '../utils/types/types.js';
import type { ParseURLOptions } from '@d-zero/shared/parse-url';

import path from 'node:path';

import { zip } from '@d-zero/fs/zip';

import { ArchiveAccessor } from './archive-accessor.js';
import { Database } from './database.js';
import { dbLog, log, saveLog } from './debug.js';
import {
appendText,
exists,
isDir,
outputText,
remove,
rename,
tar,
untar,
zip,
} from './filesystem/index.js';
import { appendText } from './filesystem/append-text.js';
import { exists } from './filesystem/exists.js';
import { isDir } from './filesystem/is-dir.js';
import { outputText } from './filesystem/output-text.js';
import { remove } from './filesystem/remove.js';
import { rename } from './filesystem/rename.js';
import { tar } from './filesystem/tar.js';
import { untar } from './filesystem/untar.js';

/**
* Main archive class for creating, opening, resuming, and writing Nitpicker archive files (`.nitpicker`).
Expand Down
2 changes: 1 addition & 1 deletion packages/@nitpicker/crawler/src/archive/database.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { tryParseUrl as parseUrl } from '@d-zero/shared/parse-url';
import { afterAll, describe, expect, it } from 'vitest';

import { Database } from './database.js';
import { remove } from './filesystem/index.js';
import { remove } from './filesystem/remove.js';

const __filename = new URL(import.meta.url).pathname;
const __dirname = path.dirname(__filename);
Expand Down
7 changes: 4 additions & 3 deletions packages/@nitpicker/crawler/src/archive/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
DatabaseEvent,
PageFilter,
} from './types.js';
import type { PageData, Resource } from '../utils/index.js';
import type { PageData, Resource } from '../utils/types/types.js';
import type { RetryDecoratorOptions } from '@d-zero/shared/retry';
import type { Knex } from 'knex';

Expand All @@ -20,10 +20,11 @@ import { pathComparator } from '@d-zero/shared/sort/path';
import { TypedAwaitEventEmitter as EventEmitter } from '@d-zero/shared/typed-await-event-emitter';
import knex from 'knex';

import { ErrorEmitter, eachSplitted } from '../utils/index.js';
import { eachSplitted } from '../utils/array/each-splitted.js';
import { ErrorEmitter } from '../utils/error/error-emitter.js';

import { dbLog } from './debug.js';
import { mkdir } from './filesystem/index.js';
import { mkdir } from './filesystem/mkdir.js';

const retrySetting: RetryDecoratorOptions = {
interval: 300,
Expand Down
17 changes: 0 additions & 17 deletions packages/@nitpicker/crawler/src/archive/filesystem/index.ts

This file was deleted.

13 changes: 0 additions & 13 deletions packages/@nitpicker/crawler/src/archive/index.ts

This file was deleted.

Loading
Loading