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

paopu

v0.1.2

Published

A CLI tool to manage your CDN script tags in files. Automatically generate a sub-resource integrity from a file, then add it to the matching script tag.

Downloads

62

Readme

✩ Paopu ✩

A CLI tool to manage your CDN script tags in files. Automatically generate a sub-resource integrity from a file, then add it to the matching script tag.

Read the Why section for more details.

Paopu was created to work with Node 14 and newer.

Feel free to submit an issue or pull request. :)

TODO:

  • More hashing options (currently only SHA256 is supported).

Install & Run

  1. Install it in your project:
$ npm i -D paopu
  1. Create a configuration.
  2. Run it:
$ paopu

Why?

Scenario: Let's say you want to tell the world that your package's bundle can be accessed on a public CDN. You might include an example script in your README, like so:

<script
  type="text/javascript"
  src="https://cdn.jsdelivr.net/npm/[email protected]/dist/my-cool-package.min.js"
  integrity="sha256-waCWKicYMCJic4tBKdkV54qhuGsq8J9JWQY+QmFVjj8="
  crossorigin="anonymous"
></script>

Problem: Every time you release a new package version, you need to update that integrity hash. Sometimes in multiple files.

Solution: Install Paopu, add a config, then run the CLI tool. Done. ✨

Create a config

Create a paopu.config.json at the root of your project. Optional properties below have default values displayed.

// paopu.config.json
{
  // Each entry uses a package name as the key
  "package-name": {

    // Specifies the file paths used in your script tags. These paths must
    // partially match your path in the `src` attribute.
    //
    // REQUIRED

    "resources": ["some/path/bundle-name.min.js", "some-path/bundle-name.js"],

    // Specifies which files to search for script tags in.
    //
    // REQUIRED

    "targets": ["README.md", "test/index.html"],

    // Specifies if the resources are located in a modules folder.
    // Automatically prepends `node_modules/<CONFIG_KEY>` to paths
    // defined in `resources`, where `<CONFIG_KEY>` is the key
    // of the given paopu config entry.
    // This also causes the tool to ignore `resourceBasePath`
    //
    // OPTIONAL

    "module": false,

    // Specifies a common base path for paths in `resources`
    // Should resolve to a package root in all cases.
    // This is ignored if `module` is `true`.
    //
    // OPTIONAL

    "resourceBasePath": ".",

    // Specifies a common base path for paths in `targets`
    //
    // OPTIONAL

    "targetBasePath": ".",

    // A url matcher for your script tag. If its `src` contains
    // this pattern AND the matching resource path, then the
    // script tag will be updated.
    // E.g., 'unpkg.com'
    //
    // OPTIONAL

    "urlPattern": 'cdn.jsdelivr.net'
  }
}

CLI options

Any CLI options given will override the defaults used by the tool.

Custom config

Flags: --config, -c

Default: paopu.config.json

Example usage: paopu -c path/to/paopu.config.json

Override the default configuration filename.

Debug mode

Flags: --debug, -d

Default: false

Example usage: paopu -d

If given, Paopu will spit out a .paopu-cache file so you can inspect the resolved paths, options, etc., being used by the tool.