@d-zero/archaeologist 3.7.1 → 4.0.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 +2 -0
- package/dist/analyze-child-process.d.ts +2 -2
- package/dist/analyze-child-process.js +7 -2
- package/dist/analyze-main-process.js +1 -1
- package/dist/cli.js +1 -1
- package/dist/freeze-child-process.d.ts +2 -0
- package/dist/freeze-child-process.js +7 -3
- package/dist/freeze-main-process.js +1 -0
- package/dist/read-config.d.ts +4 -3
- package/dist/read-config.js +6 -5
- package/dist/types.d.ts +4 -3
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -155,6 +155,8 @@ export default async function (page, { name, width, resolution, log }) {
|
|
|
155
155
|
|
|
156
156
|
例のように、ページにログインする処理をフックスクリプトに記述することで、ユーザー認証が必要なページのスクリーンショットを撮影することができます。
|
|
157
157
|
|
|
158
|
+
> **挙動変更のお知らせ:** これまでのバージョンでは、内部のプロセス間通信の制約により設定ファイルの `hooks` が `analyze` / `--freeze` の両モードで無視されていました。本リリース(次回 minor)から正しく実行されます。詳細は [MIGRATION-page-hooks.md](../../../MIGRATION-page-hooks.md) を参照してください。
|
|
159
|
+
|
|
158
160
|
## 認証
|
|
159
161
|
|
|
160
162
|
### Basic認証
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { URLPair } from './types.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { PageHookSource } from '@d-zero/puppeteer-page-scan';
|
|
3
3
|
export type ChildProcessParams = {
|
|
4
4
|
list: readonly URLPair[];
|
|
5
5
|
dir: string;
|
|
@@ -8,6 +8,6 @@ export type ChildProcessParams = {
|
|
|
8
8
|
selector?: string;
|
|
9
9
|
ignore?: string;
|
|
10
10
|
devices?: readonly string[];
|
|
11
|
-
hooks?:
|
|
11
|
+
hooks?: PageHookSource;
|
|
12
12
|
combined?: boolean;
|
|
13
13
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { writeFile } from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { createChildProcess } from '@d-zero/puppeteer-dealer';
|
|
4
|
+
import { readPageHooks } from '@d-zero/puppeteer-page-scan';
|
|
4
5
|
import { delay } from '@d-zero/shared/delay';
|
|
5
6
|
import c from 'ansi-colors';
|
|
6
7
|
import { combineImages } from './modules/combine-images.js';
|
|
@@ -11,8 +12,11 @@ import { fetchHtml } from './modules/fetch-html.js';
|
|
|
11
12
|
import { getData } from './modules/get-data.js';
|
|
12
13
|
import { normalizeTextDocument } from './modules/normalize-text-document.js';
|
|
13
14
|
import { score } from './utils.js';
|
|
14
|
-
createChildProcess((param) => {
|
|
15
|
-
const { list, dir, types = ['image', 'dom', 'text', 'code'], selector, ignore, devices, combined = false, } = param;
|
|
15
|
+
createChildProcess(async (param) => {
|
|
16
|
+
const { list, dir, types = ['image', 'dom', 'text', 'code'], selector, ignore, devices, hooks: hookSource, combined = false, } = param;
|
|
17
|
+
const hooks = hookSource && hookSource.paths.length > 0
|
|
18
|
+
? await readPageHooks(hookSource.paths, hookSource.baseDir)
|
|
19
|
+
: undefined;
|
|
16
20
|
return {
|
|
17
21
|
async eachPage({ page, url: urlA, index }, logger) {
|
|
18
22
|
const urlPair = list.find(([url]) => url === urlA);
|
|
@@ -29,6 +33,7 @@ createChildProcess((param) => {
|
|
|
29
33
|
selector,
|
|
30
34
|
ignore,
|
|
31
35
|
devices,
|
|
36
|
+
hooks,
|
|
32
37
|
}, logger);
|
|
33
38
|
dataPair.push(data);
|
|
34
39
|
await delay(600);
|
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { writeFile } from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { createChildProcess } from '@d-zero/puppeteer-dealer';
|
|
4
|
+
import { readPageHooks } from '@d-zero/puppeteer-page-scan';
|
|
4
5
|
import { delay } from '@d-zero/shared/delay';
|
|
5
6
|
import { getData } from './modules/get-data.js';
|
|
6
|
-
createChildProcess((param) => {
|
|
7
|
-
const { dir } = param;
|
|
7
|
+
createChildProcess(async (param) => {
|
|
8
|
+
const { dir, hooks: hookSource } = param;
|
|
9
|
+
const hooks = hookSource && hookSource.paths.length > 0
|
|
10
|
+
? await readPageHooks(hookSource.paths, hookSource.baseDir)
|
|
11
|
+
: undefined;
|
|
8
12
|
return {
|
|
9
13
|
async eachPage({ page, id, url }, logger) {
|
|
10
|
-
const data = await getData(page, url, {}, logger);
|
|
14
|
+
const data = await getData(page, url, { hooks }, logger);
|
|
11
15
|
await delay(600);
|
|
12
16
|
for (const size of Object.values(data.screenshots)) {
|
|
13
17
|
const jsonFile = path.resolve(dir, `${id}_${size.id}.html`);
|
package/dist/read-config.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import type { PageHookSource } from '@d-zero/puppeteer-page-scan';
|
|
1
2
|
/**
|
|
2
|
-
* Frontmatter形式の設定ファイルを読み込み、URL
|
|
3
|
+
* Frontmatter形式の設定ファイルを読み込み、URLペアリストとページフックの参照を返す
|
|
3
4
|
* @param filePath - 設定ファイルのパス
|
|
4
|
-
* @returns URL
|
|
5
|
+
* @returns URLペアのリストとページフックのロード元情報
|
|
5
6
|
*/
|
|
6
7
|
export declare function readConfig(filePath: string): Promise<{
|
|
7
8
|
pairList: [string, string][];
|
|
8
|
-
hooks:
|
|
9
|
+
hooks: PageHookSource;
|
|
9
10
|
}>;
|
package/dist/read-config.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { readPageHooks } from '@d-zero/puppeteer-page-scan';
|
|
2
1
|
import { toList } from '@d-zero/readtext/list';
|
|
3
2
|
import { readConfigFile } from '@d-zero/shared/config-reader';
|
|
4
3
|
/**
|
|
5
|
-
* Frontmatter形式の設定ファイルを読み込み、URL
|
|
4
|
+
* Frontmatter形式の設定ファイルを読み込み、URLペアリストとページフックの参照を返す
|
|
6
5
|
* @param filePath - 設定ファイルのパス
|
|
7
|
-
* @returns URL
|
|
6
|
+
* @returns URLペアのリストとページフックのロード元情報
|
|
8
7
|
*/
|
|
9
8
|
export async function readConfig(filePath) {
|
|
10
9
|
const { content, baseDir } = await readConfigFile(filePath);
|
|
@@ -16,9 +15,11 @@ export async function readConfig(filePath) {
|
|
|
16
15
|
`${content.attributes.comparisonHost}${url.pathname}${url.search}`,
|
|
17
16
|
];
|
|
18
17
|
});
|
|
19
|
-
const hooks = await readPageHooks(content.attributes?.hooks ?? [], baseDir);
|
|
20
18
|
return {
|
|
21
19
|
pairList,
|
|
22
|
-
hooks
|
|
20
|
+
hooks: {
|
|
21
|
+
paths: content.attributes?.hooks ?? [],
|
|
22
|
+
baseDir,
|
|
23
|
+
},
|
|
23
24
|
};
|
|
24
25
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
1
|
+
import type { PageHookSource } from '@d-zero/puppeteer-page-scan';
|
|
2
|
+
import type { Screenshot } from '@d-zero/puppeteer-screenshot';
|
|
3
3
|
/**
|
|
4
4
|
* ページごとのスクリーンショットとDOMツリーのデータ
|
|
5
5
|
*/
|
|
@@ -97,7 +97,8 @@ export interface AnalyzeOptions extends GeneralOptions {
|
|
|
97
97
|
export interface FreezeOptions extends GeneralOptions {
|
|
98
98
|
}
|
|
99
99
|
interface GeneralOptions {
|
|
100
|
-
readonly hooks
|
|
100
|
+
readonly hooks?: PageHookSource;
|
|
101
101
|
readonly limit?: number;
|
|
102
102
|
readonly debug?: boolean;
|
|
103
103
|
}
|
|
104
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d-zero/archaeologist",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Uncover visual and HTML differences in web pages with precision",
|
|
5
5
|
"author": "D-ZERO",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"clean": "tsc --build --clean"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@d-zero/cli-core": "1.3.
|
|
27
|
+
"@d-zero/cli-core": "1.3.9",
|
|
28
28
|
"@d-zero/fs": "0.2.3",
|
|
29
29
|
"@d-zero/html-distiller": "2.0.5",
|
|
30
|
-
"@d-zero/puppeteer-dealer": "0.7.
|
|
31
|
-
"@d-zero/puppeteer-page-scan": "4.
|
|
32
|
-
"@d-zero/puppeteer-screenshot": "3.
|
|
30
|
+
"@d-zero/puppeteer-dealer": "0.7.11",
|
|
31
|
+
"@d-zero/puppeteer-page-scan": "4.5.0",
|
|
32
|
+
"@d-zero/puppeteer-screenshot": "3.4.0",
|
|
33
33
|
"@d-zero/readtext": "1.1.21",
|
|
34
|
-
"@d-zero/shared": "0.
|
|
34
|
+
"@d-zero/shared": "0.22.0",
|
|
35
35
|
"ansi-colors": "4.1.3",
|
|
36
36
|
"diff": "8.0.3",
|
|
37
37
|
"front-matter": "4.0.2",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"url": "https://github.com/d-zero-dev/tools.git",
|
|
55
55
|
"directory": "packages/@d-zero/archaeologist"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "2d24e08c0cb516b7ea9d07a4301eb991193cca11"
|
|
58
58
|
}
|