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

netlify-plugin-no-more-404

v0.0.15

Published

fail netlify build if html goes missing with no redirects

Downloads

214

Readme

Netlify Plugin No More 404

This build plugin will remember the html files you've built, and either warn or fail your build when you make the next build and accidentally lose some html pages (whether on purpose or intentional). The plugin understands Netlify redirects, so you can add a redirect to resolve missing html.

Note: this is different than https://github.com/munter/netlify-plugin-checklinks which checks the validity of outgoing links.

this plugin focuses entirely on whether your own internal URL structure has been preserved by some combination of your build process (it is agnostic of SSG/framework) and Netlify Redirects

Because this plugin is SSG/framework agnostic, it can be a great aid for migrating between frameworks.

Demo

https://github.com/sw-yx/netlify-plugin-no-more-404-demo

Usage

To install, add the following lines to your netlify.toml file:

[[plugins]]
package = "netlify-plugin-no-more-404"

  # all inputs are optional, we just show you the defaults below
  [plugins.inputs]
  
  # either "warn" or "error"
  on404 = "error" 
  
  # change this key to a new one any time you need to restart from scratch
  cacheKey = "MyCacheKey"
  
  # (for development) turn true for extra diagnostic logging
  debugMode = false

What It Does

On first run, we scan your publish directory and save a manifest of all your html files to a cache. The cache is a simple JSON file using a cacheKey.

On subsequent runs:

  • we read the manifest from the cache
  • read any _redirects or netlify.toml redirects you may have
  • match it against your new publish directory for missing paths (we are agnostic whether you use /foo or /foo.html or /foo/index.html) not covered by a redirect.
  • By default we fail your build if a missing path is found.
  • If no issues found, we save a new manifest to cache for the next run.

This cache is cleared when you "clear cache and deploy site" in the Netlify UI - I dont know how to get around this yet.

You can see the /tests folder for a definitive guide on what we test against.

Note: if your netlify.toml redirects have conditions, we don't account for that since we can't be sure to exhaustively check all conditions. We just ignore conditions for now.

Future plans

WE ARE SEEKING MAINTAINERS. I probably wont have time to attend to this full-time.

  • Local (Netlify Dev) testing as a prepush script?

  • persist through "clear cache and deploy site".

  • Maybe exhaustively check netlify.toml redirect conditions?

  • An option for graceful downgrade when some paths are moved to serverless or clientside rendering (right now you have to bump cacheKey to reindex from scratch)

  • We could add a preserveBuildIds config:

    plugins:
      - package: netlify-plugin-no-more-404
        config:
          on404: 'error'
          cacheKey: 'anystring' 
          preserveBuildIds: # compare vs specific build IDs to ensure no regression
          - abc123
          - def345
          - ghi678