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

dotenv-generator

v0.1.8

Published

Creates an env file from a template or an example .env file

Downloads

3

Readme

Contributors Forks Stargazers Issues MIT License

About The Project

asciicast

I hate having to manually think about setting up my .env files every time I have to bring up a new project without understanding any of the keys. Installing new packages also kind of implies that you manually go through the process to make and also understand the .env file that you need to have in order for the package to run successfully.

This should make that process smoother by making it interactive leaving less room for error while making for a nicer installation experience (think of zip files vs install wizards).

Getting Started

The project is very simple to setup, clone and run yarn to install dependencies. To run the project execute yarn start. You should have an example env file (default env.example) that will be used to generate the setup flow. It shouldn't be anything special so if you already have it chances are you can use it with dotenv-generator. You can also use comments ("#") to provide a description for the env value. By default you can put comments above the variable to describe it, or you can use an inline comment after the variable and the default value.

Installation

Run yarn to install dependencies

Testing

Run yarn test to execute tests. To generate coverage run yarn coverage

Usage

Example env file

# Comment that will be applied as description to the variable after it
PUBLIC=STRINGY
# Comment that will override the inline comment
BOOLEAN=true # Inline comment that will be overriden that you can use for additional info but not for setup
NUMBEROO=2
SECRETSTUFF=bar # Inline comment that will be displayed during setup
SECRET=2
# Comment that will be ignored

With the given example file the setup flow would be as following:

  • The first value would have the description as the first line comment for the value "PUBLIC" with the default value of "STRINGY". Enter applies the default value.
  • The second value would have the description of the third line comment for the value "BOOLEAN" with the default value of "true". Only boolean values would be accepted here.
  • The third value would have the generated description and it would look like this "Enter the value, type number, for NUMBEROO: 2". Only numbers would be accepted here.
  • The fourth value would have the description of the inline comment for the value "SECRETSTUFF" with the default value of "bar".
  • The last value would have the generated description.
  • The last line comment would be ignored and wouldn't impact the setup.

The following recording demonstrates this:

asciicast

How to use dotenv-generator

The easiest way to use this package is to run it (Duh). You can add a configure script to your package.json file that runs dotenv-generator. If you want users to execute this script let them know by asking them to perform this after installation npm explore {name_of_the_package} -- npm run configure.

Postinstall

Ideally your project should use dotenv-generator --postinstall as a postinstall action. This means that after installation of your package, dotenv-generator will be run. This allows for a seamless setup of your project that will magically happen after installation. Since this is not an ideal world npm 6+ doesn't play nice with interactive postinstall hooks so I've added a check for that if you include the --postinstall flag it will check the npm version and for npm 6+ the script won't execute the interactive flow.It will instead print a message saying that the configuration could be done by executing npm explore {name_of_the_package} -- npm run postinstall. To view this output you must include --foreground-scripts as a flag for package installation ie. npm i --foreground-scripts.

Don't forget to include an .env.example file with descriptions of your fields in the root directory, or anywhere else but then specifying -f inputFilePath.

Global

You can also install this package globally by running npm i -g dotenv-generator. After this you can use dotenv-generator anywhere. This makes it really simple to setup multiple projects without having to worry about the generator being a dependency.

Parameters

Available parameters are:

  • -f, --file - The environment file name to be used as an example
  • -o, --output - The environment file name to be used as an output
  • -pi, --postinstall - If set the script will check for npm version
  • -d, --debug - A flag to enable writing debug output to stdout

After completed installation your package folder inside of node_modules will contain a .env file with the provided values that your package can then use.

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this project better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE.md for more information.

Contact

Nenad Lukic - @lnenad