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

dx-scripts

v0.1.2

Published

A collection of utility scripts for developer experience and productivity.

Downloads

28

Readme

dx-scripts

A collection of utility scripts for developer experience and productivity.

npm version npm downloads

Installation

# with npm
npm i -D dx-scripts

# or with yarn
yarn add --dev dx-scripts

Scripts

dx-scripts lighthouse

It takes multiple URLs and run Lighthouse performance analysis on the URLs.

To reduce the Lighthouse variability and produce a more reliable performance report, the script runs the performance analysis 5 times by default for each URL and calculate the most representable performance report for the following matrixes:

Arguments and Options

Usage: dx-scripts lighthouse [options] <urls...>

Arguments:
  urls                    Lighthouse will run the analysis on the URLs.

Options:
  -i, --iteration <type>  How many times Lighthouse should run the analysis per URL (default: "5")
  -h, --help              display help for command

Example

# It will run Lighthouse 10 times on each given URLs
dx-scripts lighthouse https://dawchihliou.github.io https://github.com/DawChihLiou -i 10

Use Case

The script is suitable for release automation pipeline. For example, you can integrate dx-scripts lighthouse in your Pull Request to generate Lighthouse performance report on feature preview updates. You can see more detail in this article.

dx-scripts image

It takes in paths or glob patterns to the image files and generate optimized images in the formats and the output directory you specified.

The script will keep the output file structure and filenames as the they are under the given output directory.

This script is built on top of sharp.

Arguments and Options

Usage: dx-scripts image [options] <paths...>

Arguments:
  paths                  file paths or glob patterns

Options:
  -o, --outdir [outdir]  Output directory (default: ".")
  --webp                 To generate .webp files (default: true)
  --avif                 To generate .avif files (default: false)
  --png                  To generate .png files (default: false)
  --jpg                  To generate .jpg files (default: false)
  --gif                  To generate animated .webp files (default: false)
  -h, --help             display help for command

Example

# File structure (before image optimization)
#
# public
# └── images
#    └── articles
#        ├── article-1
#        │   ├── image-1.png
#        │   └── image-2.png
#        └── article-2
#           ├── image-1.png
#           └── image-2.png

# Run `image` script
dx-scripts image public/images/articles/**/*.png -o public/images/optimized --avif

# File structure (after image optimization)
#
# public
# └── images
#     ├── articles
#     │    ├── article-1
#     │    │   ├── image-1.png
#     │    │   └── image-2.png
#     │    └── article-2
#     │       ├── image-1.png
#     │       └── image-2.png
#     └── optimized
#         └── articles
#             ├── article-1
#             │   ├── image-1.webp
#             │   ├── image-1.avif
#             │   ├── image-2.webp
#             │   └── image-2.avif
#             └── article-2
#                 ├── image-1.webp
#                 ├── image-1.avif
#                 ├── image-2.webp
#                 └── image-2.avif

Use Case

The script is suitable for static site generation (SSG). For example, if you are using NextJS for your static site, the next/image component doesn't support image optimization at build time so you won't be able to use the <Image> component.

To generate optimized images, you can simply use dx-scripts image script in your package.json scripts.

scripts: {
+   "image": "dx-scripts image public/**/*.png -o public/optimized",
+   "prepare": "yarn image"
}

And run:

yarn

You'll see the generated .webp files in /public/optimized directory.