npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dreipol/lighthouse-runner

v3.0.8

Published

Command Line Runner for lighthouse with integrated budget checks for CI and quality control

Downloads

98

Readme

lighthouse-runner

CircleCI Codacy Badge

Dreihouse is a tool to run automated lighthouse audits for a webproject. Dreihouse has the advantage to be more configurable than lighthouse.

Use Cases

There are several usecases for an automated audit tool like this. You can implement it into your CI so you'll never deploy a page with bad performances again. Or if you wan't to see if a site enhances over time. You can also implement it in a gulp command.

Install

npm i @dreipol/lighthouse-runner

Config

| field | type | default | value | | ------------------ | ------------- | -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | | paths | Array | ['/'] | Array of url paths. All these routes are tested and reported | | chromeFlags | Array | ['--window-size=1200,800'] | Array of additional chrome flags. See all | | folder | string | ./dreihouse-reports | Define location to store the reports | | disableEmulation | boolean | true | Applay device emulation | | disableThrottling | boolean | true | Disable Network and CPU throttling | | initialPageLoad | boolean | true | Define whether the page should be visited before the audits are run (Cache stuff) | | preAuditScripts| Array<PreAuditScriptInterface> | | Current available persisters are html json and html-dashboard| | report | Array<string> | ['html'] | Different reporters. Thos will process the generated audit results. [cli, html, json-dashboard, json`] |

preAuditScripts

In order to handle login forms, or do other modifications of the page before lighthouse audits the page, you can add some preAuditScripts in the config. Those scripts are executed right before lighthouse starts. These scripts have to implement the PreAuditScriptInterface interface.

Before execution of this script, the browser instance will already be on the inital url, passed in the execute method of Dreihouse

Here is an example of such login script

ES6

    module.exports = {
        execute:async(logger, page) {
            await page.waitForSelector('#username', { visible: true });
            await page.waitForSelector('#password', { visible: true });
            
            const usernameInput = await page.$('#username');
            const passwordInput = await page.$('#password');
            
            await usernameInput.type(process.env.LOGIN_USERNAME);
            await passwordInput.type(process.env.LOGIN_PASSWORD);
            
            await passwordInput.press('Enter');
        }
    }

ES5

    module.exports = {
    execute: function(logger, page) {
        return page.waitForSelector('#id_password', { visible: true })
            .then(() => {
                return page.$('#id_password');
            })
            .then((passwordInput) => {
                return passwordInput.type(process.env.LOCKDOWN_PASSWORD)
                    .then(() => {
                        return passwordInput;
                    });
            })
            .then((passwordInput) => {
                return passwordInput.press('Enter');
            });
    },
};

Now in your config file you can load the login script

...
saveReport: true,
budget: {
    ...
},
preAuditScripts: [
    require('your/login/script.js'),
],
reporters: {
    modules: [
        ...
        
        

Example

    paths: [
        '/',
    ],
    folder: './dreihouse-reports',
    tag: 'desktop',
    chromeFlags: ['--window-size=1280,1024', '--headless'],
    initialPageload: false,
    disableEmulation: true,
    disableThrottling: true,
    preAuditScripts: [
        loginScript,
    ],
    budget: {
        dreipol: 0.9,
        seo: 0.9,
        performance: 0.9,
        pwa: 0.9,
        accessibility: 0.9,
        'best-practices': 0.9,
    },

Programmatic use

In order to modify dreihouse to your needs, you can orchestrate dreihouse programmatically.

In this example script we run the audit every 15s and use the cli to report the results but only start the chrome once and reuse the connection.

    import Dreihouse from "@dreipol/lighthouse-runner/dist/Dreihouse";
    
    const dreihouse = new Dreihouse(CONFIG, ['cli']);
    
    async function run() {
        await dreihouse.startChrome(INITIAL_URL);
        await execute();
    }
    
    async function execute() {
        await dreihouse.audit(URL);
        setTimeout(async () => {
            await execute();
        }, 15000);
    }
    
    
    run();

Tools