envv-flow
Version:
A simple package to manage and switch between environment files.
214 lines (133 loc) • 5.25 kB
Markdown
# 🌊 Envv Flow - [](https://www.npmjs.com/package/envv-flow) [](https://npmjs.org/package/envv-flow)
### *Because who needs hardcoded `.env` files?*
Welcome to **Envv Flow**, the tool that lets you swap out environment files as easily as changing your socks (well... almost). No more manual copy-pasting or git mishaps—just smooth sailing between local, staging, and production environments.
## 🚨 The Problem
You’ve got multiple environments—`local`, `staging`, `production`—and each one has its own `.env` file.
But your app keeps getting confused:
* One minute it’s connected to your **local** database...
* The next, it’s wreaking havoc in **production**. 😱
Enter **Envv Flow** — your new favorite way to manage and switch `.env` files effortlessly.
## ✅ The Solution
Envv Flow makes it easy to manage multiple .env files across environments.
When you run it, it simply takes the desired environment file—like .env.local, .env.stage, or .env.production—and copies its contents into your main .env file.
That’s it.
No more renaming files, no more manual copy-pasting—just a clean, consistent .env file ready for whatever environment you're working in.
Just clean, controlled environment switching.
## ✨ Key Features
* **🔁 Environment Magic:** Switch between `.env.local`, `.env.stg`, `.env.prod`, or any custom `.env` file with a single command.
* **🧘 Zero Fuss:** No more manual renaming or copy-pasting.
* **⚙️ Customizable:** Define your own mappings in a simple `config.json` file.
* **📦 Easy to Use:** Works with any Node.js project. Just install it as a dev dependency.
## 📦 Installation
Install **Envv Flow** as a development dependency:
```bash
npm install --save-dev envv-flow
```
Perfect — here's the updated **🛠️ Configuration** section incorporating the new `env-flow-init` command, and guiding users through the rest.
## 🛠️ Configuration
To get started, just run:
```bash
npx env-flow-init
```
This will automatically create a `config.json` file in the root of your project with the following default content:
```json
{
"local": ".env.local",
"stg": ".env.stage",
"prod": ".env.production"
}
```
This file maps environment names to their corresponding `.env` files.
> 💡 You can customize this mapping however you like. Want to use `.env.dev` instead of `.env.local`? No problem—just update the values in `config.json`.
For example:
```json
{
"dev": ".env.dev",
"qa": ".env.qa",
"prod": ".env.prod"
}
```
Env Flow will use this mapping whenever you run a switch command.
Thanks! Here's the **updated Usage section** reflecting your new command structure:
## 🚀 Usage
After setting up your `config.json` (using `npx env-flow-init`), you’re ready to flow through environments like a breeze. 🌬️
### 🔄 Switch Environments
```bash
npx env-flow switch <env-name>
```
**Example:**
```bash
npx env-flow switch local
```
This copies the contents of `.env.local` (or whatever file is mapped in `config.json`) into your main `.env` file. ✅
### 📋 List Available Environments
```bash
npx env-flow list
```
This will output all available environment mappings from your `config.json` so you know exactly what you can switch to.
### 📌 Check Current Environment
```bash
npx env-flow status
```
This shows which environment is currently active (based on the contents of `.env` and what it matches in your config).
## 📚 Example
Let’s say you have the following `.env` files:
**.env.local**
```
DB_HOST=localhost
DB_USER=root
DB_PASS=password
```
**.env.stage**
```
DB_HOST=staging-db.example.com
DB_USER=stg_user
DB_PASS=stg_password
```
**.env.production**
```
DB_HOST=prod-db.example.com
DB_USER=prod_user
DB_PASS=prod_password
```
You can switch to your local environment like this:
```bash
npx env-flow switch local
```
**And BAM!** 🎉 Your `.env` is now loaded with local settings—ready to go.
## ❤️ Why You’ll Love It
* Tired of juggling multiple `.env` files?
✔️ This solves it.
* Nervous about pushing the wrong config to production?
✔️ Safe switching.
* Want more time coding, less time debugging config issues?
✔️ You’re welcome.
## 🙌 Contributing
Found a bug?
Got an idea for a killer feature?
Please open an issue or submit a pull request. This project thrives on your feedback and contributions!
## 💭 Final Thoughts
If you’ve ever felt the frustration of managing `.env` files manually, **Envv Flow** is here to save the day.
Because life’s too short for environment variable drama.
Now go forth, switch with confidence, and let **Envv Flow** handle the work!
## ✍️ Author
Crafted with universe, keyboard rage, and just the right amount of “why isn’t this built-in already?” by [cinfinit](https://github.com/cinfinit).
If this saved you from one more accidental .env.production mishap in local dev—
you’re welcome. 😎
Feel free to send praise, bug reports, or memes.
No feature requests on Mondays. 😉