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

@caxy/dotenv-updater

v1.0.9

Published

Keep your gitignored local .env file up to date with the dist file.

Downloads

4,979

Readme

npm (scoped) npm

Dotenv Updater

Dotenv Updater is a module that keeps your local, gitignored, .env files up to date with the latest variables defined in a dist/example file, like .env.example.

It compares your .env file with the .env.example (or other file specified in config), and if there any variables missing from your .env file it will interactively prompt you for their values on the command line, and update your .env file for you.

Install

# with npm
npm install --save-dev @caxy/dotenv-updater

# or with Yarn
yarn add --dev @caxy/dotenv-updater

Usage

The primary use-case is to run this script alongside your other npm/Yarn scripts defined in your package.json.

For example, you can add calls to dotenv-updater at the beginning of your commonly run scripts, so that you can ensure you'll always have an up-to-date env file.

# in your package.json

"scripts": {
  "start": "dotenv-updater && node dist/index.js",
  "build": "dotenv-updater && ..."
},
...

You can also run it manually from the command line at the root of the project (or anywhere if installed globally):

dotenv-updater

Configuration

You can add configuration in your package.json file to modify some of the default settings, which you will definitely want to do if your dist file is not named .env.example.

Below shows the configuration options available and their default values.

# in your package.json

{
  # ...

  "dotenvUpdater": {
    "envFile": ".env",
    "distFile": ".env.example",
    "checkExtraVars": true
  }
}

Options

| Option name | Description | Default value | |----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------| | envFile | The name of the local env file. This is the file that will be updated with new variables found in the distFile. This file is often ignored and excluded from source control since it may contain sensitive information. | ".env" | | distFile | The name of the "dist" env file, which serves as the empty template for the environment variables that are available to be defined. This file is often tracked in the repository and has default/placeholder values. | ".env.example" | | checkExtraVars | Boolean flag to enable/disable the "check extra vars" feature. When set to true, the script will check to see if there are any variables defined in the envFile that are not defined in the distFile. If any are found, a message will be printed to the console indicating that there are extra variables not found in the dist file and will include which variables. The idea here is that if there are any extra variables in the envFile, they might be outdated / no longer used and can be removed, or it might be an indication that the distFile is missing some variables that are used and they should be updated with those. This will not remove any variables from the envFile, it will only log a message to the console. | true |