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

env-toolkit

v1.1.0

Published

This is a package that can generate or compare env files for your project.

Downloads

9

Readme

env-toolkit

env-toolkit is a command-line tool for generating and managing environment variables. It scans a directory for environment variables and creates a .env file based on the results. You can configure it to exclude certain folders, specify prefixes for environment variables, and control whether to overwrite existing .env files.

Generating Files

By default, env-toolkit scans the current working directory for environment variables and generates a .env file with the format env-timestamp. You can pass a name for the output file or choose to overwrite the existing .env file.

Scanned directory: my-fancy-project
Excluded folders: node_modules,dist,build,test,.git,build,coverage,public,out,tmp
Total environment variables found: 72
Output file: /my-fancy-project/.env-1722716928992

Printing Variables

Use the --print option to print a table of all the variables found in the current directory, ordered alphabetically.

Scanned directory: my-fancy-project
Excluded folders: node_modules,dist,build,test,.git,build,coverage,public,out,tmp
Total environment variables found: 3
╔════╤════════════════════════════════════════╗
║ #  │ Environment Variables                  ║
╟────┼────────────────────────────────────────╢
║ 1  │ VARIABLE_1                             ║
╟────┼────────────────────────────────────────╢
║ 2  │ VARIABLE_2                             ║
╟────┼────────────────────────────────────────╢
║ 3  │ VARIABLE_3                             ║
╚════╧════════════════════════════════════════╝

Comparing Variables

Use the --compare or -c option to compare your current .env file (default: .env) and see which variables have been added or removed. This helps identify changes rather than simply printing all variables.

The current .env file is out of date!
New variables: 3
Removed variables: 1
┌─────────────────┬──────────────────┐
│ Added Variables │ Removed Variable │
├─────────────────┼──────────────────┤
│ VARIABLE_1      │ VARIABLE_4       │
├─────────────────┼──────────────────┤
│ VARIABLE_2      │                  │
├─────────────────┼──────────────────┤
│ VARIABLE_3      │                  │
└─────────────────┴──────────────────┘

Updating Variables

If you only want to add newly added variables to your existing .env file, use the --update or -u option. This will append the new variables at the end of your .env file with the current time.

# Newly added env variables (time)

VAR1 =
VAR2 =

Installation

To use env-toolkit, you need to have Node.js and npm installed. You can install the package globally using npm:

npm install -g env-toolkit

Usage

You can run env-toolkit using the command line. Below are the available options:

Command Line Options

| Option | Alias | Description | Type | Default Value | | ----------- | ----- | --------------------------------------------------------------------- | --------- | --------------------------------------------------------------------------------------- | | directory | -d | The directory to scan for .env variables | string | Current working directory | | exclude | -e | Folders to exclude from the scan | array | ["node_modules", "dist", "build", "test", ".git", "coverage", "public", "out", "tmp"] | | prefixes | -p | Prefixes used with env variables | array | ["process.env"] | | name | -n | Name of the output .env file | string | .env-timestamp | | output | -o | Directory to place the generated .env file | string | Current working directory | | overwrite | -w | Flag to overwrite the previous .env file | boolean | false | | print | none | Print all of the environment variables found in the directory | boolean | false | | compare | -c | Checks the current .env file and prints the new o removed variables | | | | update | -u | Updates the previous .env file | | | | version | none | Displays the current version | | | | help | -h | List all the commands | | |

Example

  1. It will generate an env in the root directory with name .env-timestamp
env-toolkit
  1. Specify directory and exclude folders:
env-toolkit --directory ./src --exclude '["node_modules", "dist"]'
  1. Specify prefixes and output directory:
env-toolkit --prefixes '["MY_APP"]' --output ./config
  1. Print environment variables without creating a file:
env-toolkit --print
  1. Overwrite existing .env file:
env-toolkit --overwrite

Contributing

Contributions are welcome! Please open an issue or a pull request if you have any improvements or bug fixes.

License

This project is licensed under the ISC License. See the LICENSE file for details.

Author