@govtechsg/oobee 0.10.98 → 0.11.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/AGENTS.md +25 -0
- package/CRAWL.md +260 -0
- package/README.md +4 -0
- package/dist/combine.js +7 -0
- package/dist/constants/common.js +7 -0
- package/dist/constants/constants.js +17 -0
- package/dist/crawlers/commonCrawlerFunc.js +89 -48
- package/dist/crawlers/crawlDomain.js +88 -30
- package/dist/crawlers/crawlSitemap.js +123 -18
- package/dist/mergeAxeResults.js +2 -1
- package/dist/utils.js +36 -9
- package/oobee-client-scanner.js +2 -2
- package/package.json +1 -1
- package/src/combine.ts +7 -0
- package/src/constants/common.ts +9 -0
- package/src/constants/constants.ts +17 -0
- package/src/crawlers/commonCrawlerFunc.ts +101 -62
- package/src/crawlers/crawlDomain.ts +89 -30
- package/src/crawlers/crawlSitemap.ts +128 -19
- package/src/mergeAxeResults.ts +2 -1
- package/src/utils.ts +31 -8
- /package/{0a93900f-3345-4f25-8be7-c2d3748034be.txt → f0ce5c33-4dd0-4e14-8e67-1394f57ff517.txt} +0 -0
package/src/utils.ts
CHANGED
|
@@ -390,14 +390,31 @@ export const cleanUp = async (randomToken?: string, isError: boolean = false): P
|
|
|
390
390
|
consoleLogger.warn(`Unable to force remove userDataDirectory: ${error.message}`);
|
|
391
391
|
}
|
|
392
392
|
|
|
393
|
-
// Also remove _pool* sibling directories created by browser pool re-launches
|
|
394
|
-
|
|
395
|
-
|
|
393
|
+
// Also remove _pool* sibling directories created by browser pool re-launches.
|
|
394
|
+
// On Windows, Chrome writes files (optimization_guide_model_store,
|
|
395
|
+
// segmentation_platform, first_party_sets.db, etc.) during its shutdown
|
|
396
|
+
// sequence and may still hold file locks. Retry up to 10 times at 5s intervals.
|
|
397
|
+
const removePoolDirs = (): number => {
|
|
398
|
+
// On Windows, glob interprets backslashes as escape characters, not path
|
|
399
|
+
// separators. Normalize to forward slashes so the pattern actually matches.
|
|
400
|
+
const globPattern = `${constants.userDataDirectory}_pool*`.replace(/\\/g, '/');
|
|
401
|
+
const poolDirs = globSync(globPattern);
|
|
396
402
|
for (const dir of poolDirs) {
|
|
397
403
|
fs.rmSync(dir, { recursive: true, force: true });
|
|
398
404
|
}
|
|
399
|
-
|
|
400
|
-
|
|
405
|
+
return poolDirs.length;
|
|
406
|
+
};
|
|
407
|
+
for (let attempt = 0; attempt < 10; attempt++) {
|
|
408
|
+
try {
|
|
409
|
+
if (removePoolDirs() === 0) break; // nothing left to clean
|
|
410
|
+
break; // rmSync succeeded for all dirs
|
|
411
|
+
} catch {
|
|
412
|
+
if (attempt < 9) {
|
|
413
|
+
await new Promise(r => setTimeout(r, 5000));
|
|
414
|
+
} else {
|
|
415
|
+
consoleLogger.warn('Unable to remove pool directories after 10 attempts');
|
|
416
|
+
}
|
|
417
|
+
}
|
|
401
418
|
}
|
|
402
419
|
}
|
|
403
420
|
|
|
@@ -418,7 +435,7 @@ export const cleanUp = async (randomToken?: string, isError: boolean = false): P
|
|
|
418
435
|
const crawleeDir = path.join(storagePath, 'crawlee');
|
|
419
436
|
const dataset = await Dataset.open(crawleeDir);
|
|
420
437
|
await dataset.drop();
|
|
421
|
-
const requestQueue = await RequestQueue.open(crawleeDir);
|
|
438
|
+
const requestQueue = await RequestQueue.open(`${crawleeDir}_rq`);
|
|
422
439
|
await requestQueue.drop();
|
|
423
440
|
} catch (error) {
|
|
424
441
|
consoleLogger.info(`Crawlee storage drop in cleanUp: ${error.message}`);
|
|
@@ -428,6 +445,11 @@ export const cleanUp = async (randomToken?: string, isError: boolean = false): P
|
|
|
428
445
|
} catch (error) {
|
|
429
446
|
consoleLogger.warn(`Unable to force remove crawlee folder: ${error.message}`);
|
|
430
447
|
}
|
|
448
|
+
try {
|
|
449
|
+
fs.rmSync(path.join(storagePath, 'crawlee_rq'), { recursive: true, force: true });
|
|
450
|
+
} catch (error) {
|
|
451
|
+
consoleLogger.warn(`Unable to force remove crawlee_rq folder: ${error.message}`);
|
|
452
|
+
}
|
|
431
453
|
|
|
432
454
|
try {
|
|
433
455
|
fs.rmSync(path.join(storagePath, 'pdfs'), { recursive: true, force: true });
|
|
@@ -1022,9 +1044,10 @@ export const zipResults = async (zipName: string, resultsPath: string): Promise<
|
|
|
1022
1044
|
if (!stats.isDirectory()) {
|
|
1023
1045
|
throw new Error(`resultsPath is not a directory: ${resultsPath}`);
|
|
1024
1046
|
}
|
|
1025
|
-
async function addFolderToZip(folderPath: string, zipFolder: JSZip): Promise<void> {
|
|
1047
|
+
async function addFolderToZip(folderPath: string, zipFolder: JSZip, isRoot = false): Promise<void> {
|
|
1026
1048
|
const items = await fs.readdir(folderPath);
|
|
1027
1049
|
for (const item of items) {
|
|
1050
|
+
if (isRoot && item.startsWith('crawlee')) continue;
|
|
1028
1051
|
const fullPath = path.join(folderPath, item);
|
|
1029
1052
|
const stats = await fs.stat(fullPath);
|
|
1030
1053
|
if (stats.isDirectory()) {
|
|
@@ -1038,7 +1061,7 @@ export const zipResults = async (zipName: string, resultsPath: string): Promise<
|
|
|
1038
1061
|
}
|
|
1039
1062
|
|
|
1040
1063
|
const zip = new JSZip();
|
|
1041
|
-
await addFolderToZip(resultsPath, zip);
|
|
1064
|
+
await addFolderToZip(resultsPath, zip, true);
|
|
1042
1065
|
|
|
1043
1066
|
const zipStream = zip.generateNodeStream({
|
|
1044
1067
|
type: 'nodebuffer',
|
/package/{0a93900f-3345-4f25-8be7-c2d3748034be.txt → f0ce5c33-4dd0-4e14-8e67-1394f57ff517.txt}
RENAMED
|
File without changes
|