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

libgrabber

v0.5.14

Published

Automatically updates hosted projects on jsDelivr CDN.

Downloads

26

Readme

libgrabber

libgrabber is a bot that runs on jsDelivr's servers to auto-update projects. There are three simple steps to enable auto-updating:

  1. Prepare minified files
  2. Add or update update.json schema at jsDelivr
  3. Create New Package Release

If you are a developer and want to contribute to our bot's code, we also include [instructions](Running your own libgrabber bot) for running the bot locally.

Usage

Prepare minified files

Please upload only minified files on jsDelivr. Smaller files helps users load websites faster. Minified files also helps us with hosting and promotes good practices. If you need to upload images, see if extra compression can make your images smaller. SVG optimizers may also help with SVG files from Inkscape and Illustrator.

Add update.json schema

libgrabber looks for update.json at the root of each project folder. This file tells libgrabber where to check for project updates and which files it should copy to jsDelivr. You add update.json using these steps:

  1. Fork the jsDelivr/jsDelivr repo
  2. Open your project folder. If it doesn't exist, please add a new folder and info.ini file using jsDelivr's file structure.
  3. Write update.json using this format:
{
  "packageManager": "<github|npm|bower>",
  "name": "<package-name>",
  "repo": "<user>/<repo>",
  "files": {
    "basePath": "<dir>",
    "include": ["<glob-string-1>", "<glob-string-2>"],
    "exclude": ["<glob-string-3>"]
  }
}

packageManager (required) (github, npm or bower) - to declare which package manager libgrabber watches for new versions

name (required) - refers to package name on npm or Bower, or repo name when GitHub is used

repo (optional when npm or bower is used) - GitHub repository (for example jsdelivr/libgrabber)

files/basePath (optional) - base directory from which files are copied (for example dist/). Defaults to / (relative to the root directory of unpacked project package).

files/include (optional) - array that specifies files and dirs that will be copied from project package. Accepts one or more glob strings. Defaults to **/*, meaning all files and directories. Useful examples:

  • main.min.js - copies main.min.js file in the base dir
  • *.js - copies javascript files found in the base dir
  • **/*.js - copies javascript files found in the base directory and recursively in all its subdirectories. Directory structure will be retained.
  • dist/*.js - copies javascript files from dist dir. Directory structure will not be retained (e.g. dist dir will be stripped when copied). To retain directory structure prepend glob with ./ e.g. ./vendors/*.js

files/exclude (optional) - array that specifies files and dirs that will be excluded. Format is the same as files/include.

Libgrabber glob functionality is based on node-glob, for more information and examples, please see its documentation.

Tools

Examples

Bootstrap Example (github)

Following example excludes non-minified resources:

{
  "packageManager": "github",
  "name": "bootstrap",
  "repo": "twbs/bootstrap",
  "files": {
    "basePath": "dist/",
    "exclude": ["css/bootstrap.css", "css/bootstrap.css.map", "css/bootstrap-theme.css", "css/bootstrap-theme.css.map", "js/bootstrap.js"]
  }
}
Humane-js (/files/humane.js/update.json) (github)
{
  "packageManager": "github",
  "name": "humane.js",
  "repo": "wavded/humane-js",
  "files": {
    "include": ["humane.min.js", "humane.js", "./themes/**/*"]
  }
}
Lodash Example (npm)
{
  "packageManager": "npm",
  "name": "lodash",
  "repo": "lodash/lodash",
  "files": {
    "basePath": "dist/"
  }
}
midnight.js Example (single-item include array)
{
  "packageManager": "github",
  "name": "jquery.midnight",
  "repo": "Aerolab/midnight.js",
  "files": {
    "include": ["midnight.jquery.min.js"]
  }
}

Create new package release

When libgrabber detects a release with a new SemVer compliant tag, it will automatically update the repo on jsDelivr. The packageManager value you chose in update.json determines where you need to update your actual package.

GitHub Releases

You can use the GitHub web GUI, or from CLI use git-tag to post a new release.

npm

Use npm publish.

Bower

Bower has its own system to register packages, though the package file needs a git host. If GitHub is used, follow the instructions above to let Bower know your package is updated.


Running your own libgrabber bot

It is not required for you to run the bot yourself to update your own project. These instructions are for you to run libgrabber locally for testing.

Configuration

Repo
  1. Properly configured git account (user.name, user.email, ssh key with empty ssh passphrase)
  2. Forked jsdelivr repo
  3. Upstream set to jsdelivr repo
$ git remote add upstream [email protected]:jsdelivr/jsdelivr.git
Libgrabber config
{
  "github-access-token": "<secret>",
  "pull-request-repo": "https://github.com/jsdelivr/jsdelivr",
  "origin-repo": "<forked-repo-https-endpoint>",
  "mention-repo-owner": false,
  "papertrail-url": "<optional>",
  "papertrail-hostname": "<optional>"
}

Running

# --jsdelivr-path <path to the cloned forked repo>
# --config <path to the above mention config file>
# --project <name of project to update, if absent libgrabber will default to updating all projects>
$ libgrabber --jsdelivr-path jsdelivr/ --config jsdelivr/libgrabber.config.json --project projectName