@nitpicker/report-google-sheets 0.23.0 → 0.25.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 +1 -1
- package/lib/data/create-image-list.js +1 -1
- package/lib/data/create-links.js +4 -4
- package/lib/data/create-page-list.d.ts +1 -3
- package/lib/data/create-page-list.js +4 -55
- package/lib/data/create-referrers-relational-table.d.ts +0 -1
- package/lib/data/create-referrers-relational-table.js +3 -4
- package/lib/data/create-resources-relational-table.d.ts +0 -1
- package/lib/data/create-resources-relational-table.js +3 -4
- package/lib/data/create-resources.js +1 -1
- package/lib/debug.d.ts +0 -1
- package/lib/debug.js +0 -1
- package/lib/open-report-archive.d.ts +2 -2
- package/lib/open-report-archive.js +1 -1
- package/lib/report.d.ts +5 -11
- package/lib/report.js +5 -42
- package/lib/sheets/create-sheets.d.ts +1 -4
- package/lib/sheets/create-sheets.js +2 -2
- package/lib/sheets/types.d.ts +6 -8
- package/lib/utils/truncate-note-text.d.ts +1 -1
- package/lib/utils/truncate-note-text.js +1 -1
- package/package.json +8 -8
- package/lib/data/create-discrepancies.d.ts +0 -17
- package/lib/data/create-discrepancies.js +0 -61
- package/lib/data/create-violations.d.ts +0 -19
- package/lib/data/create-violations.js +0 -67
- package/lib/load-config.d.ts +0 -8
- package/lib/load-config.js +0 -16
- package/lib/reports/get-plugin-reports.d.ts +0 -17
- package/lib/reports/get-plugin-reports.js +0 -29
package/README.md
CHANGED
package/lib/data/create-links.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { applyEqualityOrInFilter, getInboundReferrerUrlsByPageIds, streamAllContentItems, } from '@nitpicker/query';
|
|
2
|
-
import {
|
|
2
|
+
import { sheetLog } from '../debug.js';
|
|
3
3
|
import { createCellData } from '../sheets/create-cell-data.js';
|
|
4
4
|
import { defaultCellFormat } from '../sheets/default-cell-format.js';
|
|
5
5
|
import { booleanFormatError } from '../sheets/format.js';
|
|
6
6
|
import { joinUrlsForNote } from '../utils/join-urls-for-note.js';
|
|
7
7
|
import { truncateNoteText } from '../utils/truncate-note-text.js';
|
|
8
|
-
const log =
|
|
8
|
+
const log = sheetLog.extend('Links');
|
|
9
9
|
/**
|
|
10
10
|
* Formats one referrer's cell-note line, restoring the pre-rewrite report's
|
|
11
11
|
* `text (url => [REDIRECTED FROM] rawUrl)` shape.
|
|
@@ -56,7 +56,7 @@ function formatReferrerNoteLine(detail) {
|
|
|
56
56
|
*/
|
|
57
57
|
export function createLinks(options) {
|
|
58
58
|
const urls = options?.urls;
|
|
59
|
-
return (
|
|
59
|
+
return (accessor) => {
|
|
60
60
|
return {
|
|
61
61
|
name: 'Links',
|
|
62
62
|
requiresReadModel: true,
|
|
@@ -84,7 +84,7 @@ export function createLinks(options) {
|
|
|
84
84
|
async run({ sheet, maxRows, estimatedTotal, onProgress }) {
|
|
85
85
|
let sent = 0;
|
|
86
86
|
// No cheap running total from `streamAllContentItems` itself (unlike
|
|
87
|
-
// `
|
|
87
|
+
// `listViewerPages`'s `page.total`)
|
|
88
88
|
// — `estimatedTotal` (from `estimateRowCount()`, captured once in
|
|
89
89
|
// Phase 1.5) is the progress denominator instead.
|
|
90
90
|
const total = estimatedTotal;
|
|
@@ -2,8 +2,7 @@ import type { CreateSheet } from '../sheets/types.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Creates the "Page List" sheet configuration -- the primary sitemap-style report.
|
|
4
4
|
*
|
|
5
|
-
* This is the most complex sheet,
|
|
6
|
-
* plugin data into a comprehensive per-page inventory:
|
|
5
|
+
* This is the most complex sheet, turning crawler metadata into a comprehensive per-page inventory:
|
|
7
6
|
*
|
|
8
7
|
* - **URL decomposition**: Protocol, domain, and up to 10 path segments for
|
|
9
8
|
* hierarchical filtering in the spreadsheet — computed once at read-model
|
|
@@ -16,7 +15,6 @@ import type { CreateSheet } from '../sheets/types.js';
|
|
|
16
15
|
* (status >= 400, excluding 401 which is often auth-protected) — fetched
|
|
17
16
|
* per cursor batch via `getOutboundLinkFactsByPageIds`.
|
|
18
17
|
* - **SEO metadata**: description, keywords, canonical, alternate, OGP, etc.
|
|
19
|
-
* - **Plugin columns**: Dynamic columns from analyze plugin `pageData`.
|
|
20
18
|
*
|
|
21
19
|
* Conditional formatting highlights:
|
|
22
20
|
* - Bad links (non-zero count)
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { tryParseUrl as parseUrl } from '@d-zero/shared/parse-url';
|
|
2
2
|
import { buildRedirectFromUrlsByDestId, countPageListRows, getOutboundLinkFactsByPageIds, streamPageListRows, } from '@nitpicker/query';
|
|
3
|
-
import {
|
|
3
|
+
import { sheetLog } from '../debug.js';
|
|
4
4
|
import { createCellData } from '../sheets/create-cell-data.js';
|
|
5
5
|
import { defaultCellFormat } from '../sheets/default-cell-format.js';
|
|
6
6
|
import { booleanFormatError } from '../sheets/format.js';
|
|
7
7
|
import { joinUrlsForNote } from '../utils/join-urls-for-note.js';
|
|
8
|
-
import { nonNullFilter } from '../utils/non-null-filter.js';
|
|
9
8
|
import { truncateNoteText } from '../utils/truncate-note-text.js';
|
|
10
|
-
const log =
|
|
9
|
+
const log = sheetLog.extend('PageList');
|
|
11
10
|
/**
|
|
12
11
|
* Creates the "Page List" sheet configuration -- the primary sitemap-style report.
|
|
13
12
|
*
|
|
14
|
-
* This is the most complex sheet,
|
|
15
|
-
* plugin data into a comprehensive per-page inventory:
|
|
13
|
+
* This is the most complex sheet, turning crawler metadata into a comprehensive per-page inventory:
|
|
16
14
|
*
|
|
17
15
|
* - **URL decomposition**: Protocol, domain, and up to 10 path segments for
|
|
18
16
|
* hierarchical filtering in the spreadsheet — computed once at read-model
|
|
@@ -25,7 +23,6 @@ const log = pLog.extend('PageList');
|
|
|
25
23
|
* (status >= 400, excluding 401 which is often auth-protected) — fetched
|
|
26
24
|
* per cursor batch via `getOutboundLinkFactsByPageIds`.
|
|
27
25
|
* - **SEO metadata**: description, keywords, canonical, alternate, OGP, etc.
|
|
28
|
-
* - **Plugin columns**: Dynamic columns from analyze plugin `pageData`.
|
|
29
26
|
*
|
|
30
27
|
* Conditional formatting highlights:
|
|
31
28
|
* - Bad links (non-zero count)
|
|
@@ -69,11 +66,8 @@ const log = pLog.extend('PageList');
|
|
|
69
66
|
*/
|
|
70
67
|
export function createPageList(options) {
|
|
71
68
|
const urls = options?.urls;
|
|
72
|
-
return (
|
|
69
|
+
return (accessor) => {
|
|
73
70
|
let maxDepth = 0;
|
|
74
|
-
const reportPageData = reports
|
|
75
|
-
.map((r) => (r.pageData ? { name: r.name, pageData: r.pageData } : null))
|
|
76
|
-
.filter(nonNullFilter);
|
|
77
71
|
return {
|
|
78
72
|
name: 'Page List',
|
|
79
73
|
requiresReadModel: true,
|
|
@@ -142,11 +136,6 @@ export function createPageList(options) {
|
|
|
142
136
|
'scroll_height_desktop',
|
|
143
137
|
'scroll_height_mobile',
|
|
144
138
|
];
|
|
145
|
-
for (const report of reports) {
|
|
146
|
-
if (report.pageData) {
|
|
147
|
-
headers.push(...Object.values(report.pageData.headers));
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
139
|
return headers;
|
|
151
140
|
},
|
|
152
141
|
estimateRowCount() {
|
|
@@ -280,46 +269,6 @@ export function createPageList(options) {
|
|
|
280
269
|
createCellData({ value: dash(item.scrollHeightDesktop) }, defaultCellFormat),
|
|
281
270
|
createCellData({ value: dash(item.scrollHeightMobile) }, defaultCellFormat),
|
|
282
271
|
];
|
|
283
|
-
for (const report of reportPageData) {
|
|
284
|
-
const tableData = report.pageData.data[item.url];
|
|
285
|
-
const options = report.pageData.options
|
|
286
|
-
? report.pageData.options[item.url]
|
|
287
|
-
: null;
|
|
288
|
-
if (!tableData) {
|
|
289
|
-
reportLog("%s did'nt have table of %s", report.name, item.url);
|
|
290
|
-
continue;
|
|
291
|
-
}
|
|
292
|
-
reportLog('Add %s to table from %s', item.url, report.name);
|
|
293
|
-
data.push(...Object.keys(report.pageData.headers).map((key) => {
|
|
294
|
-
const option = options ? options[key] || null : null;
|
|
295
|
-
const cellData = tableData[key];
|
|
296
|
-
const format = {};
|
|
297
|
-
let note;
|
|
298
|
-
if (option) {
|
|
299
|
-
if (option.bold) {
|
|
300
|
-
format.bold = !!option.bold;
|
|
301
|
-
}
|
|
302
|
-
if (option.fontFamily != null) {
|
|
303
|
-
format.fontFamily = `${option.fontFamily}`;
|
|
304
|
-
}
|
|
305
|
-
if (option.fontSize != null) {
|
|
306
|
-
format.fontSize = +option.fontSize;
|
|
307
|
-
}
|
|
308
|
-
if (option.italic != null) {
|
|
309
|
-
format.italic = !!option.italic;
|
|
310
|
-
}
|
|
311
|
-
if (option.strike != null) {
|
|
312
|
-
format.strikethrough = !!option.strike;
|
|
313
|
-
}
|
|
314
|
-
if (option.underline != null) {
|
|
315
|
-
format.underline = !!option.underline;
|
|
316
|
-
}
|
|
317
|
-
note = truncateNoteText(cellData?.note || `${option.note || ''}`);
|
|
318
|
-
}
|
|
319
|
-
const value = cellData?.value;
|
|
320
|
-
return createCellData({ value, textFormat: format, note, ifNull: false }, defaultCellFormat);
|
|
321
|
-
}));
|
|
322
|
-
}
|
|
323
272
|
await sheet.appendRow(data);
|
|
324
273
|
sent++;
|
|
325
274
|
onProgress(sent, total);
|
|
@@ -18,7 +18,6 @@ import type { CreateSheet } from '../sheets/types.js';
|
|
|
18
18
|
* resolution) is still shown as a note on the "Link (To)" cell whenever it
|
|
19
19
|
* differs from the resolved destination, and the `Count` column reports how
|
|
20
20
|
* many raw anchor occurrences this edge summarizes.
|
|
21
|
-
* @param _reports
|
|
22
21
|
* @param accessor
|
|
23
22
|
*/
|
|
24
23
|
export declare const createReferrersRelationalTable: CreateSheet;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { streamAnchorFactEdges } from '@nitpicker/query';
|
|
2
|
-
import {
|
|
2
|
+
import { sheetLog } from '../debug.js';
|
|
3
3
|
import { createCellData } from '../sheets/create-cell-data.js';
|
|
4
4
|
import { defaultCellFormat } from '../sheets/default-cell-format.js';
|
|
5
5
|
import { booleanFormatError } from '../sheets/format.js';
|
|
6
|
-
const log =
|
|
6
|
+
const log = sheetLog.extend('ReferrersRelationalTable');
|
|
7
7
|
/**
|
|
8
8
|
* Creates the "Referrers Relational Table" sheet configuration.
|
|
9
9
|
*
|
|
@@ -23,10 +23,9 @@ const log = pLog.extend('ReferrersRelationalTable');
|
|
|
23
23
|
* resolution) is still shown as a note on the "Link (To)" cell whenever it
|
|
24
24
|
* differs from the resolved destination, and the `Count` column reports how
|
|
25
25
|
* many raw anchor occurrences this edge summarizes.
|
|
26
|
-
* @param _reports
|
|
27
26
|
* @param accessor
|
|
28
27
|
*/
|
|
29
|
-
export const createReferrersRelationalTable = (
|
|
28
|
+
export const createReferrersRelationalTable = (accessor) => {
|
|
30
29
|
return {
|
|
31
30
|
name: 'Referrers Relational Table',
|
|
32
31
|
requiresReadModel: true,
|
|
@@ -15,7 +15,6 @@ import type { CreateSheet } from '../sheets/types.js';
|
|
|
15
15
|
* model), the same table `resource.getReferrers()` ultimately queried
|
|
16
16
|
* pre-rewrite — this sheet replaces that per-resource N+1 query pattern
|
|
17
17
|
* with one streamed scan.
|
|
18
|
-
* @param _reports
|
|
19
18
|
* @param accessor
|
|
20
19
|
*/
|
|
21
20
|
export declare const createResourcesRelationalTable: CreateSheet;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { streamResourceReferrerEdges } from '@nitpicker/query';
|
|
2
|
-
import {
|
|
2
|
+
import { sheetLog } from '../debug.js';
|
|
3
3
|
import { createCellData } from '../sheets/create-cell-data.js';
|
|
4
4
|
import { defaultCellFormat } from '../sheets/default-cell-format.js';
|
|
5
5
|
import { booleanFormatError } from '../sheets/format.js';
|
|
6
|
-
const log =
|
|
6
|
+
const log = sheetLog.extend('ResourcesRelationalTable');
|
|
7
7
|
/**
|
|
8
8
|
* Creates the "Resources Relational Table" sheet configuration.
|
|
9
9
|
*
|
|
@@ -20,10 +20,9 @@ const log = pLog.extend('ResourcesRelationalTable');
|
|
|
20
20
|
* model), the same table `resource.getReferrers()` ultimately queried
|
|
21
21
|
* pre-rewrite — this sheet replaces that per-resource N+1 query pattern
|
|
22
22
|
* with one streamed scan.
|
|
23
|
-
* @param _reports
|
|
24
23
|
* @param accessor
|
|
25
24
|
*/
|
|
26
|
-
export const createResourcesRelationalTable = (
|
|
25
|
+
export const createResourcesRelationalTable = (accessor) => {
|
|
27
26
|
return {
|
|
28
27
|
name: 'Resources Relational Table',
|
|
29
28
|
createHeaders() {
|
|
@@ -105,7 +105,7 @@ async function countResourceGroups(accessor) {
|
|
|
105
105
|
*/
|
|
106
106
|
export function createResources(options) {
|
|
107
107
|
const dedupe = options?.dedupe === true;
|
|
108
|
-
return (
|
|
108
|
+
return (accessor) => {
|
|
109
109
|
if (!dedupe) {
|
|
110
110
|
return {
|
|
111
111
|
name: 'Resources',
|
package/lib/debug.d.ts
CHANGED
package/lib/debug.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ArchiveAccessor } from '@nitpicker/
|
|
1
|
+
import type { ArchiveAccessor } from '@nitpicker/archive/archive-accessor';
|
|
2
2
|
/**
|
|
3
3
|
* Result of opening an archive for reporting.
|
|
4
4
|
*
|
|
@@ -15,7 +15,7 @@ export interface ReportArchiveHandle extends AsyncDisposable {
|
|
|
15
15
|
/**
|
|
16
16
|
* Opens a `.nitpicker` archive for reporting, via `@nitpicker/query`'s
|
|
17
17
|
* `ArchiveManager` (the same tar-extraction cache `viewer`/`query` CLI use)
|
|
18
|
-
* instead of `@nitpicker/
|
|
18
|
+
* instead of `@nitpicker/archive`'s `Archive.open` — report used to
|
|
19
19
|
* re-extract the full tar on every run; `ArchiveManager` reuses the cache
|
|
20
20
|
* across runs and returns a read-only `ArchiveAccessor`, matching report's
|
|
21
21
|
* actual access pattern (it never writes back to the archive).
|
|
@@ -3,7 +3,7 @@ import { archiveLog } from './debug.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Opens a `.nitpicker` archive for reporting, via `@nitpicker/query`'s
|
|
5
5
|
* `ArchiveManager` (the same tar-extraction cache `viewer`/`query` CLI use)
|
|
6
|
-
* instead of `@nitpicker/
|
|
6
|
+
* instead of `@nitpicker/archive`'s `Archive.open` — report used to
|
|
7
7
|
* re-extract the full tar on every run; `ArchiveManager` reuses the cache
|
|
8
8
|
* across runs and returns a read-only `ArchiveAccessor`, matching report's
|
|
9
9
|
* actual access pattern (it never writes back to the archive).
|
package/lib/report.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* tables last since their row counts (one row per edge, not per page) are
|
|
7
7
|
* the most likely to explode past the Google Sheets 10M-cell limit.
|
|
8
8
|
*/
|
|
9
|
-
export declare const SHEET_PRIORITY_ORDER: readonly ["Page List", "Links", "
|
|
9
|
+
export declare const SHEET_PRIORITY_ORDER: readonly ["Page List", "Links", "Resources", "Images", "Referrers Relational Table", "Resources Relational Table", "Summary"];
|
|
10
10
|
export type SheetName = (typeof SHEET_PRIORITY_ORDER)[number];
|
|
11
11
|
/**
|
|
12
12
|
* Parameters for {@link report}.
|
|
@@ -31,8 +31,6 @@ export interface ReportParams {
|
|
|
31
31
|
* `./credentials.json` fallback before calling here.
|
|
32
32
|
*/
|
|
33
33
|
readonly credentialFilePath?: string;
|
|
34
|
-
/** Path to the nitpicker config file, or `null` for defaults. */
|
|
35
|
-
readonly configPath: string | null;
|
|
36
34
|
/** When `true`, generate all sheets without interactive prompt. */
|
|
37
35
|
readonly all?: boolean;
|
|
38
36
|
/** When `true`, suppress progress display output. */
|
|
@@ -53,8 +51,8 @@ export interface ReportParams {
|
|
|
53
51
|
/**
|
|
54
52
|
* Restricts generation to pages matching these URLs (raw, pre-normalization —
|
|
55
53
|
* normalized internally against the archive's `disableQueries` config via
|
|
56
|
-
* `resolveAndValidatePageListUrlFilter`). When set, only the
|
|
57
|
-
* rows are one-per-page (`Page List`, `Links`, `
|
|
54
|
+
* `resolveAndValidatePageListUrlFilter`). When set, only the three sheets whose
|
|
55
|
+
* rows are one-per-page (`Page List`, `Links`, `Images`) are
|
|
58
56
|
* eligible for generation — see {@link URL_FILTERABLE_SHEETS}'s docs for why
|
|
59
57
|
* the rest are excluded. An empty array is rejected by
|
|
60
58
|
* `resolveAndValidatePageListUrlFilter` rather than silently falling back to
|
|
@@ -92,10 +90,9 @@ export interface ReportParams {
|
|
|
92
90
|
* 1. Authenticates with Google Sheets API using OAuth2 credentials.
|
|
93
91
|
* 2. Opens the `.nitpicker` archive (read-only, via `openReportArchive` —
|
|
94
92
|
* see that function's docs for why this replaced `Archive.open`).
|
|
95
|
-
* 3.
|
|
96
|
-
* 4. Presents an interactive multi-select prompt for the user to
|
|
93
|
+
* 3. Presents an interactive multi-select prompt for the user to
|
|
97
94
|
* choose which sheets to generate.
|
|
98
|
-
*
|
|
95
|
+
* 4. Delegates to `createSheets()` for cell-budget-aware, priority-ordered
|
|
99
96
|
* data generation and upload, including its `TaskList` progress display
|
|
100
97
|
* and Google Sheets API rate-limit (429/403/5xx/ECONNRESET) backoff
|
|
101
98
|
* display — see `create-sheets.ts`'s docs.
|
|
@@ -112,7 +109,6 @@ export interface ReportParams {
|
|
|
112
109
|
* filePath: './output.nitpicker',
|
|
113
110
|
* sheetUrl: 'https://docs.google.com/spreadsheets/d/xxx/edit',
|
|
114
111
|
* credentialFilePath: './credentials.json',
|
|
115
|
-
* configPath: './nitpicker.config.json',
|
|
116
112
|
* });
|
|
117
113
|
* ```
|
|
118
114
|
* @example
|
|
@@ -121,7 +117,6 @@ export interface ReportParams {
|
|
|
121
117
|
* await report({
|
|
122
118
|
* filePath: './output.nitpicker',
|
|
123
119
|
* sheetUrl: 'https://docs.google.com/spreadsheets/d/xxx/edit',
|
|
124
|
-
* configPath: null,
|
|
125
120
|
* });
|
|
126
121
|
* ```
|
|
127
122
|
* @example
|
|
@@ -131,7 +126,6 @@ export interface ReportParams {
|
|
|
131
126
|
* filePath: './output.nitpicker',
|
|
132
127
|
* sheetUrl: 'https://docs.google.com/spreadsheets/d/xxx/edit',
|
|
133
128
|
* credentialFilePath: './credentials.json',
|
|
134
|
-
* configPath: null,
|
|
135
129
|
* sheets: ['Page List', 'Links'],
|
|
136
130
|
* });
|
|
137
131
|
* ```
|
package/lib/report.js
CHANGED
|
@@ -2,19 +2,15 @@ import { authentication } from '@d-zero/google-auth';
|
|
|
2
2
|
import { Sheets } from '@d-zero/google-sheets';
|
|
3
3
|
import { resolveAndValidatePageListUrlFilter, warnUnmatchedPageListUrls, } from '@nitpicker/query';
|
|
4
4
|
import enquirer from 'enquirer';
|
|
5
|
-
import { createDiscrepancies } from './data/create-discrepancies.js';
|
|
6
5
|
import { createImageList } from './data/create-image-list.js';
|
|
7
6
|
import { createLinks } from './data/create-links.js';
|
|
8
7
|
import { createPageList } from './data/create-page-list.js';
|
|
9
8
|
import { createReferrersRelationalTable } from './data/create-referrers-relational-table.js';
|
|
10
9
|
import { createResourcesRelationalTable } from './data/create-resources-relational-table.js';
|
|
11
10
|
import { createResources } from './data/create-resources.js';
|
|
12
|
-
import { createViolations } from './data/create-violations.js';
|
|
13
11
|
import { log } from './debug.js';
|
|
14
12
|
import { isDriveFolderUrl } from './is-drive-folder-url.js';
|
|
15
|
-
import { loadConfig } from './load-config.js';
|
|
16
13
|
import { openReportArchive } from './open-report-archive.js';
|
|
17
|
-
import { getPluginReports } from './reports/get-plugin-reports.js';
|
|
18
14
|
import { resolveSpreadsheetUrl } from './resolve-spreadsheet-url.js';
|
|
19
15
|
import { createSheets } from './sheets/create-sheets.js';
|
|
20
16
|
/**
|
|
@@ -28,8 +24,6 @@ import { createSheets } from './sheets/create-sheets.js';
|
|
|
28
24
|
export const SHEET_PRIORITY_ORDER = [
|
|
29
25
|
'Page List',
|
|
30
26
|
'Links',
|
|
31
|
-
'Violations',
|
|
32
|
-
'Discrepancies',
|
|
33
27
|
'Resources',
|
|
34
28
|
'Images',
|
|
35
29
|
'Referrers Relational Table',
|
|
@@ -42,9 +36,6 @@ export const SHEET_PRIORITY_ORDER = [
|
|
|
42
36
|
* unambiguous meaning. The rest are excluded from both `--all` and the
|
|
43
37
|
* interactive picker when `--urls` is given:
|
|
44
38
|
*
|
|
45
|
-
* - `Discrepancies` compares two URLs per row (`leftSourceUrl`/
|
|
46
|
-
* `rightSourceUrl`) — which side matching `--urls` should keep is
|
|
47
|
-
* undefined.
|
|
48
39
|
* - `Resources` / `Resources Relational Table` are many-to-many with pages
|
|
49
40
|
* (one resource can be referenced by many pages), and the dedupe-mode
|
|
50
41
|
* aggregation is precomputed at `viewer-build` time across the whole
|
|
@@ -55,12 +46,7 @@ export const SHEET_PRIORITY_ORDER = [
|
|
|
55
46
|
* "restrict to these pages" means.
|
|
56
47
|
* - `Summary` has no generator at all (see the `switch` below).
|
|
57
48
|
*/
|
|
58
|
-
const URL_FILTERABLE_SHEETS = [
|
|
59
|
-
'Page List',
|
|
60
|
-
'Links',
|
|
61
|
-
'Violations',
|
|
62
|
-
'Images',
|
|
63
|
-
];
|
|
49
|
+
const URL_FILTERABLE_SHEETS = ['Page List', 'Links', 'Images'];
|
|
64
50
|
/**
|
|
65
51
|
* Generates a Google Sheets report from a `.nitpicker` archive file.
|
|
66
52
|
*
|
|
@@ -70,10 +56,9 @@ const URL_FILTERABLE_SHEETS = [
|
|
|
70
56
|
* 1. Authenticates with Google Sheets API using OAuth2 credentials.
|
|
71
57
|
* 2. Opens the `.nitpicker` archive (read-only, via `openReportArchive` —
|
|
72
58
|
* see that function's docs for why this replaced `Archive.open`).
|
|
73
|
-
* 3.
|
|
74
|
-
* 4. Presents an interactive multi-select prompt for the user to
|
|
59
|
+
* 3. Presents an interactive multi-select prompt for the user to
|
|
75
60
|
* choose which sheets to generate.
|
|
76
|
-
*
|
|
61
|
+
* 4. Delegates to `createSheets()` for cell-budget-aware, priority-ordered
|
|
77
62
|
* data generation and upload, including its `TaskList` progress display
|
|
78
63
|
* and Google Sheets API rate-limit (429/403/5xx/ECONNRESET) backoff
|
|
79
64
|
* display — see `create-sheets.ts`'s docs.
|
|
@@ -90,7 +75,6 @@ const URL_FILTERABLE_SHEETS = [
|
|
|
90
75
|
* filePath: './output.nitpicker',
|
|
91
76
|
* sheetUrl: 'https://docs.google.com/spreadsheets/d/xxx/edit',
|
|
92
77
|
* credentialFilePath: './credentials.json',
|
|
93
|
-
* configPath: './nitpicker.config.json',
|
|
94
78
|
* });
|
|
95
79
|
* ```
|
|
96
80
|
* @example
|
|
@@ -99,7 +83,6 @@ const URL_FILTERABLE_SHEETS = [
|
|
|
99
83
|
* await report({
|
|
100
84
|
* filePath: './output.nitpicker',
|
|
101
85
|
* sheetUrl: 'https://docs.google.com/spreadsheets/d/xxx/edit',
|
|
102
|
-
* configPath: null,
|
|
103
86
|
* });
|
|
104
87
|
* ```
|
|
105
88
|
* @example
|
|
@@ -109,13 +92,12 @@ const URL_FILTERABLE_SHEETS = [
|
|
|
109
92
|
* filePath: './output.nitpicker',
|
|
110
93
|
* sheetUrl: 'https://docs.google.com/spreadsheets/d/xxx/edit',
|
|
111
94
|
* credentialFilePath: './credentials.json',
|
|
112
|
-
* configPath: null,
|
|
113
95
|
* sheets: ['Page List', 'Links'],
|
|
114
96
|
* });
|
|
115
97
|
* ```
|
|
116
98
|
*/
|
|
117
99
|
export async function report(params) {
|
|
118
|
-
const { filePath, sheetUrl, credentialFilePath,
|
|
100
|
+
const { filePath, sheetUrl, credentialFilePath, all, silent, dedupeResources, onExtractProgress, } = params;
|
|
119
101
|
log('Initialization');
|
|
120
102
|
const warnings = [];
|
|
121
103
|
// The Drive scope is requested only when a Spreadsheet has to be created, so
|
|
@@ -144,16 +126,6 @@ export async function report(params) {
|
|
|
144
126
|
const normalizedUrls = params.urls === undefined
|
|
145
127
|
? undefined
|
|
146
128
|
: await resolveAndValidatePageListUrlFilter(accessor, params.urls, collectWarning);
|
|
147
|
-
log('Loading config');
|
|
148
|
-
const config = await loadConfig(configPath);
|
|
149
|
-
log('Config loaded');
|
|
150
|
-
const plugins = config.plugins?.analyze
|
|
151
|
-
? Object.keys(config.plugins.analyze)
|
|
152
|
-
: undefined;
|
|
153
|
-
log('Loaded plugins: %O', plugins);
|
|
154
|
-
log('Loading plugin reports');
|
|
155
|
-
const reports = await getPluginReports(accessor);
|
|
156
|
-
log('Plugin reports loaded: %d', reports.length);
|
|
157
129
|
const availableSheetNames = normalizedUrls === undefined ? SHEET_PRIORITY_ORDER : URL_FILTERABLE_SHEETS;
|
|
158
130
|
if (normalizedUrls !== undefined) {
|
|
159
131
|
const excluded = SHEET_PRIORITY_ORDER.filter((name) => !URL_FILTERABLE_SHEETS.includes(name));
|
|
@@ -209,14 +181,6 @@ export async function report(params) {
|
|
|
209
181
|
createSheetList.push(createLinks({ urls: normalizedUrls }));
|
|
210
182
|
break;
|
|
211
183
|
}
|
|
212
|
-
case 'Violations': {
|
|
213
|
-
createSheetList.push(createViolations({ urls: normalizedUrls }));
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
case 'Discrepancies': {
|
|
217
|
-
createSheetList.push(createDiscrepancies);
|
|
218
|
-
break;
|
|
219
|
-
}
|
|
220
184
|
case 'Resources': {
|
|
221
185
|
createSheetList.push(createResources({ dedupe: dedupeResources }));
|
|
222
186
|
break;
|
|
@@ -243,7 +207,7 @@ export async function report(params) {
|
|
|
243
207
|
}
|
|
244
208
|
}
|
|
245
209
|
}
|
|
246
|
-
// Created only now — after archive/
|
|
210
|
+
// Created only now — after archive/selection errors and prompt
|
|
247
211
|
// cancellation can no longer happen — so a failed or aborted run does not
|
|
248
212
|
// leave an empty Spreadsheet behind in the Drive folder.
|
|
249
213
|
const targetUrl = await resolveSpreadsheetUrl({
|
|
@@ -267,7 +231,6 @@ export async function report(params) {
|
|
|
267
231
|
await createSheets({
|
|
268
232
|
sheets,
|
|
269
233
|
accessor,
|
|
270
|
-
reports,
|
|
271
234
|
createSheetList,
|
|
272
235
|
options: {
|
|
273
236
|
onWarn: (message) => warnings.push(message),
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { CreateSheet } from './types.js';
|
|
2
2
|
import type { Sheets } from '@d-zero/google-sheets';
|
|
3
|
-
import type { ArchiveAccessor } from '@nitpicker/
|
|
4
|
-
import type { Report } from '@nitpicker/types';
|
|
3
|
+
import type { ArchiveAccessor } from '@nitpicker/archive/archive-accessor';
|
|
5
4
|
/**
|
|
6
5
|
* Parameters for {@link createSheets}.
|
|
7
6
|
*/
|
|
@@ -10,8 +9,6 @@ export interface CreateSheetsParams {
|
|
|
10
9
|
readonly sheets: Sheets;
|
|
11
10
|
/** アーカイブへの read-only アクセサ */
|
|
12
11
|
readonly accessor: ArchiveAccessor;
|
|
13
|
-
/** 監査プラグインのレポート配列 */
|
|
14
|
-
readonly reports: Report[];
|
|
15
12
|
/**
|
|
16
13
|
* シート設定のファクトリ関数配列。**配列の順序がそのままセル予算の優先順位になる**
|
|
17
14
|
* — 呼び出し元(`report.ts`)がユーザー選択をこの優先順位で並べ替えてから渡す。
|
|
@@ -86,14 +86,14 @@ const NULL_STREAM = {
|
|
|
86
86
|
* @param params - シート作成に必要なパラメータ
|
|
87
87
|
*/
|
|
88
88
|
export async function createSheets(params) {
|
|
89
|
-
const { sheets, accessor,
|
|
89
|
+
const { sheets, accessor, createSheetList, options } = params;
|
|
90
90
|
if (!createSheetList) {
|
|
91
91
|
sheetLog('createSheetList is empty');
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
94
94
|
const onWarn = options?.onWarn;
|
|
95
95
|
sheetLog('Initializing %d sheet setting(s)', createSheetList.length);
|
|
96
|
-
const settings = await Promise.all(createSheetList.map((createSheet) => createSheet(
|
|
96
|
+
const settings = await Promise.all(createSheetList.map((createSheet) => createSheet(accessor)));
|
|
97
97
|
sheetLog('Sheet settings initialized: %O', settings.map((s) => s.name));
|
|
98
98
|
if (settings.length === 0) {
|
|
99
99
|
sheetLog('No sheets selected');
|
package/lib/sheets/types.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Sheet } from '@d-zero/google-sheets';
|
|
2
|
-
import type { ArchiveAccessor } from '@nitpicker/
|
|
3
|
-
import type { Report } from '@nitpicker/types';
|
|
2
|
+
import type { ArchiveAccessor } from '@nitpicker/archive/archive-accessor';
|
|
4
3
|
import type { sheets_v4 } from 'googleapis';
|
|
5
4
|
/** A value that may be synchronous or wrapped in a Promise. */
|
|
6
5
|
export type Promiseable<T> = Promise<T> | T;
|
|
@@ -74,7 +73,7 @@ export interface CreateSheetSetting {
|
|
|
74
73
|
* `viewer_anchor_facts`, `viewer_images`, etc.) — `report.ts` only calls
|
|
75
74
|
* `requireViewerReadModel` once, up front, when at least one selected
|
|
76
75
|
* sheet sets this. Sheets that read only write-model tables (Links,
|
|
77
|
-
* Resources
|
|
76
|
+
* Resources) must leave this `false`/omitted so a report
|
|
78
77
|
* limited to those sheets never requires a `viewer-build` run. Defaults
|
|
79
78
|
* to `false`.
|
|
80
79
|
*/
|
|
@@ -106,12 +105,11 @@ export interface CreateSheetSetting {
|
|
|
106
105
|
/**
|
|
107
106
|
* Factory function that produces a {@link CreateSheetSetting} for one sheet.
|
|
108
107
|
*
|
|
109
|
-
* Receives the
|
|
110
|
-
*
|
|
111
|
-
* (for `run()`/`estimateRowCount()` to query against).
|
|
108
|
+
* Receives the archive accessor (for `run()`/`estimateRowCount()` to query
|
|
109
|
+
* against).
|
|
112
110
|
* @example
|
|
113
111
|
* ```ts
|
|
114
|
-
* const createMySheet: CreateSheet = (
|
|
112
|
+
* const createMySheet: CreateSheet = (accessor) => ({
|
|
115
113
|
* name: 'My Sheet',
|
|
116
114
|
* createHeaders: () => ['URL', 'Title'],
|
|
117
115
|
* estimateRowCount: async () => (await listViewerPages(accessor, { limit: 1 })).total,
|
|
@@ -137,4 +135,4 @@ export interface CreateSheetSetting {
|
|
|
137
135
|
* });
|
|
138
136
|
* ```
|
|
139
137
|
*/
|
|
140
|
-
export type CreateSheet = (
|
|
138
|
+
export type CreateSheet = (accessor: ArchiveAccessor) => Promiseable<CreateSheetSetting>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Truncates an arbitrary, already-built note string to `maxLength`,
|
|
3
3
|
* appending a truncation marker when truncation actually happens. Sibling
|
|
4
4
|
* to {@link joinUrlsForNote} for note content that isn't a list of URLs (a
|
|
5
|
-
* page title, a JSON blob
|
|
5
|
+
* page title, a JSON blob) — both share
|
|
6
6
|
* the same {@link NOTE_MAX_LENGTH} ceiling so every note this package
|
|
7
7
|
* writes stays under `Cell.provide()`'s hard cut (see `NOTE_MAX_LENGTH`'s
|
|
8
8
|
* docs).
|
|
@@ -3,7 +3,7 @@ import { NOTE_MAX_LENGTH } from './join-urls-for-note.js';
|
|
|
3
3
|
* Truncates an arbitrary, already-built note string to `maxLength`,
|
|
4
4
|
* appending a truncation marker when truncation actually happens. Sibling
|
|
5
5
|
* to {@link joinUrlsForNote} for note content that isn't a list of URLs (a
|
|
6
|
-
* page title, a JSON blob
|
|
6
|
+
* page title, a JSON blob) — both share
|
|
7
7
|
* the same {@link NOTE_MAX_LENGTH} ceiling so every note this package
|
|
8
8
|
* writes stays under `Cell.provide()`'s hard cut (see `NOTE_MAX_LENGTH`'s
|
|
9
9
|
* docs).
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nitpicker/report-google-sheets",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Nitpicker reporter that outputs crawl
|
|
3
|
+
"version": "0.25.0",
|
|
4
|
+
"description": "Nitpicker reporter that outputs crawl results to Google Sheets",
|
|
5
5
|
"author": "D-ZERO",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"engines": {
|
|
@@ -32,19 +32,19 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@d-zero/dealer": "1.14.0",
|
|
34
34
|
"@d-zero/google-auth": "0.7.6",
|
|
35
|
-
"@d-zero/google-sheets": "0.12.
|
|
35
|
+
"@d-zero/google-sheets": "0.12.1",
|
|
36
36
|
"@d-zero/shared": "0.23.0",
|
|
37
|
-
"@nitpicker/
|
|
38
|
-
"@nitpicker/query": "0.
|
|
39
|
-
"@nitpicker/types": "0.23.0",
|
|
37
|
+
"@nitpicker/archive": "0.25.0",
|
|
38
|
+
"@nitpicker/query": "0.25.0",
|
|
40
39
|
"ansi-colors": "4.1.3",
|
|
41
40
|
"debug": "4.4.3",
|
|
42
41
|
"enquirer": "2.4.1"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
44
|
+
"@nitpicker/crawler": "0.25.0",
|
|
45
45
|
"@types/debug": "4.1.13",
|
|
46
46
|
"googleapis": "173.0.0",
|
|
47
|
-
"vitest": "5.0.
|
|
47
|
+
"vitest": "5.0.5"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "fb258acf112366504c6dbb44b69a25bbc528fa30"
|
|
50
50
|
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { CreateSheet } from '../sheets/types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Creates the "Discrepancies" sheet configuration.
|
|
4
|
-
*
|
|
5
|
-
* Lists cross-page discrepancies produced by analyze plugins (e.g. meta tag
|
|
6
|
-
* consistency checks).
|
|
7
|
-
*
|
|
8
|
-
* The pre-rewrite version also compared every anchor's `textContent`
|
|
9
|
-
* against its `title` attribute (a "Link Text vs Page Title" check, despite
|
|
10
|
-
* the label — it never actually compared to the destination page's
|
|
11
|
-
* `<title>`). That check is dropped: an anchor's `title` attribute is not
|
|
12
|
-
* stored anywhere in the 0.13 write model or the viewer read model (only
|
|
13
|
-
* `anchor_edges.first_text_id`/`viewer_anchor_facts.first_text_id`, the
|
|
14
|
-
* `textContent`, survive), so there is no data left to compare against.
|
|
15
|
-
* @param reports - Analyze plugin reports to extract discrepancy data from.
|
|
16
|
-
*/
|
|
17
|
-
export declare const createDiscrepancies: CreateSheet;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { pLog } from '../debug.js';
|
|
2
|
-
import { createCellData } from '../sheets/create-cell-data.js';
|
|
3
|
-
import { defaultCellFormat } from '../sheets/default-cell-format.js';
|
|
4
|
-
const log = pLog.extend('Discrepancies');
|
|
5
|
-
/**
|
|
6
|
-
* Creates the "Discrepancies" sheet configuration.
|
|
7
|
-
*
|
|
8
|
-
* Lists cross-page discrepancies produced by analyze plugins (e.g. meta tag
|
|
9
|
-
* consistency checks).
|
|
10
|
-
*
|
|
11
|
-
* The pre-rewrite version also compared every anchor's `textContent`
|
|
12
|
-
* against its `title` attribute (a "Link Text vs Page Title" check, despite
|
|
13
|
-
* the label — it never actually compared to the destination page's
|
|
14
|
-
* `<title>`). That check is dropped: an anchor's `title` attribute is not
|
|
15
|
-
* stored anywhere in the 0.13 write model or the viewer read model (only
|
|
16
|
-
* `anchor_edges.first_text_id`/`viewer_anchor_facts.first_text_id`, the
|
|
17
|
-
* `textContent`, survive), so there is no data left to compare against.
|
|
18
|
-
* @param reports - Analyze plugin reports to extract discrepancy data from.
|
|
19
|
-
*/
|
|
20
|
-
export const createDiscrepancies = (reports) => {
|
|
21
|
-
return {
|
|
22
|
-
name: 'Discrepancies',
|
|
23
|
-
createHeaders() {
|
|
24
|
-
return ['Type', 'Left URL', 'Left', 'Right', 'Right URL', 'Note'];
|
|
25
|
-
},
|
|
26
|
-
estimateRowCount() {
|
|
27
|
-
let count = 0;
|
|
28
|
-
for (const report of reports) {
|
|
29
|
-
count += report.discrepancies?.length ?? 0;
|
|
30
|
-
}
|
|
31
|
-
return count;
|
|
32
|
-
},
|
|
33
|
-
async run({ sheet, maxRows, onProgress }) {
|
|
34
|
-
let sent = 0;
|
|
35
|
-
const total = reports.reduce((sum, r) => sum + (r.discrepancies?.length ?? 0), 0);
|
|
36
|
-
for (const report of reports) {
|
|
37
|
-
if (!report.discrepancies) {
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
log('From %s', report.name);
|
|
41
|
-
for (const discrepancy of report.discrepancies) {
|
|
42
|
-
if (sent >= maxRows) {
|
|
43
|
-
await sheet.flush();
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
await sheet.appendRow([
|
|
47
|
-
createCellData({ value: report.name }, defaultCellFormat),
|
|
48
|
-
createCellData({ value: discrepancy.leftSourceUrl, note: discrepancy.leftSourceUrlNote }, defaultCellFormat),
|
|
49
|
-
createCellData({ value: discrepancy.left, note: discrepancy.leftNote }, defaultCellFormat),
|
|
50
|
-
createCellData({ value: discrepancy.right, note: discrepancy.rightNote }, defaultCellFormat),
|
|
51
|
-
createCellData({ value: discrepancy.rightSourceUrl, note: discrepancy.rightSourceUrlNote }, defaultCellFormat),
|
|
52
|
-
createCellData({ value: discrepancy.note }, defaultCellFormat),
|
|
53
|
-
]);
|
|
54
|
-
sent++;
|
|
55
|
-
onProgress(sent, total);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
await sheet.flush();
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { CreateSheet } from '../sheets/types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Creates the "Violations" sheet configuration.
|
|
4
|
-
*
|
|
5
|
-
* Streams `streamAllViolations` — a plain `analysis_violations.id` keyset
|
|
6
|
-
* pass, unlike the pre-rewrite version, which pre-loaded every violation
|
|
7
|
-
* into a `Report.violations` array before generation started (via
|
|
8
|
-
* `getPluginReports`). No read-model dependency: `analysis_violations` is a
|
|
9
|
-
* write-model table.
|
|
10
|
-
* `options.urls` (already normalized via `resolvePageListUrlFilter`)
|
|
11
|
-
* restricts both `estimateRowCount` and `run` to violations reported
|
|
12
|
-
* against exactly those pages.
|
|
13
|
-
* @param options - Row-set restriction. Omitted or `urls: undefined` reports every violation.
|
|
14
|
-
* @param options.urls - See above.
|
|
15
|
-
* @returns A {@link CreateSheet} factory for the Violations sheet.
|
|
16
|
-
*/
|
|
17
|
-
export declare function createViolations(options?: {
|
|
18
|
-
urls?: readonly string[];
|
|
19
|
-
}): CreateSheet;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { applyEqualityOrInFilter, streamAllViolations } from '@nitpicker/query';
|
|
2
|
-
import { createCellData } from '../sheets/create-cell-data.js';
|
|
3
|
-
import { defaultCellFormat } from '../sheets/default-cell-format.js';
|
|
4
|
-
/**
|
|
5
|
-
* Counts every `analysis_violations` row, for `estimateRowCount()`.
|
|
6
|
-
* @param accessor - The archive accessor to query.
|
|
7
|
-
* @param urls - Exact-match URL allowlist, already normalized. Omitted or empty counts every row.
|
|
8
|
-
*/
|
|
9
|
-
async function countViolations(accessor, urls) {
|
|
10
|
-
const knex = accessor.getKnex();
|
|
11
|
-
const [row] = await knex('analysis_violations as v')
|
|
12
|
-
.join('content_items as p', 'p.id', 'v.page_id')
|
|
13
|
-
.join('url_refs as ur', 'ur.id', 'p.url_id')
|
|
14
|
-
.modify((qb) => applyEqualityOrInFilter(qb, 'ur.url', urls))
|
|
15
|
-
.count({ count: '*' });
|
|
16
|
-
return Number(row?.count ?? 0);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Creates the "Violations" sheet configuration.
|
|
20
|
-
*
|
|
21
|
-
* Streams `streamAllViolations` — a plain `analysis_violations.id` keyset
|
|
22
|
-
* pass, unlike the pre-rewrite version, which pre-loaded every violation
|
|
23
|
-
* into a `Report.violations` array before generation started (via
|
|
24
|
-
* `getPluginReports`). No read-model dependency: `analysis_violations` is a
|
|
25
|
-
* write-model table.
|
|
26
|
-
* `options.urls` (already normalized via `resolvePageListUrlFilter`)
|
|
27
|
-
* restricts both `estimateRowCount` and `run` to violations reported
|
|
28
|
-
* against exactly those pages.
|
|
29
|
-
* @param options - Row-set restriction. Omitted or `urls: undefined` reports every violation.
|
|
30
|
-
* @param options.urls - See above.
|
|
31
|
-
* @returns A {@link CreateSheet} factory for the Violations sheet.
|
|
32
|
-
*/
|
|
33
|
-
export function createViolations(options) {
|
|
34
|
-
const urls = options?.urls;
|
|
35
|
-
return (_reports, accessor) => {
|
|
36
|
-
return {
|
|
37
|
-
name: 'Violations',
|
|
38
|
-
createHeaders() {
|
|
39
|
-
return ['Validator', 'Severity', 'Rule', 'Code', 'Message', 'URL'];
|
|
40
|
-
},
|
|
41
|
-
estimateRowCount: () => countViolations(accessor, urls),
|
|
42
|
-
async run({ sheet, maxRows, estimatedTotal, onProgress }) {
|
|
43
|
-
let sent = 0;
|
|
44
|
-
const total = estimatedTotal;
|
|
45
|
-
for await (const chunk of streamAllViolations(accessor, { urls })) {
|
|
46
|
-
for (const violation of chunk) {
|
|
47
|
-
if (sent >= maxRows) {
|
|
48
|
-
await sheet.flush();
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
await sheet.appendRow([
|
|
52
|
-
createCellData({ value: violation.validator }, defaultCellFormat),
|
|
53
|
-
createCellData({ value: violation.severity }, defaultCellFormat),
|
|
54
|
-
createCellData({ value: violation.rule }, defaultCellFormat),
|
|
55
|
-
createCellData({ value: violation.code }, defaultCellFormat),
|
|
56
|
-
createCellData({ value: violation.message }, defaultCellFormat),
|
|
57
|
-
createCellData({ value: violation.url }, defaultCellFormat),
|
|
58
|
-
]);
|
|
59
|
-
sent++;
|
|
60
|
-
onProgress(sent, total);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
await sheet.flush();
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
}
|
package/lib/load-config.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ConfigJSON } from '@nitpicker/types';
|
|
2
|
-
/**
|
|
3
|
-
* Loads a nitpicker configuration JSON file from the given path.
|
|
4
|
-
* Returns an empty object when no path is provided.
|
|
5
|
-
* @param filePath - Absolute or relative path to the configuration file, or `null` to skip loading
|
|
6
|
-
* @returns The parsed configuration object
|
|
7
|
-
*/
|
|
8
|
-
export declare function loadConfig(filePath: string | null): Promise<ConfigJSON>;
|
package/lib/load-config.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
/**
|
|
4
|
-
* Loads a nitpicker configuration JSON file from the given path.
|
|
5
|
-
* Returns an empty object when no path is provided.
|
|
6
|
-
* @param filePath - Absolute or relative path to the configuration file, or `null` to skip loading
|
|
7
|
-
* @returns The parsed configuration object
|
|
8
|
-
*/
|
|
9
|
-
export async function loadConfig(filePath) {
|
|
10
|
-
if (!filePath) {
|
|
11
|
-
return {};
|
|
12
|
-
}
|
|
13
|
-
const absFilePath = path.isAbsolute(filePath) ? filePath : path.resolve(filePath);
|
|
14
|
-
const data = await fs.readFile(absFilePath, { encoding: 'utf8' });
|
|
15
|
-
return JSON.parse(data);
|
|
16
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ArchiveAccessor } from '@nitpicker/crawler';
|
|
2
|
-
import type { Report } from '@nitpicker/types';
|
|
3
|
-
/**
|
|
4
|
-
* Retrieves analyze plugin reports stored in the archive's `analysis/report`
|
|
5
|
-
* namespace file — the `pageData`/`discrepancies` source for the Page List
|
|
6
|
-
* and Discrepancies sheets. Returns an empty array if none is found.
|
|
7
|
-
*
|
|
8
|
-
* Violations are deliberately NOT loaded here (unlike the pre-rewrite
|
|
9
|
-
* version, which pre-fetched every `getViolations` page into a synthetic
|
|
10
|
-
* `{ name: 'violations', violations }` report entry): the Violations sheet
|
|
11
|
-
* now calls `getViolations` directly inside its own `run()`, streaming
|
|
12
|
-
* pages as it sends rows instead of holding the full violation set in
|
|
13
|
-
* memory before the first row goes out.
|
|
14
|
-
* @param accessor - The opened archive to read plugin reports from.
|
|
15
|
-
* @returns An array of plugin report data (0 or 1 entries).
|
|
16
|
-
*/
|
|
17
|
-
export declare function getPluginReports(accessor: ArchiveAccessor): Promise<Report[]>;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { reportLog } from '../debug.js';
|
|
2
|
-
/**
|
|
3
|
-
* Retrieves analyze plugin reports stored in the archive's `analysis/report`
|
|
4
|
-
* namespace file — the `pageData`/`discrepancies` source for the Page List
|
|
5
|
-
* and Discrepancies sheets. Returns an empty array if none is found.
|
|
6
|
-
*
|
|
7
|
-
* Violations are deliberately NOT loaded here (unlike the pre-rewrite
|
|
8
|
-
* version, which pre-fetched every `getViolations` page into a synthetic
|
|
9
|
-
* `{ name: 'violations', violations }` report entry): the Violations sheet
|
|
10
|
-
* now calls `getViolations` directly inside its own `run()`, streaming
|
|
11
|
-
* pages as it sends rows instead of holding the full violation set in
|
|
12
|
-
* memory before the first row goes out.
|
|
13
|
-
* @param accessor - The opened archive to read plugin reports from.
|
|
14
|
-
* @returns An array of plugin report data (0 or 1 entries).
|
|
15
|
-
*/
|
|
16
|
-
export async function getPluginReports(accessor) {
|
|
17
|
-
const reports = [];
|
|
18
|
-
reportLog('Load');
|
|
19
|
-
try {
|
|
20
|
-
const report = await accessor.getData('analysis/report');
|
|
21
|
-
if (report) {
|
|
22
|
-
reports.push(report);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
catch {
|
|
26
|
-
reportLog('Failed: report is not found');
|
|
27
|
-
}
|
|
28
|
-
return reports;
|
|
29
|
-
}
|