@guihakka2/envdiff 0.1.0 → 0.1.1

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.
package/README.md CHANGED
@@ -5,6 +5,7 @@ Compare `.env` files across environments (dev, staging, prod, `.env.example`)
5
5
  Safe to run in CI logs, screenshots and pull requests: values are compared in memory, only key names are shown.
6
6
 
7
7
  ```bash
8
+ npx @guihakka2/envdiff # compares .env.example with .env in this folder
8
9
  npx @guihakka2/envdiff .env .env.example --keys-only
9
10
  npx @guihakka2/envdiff .env.staging .env.production
10
11
  ```
package/bin/envdiff.js CHANGED
@@ -3,9 +3,10 @@ import { readFileSync } from 'node:fs';
3
3
  import { parseArgs } from 'node:util';
4
4
  import { compare } from '../src/index.js';
5
5
 
6
- const HELP = `Usage: envdiff <file> <file> [more files...] [options]
6
+ const HELP = `Usage: envdiff [<file> <file> [more files...]] [options]
7
7
 
8
8
  Compares keys across .env files. Values are compared but NEVER printed.
9
+ With no files, compares .env.example and .env in the current folder (keys only).
9
10
 
10
11
  Options:
11
12
  --keys-only Only compare keys (useful against .env.example)
@@ -24,13 +25,19 @@ try {
24
25
  const { values: o, positionals } = args;
25
26
  if (o.help) { console.log(HELP); process.exit(0); }
26
27
  if (o.version) { console.log(JSON.parse(readFileSync(new URL('../package.json', import.meta.url))).version); process.exit(0); }
27
- if (positionals.length < 2) { console.error(HELP); process.exit(2); }
28
+ const zeroArg = positionals.length === 0;
29
+ const names = zeroArg ? ['.env.example', '.env'] : positionals;
30
+ if (names.length < 2) { console.error(HELP); process.exit(2); }
28
31
 
29
32
  let files;
30
- try { files = positionals.map((name) => ({ name, text: readFileSync(name, 'utf8') })); }
31
- catch (e) { console.error(`envdiff: cannot read ${e.path}: ${e.code}`); process.exit(2); }
32
-
33
- const r = compare(files, { keysOnly: o['keys-only'] });
33
+ try { files = names.map((name) => ({ name, text: readFileSync(name, 'utf8') })); }
34
+ catch (e) {
35
+ console.error(`envdiff: cannot read ${e.path}: ${e.code}`);
36
+ if (zeroArg) console.error('With no arguments envdiff compares .env.example and .env in the current folder.\nRun envdiff --help for usage.');
37
+ process.exit(2);
38
+ }
39
+
40
+ const r = compare(files, { keysOnly: o['keys-only'] || zeroArg });
34
41
  if (o.json) { console.log(JSON.stringify(r, null, 2)); process.exit(r.ok ? 0 : 1); }
35
42
 
36
43
  const color = process.stdout.isTTY && !process.env.NO_COLOR;
package/package.json CHANGED
@@ -1,14 +1,34 @@
1
1
  {
2
2
  "name": "@guihakka2/envdiff",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Compare .env files across environments without ever printing secret values.",
5
5
  "type": "module",
6
- "bin": { "envdiff": "bin/envdiff.js" },
6
+ "bin": {
7
+ "envdiff": "bin/envdiff.js"
8
+ },
7
9
  "exports": "./src/index.js",
8
- "files": ["bin", "src"],
9
- "engines": { "node": ">=20" },
10
- "scripts": { "test": "node --test" },
11
- "keywords": ["dotenv", "env", "diff", "config", "devops", "cli", "secrets"],
12
- "repository": { "type": "git", "url": "git+https://github.com/Guihakka2/envdiff.git" },
10
+ "files": [
11
+ "bin",
12
+ "src"
13
+ ],
14
+ "engines": {
15
+ "node": ">=20"
16
+ },
17
+ "scripts": {
18
+ "test": "node --test"
19
+ },
20
+ "keywords": [
21
+ "dotenv",
22
+ "env",
23
+ "diff",
24
+ "config",
25
+ "devops",
26
+ "cli",
27
+ "secrets"
28
+ ],
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/Guihakka2/envdiff.git"
32
+ },
13
33
  "license": "MIT"
14
34
  }