@d-zero/archaeologist 3.6.1 → 3.7.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
@@ -14,15 +14,16 @@
14
14
  ## CLI
15
15
 
16
16
  ```sh
17
+ npx @d-zero/archaeologist <urlA> <urlB> [options]
17
18
  npx @d-zero/archaeologist -f <listfile> [options]
18
19
  ```
19
20
 
20
- URLリストを持つファイルを指定して実行します。
21
+ 2つのURLを直接指定するか、URLリストを持つファイルを指定して実行します。
21
22
 
22
23
  ### オプション
23
24
 
24
25
  - `-v, --version`: バージョンを表示
25
- - `-f, --listfile <filepath>`: URLリストを持つファイルのパス(必須)
26
+ - `-f, --listfile <filepath>`: URLリストを持つファイルのパス
26
27
  - `-t, --type <types>`: 比較タイプの指定(`image,dom,text,code`、カンマ区切り)
27
28
  - `-s, --selector <selector>`: 比較対象を限定するCSSセレクター
28
29
  - `-i, --ignore <selector>`: 無視するCSSセレクター
@@ -61,6 +62,9 @@ URLリストを持つファイルを指定して実行します。
61
62
  ### 使用例
62
63
 
63
64
  ```sh
65
+ # 2つのURLを直接比較
66
+ npx @d-zero/archaeologist http://localhost:3000/page https://example.com/page
67
+
64
68
  # デフォルトデバイス(desktop-compact, mobile)
65
69
  npx @d-zero/archaeologist -f urls.txt
66
70
 
package/dist/cli.js CHANGED
@@ -6,7 +6,7 @@ import { freeze } from './freeze-main-process.js';
6
6
  import { readConfig } from './read-config.js';
7
7
  const require = createRequire(import.meta.url);
8
8
  const pkg = require('../package.json');
9
- const { options, hasConfigFile } = createCLI({
9
+ const { options, args, hasConfigFile } = createCLI({
10
10
  name: pkg.name,
11
11
  version: pkg.version,
12
12
  aliases: {
@@ -17,7 +17,8 @@ const { options, hasConfigFile } = createCLI({
17
17
  d: 'devices',
18
18
  },
19
19
  usage: [
20
- 'Usage: archaeologist -f <listfile> [options]',
20
+ 'Usage: archaeologist <urlA> <urlB> [options]',
21
+ ' archaeologist -f <listfile> [options]',
21
22
  '',
22
23
  'Options:',
23
24
  '\t-f, --listfile <file> File containing URL pairs to analyze',
@@ -39,6 +40,7 @@ const { options, hasConfigFile } = createCLI({
39
40
  '\tdesktop, tablet, mobile, desktop-hd, desktop-compact, mobile-large, mobile-small',
40
41
  '',
41
42
  'Examples:',
43
+ '\tarchaeologist http://localhost:3000 https://example.com',
42
44
  '\tarchaeologist -f urls.txt',
43
45
  '\tarchaeologist -f urls.txt --devices desktop,mobile',
44
46
  '\tarchaeologist -f urls.txt --combined',
@@ -56,24 +58,24 @@ const { options, hasConfigFile } = createCLI({
56
58
  cli.device,
57
59
  combined: cli.combined,
58
60
  }),
59
- validateArgs: (options) => {
60
- return !!(options.listfile?.length || options.freeze?.length);
61
+ validateArgs: (options, cli) => {
62
+ return !!(options.listfile?.length || options.freeze?.length || cli._.length === 2);
61
63
  },
62
64
  });
65
+ const analyzeOptions = {
66
+ types: options.type ? parseList(options.type) : undefined,
67
+ selector: options.selector,
68
+ ignore: options.ignore,
69
+ devices: options.devices ? parseList(options.devices) : undefined,
70
+ combined: options.combined,
71
+ limit: options.limit,
72
+ debug: options.debug,
73
+ verbose: options.verbose,
74
+ interval: options.interval,
75
+ };
63
76
  if (hasConfigFile) {
64
77
  const { pairList, hooks } = await readConfig(options.listfile);
65
- await analyze(pairList, {
66
- hooks,
67
- types: options.type ? parseList(options.type) : undefined,
68
- selector: options.selector,
69
- ignore: options.ignore,
70
- devices: options.devices ? parseList(options.devices) : undefined,
71
- combined: options.combined,
72
- limit: options.limit,
73
- debug: options.debug,
74
- verbose: options.verbose,
75
- interval: options.interval,
76
- });
78
+ await analyze(pairList, { ...analyzeOptions, hooks });
77
79
  process.exit(0);
78
80
  }
79
81
  if (options.freeze) {
@@ -87,3 +89,8 @@ if (options.freeze) {
87
89
  });
88
90
  process.exit(0);
89
91
  }
92
+ if (args.length === 2) {
93
+ const pairList = [[args[0], args[1]]];
94
+ await analyze(pairList, { ...analyzeOptions, hooks: [] });
95
+ process.exit(0);
96
+ }
package/dist/types.d.ts CHANGED
@@ -1,50 +1,99 @@
1
1
  export type { PageHook } from '@d-zero/puppeteer-screenshot';
2
2
  import type { PageHook, Screenshot } from '@d-zero/puppeteer-screenshot';
3
+ /**
4
+ * ページごとのスクリーンショットとDOMツリーのデータ
5
+ */
3
6
  export type PageData = {
4
7
  url: string;
5
8
  screenshots: Record<string, Screenshot & {
6
9
  domTree: string;
7
10
  }>;
8
11
  };
12
+ /**
13
+ * 比較対象のURLペア
14
+ */
9
15
  export type URLPair = readonly [urlA: string, urlB: string];
16
+ /**
17
+ * URLペアの比較結果
18
+ */
10
19
  export type Result = {
11
20
  target: [urlA: string, urlB: string];
12
21
  screenshots: Record<string, MediaResult>;
13
22
  code: CodeResult | null;
14
23
  };
24
+ /**
25
+ * デバイスサイズごとのメディア比較結果
26
+ */
15
27
  export type MediaResult = {
16
28
  image: ImageResult | null;
17
29
  dom: DOMResult | null;
18
30
  text: TextResult | null;
19
31
  };
32
+ /**
33
+ * ビジュアル差分の結果
34
+ */
20
35
  export type ImageResult = {
36
+ /** ピクセル一致率(0〜1) */
21
37
  matches: number;
38
+ /** 差分画像のファイルパス */
22
39
  file: string;
23
40
  };
41
+ /**
42
+ * DOM差分の結果
43
+ */
24
44
  export type DOMResult = {
45
+ /** DOM一致率(0〜1) */
25
46
  matches: number;
47
+ /** 差分テキスト(差分がない場合はnull) */
26
48
  diff: string | null;
49
+ /** 差分ファイルのパス */
27
50
  file: string;
28
51
  };
52
+ /**
53
+ * テキスト差分の結果(形態素解析による比較)
54
+ */
29
55
  export type TextResult = {
56
+ /** テキスト一致率(0〜1) */
30
57
  matches: number;
58
+ /** 差分テキスト(差分がない場合はnull) */
31
59
  diff: string | null;
60
+ /** 差分ファイルのパス */
32
61
  file: string;
33
62
  };
63
+ /**
64
+ * 生HTMLソースの差分結果
65
+ */
34
66
  export type CodeResult = {
67
+ /** ソースコード一致率(0〜1) */
35
68
  matches: number;
69
+ /** 差分テキスト(差分がない場合はnull) */
36
70
  diff: string | null;
71
+ /** 差分ファイルのパス */
37
72
  file: string;
38
73
  };
74
+ /**
75
+ * Archaeologistの分析オプション
76
+ */
39
77
  export interface ArchaeologistOptions extends AnalyzeOptions {
40
78
  }
79
+ /**
80
+ * 分析オプション
81
+ */
41
82
  export interface AnalyzeOptions extends GeneralOptions {
83
+ /** 比較タイプ(`image`, `dom`, `text`, `code`) */
42
84
  readonly types?: readonly string[];
85
+ /** 比較対象を限定するCSSセレクター */
43
86
  readonly selector?: string;
87
+ /** 無視するCSSセレクター */
44
88
  readonly ignore?: string;
89
+ /** デバイスプリセット名 */
45
90
  readonly devices?: readonly string[];
91
+ /** 環境AとBのスクリーンショットを左右に並べた合成画像を出力 */
46
92
  readonly combined?: boolean;
47
93
  }
94
+ /**
95
+ * フリーズモードのオプション
96
+ */
48
97
  export interface FreezeOptions extends GeneralOptions {
49
98
  }
50
99
  interface GeneralOptions {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d-zero/archaeologist",
3
- "version": "3.6.1",
3
+ "version": "3.7.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.6",
27
+ "@d-zero/cli-core": "1.3.7",
28
28
  "@d-zero/fs": "0.2.2",
29
29
  "@d-zero/html-distiller": "2.0.4",
30
- "@d-zero/puppeteer-dealer": "0.7.8",
31
- "@d-zero/puppeteer-page-scan": "4.4.8",
32
- "@d-zero/puppeteer-screenshot": "3.3.8",
30
+ "@d-zero/puppeteer-dealer": "0.7.9",
31
+ "@d-zero/puppeteer-page-scan": "4.4.9",
32
+ "@d-zero/puppeteer-screenshot": "3.3.9",
33
33
  "@d-zero/readtext": "1.1.20",
34
- "@d-zero/shared": "0.21.1",
34
+ "@d-zero/shared": "0.21.2",
35
35
  "ansi-colors": "4.1.3",
36
36
  "diff": "8.0.3",
37
37
  "front-matter": "4.0.2",
@@ -49,5 +49,5 @@
49
49
  "@types/pixelmatch": "5.2.6",
50
50
  "@types/pngjs": "6.0.5"
51
51
  },
52
- "gitHead": "a347e4e88968fca7f2ace7639090d32014479d9f"
52
+ "gitHead": "964c118678a0ad4377e4c2c9af8833707fa29c2d"
53
53
  }