@kevinpatil/envguard 1.0.2 → 1.0.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/dist/index.js +20 -5
- 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.
|
|
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
|
|
301
|
-
|
|
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
|
|
306
|
-
|
|
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);
|