nero-env 0.1.2 → 0.1.4
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/LICENSE +21 -0
- package/README.md +38 -13
- package/dist/cli/command.js +17 -20
- package/dist/cli/options.js +10 -10
- package/dist/core/compareEnv.js +1 -4
- package/dist/core/readEnv.js +3 -9
- package/dist/core/types.js +1 -2
- package/dist/core/validateEnv.js +1 -4
- package/dist/index.js +4 -6
- package/dist/meta.js +4 -5
- package/dist/output/formatter.js +1 -4
- package/dist/output/printer.js +16 -22
- package/dist/output/types.js +1 -2
- package/dist/update.js +6 -12
- package/package.json +24 -4
- package/dist/cli/help.js +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Roshan Singh
|
|
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.
|
package/README.md
CHANGED
|
@@ -1,35 +1,60 @@
|
|
|
1
|
-
|
|
1
|
+
<h1 align="center">nero-env</h1>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://img.shields.io/npm/v/nero-env?color=6366f1" alt="npm version" />
|
|
5
|
+
<img src="https://img.shields.io/npm/dm/nero-env?color=0f172a" alt="npm downloads" />
|
|
6
|
+
<img src="https://img.shields.io/github/license/alcanivorax/nero-env?color=22c55e" alt="license" />
|
|
7
|
+
</p>
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
<p align="center">
|
|
10
|
+
<img
|
|
11
|
+
src="https://raw.githubusercontent.com/alcanivorax/nero-env/main/assets/nero-env-preview.png"
|
|
12
|
+
alt="nero-env preview"
|
|
13
|
+
width="700"
|
|
14
|
+
/>
|
|
15
|
+
</p>
|
|
6
16
|
|
|
7
|
-
|
|
8
|
-
- empty values
|
|
9
|
-
- unused variables
|
|
17
|
+
A simple CLI tool to validate environment variables in your project.
|
|
10
18
|
|
|
11
|
-
|
|
19
|
+
## Overview
|
|
12
20
|
|
|
13
|
-
|
|
21
|
+
nero-env compares your active `.env` file with `.env.example` and reports discrepancies. It helps ensure your environment configuration is complete and accurate.
|
|
14
22
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
**What it checks:**
|
|
24
|
+
|
|
25
|
+
- **Missing variables** - defined in `.env.example` but not in `.env`
|
|
26
|
+
- **Empty values** - defined in `.env` but has no value assigned
|
|
27
|
+
- **Unused variables** - present in `.env` but not declared in `.env.example`
|
|
28
|
+
|
|
29
|
+
Clear output. No configuration required. Safe by default.
|
|
30
|
+
|
|
31
|
+
---
|
|
19
32
|
|
|
20
33
|
## Installation
|
|
21
34
|
|
|
35
|
+
Install globally using npm:
|
|
36
|
+
|
|
22
37
|
```bash
|
|
23
38
|
npm install -g nero-env
|
|
24
39
|
```
|
|
25
40
|
|
|
41
|
+
---
|
|
42
|
+
|
|
26
43
|
## Usage
|
|
27
44
|
|
|
45
|
+
### Basic Usage
|
|
46
|
+
|
|
47
|
+
Run in your project directory:
|
|
48
|
+
|
|
28
49
|
```bash
|
|
29
50
|
nero-env
|
|
30
51
|
```
|
|
31
52
|
|
|
32
|
-
|
|
53
|
+
This will check for `.env` and `.env.example` files in the current directory.
|
|
54
|
+
|
|
55
|
+
### Check a Specific Project
|
|
56
|
+
|
|
57
|
+
Specify a custom path:
|
|
33
58
|
|
|
34
59
|
```bash
|
|
35
60
|
nero-env --path ./apps/api
|
package/dist/cli/command.js
CHANGED
|
@@ -1,29 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const printer_1 = require("../output/printer");
|
|
11
|
-
function run() {
|
|
12
|
-
const options = (0, options_1.parseOptions)();
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { parseOptions } from "./options.js";
|
|
3
|
+
import { readEnvFile } from "../core/readEnv.js";
|
|
4
|
+
import { compareEnv } from "../core/compareEnv.js";
|
|
5
|
+
import { validateEnv } from "../core/validateEnv.js";
|
|
6
|
+
import { formatEnvReport } from "../output/formatter.js";
|
|
7
|
+
import { printReport } from "../output/printer.js";
|
|
8
|
+
export function run() {
|
|
9
|
+
const options = parseOptions();
|
|
13
10
|
const targetPath = options.projectPath;
|
|
14
|
-
const envFilePath =
|
|
15
|
-
const exampleFilePath =
|
|
16
|
-
const actualEnv =
|
|
17
|
-
const exampleEnv =
|
|
18
|
-
const report =
|
|
11
|
+
const envFilePath = join(targetPath, ".env");
|
|
12
|
+
const exampleFilePath = join(targetPath, ".env.example");
|
|
13
|
+
const actualEnv = readEnvFile(envFilePath);
|
|
14
|
+
const exampleEnv = readEnvFile(exampleFilePath);
|
|
15
|
+
const report = compareEnv(exampleEnv, actualEnv);
|
|
19
16
|
// Extra validation layer
|
|
20
|
-
const emptyKeys =
|
|
17
|
+
const emptyKeys = validateEnv(actualEnv);
|
|
21
18
|
if (emptyKeys.length > 0) {
|
|
22
19
|
report.issues.empty = emptyKeys;
|
|
23
20
|
report.hasIssues = true;
|
|
24
21
|
}
|
|
25
|
-
const formattedReport =
|
|
26
|
-
|
|
22
|
+
const formattedReport = formatEnvReport(report);
|
|
23
|
+
printReport(formattedReport);
|
|
27
24
|
if (formattedReport.hasIssues) {
|
|
28
25
|
process.exit(1);
|
|
29
26
|
}
|
package/dist/cli/options.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
function parseOptions() {
|
|
7
|
-
const program = new commander_1.Command();
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { CLI_NAME, CLI_VERSION } from "../meta.js";
|
|
4
|
+
export function parseOptions() {
|
|
5
|
+
const program = new Command();
|
|
8
6
|
program
|
|
9
|
-
.name(
|
|
7
|
+
.name(CLI_NAME)
|
|
10
8
|
.description("Validate and compare .env files")
|
|
11
|
-
.
|
|
9
|
+
.version(CLI_VERSION, "-v, --version", "output the version number")
|
|
10
|
+
.option("-p, --path <path>", "Path to the project directory (defaults to current working directory)", process.cwd())
|
|
11
|
+
.helpOption("-h, --help", "display help for command")
|
|
12
12
|
.parse(process.argv);
|
|
13
13
|
const opts = program.opts();
|
|
14
14
|
return {
|
|
15
|
-
projectPath:
|
|
15
|
+
projectPath: resolve(opts.path),
|
|
16
16
|
};
|
|
17
17
|
}
|
package/dist/core/compareEnv.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.compareEnv = compareEnv;
|
|
4
|
-
function compareEnv(exampleEnv, actualEnv) {
|
|
1
|
+
export function compareEnv(exampleEnv, actualEnv) {
|
|
5
2
|
const expectedKeys = new Set(Object.keys(exampleEnv));
|
|
6
3
|
const actualKeys = new Set(Object.keys(actualEnv));
|
|
7
4
|
const issues = {
|
package/dist/core/readEnv.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.readEnvFile = readEnvFile;
|
|
7
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
function readEnvFile(filePath) {
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
export function readEnvFile(filePath) {
|
|
9
3
|
const envVariables = {};
|
|
10
4
|
try {
|
|
11
|
-
const fileContent =
|
|
5
|
+
const fileContent = fs.readFileSync(filePath, "utf8");
|
|
12
6
|
if (!fileContent) {
|
|
13
7
|
return envVariables;
|
|
14
8
|
}
|
package/dist/core/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/core/validateEnv.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateEnv = validateEnv;
|
|
4
|
-
function validateEnv(actualEnv) {
|
|
1
|
+
export function validateEnv(actualEnv) {
|
|
5
2
|
const emptyKeys = [];
|
|
6
3
|
for (const [key, value] of Object.entries(actualEnv)) {
|
|
7
4
|
if (value === "") {
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const command_1 = require("./cli/command");
|
|
5
|
-
const update_1 = require("./update");
|
|
2
|
+
import { run } from "./cli/command.js";
|
|
3
|
+
import { notifyUpdate } from "./update.js";
|
|
6
4
|
try {
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
notifyUpdate();
|
|
6
|
+
run();
|
|
9
7
|
}
|
|
10
8
|
catch (err) {
|
|
11
9
|
console.error("Unexpected error:", err);
|
package/dist/meta.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
exports.CLI_VERSION = "0.1.0";
|
|
1
|
+
// src/meta.ts
|
|
2
|
+
import pkg from "../package.json" with { type: "json" };
|
|
3
|
+
export const CLI_NAME = pkg.name;
|
|
4
|
+
export const CLI_VERSION = pkg.version;
|
package/dist/output/formatter.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatEnvReport = formatEnvReport;
|
|
4
|
-
function formatEnvReport(report) {
|
|
1
|
+
export function formatEnvReport(report) {
|
|
5
2
|
const sections = [];
|
|
6
3
|
const { missing, unused, empty } = report.issues;
|
|
7
4
|
if (missing.length > 0) {
|
package/dist/output/printer.js
CHANGED
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.printReport = printReport;
|
|
7
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
1
|
+
import chalk from "chalk";
|
|
8
2
|
const icons = {
|
|
9
|
-
error:
|
|
10
|
-
warning:
|
|
11
|
-
success:
|
|
3
|
+
error: chalk.red("❌"),
|
|
4
|
+
warning: chalk.yellow("⚠️"),
|
|
5
|
+
success: chalk.green("✅"),
|
|
12
6
|
};
|
|
13
|
-
function printReport(report) {
|
|
7
|
+
export function printReport(report) {
|
|
14
8
|
// Title
|
|
15
|
-
console.log(
|
|
16
|
-
console.log(
|
|
9
|
+
console.log(chalk.bold("Nero Env Check"));
|
|
10
|
+
console.log(chalk.dim("─────────────\n"));
|
|
17
11
|
// Success case
|
|
18
12
|
if (!report.hasIssues || report.sections.length === 0) {
|
|
19
|
-
console.log(`${icons.success} ${
|
|
13
|
+
console.log(`${icons.success} ${chalk.green("No environment issues found")}`);
|
|
20
14
|
printSummary(0, 0);
|
|
21
15
|
return;
|
|
22
16
|
}
|
|
@@ -38,27 +32,27 @@ function printReport(report) {
|
|
|
38
32
|
function printSection(section) {
|
|
39
33
|
const icon = icons[section.severity];
|
|
40
34
|
if (section.source === ".env") {
|
|
41
|
-
console.log(`${icon} ${
|
|
35
|
+
console.log(`${icon} ${chalk.bold(section.title)} ${chalk.dim(`(${section.source})`)}`);
|
|
42
36
|
}
|
|
43
37
|
else {
|
|
44
|
-
console.log(`${icon} ${
|
|
38
|
+
console.log(`${icon} ${chalk.bold(section.title)} ${chalk.dim(`(not declared in ${section.source})`)}`);
|
|
45
39
|
}
|
|
46
40
|
for (const item of section.items) {
|
|
47
|
-
console.log(` ${
|
|
41
|
+
console.log(` ${chalk.dim("•")} ${chalk.cyan(item)}`);
|
|
48
42
|
}
|
|
49
43
|
}
|
|
50
44
|
function printSummary(errors, warnings) {
|
|
51
|
-
console.log(
|
|
45
|
+
console.log(chalk.dim("─────────────"));
|
|
52
46
|
if (errors === 0 && warnings === 0) {
|
|
53
|
-
console.log(
|
|
47
|
+
console.log(chalk.dim("Summary: ") + chalk.green("No issues found"));
|
|
54
48
|
return;
|
|
55
49
|
}
|
|
56
50
|
const parts = [];
|
|
57
51
|
if (errors > 0) {
|
|
58
|
-
parts.push(
|
|
52
|
+
parts.push(chalk.red(`${errors} error${errors > 1 ? "s" : ""}`));
|
|
59
53
|
}
|
|
60
54
|
if (warnings > 0) {
|
|
61
|
-
parts.push(
|
|
55
|
+
parts.push(chalk.yellow(`${warnings} warning${warnings > 1 ? "s" : ""}`));
|
|
62
56
|
}
|
|
63
|
-
console.log(
|
|
57
|
+
console.log(chalk.dim("Summary: ") + parts.join(chalk.dim(", ")));
|
|
64
58
|
}
|
package/dist/output/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/update.js
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.notifyUpdate = notifyUpdate;
|
|
7
|
-
const update_notifier_1 = __importDefault(require("update-notifier"));
|
|
8
|
-
const meta_1 = require("./meta");
|
|
9
|
-
function notifyUpdate() {
|
|
10
|
-
(0, update_notifier_1.default)({
|
|
1
|
+
import updateNotifier from "update-notifier";
|
|
2
|
+
import { CLI_NAME, CLI_VERSION } from "./meta.js";
|
|
3
|
+
export function notifyUpdate() {
|
|
4
|
+
updateNotifier({
|
|
11
5
|
pkg: {
|
|
12
|
-
name:
|
|
13
|
-
version:
|
|
6
|
+
name: CLI_NAME,
|
|
7
|
+
version: CLI_VERSION,
|
|
14
8
|
},
|
|
15
9
|
updateCheckInterval: 1000 * 60 * 60 * 24,
|
|
16
10
|
}).notify({ isGlobal: true });
|
package/package.json
CHANGED
|
@@ -1,23 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nero-env",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Validate and compare .env files",
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"description": "Validate and compare .env files to catch missing, empty, and unused variables.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
5
7
|
"bin": {
|
|
6
8
|
"nero-env": "dist/index.js"
|
|
7
9
|
},
|
|
8
10
|
"files": [
|
|
9
|
-
"dist"
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md"
|
|
10
13
|
],
|
|
11
14
|
"scripts": {
|
|
15
|
+
"dev": "tsx src/index.ts",
|
|
12
16
|
"build": "tsc",
|
|
13
|
-
"
|
|
17
|
+
"start": "node dist/index.js"
|
|
14
18
|
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"env",
|
|
21
|
+
"dotenv",
|
|
22
|
+
"environment-variables",
|
|
23
|
+
"env-validation",
|
|
24
|
+
"env-check",
|
|
25
|
+
"env-compare",
|
|
26
|
+
"config",
|
|
27
|
+
"cli",
|
|
28
|
+
"node-cli",
|
|
29
|
+
"developer-tools",
|
|
30
|
+
"devtools",
|
|
31
|
+
"nero"
|
|
32
|
+
],
|
|
33
|
+
"author": "alcanivorax",
|
|
15
34
|
"license": "MIT",
|
|
16
35
|
"packageManager": "pnpm@10.17.1",
|
|
17
36
|
"devDependencies": {
|
|
18
37
|
"@types/node": "^25.0.3",
|
|
19
38
|
"@types/update-notifier": "^6.0.8",
|
|
20
39
|
"ts-node": "^10.9.2",
|
|
40
|
+
"tsx": "^4.21.0",
|
|
21
41
|
"typescript": "^5.9.3"
|
|
22
42
|
},
|
|
23
43
|
"dependencies": {
|
package/dist/cli/help.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|