@kevinpatil/envguard 1.0.2 → 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 +20 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -293,17 +293,32 @@ function report(results, options = {}) {
293
293
 
294
294
  // src/index.ts
295
295
  var program = new import_commander.Command();
296
- program.name("envguard").description("Validate .env files against .env.example before your app ships").version("1.0.1").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) => {
297
297
  const envPath = import_path.default.resolve(process.cwd(), options.env);
298
298
  const examplePath = import_path.default.resolve(process.cwd(), options.example);
299
299
  if (!import_fs2.default.existsSync(envPath)) {
300
- console.error(`Error: ${options.env} not found in ${process.cwd()}`);
301
- console.error(`Tip: Create a .env file or use --env to point to one.`);
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
+ }
302
312
  process.exit(1);
303
313
  }
304
314
  if (!import_fs2.default.existsSync(examplePath)) {
305
- console.error(`Error: ${options.example} not found in ${process.cwd()}`);
306
- console.error(`Tip: Create a .env.example file or use --example to point to one.`);
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
+ }
307
322
  process.exit(1);
308
323
  }
309
324
  const env = parseEnvFile(envPath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevinpatil/envguard",
3
- "version": "1.0.2",
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": {