@nitpicker/report-google-sheets 0.21.0 → 0.22.1

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.
@@ -1,5 +1,5 @@
1
1
  import { tryParseUrl as parseUrl } from '@d-zero/shared/parse-url';
2
- import { buildRedirectFromUrlsByDestId, countViewerPagesTotal, getOutboundLinkFactsByPageIds, streamPageListRows, } from '@nitpicker/query';
2
+ import { buildRedirectFromUrlsByDestId, countPageListRows, getOutboundLinkFactsByPageIds, streamPageListRows, } from '@nitpicker/query';
3
3
  import { pLog, reportLog } from '../debug.js';
4
4
  import { createCellData } from '../sheets/create-cell-data.js';
5
5
  import { defaultCellFormat } from '../sheets/default-cell-format.js';
@@ -53,356 +53,396 @@ const log = pLog.extend('PageList');
53
53
  * precomputed once, for every page, before the read model is queryable at
54
54
  * all (see `build-viewer-read-model.ts`), so every column is known
55
55
  * synchronously from the current row alone.
56
- * @param reports - Analyze plugin reports to extract per-page data columns from
57
- * @param accessor - The archive accessor to query.
56
+ * ## URL-restricted mode (`--urls`)
57
+ *
58
+ * `options.urls` (already normalized via `resolvePageListUrlFilter`)
59
+ * restricts every read below to exactly those pages — both
60
+ * `estimateRowCount` and `run` go through `countPageListRows`/
61
+ * `streamPageListRows`, the same shared filter (`applyPageListRowFilters`)
62
+ * that guarantees the two never disagree about which pages are in scope.
63
+ * @param options - Row-set restriction. Omitted or `urls: undefined` reports every page.
64
+ * @param options.urls - See "URL-restricted mode" above.
65
+ * @returns A {@link CreateSheet} factory for the Page List sheet.
66
+ * @example
67
+ * createSheetList.push(createPageList());
68
+ * createSheetList.push(createPageList({ urls: ['https://example.com/a'] }));
58
69
  */
59
- export const createPageList = (reports, accessor) => {
60
- let maxDepth = 0;
61
- const reportPageData = reports
62
- .map((r) => (r.pageData ? { name: r.name, pageData: r.pageData } : null))
63
- .filter(nonNullFilter);
64
- return {
65
- name: 'Page List',
66
- requiresReadModel: true,
67
- createHeaders() {
68
- const headers = [
69
- 'Title',
70
- 'Full Title',
71
- 'URL',
72
- 'Protocol',
73
- 'Domain',
74
- 'path1',
75
- 'path2',
76
- 'path3',
77
- 'path4',
78
- 'path5',
79
- 'path6',
80
- 'path7',
81
- 'path8',
82
- 'path9',
83
- 'path10',
84
- 'Status Code',
85
- 'Redirect From',
86
- 'Language',
87
- 'charset',
88
- 'Internal Links',
89
- 'Internal Bad Links',
90
- 'External Links',
91
- 'External Bad Links',
92
- 'Internal Referrers',
93
- 'description',
94
- 'keywords',
95
- 'noindex',
96
- 'nofollow',
97
- 'noarchive',
98
- 'robots:raw',
99
- 'canonical',
100
- 'manifest',
101
- 'theme-color',
102
- 'twitter:card',
103
- 'twitter:site',
104
- 'twitter:creator',
105
- 'og:site_name',
106
- 'og:url',
107
- 'og:title',
108
- 'og:description',
109
- 'og:type',
110
- 'og:image',
111
- 'og:image:alt',
112
- 'og:locale',
113
- 'og:article:published_time',
114
- 'jsonld_count',
115
- 'tags_providers',
116
- 'main_content_selector',
117
- 'main_content_word_count',
118
- 'main_content_body_word_count',
119
- 'main_content_heading_count',
120
- 'main_content_image_count',
121
- 'main_content_table_count',
122
- 'main_content_button_count',
123
- 'main_content_iframe_count',
124
- 'main_content_video_count',
125
- 'main_content_audio_count',
126
- 'main_content_canvas_count',
127
- 'main_content_custom_element_count',
128
- 'scroll_height_desktop',
129
- 'scroll_height_mobile',
130
- ];
131
- for (const report of reports) {
132
- if (report.pageData) {
133
- headers.push(...Object.values(report.pageData.headers));
134
- }
135
- }
136
- return headers;
137
- },
138
- estimateRowCount() {
139
- return countViewerPagesTotal(accessor.getKnex(), { isExternal: false });
140
- },
141
- async run({ sheet, maxRows, estimatedTotal, onProgress }) {
142
- const redirectFromByDestId = await buildRedirectFromUrlsByDestId(accessor);
143
- let sent = 0;
144
- const total = estimatedTotal;
145
- for await (const chunk of streamPageListRows(accessor)) {
146
- const linkFactsByPageId = await getOutboundLinkFactsByPageIds(accessor, chunk.map((item) => item.pageId));
147
- for (const item of chunk) {
148
- if (sent >= maxRows) {
149
- await sheet.flush();
150
- return;
70
+ export function createPageList(options) {
71
+ const urls = options?.urls;
72
+ return (reports, accessor) => {
73
+ let maxDepth = 0;
74
+ const reportPageData = reports
75
+ .map((r) => (r.pageData ? { name: r.name, pageData: r.pageData } : null))
76
+ .filter(nonNullFilter);
77
+ return {
78
+ name: 'Page List',
79
+ requiresReadModel: true,
80
+ createHeaders() {
81
+ const headers = [
82
+ 'Title',
83
+ 'Full Title',
84
+ 'URL',
85
+ 'Protocol',
86
+ 'Domain',
87
+ 'path1',
88
+ 'path2',
89
+ 'path3',
90
+ 'path4',
91
+ 'path5',
92
+ 'path6',
93
+ 'path7',
94
+ 'path8',
95
+ 'path9',
96
+ 'path10',
97
+ 'Status Code',
98
+ 'Redirect From',
99
+ 'Redirect To',
100
+ 'Language',
101
+ 'charset',
102
+ 'Internal Links',
103
+ 'Internal Bad Links',
104
+ 'External Links',
105
+ 'External Bad Links',
106
+ 'Internal Referrers',
107
+ 'description',
108
+ 'keywords',
109
+ 'noindex',
110
+ 'nofollow',
111
+ 'noarchive',
112
+ 'robots:raw',
113
+ 'canonical',
114
+ 'manifest',
115
+ 'theme-color',
116
+ 'twitter:card',
117
+ 'twitter:site',
118
+ 'twitter:creator',
119
+ 'og:site_name',
120
+ 'og:url',
121
+ 'og:title',
122
+ 'og:description',
123
+ 'og:type',
124
+ 'og:image',
125
+ 'og:image:alt',
126
+ 'og:locale',
127
+ 'og:article:published_time',
128
+ 'jsonld_count',
129
+ 'tags_providers',
130
+ 'main_content_selector',
131
+ 'main_content_word_count',
132
+ 'main_content_body_word_count',
133
+ 'main_content_heading_count',
134
+ 'main_content_image_count',
135
+ 'main_content_table_count',
136
+ 'main_content_button_count',
137
+ 'main_content_iframe_count',
138
+ 'main_content_video_count',
139
+ 'main_content_audio_count',
140
+ 'main_content_canvas_count',
141
+ 'main_content_custom_element_count',
142
+ 'scroll_height_desktop',
143
+ 'scroll_height_mobile',
144
+ ];
145
+ for (const report of reports) {
146
+ if (report.pageData) {
147
+ headers.push(...Object.values(report.pageData.headers));
151
148
  }
152
- // Only for the Title column's indentation depth below --
153
- // protocol/hostname/path1..10 come precomputed from the read
154
- // model (item.*) and no longer need a per-row parse.
155
- const parsedForDepth = parseUrl(item.url);
156
- if (!parsedForDepth) {
157
- continue;
158
- }
159
- maxDepth = Math.max(parsedForDepth.depth, maxDepth);
160
- const isRoot = parsedForDepth.dirname == null;
161
- const depth = isRoot
162
- ? 0
163
- : parsedForDepth.depth - (parsedForDepth.isIndex ? 1 : 0);
164
- const facts = linkFactsByPageId.get(item.pageId);
165
- const redirectFromUrls = redirectFromByDestId.get(item.pageId) ?? [];
166
- const internalReferrers = item.dirIndexInboundLinkCount ?? item.inboundLinkCount ?? 0;
167
- const data = [
168
- createCellData({
169
- value: item.displayTitle ?? item.title,
170
- cellFormat: { padding: { left: Math.max(depth, 0) * 20 + 3 } },
171
- note: truncateNoteText(`Full-title:\n${item.title}`),
172
- }, defaultCellFormat),
173
- createCellData({ value: item.title }, defaultCellFormat),
174
- createCellData({ value: item.url, textFormat: { link: { uri: item.url } } }, defaultCellFormat),
175
- createCellData({ value: item.protocol }, defaultCellFormat),
176
- createCellData({ value: item.hostname }, defaultCellFormat),
177
- createCellData({ value: item.path1 }, defaultCellFormat),
178
- createCellData({ value: item.path2 }, defaultCellFormat),
179
- createCellData({ value: item.path3 }, defaultCellFormat),
180
- createCellData({ value: item.path4 }, defaultCellFormat),
181
- createCellData({ value: item.path5 }, defaultCellFormat),
182
- createCellData({ value: item.path6 }, defaultCellFormat),
183
- createCellData({ value: item.path7 }, defaultCellFormat),
184
- createCellData({ value: item.path8 }, defaultCellFormat),
185
- createCellData({ value: item.path9 }, defaultCellFormat),
186
- createCellData({ value: item.path10 }, defaultCellFormat),
187
- createCellData({ value: item.status ?? -1 }, defaultCellFormat),
188
- createCellData({
189
- value: redirectFromUrls.length,
190
- note: joinUrlsForNote(redirectFromUrls),
191
- }, defaultCellFormat),
192
- createCellData({ value: item.lang || 'N/A' }, defaultCellFormat),
193
- createCellData({ value: item.charset }, defaultCellFormat),
194
- createCellData({ value: facts?.internalLinks ?? 0 }, defaultCellFormat),
195
- createCellData({ value: facts?.internalBadLinks ?? 0 }, defaultCellFormat),
196
- createCellData({ value: facts?.externalLinks ?? 0 }, defaultCellFormat),
197
- createCellData({ value: facts?.externalBadLinks ?? 0 }, defaultCellFormat),
198
- createCellData({ value: internalReferrers }, defaultCellFormat),
199
- createCellData({ value: item.description }, defaultCellFormat),
200
- createCellData({ value: item.keywords }, defaultCellFormat),
201
- createCellData({ value: item.noindex }, defaultCellFormat),
202
- createCellData({ value: item.nofollow }, defaultCellFormat),
203
- createCellData({ value: item.noarchive }, defaultCellFormat),
204
- createCellData({ value: item.robotsRaw }, defaultCellFormat),
205
- createCellData({ value: item.canonical }, defaultCellFormat),
206
- createCellData({ value: item.manifest }, defaultCellFormat),
207
- createCellData({ value: item.themeColor }, defaultCellFormat),
208
- createCellData({ value: item.twitterCard }, defaultCellFormat),
209
- createCellData({ value: item.twitterSite }, defaultCellFormat),
210
- createCellData({ value: item.twitterCreator }, defaultCellFormat),
211
- createCellData({ value: item.ogSiteName }, defaultCellFormat),
212
- createCellData({ value: item.ogUrl, textFormat: { link: { uri: item.ogUrl ?? '' } } }, defaultCellFormat),
213
- createCellData({ value: item.ogTitle }, defaultCellFormat),
214
- createCellData({ value: item.ogDescription }, defaultCellFormat),
215
- createCellData({ value: item.ogType }, defaultCellFormat),
216
- createCellData({ value: item.ogImage }, defaultCellFormat),
217
- createCellData({ value: item.ogImageAlt }, defaultCellFormat),
218
- createCellData({ value: item.ogLocale }, defaultCellFormat),
219
- createCellData({ value: item.ogArticlePublishedTime }, defaultCellFormat),
220
- // Denormalised aggregates: written at scrape time so no per-page
221
- // GROUP BY is needed here. `tagsProvidersCsv` is comma-separated
222
- // for native Google Sheets list rendering.
223
- createCellData({ value: item.jsonldCount }, defaultCellFormat),
224
- createCellData({ value: item.tagsProvidersCsv }, defaultCellFormat),
225
- // beholder MainContentsData / ScrollHeightData denormalised
226
- // aggregates. `null` (page never fully rendered) or `0` (rendered,
227
- // no main region / no elements of that kind found) render as
228
- // blank / 0 respectively — no special-casing needed here.
229
- createCellData({ value: item.mainContentSelector }, defaultCellFormat),
230
- createCellData({ value: item.mainContentWordCount }, defaultCellFormat),
231
- createCellData({ value: item.mainContentBodyWordCount }, defaultCellFormat),
232
- createCellData({ value: item.mainContentHeadingCount }, defaultCellFormat),
233
- createCellData({ value: item.mainContentImageCount }, defaultCellFormat),
234
- createCellData({ value: item.mainContentTableCount }, defaultCellFormat),
235
- createCellData({ value: item.mainContentButtonCount }, defaultCellFormat),
236
- createCellData({ value: item.mainContentIframeCount }, defaultCellFormat),
237
- createCellData({ value: item.mainContentVideoCount }, defaultCellFormat),
238
- createCellData({ value: item.mainContentAudioCount }, defaultCellFormat),
239
- createCellData({ value: item.mainContentCanvasCount }, defaultCellFormat),
240
- createCellData({ value: item.mainContentCustomElementCount }, defaultCellFormat),
241
- createCellData({ value: item.scrollHeightDesktop }, defaultCellFormat),
242
- createCellData({ value: item.scrollHeightMobile }, defaultCellFormat),
243
- ];
244
- for (const report of reportPageData) {
245
- const tableData = report.pageData.data[item.url];
246
- const options = report.pageData.options
247
- ? report.pageData.options[item.url]
248
- : null;
249
- if (!tableData) {
250
- reportLog("%s did'nt have table of %s", report.name, item.url);
149
+ }
150
+ return headers;
151
+ },
152
+ estimateRowCount() {
153
+ return countPageListRows(accessor, { urls });
154
+ },
155
+ async run({ sheet, maxRows, estimatedTotal, onProgress }) {
156
+ const redirectFromByDestId = await buildRedirectFromUrlsByDestId(accessor);
157
+ let sent = 0;
158
+ const total = estimatedTotal;
159
+ for await (const chunk of streamPageListRows(accessor, { urls })) {
160
+ const linkFactsByPageId = await getOutboundLinkFactsByPageIds(accessor, chunk.map((item) => item.pageId));
161
+ for (const item of chunk) {
162
+ if (sent >= maxRows) {
163
+ await sheet.flush();
164
+ return;
165
+ }
166
+ // Only for the Title column's indentation depth below --
167
+ // protocol/hostname/path1..10 come precomputed from the read
168
+ // model (item.*) and no longer need a per-row parse.
169
+ const parsedForDepth = parseUrl(item.url);
170
+ if (!parsedForDepth) {
251
171
  continue;
252
172
  }
253
- reportLog('Add %s to table from %s', item.url, report.name);
254
- data.push(...Object.keys(report.pageData.headers).map((key) => {
255
- const option = options ? options[key] || null : null;
256
- const cellData = tableData[key];
257
- const format = {};
258
- let note;
259
- if (option) {
260
- if (option.bold) {
261
- format.bold = !!option.bold;
262
- }
263
- if (option.fontFamily != null) {
264
- format.fontFamily = `${option.fontFamily}`;
265
- }
266
- if (option.fontSize != null) {
267
- format.fontSize = +option.fontSize;
268
- }
269
- if (option.italic != null) {
270
- format.italic = !!option.italic;
271
- }
272
- if (option.strike != null) {
273
- format.strikethrough = !!option.strike;
274
- }
275
- if (option.underline != null) {
276
- format.underline = !!option.underline;
277
- }
278
- note = truncateNoteText(cellData?.note || `${option.note || ''}`);
173
+ maxDepth = Math.max(parsedForDepth.depth, maxDepth);
174
+ const isRoot = parsedForDepth.dirname == null;
175
+ const depth = isRoot
176
+ ? 0
177
+ : parsedForDepth.depth - (parsedForDepth.isIndex ? 1 : 0);
178
+ const facts = linkFactsByPageId.get(item.pageId);
179
+ const redirectFromUrls = redirectFromByDestId.get(item.pageId) ?? [];
180
+ const internalReferrers = item.dirIndexInboundLinkCount ?? item.inboundLinkCount ?? 0;
181
+ // A redirect-source row (see PageListItem.isRedirectSource's docs)
182
+ // carries no audit signal of its own — every column below reads
183
+ // from a sanitized null/0/false rather than real page data.
184
+ // Rendering the raw sanitized value would read as "an empty page";
185
+ // `dash` renders it as `-` instead, so the row reads as explicitly
186
+ // not-applicable. URL / Status Code / Redirect From / Redirect To
187
+ // are excluded — they carry real signal even on a redirect source.
188
+ const dash = (value) => (item.isRedirectSource ? '-' : value);
189
+ const data = [
190
+ createCellData({
191
+ value: dash(item.displayTitle ?? item.title),
192
+ cellFormat: { padding: { left: Math.max(depth, 0) * 20 + 3 } },
193
+ // `item.title` is sanitized to null on a redirect-source row
194
+ // (see `dash`'s comment above) — omit the note entirely
195
+ // there instead of leaking a literal "Full-title:\nnull"
196
+ // string into it.
197
+ note: item.isRedirectSource
198
+ ? undefined
199
+ : truncateNoteText(`Full-title:\n${item.title}`),
200
+ }, defaultCellFormat),
201
+ createCellData({ value: dash(item.title) }, defaultCellFormat),
202
+ createCellData({ value: item.url, textFormat: { link: { uri: item.url } } }, defaultCellFormat),
203
+ createCellData({ value: dash(item.protocol) }, defaultCellFormat),
204
+ createCellData({ value: dash(item.hostname) }, defaultCellFormat),
205
+ createCellData({ value: dash(item.path1) }, defaultCellFormat),
206
+ createCellData({ value: dash(item.path2) }, defaultCellFormat),
207
+ createCellData({ value: dash(item.path3) }, defaultCellFormat),
208
+ createCellData({ value: dash(item.path4) }, defaultCellFormat),
209
+ createCellData({ value: dash(item.path5) }, defaultCellFormat),
210
+ createCellData({ value: dash(item.path6) }, defaultCellFormat),
211
+ createCellData({ value: dash(item.path7) }, defaultCellFormat),
212
+ createCellData({ value: dash(item.path8) }, defaultCellFormat),
213
+ createCellData({ value: dash(item.path9) }, defaultCellFormat),
214
+ createCellData({ value: dash(item.path10) }, defaultCellFormat),
215
+ createCellData({ value: item.status ?? -1 }, defaultCellFormat),
216
+ createCellData({
217
+ value: dash(redirectFromUrls.length),
218
+ note: joinUrlsForNote(redirectFromUrls),
219
+ }, defaultCellFormat),
220
+ createCellData({
221
+ value: item.redirectDestUrl,
222
+ textFormat: item.redirectDestUrl
223
+ ? { link: { uri: item.redirectDestUrl } }
224
+ : undefined,
225
+ }, defaultCellFormat),
226
+ createCellData({ value: dash(item.lang || 'N/A') }, defaultCellFormat),
227
+ createCellData({ value: dash(item.charset) }, defaultCellFormat),
228
+ createCellData({ value: dash(facts?.internalLinks ?? 0) }, defaultCellFormat),
229
+ createCellData({ value: dash(facts?.internalBadLinks ?? 0) }, defaultCellFormat),
230
+ createCellData({ value: dash(facts?.externalLinks ?? 0) }, defaultCellFormat),
231
+ createCellData({ value: dash(facts?.externalBadLinks ?? 0) }, defaultCellFormat),
232
+ createCellData({ value: dash(internalReferrers) }, defaultCellFormat),
233
+ createCellData({ value: dash(item.description) }, defaultCellFormat),
234
+ createCellData({ value: dash(item.keywords) }, defaultCellFormat),
235
+ createCellData({ value: dash(item.noindex) }, defaultCellFormat),
236
+ createCellData({ value: dash(item.nofollow) }, defaultCellFormat),
237
+ createCellData({ value: dash(item.noarchive) }, defaultCellFormat),
238
+ createCellData({ value: dash(item.robotsRaw) }, defaultCellFormat),
239
+ createCellData({ value: dash(item.canonical) }, defaultCellFormat),
240
+ createCellData({ value: dash(item.manifest) }, defaultCellFormat),
241
+ createCellData({ value: dash(item.themeColor) }, defaultCellFormat),
242
+ createCellData({ value: dash(item.twitterCard) }, defaultCellFormat),
243
+ createCellData({ value: dash(item.twitterSite) }, defaultCellFormat),
244
+ createCellData({ value: dash(item.twitterCreator) }, defaultCellFormat),
245
+ createCellData({ value: dash(item.ogSiteName) }, defaultCellFormat),
246
+ createCellData({
247
+ value: dash(item.ogUrl),
248
+ textFormat: item.isRedirectSource
249
+ ? undefined
250
+ : { link: { uri: item.ogUrl ?? '' } },
251
+ }, defaultCellFormat),
252
+ createCellData({ value: dash(item.ogTitle) }, defaultCellFormat),
253
+ createCellData({ value: dash(item.ogDescription) }, defaultCellFormat),
254
+ createCellData({ value: dash(item.ogType) }, defaultCellFormat),
255
+ createCellData({ value: dash(item.ogImage) }, defaultCellFormat),
256
+ createCellData({ value: dash(item.ogImageAlt) }, defaultCellFormat),
257
+ createCellData({ value: dash(item.ogLocale) }, defaultCellFormat),
258
+ createCellData({ value: dash(item.ogArticlePublishedTime) }, defaultCellFormat),
259
+ // Denormalised aggregates: written at scrape time so no per-page
260
+ // GROUP BY is needed here. `tagsProvidersCsv` is comma-separated
261
+ // for native Google Sheets list rendering.
262
+ createCellData({ value: dash(item.jsonldCount) }, defaultCellFormat),
263
+ createCellData({ value: dash(item.tagsProvidersCsv) }, defaultCellFormat),
264
+ // beholder MainContentsData / ScrollHeightData denormalised
265
+ // aggregates. `null` (page never fully rendered) or `0` (rendered,
266
+ // no main region / no elements of that kind found) render as
267
+ // blank / 0 respectively — no special-casing needed here.
268
+ createCellData({ value: dash(item.mainContentSelector) }, defaultCellFormat),
269
+ createCellData({ value: dash(item.mainContentWordCount) }, defaultCellFormat),
270
+ createCellData({ value: dash(item.mainContentBodyWordCount) }, defaultCellFormat),
271
+ createCellData({ value: dash(item.mainContentHeadingCount) }, defaultCellFormat),
272
+ createCellData({ value: dash(item.mainContentImageCount) }, defaultCellFormat),
273
+ createCellData({ value: dash(item.mainContentTableCount) }, defaultCellFormat),
274
+ createCellData({ value: dash(item.mainContentButtonCount) }, defaultCellFormat),
275
+ createCellData({ value: dash(item.mainContentIframeCount) }, defaultCellFormat),
276
+ createCellData({ value: dash(item.mainContentVideoCount) }, defaultCellFormat),
277
+ createCellData({ value: dash(item.mainContentAudioCount) }, defaultCellFormat),
278
+ createCellData({ value: dash(item.mainContentCanvasCount) }, defaultCellFormat),
279
+ createCellData({ value: dash(item.mainContentCustomElementCount) }, defaultCellFormat),
280
+ createCellData({ value: dash(item.scrollHeightDesktop) }, defaultCellFormat),
281
+ createCellData({ value: dash(item.scrollHeightMobile) }, defaultCellFormat),
282
+ ];
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;
279
291
  }
280
- const value = cellData?.value;
281
- return createCellData({ value, textFormat: format, note, ifNull: false }, defaultCellFormat);
282
- }));
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
+ await sheet.appendRow(data);
324
+ sent++;
325
+ onProgress(sent, total);
283
326
  }
284
- await sheet.appendRow(data);
285
- sent++;
286
- onProgress(sent, total);
287
327
  }
288
- }
289
- await sheet.flush();
290
- },
291
- async updateSheet(sheet) {
292
- await sheet.frozen(1, 1);
293
- await sheet.conditionalFormat([
294
- sheet.getColNumByHeaderName('Internal Bad Links'),
295
- sheet.getColNumByHeaderName('External Bad Links'),
296
- ], {
297
- booleanRule: {
298
- condition: {
299
- type: 'NUMBER_NOT_EQ',
300
- values: [
301
- {
302
- userEnteredValue: '0',
303
- },
304
- ],
328
+ await sheet.flush();
329
+ },
330
+ async updateSheet(sheet) {
331
+ await sheet.frozen(1, 1);
332
+ await sheet.conditionalFormat([
333
+ sheet.getColNumByHeaderName('Internal Bad Links'),
334
+ sheet.getColNumByHeaderName('External Bad Links'),
335
+ ], {
336
+ booleanRule: {
337
+ condition: {
338
+ type: 'NUMBER_NOT_EQ',
339
+ values: [
340
+ {
341
+ userEnteredValue: '0',
342
+ },
343
+ ],
344
+ },
345
+ format: booleanFormatError,
305
346
  },
306
- format: booleanFormatError,
307
- },
308
- });
309
- await sheet.conditionalFormat([sheet.getColNumByHeaderName('Language')], {
310
- booleanRule: {
311
- condition: {
312
- type: 'TEXT_EQ',
313
- values: [
314
- {
315
- userEnteredValue: 'N/A',
316
- },
317
- ],
347
+ });
348
+ await sheet.conditionalFormat([sheet.getColNumByHeaderName('Language')], {
349
+ booleanRule: {
350
+ condition: {
351
+ type: 'TEXT_EQ',
352
+ values: [
353
+ {
354
+ userEnteredValue: 'N/A',
355
+ },
356
+ ],
357
+ },
358
+ format: booleanFormatError,
318
359
  },
319
- format: booleanFormatError,
320
- },
321
- });
322
- await sheet.conditionalFormat([sheet.getColNumByHeaderName('Internal Referrers')], {
323
- booleanRule: {
324
- condition: {
325
- type: 'NUMBER_LESS',
326
- values: [
327
- {
328
- userEnteredValue: '2',
329
- },
330
- ],
360
+ });
361
+ await sheet.conditionalFormat([sheet.getColNumByHeaderName('Internal Referrers')], {
362
+ booleanRule: {
363
+ condition: {
364
+ type: 'NUMBER_LESS',
365
+ values: [
366
+ {
367
+ userEnteredValue: '2',
368
+ },
369
+ ],
370
+ },
371
+ format: booleanFormatError,
331
372
  },
332
- format: booleanFormatError,
333
- },
334
- });
335
- await sheet.conditionalFormat([
336
- sheet.getColNumByHeaderName('path1'),
337
- sheet.getColNumByHeaderName('path2'),
338
- sheet.getColNumByHeaderName('path3'),
339
- sheet.getColNumByHeaderName('path4'),
340
- sheet.getColNumByHeaderName('path5'),
341
- sheet.getColNumByHeaderName('path6'),
342
- sheet.getColNumByHeaderName('path7'),
343
- sheet.getColNumByHeaderName('path8'),
344
- sheet.getColNumByHeaderName('path9'),
345
- sheet.getColNumByHeaderName('path10'),
346
- ], {
347
- booleanRule: {
348
- condition: {
349
- type: 'CUSTOM_FORMULA',
350
- values: [
351
- {
352
- userEnteredValue: '=REGEXMATCH(INDIRECT(ADDRESS(ROW(),COLUMN())), "(?i)(^/_|_$|_copy|-copy|copy_|copy-|dummy)")',
353
- },
354
- ],
373
+ });
374
+ await sheet.conditionalFormat([
375
+ sheet.getColNumByHeaderName('path1'),
376
+ sheet.getColNumByHeaderName('path2'),
377
+ sheet.getColNumByHeaderName('path3'),
378
+ sheet.getColNumByHeaderName('path4'),
379
+ sheet.getColNumByHeaderName('path5'),
380
+ sheet.getColNumByHeaderName('path6'),
381
+ sheet.getColNumByHeaderName('path7'),
382
+ sheet.getColNumByHeaderName('path8'),
383
+ sheet.getColNumByHeaderName('path9'),
384
+ sheet.getColNumByHeaderName('path10'),
385
+ ], {
386
+ booleanRule: {
387
+ condition: {
388
+ type: 'CUSTOM_FORMULA',
389
+ values: [
390
+ {
391
+ userEnteredValue: '=REGEXMATCH(INDIRECT(ADDRESS(ROW(),COLUMN())), "(?i)(^/_|_$|_copy|-copy|copy_|copy-|dummy)")',
392
+ },
393
+ ],
394
+ },
395
+ format: booleanFormatError,
355
396
  },
356
- format: booleanFormatError,
357
- },
358
- });
359
- await sheet.conditionalFormat([sheet.getColNumByHeaderName('Title')], {
360
- booleanRule: {
361
- condition: {
362
- type: 'CUSTOM_FORMULA',
363
- values: [
364
- {
365
- userEnteredValue: '=REGEXMATCH(INDIRECT(ADDRESS(ROW(),COLUMN())), "(?i)(^| )(401|403|404|500|501|502|503)")',
366
- },
367
- ],
397
+ });
398
+ await sheet.conditionalFormat([sheet.getColNumByHeaderName('Title')], {
399
+ booleanRule: {
400
+ condition: {
401
+ type: 'CUSTOM_FORMULA',
402
+ values: [
403
+ {
404
+ userEnteredValue: '=REGEXMATCH(INDIRECT(ADDRESS(ROW(),COLUMN())), "(?i)(^| )(401|403|404|500|501|502|503)")',
405
+ },
406
+ ],
407
+ },
408
+ format: booleanFormatError,
368
409
  },
369
- format: booleanFormatError,
370
- },
371
- });
372
- await sheet.conditionalFormat([sheet.getColNumByHeaderName('Protocol')], {
373
- booleanRule: {
374
- condition: {
375
- type: 'TEXT_EQ',
376
- values: [
377
- {
378
- userEnteredValue: 'http:',
379
- },
380
- ],
410
+ });
411
+ await sheet.conditionalFormat([sheet.getColNumByHeaderName('Protocol')], {
412
+ booleanRule: {
413
+ condition: {
414
+ type: 'TEXT_EQ',
415
+ values: [
416
+ {
417
+ userEnteredValue: 'http:',
418
+ },
419
+ ],
420
+ },
421
+ format: booleanFormatError,
381
422
  },
382
- format: booleanFormatError,
383
- },
384
- });
385
- await sheet.conditionalFormat([sheet.getColNumByHeaderName('Status Code')], {
386
- booleanRule: {
387
- condition: {
388
- type: 'NUMBER_NOT_BETWEEN',
389
- values: [
390
- {
391
- userEnteredValue: '200',
392
- },
393
- {
394
- userEnteredValue: '399',
395
- },
396
- ],
423
+ });
424
+ await sheet.conditionalFormat([sheet.getColNumByHeaderName('Status Code')], {
425
+ booleanRule: {
426
+ condition: {
427
+ type: 'NUMBER_NOT_BETWEEN',
428
+ values: [
429
+ {
430
+ userEnteredValue: '200',
431
+ },
432
+ {
433
+ userEnteredValue: '399',
434
+ },
435
+ ],
436
+ },
437
+ format: booleanFormatError,
397
438
  },
398
- format: booleanFormatError,
399
- },
400
- });
401
- for (let i = maxDepth + 1; i <= 10; i++) {
402
- const name = `path${i}`;
403
- log('Hide col %s', name);
404
- await sheet.hideCol(sheet.getColNumByHeaderName(name));
405
- }
406
- },
439
+ });
440
+ for (let i = maxDepth + 1; i <= 10; i++) {
441
+ const name = `path${i}`;
442
+ log('Hide col %s', name);
443
+ await sheet.hideCol(sheet.getColNumByHeaderName(name));
444
+ }
445
+ },
446
+ };
407
447
  };
408
- };
448
+ }