All Projects → Tekill → env-diff

Tekill / env-diff

Licence: MIT license
Env-diff is a lightweight library which sync your .env files with .env.dist by composer scripts, hooks or manual running

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to env-diff

salak.rs
A multi layered configuration loader and zero-boilerplate configuration parser.
Stars: ✭ 27 (+12.5%)
Mutual labels:  environment, env
ini
📝 Go INI config management. support multi file load, data override merge. parse ENV variable, parse variable reference. Dotenv file parse and loader. INI配置读取管理,支持多文件加载,数据覆盖合并, 解析ENV变量, 解析变量引用。DotEnv 解析加载
Stars: ✭ 72 (+200%)
Mutual labels:  environment, env
environment
🌳 Environment variable configuration for Node.js made easy.
Stars: ✭ 12 (-50%)
Mutual labels:  environment, env
workbench
A hierarchical environment manager for bash, written in bash.
Stars: ✭ 17 (-29.17%)
Mutual labels:  environment, env
ts-dotenv
Strongly-typed environment variables for Node.js
Stars: ✭ 18 (-25%)
Mutual labels:  environment, env
gatsby-plugin-dynamic-routes
Creating dynamic routes based on your environment and/or renaming existing routes
Stars: ✭ 14 (-41.67%)
Mutual labels:  environment, env
dotenvy
Speed up your production sites by ditching .env for key/value variable pairs as Apache, Nginx, and shell equivalents
Stars: ✭ 31 (+29.17%)
Mutual labels:  environment, env
tfenv
Transform environment variables for use with Terraform (e.g. `HOSTNAME` ⇨ `TF_VAR_hostname`)
Stars: ✭ 120 (+400%)
Mutual labels:  env
envo
A community-driven ontology for the representation of environments
Stars: ✭ 106 (+341.67%)
Mutual labels:  environment
envsafe
🔒 Makes sure you don't accidentally deploy apps with missing or invalid environment variables.
Stars: ✭ 705 (+2837.5%)
Mutual labels:  env
ai-learning-environments
List of environments and competitions for RL and AI training
Stars: ✭ 14 (-41.67%)
Mutual labels:  environment
coffee-boots
Support property-based configuring of multiple Caffeine caches for Spring Cache abstraction.
Stars: ✭ 22 (-8.33%)
Mutual labels:  environment
bash.env
Bash.env is a cascading Bash environment system for those who work on different hardware and OS environments. Similar to oh-my-zsh but for Bash, and special sauce for those who work 'ssh' on remote machines.
Stars: ✭ 50 (+108.33%)
Mutual labels:  environment
EnvReportBC
List of repositories administered by Environmental Reporting BC (www.gov.bc.ca/environmental-reporting-bc)
Stars: ✭ 17 (-29.17%)
Mutual labels:  env
betterconf
Minimalistic Python library for your configs.
Stars: ✭ 35 (+45.83%)
Mutual labels:  env
envclasses
envclasses is a library to map fields on dataclass object to environment variables.
Stars: ✭ 26 (+8.33%)
Mutual labels:  env
tpl
Use go templates with simple and complex environment variables
Stars: ✭ 18 (-25%)
Mutual labels:  environment
wqbc
An R package for water quality thresholds and index calculation for British Columbia
Stars: ✭ 16 (-33.33%)
Mutual labels:  env
jest-environment-selenium
Jest environment for running Selenium WebDriver tests
Stars: ✭ 28 (+16.67%)
Mutual labels:  environment
seed-pixi-typescript
A pre installed environnement to work with pixi.js with webpack & typescript
Stars: ✭ 36 (+50%)
Mutual labels:  environment

EnvDiff

Latest Version on Packagist Software License Build Status Coverage Status Quality Score

EnvDiff is tool to compare environment keys to find the difference between .env files and actualize them.

Example cast

Installation

composer require tekill/env-diff

Manual running

Actualize variables

Compare .env with .env.dist and add missing variables to .env file.

php ./vendor/bin/env-diff actualize

Compare .env with .env.example and add missing variables to .env file.

php ./vendor/bin/env-diff actualize .env.example

Compare .env-target with .env.example and add missing variables to .env-target file.

php ./vendor/bin/env-diff actualize .env.example .env-target

If you want to delete outdated values just run command with -k=false option.

php ./vendor/bin/env-diff actualize -k=false

Show differences

Command has same interface, arguments and options.

Compare .env with .env.dist and show differences between them.

php ./vendor/bin/env-diff diff

Composer script

Add code block in composer.json:

"scripts": {
    "post-update-cmd": "LF\\EnvDiff\\Composer\\ScriptHandler::actualizeEnv"
}

The .env will then be created or updated by the composer script, to match the structure of the dist file .env.dist by asking you the missing variables.

By default, the dist file is assumed to be in the same place than the target .env file, suffixed by .dist. This can be changed in the configuration:

{
    "extra": {
        "lf-env-diff": [
            {
                "dist": "path/to/env.dist",
                "target": "path/to/.env"
            }
        ]
    }
}

The script handler will ask you interactively for variables which are missing in the target env file, using the value of the dist file as default value. If composer is run in a non-interactive mode --no-interaction, the values of the dist file will be used for missing variables.

Warning: This handler will overwrite any comments or spaces into your target .env file so handle with care.

Managing multiple ignored files

The handler can manage multiple ignored files. To use this feature, the lf-env-diff extra should contain a JSON array with multiple configurations inside it instead of a configuration object:

{
    "extra": {
        "lf-env-diff": [
            {
                 "dist": "path/to/.env.dist",
                 "target": "path/to/.env"
            },
            {
                 "dist": "path/to/.env.dist",
                 "target": "path/to/.env-test",
                 "keep-outdated": false
            }
        ]
    }
}

Show difference

Add code block in composer.json:

"scripts": {
    "post-update-cmd": "LF\\EnvDiff\\Composer\\ScriptHandler::showDifference"
}

This handler has same behavior as described before.

Git hooks

You can use Git hook that gets triggered after any 'git pull' whenever one of the files specified has changed. Useful to update any web application dependency or sync configuration.

Create post-merge hook in .git/hooks directory of your project:

#/usr/bin/env bash

changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"

check_run() {
  echo "$changed_files" | grep -E --quiet "$1" && eval "$2"
}

# Actualize env files if the `env.dist` file gets changed
check_run env.dist "php ./vendor/bin/env-diff actualize"
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].