@kevinpatil/envguard 1.0.1 → 1.0.3

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.
Files changed (2) hide show
  1. package/dist/index.js +27 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -26,6 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  // src/index.ts
27
27
  var import_commander = require("commander");
28
28
  var import_path = __toESM(require("path"));
29
+ var import_fs2 = __toESM(require("fs"));
29
30
 
30
31
  // src/parser.ts
31
32
  var import_fs = __toESM(require("fs"));
@@ -292,9 +293,34 @@ function report(results, options = {}) {
292
293
 
293
294
  // src/index.ts
294
295
  var program = new import_commander.Command();
295
- program.name("envguard").description("Validate .env files against .env.example before your app ships").version("1.0.0").option("--env <file>", "path to .env file", ".env").option("--example <file>", "path to .env.example file", ".env.example").option("--strict", "exit with code 1 if any errors are found").option("--json", "output results as JSON").action((options) => {
296
+ program.name("envguard").description("Validate .env files against .env.example before your app ships").version("1.0.3").option("--env <file>", "path to .env file", ".env").option("--example <file>", "path to .env.example file", ".env.example").option("--strict", "exit with code 1 if any errors are found").option("--json", "output results as JSON").action((options) => {
296
297
  const envPath = import_path.default.resolve(process.cwd(), options.env);
297
298
  const examplePath = import_path.default.resolve(process.cwd(), options.example);
299
+ if (!import_fs2.default.existsSync(envPath)) {
300
+ console.error(`Error: '${options.env}' not found.`);
301
+ if (options.env === ".env") {
302
+ const named = [".env.local", ".env.development", ".env.staging", ".env.production"].filter((f) => import_fs2.default.existsSync(import_path.default.resolve(process.cwd(), f)));
303
+ if (named.length > 0) {
304
+ console.error(`Found: ${named.join(", ")}`);
305
+ console.error(`Tip: Use --env to target one, e.g. --env ${named[0]}`);
306
+ } else {
307
+ console.error(`Tip: Create a .env file or use --env <file> to point to one.`);
308
+ }
309
+ } else {
310
+ console.error(`Tip: Check the path and try again.`);
311
+ }
312
+ process.exit(1);
313
+ }
314
+ if (!import_fs2.default.existsSync(examplePath)) {
315
+ console.error(`Error: '${options.example}' not found.`);
316
+ if (options.example === ".env.example") {
317
+ console.error(`Tip: Create a .env.example file that lists all required keys.`);
318
+ console.error(` Or use --example <file> to point to an existing template.`);
319
+ } else {
320
+ console.error(`Tip: Check the path and try again.`);
321
+ }
322
+ process.exit(1);
323
+ }
298
324
  const env = parseEnvFile(envPath);
299
325
  const example = parseEnvExample(examplePath);
300
326
  const results = validate(env, example);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevinpatil/envguard",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "CLI tool that validates .env files against .env.example before your app ships",
5
5
  "main": "dist/index.js",
6
6
  "bin": {