env-detector 1.0.4 → 1.1.0

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 (3) hide show
  1. package/LICENSE +20 -1
  2. package/bin/env-scan.js +19 -4
  3. package/package.json +1 -1
package/LICENSE CHANGED
@@ -1,2 +1,21 @@
1
1
  MIT License
2
- Copyright (c) 2026
2
+
3
+ Copyright (c) 2026 Jenil Gajjar
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/bin/env-scan.js CHANGED
@@ -17,9 +17,27 @@ const fixMode = args.includes("--fix");
17
17
  const securityMode = args.includes("--security");
18
18
  const strictMode = args.includes("--strict");
19
19
  const versionMode = args.includes("--version") || args.includes("--v")
20
+ const helpMode = args.includes("--help") || args.includes("-h");
20
21
 
21
22
  let result = scanProject(cwd);
22
23
 
24
+ if (helpMode) {
25
+ console.log(`
26
+ Usage: env-detector [options]
27
+
28
+ Options:
29
+ --ask Interactive mode to fill missing or empty values
30
+ --compare Show detailed comparison of used, missing, empty, and unused variables
31
+ --check Exit with error if variables are missing or empty
32
+ --fix Remove unused variables from .env
33
+ --security Scan for hardcoded secrets in source files and .env
34
+ --strict Fail if any issues (missing, empty, or unused) are found
35
+ --version Show version information
36
+ --help, -h Show this help message
37
+ `);
38
+ process.exit(0);
39
+ }
40
+
23
41
  if (versionMode) {
24
42
  const pkg = require("../package.json");
25
43
  console.log(`env-detector v${pkg.version}`);
@@ -89,18 +107,16 @@ if (!fs.existsSync(envPath)) {
89
107
 
90
108
 
91
109
  // grouped generation
92
- if (Object.keys(result.grouped).length) {
110
+ if (Object.keys(result.grouped).length && !askMode) {
93
111
 
94
112
  let output = "";
95
113
 
96
- // collect grouped keys
97
114
  const groupedKeys = new Set();
98
115
 
99
116
  Object.values(result.grouped).forEach(keys => {
100
117
  keys.forEach(k => groupedKeys.add(k));
101
118
  });
102
119
 
103
- // GLOBAL VARIABLES
104
120
  const globalKeys = result.used.filter(k => !groupedKeys.has(k));
105
121
 
106
122
  if (globalKeys.length) {
@@ -114,7 +130,6 @@ if (Object.keys(result.grouped).length) {
114
130
  output += "\n";
115
131
  }
116
132
 
117
- // GROUPED ENVIRONMENTS
118
133
  Object.entries(result.grouped).forEach(([env, keys]) => {
119
134
 
120
135
  output += `# ${env}\n`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "env-detector",
3
- "version": "1.0.4",
3
+ "version": "1.1.0",
4
4
  "description": "Smart .env generator and auditor",
5
5
  "main": "src/scan.js",
6
6
  "bin": {