From 65170e593fba851e0d7f0b4068c434843b302bef Mon Sep 17 00:00:00 2001 From: Suzanne Aitchison Date: Wed, 14 May 2025 10:38:39 +0100 Subject: [PATCH 01/21] WIP: puppeteer upgraded, working locally onSuccess --- package.json | 2 +- src/lib/run-audit-with-server/index.js | 6 +- src/lib/run-audit-with-url/index.js | 8 +- src/lib/run-event/index.js | 3 +- src/run-lighthouse.js | 38 +-- yarn.lock | 372 +++++++++++++++++++++++-- 6 files changed, 374 insertions(+), 55 deletions(-) diff --git a/package.json b/package.json index 4355c745..65dc352a 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "express": "^4.17.1", "html-minifier": "^4.0.0", "lighthouse": "^9.6.3", - "puppeteer": "^18.0.0" + "puppeteer": "^24.8.2" }, "engines": { "node": ">=18.14.0" diff --git a/src/lib/run-audit-with-server/index.js b/src/lib/run-audit-with-server/index.js index 4818a8eb..940132a5 100644 --- a/src/lib/run-audit-with-server/index.js +++ b/src/lib/run-audit-with-server/index.js @@ -1,7 +1,7 @@ import { join } from 'path'; import { formatResults } from '../../format.js'; -import { runLighthouse, getBrowserPath } from '../../run-lighthouse.js'; +import { runLighthouse } from '../../run-lighthouse.js'; import persistResults from '../persist-results/index.js'; import getServer from '../get-server/index.js'; @@ -16,13 +16,13 @@ const runAuditWithServer = async ({ try { const { server } = getServer({ serveDir: serveDir, auditUrl: url }); - const browserPath = await getBrowserPath(); + const { error, results } = await new Promise((resolve) => { const instance = server.listen(async () => { try { const fullPath = path ? `${server.url}/${path}` : server.url; - const results = await runLighthouse(browserPath, fullPath, settings); + const results = await runLighthouse("PLACEHOLDER", fullPath, settings); resolve({ error: false, results }); } catch (error) { resolve({ error }); diff --git a/src/lib/run-audit-with-url/index.js b/src/lib/run-audit-with-url/index.js index fde0e3b4..29d462fe 100644 --- a/src/lib/run-audit-with-url/index.js +++ b/src/lib/run-audit-with-url/index.js @@ -1,13 +1,11 @@ import { formatResults } from '../../format.js'; -import { runLighthouse, getBrowserPath } from '../../run-lighthouse.js'; +import { runLighthouse } from '../../run-lighthouse.js'; const runAuditWithUrl = async ({ path = '', url, thresholds, settings }) => { try { - const browserPath = await getBrowserPath(); - const getResults = async () => { const fullPath = path ? `${url}/${path}` : url; - const results = await runLighthouse(browserPath, fullPath, settings); + const results = await runLighthouse(fullPath, settings); try { return { results }; @@ -19,6 +17,7 @@ const runAuditWithUrl = async ({ path = '', url, thresholds, settings }) => { const { error, results } = await getResults(); if (error) { + console.log("error line 22 run audit with url", error) return { error }; } else { const { summary, shortSummary, details, report, errors, runtimeError } = @@ -37,6 +36,7 @@ const runAuditWithUrl = async ({ path = '', url, thresholds, settings }) => { }; } } catch (error) { + console.log("error line 41 run audit with url", error) return { error }; } }; diff --git a/src/lib/run-event/index.js b/src/lib/run-event/index.js index 0409e403..2c1376f0 100644 --- a/src/lib/run-event/index.js +++ b/src/lib/run-event/index.js @@ -17,7 +17,7 @@ const runEvent = async ({ } = {}) => { const isOnSuccess = event === 'onSuccess'; - const deployUrl = process.env.DEPLOY_URL; + const deployUrl = 'https://68244ec43a5a6b46e855abe0--testing-secret-scanning-ui.netlify.app/'; // If we don't have the deploy URL to test against, we can't run Lighthouse onSuccess. // If running locally, ensure you have a DEPLOY_URL set in your .env file @@ -67,6 +67,7 @@ const runEvent = async ({ }); console.log(startMessage); + console.log('*** url', url); const runner = isOnSuccess ? runAuditWithUrl : runAuditWithServer; const { errors, summary, shortSummary, details, report, runtimeError } = diff --git a/src/run-lighthouse.js b/src/run-lighthouse.js index 984812c9..6587ded2 100644 --- a/src/run-lighthouse.js +++ b/src/run-lighthouse.js @@ -1,37 +1,41 @@ -import puppeteer from 'puppeteer'; +import puppeteer from 'puppeteer'; import lighthouse from 'lighthouse'; import log from 'lighthouse-logger'; -import chromeLauncher from 'chrome-launcher'; -export const getBrowserPath = async () => { - const browserFetcher = puppeteer.createBrowserFetcher(); - const revisions = await browserFetcher.localRevisions(); - if (revisions.length <= 0) { - throw new Error('Could not find local browser'); - } - const info = await browserFetcher.revisionInfo(revisions[0]); - return info.executablePath; -}; +// export const getBrowserPath = async () => { +// const browserFetcher = new BrowserFetcher(); +// const revisions = await browserFetcher.localRevisions(); +// if (revisions.length <= 0) { +// throw new Error('Could not find local browser'); +// } +// const info = await browserFetcher.revisionInfo(revisions[0]); +// return info.executablePath; +// }; -export const runLighthouse = async (browserPath, url, settings) => { +export const runLighthouse = async (url, settings) => { let chrome; try { const logLevel = 'error'; log.setLevel(logLevel); - chrome = await chromeLauncher.launch({ - chromePath: browserPath, - chromeFlags: [ + chrome = await puppeteer.launch({ + args: [ '--headless', '--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage', + '--remote-debugging-port=0' ], logLevel, }); + + // Get the debugging port from the browser's websocket endpoint + const browserWSEndpoint = chrome.wsEndpoint(); + const port = parseInt(browserWSEndpoint.split(':')[2].split('/')[0], 10); + const results = await lighthouse( url, { - port: chrome.port, + port, output: 'html', logLevel, }, @@ -40,7 +44,7 @@ export const runLighthouse = async (browserPath, url, settings) => { return results; } finally { if (chrome) { - await chrome.kill(); + await chrome.close(); } } }; diff --git a/yarn.lock b/yarn.lock index 57c6a026..0a12df2d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -834,6 +834,19 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" +"@puppeteer/browsers@2.10.4": + version "2.10.4" + resolved "https://registry.yarnpkg.com/@puppeteer/browsers/-/browsers-2.10.4.tgz#9f8923b206f7932a06d32271b14bbea3368b38f2" + integrity sha512-9DxbZx+XGMNdjBynIs4BRSz+M3iRDeB7qRcAr6UORFLphCIM2x3DXgOucvADiifcqCE4XePFUKcnaAMyGbrDlQ== + dependencies: + debug "^4.4.0" + extract-zip "^2.0.1" + progress "^2.0.3" + proxy-agent "^6.5.0" + semver "^7.7.1" + tar-fs "^3.0.8" + yargs "^17.7.2" + "@sentry/core@6.19.7": version "6.19.7" resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.19.7.tgz#156aaa56dd7fad8c89c145be6ad7a4f7209f9785" @@ -926,6 +939,11 @@ resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82" integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw== +"@tootallnate/quickjs-emscripten@^0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz#db4ecfd499a9765ab24002c3b696d02e6d32a12c" + integrity sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA== + "@tsconfig/node10@^1.0.7": version "1.0.9" resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.9.tgz#df4907fc07a886922637b15e02d4cebc4c0021b2" @@ -1143,6 +1161,11 @@ agent-base@6: dependencies: debug "4" +agent-base@^7.1.0, agent-base@^7.1.2: + version "7.1.3" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-7.1.3.tgz#29435eb821bc4194633a5b89e5bc4703bafc25a1" + integrity sha512-jRR5wdylq8CkOe6hei19GGZnxM6rBGwFl3Bg0YItGDimvjGtAvdZk4Pu6Cl4u4Igsws4a1fd1Vq3ezrhn4KmFw== + aggregate-error@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/aggregate-error/-/aggregate-error-3.1.0.tgz#92670ff50f5359bdb7a3e0d40d0ec30c5737687a" @@ -1354,6 +1377,13 @@ assert-plus@1.0.0, assert-plus@^1.0.0: resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" integrity sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw== +ast-types@^0.13.4: + version "0.13.4" + resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.13.4.tgz#ee0d77b343263965ecc3fb62da16e7222b2b6782" + integrity sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w== + dependencies: + tslib "^2.0.1" + astral-regex@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31" @@ -1394,6 +1424,11 @@ axe-core@4.4.1: resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.4.1.tgz#7dbdc25989298f9ad006645cd396782443757413" integrity sha512-gd1kmb21kwNuWr6BQz8fv6GNECPBnUasepcoLbekws23NVBLODdsClRZ+bQ8+9Uomf3Sm3+Vwn0oYG9NvwnJCw== +b4a@^1.6.4: + version "1.6.7" + resolved "https://registry.yarnpkg.com/b4a/-/b4a-1.6.7.tgz#a99587d4ebbfbd5a6e3b21bdb5d5fa385767abe4" + integrity sha512-OnAYlL5b7LEkALw87fUVafQw5rVR9RjwGd4KUwNQ6DrrNmaVaUCgLipfVlzrPQ4tWOR9P0IXGNOx50jYCCdSJg== + babel-jest@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-29.7.0.tgz#f4369919225b684c56085998ac63dbd05be020d5" @@ -1459,6 +1494,39 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== +bare-events@^2.2.0, bare-events@^2.5.4: + version "2.5.4" + resolved "https://registry.yarnpkg.com/bare-events/-/bare-events-2.5.4.tgz#16143d435e1ed9eafd1ab85f12b89b3357a41745" + integrity sha512-+gFfDkR8pj4/TrWCGUGWmJIkBwuxPS5F+a5yWjOHQt2hHvNZd5YLzadjmDUtFmMM4y429bnKLa8bYBMHcYdnQA== + +bare-fs@^4.0.1: + version "4.1.5" + resolved "https://registry.yarnpkg.com/bare-fs/-/bare-fs-4.1.5.tgz#1d06c076e68cc8bf97010d29af9e3ac3808cdcf7" + integrity sha512-1zccWBMypln0jEE05LzZt+V/8y8AQsQQqxtklqaIyg5nu6OAYFhZxPXinJTSG+kU5qyNmeLgcn9AW7eHiCHVLA== + dependencies: + bare-events "^2.5.4" + bare-path "^3.0.0" + bare-stream "^2.6.4" + +bare-os@^3.0.1: + version "3.6.1" + resolved "https://registry.yarnpkg.com/bare-os/-/bare-os-3.6.1.tgz#9921f6f59edbe81afa9f56910658422c0f4858d4" + integrity sha512-uaIjxokhFidJP+bmmvKSgiMzj2sV5GPHaZVAIktcxcpCyBFFWO+YlikVAdhmUo2vYFvFhOXIAlldqV29L8126g== + +bare-path@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/bare-path/-/bare-path-3.0.0.tgz#b59d18130ba52a6af9276db3e96a2e3d3ea52178" + integrity sha512-tyfW2cQcB5NN8Saijrhqn0Zh7AnFNsnczRcuWODH0eYAXBsJ5gVxAUuNr7tsHSC6IZ77cA0SitzT+s47kot8Mw== + dependencies: + bare-os "^3.0.1" + +bare-stream@^2.6.4: + version "2.6.5" + resolved "https://registry.yarnpkg.com/bare-stream/-/bare-stream-2.6.5.tgz#bba8e879674c4c27f7e27805df005c15d7a2ca07" + integrity sha512-jSmxKJNJmHySi6hC42zlZnq00rga4jjxcgNZjY9N5WlOe/iOoGRtdwGsHzQv2RlH2KOYMwGUXhf2zXd32BA9RA== + dependencies: + streamx "^2.21.0" + base64-js@^1.3.1: version "1.5.1" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" @@ -1471,6 +1539,11 @@ basic-auth@^2.0.1, basic-auth@~2.0.1: dependencies: safe-buffer "5.1.2" +basic-ftp@^5.0.2: + version "5.0.5" + resolved "https://registry.yarnpkg.com/basic-ftp/-/basic-ftp-5.0.5.tgz#14a474f5fffecca1f4f406f1c26b18f800225ac0" + integrity sha512-4Bcg1P8xhUuqcii/S0Z9wiHIrQVPMermM1any+MX5GeGD7faD3/msQUDGLol9wOcz4/jbg/WJnGqoJF6LiBdtg== + batch@0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/batch/-/batch-0.6.1.tgz#dc34314f4e679318093fc760272525f94bf25c16" @@ -1712,6 +1785,14 @@ chrome-launcher@^0.15.0: is-wsl "^2.2.0" lighthouse-logger "^1.0.0" +chromium-bidi@5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/chromium-bidi/-/chromium-bidi-5.1.0.tgz#8d0e47f7ac9270262df29792318dd5378e983e62" + integrity sha512-9MSRhWRVoRPDG0TgzkHrshFSJJNZzfY5UFqUMuksg7zL1yoZIZ3jLB0YAgHclbiAxPI86pBnwDX1tbzoiV8aFw== + dependencies: + mitt "^3.0.1" + zod "^3.24.1" + ci-info@^3.2.0: version "3.9.0" resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.9.0.tgz#4279a62028a7b1f262f3473fc9605f5e218c59b4" @@ -2014,6 +2095,16 @@ cosmiconfig@^8.0.0: parse-json "^5.2.0" path-type "^4.0.0" +cosmiconfig@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-9.0.0.tgz#34c3fc58287b915f3ae905ab6dc3de258b55ad9d" + integrity sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg== + dependencies: + env-paths "^2.2.1" + import-fresh "^3.3.0" + js-yaml "^4.1.0" + parse-json "^5.2.0" + create-jest@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/create-jest/-/create-jest-29.7.0.tgz#a355c5b3cb1e1af02ba177fe7afd7feee49a5320" @@ -2136,6 +2227,11 @@ dashdash@^1.12.0: dependencies: assert-plus "^1.0.0" +data-uri-to-buffer@^6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz#8a58bb67384b261a38ef18bea1810cb01badd28b" + integrity sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw== + dayjs@^1.10.4: version "1.11.10" resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.10.tgz#68acea85317a6e164457d6d6947564029a6a16a0" @@ -2169,6 +2265,13 @@ debug@^3.1.0, debug@^3.2.7: dependencies: ms "^2.1.1" +debug@^4.4.0: + version "4.4.1" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.1.tgz#e5a8bc6cbc4c6cd3e64308b0693a3d4fa550189b" + integrity sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ== + dependencies: + ms "^2.1.3" + decamelize-keys@^1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.1.tgz#04a2d523b2f18d80d0158a43b895d56dff8d19d8" @@ -2242,6 +2345,15 @@ define-properties@^1.1.3, define-properties@^1.1.4, define-properties@^1.2.0: has-property-descriptors "^1.0.0" object-keys "^1.1.1" +degenerator@^5.0.0: + version "5.0.1" + resolved "https://registry.yarnpkg.com/degenerator/-/degenerator-5.0.1.tgz#9403bf297c6dad9a1ece409b37db27954f91f2f5" + integrity sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ== + dependencies: + ast-types "^0.13.4" + escodegen "^2.1.0" + esprima "^4.0.1" + delayed-stream@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" @@ -2277,6 +2389,11 @@ devtools-protocol@0.0.1045489: resolved "https://registry.yarnpkg.com/devtools-protocol/-/devtools-protocol-0.0.1045489.tgz#f959ad560b05acd72d55644bc3fb8168a83abf28" integrity sha512-D+PTmWulkuQW4D1NTiCRCFxF7pQPn0hgp4YyX4wAQ6xYXKOadSWPR3ENGDQ47MW/Ewc9v2rpC/UEEGahgBYpSQ== +devtools-protocol@0.0.1439962: + version "0.0.1439962" + resolved "https://registry.yarnpkg.com/devtools-protocol/-/devtools-protocol-0.0.1439962.tgz#395c5ca1cd83aa451c667056a025f9873c4598c1" + integrity sha512-jJF48UdryzKiWhJ1bLKr7BFWUQCEIT5uCNbDLqkQJBtkFxYzILJH44WN0PDKMIlGDN7Utb8vyUY85C3w4R/t2g== + devtools-protocol@0.0.981744: version "0.0.981744" resolved "https://registry.yarnpkg.com/devtools-protocol/-/devtools-protocol-0.0.981744.tgz#9960da0370284577d46c28979a0b32651022bacf" @@ -2371,6 +2488,11 @@ enquirer@^2.3.6: ansi-colors "^4.1.1" strip-ansi "^6.0.1" +env-paths@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.1.tgz#420399d416ce1fbe9bc0a07c62fa68d67fd0f8f2" + integrity sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A== + error-ex@^1.3.1: version "1.3.2" resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" @@ -2473,6 +2595,17 @@ escape-string-regexp@^4.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== +escodegen@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-2.1.0.tgz#ba93bbb7a43986d29d6041f99f5262da773e2e17" + integrity sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w== + dependencies: + esprima "^4.0.1" + estraverse "^5.2.0" + esutils "^2.0.2" + optionalDependencies: + source-map "~0.6.1" + eslint-import-resolver-node@^0.3.9: version "0.3.9" resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz#d4eaac52b8a2e7c3cd1903eb00f7e053356118ac" @@ -2585,7 +2718,7 @@ espree@^9.6.0, espree@^9.6.1: acorn-jsx "^5.3.2" eslint-visitor-keys "^3.4.1" -esprima@^4.0.0: +esprima@^4.0.0, esprima@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== @@ -2719,7 +2852,7 @@ extend@~3.0.2: resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== -extract-zip@2.0.1: +extract-zip@2.0.1, extract-zip@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-2.0.1.tgz#663dca56fe46df890d5f131ef4a06d22bb8ba13a" integrity sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg== @@ -2745,6 +2878,11 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== +fast-fifo@^1.2.0, fast-fifo@^1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/fast-fifo/-/fast-fifo-1.3.2.tgz#286e31de96eb96d38a97899815740ba2a4f3640c" + integrity sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ== + fast-json-stable-stringify@^2.0.0, fast-json-stable-stringify@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" @@ -2977,6 +3115,15 @@ get-symbol-description@^1.0.0: call-bind "^1.0.2" get-intrinsic "^1.1.1" +get-uri@^6.0.1: + version "6.0.4" + resolved "https://registry.yarnpkg.com/get-uri/-/get-uri-6.0.4.tgz#6daaee9e12f9759e19e55ba313956883ef50e0a7" + integrity sha512-E1b1lFFLvLgak2whF2xDBcOy6NLVGZBqqjJjsIhvopKfWWEi64pLVTWWehV8KlLerZkfNTA95sTe2OdJKm1OzQ== + dependencies: + basic-ftp "^5.0.2" + data-uri-to-buffer "^6.0.2" + debug "^4.3.4" + getos@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/getos/-/getos-3.2.1.tgz#0134d1f4e00eb46144c5a9c0ac4dc087cbb27dc5" @@ -3237,6 +3384,14 @@ http-proxy-agent@^4.0.1: agent-base "6" debug "4" +http-proxy-agent@^7.0.0, http-proxy-agent@^7.0.1: + version "7.0.2" + resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz#9a8b1f246866c028509486585f62b8f2c18c270e" + integrity sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig== + dependencies: + agent-base "^7.1.0" + debug "^4.3.4" + http-signature@~1.3.6: version "1.3.6" resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.3.6.tgz#cb6fbfdf86d1c974f343be94e87f7fc128662cf9" @@ -3254,6 +3409,14 @@ https-proxy-agent@5.0.1, https-proxy-agent@^5.0.0: agent-base "6" debug "4" +https-proxy-agent@^7.0.6: + version "7.0.6" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz#da8dfeac7da130b05c2ba4b59c9b6cd66611a6b9" + integrity sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw== + dependencies: + agent-base "^7.1.2" + debug "4" + human-signals@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" @@ -3371,6 +3534,14 @@ intl-messageformat@^4.4.0: dependencies: intl-messageformat-parser "^1.8.1" +ip-address@^9.0.5: + version "9.0.5" + resolved "https://registry.yarnpkg.com/ip-address/-/ip-address-9.0.5.tgz#117a960819b08780c3bd1f14ef3c1cc1d3f3ea5a" + integrity sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g== + dependencies: + jsbn "1.1.0" + sprintf-js "^1.1.3" + ipaddr.js@1.9.1: version "1.9.1" resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3" @@ -4043,6 +4214,11 @@ js-yaml@^4.1.0: dependencies: argparse "^2.0.1" +jsbn@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-1.1.0.tgz#b01307cb29b618a1ed26ec79e911f803c4da0040" + integrity sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A== + jsbn@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" @@ -4519,6 +4695,11 @@ lru-cache@^6.0.0: dependencies: yallist "^4.0.0" +lru-cache@^7.14.1: + version "7.18.3" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-7.18.3.tgz#f793896e0fd0e954a59dfdd82f0773808df6aa89" + integrity sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA== + lru_map@^0.3.3: version "0.3.3" resolved "https://registry.yarnpkg.com/lru_map/-/lru_map-0.3.3.tgz#b5c8351b9464cbd750335a79650a0ec0e56118dd" @@ -4804,6 +4985,11 @@ minimist@^1.2.0, minimist@^1.2.6, minimist@^1.2.8: resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== +mitt@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/mitt/-/mitt-3.0.1.tgz#ea36cf0cc30403601ae074c8f77b7092cdab36d1" + integrity sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw== + mkdirp-classic@^0.5.2: version "0.5.3" resolved "https://registry.yarnpkg.com/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz#fa10c9115cc6d8865be221ba47ee9bed78601113" @@ -4830,7 +5016,7 @@ ms@2.1.2: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -ms@2.1.3, ms@^2.1.1: +ms@2.1.3, ms@^2.1.1, ms@^2.1.3: version "2.1.3" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== @@ -4866,6 +5052,11 @@ netlify-plugin-cypress@^2.2.1: puppeteer "18.1.0" ramda "0.27.1" +netmask@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/netmask/-/netmask-2.0.2.tgz#8b01a07644065d536383835823bc52004ebac5e7" + integrity sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg== + no-case@^2.2.0: version "2.3.2" resolved "https://registry.yarnpkg.com/no-case/-/no-case-2.3.2.tgz#60b813396be39b3f1288a4c1ed5d1e7d28b464ac" @@ -5123,6 +5314,28 @@ p-try@^2.0.0: resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== +pac-proxy-agent@^7.1.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/pac-proxy-agent/-/pac-proxy-agent-7.2.0.tgz#9cfaf33ff25da36f6147a20844230ec92c06e5df" + integrity sha512-TEB8ESquiLMc0lV8vcd5Ql/JAKAoyzHFXaStwjkzpOpC5Yv+pIzLfHvjTSdf3vpa2bMiUQrg9i6276yn8666aA== + dependencies: + "@tootallnate/quickjs-emscripten" "^0.23.0" + agent-base "^7.1.2" + debug "^4.3.4" + get-uri "^6.0.1" + http-proxy-agent "^7.0.0" + https-proxy-agent "^7.0.6" + pac-resolver "^7.0.1" + socks-proxy-agent "^8.0.5" + +pac-resolver@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/pac-resolver/-/pac-resolver-7.0.1.tgz#54675558ea368b64d210fd9c92a640b5f3b8abb6" + integrity sha512-5NPgf87AT2STgwa2ntRMr45jTKrYBGkVU36yT0ig/n/GMAa3oPqhZfIQ2kMEimReg0+t9kZViDVZ83qfVUlckg== + dependencies: + degenerator "^5.0.0" + netmask "^2.0.2" + param-case@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/param-case/-/param-case-2.1.1.tgz#df94fd8cf6531ecf75e6bef9a0858fbc72be2247" @@ -5270,7 +5483,7 @@ process@^0.11.10: resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" integrity sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A== -progress@2.0.3: +progress@2.0.3, progress@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== @@ -5291,12 +5504,26 @@ proxy-addr@~2.0.7: forwarded "0.2.0" ipaddr.js "1.9.1" +proxy-agent@^6.5.0: + version "6.5.0" + resolved "https://registry.yarnpkg.com/proxy-agent/-/proxy-agent-6.5.0.tgz#9e49acba8e4ee234aacb539f89ed9c23d02f232d" + integrity sha512-TmatMXdr2KlRiA2CyDu8GqR8EjahTG3aY3nXjdzFyoZbmB8hrBsTyMezhULIXKnC0jpfjlmiZ3+EaCzoInSu/A== + dependencies: + agent-base "^7.1.2" + debug "^4.3.4" + http-proxy-agent "^7.0.1" + https-proxy-agent "^7.0.6" + lru-cache "^7.14.1" + pac-proxy-agent "^7.1.0" + proxy-from-env "^1.1.0" + socks-proxy-agent "^8.0.5" + proxy-from-env@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.0.0.tgz#33c50398f70ea7eb96d21f7b817630a55791c7ee" integrity sha512-F2JHgJQ1iqwnHDcQjVBsq3n/uoaFL+iPW/eAeL7kVxy/2RrWaN4WroKjjvbsoRtv0ftelNyC01bjRhn/bhcf4A== -proxy-from-env@1.1.0: +proxy-from-env@1.1.0, proxy-from-env@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== @@ -5324,21 +5551,17 @@ punycode@^2.1.0, punycode@^2.1.1: resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== -puppeteer-core@18.2.1: - version "18.2.1" - resolved "https://registry.yarnpkg.com/puppeteer-core/-/puppeteer-core-18.2.1.tgz#9b7827bb2bf478bb615e2c21425e4659555dc1fe" - integrity sha512-MRtTAZfQTluz3U2oU/X2VqVWPcR1+94nbA2V6ZrSZRVEwLqZ8eclZ551qGFQD/vD2PYqHJwWOW/fpC721uznVw== +puppeteer-core@24.8.2: + version "24.8.2" + resolved "https://registry.yarnpkg.com/puppeteer-core/-/puppeteer-core-24.8.2.tgz#f3e939e39e001d9933e79d980371e380d9e535c1" + integrity sha512-wNw5cRZOHiFibWc0vdYCYO92QuKTbJ8frXiUfOq/UGJWMqhPoBThTKkV+dJ99YyWfzJ2CfQQ4T1nhhR0h8FlVw== dependencies: - cross-fetch "3.1.5" - debug "4.3.4" - devtools-protocol "0.0.1045489" - extract-zip "2.0.1" - https-proxy-agent "5.0.1" - proxy-from-env "1.1.0" - rimraf "3.0.2" - tar-fs "2.1.1" - unbzip2-stream "1.4.3" - ws "8.9.0" + "@puppeteer/browsers" "2.10.4" + chromium-bidi "5.1.0" + debug "^4.4.0" + devtools-protocol "0.0.1439962" + typed-query-selector "^2.12.0" + ws "^8.18.2" puppeteer-core@^13.7.0: version "13.7.0" @@ -5375,15 +5598,17 @@ puppeteer@18.1.0: unbzip2-stream "1.4.3" ws "8.9.0" -puppeteer@^18.0.0: - version "18.2.1" - resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-18.2.1.tgz#08967cd423efe511ee4c6e3a5c882ffaf2e6bbf3" - integrity sha512-7+UhmYa7wxPh2oMRwA++k8UGVDxh3YdWFB52r9C3tM81T6BU7cuusUSxImz0GEYSOYUKk/YzIhkQ6+vc0gHbxQ== +puppeteer@^24.8.2: + version "24.8.2" + resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-24.8.2.tgz#3ee6cfe74e4cc8dc4dd5cb4b553f4d4416df935f" + integrity sha512-Sn6SBPwJ6ASFvQ7knQkR+yG7pcmr4LfXzmoVp3NR0xXyBbPhJa8a8ybtb6fnw1g/DD/2t34//yirubVczko37w== dependencies: - https-proxy-agent "5.0.1" - progress "2.0.3" - proxy-from-env "1.1.0" - puppeteer-core "18.2.1" + "@puppeteer/browsers" "2.10.4" + chromium-bidi "5.1.0" + cosmiconfig "^9.0.0" + devtools-protocol "0.0.1439962" + puppeteer-core "24.8.2" + typed-query-selector "^2.12.0" pure-rand@^6.0.0: version "6.0.4" @@ -5709,6 +5934,11 @@ semver@^6.0.0, semver@^6.3.0, semver@^6.3.1: resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== +semver@^7.7.1: + version "7.7.2" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.7.2.tgz#67d99fdcd35cec21e6f8b87a7fd515a33f982b58" + integrity sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA== + send@0.18.0: version "0.18.0" resolved "https://registry.yarnpkg.com/send/-/send-0.18.0.tgz#670167cc654b05f5aa4a767f9113bb371bc706be" @@ -5834,6 +6064,28 @@ slice-ansi@^4.0.0: astral-regex "^2.0.0" is-fullwidth-code-point "^3.0.0" +smart-buffer@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/smart-buffer/-/smart-buffer-4.2.0.tgz#6e1d71fa4f18c05f7d0ff216dd16a481d0e8d9ae" + integrity sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg== + +socks-proxy-agent@^8.0.5: + version "8.0.5" + resolved "https://registry.yarnpkg.com/socks-proxy-agent/-/socks-proxy-agent-8.0.5.tgz#b9cdb4e7e998509d7659d689ce7697ac21645bee" + integrity sha512-HehCEsotFqbPW9sJ8WVYB6UbmIMv7kUUORIF2Nncq4VQvBfNBLibW9YZR5dlYCSUhwcD628pRllm7n+E+YTzJw== + dependencies: + agent-base "^7.1.2" + debug "^4.3.4" + socks "^2.8.3" + +socks@^2.8.3: + version "2.8.4" + resolved "https://registry.yarnpkg.com/socks/-/socks-2.8.4.tgz#07109755cdd4da03269bda4725baa061ab56d5cc" + integrity sha512-D3YaD0aRxR3mEcqnidIs7ReYJFVzWdd6fXJYUM8ixcQcJRGTka/b3saV0KflYhyVJXKhb947GndU35SxYNResQ== + dependencies: + ip-address "^9.0.5" + smart-buffer "^4.2.0" + source-map-support@0.5.13: version "0.5.13" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.13.tgz#31b24a9c2e73c2de85066c0feb7d44767ed52932" @@ -5842,7 +6094,7 @@ source-map-support@0.5.13: buffer-from "^1.0.0" source-map "^0.6.0" -source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.0: +source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.0, source-map@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== @@ -5889,6 +6141,11 @@ split2@^3.0.0, split2@^3.2.2: dependencies: readable-stream "^3.0.0" +sprintf-js@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.1.3.tgz#4914b903a2f8b685d17fdf78a70e917e872e444a" + integrity sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA== + sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" @@ -5957,6 +6214,16 @@ streaming-json-stringify@3: json-stringify-safe "5" readable-stream "2" +streamx@^2.15.0, streamx@^2.21.0: + version "2.22.0" + resolved "https://registry.yarnpkg.com/streamx/-/streamx-2.22.0.tgz#cd7b5e57c95aaef0ff9b2aef7905afa62ec6e4a7" + integrity sha512-sLh1evHOzBy/iWRiR6d1zRcLao4gGZr3C1kzNz4fopCOKJb6xD9ub8Mpi9Mr1R6id5o43S+d93fI48UC5uM9aw== + dependencies: + fast-fifo "^1.3.2" + text-decoder "^1.1.0" + optionalDependencies: + bare-events "^2.2.0" + string-length@^4.0.1: version "4.0.2" resolved "https://registry.yarnpkg.com/string-length/-/string-length-4.0.2.tgz#a8a8dc7bd5c1a82b9b3c8b87e125f66871b6e57a" @@ -6102,6 +6369,17 @@ tar-fs@2.1.1: pump "^3.0.0" tar-stream "^2.1.4" +tar-fs@^3.0.8: + version "3.0.8" + resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-3.0.8.tgz#8f62012537d5ff89252d01e48690dc4ebed33ab7" + integrity sha512-ZoROL70jptorGAlgAYiLoBLItEKw/fUxg9BSYK/dF/GAGYFJOJJJMvjPAKDJraCXFwadD456FCuvLWgfhMsPwg== + dependencies: + pump "^3.0.0" + tar-stream "^3.1.5" + optionalDependencies: + bare-fs "^4.0.1" + bare-path "^3.0.0" + tar-stream@^2.1.4: version "2.2.0" resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-2.2.0.tgz#acad84c284136b060dc3faa64474aa9aebd77287" @@ -6113,6 +6391,15 @@ tar-stream@^2.1.4: inherits "^2.0.3" readable-stream "^3.1.1" +tar-stream@^3.1.5: + version "3.1.7" + resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-3.1.7.tgz#24b3fb5eabada19fe7338ed6d26e5f7c482e792b" + integrity sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ== + dependencies: + b4a "^1.6.4" + fast-fifo "^1.2.0" + streamx "^2.15.0" + test-exclude@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-6.0.0.tgz#04a8698661d805ea6fa293b6cb9e63ac044ef15e" @@ -6122,6 +6409,13 @@ test-exclude@^6.0.0: glob "^7.1.4" minimatch "^3.0.4" +text-decoder@^1.1.0: + version "1.2.3" + resolved "https://registry.yarnpkg.com/text-decoder/-/text-decoder-1.2.3.tgz#b19da364d981b2326d5f43099c310cc80d770c65" + integrity sha512-3/o9z3X0X0fTupwsYvR03pJ/DjWuqqrfwBgTQzdWDiQSm9KitAyz/9WqsT2JQW7KV2m+bC2ol/zqpW37NHxLaA== + dependencies: + b4a "^1.6.4" + text-extensions@^1.0.0: version "1.9.0" resolved "https://registry.yarnpkg.com/text-extensions/-/text-extensions-1.9.0.tgz#1853e45fee39c945ce6f6c36b2d659b5aabc2a26" @@ -6256,6 +6550,11 @@ tslib@^1.9.3: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== +tslib@^2.0.1: + version "2.8.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" + integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== + tslib@^2.1.0: version "2.6.2" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" @@ -6367,6 +6666,11 @@ typed-array-length@^1.0.4: for-each "^0.3.3" is-typed-array "^1.1.9" +typed-query-selector@^2.12.0: + version "2.12.0" + resolved "https://registry.yarnpkg.com/typed-query-selector/-/typed-query-selector-2.12.0.tgz#92b65dbc0a42655fccf4aeb1a08b1dddce8af5f2" + integrity sha512-SbklCd1F0EiZOyPiW192rrHZzZ5sBijB6xM+cpmrwDqObvdtunOHHIk9fCGsoK5JVIYXoyEp4iEdE3upFH3PAg== + typedarray-to-buffer@^3.1.5: version "3.1.5" resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080" @@ -6646,6 +6950,11 @@ ws@^7.0.0: resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.9.tgz#54fa7db29f4c7cec68b1ddd3a89de099942bb591" integrity sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q== +ws@^8.18.2: + version "8.18.2" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.2.tgz#42738b2be57ced85f46154320aabb51ab003705a" + integrity sha512-DMricUmwGZUVr++AEAe2uiVM7UoO9MAVZMDu05UQOaUII0lp+zOzLLU4Xqh/JvTqklB1T4uELaaPBKyjE1r4fQ== + xdg-basedir@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-4.0.0.tgz#4bc8d9984403696225ef83a1573cbbcb4e79db13" @@ -6676,7 +6985,7 @@ yargs-parser@^21.0.0, yargs-parser@^21.1.1: resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35" integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw== -yargs@^17.0.0, yargs@^17.3.1: +yargs@^17.0.0, yargs@^17.3.1, yargs@^17.7.2: version "17.7.2" resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269" integrity sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w== @@ -6711,3 +7020,8 @@ yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== + +zod@^3.24.1: + version "3.24.4" + resolved "https://registry.yarnpkg.com/zod/-/zod-3.24.4.tgz#e2e2cca5faaa012d76e527d0d36622e0a90c315f" + integrity sha512-OdqJE9UDRPwWsrHjLN2F8bPxvwJBK22EHLWtanu0LSYr5YqzsaaW3RMgmjwr8Rypg5k+meEJdSPXJZXE/yqOMg== From 20c9d012dc421405a9bfabae9c79cd1ed4abe29b Mon Sep 17 00:00:00 2001 From: Suzanne Aitchison Date: Wed, 14 May 2025 10:42:01 +0100 Subject: [PATCH 02/21] updated to work with onPostBuild step also --- src/lib/run-audit-with-server/index.js | 6 +++--- src/run-lighthouse.js | 16 ++++++---------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/lib/run-audit-with-server/index.js b/src/lib/run-audit-with-server/index.js index 940132a5..4818a8eb 100644 --- a/src/lib/run-audit-with-server/index.js +++ b/src/lib/run-audit-with-server/index.js @@ -1,7 +1,7 @@ import { join } from 'path'; import { formatResults } from '../../format.js'; -import { runLighthouse } from '../../run-lighthouse.js'; +import { runLighthouse, getBrowserPath } from '../../run-lighthouse.js'; import persistResults from '../persist-results/index.js'; import getServer from '../get-server/index.js'; @@ -16,13 +16,13 @@ const runAuditWithServer = async ({ try { const { server } = getServer({ serveDir: serveDir, auditUrl: url }); - + const browserPath = await getBrowserPath(); const { error, results } = await new Promise((resolve) => { const instance = server.listen(async () => { try { const fullPath = path ? `${server.url}/${path}` : server.url; - const results = await runLighthouse("PLACEHOLDER", fullPath, settings); + const results = await runLighthouse(browserPath, fullPath, settings); resolve({ error: false, results }); } catch (error) { resolve({ error }); diff --git a/src/run-lighthouse.js b/src/run-lighthouse.js index 6587ded2..ec40b8bd 100644 --- a/src/run-lighthouse.js +++ b/src/run-lighthouse.js @@ -2,22 +2,18 @@ import puppeteer from 'puppeteer'; import lighthouse from 'lighthouse'; import log from 'lighthouse-logger'; -// export const getBrowserPath = async () => { -// const browserFetcher = new BrowserFetcher(); -// const revisions = await browserFetcher.localRevisions(); -// if (revisions.length <= 0) { -// throw new Error('Could not find local browser'); -// } -// const info = await browserFetcher.revisionInfo(revisions[0]); -// return info.executablePath; -// }; +export const getBrowserPath = async () => { + // In newer Puppeteer versions, we can get the executable path directly + return puppeteer.executablePath(); +}; -export const runLighthouse = async (url, settings) => { +export const runLighthouse = async (browserPath, url, settings) => { let chrome; try { const logLevel = 'error'; log.setLevel(logLevel); chrome = await puppeteer.launch({ + executablePath: browserPath, args: [ '--headless', '--no-sandbox', From 5dc24d085d54e2d5d64e3d9131882d66dc81c25a Mon Sep 17 00:00:00 2001 From: Suzanne Aitchison Date: Wed, 14 May 2025 10:46:35 +0100 Subject: [PATCH 03/21] format --- src/lib/run-audit-with-url/index.js | 4 ++-- src/lib/run-event/index.js | 3 ++- src/run-lighthouse.js | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/lib/run-audit-with-url/index.js b/src/lib/run-audit-with-url/index.js index 29d462fe..0db9de65 100644 --- a/src/lib/run-audit-with-url/index.js +++ b/src/lib/run-audit-with-url/index.js @@ -17,7 +17,7 @@ const runAuditWithUrl = async ({ path = '', url, thresholds, settings }) => { const { error, results } = await getResults(); if (error) { - console.log("error line 22 run audit with url", error) + console.log('error line 22 run audit with url', error); return { error }; } else { const { summary, shortSummary, details, report, errors, runtimeError } = @@ -36,7 +36,7 @@ const runAuditWithUrl = async ({ path = '', url, thresholds, settings }) => { }; } } catch (error) { - console.log("error line 41 run audit with url", error) + console.log('error line 41 run audit with url', error); return { error }; } }; diff --git a/src/lib/run-event/index.js b/src/lib/run-event/index.js index 2c1376f0..6662fdd8 100644 --- a/src/lib/run-event/index.js +++ b/src/lib/run-event/index.js @@ -17,7 +17,8 @@ const runEvent = async ({ } = {}) => { const isOnSuccess = event === 'onSuccess'; - const deployUrl = 'https://68244ec43a5a6b46e855abe0--testing-secret-scanning-ui.netlify.app/'; + const deployUrl = + 'https://68244ec43a5a6b46e855abe0--testing-secret-scanning-ui.netlify.app/'; // If we don't have the deploy URL to test against, we can't run Lighthouse onSuccess. // If running locally, ensure you have a DEPLOY_URL set in your .env file diff --git a/src/run-lighthouse.js b/src/run-lighthouse.js index ec40b8bd..19901bcd 100644 --- a/src/run-lighthouse.js +++ b/src/run-lighthouse.js @@ -1,4 +1,4 @@ -import puppeteer from 'puppeteer'; +import puppeteer from 'puppeteer'; import lighthouse from 'lighthouse'; import log from 'lighthouse-logger'; @@ -19,7 +19,7 @@ export const runLighthouse = async (browserPath, url, settings) => { '--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage', - '--remote-debugging-port=0' + '--remote-debugging-port=0', ], logLevel, }); From 75fb12f489fbba73b27a17924c19f3934d464885 Mon Sep 17 00:00:00 2001 From: Suzanne Aitchison Date: Wed, 14 May 2025 11:02:46 +0100 Subject: [PATCH 04/21] fix test mocks --- src/e2e/mocks/puppeteer.js | 6 +++--- src/lib/run-audit-with-server/index.js | 6 ++---- src/lib/run-event/index.js | 4 +--- src/run-lighthouse.js | 7 +------ 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/e2e/mocks/puppeteer.js b/src/e2e/mocks/puppeteer.js index e6157c39..6f5e4402 100644 --- a/src/e2e/mocks/puppeteer.js +++ b/src/e2e/mocks/puppeteer.js @@ -2,9 +2,9 @@ const puppeteer = () => jest.unstable_mockModule('puppeteer', () => { return { default: { - createBrowserFetcher: () => ({ - localRevisions: () => Promise.resolve(['123']), - revisionInfo: () => Promise.resolve({ executablePath: 'path' }), + launch: () => Promise.resolve({ + wsEndpoint: () => 'ws://127.0.0.1:9222/devtools/browser/xyz', + close: () => Promise.resolve(), }), }, }; diff --git a/src/lib/run-audit-with-server/index.js b/src/lib/run-audit-with-server/index.js index 4818a8eb..ffc70e15 100644 --- a/src/lib/run-audit-with-server/index.js +++ b/src/lib/run-audit-with-server/index.js @@ -1,7 +1,7 @@ import { join } from 'path'; import { formatResults } from '../../format.js'; -import { runLighthouse, getBrowserPath } from '../../run-lighthouse.js'; +import { runLighthouse } from '../../run-lighthouse.js'; import persistResults from '../persist-results/index.js'; import getServer from '../get-server/index.js'; @@ -16,13 +16,11 @@ const runAuditWithServer = async ({ try { const { server } = getServer({ serveDir: serveDir, auditUrl: url }); - const browserPath = await getBrowserPath(); - const { error, results } = await new Promise((resolve) => { const instance = server.listen(async () => { try { const fullPath = path ? `${server.url}/${path}` : server.url; - const results = await runLighthouse(browserPath, fullPath, settings); + const results = await runLighthouse(fullPath, settings); resolve({ error: false, results }); } catch (error) { resolve({ error }); diff --git a/src/lib/run-event/index.js b/src/lib/run-event/index.js index 6662fdd8..0409e403 100644 --- a/src/lib/run-event/index.js +++ b/src/lib/run-event/index.js @@ -17,8 +17,7 @@ const runEvent = async ({ } = {}) => { const isOnSuccess = event === 'onSuccess'; - const deployUrl = - 'https://68244ec43a5a6b46e855abe0--testing-secret-scanning-ui.netlify.app/'; + const deployUrl = process.env.DEPLOY_URL; // If we don't have the deploy URL to test against, we can't run Lighthouse onSuccess. // If running locally, ensure you have a DEPLOY_URL set in your .env file @@ -68,7 +67,6 @@ const runEvent = async ({ }); console.log(startMessage); - console.log('*** url', url); const runner = isOnSuccess ? runAuditWithUrl : runAuditWithServer; const { errors, summary, shortSummary, details, report, runtimeError } = diff --git a/src/run-lighthouse.js b/src/run-lighthouse.js index 19901bcd..98317305 100644 --- a/src/run-lighthouse.js +++ b/src/run-lighthouse.js @@ -2,18 +2,13 @@ import puppeteer from 'puppeteer'; import lighthouse from 'lighthouse'; import log from 'lighthouse-logger'; -export const getBrowserPath = async () => { - // In newer Puppeteer versions, we can get the executable path directly - return puppeteer.executablePath(); -}; -export const runLighthouse = async (browserPath, url, settings) => { +export const runLighthouse = async (url, settings) => { let chrome; try { const logLevel = 'error'; log.setLevel(logLevel); chrome = await puppeteer.launch({ - executablePath: browserPath, args: [ '--headless', '--no-sandbox', From 6dab3099552d31b933cc93422ce5203c929a540e Mon Sep 17 00:00:00 2001 From: Suzanne Aitchison Date: Wed, 14 May 2025 11:35:58 +0100 Subject: [PATCH 05/21] try different launch args --- src/lib/persist-results/index.js | 13 +++++++++++-- src/run-lighthouse.js | 6 +++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/lib/persist-results/index.js b/src/lib/persist-results/index.js index 75d6a48c..d50ac3b9 100644 --- a/src/lib/persist-results/index.js +++ b/src/lib/persist-results/index.js @@ -2,8 +2,17 @@ import { dirname } from 'path'; import { mkdir, writeFile } from 'fs/promises'; const persistResults = async ({ report, path }) => { - await mkdir(dirname(path), { recursive: true }); - await writeFile(path, report); + console.log('Attempting to persist report to:', path); + console.log('Report directory:', dirname(path)); + + try { + await mkdir(dirname(path), { recursive: true }); + await writeFile(path, report); + console.log('Successfully wrote report to:', path); + } catch (error) { + console.error('Failed to persist report:', error); + throw error; // Re-throw to maintain existing error handling + } }; export default persistResults; diff --git a/src/run-lighthouse.js b/src/run-lighthouse.js index 98317305..8c2aeeb9 100644 --- a/src/run-lighthouse.js +++ b/src/run-lighthouse.js @@ -10,13 +10,17 @@ export const runLighthouse = async (url, settings) => { log.setLevel(logLevel); chrome = await puppeteer.launch({ args: [ - '--headless', + '--headless=new', '--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage', '--remote-debugging-port=0', + '--disable-software-rasterizer', + '--disable-setuid-sandbox', + '--no-zygote', ], logLevel, + ignoreDefaultArgs: ['--disable-extensions'], }); // Get the debugging port from the browser's websocket endpoint From 15ce11d4d29efdd9e4284d845d6680f14ef20c74 Mon Sep 17 00:00:00 2001 From: Suzanne Aitchison Date: Wed, 14 May 2025 12:02:21 +0100 Subject: [PATCH 06/21] dont use puppeteer? --- src/run-lighthouse.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/run-lighthouse.js b/src/run-lighthouse.js index 8c2aeeb9..4518c5c6 100644 --- a/src/run-lighthouse.js +++ b/src/run-lighthouse.js @@ -1,45 +1,44 @@ -import puppeteer from 'puppeteer'; import lighthouse from 'lighthouse'; +import chromeLauncher from 'chrome-launcher'; import log from 'lighthouse-logger'; - export const runLighthouse = async (url, settings) => { let chrome; try { - const logLevel = 'error'; + const logLevel = settings?.logLevel || 'error'; log.setLevel(logLevel); - chrome = await puppeteer.launch({ - args: [ + + // Launch Chrome using chrome-launcher + chrome = await chromeLauncher.launch({ + chromeFlags: [ '--headless=new', '--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage', - '--remote-debugging-port=0', '--disable-software-rasterizer', '--disable-setuid-sandbox', '--no-zygote', ], logLevel, - ignoreDefaultArgs: ['--disable-extensions'], + handleSIGINT: true, }); - // Get the debugging port from the browser's websocket endpoint - const browserWSEndpoint = chrome.wsEndpoint(); - const port = parseInt(browserWSEndpoint.split(':')[2].split('/')[0], 10); - const results = await lighthouse( url, { - port, + port: chrome.port, output: 'html', logLevel, + onlyCategories: settings?.onlyCategories, + locale: settings?.locale || 'en-US', + formFactor: settings?.preset === 'desktop' ? 'desktop' : 'mobile', }, settings, ); return results; } finally { if (chrome) { - await chrome.close(); + await chrome.kill(); } } }; From 868de7b6824c57d2d001955ab0855575da7b3440 Mon Sep 17 00:00:00 2001 From: Suzanne Aitchison Date: Wed, 14 May 2025 12:09:35 +0100 Subject: [PATCH 07/21] wholly puppeteer --- src/run-lighthouse.js | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/run-lighthouse.js b/src/run-lighthouse.js index 4518c5c6..8c6217eb 100644 --- a/src/run-lighthouse.js +++ b/src/run-lighthouse.js @@ -1,32 +1,38 @@ import lighthouse from 'lighthouse'; -import chromeLauncher from 'chrome-launcher'; +import puppeteer from 'puppeteer'; import log from 'lighthouse-logger'; export const runLighthouse = async (url, settings) => { - let chrome; + let browser; try { const logLevel = settings?.logLevel || 'error'; log.setLevel(logLevel); - // Launch Chrome using chrome-launcher - chrome = await chromeLauncher.launch({ - chromeFlags: [ - '--headless=new', + // Launch Chrome using Puppeteer with CI-friendly flags + browser = await puppeteer.launch({ + headless: 'new', + args: [ '--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage', '--disable-software-rasterizer', '--disable-setuid-sandbox', '--no-zygote', + '--disable-web-security', + '--allow-running-insecure-content', + '--disable-features=IsolateOrigins,site-per-process', ], - logLevel, - handleSIGINT: true, + ignoreDefaultArgs: ['--enable-automation'], }); + // Get the browser's websocket endpoint and extract the port + const browserWSEndpoint = browser.wsEndpoint(); + const port = parseInt(browserWSEndpoint.split(':')[2].split('/')[0], 10); + const results = await lighthouse( url, { - port: chrome.port, + port, output: 'html', logLevel, onlyCategories: settings?.onlyCategories, @@ -37,8 +43,8 @@ export const runLighthouse = async (url, settings) => { ); return results; } finally { - if (chrome) { - await chrome.kill(); + if (browser) { + await browser.close(); } } }; From a1280b90191596edd514a9ad4761a7d523566bbf Mon Sep 17 00:00:00 2001 From: Suzanne Aitchison Date: Wed, 14 May 2025 12:13:19 +0100 Subject: [PATCH 08/21] flags --- src/run-lighthouse.js | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/run-lighthouse.js b/src/run-lighthouse.js index 8c6217eb..9f904b90 100644 --- a/src/run-lighthouse.js +++ b/src/run-lighthouse.js @@ -1,17 +1,17 @@ import lighthouse from 'lighthouse'; -import puppeteer from 'puppeteer'; +import chromeLauncher from 'chrome-launcher'; import log from 'lighthouse-logger'; export const runLighthouse = async (url, settings) => { - let browser; + let chrome; try { const logLevel = settings?.logLevel || 'error'; log.setLevel(logLevel); - // Launch Chrome using Puppeteer with CI-friendly flags - browser = await puppeteer.launch({ - headless: 'new', - args: [ + // Launch Chrome using chrome-launcher with additional CI-friendly flags + chrome = await chromeLauncher.launch({ + chromeFlags: [ + '--headless=new', '--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage', @@ -21,18 +21,15 @@ export const runLighthouse = async (url, settings) => { '--disable-web-security', '--allow-running-insecure-content', '--disable-features=IsolateOrigins,site-per-process', + '--single-process', // Try running in a single process ], - ignoreDefaultArgs: ['--enable-automation'], + handleSIGINT: true, + chromePath: process.env.CHROME_PATH, // Allow custom Chrome path in CI }); - - // Get the browser's websocket endpoint and extract the port - const browserWSEndpoint = browser.wsEndpoint(); - const port = parseInt(browserWSEndpoint.split(':')[2].split('/')[0], 10); - const results = await lighthouse( url, { - port, + port: chrome.port, output: 'html', logLevel, onlyCategories: settings?.onlyCategories, @@ -43,8 +40,8 @@ export const runLighthouse = async (url, settings) => { ); return results; } finally { - if (browser) { - await browser.close(); + if (chrome) { + await chrome.kill(); } } }; From 440eb6a23439249aaf1d9c959aa194d87d000fd1 Mon Sep 17 00:00:00 2001 From: Suzanne Aitchison Date: Wed, 14 May 2025 12:16:03 +0100 Subject: [PATCH 09/21] logging --- src/run-lighthouse.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/run-lighthouse.js b/src/run-lighthouse.js index 9f904b90..bf6baf2a 100644 --- a/src/run-lighthouse.js +++ b/src/run-lighthouse.js @@ -5,27 +5,24 @@ import log from 'lighthouse-logger'; export const runLighthouse = async (url, settings) => { let chrome; try { - const logLevel = settings?.logLevel || 'error'; + // Set debug level logging to see what's happening + const logLevel = 'info'; log.setLevel(logLevel); - // Launch Chrome using chrome-launcher with additional CI-friendly flags + console.log('Launching Chrome...'); + // Launch Chrome with minimal flags chrome = await chromeLauncher.launch({ chromeFlags: [ '--headless=new', '--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage', - '--disable-software-rasterizer', - '--disable-setuid-sandbox', - '--no-zygote', - '--disable-web-security', - '--allow-running-insecure-content', - '--disable-features=IsolateOrigins,site-per-process', - '--single-process', // Try running in a single process ], + logLevel, handleSIGINT: true, - chromePath: process.env.CHROME_PATH, // Allow custom Chrome path in CI }); + console.log('Chrome launched on port:', chrome.port); + console.log('Starting Lighthouse audit for URL:', url); const results = await lighthouse( url, { @@ -38,9 +35,14 @@ export const runLighthouse = async (url, settings) => { }, settings, ); + console.log('Lighthouse audit completed'); return results; + } catch (error) { + console.error('Error during Lighthouse run:', error); + throw error; } finally { if (chrome) { + console.log('Cleaning up Chrome...'); await chrome.kill(); } } From 156f3b0a747d57839b68eb34cff4d3ded947871c Mon Sep 17 00:00:00 2001 From: Suzanne Aitchison Date: Wed, 14 May 2025 12:25:01 +0100 Subject: [PATCH 10/21] look for installation --- src/run-lighthouse.js | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/run-lighthouse.js b/src/run-lighthouse.js index bf6baf2a..e5e71dfa 100644 --- a/src/run-lighthouse.js +++ b/src/run-lighthouse.js @@ -2,16 +2,21 @@ import lighthouse from 'lighthouse'; import chromeLauncher from 'chrome-launcher'; import log from 'lighthouse-logger'; +// Common Chrome paths in CI environments +const CI_CHROME_PATHS = [ + '/usr/bin/google-chrome', + '/usr/bin/google-chrome-stable', +]; + export const runLighthouse = async (url, settings) => { let chrome; try { - // Set debug level logging to see what's happening - const logLevel = 'info'; + const logLevel = settings?.logLevel || 'error'; log.setLevel(logLevel); console.log('Launching Chrome...'); // Launch Chrome with minimal flags - chrome = await chromeLauncher.launch({ + const launchOptions = { chromeFlags: [ '--headless=new', '--no-sandbox', @@ -20,7 +25,29 @@ export const runLighthouse = async (url, settings) => { ], logLevel, handleSIGINT: true, - }); + }; + + // In CI, Chrome might be installed in a custom location + if (process.env.CHROME_PATH) { + console.log(`Using Chrome from: ${process.env.CHROME_PATH}`); + launchOptions.chromePath = process.env.CHROME_PATH; + } else { + // Try common CI paths + for (const path of CI_CHROME_PATHS) { + try { + const { execSync } = await import('child_process'); + execSync(`test -f ${path}`); + launchOptions.chromePath = path; + console.log(`Found Chrome at: ${path}`); + break; + } catch (e) { + // Path doesn't exist, try next one + continue; + } + } + } + + chrome = await chromeLauncher.launch(launchOptions); console.log('Chrome launched on port:', chrome.port); console.log('Starting Lighthouse audit for URL:', url); const results = await lighthouse( From b6f6fe0b8dd9a6573e22e593366edd9425f2fdef Mon Sep 17 00:00:00 2001 From: Suzanne Aitchison Date: Wed, 14 May 2025 12:27:49 +0100 Subject: [PATCH 11/21] let launcher find path --- src/run-lighthouse.js | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/src/run-lighthouse.js b/src/run-lighthouse.js index e5e71dfa..04508e57 100644 --- a/src/run-lighthouse.js +++ b/src/run-lighthouse.js @@ -2,12 +2,6 @@ import lighthouse from 'lighthouse'; import chromeLauncher from 'chrome-launcher'; import log from 'lighthouse-logger'; -// Common Chrome paths in CI environments -const CI_CHROME_PATHS = [ - '/usr/bin/google-chrome', - '/usr/bin/google-chrome-stable', -]; - export const runLighthouse = async (url, settings) => { let chrome; try { @@ -27,24 +21,13 @@ export const runLighthouse = async (url, settings) => { handleSIGINT: true, }; - // In CI, Chrome might be installed in a custom location + // Let chrome-launcher find Chrome in the environment if (process.env.CHROME_PATH) { - console.log(`Using Chrome from: ${process.env.CHROME_PATH}`); + console.log(`Using Chrome from environment: ${process.env.CHROME_PATH}`); launchOptions.chromePath = process.env.CHROME_PATH; } else { - // Try common CI paths - for (const path of CI_CHROME_PATHS) { - try { - const { execSync } = await import('child_process'); - execSync(`test -f ${path}`); - launchOptions.chromePath = path; - console.log(`Found Chrome at: ${path}`); - break; - } catch (e) { - // Path doesn't exist, try next one - continue; - } - } + // Let chrome-launcher find Chrome automatically + console.log('Letting chrome-launcher find Chrome...'); } chrome = await chromeLauncher.launch(launchOptions); From a7cbc2caac80699d7af60f74586ade79ba49bef4 Mon Sep 17 00:00:00 2001 From: Suzanne Aitchison Date: Wed, 14 May 2025 12:32:46 +0100 Subject: [PATCH 12/21] is chrome available now? --- src/run-lighthouse.js | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/run-lighthouse.js b/src/run-lighthouse.js index 04508e57..b62c9cf1 100644 --- a/src/run-lighthouse.js +++ b/src/run-lighthouse.js @@ -1,6 +1,7 @@ import lighthouse from 'lighthouse'; import chromeLauncher from 'chrome-launcher'; import log from 'lighthouse-logger'; +import puppeteer from 'puppeteer'; export const runLighthouse = async (url, settings) => { let chrome; @@ -21,13 +22,26 @@ export const runLighthouse = async (url, settings) => { handleSIGINT: true, }; - // Let chrome-launcher find Chrome in the environment - if (process.env.CHROME_PATH) { - console.log(`Using Chrome from environment: ${process.env.CHROME_PATH}`); - launchOptions.chromePath = process.env.CHROME_PATH; - } else { - // Let chrome-launcher find Chrome automatically - console.log('Letting chrome-launcher find Chrome...'); + // Get browser executable from puppeteer + const browser = await puppeteer.launch({ + headless: 'new', + args: ['--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage'] + }); + + try { + const browserPath = browser.executablePath(); + console.log(`Using Chrome from puppeteer: ${browserPath}`); + launchOptions.chromePath = browserPath; + await browser.close(); + } catch (error) { + await browser.close(); + // Fallback to environment variable if puppeteer's Chrome is not available + if (process.env.CHROME_PATH) { + console.log(`Using Chrome from environment: ${process.env.CHROME_PATH}`); + launchOptions.chromePath = process.env.CHROME_PATH; + } else { + console.log('Letting chrome-launcher find Chrome...'); + } } chrome = await chromeLauncher.launch(launchOptions); From 049ce659833afabfd1d82236af405e3337865144 Mon Sep 17 00:00:00 2001 From: Suzanne Aitchison Date: Wed, 14 May 2025 12:35:01 +0100 Subject: [PATCH 13/21] try installing chrome --- src/run-lighthouse.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/run-lighthouse.js b/src/run-lighthouse.js index b62c9cf1..33421019 100644 --- a/src/run-lighthouse.js +++ b/src/run-lighthouse.js @@ -2,6 +2,7 @@ import lighthouse from 'lighthouse'; import chromeLauncher from 'chrome-launcher'; import log from 'lighthouse-logger'; import puppeteer from 'puppeteer'; +import { install } from '@puppeteer/browsers'; export const runLighthouse = async (url, settings) => { let chrome; @@ -22,19 +23,25 @@ export const runLighthouse = async (url, settings) => { handleSIGINT: true, }; - // Get browser executable from puppeteer - const browser = await puppeteer.launch({ - headless: 'new', - args: ['--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage'] - }); - + // Install Chrome if needed and get its path try { + console.log('Installing Chrome via puppeteer...'); + await install({ + browser: 'chrome', + buildId: 'stable' + }); + + const browser = await puppeteer.launch({ + headless: 'new', + args: ['--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage'] + }); + const browserPath = browser.executablePath(); console.log(`Using Chrome from puppeteer: ${browserPath}`); launchOptions.chromePath = browserPath; await browser.close(); } catch (error) { - await browser.close(); + console.log('Error installing/launching Chrome:', error.message); // Fallback to environment variable if puppeteer's Chrome is not available if (process.env.CHROME_PATH) { console.log(`Using Chrome from environment: ${process.env.CHROME_PATH}`); From 422795eb642e1ade5861cb8441a38b455deb4b7b Mon Sep 17 00:00:00 2001 From: Suzanne Aitchison Date: Wed, 14 May 2025 12:39:23 +0100 Subject: [PATCH 14/21] puppeteer core --- package.json | 2 +- src/run-lighthouse.js | 25 +++++++++------------ yarn.lock | 51 ++++++++++--------------------------------- 3 files changed, 23 insertions(+), 55 deletions(-) diff --git a/package.json b/package.json index 65dc352a..f6b8d7c2 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "express": "^4.17.1", "html-minifier": "^4.0.0", "lighthouse": "^9.6.3", - "puppeteer": "^24.8.2" + "puppeteer-core": "^24.8.2" }, "engines": { "node": ">=18.14.0" diff --git a/src/run-lighthouse.js b/src/run-lighthouse.js index 33421019..d757b051 100644 --- a/src/run-lighthouse.js +++ b/src/run-lighthouse.js @@ -1,8 +1,7 @@ import lighthouse from 'lighthouse'; import chromeLauncher from 'chrome-launcher'; import log from 'lighthouse-logger'; -import puppeteer from 'puppeteer'; -import { install } from '@puppeteer/browsers'; +import puppeteer from 'puppeteer-core'; export const runLighthouse = async (url, settings) => { let chrome; @@ -23,28 +22,24 @@ export const runLighthouse = async (url, settings) => { handleSIGINT: true, }; - // Install Chrome if needed and get its path + // Launch Chrome using puppeteer-core try { - console.log('Installing Chrome via puppeteer...'); - await install({ - browser: 'chrome', - buildId: 'stable' - }); - + console.log('Launching Chrome with puppeteer-core...'); const browser = await puppeteer.launch({ + channel: 'chrome', headless: 'new', args: ['--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage'] }); - + const browserPath = browser.executablePath(); - console.log(`Using Chrome from puppeteer: ${browserPath}`); - launchOptions.chromePath = browserPath; await browser.close(); + + console.log(`Found Chrome at: ${browserPath}`); + launchOptions.chromePath = browserPath; } catch (error) { - console.log('Error installing/launching Chrome:', error.message); - // Fallback to environment variable if puppeteer's Chrome is not available + console.log('Error launching Chrome with puppeteer:', error.message); if (process.env.CHROME_PATH) { - console.log(`Using Chrome from environment: ${process.env.CHROME_PATH}`); + console.log(`Falling back to CHROME_PATH: ${process.env.CHROME_PATH}`); launchOptions.chromePath = process.env.CHROME_PATH; } else { console.log('Letting chrome-launcher find Chrome...'); diff --git a/yarn.lock b/yarn.lock index 0a12df2d..f4cb3805 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2095,16 +2095,6 @@ cosmiconfig@^8.0.0: parse-json "^5.2.0" path-type "^4.0.0" -cosmiconfig@^9.0.0: - version "9.0.0" - resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-9.0.0.tgz#34c3fc58287b915f3ae905ab6dc3de258b55ad9d" - integrity sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg== - dependencies: - env-paths "^2.2.1" - import-fresh "^3.3.0" - js-yaml "^4.1.0" - parse-json "^5.2.0" - create-jest@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/create-jest/-/create-jest-29.7.0.tgz#a355c5b3cb1e1af02ba177fe7afd7feee49a5320" @@ -2488,11 +2478,6 @@ enquirer@^2.3.6: ansi-colors "^4.1.1" strip-ansi "^6.0.1" -env-paths@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.1.tgz#420399d416ce1fbe9bc0a07c62fa68d67fd0f8f2" - integrity sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A== - error-ex@^1.3.1: version "1.3.2" resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" @@ -5551,18 +5536,6 @@ punycode@^2.1.0, punycode@^2.1.1: resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== -puppeteer-core@24.8.2: - version "24.8.2" - resolved "https://registry.yarnpkg.com/puppeteer-core/-/puppeteer-core-24.8.2.tgz#f3e939e39e001d9933e79d980371e380d9e535c1" - integrity sha512-wNw5cRZOHiFibWc0vdYCYO92QuKTbJ8frXiUfOq/UGJWMqhPoBThTKkV+dJ99YyWfzJ2CfQQ4T1nhhR0h8FlVw== - dependencies: - "@puppeteer/browsers" "2.10.4" - chromium-bidi "5.1.0" - debug "^4.4.0" - devtools-protocol "0.0.1439962" - typed-query-selector "^2.12.0" - ws "^8.18.2" - puppeteer-core@^13.7.0: version "13.7.0" resolved "https://registry.yarnpkg.com/puppeteer-core/-/puppeteer-core-13.7.0.tgz#3344bee3994163f49120a55ddcd144a40575ba5b" @@ -5581,6 +5554,18 @@ puppeteer-core@^13.7.0: unbzip2-stream "1.4.3" ws "8.5.0" +puppeteer-core@^24.8.2: + version "24.8.2" + resolved "https://registry.yarnpkg.com/puppeteer-core/-/puppeteer-core-24.8.2.tgz#f3e939e39e001d9933e79d980371e380d9e535c1" + integrity sha512-wNw5cRZOHiFibWc0vdYCYO92QuKTbJ8frXiUfOq/UGJWMqhPoBThTKkV+dJ99YyWfzJ2CfQQ4T1nhhR0h8FlVw== + dependencies: + "@puppeteer/browsers" "2.10.4" + chromium-bidi "5.1.0" + debug "^4.4.0" + devtools-protocol "0.0.1439962" + typed-query-selector "^2.12.0" + ws "^8.18.2" + puppeteer@18.1.0: version "18.1.0" resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-18.1.0.tgz#7fa53b29f87dfb3192d415f38a46e35b107ec907" @@ -5598,18 +5583,6 @@ puppeteer@18.1.0: unbzip2-stream "1.4.3" ws "8.9.0" -puppeteer@^24.8.2: - version "24.8.2" - resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-24.8.2.tgz#3ee6cfe74e4cc8dc4dd5cb4b553f4d4416df935f" - integrity sha512-Sn6SBPwJ6ASFvQ7knQkR+yG7pcmr4LfXzmoVp3NR0xXyBbPhJa8a8ybtb6fnw1g/DD/2t34//yirubVczko37w== - dependencies: - "@puppeteer/browsers" "2.10.4" - chromium-bidi "5.1.0" - cosmiconfig "^9.0.0" - devtools-protocol "0.0.1439962" - puppeteer-core "24.8.2" - typed-query-selector "^2.12.0" - pure-rand@^6.0.0: version "6.0.4" resolved "https://registry.yarnpkg.com/pure-rand/-/pure-rand-6.0.4.tgz#50b737f6a925468679bff00ad20eade53f37d5c7" From 056c85b9d7ce3958ca9732b3ebc9d4eb769f07e4 Mon Sep 17 00:00:00 2001 From: Suzanne Aitchison Date: Wed, 14 May 2025 14:45:07 +0100 Subject: [PATCH 15/21] another attempt with puppeteer --- package.json | 2 +- src/run-lighthouse.js | 16 +++++--------- yarn.lock | 51 +++++++++++++++++++++++++++++++++---------- 3 files changed, 45 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index f6b8d7c2..ed69e698 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "express": "^4.17.1", "html-minifier": "^4.0.0", "lighthouse": "^9.6.3", - "puppeteer-core": "^24.8.2" + "puppeteer": "24.8.2" }, "engines": { "node": ">=18.14.0" diff --git a/src/run-lighthouse.js b/src/run-lighthouse.js index d757b051..97e21c5b 100644 --- a/src/run-lighthouse.js +++ b/src/run-lighthouse.js @@ -1,7 +1,7 @@ import lighthouse from 'lighthouse'; import chromeLauncher from 'chrome-launcher'; import log from 'lighthouse-logger'; -import puppeteer from 'puppeteer-core'; +import puppeteer from 'puppeteer'; export const runLighthouse = async (url, settings) => { let chrome; @@ -22,11 +22,10 @@ export const runLighthouse = async (url, settings) => { handleSIGINT: true, }; - // Launch Chrome using puppeteer-core + // Launch Chrome using puppeteer try { - console.log('Launching Chrome with puppeteer-core...'); + console.log('Launching Chrome with puppeteer...'); const browser = await puppeteer.launch({ - channel: 'chrome', headless: 'new', args: ['--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage'] }); @@ -37,13 +36,8 @@ export const runLighthouse = async (url, settings) => { console.log(`Found Chrome at: ${browserPath}`); launchOptions.chromePath = browserPath; } catch (error) { - console.log('Error launching Chrome with puppeteer:', error.message); - if (process.env.CHROME_PATH) { - console.log(`Falling back to CHROME_PATH: ${process.env.CHROME_PATH}`); - launchOptions.chromePath = process.env.CHROME_PATH; - } else { - console.log('Letting chrome-launcher find Chrome...'); - } + console.error('Error launching Chrome with puppeteer:', error); + throw error; } chrome = await chromeLauncher.launch(launchOptions); diff --git a/yarn.lock b/yarn.lock index f4cb3805..06c3b825 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2095,6 +2095,16 @@ cosmiconfig@^8.0.0: parse-json "^5.2.0" path-type "^4.0.0" +cosmiconfig@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-9.0.0.tgz#34c3fc58287b915f3ae905ab6dc3de258b55ad9d" + integrity sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg== + dependencies: + env-paths "^2.2.1" + import-fresh "^3.3.0" + js-yaml "^4.1.0" + parse-json "^5.2.0" + create-jest@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/create-jest/-/create-jest-29.7.0.tgz#a355c5b3cb1e1af02ba177fe7afd7feee49a5320" @@ -2478,6 +2488,11 @@ enquirer@^2.3.6: ansi-colors "^4.1.1" strip-ansi "^6.0.1" +env-paths@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.1.tgz#420399d416ce1fbe9bc0a07c62fa68d67fd0f8f2" + integrity sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A== + error-ex@^1.3.1: version "1.3.2" resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" @@ -5536,6 +5551,18 @@ punycode@^2.1.0, punycode@^2.1.1: resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== +puppeteer-core@24.8.2: + version "24.8.2" + resolved "https://registry.yarnpkg.com/puppeteer-core/-/puppeteer-core-24.8.2.tgz#f3e939e39e001d9933e79d980371e380d9e535c1" + integrity sha512-wNw5cRZOHiFibWc0vdYCYO92QuKTbJ8frXiUfOq/UGJWMqhPoBThTKkV+dJ99YyWfzJ2CfQQ4T1nhhR0h8FlVw== + dependencies: + "@puppeteer/browsers" "2.10.4" + chromium-bidi "5.1.0" + debug "^4.4.0" + devtools-protocol "0.0.1439962" + typed-query-selector "^2.12.0" + ws "^8.18.2" + puppeteer-core@^13.7.0: version "13.7.0" resolved "https://registry.yarnpkg.com/puppeteer-core/-/puppeteer-core-13.7.0.tgz#3344bee3994163f49120a55ddcd144a40575ba5b" @@ -5554,18 +5581,6 @@ puppeteer-core@^13.7.0: unbzip2-stream "1.4.3" ws "8.5.0" -puppeteer-core@^24.8.2: - version "24.8.2" - resolved "https://registry.yarnpkg.com/puppeteer-core/-/puppeteer-core-24.8.2.tgz#f3e939e39e001d9933e79d980371e380d9e535c1" - integrity sha512-wNw5cRZOHiFibWc0vdYCYO92QuKTbJ8frXiUfOq/UGJWMqhPoBThTKkV+dJ99YyWfzJ2CfQQ4T1nhhR0h8FlVw== - dependencies: - "@puppeteer/browsers" "2.10.4" - chromium-bidi "5.1.0" - debug "^4.4.0" - devtools-protocol "0.0.1439962" - typed-query-selector "^2.12.0" - ws "^8.18.2" - puppeteer@18.1.0: version "18.1.0" resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-18.1.0.tgz#7fa53b29f87dfb3192d415f38a46e35b107ec907" @@ -5583,6 +5598,18 @@ puppeteer@18.1.0: unbzip2-stream "1.4.3" ws "8.9.0" +puppeteer@24.8.2: + version "24.8.2" + resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-24.8.2.tgz#3ee6cfe74e4cc8dc4dd5cb4b553f4d4416df935f" + integrity sha512-Sn6SBPwJ6ASFvQ7knQkR+yG7pcmr4LfXzmoVp3NR0xXyBbPhJa8a8ybtb6fnw1g/DD/2t34//yirubVczko37w== + dependencies: + "@puppeteer/browsers" "2.10.4" + chromium-bidi "5.1.0" + cosmiconfig "^9.0.0" + devtools-protocol "0.0.1439962" + puppeteer-core "24.8.2" + typed-query-selector "^2.12.0" + pure-rand@^6.0.0: version "6.0.4" resolved "https://registry.yarnpkg.com/pure-rand/-/pure-rand-6.0.4.tgz#50b737f6a925468679bff00ad20eade53f37d5c7" From b3461852390821c288617ae3fb6f40f1898cf378 Mon Sep 17 00:00:00 2001 From: Suzanne Aitchison Date: Wed, 14 May 2025 14:52:36 +0100 Subject: [PATCH 16/21] cache dir --- src/run-lighthouse.js | 86 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 77 insertions(+), 9 deletions(-) diff --git a/src/run-lighthouse.js b/src/run-lighthouse.js index 97e21c5b..f561fe0e 100644 --- a/src/run-lighthouse.js +++ b/src/run-lighthouse.js @@ -1,3 +1,5 @@ +import fs from 'fs'; + import lighthouse from 'lighthouse'; import chromeLauncher from 'chrome-launcher'; import log from 'lighthouse-logger'; @@ -25,16 +27,82 @@ export const runLighthouse = async (url, settings) => { // Launch Chrome using puppeteer try { console.log('Launching Chrome with puppeteer...'); - const browser = await puppeteer.launch({ - headless: 'new', - args: ['--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage'] - }); - - const browserPath = browser.executablePath(); - await browser.close(); + // Check for Chrome in Netlify environment first + const chromePaths = [ + '/opt/buildhome/.cache/puppeteer/chrome/linux-119.0.6045.105/chrome-linux64/chrome', + '/usr/bin/google-chrome', + '/usr/bin/chromium-browser' + ]; + + let executablePath; + for (const path of chromePaths) { + try { + await fs.promises.access(path); + executablePath = path; + console.log('Found Chrome at:', path); + break; + } catch (err) { + console.log(`Chrome not found at ${path}`); + } + } + + if (!executablePath) { + console.log('No Chrome installation found, using bundled Chromium'); + // Let puppeteer use its bundled version + executablePath = undefined; + } + + // Use /tmp directory which should be writable in Netlify + const cacheDirectory = '/tmp/puppeteer'; + console.log('Using cache directory:', cacheDirectory); + + // Ensure cache directory exists + try { + await fs.promises.mkdir(cacheDirectory, { recursive: true }); + console.log('Cache directory created/verified'); + } catch (err) { + console.warn('Could not create cache directory:', err.message); + } + + // Launch browser for Lighthouse with specific configuration for Netlify + let browser; + try { + const launchConfig = { + headless: 'new', + ...(executablePath ? { executablePath } : {}), + args: [ + '--no-sandbox', + '--disable-gpu', + '--disable-dev-shm-usage', + '--disable-software-rasterizer', + '--disable-setuid-sandbox', + '--no-zygote' + ], + cacheDirectory + }; + + console.log('Launching browser with config:', launchConfig); + browser = await puppeteer.launch(launchConfig); - console.log(`Found Chrome at: ${browserPath}`); - launchOptions.chromePath = browserPath; + // Get browser information + const browserPath = browser.executablePath(); + const wsEndpoint = browser.wsEndpoint(); + + console.log('Browser launched successfully'); + console.log('Browser WebSocket endpoint:', wsEndpoint); + console.log(`Found Chrome at: ${browserPath}`); + + launchOptions.chromePath = browserPath; + } finally { + if (browser) { + try { + await browser.close(); + console.log('Browser closed successfully'); + } catch (err) { + console.warn('Error closing browser:', err); + } + } + } } catch (error) { console.error('Error launching Chrome with puppeteer:', error); throw error; From 54109fd9e9d2422e843e215ae4d67c1b6612591c Mon Sep 17 00:00:00 2001 From: Suzanne Aitchison Date: Wed, 14 May 2025 14:57:01 +0100 Subject: [PATCH 17/21] more logging --- src/run-lighthouse.js | 47 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/src/run-lighthouse.js b/src/run-lighthouse.js index f561fe0e..f15d7207 100644 --- a/src/run-lighthouse.js +++ b/src/run-lighthouse.js @@ -27,6 +27,25 @@ export const runLighthouse = async (url, settings) => { // Launch Chrome using puppeteer try { console.log('Launching Chrome with puppeteer...'); + console.log('Puppeteer package:', JSON.stringify({ + version: puppeteer.version, + browserRevision: puppeteer._preferredRevision + })); + + try { + console.log('Default browser path:', await puppeteer.executablePath()); + } catch (err) { + console.log('Error getting default browser path:', err.message); + } + + try { + const browserFetcher = puppeteer.createBrowserFetcher(); + const revisionInfo = await browserFetcher.download(); + console.log('Browser download info:', revisionInfo); + } catch (err) { + console.log('Error downloading browser:', err.message); + } + // Check for Chrome in Netlify environment first const chromePaths = [ '/opt/buildhome/.cache/puppeteer/chrome/linux-119.0.6045.105/chrome-linux64/chrome', @@ -82,17 +101,35 @@ export const runLighthouse = async (url, settings) => { }; console.log('Launching browser with config:', launchConfig); + + try { + const execPath = await puppeteer.resolveExecutablePath(); + console.log('Resolved executable path:', execPath); + launchConfig.executablePath = execPath; + } catch (err) { + console.log('Error resolving executable path:', err.message); + } + + // Add product and channel settings + launchConfig.product = 'chrome'; + launchConfig.channel = 'chrome'; + + console.log('Final launch config:', launchConfig); browser = await puppeteer.launch(launchConfig); // Get browser information - const browserPath = browser.executablePath(); - const wsEndpoint = browser.wsEndpoint(); - console.log('Browser launched successfully'); + + const wsEndpoint = browser.wsEndpoint(); console.log('Browser WebSocket endpoint:', wsEndpoint); - console.log(`Found Chrome at: ${browserPath}`); - launchOptions.chromePath = browserPath; + // Use the launch config's executable path for chrome-launcher + if (launchConfig.executablePath) { + console.log(`Using Chrome at: ${launchConfig.executablePath}`); + launchOptions.chromePath = launchConfig.executablePath; + } else { + console.log('Using default Chrome path'); + } } finally { if (browser) { try { From 21d1952b056766eb79a82ddc820871cfba8be922 Mon Sep 17 00:00:00 2001 From: Suzanne Aitchison Date: Wed, 14 May 2025 15:00:22 +0100 Subject: [PATCH 18/21] updatw --- src/run-lighthouse.js | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/src/run-lighthouse.js b/src/run-lighthouse.js index f15d7207..d68f0d40 100644 --- a/src/run-lighthouse.js +++ b/src/run-lighthouse.js @@ -27,23 +27,13 @@ export const runLighthouse = async (url, settings) => { // Launch Chrome using puppeteer try { console.log('Launching Chrome with puppeteer...'); - console.log('Puppeteer package:', JSON.stringify({ - version: puppeteer.version, - browserRevision: puppeteer._preferredRevision - })); try { - console.log('Default browser path:', await puppeteer.executablePath()); + // For newer Puppeteer versions, just log the install location + const installDir = process.env.PUPPETEER_CACHE_DIR || '/tmp/puppeteer'; + console.log('Puppeteer install directory:', installDir); } catch (err) { - console.log('Error getting default browser path:', err.message); - } - - try { - const browserFetcher = puppeteer.createBrowserFetcher(); - const revisionInfo = await browserFetcher.download(); - console.log('Browser download info:', revisionInfo); - } catch (err) { - console.log('Error downloading browser:', err.message); + console.log('Error getting Puppeteer info:', err.message); } // Check for Chrome in Netlify environment first @@ -102,18 +92,6 @@ export const runLighthouse = async (url, settings) => { console.log('Launching browser with config:', launchConfig); - try { - const execPath = await puppeteer.resolveExecutablePath(); - console.log('Resolved executable path:', execPath); - launchConfig.executablePath = execPath; - } catch (err) { - console.log('Error resolving executable path:', err.message); - } - - // Add product and channel settings - launchConfig.product = 'chrome'; - launchConfig.channel = 'chrome'; - console.log('Final launch config:', launchConfig); browser = await puppeteer.launch(launchConfig); From 0bfe9df91ea2e439f02a9638227330fdca534d0d Mon Sep 17 00:00:00 2001 From: Suzanne Aitchison Date: Wed, 14 May 2025 15:04:06 +0100 Subject: [PATCH 19/21] try another way to configure cache dir --- src/run-lighthouse.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/run-lighthouse.js b/src/run-lighthouse.js index d68f0d40..d4e7ef15 100644 --- a/src/run-lighthouse.js +++ b/src/run-lighthouse.js @@ -28,16 +28,21 @@ export const runLighthouse = async (url, settings) => { try { console.log('Launching Chrome with puppeteer...'); + // Set cache directory before any Puppeteer operations + process.env.PUPPETEER_CACHE_DIR = '/tmp/puppeteer'; + console.log('Setting Puppeteer cache directory:', process.env.PUPPETEER_CACHE_DIR); + try { - // For newer Puppeteer versions, just log the install location - const installDir = process.env.PUPPETEER_CACHE_DIR || '/tmp/puppeteer'; - console.log('Puppeteer install directory:', installDir); + console.log('Installing Chrome...'); + await puppeteer.browsers().install(); + console.log('Chrome installation complete'); } catch (err) { - console.log('Error getting Puppeteer info:', err.message); + console.log('Error installing Chrome:', err.message); } // Check for Chrome in Netlify environment first const chromePaths = [ + '/opt/buildhome/.cache/puppeteer/chrome/linux-136.0.7103.92/chrome-linux64/chrome', '/opt/buildhome/.cache/puppeteer/chrome/linux-119.0.6045.105/chrome-linux64/chrome', '/usr/bin/google-chrome', '/usr/bin/chromium-browser' @@ -78,7 +83,6 @@ export const runLighthouse = async (url, settings) => { try { const launchConfig = { headless: 'new', - ...(executablePath ? { executablePath } : {}), args: [ '--no-sandbox', '--disable-gpu', @@ -86,8 +90,7 @@ export const runLighthouse = async (url, settings) => { '--disable-software-rasterizer', '--disable-setuid-sandbox', '--no-zygote' - ], - cacheDirectory + ] }; console.log('Launching browser with config:', launchConfig); From 1af569dcab0c1f1fcea8599f276af123f79c7335 Mon Sep 17 00:00:00 2001 From: Suzanne Aitchison Date: Wed, 14 May 2025 15:12:07 +0100 Subject: [PATCH 20/21] try PUPPETEER_BROWSER_PATH --- src/run-lighthouse.js | 67 +++++++++---------------------------------- 1 file changed, 13 insertions(+), 54 deletions(-) diff --git a/src/run-lighthouse.js b/src/run-lighthouse.js index d4e7ef15..ce117f06 100644 --- a/src/run-lighthouse.js +++ b/src/run-lighthouse.js @@ -28,54 +28,26 @@ export const runLighthouse = async (url, settings) => { try { console.log('Launching Chrome with puppeteer...'); - // Set cache directory before any Puppeteer operations - process.env.PUPPETEER_CACHE_DIR = '/tmp/puppeteer'; - console.log('Setting Puppeteer cache directory:', process.env.PUPPETEER_CACHE_DIR); + // Set Puppeteer browser path to a writable location + const browserPath = '/tmp/puppeteer/chrome/linux-136.0.7103.92/chrome-linux64/chrome'; + process.env.PUPPETEER_BROWSER_PATH = browserPath; + console.log('Setting Puppeteer browser path:', process.env.PUPPETEER_BROWSER_PATH); + // Create the directory structure if it doesn't exist try { - console.log('Installing Chrome...'); - await puppeteer.browsers().install(); - console.log('Chrome installation complete'); + await fs.promises.mkdir('/tmp/puppeteer/chrome/linux-136.0.7103.92/chrome-linux64', { recursive: true }); + console.log('Browser directory structure created'); } catch (err) { - console.log('Error installing Chrome:', err.message); + console.error('Error creating browser directory:', err.message); } - // Check for Chrome in Netlify environment first - const chromePaths = [ - '/opt/buildhome/.cache/puppeteer/chrome/linux-136.0.7103.92/chrome-linux64/chrome', - '/opt/buildhome/.cache/puppeteer/chrome/linux-119.0.6045.105/chrome-linux64/chrome', - '/usr/bin/google-chrome', - '/usr/bin/chromium-browser' - ]; - - let executablePath; - for (const path of chromePaths) { - try { - await fs.promises.access(path); - executablePath = path; - console.log('Found Chrome at:', path); - break; - } catch (err) { - console.log(`Chrome not found at ${path}`); - } - } - - if (!executablePath) { - console.log('No Chrome installation found, using bundled Chromium'); - // Let puppeteer use its bundled version - executablePath = undefined; - } - - // Use /tmp directory which should be writable in Netlify - const cacheDirectory = '/tmp/puppeteer'; - console.log('Using cache directory:', cacheDirectory); - - // Ensure cache directory exists + // Verify the browser path exists try { - await fs.promises.mkdir(cacheDirectory, { recursive: true }); - console.log('Cache directory created/verified'); + await fs.promises.access(browserPath); + console.log('Browser exists at:', browserPath); + launchOptions.chromePath = browserPath; } catch (err) { - console.warn('Could not create cache directory:', err.message); + console.log('Browser not found at configured path, will use default'); } // Launch browser for Lighthouse with specific configuration for Netlify @@ -94,23 +66,11 @@ export const runLighthouse = async (url, settings) => { }; console.log('Launching browser with config:', launchConfig); - - console.log('Final launch config:', launchConfig); browser = await puppeteer.launch(launchConfig); - - // Get browser information console.log('Browser launched successfully'); const wsEndpoint = browser.wsEndpoint(); console.log('Browser WebSocket endpoint:', wsEndpoint); - - // Use the launch config's executable path for chrome-launcher - if (launchConfig.executablePath) { - console.log(`Using Chrome at: ${launchConfig.executablePath}`); - launchOptions.chromePath = launchConfig.executablePath; - } else { - console.log('Using default Chrome path'); - } } finally { if (browser) { try { @@ -123,7 +83,6 @@ export const runLighthouse = async (url, settings) => { } } catch (error) { console.error('Error launching Chrome with puppeteer:', error); - throw error; } chrome = await chromeLauncher.launch(launchOptions); From c0b7a75dd60d962d72c98996f791fa96c74b67b1 Mon Sep 17 00:00:00 2001 From: Suzanne Aitchison Date: Wed, 14 May 2025 15:39:09 +0100 Subject: [PATCH 21/21] try getting executable path from puppeteer --- src/run-lighthouse.js | 94 ++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 64 deletions(-) diff --git a/src/run-lighthouse.js b/src/run-lighthouse.js index ce117f06..1790757e 100644 --- a/src/run-lighthouse.js +++ b/src/run-lighthouse.js @@ -1,5 +1,3 @@ -import fs from 'fs'; - import lighthouse from 'lighthouse'; import chromeLauncher from 'chrome-launcher'; import log from 'lighthouse-logger'; @@ -11,79 +9,47 @@ export const runLighthouse = async (url, settings) => { const logLevel = settings?.logLevel || 'error'; log.setLevel(logLevel); - console.log('Launching Chrome...'); - // Launch Chrome with minimal flags + // Let Puppeteer handle Chrome installation with its defaults + let executablePath; + try { + const browser = await puppeteer.launch({ + headless: 'new', + args: [ + '--no-sandbox', + '--disable-gpu', + '--disable-dev-shm-usage', + '--disable-software-rasterizer', + '--disable-setuid-sandbox', + '--no-zygote' + ] + }); + + // Get the executable path from Puppeteer's browser instance + executablePath = browser.process().spawnArgs[0]; + console.log('Using Chrome at:', executablePath); + await browser.close(); + } catch (err) { + console.error('Error launching Chrome:', err.message); + throw err; // We need Chrome to continue + } + + // Configure chrome-launcher const launchOptions = { chromeFlags: [ '--headless=new', '--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage', + '--disable-software-rasterizer', + '--disable-setuid-sandbox', + '--no-zygote' ], logLevel, handleSIGINT: true, + chromePath: executablePath }; - // Launch Chrome using puppeteer - try { - console.log('Launching Chrome with puppeteer...'); - - // Set Puppeteer browser path to a writable location - const browserPath = '/tmp/puppeteer/chrome/linux-136.0.7103.92/chrome-linux64/chrome'; - process.env.PUPPETEER_BROWSER_PATH = browserPath; - console.log('Setting Puppeteer browser path:', process.env.PUPPETEER_BROWSER_PATH); - - // Create the directory structure if it doesn't exist - try { - await fs.promises.mkdir('/tmp/puppeteer/chrome/linux-136.0.7103.92/chrome-linux64', { recursive: true }); - console.log('Browser directory structure created'); - } catch (err) { - console.error('Error creating browser directory:', err.message); - } - - // Verify the browser path exists - try { - await fs.promises.access(browserPath); - console.log('Browser exists at:', browserPath); - launchOptions.chromePath = browserPath; - } catch (err) { - console.log('Browser not found at configured path, will use default'); - } - - // Launch browser for Lighthouse with specific configuration for Netlify - let browser; - try { - const launchConfig = { - headless: 'new', - args: [ - '--no-sandbox', - '--disable-gpu', - '--disable-dev-shm-usage', - '--disable-software-rasterizer', - '--disable-setuid-sandbox', - '--no-zygote' - ] - }; - - console.log('Launching browser with config:', launchConfig); - browser = await puppeteer.launch(launchConfig); - console.log('Browser launched successfully'); - - const wsEndpoint = browser.wsEndpoint(); - console.log('Browser WebSocket endpoint:', wsEndpoint); - } finally { - if (browser) { - try { - await browser.close(); - console.log('Browser closed successfully'); - } catch (err) { - console.warn('Error closing browser:', err); - } - } - } - } catch (error) { - console.error('Error launching Chrome with puppeteer:', error); - } + console.log('Chrome launch options:', launchOptions); chrome = await chromeLauncher.launch(launchOptions); console.log('Chrome launched on port:', chrome.port);