mikestead / lighthouse-batch Goto Github PK
View Code? Open in Web Editor NEWRun Lighthouse analysis over multiple sites in a single command
License: MIT License
Run Lighthouse analysis over multiple sites in a single command
License: MIT License
Hi,
I'm wondering if it's possible to declare each of the reports Lighthouse generates separately. E.g...
lighthouse-batch -f urls.txt --html - "--perf"
runs a performance only audit (although that seems to fail and generates all)
Is it possible to run an SEO / Accessibility / Best Practices audit separately? Something like...
lighthouse-batch -f urls.txt --html - "--acce"
Hello guys,
Lighthouse v7.3.0 was released some time ago.
The release notes includes the jsonld
update to its latest version
It fixes this vulnerability described below:
Lots has changed and we'd love to make sure folks using lh-batch get all the latest and greatest.
For you, you'll have to tweak your getAverageScore
method. reportCategories
to categories
, but that should be it. https://developers.google.com/web/tools/lighthouse/v3/migration
for example, how to run "url" 5 times?
Hi mikestead, thanks for the great batch process package.
I started to use it and find a issue, seems it does not support Desktop mode yet.
I tried to use -p --preset=desktop which is working in "lighthouse", but when it applies to "lighthouse-batch", following error occurs:
Invalid values:
Argument: preset, Given: "desktop", Choices: "perf", "experimental"
in "lighthouse", it supports 3 parameters: perf, experimental, desktop.
Thank you.
H
Getting JScript compilation error on Windows 10
Read suggestions stating to try using the -g parameter as well (ex: lighthouse-batch -s https://airhorner.com,https://housing.com -g), however that gives a "Global instance not found" and then the same error again:
At title, not able to run with this setting. I've commented some details in 13. However, I've tried a few different forms of this.
lighthouse-batch -h -v -s <url> --params "--chrome-flags=\"--no-sandbox --disable-gpu --emulated-form-factor=none\""
--params "--chrome-flags=\"--emulated-form-factor=none\""
--params --emulated-form-factor=none
and all the above replacing none
with desktop
I've confirmed lighthouse does accept this as
lighthouse <url> --params --emulated-form-factor=none
worked as expected.
I've also confirmed that lighthouse-batch
is accepting --params
as the first in the list above does run without --headless
successfully.
I'm relatively positive its user error, but I can't figure out any alternative that does work.
If I can confirm with a non-headless it's running in desktop, to then be able to run the batch headless that would be preferred.
Any ideas?
Because of variable NodeJS versions and our CI processes, we run our NPM projects using a contextual install of NPM/NodeJS local to the project, managed by a Maven module.
When trying to run this tool with these commands:
./node/npm install -g lighthouse-batch
./node/lighthouse-batch -f pages.txt
I get the following output:
npm WARN deprecated [email protected]: Package no longer supported. Contact support@n pmjs.com for more info.
[PROJECT-ROOT]\node\lighthouse-batch -> [PROJECT-ROOT]\node\node_modules\lighthouse-batch\run.js
updated 1 package in 24.704s
'node' is not recognized as an internal or external command, operable program or batch file.
1/0: Lighthouse analysis FAILED for [TEST PAGE 1]
'node' is not recognized as an internal or external command, operable program or batch file. 2/0: Lighthouse analysis FAILED for [TEST PAGE 2]
I am running this command
/usr/local/bin/lighthouse-batch -s "https://1.site","https://2.site","https://3.site",
"https://4.site" --html --out /var/www/lighthouse/`date +"%F"`/
It works fine.
I added this command in a bash script. I run the script, still works fine.
Then I run the script as a cron job, I get the following error.
"/usr/local/lib/node_modules/lighthouse-batch/node_modules/lighthouse/lighthouse-core/lib/url-shim.js:36
class URLShim extends URL {
^
ReferenceError: URL is not defined
at Object.<anonymous> (/usr/local/lib/node_modules/lighthouse-batch/node_modules/lighthouse/lighthouse-core/lib/url-shim.js:36:23)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/usr/local/lib/node_modules/lighthouse-batch/node_modules/lighthouse/lighthouse-core/lib/network-request.js:14:13)
at Module._compile (module.js:652:30)
"
node --version
v12.18.3
Is there maybe a variable I need to set in cron? Or in the script?
Tool started failing in CI - would that be because you don't specify --chrome-flags="--headless"
in the Lighthouse command?
Is there any Pipeline scripts used in Jenkins using lighthouse-batch
What's your PayPal Mike? Would like to send you a coffee. LHB has been a huge help to me over the last 6 months.
Question
Is there any option that I could use to prevent the creation of reports.
Because I found my self not needing them.
Suggestion
Couldn't there be a flag I use to only display the metrics to my pages in my terminal?
Extra question
How can I set a minimal score (threshold) for my performance/pwa/best-practice/best-practices for the CI to pass?
Hi;
Again thanks for this useful tool. :) We' ve a problem about broken links.
We' re running lighthouse-batch with this command:
lighthouse-batch -f src/urls_all.txt --accessibility 60 --params "--port 49965 --preset=desktop" --out "./lighthouse/desktop/"
If there are some broken links in the urls_all.txt, lighthouse-batch gives the error below error & breaks down in the middle of the process.
For example it successfully tests 1000 pages but got an 404 error in the 1001th page. It doesn' t continue to text the next URLs & because it doesn' t create summary.json file, we need to whole process again just after deleting the broken link from the text file.
Is there any way to continue to run the script even we had broken links in the url list?
Kind regards.
When visiting the npmjs page (https://www.npmjs.com/package/lighthouse-batch) the link to this git repository isn't reported.
Hi mikestead, thanks for the great batch process package.
I started to use it and find a issue, seems it does not support Desktop mode yet.
I tried to use -p --preset=desktop which is working in "lighthouse", but when it applies to "lighthouse-batch", following error occurs:
Invalid values:
Argument: preset, Given: "desktop", Choices: "perf", "experimental"
in "lighthouse", it supports 3 parameters: perf, experimental, desktop.
Thank you.
H
"requestedUrl": "https://www.saramin.co.kr/zf_user/",
"finalUrl": "https://m.saramin.co.kr/",
Do I have to fill out an option?
Hi,
I am trying the following on a windows 10 machine:
npm install -g lighthouse-batch
cd C:\lighthouse
lighthouse-batch -f sites.txt --html
where sites.txt has a number of websites in it, separated by newline.
This results in the following error reported over and over:
PS C:\lighthouse> lighthouse-batch -f sites.txt --html
internal/modules/cjs/loader.js:775
throw err;
^
Error: Cannot find module 'C:\Users\Dylan'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
at Function.Module._load (internal/modules/cjs/loader.js:677:27)
at Function.Module.runMain (internal/modules/cjs/loader.js:999:10)
at internal/main/run_main_module.js:17:11 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
1/0: Lighthouse analysis FAILED for https://www.mysite.com/
internal/modules/cjs/loader.js:775
throw err;
^
Is there a dependency missing or am I doing something wrong? I tried following the instructions on the readme.md but I am hitting this error in windows and a similar error in Mac OSX.
There is new weighting and new metrics in Lighthouse v6. Is it possible to update this package to use the latest version of Lighthouse?
Using v2.1.0:
/usr/local/lib/node_modules/lighthouse-batch/index.js:107
const total = report.reportCategories.reduce((sum, cat) => sum + cat.score, 0)
^
TypeError: Cannot read property 'reduce' of undefined
at getAverageScore (/usr/local/lib/node_modules/lighthouse-batch/index.js:107:41)
at updateSummary (/usr/local/lib/node_modules/lighthouse-batch/index.js:102:19)
at sitesInfo.map (/usr/local/lib/node_modules/lighthouse-batch/index.js:41:21)
at Array.map (<anonymous>)
at execute (/usr/local/lib/node_modules/lighthouse-batch/index.js:27:38)
at Object.<anonymous> (/usr/local/lib/node_modules/lighthouse-batch/run.js:17:1)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
I wish to understand how to use lighthouse batch for the entire website where we will be using login authentication and also doing some selection kind of. We see examples for static websites only.It will be very much helpful if we have a sample.Thanks in Advance.
The following cmd line fails:
lighthouse-batch -f site.txt -h -p "--preset=desktop"
Invalid values:
Argument: preset, Given: "desktop", Choices: "perf", "experimental"
But this lighthouse command line :
lighthouse https://www.xxxx.com/ --output=json,html --preset=desktop
Is lighthouse-batch using a different version of the lighthouse library?
Succeeds. As such I am unable to run lighthouse-batch for desktop workloads.
Is it possible to only output HTML versions of reports?
When I try to call lighthouse from the command line I successfully get results returned e.g. lighthouse https://www.bbc.com
However when I try to audit the same site using lighthouse-batch it fails (command is lighthouse-batch -s https://www.bbc.com
)
Comparing the output of the two commands they differ after this line: LH:CriConnection:warn Cannot create new tab; reusing open tab.
Any ideas why this might be please?
Hi,
I need help on which argument i need to pass in command for below cases.
Desktop only
pass cookie value
accessibility testing only
headless mode
when running this program, I deleted all files in the output parameter and I could not bring back. Please fıx the bugs.
This section:
Line 21 in 52a59d1
HI There,
I am trying to run lighthouse batch but it always taking lighthouse version 8.6.0
How can i modify lighthouse-batch to use latest lighthouse version 11.0.0.
I have tried updating "package.json" with
"dependencies": {
"commander": "^2.9.0",
"lighthouse": "^11.0.0",
"shelljs": "^0.8.4"
}
then npm install
but its giving me error as while running lighthouse-batch:
C:\Windows\System32>lighthouse-batch
Failed to find Lighthouse CLI, aborting.
Please note that lighthouse 11.0.0 is already installed in my machine:
C:\Windows\System32>lighthouse --version
11.0.0
Hi,
Can I specify the test on mobile instead of desktop?
Regards,
As i can see, the default lighthouse check is mobile. Is there any possibility to change the test between mobile, desktop or do checks for both mobile and desktop?
Reproduce:
$ ./node_modules/lighthouse-batch/run.js -s "https://www.ncbi.nlm.nih.gov/nlmcatalog?term=(Physiology[Journal]) AND 1980[Publication"
/bin/sh: -c: line 0: syntax error near unexpected token `('
Are you open to a pull request for adding concurrency?
The thought is to allow a parameter -c
which would chunk sites and execute concurrently?
This is potentially out of scope for lighthouse-batch, but at the end of a successful Lighthouse run (after the report JSON has been generated), sometimes ChromeLauncher is unable to terminate the Chrome task because one or more of its children have already been terminated, e.g.
status Generating results...
Printer json output written to output.json
ChromeLauncher Killing Chrome instance 2720
ChromeLauncher:warn Chrome could not be killed Command failed: taskkill /pid 2720 /T /F
ERROR: The process with PID 5676 (child process of PID 2720) could not be terminated.
Reason: There is no running instance of the task.
the value of outcome
(index.js line 56) is now non-zero (as there is an error on the command line), even though the bit we care about (the report generation step) actually completed.
Expecting lighthouse-batch to be able to parse and understand the error output is probably asking a bit much(!), but would it be possible to include an error override flag in the lighthouse-batch parameters to enable best-effort processing in updateSummary
(index.js line 172) in edge-cases like this, rather than just recording the error message against blank summary values?
(as an aside, the underlying problem seems to be that Lighthouse CLI reports failure to kill a child process as an ERROR, even though a failure to kill the parent process itself is merely a WARNING. I'll be raising this issue against Lighthouse CLI separately!)
Hi,
Tested out your repo, and ran this command:
Why is it doing RM? It wiped 80% of my projects..
In your docs you're stating:
-o, --out [out] the output folder to place reports, defaults to './report/lighthouse'
-s, --sites [sites] a comma delimited list of site urls to analyze with Lighthouse
I never expected the rm.
But in your code at line 21 in index.js:
rm('-rf', out)
This got me very frustrated, not even a heads up about wiping the whole folder. I'd expect a new folder to be created, not that everything gets deleted and then a new one generated?
Hi mikestead,
When I tried to export the .csv format by using following command, an error occurs
lighthouse-batch -p --output=csv -s https://www.google.com
This will impact a batch processing when I read list from site.txt.
E.g., in site.txt, following URLs are listed:
https://www.google.com
https://www.bing.com
Then, when try to use following command, the error will occur and interrupt the next URL's process.
lighthouse-batch -p --output=csv -f D:\site.txt
But the JSON file is actually existing.
The --output=csv
is supported in "lighthouse", by using this, the output csv files is easy to be imported and proceeding in a pivot table in excel, especially multi URLs existing.
So, if this can be supported in "lighthouse-batch", will be a GREAT improvement.
Thanks again for providing the resource and package.
Runtime error encountered: Waiting for DevTools protocol response has exceeded the allotted time. (Method: Runtime.evaluate)
LHError: PROTOCOL_TIMEOUT
at Timeout.setTimeout [as _onTimeout] (/path/to/job/node_modules/lighthouse/lighthouse-core/gather/driver.js:291:21)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
1/1: Lighthouse analysis FAILED for https://dev.domain.ext
Yet the process returns a success code.
I want to have the batch option, but just want the pass/fail option that you can get from lighthouse-ci. Any way to just highlight the number in the results?
Hi;
Thanks for this wonderful tool. We' ve a problem about some links that has more than 255 characters. We cannot generate score & save these kind of URLs. I think it' s because of Windows is allowing File Name' s lengh as maximum 255.
Is there a way to modify file name?
Kind regards.
Hello!
I've been using lighthouse-batch as modules (import runner from 'lighthouse-batch'
) and surprisingly it's working properly (with correct parameters)
But when I tried migrating my project to Yarn v2 + PnP, lighthouse-batch just gives an error, "Failed to find Lighthouse CLI, aborting." and then stops, even though I already added 'lighthouse'
as workspace package dependencies.
It'd be great to have the ability to point to a JSON path that lists the URLs to score. I'm trying to get scores for multiple main pages to a single website in bulk.
Currently the way it calculate the file name to save the report as json is based only on the url, so if one want to batch load multiple time the same url to get averages values , then those reports will be overwritten as it uses the same file.
Best would be to fix the code that set the filename to be unique (uuid) and not depending on the url or at least it should be shorter also as urls that are very long produce long files name too. which is not so ideal.
https://github.com/mikestead/lighthouse-batch/blob/master/index.js#L106-L108
and
https://github.com/mikestead/lighthouse-batch/blob/master/index.js#L78
Maybe using a "uuid" generator for the file would solve it
default device emulation switch from https://github.com/GoogleChrome/lighthouse doesn't work in lighthouse-batch
https://github.com/andreasonny83/lighthouse-ci
ideally, if this tool will also support parameters causing returning success or fail in case of exceeded threshold values.
imagine:
$ lighthouse-batch -s https://example.com,http://demo.example.com --score=75
$ lighthouse-batch -s https://example.com,http://demo.example.com --accessibility=90 --seo=80
$ lighthouse-batch -s https://example.com,http://demo.example.com --accessibility=90 --seo=80 --report=folder
$ lighthouse-batch https://example.com,http://demo.example.com --report=folder --config-path=configs.json
this matters because I'd like to include using this tool lighthouse-batch in my build in case of checking many site pages and also considering thresholds. to get immediate feedback / "sth is wrong in one of my pages in case of performance"
what do you think?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.