Thanks to visit codestin.com
Credit goes to github.com

Skip to content

nekrassov01/lem

Repository files navigation

lem logo

The local env manager

The env splitting, delivery, replacement, and monitoring tool for monorepo

CI Go Report Card LICENSE LATEST Ask DeepWiki

Overview

LEM stands for Local Env Manager, and its logo is inspired by Lemmings. This tool is designed for monorepos where back-end APIs, front-end UIs, infrastructure resources, and more are managed together. It provides utilities to centrally manage .env files and distribute them to separate directory roots according to your configuration. The basic concept is to use prefixes for environment variable management, while also supporting unprefixed variables for flexible delivery.

Features

This tool supports the following features:

  • Generate a template for the configuration file
  • Validate configuration with fine granularity
  • Switch stages and persist the current stage
  • Split, replace prefixes, and distribute the central .env to each directory
  • Monitor the central .env and reflect changes automatically
  • Detect empty environment variable values and exit with an error
  • Automatically generate .envrc and use watch_file for direnv integration

Commands

NAME:
   lem - The local env manager for monorepo

USAGE:
   lem [global options] [command [command options]]

VERSION:
   0.0.0 (revision: XXXXXXX)

COMMANDS:
   init      Initialize the configuration file to current directory
   validate  Validate that the configuration file is executable
   stage     Show the current stage context
   switch    Toggle the current stage to the specified stage
   list      Show the env file entries in the current stage
   run       Switch env and deliver env files to the specified directory
   watch     Watch changes in the central env and run continuously

GLOBAL OPTIONS:
   --help, -h     show help
   --version, -v  print the version

Configuration

Set up with TOML format as follows:

[stage]
default = "<central-env-dir>/.env"
dev = "<central-env-dir>/.env.development"
stg = "<central-env-dir>/.env.staging"
prod = "<central-env-dir>/.env.production"

[group.api]
prefix = "API"
dir = "./backend"
replace = ["REPLACEABLE1"]
plain = ["PLAIN1"]
check = true
direnv = ["api", "ui"]

[group.ui]
prefix = "UI"
dir = "./frontend"
replace = ["REPLACEABLE2"]
plain = ["PLAIN2"]
check = true
direnv = ["ui"]

Note

The path must be either relative to the configuration file location or absolute.

Table Key Value Description
stage <string> string The pairs of stage name and .env file path. If not specified, default is used.
group.<id> prefix string The prefixes environment variables to be delivered by the group.
group.<id> dir string The destination for the group to be delivered.
group.<id> replace array<string> The Prefixes of the environment variable to be delivered after being replaced by the prefix defined by the group.
group.<id> plain array<string> The environment variables to be delivered without prefixes.
group.<id> check bool Whether the group performs an empty value check or not.
group.<id> direnv array<id> Automatically generate .envrc in each directory, write watch_file to track changes.

Installation

Install with homebrew

brew install nekrassov01/tap/lem

Install with go

go install github.com/nekrassov01/lem@latest

Or download binary from releases

Shell completion

Supported Shells are as follows:

  • bash
  • zsh
  • fish
  • pwsh
lem completion bash|zsh|fish|pwsh

# In the case of bash
source <(lem completion bash)

Todo

  • Support direnv Integration
  • Logging

Author

nekrassov01

License

MIT

About

The env splitting, delivery, replacement, and monitoring tool for monorepo

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published