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

@dmail/lighthouse-report

v2.1.0

Published

[![npm package](https://img.shields.io/npm/v/@dmail/lighthouse-report.svg)](https://www.npmjs.com/package/@dmail/lighthouse-report) [![build](https://travis-ci.com/dmail/lighthouse-report.svg?branch=master)](http://travis-ci.com/dmail/lighthouse-report) [

Downloads

10

Readme

lighthouse-report

npm package build codecov

Generate lighthouse report programmatically. Can also auto comment pull request on github with your lighthouse report.

Introduction

Thi module has the following exports

  • generateLighthouseReport
  • commentPullRequestWithLighthouseReport

generateLighthouseReport example

const { generateLighthouseReport } = require("@dmail/lighthouse-report")

generateLighthouseReport({
  url: "http://google.com",
  projectPath: __dirname,
  jsonReportRelativePath: "/lighthouse-report.json",
  htmlReportRelativePath: "/lighthouse-report.html",
})

The code above will create two files in the current directory corresponding to lighthouse report for http://google.com

commentPullRequestWithLighthouseReport example

const { readFileSync } = require("fs")
const { commentPullRequestWithLighthouseReport } = require("@dmail/lighthouse-report")

const lighthouseReport = JSON.parse(String(readFileSync(`${__dirname}/lighthouse-report.json`)))
const lighthouseProductionReport = JSON.parse(
  String(readFileSync(`${__dirname}/lighthouse-production-report.json`)),
)

commentPullRequestWithLighthouseReport({
  githubApiToken: process.env.GITHUB_API_TOKEN,
  repositoryOwner: "dmail",
  repositoryName: "lighthouse-report",
  pullRequestNumber: 5,
  lighthouseReport,
  lighthouseProductionReport,
})

The code above will search in your github repository pull request for a comment about lighthouse report.

When the comment does not exists:

  • it creates a gist
  • then it create a comment in your pull request with a link to view your lighthouse report

When the comment exists:

  • it updates the gist
  • it updates the comment on the pull request with latest data

This function is meant to be runned every time you push a commit on a pull request. You have to setup how to call it and provide pullRequestNumber.

List of things to know

  • If you pass lighthouseProductionReport, the comment contains score diff between your pull request and production.
  • To create a githubApiToken go to https://github.com/settings/tokens.
  • gihubApiToken must be allowed to read/write gists and read/write comments.
  • The gist created is secret and owned by the owner of githubApiToken.
  • The pull request comment is made by the owner of githubApiToken.
  • If you use travis you can use the undocumented lighthousePullRequestCommentFromTravisBuild export. — see source

Installation

npm install @dmail/[email protected]