nero-env 0.1.3 → 0.1.5

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.
@@ -1,29 +1,26 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.run = run;
4
- const node_path_1 = require("node:path");
5
- const options_1 = require("./options");
6
- const readEnv_1 = require("../core/readEnv");
7
- const compareEnv_1 = require("../core/compareEnv");
8
- const validateEnv_1 = require("../core/validateEnv");
9
- const formatter_1 = require("../output/formatter");
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 = (0, node_path_1.join)(targetPath, ".env");
15
- const exampleFilePath = (0, node_path_1.join)(targetPath, ".env.example");
16
- const actualEnv = (0, readEnv_1.readEnvFile)(envFilePath);
17
- const exampleEnv = (0, readEnv_1.readEnvFile)(exampleFilePath);
18
- const report = (0, compareEnv_1.compareEnv)(exampleEnv, actualEnv);
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 = (0, validateEnv_1.validateEnv)(actualEnv);
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 = (0, formatter_1.formatEnvReport)(report);
26
- (0, printer_1.printReport)(formattedReport);
22
+ const formattedReport = formatEnvReport(report);
23
+ printReport(formattedReport);
27
24
  if (formattedReport.hasIssues) {
28
25
  process.exit(1);
29
26
  }
@@ -1,17 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseOptions = parseOptions;
4
- const commander_1 = require("commander");
5
- const node_path_1 = require("node:path");
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("nero-env")
7
+ .name(CLI_NAME)
10
8
  .description("Validate and compare .env files")
11
- .option("-p, --path <path>", "Path to the project directory", process.cwd())
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: (0, node_path_1.resolve)(opts.path),
15
+ projectPath: resolve(opts.path),
16
16
  };
17
17
  }
@@ -1,7 +1,4 @@
1
- "use strict";
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 = {
@@ -1,14 +1,8 @@
1
- "use strict";
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.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 = node_fs_1.default.readFileSync(filePath, "utf8");
5
+ const fileContent = fs.readFileSync(filePath, "utf8");
12
6
  if (!fileContent) {
13
7
  return envVariables;
14
8
  }
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,7 +1,4 @@
1
- "use strict";
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
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
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
- (0, update_1.notifyUpdate)(); // non-blocking, safe, cached
8
- (0, command_1.run)();
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CLI_VERSION = exports.CLI_NAME = void 0;
4
- exports.CLI_NAME = "nero-env";
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;
@@ -1,7 +1,4 @@
1
- "use strict";
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) {
@@ -1,22 +1,16 @@
1
- "use strict";
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: chalk_1.default.red("❌"),
10
- warning: chalk_1.default.yellow("⚠️"),
11
- success: chalk_1.default.green("✅"),
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(chalk_1.default.bold("Nero Env Check"));
16
- console.log(chalk_1.default.dim("─────────────\n"));
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} ${chalk_1.default.green("No environment issues found")}`);
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} ${chalk_1.default.bold(section.title)} ${chalk_1.default.dim(`(${section.source})`)}`);
35
+ console.log(`${icon} ${chalk.bold(section.title)} ${chalk.dim(`(${section.source})`)}`);
42
36
  }
43
37
  else {
44
- console.log(`${icon} ${chalk_1.default.bold(section.title)} ${chalk_1.default.dim(`(not declared in ${section.source})`)}`);
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(` ${chalk_1.default.dim("•")} ${chalk_1.default.cyan(item)}`);
41
+ console.log(` ${chalk.dim("•")} ${chalk.cyan(item)}`);
48
42
  }
49
43
  }
50
44
  function printSummary(errors, warnings) {
51
- console.log(chalk_1.default.dim("─────────────"));
45
+ console.log(chalk.dim("─────────────"));
52
46
  if (errors === 0 && warnings === 0) {
53
- console.log(chalk_1.default.dim("Summary: ") + chalk_1.default.green("No issues found"));
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(chalk_1.default.red(`${errors} error${errors > 1 ? "s" : ""}`));
52
+ parts.push(chalk.red(`${errors} error${errors > 1 ? "s" : ""}`));
59
53
  }
60
54
  if (warnings > 0) {
61
- parts.push(chalk_1.default.yellow(`${warnings} warning${warnings > 1 ? "s" : ""}`));
55
+ parts.push(chalk.yellow(`${warnings} warning${warnings > 1 ? "s" : ""}`));
62
56
  }
63
- console.log(chalk_1.default.dim("Summary: ") + parts.join(chalk_1.default.dim(", ")));
57
+ console.log(chalk.dim("Summary: ") + parts.join(chalk.dim(", ")));
64
58
  }
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/dist/update.js CHANGED
@@ -1,16 +1,10 @@
1
- "use strict";
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.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: meta_1.CLI_NAME,
13
- version: meta_1.CLI_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,6 +1,6 @@
1
1
  {
2
2
  "name": "nero-env",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Validate and compare .env files to catch missing, empty, and unused variables.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -37,6 +37,7 @@
37
37
  "@types/node": "^25.0.3",
38
38
  "@types/update-notifier": "^6.0.8",
39
39
  "ts-node": "^10.9.2",
40
+ "tsx": "^4.21.0",
40
41
  "typescript": "^5.9.3"
41
42
  },
42
43
  "dependencies": {
package/dist/cli/help.js DELETED
@@ -1 +0,0 @@
1
- "use strict";