@justmpm/firebase-audit 0.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.
package/dist/cli.js ADDED
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ scan
4
+ } from "./chunk-VKCDUCYE.js";
5
+
6
+ // src/cli.ts
7
+ import { createRequire } from "module";
8
+ var require2 = createRequire(import.meta.url);
9
+ var pkg = require2("../package.json");
10
+ async function main() {
11
+ const args = process.argv.slice(2);
12
+ const cmd = args[0] ?? "scan";
13
+ if (cmd === "--version" || cmd === "-v") {
14
+ console.log(pkg.version);
15
+ return;
16
+ }
17
+ if (cmd !== "scan") {
18
+ console.error(`Comando desconhecido: ${cmd}
19
+ Uso: firebase-audit scan [--json] [--strict] [--adapter=fn] [--cwd=path]`);
20
+ process.exit(1);
21
+ }
22
+ const asJson = args.includes("--json");
23
+ const strict = args.includes("--strict");
24
+ const adapterArg = args.find((a) => a.startsWith("--adapter="))?.split("=")[1];
25
+ const cwdArg = args.find((a) => a.startsWith("--cwd="))?.split("=")[1];
26
+ const rootDir = cwdArg ?? process.cwd();
27
+ const { findings, summary } = await scan(rootDir, { strict, adapterFn: adapterArg });
28
+ if (asJson) {
29
+ console.log(JSON.stringify({ version: pkg.version, summary, findings }, null, 2));
30
+ if (strict && summary.errors > 0) process.exit(2);
31
+ return;
32
+ }
33
+ console.log(`
34
+ FIREBASE AUDIT v${pkg.version}`);
35
+ console.log("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
36
+ if (findings.length === 0) {
37
+ console.log("\n\u2713 Nenhum problema encontrado (V1 static-first, 10 checks).\n");
38
+ return;
39
+ }
40
+ for (const f of findings) {
41
+ const icon = f.severity === "ERROR" ? "\u274C" : f.severity === "WARNING" ? "\u26A0" : "\u2139";
42
+ const where = f.file ? ` (${f.file}${f.line ? `:${f.line}` : ""})` : "";
43
+ console.log(`
44
+ ${icon} ${f.rule} [${f.confidence}]${where}
45
+ ${f.message}`);
46
+ if (f.fix) console.log(` \u2192 ${f.fix}`);
47
+ }
48
+ console.log(`
49
+ SUMMARY: ${summary.errors} errors, ${summary.warnings} warnings, ${summary.infos} infos
50
+ `);
51
+ if (strict && summary.errors > 0) process.exit(2);
52
+ }
53
+ main().catch((err) => {
54
+ console.error("[firebase-audit] Fatal:", err instanceof Error ? err.message : err);
55
+ process.exit(1);
56
+ });