Skip to content

Introduction

Matt Carlotta edited this page Nov 3, 2023 · 22 revisions

A stand-alone .env file parser for interpolating and assigning ENVs into a process locally or remotely.

Motivation

The idea of having to use a language-specific .env file parser never sat right with me. For example, as of writing this, if I want to run a project with some environment-specific ENVs from a .env file into JavaScript, I need to use a JavaScript specific parser. Same holds true for any other language: Rust, Golang, Python, and C++ to name a few.

Therefore, I sought out to ask the question: What if, instead of using a language-specific parser, there was a language agnostic .env file parser? Could it be done? And could it be done efficiently WITHOUT using some overly complicated, hard-to-maintain regular expression?

One other motivating factor for the creation of this project came about while working at a small start up company: How can we share ENVs across teams and across services?

In that role, the best way to share was to:

  • Use LastPass (which contained ENVs that were out of date)
  • Go to the 3rd party service and manually copy each ENV (which requires access to said 3rd party service)
  • Create a one time secret using some 3rd party website (hopefully they're legitimate and going to remove the secrets after viewing)
  • Share it via Slack and then delete the message (always the best solution when in a bind) 💀

Neither of the above solutions seemed ideal to me, so I wanted to not only create a universal .env file parser, but also a flexible tool to retrieve ENVs remotely and securely.

Solution

The nvi CLI tool aims to:

  • be simple to use
  • not hinder development
  • be open sourced and licensed under GNU GPL 3.0
  • act as a universal .env file parser by preprocessing one or many .env files
  • have the ability to check if ENVs are missing before a child process starts
  • assign ENVs to a parent process that allows a child process to run as intended
  • work locally (offline) OR remotely (online)
  • be as transparent as possible while being secure as possible
  • be flexible and extensible for adding new features
  • be easy to maintain by not relying upon any complicated regular expressions

By achieving these goals, new developers will have the opportunity to join the community and consequently help improve the nvi CLI tool for all users!