@nitpicker/report-google-sheets 0.4.1 → 0.4.3

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.
Files changed (37) hide show
  1. package/package.json +7 -4
  2. package/CHANGELOG.md +0 -8
  3. package/src/__tests__/api/create-sheets.api.ts +0 -234
  4. package/src/__tests__/api/helpers.ts +0 -148
  5. package/src/__tests__/api/sheets.api.ts +0 -217
  6. package/src/archive.ts +0 -29
  7. package/src/data/add-to-summary.ts +0 -10
  8. package/src/data/create-discrepancies.ts +0 -81
  9. package/src/data/create-image-list.ts +0 -74
  10. package/src/data/create-links.ts +0 -134
  11. package/src/data/create-page-list.ts +0 -472
  12. package/src/data/create-referrers-relational-table.ts +0 -115
  13. package/src/data/create-resources-relational-table.ts +0 -104
  14. package/src/data/create-resources.ts +0 -51
  15. package/src/data/create-violations.spec.ts +0 -95
  16. package/src/data/create-violations.ts +0 -47
  17. package/src/debug.ts +0 -7
  18. package/src/index.ts +0 -1
  19. package/src/load-config.spec.ts +0 -37
  20. package/src/load-config.ts +0 -17
  21. package/src/report.ts +0 -231
  22. package/src/reports/get-plugin-reports.spec.ts +0 -42
  23. package/src/reports/get-plugin-reports.ts +0 -24
  24. package/src/sheets/create-cell-data.ts +0 -1
  25. package/src/sheets/create-sheets.ts +0 -523
  26. package/src/sheets/default-cell-format.spec.ts +0 -13
  27. package/src/sheets/default-cell-format.ts +0 -8
  28. package/src/sheets/format.spec.ts +0 -17
  29. package/src/sheets/format.ts +0 -14
  30. package/src/sheets/types.ts +0 -106
  31. package/src/types.ts +0 -11
  32. package/src/utils/has-prop-filter.spec.ts +0 -25
  33. package/src/utils/has-prop-filter.ts +0 -21
  34. package/src/utils/non-null-filter.spec.ts +0 -27
  35. package/src/utils/non-null-filter.ts +0 -15
  36. package/tsconfig.json +0 -11
  37. package/tsconfig.tsbuildinfo +0 -1
@@ -1,81 +0,0 @@
1
- import type { CreateSheet } from '../sheets/types.js';
2
- import type { Cell } from '@d-zero/google-sheets';
3
-
4
- import { pLog } from '../debug.js';
5
- import { createCellData } from '../sheets/create-cell-data.js';
6
- import { defaultCellFormat } from '../sheets/default-cell-format.js';
7
-
8
- const log = pLog.extend('Discrepancies');
9
-
10
- /**
11
- * Creates the "Discrepancies" sheet configuration.
12
- *
13
- * Generates discrepancy data from two sources:
14
- *
15
- * 1. **Link Text vs Page Title** (via `eachPage`): For every anchor on
16
- * each page, creates a row comparing the link's text content with the
17
- * linked page's title. This helps identify misleading or inconsistent
18
- * link labels.
19
- *
20
- * 2. **Plugin discrepancies** (via `addRows`): Includes any discrepancy data
21
- * produced by analyze plugins (e.g. meta tag consistency checks).
22
- *
23
- * Both data sources are written to the same sheet, distinguished by
24
- * the "Type" column.
25
- * @param reports
26
- */
27
- export const createDiscrepancies: CreateSheet = (reports) => {
28
- return {
29
- name: 'Discrepancies',
30
- createHeaders() {
31
- return ['Type', 'Left URL', 'Left', 'Right', 'Right URL', 'Note'];
32
- },
33
- async eachPage(page) {
34
- const anchors = await page.getAnchors();
35
- const data: Cell[][] = [];
36
- log('Create text link discrepancies');
37
- log('Found %d anchors', anchors.length);
38
- for (const anchor of anchors) {
39
- data.push([
40
- createCellData({ value: 'Link Text vs Page Title' }, defaultCellFormat),
41
- createCellData({ value: page.url.href }, defaultCellFormat),
42
- createCellData({ value: anchor.textContent }, defaultCellFormat),
43
- createCellData({ value: anchor.title }, defaultCellFormat),
44
- createCellData({ value: anchor.url }, defaultCellFormat),
45
- createCellData({ value: '' }, defaultCellFormat),
46
- ]);
47
- }
48
- return data;
49
- },
50
- addRows() {
51
- const data: Cell[][] = [];
52
- for (const report of reports) {
53
- if (!report.discrepancies) {
54
- continue;
55
- }
56
- for (const discrepancy of report.discrepancies) {
57
- data.push([
58
- createCellData(
59
- { value: discrepancy.leftSourceUrl, note: discrepancy.leftSourceUrlNote },
60
- defaultCellFormat,
61
- ),
62
- createCellData(
63
- { value: discrepancy.left, note: discrepancy.leftNote },
64
- defaultCellFormat,
65
- ),
66
- createCellData(
67
- { value: discrepancy.right, note: discrepancy.rightNote },
68
- defaultCellFormat,
69
- ),
70
- createCellData(
71
- { value: discrepancy.rightSourceUrl, note: discrepancy.rightSourceUrlNote },
72
- defaultCellFormat,
73
- ),
74
- createCellData({ value: discrepancy.note }, defaultCellFormat),
75
- ]);
76
- }
77
- }
78
- return data;
79
- },
80
- };
81
- };
@@ -1,74 +0,0 @@
1
- import type { CreateSheet } from '../sheets/types.js';
2
- import type { Cell } from '@d-zero/google-sheets';
3
-
4
- import { JSDOM } from 'jsdom';
5
-
6
- import { createCellData } from '../sheets/create-cell-data.js';
7
- import { defaultCellFormat } from '../sheets/default-cell-format.js';
8
-
9
- /**
10
- * Creates the "Images" sheet configuration.
11
- *
12
- * Extracts all `<img>` elements from each internal page's HTML and
13
- * reports their attributes (src, currentSrc, alt, dimensions, lazy loading).
14
- * Uses JSDOM to parse the HTML so that resolved `src` URLs (after base URL
15
- * resolution) and `currentSrc` (for `<picture>` / `srcset`) are available.
16
- *
17
- * External pages are skipped because their HTML snapshots are not stored
18
- * in the archive.
19
- */
20
- export const createImageList: CreateSheet = () => {
21
- return {
22
- name: 'Images',
23
- createHeaders() {
24
- return [
25
- 'Page URL',
26
- 'Image path (src)',
27
- 'Image Path (currentSrc)',
28
- 'Alternative Text',
29
- 'Displayed Width',
30
- 'Displayed Height',
31
- // 'Original Width',
32
- // 'Original Height',
33
- // 'Fit Width Rate',
34
- // 'Fit Height Rate',
35
- 'Lazy Loading',
36
- 'Source Code',
37
- ];
38
- },
39
-
40
- async eachPage(page) {
41
- if (!page.isInternalPage()) {
42
- return;
43
- }
44
-
45
- const html = await page.getHtml();
46
- if (!html) {
47
- return;
48
- }
49
- const dom = new JSDOM(html, { url: page.url.href });
50
- const imgs = dom.window.document.querySelectorAll('img');
51
-
52
- const imgData: Cell[][] = [];
53
-
54
- for (const img of imgs) {
55
- const data = [
56
- createCellData({ value: page.url.href }, defaultCellFormat),
57
- createCellData({ value: img.src }, defaultCellFormat),
58
- createCellData({ value: img.currentSrc }, defaultCellFormat),
59
- createCellData({ value: img.alt }, defaultCellFormat),
60
- createCellData({ value: img.width }, defaultCellFormat),
61
- createCellData({ value: img.height }, defaultCellFormat),
62
- // createCellData({ value: img.naturalWidth }, defaultCellFormat),
63
- // createCellData({ value: img.naturalHeight }, defaultCellFormat),
64
- createCellData({ value: img.loading === 'lazy' }, defaultCellFormat),
65
- createCellData({ value: img.outerHTML }, defaultCellFormat),
66
- ];
67
-
68
- imgData.push(data);
69
- }
70
-
71
- return imgData;
72
- },
73
- };
74
- };
@@ -1,134 +0,0 @@
1
- import type { CreateSheet } from '../sheets/types.js';
2
-
3
- import { pLog } from '../debug.js';
4
- import { createCellData } from '../sheets/create-cell-data.js';
5
- import { defaultCellFormat } from '../sheets/default-cell-format.js';
6
- import { booleanFormatError } from '../sheets/format.js';
7
-
8
- const log = pLog.extend('Links');
9
-
10
- /**
11
- * Creates the "Links" sheet configuration.
12
- *
13
- * Produces one row per crawled page with URL, title, HTTP status,
14
- * content type, redirect chain, referrers, response headers, and remarks.
15
- * The remarks column shows the skip reason for pages that were skipped
16
- * during crawling (e.g., blocked by robots.txt, excluded by rules).
17
- * Applies conditional formatting to highlight:
18
- * - Status codes >= 400 (client/server errors)
19
- * - Status codes outside the 200-399 range (non-success)
20
- *
21
- * The header row and first column are frozen for easier scrolling.
22
- */
23
- export const createLinks: CreateSheet = () => {
24
- return {
25
- name: 'Links',
26
- createHeaders() {
27
- return [
28
- 'URL',
29
- 'Page Title',
30
- 'Status Code',
31
- 'Status Text',
32
- 'Content Type',
33
- 'Redirect From',
34
- 'Referrers',
35
- 'Headers',
36
- 'Remarks',
37
- ];
38
- },
39
- async eachPage(page, num, total) {
40
- const p = Math.round((num / total) * 100);
41
- log('Create links (%d%% %d/%d)', p, num, total);
42
-
43
- // if (page.isInternalPage()) {
44
- // return;
45
- // }
46
-
47
- const referrers = await page.getReferrers();
48
- const data = [
49
- createCellData(
50
- {
51
- value: page.url.href,
52
- textFormat: { link: { uri: page.url.href } },
53
- },
54
- defaultCellFormat,
55
- ),
56
- createCellData({ value: page.title || '-' }, defaultCellFormat),
57
- createCellData({ value: page.status || -1 }, defaultCellFormat),
58
- createCellData({ value: page.statusText || '' }, defaultCellFormat),
59
- createCellData({ value: page.contentType || '' }, defaultCellFormat),
60
- createCellData(
61
- {
62
- value: page.redirectFrom.length,
63
- note: page.redirectFrom.map((r) => r.url).join('\n'),
64
- },
65
- defaultCellFormat,
66
- ),
67
- createCellData(
68
- {
69
- value: `${referrers.length} Elements`,
70
- note: referrers
71
- .map((ref) => {
72
- const text = ref.textContent || '__NO_TEXT_CONTENT__';
73
- const url = ref.url + (ref.hash ? `#${ref.hash}` : '');
74
- const pass =
75
- page.url.href === ref.through
76
- ? ''
77
- : ` => [REDIRECTED FROM] ${ref.through}`;
78
- return `${text} (${url}${pass})`;
79
- })
80
- .join('\n'),
81
- },
82
- defaultCellFormat,
83
- ),
84
- createCellData(
85
- {
86
- value: '{}',
87
- note: JSON.stringify(page.responseHeaders, null, 2),
88
- },
89
- defaultCellFormat,
90
- ),
91
- createCellData(
92
- { value: page.isSkipped ? page.skipReason || 'skipped' : '' },
93
- defaultCellFormat,
94
- ),
95
- ];
96
-
97
- return [data];
98
- },
99
- async updateSheet(sheet) {
100
- await sheet.frozen(2, 1);
101
-
102
- await sheet.conditionalFormat([sheet.getColNumByHeaderName('Status Code')], {
103
- booleanRule: {
104
- condition: {
105
- type: 'NUMBER_GREATER_THAN_EQ',
106
- values: [
107
- {
108
- userEnteredValue: '400',
109
- },
110
- ],
111
- },
112
- format: booleanFormatError,
113
- },
114
- });
115
-
116
- await sheet.conditionalFormat([sheet.getColNumByHeaderName('Status Code')], {
117
- booleanRule: {
118
- condition: {
119
- type: 'NUMBER_NOT_BETWEEN',
120
- values: [
121
- {
122
- userEnteredValue: '200',
123
- },
124
- {
125
- userEnteredValue: '399',
126
- },
127
- ],
128
- },
129
- format: booleanFormatError,
130
- },
131
- });
132
- },
133
- };
134
- };