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

github-monorepo-hook

v4.1.8

Published

A utility function to extract changed packages in a monorepo from GitHub web hooks

Downloads

24

Readme

github-monorepo-hook

github-monorepo-hook allows you to easily use GitHub web hooks with monorepos.

It detects which packages in your monorepo have been changed on a push event. The change detection analyzes the packages themselves and their local dependencies based on a configuration file in the monorepo. This allows you to do expensive package specific operations (like building, publishing etc.) only in case your code has actually changed.

In addition github-monorepo-hook supports verification of the events using the GitHub web hook secret. This helps to prevent injection of malicious code into your (build/publication/etc.) processes, which otherwise is easily possible with public web hooks. See this section for more details.

Setup

First you need to set up your monorepo for use with github-monorepo-hook. To do so, create a file called packages.json at the root of your monorepo. It should look like the following:

[
  {
    "name": "backend",
    "dependencies": [
      "db",
      "mail-queuer"
    ]
  }
]

This will cause your backend package to be flagged as changed in case files in there, your db package or in your mail-queuer packages have changed.

You may use .deployignore files in your monorepo to block certain paths and files inside your packages from being analyzed. Use one line per rule, glob is allowed.

Usage

This is a usage example for an AWS Lambda function behind an AWS API Gateway:

const getChangedPackages = require('github-monorepo-hook')

const options = {
  branch: 'master', // defaults to none
  packagePath: 'src/packages/' // defaults to 'packages/'
}

exports.handler = async (event) => {
  // event is an object containing web hook request body and headers
  const changedPackages = await getChangedPackages(
    event,
    options
  )

  console.log(changedPackages)
  /*
    logs an array of the package configurations
    for the changed packages - this enables you
    to use the "packages.json" for deployment
    configurations etc. Just add custom keys to
    the entries and use them in your application
  */
}

Secret

To enable event verification simply create an environment variable called GITHUB_SECRET containing your secret. github-monorepo-hook will resolve to false if the incomming event failed the verification. See the official documentation for more information on how to set your own secret token.

Private Repositories

To use github-monorepo-hook with private repositories, simply set an environment variable called GITHUB_TOKEN to a valid GitHub access token.