Coder Social home page Coder Social logo

enwire's Introduction

image

enwire

Tool for "re-wiring" environment variables.

  • Supports .json format
  • Supports .env format

Installation

npm install --global enwire

or use enwire without installation:

npx enwire
npx enwire --no-process -r HOME
cat package.json | npx enwire --pick name --no-process
cat .env | npx enwire --pick foo --no-process

dotenv-like Usage

Create a .env file with your env vars.

FOO=bar

Run your app with your env vars.

cat .env | enwire node app.js

Usage

Print all env vars.

enwire

Print selected env vars.

enwire --no-process --rewire HOME
# {"HOME": "..."}

Export in env var format.

enwire --no-process --rewire HOME --format env
# HOME="..."

Rewire env vars.

enwire --no-process --rewire HOME:TROLOLO
# {"TROLOLO": "..."}

Pass string as an env var.

echo Hello | enwire --raw --no-process
# {"ENWIRE": "Hello"}

Set custom name for string variable.

echo Hello | enwire --raw --no-process --name HELLO
# {"HELLO": "Hello"}

Populate env vars from JSON.

echo '{"db": "Test"}' | enwire --no-process
# {"db": "Test"}

Rewire JSON env vars.

echo '{"db": "Test"}' | enwire --no-process --rewire db:PGDATABASE --delete db
# {"PGDATABASE": "Test"}

Print project name.

cat package.json | enwire --no-process --pick name
# {"name": "enwire"}

Rewire nested keys from JSON.

cat package.json | enwire --no-process --no-merge --rewire scripts.test:TEST_CMD
# {"TEST_CMD": "./test.sh"}

Pass project name to printenv NAME script.

cat package.json | enwire --rewire name:NAME -- printenv NAME
# enwire

Pass env vars to yarn deploy script.

enwire --rewire AWS_PROFILE_PROD:AWS_PROFILE -- yarn deploy

Rewire environment variables.

db=Test enwire --rewire db:PGDATABASE -- printenv PGDATABASE
# Test

Evaluate arguments as JavaScript template strings.

HELLO=Hello enwire --eval -- echo "\${HELLO}, \${USER + '\!'}"
# Hello, user!

Prompt user to enter env var in console.

enwire --prompt TEST -- printenv TEST

Options

npx enwire --help

  • --delete, -d โ€” environment variable to delete.
  • --eval, -e โ€” evaluate CLI argumens as JS template strings.
  • --import, -i โ€” import and merge extra .json and .env files into process env
  • --prompt, -p โ€” prompt user to input variable in console if not set.
  • --rewire, -r โ€” from-to mapping of environment variable, e.g. --rewire db:PGDATABASE.
  • --delete-rewired โ€” if specified, rewired environment variables will be deleted.
  • --format โ€” by default exports in JSON format, --format=env can be set to export in env var format.
  • --no-process โ€” if specified, process environment variables will not be included.
  • --no-stdin โ€” don't merge STDIN into output.
  • --pick โ€” specifies which keys to pick from JSON object provided through STDIN.
  • --help, -h โ€” show usage info.
  • --version, -v โ€” show enwire version.

enwire's People

Contributors

semantic-release-bot avatar streamich avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

enwire's Issues

--add option

-add option would be the same as --import option, but it would not overwrite env vars if, which are already set.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.