Giter Club home page Giter Club logo

lighthouse-batch's People

Contributors

dependabot[bot] avatar elsassph avatar greenkeeper[bot] avatar iandeveseleer avatar jrobind avatar kahunacohen avatar mikestead avatar mtribes-sdk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

lighthouse-batch's Issues

Separate Audits declared in params

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"

Possible to support "Desktop" runtime?

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"
image

in "lighthouse", it supports 3 parameters: perf, experimental, desktop.

Thank you.
H

--emulated-form-factor=none/desktop doesn't work

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?

Node must be on the path to run successfully

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

[email protected]

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]

ReferenceError: URL is not defined when lighthouse-batch runs as cron job

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?

Missing Chrome headless flag?

Tool started failing in CI - would that be because you don't specify --chrome-flags="--headless" in the Lighthouse command?

Paypal

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.

lighthouse-batch reports.

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?

Tests Break on 404 Errors & Doesn' t Continue

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.

resim

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.

Possible to change Runtime setting to Desktop?

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"
image

in "lighthouse", it supports 3 parameters: perf, experimental, desktop.

Thank you.
H

Cannot find module

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.

Update to use Lighthouse v6

There is new weighting and new metrics in Lighthouse v6. Is it possible to update this package to use the latest version of Lighthouse?

TypeError: Cannot read property 'reduce' of undefined

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)

Lighthouse-batch

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.

--params fails when passing --preset=desktop

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.

HTML Only

Is it possible to only output HTML versions of reports?

How to disable the emulatedUserAgent?

I use lighthouse-batch -s <url1,url2> --params "--chrome-flags="--screenEmulation.disable --screenEmulation.mobile=false --screenEmulation.width=1350 --screenEmulation.height=940 --no-emulatedUserAgent"" --html ./report.html
but the device has always been emulation device.

image

Failure to create new browser tab

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?

Bug

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:

rm('-rf', out)

How to use lighthouse-batch with latest lighthouse version

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

Feature Request: Run concurrently

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?

ERROR in ChromeLauncher taskkill command prevents logging summary results

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!)

Lighthouse-batch is wiping everything with rm -rf

Hi,

Tested out your repo, and ran this command:
Screen Shot 2020-02-16 at 11 27 44

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?

Error when output CSV

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
image

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.
image

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.

image

Thanks again for providing the resource and package.

Process silently fails when the driver times out

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.

Integration with lighthouse-ci

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?

Cannot Generate File & Score If URL Lengh is More Than 255 Characters

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.

Failed to find Lighthouse CLI on Yarn 2 PnP

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.

Multiple URLs via JSON

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.

multi urls file overlap

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

Supporting threshold as in lighthouse-ci

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.