dotenv-diff 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lucas Bringsken
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,133 @@
1
+ Metadata-Version: 2.4
2
+ Name: dotenv-diff
3
+ Version: 0.1.0
4
+ Summary: Lightweight tool for quickly spotting missing keys and differing values in .env files
5
+ Author: Lucas Bringsken
6
+ Author-email: Lucas Bringsken <kontakt@lucasbringsken.de>
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Requires-Dist: pandas>=3.0.0
10
+ Requires-Dist: rich>=14.3.2
11
+ Requires-Dist: typer>=0.21.1
12
+ Requires-Python: >=3.12
13
+ Description-Content-Type: text/markdown
14
+
15
+ # [dotenv-diff](https://github.com/LucasBringsken/dotenv-diff)
16
+
17
+ [![PyPI](https://img.shields.io/pypi/v/dotenv-diff)](https://pypi.org/project/dotenv-diff/)
18
+ ![Python](https://img.shields.io/pypi/pyversions/dotenv-diff)
19
+ ![License](https://img.shields.io/github/license/LucasBringsken/dotenv-diff)
20
+ ![Build](https://github.com/LucasBringsken/dotenv-diff/actions/workflows/release.yml/badge.svg)
21
+
22
+
23
+ **Lightweight tool for quickly spotting missing keys and differing values in .env files**
24
+
25
+ `dotenv-diff` helps compare multiple `.env` files and immediately see:
26
+
27
+ - Which variables are missing in which files
28
+ - Which values differ between environments
29
+ - A clear matrix overview of all keys and files
30
+
31
+ It is designed as a simple developer utility for projects that maintain multiple environment configurations (local, staging, production, etc.).
32
+
33
+ ---
34
+
35
+ ## Features
36
+
37
+ - Compare any number of `.env` files at once
38
+ - Detect missing keys across environments
39
+ - Detect diverging values
40
+ - Show results in human‑friendly tables
41
+ - Three different views: summary, values, and presence
42
+ - Works with individual files, directories, and glob patterns
43
+
44
+ ---
45
+
46
+ ## Installation
47
+
48
+ ```bash
49
+ pip install dotenv-diff
50
+ ```
51
+
52
+ ---
53
+
54
+ ## Usage
55
+
56
+ All functionality is available through the command line interface.
57
+
58
+ You can pass:
59
+
60
+ - Individual `.env` files
61
+ - Directories containing `.env*` files
62
+ - Glob patterns like `.env.*`
63
+
64
+ ### Commands
65
+
66
+ #### summary
67
+
68
+ Show a high‑level overview of differences.
69
+
70
+ ```bash
71
+ dotenv-diff summary /path/to/.env.*
72
+ ```
73
+
74
+ ```
75
+ ╭─ SUMMARY ───────────────────╮
76
+ │ Total Files: 3 │
77
+ │ Unique Keys: 12 │
78
+ │ Incomplete Keys: 3 │
79
+ │ Diverging Values: 4 │
80
+ ╰─────────────────────────────╯
81
+ Incomplete Key Details
82
+ • REDIS_HOST is missing in:
83
+ ↳ .env.production
84
+ ↳ .env.staging
85
+
86
+ Diverging Value Details
87
+ • APP_ENV
88
+ ↳ .env.local: development
89
+ ↳ .env.production: production
90
+ ↳ .env.staging: staging
91
+ ```
92
+
93
+ #### values
94
+
95
+ Show a matrix of actual values for each key and file.
96
+
97
+ ```bash
98
+ dotenv-diff values /path/to/.env.*
99
+ ```
100
+
101
+ ```
102
+ ╭───────────────────────────────────────────────────────────────╮
103
+ │ VARIABLE │ .env.local │ .env.staging │ .env.production │
104
+ ├─────────────────┼────────────┼──────────────┼─────────────────┤
105
+ │ APP_ENV │ development│ staging │ production │
106
+ │ DEBUG │ true │ true │ false │
107
+ │ LOG_LEVEL │ DEBUG │ — │ INFO │
108
+ │ DATABASE_USER │ dev_user │ prod_user │ prod_user │
109
+ │ DATABASE_PASS │ dev_pass │ prod_pass │ prod_pass │
110
+ │ PORT │ 8000 │ 8000 │ — │
111
+ ╰───────────────────────────────────────────────────────────────╯
112
+ ```
113
+
114
+ #### presence
115
+
116
+ Show only whether a variable exists in each file.
117
+
118
+ ```bash
119
+ dotenv-diff presence /path/to/.env.*
120
+ ```
121
+
122
+ ```
123
+ ╭───────────────────────────────────────────────────────────────╮
124
+ │ VARIABLE │ .env.local │ .env.staging │ .env.production │
125
+ ├─────────────────┼────────────┼──────────────┼─────────────────┤
126
+ │ APP_ENV │ ✅ │ ✅ │ ✅ │
127
+ │ DEBUG │ ✅ │ ✅ │ ✅ │
128
+ │ LOG_LEVEL │ ✅ │ ❌ │ ✅ │
129
+ │ DATABASE_USER │ ✅ │ ✅ │ ✅ │
130
+ │ DATABASE_PASS │ ✅ │ ✅ │ ✅ │
131
+ │ PORT │ ✅ │ ✅ │ ❌ │
132
+ ╰───────────────────────────────────────────────────────────────╯
133
+ ```
@@ -0,0 +1,119 @@
1
+ # [dotenv-diff](https://github.com/LucasBringsken/dotenv-diff)
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/dotenv-diff)](https://pypi.org/project/dotenv-diff/)
4
+ ![Python](https://img.shields.io/pypi/pyversions/dotenv-diff)
5
+ ![License](https://img.shields.io/github/license/LucasBringsken/dotenv-diff)
6
+ ![Build](https://github.com/LucasBringsken/dotenv-diff/actions/workflows/release.yml/badge.svg)
7
+
8
+
9
+ **Lightweight tool for quickly spotting missing keys and differing values in .env files**
10
+
11
+ `dotenv-diff` helps compare multiple `.env` files and immediately see:
12
+
13
+ - Which variables are missing in which files
14
+ - Which values differ between environments
15
+ - A clear matrix overview of all keys and files
16
+
17
+ It is designed as a simple developer utility for projects that maintain multiple environment configurations (local, staging, production, etc.).
18
+
19
+ ---
20
+
21
+ ## Features
22
+
23
+ - Compare any number of `.env` files at once
24
+ - Detect missing keys across environments
25
+ - Detect diverging values
26
+ - Show results in human‑friendly tables
27
+ - Three different views: summary, values, and presence
28
+ - Works with individual files, directories, and glob patterns
29
+
30
+ ---
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install dotenv-diff
36
+ ```
37
+
38
+ ---
39
+
40
+ ## Usage
41
+
42
+ All functionality is available through the command line interface.
43
+
44
+ You can pass:
45
+
46
+ - Individual `.env` files
47
+ - Directories containing `.env*` files
48
+ - Glob patterns like `.env.*`
49
+
50
+ ### Commands
51
+
52
+ #### summary
53
+
54
+ Show a high‑level overview of differences.
55
+
56
+ ```bash
57
+ dotenv-diff summary /path/to/.env.*
58
+ ```
59
+
60
+ ```
61
+ ╭─ SUMMARY ───────────────────╮
62
+ │ Total Files: 3 │
63
+ │ Unique Keys: 12 │
64
+ │ Incomplete Keys: 3 │
65
+ │ Diverging Values: 4 │
66
+ ╰─────────────────────────────╯
67
+ Incomplete Key Details
68
+ • REDIS_HOST is missing in:
69
+ ↳ .env.production
70
+ ↳ .env.staging
71
+
72
+ Diverging Value Details
73
+ • APP_ENV
74
+ ↳ .env.local: development
75
+ ↳ .env.production: production
76
+ ↳ .env.staging: staging
77
+ ```
78
+
79
+ #### values
80
+
81
+ Show a matrix of actual values for each key and file.
82
+
83
+ ```bash
84
+ dotenv-diff values /path/to/.env.*
85
+ ```
86
+
87
+ ```
88
+ ╭───────────────────────────────────────────────────────────────╮
89
+ │ VARIABLE │ .env.local │ .env.staging │ .env.production │
90
+ ├─────────────────┼────────────┼──────────────┼─────────────────┤
91
+ │ APP_ENV │ development│ staging │ production │
92
+ │ DEBUG │ true │ true │ false │
93
+ │ LOG_LEVEL │ DEBUG │ — │ INFO │
94
+ │ DATABASE_USER │ dev_user │ prod_user │ prod_user │
95
+ │ DATABASE_PASS │ dev_pass │ prod_pass │ prod_pass │
96
+ │ PORT │ 8000 │ 8000 │ — │
97
+ ╰───────────────────────────────────────────────────────────────╯
98
+ ```
99
+
100
+ #### presence
101
+
102
+ Show only whether a variable exists in each file.
103
+
104
+ ```bash
105
+ dotenv-diff presence /path/to/.env.*
106
+ ```
107
+
108
+ ```
109
+ ╭───────────────────────────────────────────────────────────────╮
110
+ │ VARIABLE │ .env.local │ .env.staging │ .env.production │
111
+ ├─────────────────┼────────────┼──────────────┼─────────────────┤
112
+ │ APP_ENV │ ✅ │ ✅ │ ✅ │
113
+ │ DEBUG │ ✅ │ ✅ │ ✅ │
114
+ │ LOG_LEVEL │ ✅ │ ❌ │ ✅ │
115
+ │ DATABASE_USER │ ✅ │ ✅ │ ✅ │
116
+ │ DATABASE_PASS │ ✅ │ ✅ │ ✅ │
117
+ │ PORT │ ✅ │ ✅ │ ❌ │
118
+ ╰───────────────────────────────────────────────────────────────╯
119
+ ```
@@ -0,0 +1,21 @@
1
+ [project]
2
+ name = "dotenv-diff"
3
+ version = "0.1.0"
4
+ authors = [{ name = "Lucas Bringsken", email = "kontakt@lucasbringsken.de" }]
5
+ description = "Lightweight tool for quickly spotting missing keys and differing values in .env files"
6
+ readme = "README.md"
7
+ requires-python = ">=3.12"
8
+ dependencies = ["pandas>=3.0.0", "rich>=14.3.2", "typer>=0.21.1"]
9
+ license = "MIT"
10
+ license-files = ["LICEN[CS]E*"]
11
+
12
+ [project.scripts]
13
+ dotenv-diff = "dotenv_diff.cli:app"
14
+
15
+ [build-system]
16
+ requires = ["uv_build >= 0.9.28, <0.10.0"]
17
+ build-backend = "uv_build"
18
+
19
+
20
+ [dependency-groups]
21
+ dev = ["black>=26.1.0", "ruff>=0.15.0"]
File without changes
@@ -0,0 +1,5 @@
1
+ from .cli import app
2
+
3
+
4
+ if __name__ == "__main__":
5
+ app()
@@ -0,0 +1,53 @@
1
+ from pathlib import Path
2
+ from .core import compare
3
+ from .utils import expand_paths
4
+ from .output import print_summary, print_value_matrix, print_presence_matrix
5
+ import typer
6
+ from typing import List
7
+
8
+ app = typer.Typer(
9
+ help="Lightweight tool for quickly spotting missing keys and differing values in .env files",
10
+ add_completion=False,
11
+ )
12
+
13
+
14
+ @app.callback(invoke_without_command=True)
15
+ def _app_callback(
16
+ ctx: typer.Context,
17
+ ):
18
+ if ctx.obj is None:
19
+ ctx.obj = {}
20
+
21
+ if ctx.invoked_subcommand is None:
22
+ typer.echo(ctx.get_help())
23
+ raise typer.Exit(code=1)
24
+
25
+
26
+ @app.command()
27
+ def summary(
28
+ file_paths: List[Path] = typer.Argument(..., help="Paths to .env files"),
29
+ ):
30
+ """Show a diff summary for the provided files."""
31
+ file_paths = expand_paths(list(file_paths))
32
+ variable_map = compare(file_paths)
33
+ print_summary(variable_map)
34
+
35
+
36
+ @app.command()
37
+ def values(
38
+ file_paths: List[Path] = typer.Argument(..., help="Paths to .env files"),
39
+ ):
40
+ """Show value diffs as a matrix."""
41
+ file_paths = expand_paths(list(file_paths))
42
+ variable_map = compare(file_paths)
43
+ print_value_matrix(variable_map)
44
+
45
+
46
+ @app.command()
47
+ def presence(
48
+ file_paths: List[Path] = typer.Argument(..., help="Paths to .env files"),
49
+ ):
50
+ """Show presence diffs as a matrix."""
51
+ file_paths = expand_paths(list(file_paths))
52
+ variable_map = compare(file_paths)
53
+ print_presence_matrix(variable_map)
@@ -0,0 +1,24 @@
1
+ from collections import defaultdict
2
+ from pathlib import Path
3
+ from rich import print as pprint
4
+ import typer
5
+
6
+
7
+ def compare(file_paths: list[Path]) -> defaultdict:
8
+ variable_map = defaultdict(dict)
9
+ for path in file_paths:
10
+ file_content = path.read_text()
11
+ file_lines = file_content.splitlines()
12
+
13
+ for line in file_lines:
14
+ if not line.strip() or "=" not in line:
15
+ continue
16
+
17
+ key, value = line.split("=", 1)
18
+ variable_map[key.strip()][str(path)] = value.strip()
19
+
20
+ if len(variable_map) == 0:
21
+ pprint("[yellow bold]No variables found in provided files.[/yellow bold]")
22
+ raise typer.Exit(code=1)
23
+
24
+ return variable_map
@@ -0,0 +1,118 @@
1
+ from pandas import DataFrame
2
+ from rich.console import Console, Group
3
+ from rich.panel import Panel
4
+ from rich.rule import Rule
5
+ from rich.table import Table
6
+ from rich import box
7
+
8
+ console = Console()
9
+
10
+
11
+ def print_summary(map: dict):
12
+ df = DataFrame.from_dict(map, orient="index")
13
+ num_files = len(df.columns)
14
+ num_vars = len(df.index)
15
+
16
+ incomplete_mask = df.isna().any(axis=1)
17
+ diverging_mask = df.nunique(axis=1) > 1
18
+
19
+ missing_count = int(incomplete_mask.sum())
20
+ modified_count = int(diverging_mask.sum())
21
+
22
+ summary_content = Group(
23
+ "[bold cyan]SUMMARY[/bold cyan]",
24
+ Rule(style="bright_black"),
25
+ f"[bold]Total Files:[/bold] [green]{num_files}[/green]",
26
+ f"[bold]Unique Keys:[/bold] [blue]{num_vars}[/blue]",
27
+ f"[bold]Incomplete Keys:[/bold] [red]{missing_count}[/red]",
28
+ f"[bold]Diverging Values:[/bold] [yellow]{modified_count}[/yellow]",
29
+ )
30
+ console.print(
31
+ Panel(
32
+ summary_content, expand=False, border_style="bright_black", padding=(1, 2)
33
+ )
34
+ )
35
+
36
+ if missing_count > 0:
37
+ incomplete_details = []
38
+ for key, row in df[incomplete_mask].iterrows():
39
+ missing_in = row.index[row.isna()].tolist()
40
+
41
+ incomplete_details.append(f"• [bold red]{key}[/bold red] is missing in:")
42
+
43
+ for file in missing_in:
44
+ incomplete_details.append(f" [dim]↳ {file}[/dim]")
45
+
46
+ incomplete_details.append("")
47
+
48
+ console.print(
49
+ Panel(
50
+ Group(*incomplete_details[:-1]),
51
+ title="[red]Incomplete Key Details[/red]",
52
+ title_align="left",
53
+ border_style="red",
54
+ padding=(1, 2),
55
+ )
56
+ )
57
+
58
+ if modified_count > 0:
59
+ diverging_details = []
60
+ for key, row in df[diverging_mask].iterrows():
61
+ values = row.dropna()
62
+
63
+ diverging_details.append(f"• [bold yellow]{key}[/bold yellow]")
64
+
65
+ for file, val in values.items():
66
+ diverging_details.append(f" [dim]↳ {file}:[/dim] [cyan]{val}[/cyan]")
67
+
68
+ diverging_details.append("")
69
+
70
+ console.print(
71
+ Panel(
72
+ Group(*diverging_details[:-1]),
73
+ title="[yellow]Diverging Value Details[/yellow]",
74
+ title_align="left",
75
+ border_style="yellow",
76
+ padding=(1, 2),
77
+ )
78
+ )
79
+
80
+
81
+ def print_value_matrix(map: dict):
82
+ df, table = build_matrix(map)
83
+
84
+ for idx, row in df.iterrows():
85
+ table.add_row(
86
+ str(idx),
87
+ *[str(v) if v == v else "[red bold]—[/red bold]" for v in row],
88
+ )
89
+
90
+ console.print(table)
91
+
92
+
93
+ def print_presence_matrix(map: dict):
94
+ df, table = build_matrix(map, center_values=True)
95
+
96
+ for idx, row in df.iterrows():
97
+ table.add_row(str(idx), *["✅" if v == v else "❌" for v in row])
98
+
99
+ console.print(table)
100
+
101
+
102
+ def build_matrix(map: dict, center_values: bool = False) -> tuple[DataFrame, Table]:
103
+ df = DataFrame.from_dict(map, orient="index")
104
+
105
+ table = Table(
106
+ show_header=True,
107
+ header_style="bold magenta",
108
+ box=box.ROUNDED,
109
+ border_style="bright_black",
110
+ )
111
+ table.add_column("VARIABLE", style="bold")
112
+
113
+ for col in df.columns:
114
+ table.add_column(
115
+ col, style="cyan", justify="center" if center_values else "default"
116
+ )
117
+
118
+ return (df, table)
@@ -0,0 +1,20 @@
1
+ from pathlib import Path
2
+ from rich import print as pprint
3
+ import typer
4
+
5
+ def expand_paths(raw_paths: list[Path]) -> list[Path]:
6
+ expanded: list[Path] = []
7
+
8
+ for path in raw_paths:
9
+ if path.is_dir():
10
+ expanded.extend(path.glob(".env*"))
11
+ continue
12
+ if "*" in path.name:
13
+ expanded.extend(path.parent.glob(path.name))
14
+ continue
15
+ if path.exists():
16
+ expanded.append(path)
17
+ else:
18
+ pprint(f"[red bold]File not found:[/red bold] {path}")
19
+ raise typer.Exit(code=1)
20
+ return expanded