configenvy 0.1.0 → 0.1.1
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 +49 -71
- package/package.json +2 -2
- package/src/index.ts +2 -2
package/dist/index.js
CHANGED
|
@@ -1,84 +1,62 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { writeFile } from "fs/promises";
|
|
5
|
+
import { resolve } from "path";
|
|
4
6
|
import { Command } from "commander";
|
|
5
|
-
import { buildMarkdownTable, explainVariable, scanProject, toJson } from "configenvy
|
|
6
|
-
|
|
7
|
-
program
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
.version("0.1.0");
|
|
11
|
-
program
|
|
12
|
-
.command("doctor")
|
|
13
|
-
.argument("[path]", "project directory", ".")
|
|
14
|
-
.option("--format <format>", "output format: text or json", "text")
|
|
15
|
-
.option("--strict", "treat documentation warnings as errors")
|
|
16
|
-
.action(async (projectPath, options) => {
|
|
17
|
-
await runDoctor(projectPath, options);
|
|
7
|
+
import { buildMarkdownTable, explainVariable, scanProject, toJson } from "@configenvy/core";
|
|
8
|
+
var program = new Command();
|
|
9
|
+
program.name("configenvy").description("Find missing, unused, undocumented, and risky environment variables.").version("0.1.1");
|
|
10
|
+
program.command("doctor").argument("[path]", "project directory", ".").option("--format <format>", "output format: text or json", "text").option("--strict", "treat documentation warnings as errors").action(async (projectPath, options) => {
|
|
11
|
+
await runDoctor(projectPath, options);
|
|
18
12
|
});
|
|
19
|
-
program
|
|
20
|
-
|
|
21
|
-
.argument("[path]", "project directory", ".")
|
|
22
|
-
.option("--ci", "fail on warnings and errors")
|
|
23
|
-
.option("--format <format>", "output format: text or json", "text")
|
|
24
|
-
.action(async (projectPath, options) => {
|
|
25
|
-
await runDoctor(projectPath, { ...options, strict: Boolean(options.ci), ci: Boolean(options.ci) });
|
|
13
|
+
program.command("check").argument("[path]", "project directory", ".").option("--ci", "fail on warnings and errors").option("--format <format>", "output format: text or json", "text").action(async (projectPath, options) => {
|
|
14
|
+
await runDoctor(projectPath, { ...options, strict: Boolean(options.ci), ci: Boolean(options.ci) });
|
|
26
15
|
});
|
|
27
|
-
program
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
console.log(table);
|
|
39
|
-
}
|
|
16
|
+
program.command("table").argument("[path]", "project directory", ".").option("--out <file>", "write markdown table to a file").action(async (projectPath, options) => {
|
|
17
|
+
const result = await scanProject({ rootDir: resolve(projectPath) });
|
|
18
|
+
const table = buildMarkdownTable(result);
|
|
19
|
+
if (options.out) {
|
|
20
|
+
await writeFile(resolve(options.out), `${table}
|
|
21
|
+
`, "utf8");
|
|
22
|
+
} else {
|
|
23
|
+
console.log(table);
|
|
24
|
+
}
|
|
40
25
|
});
|
|
41
|
-
program
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
.argument("[path]", "project directory", ".")
|
|
45
|
-
.action(async (variable, projectPath) => {
|
|
46
|
-
const result = await scanProject({ rootDir: resolve(projectPath) });
|
|
47
|
-
console.log(explainVariable(result, variable));
|
|
26
|
+
program.command("explain").argument("<variable>", "environment variable name").argument("[path]", "project directory", ".").action(async (variable, projectPath) => {
|
|
27
|
+
const result = await scanProject({ rootDir: resolve(projectPath) });
|
|
28
|
+
console.log(explainVariable(result, variable));
|
|
48
29
|
});
|
|
49
30
|
program.parseAsync(process.argv).catch((error) => {
|
|
50
|
-
|
|
51
|
-
|
|
31
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
32
|
+
process.exit(3);
|
|
52
33
|
});
|
|
53
34
|
async function runDoctor(projectPath, options) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
process.exit(2);
|
|
65
|
-
if (hasWarning)
|
|
66
|
-
process.exit(1);
|
|
35
|
+
const result = await scanProject({ rootDir: resolve(projectPath), strict: Boolean(options.strict) });
|
|
36
|
+
if (options.format === "json") {
|
|
37
|
+
console.log(toJson(result));
|
|
38
|
+
} else {
|
|
39
|
+
printHumanReport(result.diagnostics);
|
|
40
|
+
}
|
|
41
|
+
const hasError = result.diagnostics.some((diagnostic) => diagnostic.severity === "error");
|
|
42
|
+
const hasWarning = result.diagnostics.some((diagnostic) => diagnostic.severity === "warning");
|
|
43
|
+
if (hasError || options.ci && hasWarning) process.exit(2);
|
|
44
|
+
if (hasWarning) process.exit(1);
|
|
67
45
|
}
|
|
68
46
|
function printHumanReport(diagnostics) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
47
|
+
if (diagnostics.length === 0) {
|
|
48
|
+
console.log("PASS configenvy found no environment variable issues.");
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
for (const diagnostic of diagnostics) {
|
|
52
|
+
const label = diagnostic.severity === "error" ? "FAIL" : "WARN";
|
|
53
|
+
console.log(`${label} ${diagnostic.code} ${diagnostic.variable}`);
|
|
54
|
+
console.log(` ${diagnostic.message}`);
|
|
55
|
+
if (diagnostic.files.length > 0) {
|
|
56
|
+
console.log(` files: ${diagnostic.files.join(", ")}`);
|
|
80
57
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
58
|
+
}
|
|
59
|
+
const errors = diagnostics.filter((diagnostic) => diagnostic.severity === "error").length;
|
|
60
|
+
const warnings = diagnostics.length - errors;
|
|
61
|
+
console.log(`Summary: ${errors} error(s), ${warnings} warning(s).`);
|
|
84
62
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "configenvy",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Find missing, unused, undocumented, and risky environment variables before setup breaks.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"build": "tsup src/index.ts --format esm --dts --clean"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"configenvy
|
|
35
|
+
"@configenvy/core": "0.1.1",
|
|
36
36
|
"commander": "^12.1.0"
|
|
37
37
|
},
|
|
38
38
|
"keywords": [
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { writeFile } from "node:fs/promises";
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
import { Command } from "commander";
|
|
5
|
-
import { buildMarkdownTable, explainVariable, scanProject, toJson, type Diagnostic } from "configenvy
|
|
5
|
+
import { buildMarkdownTable, explainVariable, scanProject, toJson, type Diagnostic } from "@configenvy/core";
|
|
6
6
|
|
|
7
7
|
type DoctorOptions = {
|
|
8
8
|
format?: "text" | "json";
|
|
@@ -15,7 +15,7 @@ const program = new Command();
|
|
|
15
15
|
program
|
|
16
16
|
.name("configenvy")
|
|
17
17
|
.description("Find missing, unused, undocumented, and risky environment variables.")
|
|
18
|
-
.version("0.1.
|
|
18
|
+
.version("0.1.1");
|
|
19
19
|
|
|
20
20
|
program
|
|
21
21
|
.command("doctor")
|