diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 98c9b22..2409609 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -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 キュー管理 @@ -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 書き込み直列化キュー ``` @@ -592,7 +596,7 @@ CrawlAggregateError ``` packages/test-server/ ├── src/ -│ ├── index.ts # createApp(), startServer() +│ ├── server.ts # createApp(), startServer() │ ├── routes/ │ │ ├── basic.ts # /, /about │ │ ├── recursive.ts # /recursive/** diff --git a/packages/@nitpicker/analyze-axe/package.json b/packages/@nitpicker/analyze-axe/package.json index f3b457b..43c00f6 100644 --- a/packages/@nitpicker/analyze-axe/package.json +++ b/packages/@nitpicker/analyze-axe/package.json @@ -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": { diff --git a/packages/@nitpicker/analyze-axe/src/index.spec.ts b/packages/@nitpicker/analyze-axe/src/axe-plugin.spec.ts similarity index 98% rename from packages/@nitpicker/analyze-axe/src/index.spec.ts rename to packages/@nitpicker/analyze-axe/src/axe-plugin.spec.ts index 5a8bd52..79a6dbe 100644 --- a/packages/@nitpicker/analyze-axe/src/index.spec.ts +++ b/packages/@nitpicker/analyze-axe/src/axe-plugin.spec.ts @@ -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; }); diff --git a/packages/@nitpicker/analyze-axe/src/index.ts b/packages/@nitpicker/analyze-axe/src/axe-plugin.ts similarity index 100% rename from packages/@nitpicker/analyze-axe/src/index.ts rename to packages/@nitpicker/analyze-axe/src/axe-plugin.ts diff --git a/packages/@nitpicker/analyze-lighthouse/package.json b/packages/@nitpicker/analyze-lighthouse/package.json index 9483dcf..24519c5 100644 --- a/packages/@nitpicker/analyze-lighthouse/package.json +++ b/packages/@nitpicker/analyze-lighthouse/package.json @@ -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": { diff --git a/packages/@nitpicker/analyze-lighthouse/src/index.spec.ts b/packages/@nitpicker/analyze-lighthouse/src/lighthouse-plugin.spec.ts similarity index 98% rename from packages/@nitpicker/analyze-lighthouse/src/index.spec.ts rename to packages/@nitpicker/analyze-lighthouse/src/lighthouse-plugin.spec.ts index be65d33..01f776a 100644 --- a/packages/@nitpicker/analyze-lighthouse/src/index.spec.ts +++ b/packages/@nitpicker/analyze-lighthouse/src/lighthouse-plugin.spec.ts @@ -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; }); diff --git a/packages/@nitpicker/analyze-lighthouse/src/index.ts b/packages/@nitpicker/analyze-lighthouse/src/lighthouse-plugin.ts similarity index 100% rename from packages/@nitpicker/analyze-lighthouse/src/index.ts rename to packages/@nitpicker/analyze-lighthouse/src/lighthouse-plugin.ts diff --git a/packages/@nitpicker/analyze-main-contents/package.json b/packages/@nitpicker/analyze-main-contents/package.json index 6166a07..0374ee8 100644 --- a/packages/@nitpicker/analyze-main-contents/package.json +++ b/packages/@nitpicker/analyze-main-contents/package.json @@ -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": { diff --git a/packages/@nitpicker/analyze-main-contents/src/index.spec.ts b/packages/@nitpicker/analyze-main-contents/src/main-contents-plugin.spec.ts similarity index 98% rename from packages/@nitpicker/analyze-main-contents/src/index.spec.ts rename to packages/@nitpicker/analyze-main-contents/src/main-contents-plugin.spec.ts index 39e62f0..ffa7755 100644 --- a/packages/@nitpicker/analyze-main-contents/src/index.spec.ts +++ b/packages/@nitpicker/analyze-main-contents/src/main-contents-plugin.spec.ts @@ -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; }); diff --git a/packages/@nitpicker/analyze-main-contents/src/index.ts b/packages/@nitpicker/analyze-main-contents/src/main-contents-plugin.ts similarity index 100% rename from packages/@nitpicker/analyze-main-contents/src/index.ts rename to packages/@nitpicker/analyze-main-contents/src/main-contents-plugin.ts diff --git a/packages/@nitpicker/analyze-markuplint/package.json b/packages/@nitpicker/analyze-markuplint/package.json index 765698e..64b3f7d 100644 --- a/packages/@nitpicker/analyze-markuplint/package.json +++ b/packages/@nitpicker/analyze-markuplint/package.json @@ -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": { diff --git a/packages/@nitpicker/analyze-markuplint/src/index.spec.ts b/packages/@nitpicker/analyze-markuplint/src/markuplint-plugin.spec.ts similarity index 97% rename from packages/@nitpicker/analyze-markuplint/src/index.spec.ts rename to packages/@nitpicker/analyze-markuplint/src/markuplint-plugin.spec.ts index 30f9cff..3af5ce6 100644 --- a/packages/@nitpicker/analyze-markuplint/src/index.spec.ts +++ b/packages/@nitpicker/analyze-markuplint/src/markuplint-plugin.spec.ts @@ -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; }); diff --git a/packages/@nitpicker/analyze-markuplint/src/index.ts b/packages/@nitpicker/analyze-markuplint/src/markuplint-plugin.ts similarity index 100% rename from packages/@nitpicker/analyze-markuplint/src/index.ts rename to packages/@nitpicker/analyze-markuplint/src/markuplint-plugin.ts diff --git a/packages/@nitpicker/analyze-search/package.json b/packages/@nitpicker/analyze-search/package.json index 0f2d801..b637f5b 100644 --- a/packages/@nitpicker/analyze-search/package.json +++ b/packages/@nitpicker/analyze-search/package.json @@ -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": { diff --git a/packages/@nitpicker/analyze-search/src/index.spec.ts b/packages/@nitpicker/analyze-search/src/search-plugin.spec.ts similarity index 98% rename from packages/@nitpicker/analyze-search/src/index.spec.ts rename to packages/@nitpicker/analyze-search/src/search-plugin.spec.ts index ea6942a..d8dc46a 100644 --- a/packages/@nitpicker/analyze-search/src/index.spec.ts +++ b/packages/@nitpicker/analyze-search/src/search-plugin.spec.ts @@ -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; }); diff --git a/packages/@nitpicker/analyze-search/src/index.ts b/packages/@nitpicker/analyze-search/src/search-plugin.ts similarity index 100% rename from packages/@nitpicker/analyze-search/src/index.ts rename to packages/@nitpicker/analyze-search/src/search-plugin.ts diff --git a/packages/@nitpicker/analyze-textlint/package.json b/packages/@nitpicker/analyze-textlint/package.json index 6faa8d5..c261f5e 100644 --- a/packages/@nitpicker/analyze-textlint/package.json +++ b/packages/@nitpicker/analyze-textlint/package.json @@ -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": { diff --git a/packages/@nitpicker/analyze-textlint/src/index.spec.ts b/packages/@nitpicker/analyze-textlint/src/textlint-plugin.spec.ts similarity index 98% rename from packages/@nitpicker/analyze-textlint/src/index.spec.ts rename to packages/@nitpicker/analyze-textlint/src/textlint-plugin.spec.ts index 5a07247..c96dda6 100644 --- a/packages/@nitpicker/analyze-textlint/src/index.spec.ts +++ b/packages/@nitpicker/analyze-textlint/src/textlint-plugin.spec.ts @@ -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; }); diff --git a/packages/@nitpicker/analyze-textlint/src/index.ts b/packages/@nitpicker/analyze-textlint/src/textlint-plugin.ts similarity index 100% rename from packages/@nitpicker/analyze-textlint/src/index.ts rename to packages/@nitpicker/analyze-textlint/src/textlint-plugin.ts diff --git a/packages/@nitpicker/cli/bin/nitpicker.js b/packages/@nitpicker/cli/bin/nitpicker.js index 227810f..503c9a6 100755 --- a/packages/@nitpicker/cli/bin/nitpicker.js +++ b/packages/@nitpicker/cli/bin/nitpicker.js @@ -1,3 +1,3 @@ #!/usr/bin/env node -import '../lib/index.js'; +import '../lib/cli.js'; diff --git a/packages/@nitpicker/cli/package.json b/packages/@nitpicker/cli/package.json index 43d48ae..35bdb6b 100644 --- a/packages/@nitpicker/cli/package.json +++ b/packages/@nitpicker/cli/package.json @@ -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": { diff --git a/packages/@nitpicker/cli/src/index.ts b/packages/@nitpicker/cli/src/cli.ts similarity index 100% rename from packages/@nitpicker/cli/src/index.ts rename to packages/@nitpicker/cli/src/cli.ts diff --git a/packages/@nitpicker/core/package.json b/packages/@nitpicker/core/package.json index 8568a45..d55cf45 100644 --- a/packages/@nitpicker/core/package.json +++ b/packages/@nitpicker/core/package.json @@ -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": { diff --git a/packages/@nitpicker/core/src/index.ts b/packages/@nitpicker/core/src/core.ts similarity index 76% rename from packages/@nitpicker/core/src/index.ts rename to packages/@nitpicker/core/src/core.ts index e6ff817..8ee2706 100644 --- a/packages/@nitpicker/core/src/index.ts +++ b/packages/@nitpicker/core/src/core.ts @@ -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'; diff --git a/packages/@nitpicker/core/src/hooks/index.ts b/packages/@nitpicker/core/src/hooks/index.ts deleted file mode 100644 index 4406f37..0000000 --- a/packages/@nitpicker/core/src/hooks/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { definePlugin } from './define-plugin.js'; diff --git a/packages/@nitpicker/crawler/package.json b/packages/@nitpicker/crawler/package.json index cf0cfa0..0a9ef93 100644 --- a/packages/@nitpicker/crawler/package.json +++ b/packages/@nitpicker/crawler/package.json @@ -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": { diff --git a/packages/@nitpicker/crawler/src/archive/archive-accessor.ts b/packages/@nitpicker/crawler/src/archive/archive-accessor.ts index 7deb9e9..b54bb84 100644 --- a/packages/@nitpicker/crawler/src/archive/archive-accessor.ts +++ b/packages/@nitpicker/crawler/src/archive/archive-accessor.ts @@ -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'; diff --git a/packages/@nitpicker/crawler/src/archive/archive.spec.ts b/packages/@nitpicker/crawler/src/archive/archive.spec.ts index 540eeb9..2947a4b 100644 --- a/packages/@nitpicker/crawler/src/archive/archive.spec.ts +++ b/packages/@nitpicker/crawler/src/archive/archive.spec.ts @@ -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(); + const original = await importOriginal(); return { ...original, outputText: vi.fn(original.outputText), @@ -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')); @@ -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')); diff --git a/packages/@nitpicker/crawler/src/archive/archive.ts b/packages/@nitpicker/crawler/src/archive/archive.ts index efd897a..adf6a9e 100644 --- a/packages/@nitpicker/crawler/src/archive/archive.ts +++ b/packages/@nitpicker/crawler/src/archive/archive.ts @@ -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`). diff --git a/packages/@nitpicker/crawler/src/archive/database.spec.ts b/packages/@nitpicker/crawler/src/archive/database.spec.ts index 9687374..d8d9bda 100644 --- a/packages/@nitpicker/crawler/src/archive/database.spec.ts +++ b/packages/@nitpicker/crawler/src/archive/database.spec.ts @@ -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); diff --git a/packages/@nitpicker/crawler/src/archive/database.ts b/packages/@nitpicker/crawler/src/archive/database.ts index 7c517df..15e4067 100644 --- a/packages/@nitpicker/crawler/src/archive/database.ts +++ b/packages/@nitpicker/crawler/src/archive/database.ts @@ -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'; @@ -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, diff --git a/packages/@nitpicker/crawler/src/archive/filesystem/index.ts b/packages/@nitpicker/crawler/src/archive/filesystem/index.ts deleted file mode 100644 index 95e8f1a..0000000 --- a/packages/@nitpicker/crawler/src/archive/filesystem/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -export { outputJSON } from './output-json.js'; -export { readJSON } from './read-json.js'; -export { outputText } from './output-text.js'; -export { appendText } from './append-text.js'; -export { readText } from './read-text.js'; -export { copyDir } from './copy-dir.js'; -export { copyDirSync } from './copy-dir-sync.js'; -export { isDir } from './is-dir.js'; -export { remove } from './remove.js'; -export { rename } from './rename.js'; -export { getFileList } from './get-file-list.js'; -export { readline } from './readline.js'; -export { mkdir } from './mkdir.js'; -export { exists } from './exists.js'; -export { tar } from './tar.js'; -export { untar } from './untar.js'; -export { zip, unzip, extractZip } from '@d-zero/fs/zip'; diff --git a/packages/@nitpicker/crawler/src/archive/index.ts b/packages/@nitpicker/crawler/src/archive/index.ts deleted file mode 100644 index 5bd4984..0000000 --- a/packages/@nitpicker/crawler/src/archive/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -// Archive storage and retrieval layer for Nitpicker crawl data. -// -// This package provides the `Archive` class for creating, reading, and writing -// `.nitpicker` archive files that store crawl results in a SQLite database along with -// optional HTML snapshots. It also exports the `ArchiveAccessor` for read-only -// access, `Page` and `Resource` model classes, and all related types. -export * from './archive-accessor.js'; -export type { Redirect, Referrer, Anchor, StaticPageData } from './page.js'; -export { default as Page } from './page.js'; -export { default as Resource } from './resource.js'; -export * from './types.js'; - -export { default } from './archive.js'; diff --git a/packages/@nitpicker/crawler/src/crawler-orchestrator.ts b/packages/@nitpicker/crawler/src/crawler-orchestrator.ts index 66c8fb3..e396689 100644 --- a/packages/@nitpicker/crawler/src/crawler-orchestrator.ts +++ b/packages/@nitpicker/crawler/src/crawler-orchestrator.ts @@ -11,10 +11,11 @@ import { TypedAwaitEventEmitter as EventEmitter } from '@d-zero/shared/typed-awa import pkg from '../package.json' with { type: 'json' }; import Archive from './archive/archive.js'; -import { clearDestinationCache, Crawler } from './crawler/index.js'; +import { clearDestinationCache } from './crawler/clear-destination-cache.js'; +import Crawler from './crawler/crawler.js'; import { crawlerLog, log } from './debug.js'; import { resolveOutputPath } from './resolve-output-path.js'; -import { cleanObject } from './utils/index.js'; +import { cleanObject } from './utils/object/clean-object.js'; import { WriteQueue } from './write-queue.js'; /** diff --git a/packages/@nitpicker/crawler/src/index.ts b/packages/@nitpicker/crawler/src/crawler.ts similarity index 65% rename from packages/@nitpicker/crawler/src/index.ts rename to packages/@nitpicker/crawler/src/crawler.ts index 0afe05c..dc1437e 100644 --- a/packages/@nitpicker/crawler/src/index.ts +++ b/packages/@nitpicker/crawler/src/crawler.ts @@ -6,7 +6,13 @@ */ // Types + Utils (旧 @nitpicker/types + utils) -export * from './utils/index.js'; +export * from './utils/types/types.js'; +export { eachSplitted } from './utils/array/each-splitted.js'; +export { DOMEvaluationError } from './utils/error/dom-evaluation-error.js'; +export { ErrorEmitter } from './utils/error/error-emitter.js'; +export type { ErrorEvent } from './utils/error/error-emitter.js'; +export * from './utils/object/clean-object.js'; +export { globalLog as log } from './utils/debug.js'; // Archive export { ArchiveAccessor } from './archive/archive-accessor.js'; diff --git a/packages/@nitpicker/crawler/src/crawler/handle-ignore-and-skip.ts b/packages/@nitpicker/crawler/src/crawler/handle-ignore-and-skip.ts index acc3ad6..b3bef79 100644 --- a/packages/@nitpicker/crawler/src/crawler/handle-ignore-and-skip.ts +++ b/packages/@nitpicker/crawler/src/crawler/handle-ignore-and-skip.ts @@ -1,6 +1,6 @@ import type LinkList from './link-list.js'; import type { CrawlerOptions } from './types.js'; -import type { Link } from '../utils/index.js'; +import type { Link } from '../utils/types/types.js'; import type { ExURL } from '@d-zero/shared/parse-url'; import { crawlerLog } from '../debug.js'; diff --git a/packages/@nitpicker/crawler/src/crawler/handle-resource-response.ts b/packages/@nitpicker/crawler/src/crawler/handle-resource-response.ts index def2f0c..fa6d462 100644 --- a/packages/@nitpicker/crawler/src/crawler/handle-resource-response.ts +++ b/packages/@nitpicker/crawler/src/crawler/handle-resource-response.ts @@ -1,4 +1,4 @@ -import type { Resource } from '../utils/index.js'; +import type { Resource } from '../utils/types/types.js'; /** * Track a network resource response and determine if it is newly discovered. diff --git a/packages/@nitpicker/crawler/src/crawler/handle-scrape-end.spec.ts b/packages/@nitpicker/crawler/src/crawler/handle-scrape-end.spec.ts index c0cc608..a146c94 100644 --- a/packages/@nitpicker/crawler/src/crawler/handle-scrape-end.spec.ts +++ b/packages/@nitpicker/crawler/src/crawler/handle-scrape-end.spec.ts @@ -1,5 +1,5 @@ import type { CrawlerOptions } from './types.js'; -import type { AnchorData, PageData } from '../utils/index.js'; +import type { AnchorData, PageData } from '../utils/types/types.js'; import { tryParseUrl as parseUrl } from '@d-zero/shared/parse-url'; import { describe, it, expect, vi } from 'vitest'; diff --git a/packages/@nitpicker/crawler/src/crawler/handle-scrape-end.ts b/packages/@nitpicker/crawler/src/crawler/handle-scrape-end.ts index 8169a1f..23c4fb5 100644 --- a/packages/@nitpicker/crawler/src/crawler/handle-scrape-end.ts +++ b/packages/@nitpicker/crawler/src/crawler/handle-scrape-end.ts @@ -1,6 +1,6 @@ import type LinkList from './link-list.js'; import type { CrawlerOptions } from './types.js'; -import type { AnchorData, Link, PageData } from '../utils/index.js'; +import type { AnchorData, Link, PageData } from '../utils/types/types.js'; import type { ExURL } from '@d-zero/shared/parse-url'; import { crawlerLog } from '../debug.js'; diff --git a/packages/@nitpicker/crawler/src/crawler/handle-scrape-error.ts b/packages/@nitpicker/crawler/src/crawler/handle-scrape-error.ts index 5173829..e8cdab3 100644 --- a/packages/@nitpicker/crawler/src/crawler/handle-scrape-error.ts +++ b/packages/@nitpicker/crawler/src/crawler/handle-scrape-error.ts @@ -1,6 +1,6 @@ import type LinkList from './link-list.js'; import type { CrawlerOptions } from './types.js'; -import type { Link, PageData } from '../utils/index.js'; +import type { Link, PageData } from '../utils/types/types.js'; import type { ExURL } from '@d-zero/shared/parse-url'; import { crawlerErrorLog } from '../debug.js'; diff --git a/packages/@nitpicker/crawler/src/crawler/index.ts b/packages/@nitpicker/crawler/src/crawler/index.ts deleted file mode 100644 index 20da7f3..0000000 --- a/packages/@nitpicker/crawler/src/crawler/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { default as Crawler } from './crawler.js'; -export { clearDestinationCache } from './clear-destination-cache.js'; diff --git a/packages/@nitpicker/crawler/src/crawler/link-list.spec.ts b/packages/@nitpicker/crawler/src/crawler/link-list.spec.ts index 590dbb7..103ef82 100644 --- a/packages/@nitpicker/crawler/src/crawler/link-list.spec.ts +++ b/packages/@nitpicker/crawler/src/crawler/link-list.spec.ts @@ -1,4 +1,4 @@ -import type { PageData } from '../utils/index.js'; +import type { PageData } from '../utils/types/types.js'; import type { ExURL, ParseURLOptions } from '@d-zero/shared/parse-url'; import { tryParseUrl as parseUrl } from '@d-zero/shared/parse-url'; diff --git a/packages/@nitpicker/crawler/src/crawler/link-list.ts b/packages/@nitpicker/crawler/src/crawler/link-list.ts index 433d390..ece2429 100644 --- a/packages/@nitpicker/crawler/src/crawler/link-list.ts +++ b/packages/@nitpicker/crawler/src/crawler/link-list.ts @@ -1,4 +1,4 @@ -import type { Link, PageData } from '../utils/index.js'; +import type { Link, PageData } from '../utils/types/types.js'; import type { ExURL, ParseURLOptions } from '@d-zero/shared/parse-url'; import { isError } from '@d-zero/beholder'; diff --git a/packages/@nitpicker/crawler/src/crawler/link-to-page-data.ts b/packages/@nitpicker/crawler/src/crawler/link-to-page-data.ts index 6d0d368..d59b916 100644 --- a/packages/@nitpicker/crawler/src/crawler/link-to-page-data.ts +++ b/packages/@nitpicker/crawler/src/crawler/link-to-page-data.ts @@ -1,4 +1,4 @@ -import type { Link, PageData } from '../utils/index.js'; +import type { Link, PageData } from '../utils/types/types.js'; /** * Convert a {@link Link} object into a {@link PageData} structure. diff --git a/packages/@nitpicker/crawler/src/crawler/types.ts b/packages/@nitpicker/crawler/src/crawler/types.ts index 68b3b26..977f902 100644 --- a/packages/@nitpicker/crawler/src/crawler/types.ts +++ b/packages/@nitpicker/crawler/src/crawler/types.ts @@ -1,4 +1,4 @@ -import type { PageData, CrawlerError, Resource } from '../utils/index.js'; +import type { PageData, CrawlerError, Resource } from '../utils/types/types.js'; import type { ChangePhaseEvent } from '@d-zero/beholder'; import type { ParseURLOptions } from '@d-zero/shared/parse-url'; diff --git a/packages/@nitpicker/crawler/src/types.ts b/packages/@nitpicker/crawler/src/types.ts index fbe90a7..10501e2 100644 --- a/packages/@nitpicker/crawler/src/types.ts +++ b/packages/@nitpicker/crawler/src/types.ts @@ -1,4 +1,4 @@ -import type { CrawlerError } from './utils/index.js'; +import type { CrawlerError } from './utils/types/types.js'; /** * Event map for the `CrawlerOrchestrator` class. diff --git a/packages/@nitpicker/crawler/src/utils/array/index.ts b/packages/@nitpicker/crawler/src/utils/array/index.ts deleted file mode 100644 index bc9ad2f..0000000 --- a/packages/@nitpicker/crawler/src/utils/array/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { eachSplitted } from './each-splitted.js'; diff --git a/packages/@nitpicker/crawler/src/utils/error/index.ts b/packages/@nitpicker/crawler/src/utils/error/index.ts deleted file mode 100644 index 58aa028..0000000 --- a/packages/@nitpicker/crawler/src/utils/error/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { DOMEvaluationError } from './dom-evaluation-error.js'; -export { ErrorEmitter } from './error-emitter.js'; -export type { ErrorEvent } from './error-emitter.js'; diff --git a/packages/@nitpicker/crawler/src/utils/index.ts b/packages/@nitpicker/crawler/src/utils/index.ts deleted file mode 100644 index cdf1c10..0000000 --- a/packages/@nitpicker/crawler/src/utils/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './types/index.js'; -export * from './array/index.js'; -export * from './error/index.js'; -export * from './object/index.js'; -export { globalLog as log } from './debug.js'; diff --git a/packages/@nitpicker/crawler/src/utils/object/index.ts b/packages/@nitpicker/crawler/src/utils/object/index.ts deleted file mode 100644 index abeda23..0000000 --- a/packages/@nitpicker/crawler/src/utils/object/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './clean-object.js'; diff --git a/packages/@nitpicker/crawler/src/utils/types/index.ts b/packages/@nitpicker/crawler/src/utils/types/index.ts deleted file mode 100644 index d470296..0000000 --- a/packages/@nitpicker/crawler/src/utils/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './types.js'; diff --git a/packages/@nitpicker/report-google-sheets/package.json b/packages/@nitpicker/report-google-sheets/package.json index 0ea2f11..842e049 100644 --- a/packages/@nitpicker/report-google-sheets/package.json +++ b/packages/@nitpicker/report-google-sheets/package.json @@ -18,8 +18,8 @@ "type": "module", "exports": { ".": { - "import": "./lib/index.js", - "types": "./lib/index.d.ts" + "import": "./lib/report-google-sheets.js", + "types": "./lib/report-google-sheets.d.ts" } }, "scripts": { diff --git a/packages/@nitpicker/report-google-sheets/src/index.ts b/packages/@nitpicker/report-google-sheets/src/report-google-sheets.ts similarity index 100% rename from packages/@nitpicker/report-google-sheets/src/index.ts rename to packages/@nitpicker/report-google-sheets/src/report-google-sheets.ts diff --git a/packages/@nitpicker/types/package.json b/packages/@nitpicker/types/package.json index 3dca653..3e812b3 100644 --- a/packages/@nitpicker/types/package.json +++ b/packages/@nitpicker/types/package.json @@ -18,8 +18,8 @@ "type": "module", "exports": { ".": { - "import": "./lib/index.js", - "types": "./lib/index.d.ts" + "import": "./lib/types.js", + "types": "./lib/types.d.ts" } }, "scripts": { diff --git a/packages/@nitpicker/types/src/index.ts b/packages/@nitpicker/types/src/types.ts similarity index 100% rename from packages/@nitpicker/types/src/index.ts rename to packages/@nitpicker/types/src/types.ts diff --git a/packages/test-server/src/__tests__/e2e/global-setup.ts b/packages/test-server/src/__tests__/e2e/global-setup.ts index c891e45..22e476d 100644 --- a/packages/test-server/src/__tests__/e2e/global-setup.ts +++ b/packages/test-server/src/__tests__/e2e/global-setup.ts @@ -6,7 +6,7 @@ let server: Server; * */ export async function setup() { - const { startServer } = await import('../../../src/index.js'); + const { startServer } = await import('../../../src/server.js'); server = await startServer(8010); console.log('[global-setup] Test server started on port 8010'); // eslint-disable-line no-console } diff --git a/packages/test-server/src/index.ts b/packages/test-server/src/server.ts similarity index 77% rename from packages/test-server/src/index.ts rename to packages/test-server/src/server.ts index dbf5c0d..beb5ba1 100644 --- a/packages/test-server/src/index.ts +++ b/packages/test-server/src/server.ts @@ -14,7 +14,8 @@ import { redirectRoutes } from './routes/redirect.js'; import { scopeRoutes } from './routes/scope.js'; /** - * + * Creates and configures the Hono application with all E2E test routes. + * @returns The configured Hono application instance. */ export function createApp() { const app = new Hono(); @@ -32,8 +33,9 @@ export function createApp() { } /** - * - * @param port + * Starts the E2E test server on the specified port. + * @param port - The port number to listen on. + * @returns A promise that resolves with the HTTP server instance once it is listening. */ export function startServer(port = 8010): Promise { const app = createApp();