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

create-env

v1.1.1

Published

Create .env files based on CI environmental values

Downloads

577

Readme

:rocket: Create-Env :rocket:

NPM Version License: MIT Build Status Coverage Status codecov npm

create-env is an utility to help you create .env files based on CI/CD environmental values.

Use case

You use Gitlab-CI/CD or another CI/CD to perform a build of a software artifact and you want to use the provided CI/CD secret variables as a .env file. This is where create-env comes to the rescue.

How it Works

You have defined your secret-variables inside of the CI/CD, and your variables uses a prefix like DEV_, TEST_, PROD_. create-env will take the current environment for your CI/CD pipeline, a prefix related to that environment, and the name of the file you want as output.

Then, it will generate that .env file, and remove the prefix of each secret-variable.

e.g:

  • Your secret-variables:
TEST_NODE_ENV=production
TEST_PORT=8080
  • Your .env file output:
NODE_ENV=production
PORT=8080

Installation

create-env needs to be installed as a global dependency:

NPM

npm i -g create-env

YARN

yarn global add create-env

Creating a .env file

To create a .env file you have to run create-env with the following parameters:

# Default
create-env --env-file .env --env-prefix TEST_

# NPX
npx create-env --env-file .env --env-prefix TEST_

create-env comes with a set of default prefixes (DEV_, TEST_, PROD_), if your secret-variables use those default prefixes, you can run create-env with the following parameters, the only thing your have to pass is the env which can be one of development, testing or production:

# Default
create-env --env testing --env-file .env --use-default-prefix

# NPX
npx create-env --env testing --env-file .env --use-default-prefix

TODO

  • [ ] Add --from-template option. (In order to support .env generation based on another .env file).
  • [ ] Add --no-prefix option. (In order to support generate a .env file with all the env variables).
  • [ ] Add --type option. (In order to support other formats like JSON envs).
  • [ ] Add --help option.

Issues

If you raise a bug, please, open an issue.

Contributing

PRs are welcome. Any kind of contribution is welcome.

License

create-env is licensed as MIT.