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

@nixup/env-tools

v1.0.5

Published

A node.js module with some tools to validate env specific file of your project

Downloads

214

Readme

env-tools

A node.js module with some tools to validate env specific file of your project.

This tool compares your env file with your schema file.

If any missing keys are found, then it throws an error on the console and requests you to enter the respective missing values. This can be disabled with -q or --quiet option.

If any additional key is found in the env file which is not specified in the schema file, then only a warning will be shown on the console if the quiet option is not set.

Install

Install as a dev-dependency

npm install @nixup/env-tools --save-dev

Or installing with yarn? yarn add --dev @nixup/env-tools

Usage

  • Example 1: If you have .env.schema file in the current working directory, and you want to check whether all the keys specified in the schema file are there in the .env file or not.

sample .env.schema file

PUBLIC_KEY=
PRIVATE_KEY=*
ANOTHER_SECRETE_KEY=*
WEBSITE_URL=

then with npx you can run

npx env-tools
  • Example 2: run in quiet mode, it will only throw an error if any missing keys are found or exit without any error or warning
npx env-tools -q

You can also add this to prebuild script in your package.json, so that it will execute every time before the build script is executed.

prebuild: env-tools -q
  • Example 3: you can specify different env and schema file path
npx env-tools -e ./src.env.local -s ./src/.env.schema

Default configuration

{
  "envFilePath": "./.env",
  "envSchemaFilePath": "./.env.schema",
  "charEncoding": "utf8"
}

You can override these settings by adding the file env-config.json in the same directory from where you are going to run the env-tool command. Or you can also provide a custom configuration file path with -c option.

env-config.json take precedence over the default configuration and if custom config file path is also provided with option -c, then that configuration will take precedence over the other configurations.

Available command arguments

The options specified here precede the default configurations.

-c or --config-path: Provide an alternative configuration file path to override default configuration options.
-e or --env-path: Specify a custom path to the env file.
-s or --schema-path: Specify a custom path to the env schema file.
-q or --quiet: Exit with an error if missing or extra keys are found, without prompting for missing values.
  1. -c or --config-path: provide an alternative configuration file path. This will only override the above default configuration. ex. you can only override envFilePath and envSchemaFilePath in your configuration.

env-config.json

{
  "envFilePath": "./src/.env.local",
  "envSchemaFilePath": "./src/.env.schema"
}
npx env-tools --config-path=env-config.json
  1. -e or --env-path: you can give the location of the env file and override the path specified in the default configuration.

  2. -s or --schema-path: you can give the location of the env-schema file and override the path specified in the default configuration.

  3. -q or --quiet: if you specify this option and there are missing or extra keys, the tool will exit with error code 1. And it will not ask for missing keys.