@efraindrummer/ghostdeps 0.0.0-stage → 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/utils.js ADDED
@@ -0,0 +1,44 @@
1
+ const MS_PER_DAY = 86_400_000;
2
+ export function sleep(ms) {
3
+ return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
4
+ }
5
+ /** Días completos transcurridos entre una fecha ISO y `now`. null si no hay fecha válida. */
6
+ export function daysSince(iso, now) {
7
+ if (!iso)
8
+ return null;
9
+ const t = Date.parse(iso);
10
+ if (Number.isNaN(t))
11
+ return null;
12
+ return Math.max(0, Math.floor((now.getTime() - t) / MS_PER_DAY));
13
+ }
14
+ export function daysBetween(fromIso, toIso) {
15
+ if (!fromIso || !toIso)
16
+ return null;
17
+ const a = Date.parse(fromIso);
18
+ const b = Date.parse(toIso);
19
+ if (Number.isNaN(a) || Number.isNaN(b))
20
+ return null;
21
+ return Math.max(0, Math.floor((b - a) / MS_PER_DAY));
22
+ }
23
+ export function isoDaysAgo(days, now) {
24
+ return new Date(now.getTime() - days * MS_PER_DAY).toISOString();
25
+ }
26
+ /**
27
+ * Ejecuta `fn` sobre `items` con un máximo de `limit` promesas simultáneas,
28
+ * preservando el orden de los resultados. `fn` debería capturar sus propios errores.
29
+ */
30
+ export async function mapWithConcurrency(items, limit, fn) {
31
+ const results = new Array(items.length);
32
+ let next = 0;
33
+ const workerCount = Math.max(1, Math.min(limit, items.length));
34
+ const workers = Array.from({ length: workerCount }, async () => {
35
+ while (true) {
36
+ const index = next++;
37
+ if (index >= items.length)
38
+ return;
39
+ results[index] = await fn(items[index], index);
40
+ }
41
+ });
42
+ await Promise.all(workers);
43
+ return results;
44
+ }
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@efraindrummer/ghostdeps",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Detecta dependencias fantasma (abandonadas, bus factor bajo o con señales de secuestro) evaluando la salud social y de mantenimiento del repositorio origen.",
5
+ "keywords": [
6
+ "supply-chain",
7
+ "security",
8
+ "dependencies",
9
+ "npm",
10
+ "bus-factor",
11
+ "abandoned",
12
+ "cli"
13
+ ],
14
+ "license": "MIT",
15
+ "type": "module",
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "bin": {
20
+ "ghostdeps": "dist/cli.js"
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "schema",
25
+ "README.md",
26
+ "CHANGELOG.md",
27
+ "LICENSE"
28
+ ],
29
+ "engines": {
30
+ "node": ">=20"
31
+ },
32
+ "scripts": {
33
+ "build": "tsc -p tsconfig.build.json",
34
+ "dev": "tsx src/cli.ts",
35
+ "start": "node dist/cli.js",
36
+ "test": "vitest run",
37
+ "test:watch": "vitest",
38
+ "typecheck": "tsc -p tsconfig.json --noEmit",
39
+ "prepublishOnly": "npm run typecheck && npm test && npm run build"
40
+ },
41
+ "dependencies": {
42
+ "chalk": "^5.3.0",
43
+ "cli-table3": "^0.6.5",
44
+ "commander": "^12.1.0"
45
+ },
46
+ "devDependencies": {
47
+ "@types/node": "^20.14.0",
48
+ "tsx": "^4.19.0",
49
+ "typescript": "^5.6.0",
50
+ "vitest": "^2.1.0"
51
+ }
52
+ }
@@ -0,0 +1,67 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://unpkg.com/ghostdeps/schema/ghostdepsrc.schema.json",
4
+ "title": "GhostDeps configuration",
5
+ "description": "Configuración de GhostDeps (.ghostdepsrc.json o clave \"ghostdeps\" en package.json).",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "definitions": {
9
+ "points": { "type": "number", "minimum": 0, "maximum": 100 },
10
+ "tier": {
11
+ "type": "object",
12
+ "additionalProperties": false,
13
+ "required": ["threshold", "points"],
14
+ "properties": {
15
+ "threshold": { "type": "number", "minimum": 0, "maximum": 100000 },
16
+ "points": { "$ref": "#/definitions/points" }
17
+ }
18
+ },
19
+ "tiers": { "type": "array", "items": { "$ref": "#/definitions/tier" } }
20
+ },
21
+ "properties": {
22
+ "$schema": { "type": "string" },
23
+ "ignore": {
24
+ "description": "Paquetes a omitir. Admite comodín * (ej. \"@types/*\").",
25
+ "type": "array",
26
+ "items": { "type": "string", "minLength": 1 }
27
+ },
28
+ "failUnder": { "description": "Exit code 1 si algún paquete evaluado queda por debajo.", "type": "number", "minimum": 0, "maximum": 100 },
29
+ "dev": { "description": "Incluir devDependencies.", "type": "boolean" },
30
+ "transitive": { "description": "Incluir dependencias transitivas (package-lock.json).", "type": "boolean" },
31
+ "depth": { "description": "Profundidad máxima con transitive (1 = solo directas).", "type": "integer", "minimum": 1, "maximum": 100 },
32
+ "concurrency": { "description": "Paquetes analizados en paralelo.", "type": "integer", "minimum": 1, "maximum": 32 },
33
+ "thresholds": {
34
+ "type": "object",
35
+ "additionalProperties": false,
36
+ "properties": {
37
+ "healthy": { "description": "Score mínimo para verde (default 70).", "type": "number", "minimum": 0, "maximum": 100 },
38
+ "caution": { "description": "Score mínimo para amarillo (default 40).", "type": "number", "minimum": 0, "maximum": 100 }
39
+ }
40
+ },
41
+ "weights": {
42
+ "type": "object",
43
+ "additionalProperties": false,
44
+ "properties": {
45
+ "archived": { "$ref": "#/definitions/points", "description": "Default 40." },
46
+ "deprecated": { "$ref": "#/definitions/points", "description": "Default 40." },
47
+ "abandonment": { "$ref": "#/definitions/tiers", "description": "Días sin commits (umbral estricto). Default: >730:45, >365:25, >180:10." },
48
+ "stalePublish": { "$ref": "#/definitions/tier", "description": "Días sin publicar en npm. Default: >730:5." },
49
+ "busFactor": {
50
+ "type": "object",
51
+ "additionalProperties": false,
52
+ "properties": {
53
+ "zero": { "$ref": "#/definitions/points", "description": "Default 20." },
54
+ "one": { "$ref": "#/definitions/points", "description": "Default 15." },
55
+ "two": { "$ref": "#/definitions/points", "description": "Default 5." }
56
+ }
57
+ },
58
+ "unansweredIssues": { "$ref": "#/definitions/tiers", "description": "Issues sin respuesta (umbral inclusivo). Default: >=25:15, >=10:10, >=3:5." },
59
+ "repoRedirect": { "$ref": "#/definitions/points", "description": "Default 10." },
60
+ "maintainersChanged": { "$ref": "#/definitions/points", "description": "Default 15." },
61
+ "newPublisher": { "$ref": "#/definitions/points", "description": "Default 15." },
62
+ "hijackPattern": { "$ref": "#/definitions/points", "description": "Default 15." },
63
+ "dormantRevivalDays": { "type": "number", "minimum": 0, "maximum": 100000, "description": "Default 365." }
64
+ }
65
+ }
66
+ }
67
+ }