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

next-env-police

v0.1.1

Published

next-env-police

Downloads

8

Readme

Next Env Police 🚓

searches a built nextjs static directory for any env variables not prefixed as public

what is this

This is a cli tool to check a nextjs build directory for an env variables that might have slipped out.

It will look for any environment variables not prefixed with NEXT_PUBLIC, then search the .next/static directory for all .js files that contain the value of any of those variables. It will log out a warning in the console if it finds any -- this change be changed to throw via options.

how to use

In your nextjs project you should have a next build script. simply tack an additional step onto the end of that, eg modify your build script in package.json to the following;

    "build": "next build && next-env-police",

options (beta)

Create a .next-env-police.json with the following;

{
    "envs": [
        ".env"
    ],
    "ignoreVarsByPrefix": [
        "NEXT_PUBLIC"
    ],
    "dir": ".next/static",
    "verbose": false,
    "throws: "false
}

You can ad multiple .env files, if there are are multiple you want to check, such as .env.production.

If there are certain env variabes you wan to ignore, you can add them to ignoreVarsByPrefix. Note: code is checking if key.startsWith(ignoreVarsByPrefix[x])

Code only looks in .next/static by default. I doubt you want to check the server files, since the vars are likely needed there.

verbose option as true will log out additional info.

If throws option is true, will throw an error to bust a CI.

tests

to test library internally;

yarn build
yarn start -o test/fixtures/.test.next-env-police.json