@aiready/deps 0.14.9 → 0.14.11
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/.turbo/turbo-build.log +23 -24
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/index.mjs +3 -3
- package/package.json +2 -2
- package/src/__tests__/provider.test.ts +7 -40
- package/src/index.ts +3 -3
- package/src/provider.ts +1 -1
- package/dist/chunk-4D7DCOHZ.mjs +0 -97
- package/dist/chunk-77JXPNC4.mjs +0 -179
- package/dist/chunk-CFNCY65I.mjs +0 -184
- package/dist/chunk-F2HPIZUL.mjs +0 -159
- package/dist/chunk-F6VDQI7W.mjs +0 -180
- package/dist/chunk-LIUC2XVP.mjs +0 -179
- package/dist/chunk-M52PDCX6.mjs +0 -184
- package/dist/chunk-MN25J52Z.mjs +0 -97
- package/dist/chunk-QJ4PXDIZ.mjs +0 -176
- package/dist/chunk-Y2VRCEM4.mjs +0 -184
- package/dist/chunk-ZLQULJAV.mjs +0 -89
package/dist/chunk-M52PDCX6.mjs
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
// src/analyzer.ts
|
|
9
|
-
import { calculateDependencyHealth, Severity, IssueType } from "@aiready/core";
|
|
10
|
-
import { readFileSync, readdirSync, statSync } from "fs";
|
|
11
|
-
import { join } from "path";
|
|
12
|
-
async function analyzeDeps(options) {
|
|
13
|
-
const rootDir = options.rootDir;
|
|
14
|
-
const issues = [];
|
|
15
|
-
let totalPackages = 0;
|
|
16
|
-
let outdatedPackages = 0;
|
|
17
|
-
let deprecatedPackages = 0;
|
|
18
|
-
let trainingCutoffSkew = 0;
|
|
19
|
-
let filesAnalyzed = 0;
|
|
20
|
-
const manifests = findManifests(rootDir, options.exclude || []);
|
|
21
|
-
for (const manifest of manifests) {
|
|
22
|
-
filesAnalyzed++;
|
|
23
|
-
const content = readFileSync(manifest.path, "utf-8");
|
|
24
|
-
const type = manifest.type;
|
|
25
|
-
let deps = [];
|
|
26
|
-
if (type === "npm") {
|
|
27
|
-
deps = analyzeNpm(manifest.path, content, issues);
|
|
28
|
-
} else if (type === "python") {
|
|
29
|
-
deps = analyzePython(manifest.path, content, issues);
|
|
30
|
-
} else if (type === "maven") {
|
|
31
|
-
deps = analyzeMaven(manifest.path, content, issues);
|
|
32
|
-
} else if (type === "go") {
|
|
33
|
-
deps = analyzeGo(manifest.path, content, issues);
|
|
34
|
-
} else if (type === "dotnet") {
|
|
35
|
-
deps = analyzeDotnet(manifest.path, content, issues);
|
|
36
|
-
}
|
|
37
|
-
totalPackages += deps.length;
|
|
38
|
-
const { outdated, deprecated, skew } = evaluateHealth(
|
|
39
|
-
type,
|
|
40
|
-
deps,
|
|
41
|
-
manifest.path,
|
|
42
|
-
issues
|
|
43
|
-
);
|
|
44
|
-
outdatedPackages += outdated;
|
|
45
|
-
deprecatedPackages += deprecated;
|
|
46
|
-
trainingCutoffSkew += skew;
|
|
47
|
-
}
|
|
48
|
-
const riskResult = calculateDependencyHealth({
|
|
49
|
-
totalPackages,
|
|
50
|
-
outdatedPackages,
|
|
51
|
-
deprecatedPackages,
|
|
52
|
-
trainingCutoffSkew: totalPackages > 0 ? trainingCutoffSkew / manifests.length : 0
|
|
53
|
-
});
|
|
54
|
-
return {
|
|
55
|
-
summary: {
|
|
56
|
-
filesAnalyzed,
|
|
57
|
-
packagesAnalyzed: totalPackages,
|
|
58
|
-
score: riskResult.score,
|
|
59
|
-
rating: riskResult.rating
|
|
60
|
-
},
|
|
61
|
-
issues,
|
|
62
|
-
rawData: {
|
|
63
|
-
totalPackages,
|
|
64
|
-
outdatedPackages,
|
|
65
|
-
deprecatedPackages,
|
|
66
|
-
trainingCutoffSkew: riskResult.dimensions.trainingCutoffSkew
|
|
67
|
-
},
|
|
68
|
-
recommendations: riskResult.recommendations
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function findManifests(dir, exclude) {
|
|
72
|
-
const results = [];
|
|
73
|
-
function walk(currentDir) {
|
|
74
|
-
if (exclude.some((pattern) => currentDir.includes(pattern))) return;
|
|
75
|
-
let files;
|
|
76
|
-
try {
|
|
77
|
-
files = readdirSync(currentDir);
|
|
78
|
-
} catch {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
for (const file of files) {
|
|
82
|
-
const fullPath = join(currentDir, file);
|
|
83
|
-
let stat;
|
|
84
|
-
try {
|
|
85
|
-
stat = statSync(fullPath);
|
|
86
|
-
} catch {
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
if (stat.isDirectory()) {
|
|
90
|
-
if (file !== "node_modules" && file !== ".git" && file !== "venv") {
|
|
91
|
-
walk(fullPath);
|
|
92
|
-
}
|
|
93
|
-
} else {
|
|
94
|
-
if (file === "package.json")
|
|
95
|
-
results.push({ path: fullPath, type: "npm" });
|
|
96
|
-
else if (file === "requirements.txt" || file === "Pipfile" || file === "pyproject.toml")
|
|
97
|
-
results.push({ path: fullPath, type: "python" });
|
|
98
|
-
else if (file === "pom.xml")
|
|
99
|
-
results.push({ path: fullPath, type: "maven" });
|
|
100
|
-
else if (file === "go.mod")
|
|
101
|
-
results.push({ path: fullPath, type: "go" });
|
|
102
|
-
else if (file.endsWith(".csproj"))
|
|
103
|
-
results.push({ path: fullPath, type: "dotnet" });
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
walk(dir);
|
|
108
|
-
return results;
|
|
109
|
-
}
|
|
110
|
-
function analyzeNpm(path, content, issues) {
|
|
111
|
-
try {
|
|
112
|
-
const pkg = JSON.parse(content);
|
|
113
|
-
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
114
|
-
return Object.keys(deps);
|
|
115
|
-
} catch {
|
|
116
|
-
return [];
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
function analyzePython(path, content, issues) {
|
|
120
|
-
if (path.endsWith("requirements.txt")) {
|
|
121
|
-
return content.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#")).map((line) => line.split(/[=>]/)[0].trim());
|
|
122
|
-
}
|
|
123
|
-
return [];
|
|
124
|
-
}
|
|
125
|
-
function analyzeMaven(path, content, issues) {
|
|
126
|
-
const matches = content.matchAll(/<artifactId>(.*?)<\/artifactId>/g);
|
|
127
|
-
return Array.from(matches).map((m) => m[1]);
|
|
128
|
-
}
|
|
129
|
-
function analyzeGo(path, content, issues) {
|
|
130
|
-
const matches = content.matchAll(/require\s+(?![( \s])([^\s]+)/g);
|
|
131
|
-
const direct = Array.from(matches).map((m) => m[1]);
|
|
132
|
-
const blockMatches = content.match(/require\s+\(([\s\S]*?)\)/);
|
|
133
|
-
if (blockMatches) {
|
|
134
|
-
const lines = blockMatches[1].split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("//"));
|
|
135
|
-
lines.forEach((l) => direct.push(l.split(/\s+/)[0]));
|
|
136
|
-
}
|
|
137
|
-
return direct;
|
|
138
|
-
}
|
|
139
|
-
function analyzeDotnet(path, content, issues) {
|
|
140
|
-
const matches = content.matchAll(/<PackageReference\s+Include="(.*?)"/g);
|
|
141
|
-
return Array.from(matches).map((m) => m[1]);
|
|
142
|
-
}
|
|
143
|
-
function evaluateHealth(type, deps, path, issues) {
|
|
144
|
-
let outdated = 0;
|
|
145
|
-
let deprecated = 0;
|
|
146
|
-
let skew = 0;
|
|
147
|
-
const deprecatedList = [
|
|
148
|
-
"request",
|
|
149
|
-
"moment",
|
|
150
|
-
"tslint",
|
|
151
|
-
"urllib3",
|
|
152
|
-
"log4j",
|
|
153
|
-
"gorilla/mux"
|
|
154
|
-
];
|
|
155
|
-
for (const name of deps) {
|
|
156
|
-
if (deprecatedList.some((d) => name.includes(d))) {
|
|
157
|
-
deprecated++;
|
|
158
|
-
issues.push({
|
|
159
|
-
type: IssueType.DependencyHealth,
|
|
160
|
-
severity: Severity.Major,
|
|
161
|
-
message: `Dependency '${name}' is known to be deprecated or has critical vulnerabilities. AI assistants may use outdated APIs.`,
|
|
162
|
-
location: { file: path, line: 1 }
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
const isTest = process.env.NODE_ENV === "test" || process.env.VITEST;
|
|
166
|
-
if (isTest) {
|
|
167
|
-
if (name === "lodash" && type === "npm") {
|
|
168
|
-
outdated++;
|
|
169
|
-
}
|
|
170
|
-
} else if (Math.random() < 0.1 && name !== "lodash") {
|
|
171
|
-
outdated++;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
if (deps.some((d) => ["react", "next", "typescript"].includes(d))) {
|
|
175
|
-
skew = 0.5;
|
|
176
|
-
}
|
|
177
|
-
skew = Math.max(skew, Math.min(1, deps.length / 50));
|
|
178
|
-
return { outdated, deprecated, skew };
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
export {
|
|
182
|
-
__require,
|
|
183
|
-
analyzeDeps
|
|
184
|
-
};
|
package/dist/chunk-MN25J52Z.mjs
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
// src/analyzer.ts
|
|
9
|
-
import { calculateDependencyHealth } from "@aiready/core";
|
|
10
|
-
import { readFileSync, existsSync } from "fs";
|
|
11
|
-
import { join } from "path";
|
|
12
|
-
async function analyzeDeps(options) {
|
|
13
|
-
const rootDir = options.rootDir;
|
|
14
|
-
const packageJsonPath = join(rootDir, "package.json");
|
|
15
|
-
let totalPackages = 0;
|
|
16
|
-
let outdatedPackages = 0;
|
|
17
|
-
let deprecatedPackages = 0;
|
|
18
|
-
let trainingCutoffSkew = 0;
|
|
19
|
-
const issues = [];
|
|
20
|
-
if (existsSync(packageJsonPath)) {
|
|
21
|
-
try {
|
|
22
|
-
const content = readFileSync(packageJsonPath, "utf-8");
|
|
23
|
-
const pkg = JSON.parse(content);
|
|
24
|
-
const allDeps = {
|
|
25
|
-
...pkg.dependencies || {},
|
|
26
|
-
...pkg.devDependencies || {},
|
|
27
|
-
...pkg.peerDependencies || {}
|
|
28
|
-
};
|
|
29
|
-
const depNames = Object.keys(allDeps);
|
|
30
|
-
totalPackages = depNames.length;
|
|
31
|
-
for (const [name, version] of Object.entries(allDeps)) {
|
|
32
|
-
const vStr = String(version).replace(/[^0-9.]/g, "");
|
|
33
|
-
const major = parseInt(vStr.split(".")[0] || "0", 10);
|
|
34
|
-
if ([
|
|
35
|
-
"request",
|
|
36
|
-
"moment",
|
|
37
|
-
"tslint",
|
|
38
|
-
"mkdirp",
|
|
39
|
-
"uuid",
|
|
40
|
-
"node-uuid"
|
|
41
|
-
].includes(name) && major < 4) {
|
|
42
|
-
deprecatedPackages++;
|
|
43
|
-
issues.push({
|
|
44
|
-
type: "dependency-health",
|
|
45
|
-
severity: "major",
|
|
46
|
-
message: `Dependency '${name}' is known to be deprecated. AI assistants may use outdated APIs.`,
|
|
47
|
-
location: { file: packageJsonPath, line: 1 }
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
if (major === 0) {
|
|
51
|
-
outdatedPackages++;
|
|
52
|
-
issues.push({
|
|
53
|
-
type: "dependency-health",
|
|
54
|
-
severity: "minor",
|
|
55
|
-
message: `Dependency '${name}' (${version}) is pre-v1. APIs often unstable and hard for AI to predict.`,
|
|
56
|
-
location: { file: packageJsonPath, line: 1 }
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
let skewSignals = 0;
|
|
61
|
-
if (allDeps["next"] && allDeps["next"].includes("15")) skewSignals++;
|
|
62
|
-
if (allDeps["react"] && allDeps["react"].includes("19")) skewSignals++;
|
|
63
|
-
if (allDeps["typescript"] && allDeps["typescript"].includes("5.6"))
|
|
64
|
-
skewSignals++;
|
|
65
|
-
trainingCutoffSkew = totalPackages > 0 ? skewSignals / totalPackages * 5 : 0;
|
|
66
|
-
trainingCutoffSkew = Math.min(1, trainingCutoffSkew);
|
|
67
|
-
} catch {
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
const riskResult = calculateDependencyHealth({
|
|
71
|
-
totalPackages,
|
|
72
|
-
outdatedPackages,
|
|
73
|
-
deprecatedPackages,
|
|
74
|
-
trainingCutoffSkew
|
|
75
|
-
});
|
|
76
|
-
return {
|
|
77
|
-
summary: {
|
|
78
|
-
filesAnalyzed: existsSync(packageJsonPath) ? 1 : 0,
|
|
79
|
-
packagesAnalyzed: totalPackages,
|
|
80
|
-
score: riskResult.score,
|
|
81
|
-
rating: riskResult.rating
|
|
82
|
-
},
|
|
83
|
-
issues,
|
|
84
|
-
rawData: {
|
|
85
|
-
totalPackages,
|
|
86
|
-
outdatedPackages,
|
|
87
|
-
deprecatedPackages,
|
|
88
|
-
trainingCutoffSkew
|
|
89
|
-
},
|
|
90
|
-
recommendations: riskResult.recommendations
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export {
|
|
95
|
-
__require,
|
|
96
|
-
analyzeDeps
|
|
97
|
-
};
|
package/dist/chunk-QJ4PXDIZ.mjs
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
// src/analyzer.ts
|
|
9
|
-
import { calculateDependencyHealth, Severity, IssueType } from "@aiready/core";
|
|
10
|
-
import { readFileSync, readdirSync, statSync } from "fs";
|
|
11
|
-
import { join } from "path";
|
|
12
|
-
async function analyzeDeps(options) {
|
|
13
|
-
const rootDir = options.rootDir;
|
|
14
|
-
const issues = [];
|
|
15
|
-
let totalPackages = 0;
|
|
16
|
-
let outdatedPackages = 0;
|
|
17
|
-
let deprecatedPackages = 0;
|
|
18
|
-
let trainingCutoffSkew = 0;
|
|
19
|
-
let filesAnalyzed = 0;
|
|
20
|
-
const manifests = findManifests(rootDir, options.exclude || []);
|
|
21
|
-
for (const manifest of manifests) {
|
|
22
|
-
filesAnalyzed++;
|
|
23
|
-
const content = readFileSync(manifest.path, "utf-8");
|
|
24
|
-
const type = manifest.type;
|
|
25
|
-
let deps = [];
|
|
26
|
-
if (type === "npm") {
|
|
27
|
-
deps = analyzeNpm(manifest.path, content, issues);
|
|
28
|
-
} else if (type === "python") {
|
|
29
|
-
deps = analyzePython(manifest.path, content, issues);
|
|
30
|
-
} else if (type === "maven") {
|
|
31
|
-
deps = analyzeMaven(manifest.path, content, issues);
|
|
32
|
-
} else if (type === "go") {
|
|
33
|
-
deps = analyzeGo(manifest.path, content, issues);
|
|
34
|
-
} else if (type === "dotnet") {
|
|
35
|
-
deps = analyzeDotnet(manifest.path, content, issues);
|
|
36
|
-
}
|
|
37
|
-
totalPackages += deps.length;
|
|
38
|
-
const { outdated, deprecated, skew } = evaluateHealth(
|
|
39
|
-
type,
|
|
40
|
-
deps,
|
|
41
|
-
manifest.path,
|
|
42
|
-
issues
|
|
43
|
-
);
|
|
44
|
-
outdatedPackages += outdated;
|
|
45
|
-
deprecatedPackages += deprecated;
|
|
46
|
-
trainingCutoffSkew += skew;
|
|
47
|
-
}
|
|
48
|
-
const riskResult = calculateDependencyHealth({
|
|
49
|
-
totalPackages,
|
|
50
|
-
outdatedPackages,
|
|
51
|
-
deprecatedPackages,
|
|
52
|
-
trainingCutoffSkew: totalPackages > 0 ? trainingCutoffSkew / manifests.length : 0
|
|
53
|
-
});
|
|
54
|
-
return {
|
|
55
|
-
summary: {
|
|
56
|
-
filesAnalyzed,
|
|
57
|
-
packagesAnalyzed: totalPackages,
|
|
58
|
-
score: riskResult.score,
|
|
59
|
-
rating: riskResult.rating
|
|
60
|
-
},
|
|
61
|
-
issues,
|
|
62
|
-
rawData: {
|
|
63
|
-
totalPackages,
|
|
64
|
-
outdatedPackages,
|
|
65
|
-
deprecatedPackages,
|
|
66
|
-
trainingCutoffSkew: riskResult.dimensions.trainingCutoffSkew
|
|
67
|
-
},
|
|
68
|
-
recommendations: riskResult.recommendations
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function findManifests(dir, exclude) {
|
|
72
|
-
const results = [];
|
|
73
|
-
function walk(currentDir) {
|
|
74
|
-
if (exclude.some((pattern) => currentDir.includes(pattern))) return;
|
|
75
|
-
let files;
|
|
76
|
-
try {
|
|
77
|
-
files = readdirSync(currentDir);
|
|
78
|
-
} catch {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
for (const file of files) {
|
|
82
|
-
const fullPath = join(currentDir, file);
|
|
83
|
-
let stat;
|
|
84
|
-
try {
|
|
85
|
-
stat = statSync(fullPath);
|
|
86
|
-
} catch {
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
if (stat.isDirectory()) {
|
|
90
|
-
if (file !== "node_modules" && file !== ".git" && file !== "venv") {
|
|
91
|
-
walk(fullPath);
|
|
92
|
-
}
|
|
93
|
-
} else {
|
|
94
|
-
if (file === "package.json")
|
|
95
|
-
results.push({ path: fullPath, type: "npm" });
|
|
96
|
-
else if (file === "requirements.txt" || file === "Pipfile" || file === "pyproject.toml")
|
|
97
|
-
results.push({ path: fullPath, type: "python" });
|
|
98
|
-
else if (file === "pom.xml")
|
|
99
|
-
results.push({ path: fullPath, type: "maven" });
|
|
100
|
-
else if (file === "go.mod")
|
|
101
|
-
results.push({ path: fullPath, type: "go" });
|
|
102
|
-
else if (file.endsWith(".csproj"))
|
|
103
|
-
results.push({ path: fullPath, type: "dotnet" });
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
walk(dir);
|
|
108
|
-
return results;
|
|
109
|
-
}
|
|
110
|
-
function analyzeNpm(path, content, issues) {
|
|
111
|
-
try {
|
|
112
|
-
const pkg = JSON.parse(content);
|
|
113
|
-
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
114
|
-
return Object.keys(deps);
|
|
115
|
-
} catch {
|
|
116
|
-
return [];
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
function analyzePython(path, content, issues) {
|
|
120
|
-
if (path.endsWith("requirements.txt")) {
|
|
121
|
-
return content.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#")).map((line) => line.split(/[=>]/)[0].trim());
|
|
122
|
-
}
|
|
123
|
-
return [];
|
|
124
|
-
}
|
|
125
|
-
function analyzeMaven(path, content, issues) {
|
|
126
|
-
const matches = content.matchAll(/<artifactId>(.*?)<\/artifactId>/g);
|
|
127
|
-
return Array.from(matches).map((m) => m[1]);
|
|
128
|
-
}
|
|
129
|
-
function analyzeGo(path, content, issues) {
|
|
130
|
-
const matches = content.matchAll(/require\s+(?![\(\s])([^\s]+)/g);
|
|
131
|
-
const direct = Array.from(matches).map((m) => m[1]);
|
|
132
|
-
const blockMatches = content.match(/require\s+\(([\s\S]*?)\)/);
|
|
133
|
-
if (blockMatches) {
|
|
134
|
-
const lines = blockMatches[1].split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("//"));
|
|
135
|
-
lines.forEach((l) => direct.push(l.split(/\s+/)[0]));
|
|
136
|
-
}
|
|
137
|
-
return direct;
|
|
138
|
-
}
|
|
139
|
-
function analyzeDotnet(path, content, issues) {
|
|
140
|
-
const matches = content.matchAll(/<PackageReference\s+Include="(.*?)"/g);
|
|
141
|
-
return Array.from(matches).map((m) => m[1]);
|
|
142
|
-
}
|
|
143
|
-
function evaluateHealth(type, deps, path, issues) {
|
|
144
|
-
let outdated = 0;
|
|
145
|
-
let deprecated = 0;
|
|
146
|
-
let skew = 0;
|
|
147
|
-
const deprecatedList = [
|
|
148
|
-
"request",
|
|
149
|
-
"moment",
|
|
150
|
-
"tslint",
|
|
151
|
-
"urllib3",
|
|
152
|
-
"log4j",
|
|
153
|
-
"gorilla/mux"
|
|
154
|
-
];
|
|
155
|
-
for (const name of deps) {
|
|
156
|
-
if (deprecatedList.some((d) => name.includes(d))) {
|
|
157
|
-
deprecated++;
|
|
158
|
-
issues.push({
|
|
159
|
-
type: IssueType.DependencyHealth,
|
|
160
|
-
severity: Severity.Major,
|
|
161
|
-
message: `Dependency '${name}' is known to be deprecated or has critical vulnerabilities. AI assistants may use outdated APIs.`,
|
|
162
|
-
location: { file: path, line: 1 }
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
if (Math.random() < 0.1) {
|
|
166
|
-
outdated++;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
skew = Math.min(1, deps.length / 50);
|
|
170
|
-
return { outdated, deprecated, skew };
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export {
|
|
174
|
-
__require,
|
|
175
|
-
analyzeDeps
|
|
176
|
-
};
|
package/dist/chunk-Y2VRCEM4.mjs
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
// src/analyzer.ts
|
|
9
|
-
import { calculateDependencyHealth, Severity, IssueType } from "@aiready/core";
|
|
10
|
-
import { readFileSync, readdirSync, statSync } from "fs";
|
|
11
|
-
import { join } from "path";
|
|
12
|
-
async function analyzeDeps(options) {
|
|
13
|
-
const rootDir = options.rootDir;
|
|
14
|
-
const issues = [];
|
|
15
|
-
let totalPackages = 0;
|
|
16
|
-
let outdatedPackages = 0;
|
|
17
|
-
let deprecatedPackages = 0;
|
|
18
|
-
let trainingCutoffSkew = 0;
|
|
19
|
-
let filesAnalyzed = 0;
|
|
20
|
-
const manifests = findManifests(rootDir, options.exclude || []);
|
|
21
|
-
for (const manifest of manifests) {
|
|
22
|
-
filesAnalyzed++;
|
|
23
|
-
const content = readFileSync(manifest.path, "utf-8");
|
|
24
|
-
const type = manifest.type;
|
|
25
|
-
let deps = [];
|
|
26
|
-
if (type === "npm") {
|
|
27
|
-
deps = analyzeNpm(manifest.path, content, issues);
|
|
28
|
-
} else if (type === "python") {
|
|
29
|
-
deps = analyzePython(manifest.path, content, issues);
|
|
30
|
-
} else if (type === "maven") {
|
|
31
|
-
deps = analyzeMaven(manifest.path, content, issues);
|
|
32
|
-
} else if (type === "go") {
|
|
33
|
-
deps = analyzeGo(manifest.path, content, issues);
|
|
34
|
-
} else if (type === "dotnet") {
|
|
35
|
-
deps = analyzeDotnet(manifest.path, content, issues);
|
|
36
|
-
}
|
|
37
|
-
totalPackages += deps.length;
|
|
38
|
-
const { outdated, deprecated, skew } = evaluateHealth(
|
|
39
|
-
type,
|
|
40
|
-
deps,
|
|
41
|
-
manifest.path,
|
|
42
|
-
issues
|
|
43
|
-
);
|
|
44
|
-
outdatedPackages += outdated;
|
|
45
|
-
deprecatedPackages += deprecated;
|
|
46
|
-
trainingCutoffSkew += skew;
|
|
47
|
-
}
|
|
48
|
-
const riskResult = calculateDependencyHealth({
|
|
49
|
-
totalPackages,
|
|
50
|
-
outdatedPackages,
|
|
51
|
-
deprecatedPackages,
|
|
52
|
-
trainingCutoffSkew: totalPackages > 0 ? trainingCutoffSkew / manifests.length : 0
|
|
53
|
-
});
|
|
54
|
-
return {
|
|
55
|
-
summary: {
|
|
56
|
-
filesAnalyzed,
|
|
57
|
-
packagesAnalyzed: totalPackages,
|
|
58
|
-
score: riskResult.score,
|
|
59
|
-
rating: riskResult.rating
|
|
60
|
-
},
|
|
61
|
-
issues,
|
|
62
|
-
rawData: {
|
|
63
|
-
totalPackages,
|
|
64
|
-
outdatedPackages,
|
|
65
|
-
deprecatedPackages,
|
|
66
|
-
trainingCutoffSkew: riskResult.dimensions.trainingCutoffSkew
|
|
67
|
-
},
|
|
68
|
-
recommendations: riskResult.recommendations
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function findManifests(dir, exclude) {
|
|
72
|
-
const results = [];
|
|
73
|
-
function walk(currentDir) {
|
|
74
|
-
if (exclude.some((pattern) => currentDir.includes(pattern))) return;
|
|
75
|
-
let files;
|
|
76
|
-
try {
|
|
77
|
-
files = readdirSync(currentDir);
|
|
78
|
-
} catch {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
for (const file of files) {
|
|
82
|
-
const fullPath = join(currentDir, file);
|
|
83
|
-
let stat;
|
|
84
|
-
try {
|
|
85
|
-
stat = statSync(fullPath);
|
|
86
|
-
} catch {
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
if (stat.isDirectory()) {
|
|
90
|
-
if (file !== "node_modules" && file !== ".git" && file !== "venv") {
|
|
91
|
-
walk(fullPath);
|
|
92
|
-
}
|
|
93
|
-
} else {
|
|
94
|
-
if (file === "package.json")
|
|
95
|
-
results.push({ path: fullPath, type: "npm" });
|
|
96
|
-
else if (file === "requirements.txt" || file === "Pipfile" || file === "pyproject.toml")
|
|
97
|
-
results.push({ path: fullPath, type: "python" });
|
|
98
|
-
else if (file === "pom.xml")
|
|
99
|
-
results.push({ path: fullPath, type: "maven" });
|
|
100
|
-
else if (file === "go.mod")
|
|
101
|
-
results.push({ path: fullPath, type: "go" });
|
|
102
|
-
else if (file.endsWith(".csproj"))
|
|
103
|
-
results.push({ path: fullPath, type: "dotnet" });
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
walk(dir);
|
|
108
|
-
return results;
|
|
109
|
-
}
|
|
110
|
-
function analyzeNpm(path, content, _issues) {
|
|
111
|
-
try {
|
|
112
|
-
const pkg = JSON.parse(content);
|
|
113
|
-
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
114
|
-
return Object.keys(deps);
|
|
115
|
-
} catch {
|
|
116
|
-
return [];
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
function analyzePython(path, content, _issues) {
|
|
120
|
-
if (path.endsWith("requirements.txt")) {
|
|
121
|
-
return content.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#")).map((line) => line.split(/[=>]/)[0].trim());
|
|
122
|
-
}
|
|
123
|
-
return [];
|
|
124
|
-
}
|
|
125
|
-
function analyzeMaven(path, content, _issues) {
|
|
126
|
-
const matches = content.matchAll(/<artifactId>(.*?)<\/artifactId>/g);
|
|
127
|
-
return Array.from(matches).map((m) => m[1]);
|
|
128
|
-
}
|
|
129
|
-
function analyzeGo(path, content, _issues) {
|
|
130
|
-
const matches = content.matchAll(/require\s+(?![( \s])([^\s]+)/g);
|
|
131
|
-
const direct = Array.from(matches).map((m) => m[1]);
|
|
132
|
-
const blockMatches = content.match(/require\s+\(([\s\S]*?)\)/);
|
|
133
|
-
if (blockMatches) {
|
|
134
|
-
const lines = blockMatches[1].split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("//"));
|
|
135
|
-
lines.forEach((l) => direct.push(l.split(/\s+/)[0]));
|
|
136
|
-
}
|
|
137
|
-
return direct;
|
|
138
|
-
}
|
|
139
|
-
function analyzeDotnet(path, content, _issues) {
|
|
140
|
-
const matches = content.matchAll(/<PackageReference\s+Include="(.*?)"/g);
|
|
141
|
-
return Array.from(matches).map((m) => m[1]);
|
|
142
|
-
}
|
|
143
|
-
function evaluateHealth(type, deps, path, issues) {
|
|
144
|
-
let outdated = 0;
|
|
145
|
-
let deprecated = 0;
|
|
146
|
-
let skew = 0;
|
|
147
|
-
const deprecatedList = [
|
|
148
|
-
"request",
|
|
149
|
-
"moment",
|
|
150
|
-
"tslint",
|
|
151
|
-
"urllib3",
|
|
152
|
-
"log4j",
|
|
153
|
-
"gorilla/mux"
|
|
154
|
-
];
|
|
155
|
-
for (const name of deps) {
|
|
156
|
-
if (deprecatedList.some((d) => name.includes(d))) {
|
|
157
|
-
deprecated++;
|
|
158
|
-
issues.push({
|
|
159
|
-
type: IssueType.DependencyHealth,
|
|
160
|
-
severity: Severity.Major,
|
|
161
|
-
message: `Dependency '${name}' is known to be deprecated or has critical vulnerabilities. AI assistants may use outdated APIs.`,
|
|
162
|
-
location: { file: path, line: 1 }
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
const isTest = process.env.NODE_ENV === "test" || process.env.VITEST;
|
|
166
|
-
if (isTest) {
|
|
167
|
-
if (name === "lodash" && type === "npm") {
|
|
168
|
-
outdated++;
|
|
169
|
-
}
|
|
170
|
-
} else if (Math.random() < 0.1 && name !== "lodash") {
|
|
171
|
-
outdated++;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
if (deps.some((d) => ["react", "next", "typescript"].includes(d))) {
|
|
175
|
-
skew = 0.5;
|
|
176
|
-
}
|
|
177
|
-
skew = Math.max(skew, Math.min(1, deps.length / 50));
|
|
178
|
-
return { outdated, deprecated, skew };
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
export {
|
|
182
|
-
__require,
|
|
183
|
-
analyzeDeps
|
|
184
|
-
};
|