el-filtro 0.2.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/scan.js ADDED
@@ -0,0 +1,54 @@
1
+ import { basename } from 'node:path';
2
+ import { discoverRepos } from './discovery.js';
3
+ import { detectEcosystem, detectSecondaryEcosystems } from './ecosystem.js';
4
+ import { buildReport } from './report.js';
5
+ /**
6
+ * Corre el motor del ecosistema con aislamiento de errores: un fallo controlado (ok:false)
7
+ * o un throw se traducen a "no se pudo auditar", nunca tumban el escaneo completo (§7).
8
+ */
9
+ async function runEngine(engine) {
10
+ try {
11
+ const outcome = await engine();
12
+ if (outcome.ok)
13
+ return { status: 'audited', statusReason: null, findings: outcome.findings };
14
+ return { status: 'no-audit', statusReason: outcome.reason, findings: [] };
15
+ }
16
+ catch (err) {
17
+ const reason = err instanceof Error ? err.message : String(err);
18
+ return { status: 'no-audit', statusReason: reason, findings: [] };
19
+ }
20
+ }
21
+ async function auditOneRepo(repoPath, ecosystem, deps) {
22
+ if (ecosystem === 'none')
23
+ return { status: 'not-applicable', statusReason: null, findings: [] };
24
+ if (ecosystem === 'pip')
25
+ return runEngine(() => deps.auditPip(repoPath));
26
+ return runEngine(() => deps.auditNpm(repoPath));
27
+ }
28
+ /**
29
+ * Orquesta el escaneo: descubre repos, detecta ecosistema, corre el motor que toque y
30
+ * arma el reporte. Emite progreso por repo y aísla errores por repo. Devuelve el Report
31
+ * ya agregado (el CLI decide render + escritura a disco).
32
+ */
33
+ export async function scan(root, deps) {
34
+ const discover = deps.discover ?? discoverRepos;
35
+ const detect = deps.detect ?? detectEcosystem;
36
+ const repoPaths = discover(root);
37
+ const total = repoPaths.length;
38
+ const results = [];
39
+ for (let i = 0; i < repoPaths.length; i++) {
40
+ const repoPath = repoPaths[i];
41
+ const name = basename(repoPath);
42
+ deps.onProgress?.(i + 1, total, name);
43
+ const ecosystem = detect(repoPath);
44
+ const outcome = await auditOneRepo(repoPath, ecosystem, deps);
45
+ results.push({
46
+ name,
47
+ path: repoPath,
48
+ ecosystem,
49
+ secondaryEcosystems: detectSecondaryEcosystems(repoPath),
50
+ ...outcome,
51
+ });
52
+ }
53
+ return buildReport(root, results, deps.now);
54
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "el-filtro",
3
+ "version": "0.2.0",
4
+ "description": "Escanea de una pasada todos tus repos npm/pip y te dice, en lenguaje simple, qué dependencias arreglar ya y cuáles pueden esperar. 100% determinístico, sin IA ni API key.",
5
+ "license": "MIT",
6
+ "author": "Juan Carlos Caro (JuanIA-sketch)",
7
+ "type": "module",
8
+ "bin": { "el-filtro": "bin/el-filtro.js" },
9
+ "files": ["bin", "dist", "README.md", "LICENSE"],
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "prepare": "tsc",
13
+ "test": "npm run build && vitest run",
14
+ "test:watch": "vitest",
15
+ "dev": "tsx src/cli.ts"
16
+ },
17
+ "engines": { "node": ">=18" },
18
+ "dependencies": {
19
+ "commander": "^12.1.0",
20
+ "picocolors": "^1.1.1"
21
+ },
22
+ "devDependencies": {
23
+ "@types/node": "^20.14.0",
24
+ "tsx": "^4.19.0",
25
+ "typescript": "^5.5.0",
26
+ "vitest": "^2.1.0"
27
+ }
28
+ }