README
dotenv-extended-prepare
I like high development convenience. Almost every new project has its .env schemas/examples/samples or defaults. Usually, after cloning a new repository, the developer has to not just enter environment variables, but also search for their names, check which ones are already set by default and create an .env file.
This package protects developers from manually doing boring stuff — isn't that what we're here for?
Just run npm i
on a new repo, and .env
preset will be sitting in the top-level directory for you to fill it.
Preview
The newly created
.env
file contains required variable names with=
on line end:
NODE_ENV=
# PORT=
# npm_package_name=
TOKEN=
Variables from
.env.defaults
are taken as optional — commented out with#
on line start.
The
.env.schema
variables definitely want you to fill them in.
Installation
For manual usage
- Perform a global installation:
npm i -g dotenv-extended-prepare
- Simply run it after cloning another genius repo telling you to scrap around the files looking for variable names
dotenv-extended-prepare
For making your own repo automatically 100% top-level
- Install
dotenv-extended-prepare
as a development dependency:
npm i -D dotenv-extended-prepare
- Specify a
postinstall
script in your package file — it will run onnpm i
# package.json
"scripts": {
"postinstall": "dotenv-extended-prepare"
}
If you need to specify a custom path or name to schemas/defaults, or you don't use
dotenv-extended
at all, or you prefer using regular OGdotenv
like our grandpas did and your env sample is named.env.example
— just wait a couple of days. I'm planning to add more names for auto-search and some configuration.
Bonuses
- A safe one-liner for adding "postinstall" to
package.json
:
node -e "let pkg=require('./package.json'); pkg.scripts.postinstall=pkg.scripts.postinstall??'dotenv-extended-prepare'; require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2));"