@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/.turbo/turbo-build.log
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
DTS Build
|
|
20
|
-
DTS
|
|
21
|
-
DTS dist/
|
|
22
|
-
DTS dist/
|
|
23
|
-
DTS dist/
|
|
24
|
-
DTS dist/index.d.mts 1.18 KB
|
|
1
|
+
|
|
2
|
+
> @aiready/deps@0.14.9 build /Users/pengcao/projects/aiready/packages/deps
|
|
3
|
+
> tsup src/index.ts src/cli.ts --format cjs,esm --dts
|
|
4
|
+
|
|
5
|
+
CLI Building entry: src/cli.ts, src/index.ts
|
|
6
|
+
CLI Using tsconfig: tsconfig.json
|
|
7
|
+
CLI tsup v8.5.1
|
|
8
|
+
CLI Target: es2020
|
|
9
|
+
CJS Build start
|
|
10
|
+
ESM Build start
|
|
11
|
+
CJS dist/index.js 8.21 KB
|
|
12
|
+
CJS dist/cli.js 7.82 KB
|
|
13
|
+
CJS ⚡️ Build success in 54ms
|
|
14
|
+
ESM dist/chunk-QTMAUA24.mjs 5.70 KB
|
|
15
|
+
ESM dist/index.mjs 1.82 KB
|
|
16
|
+
ESM dist/cli.mjs 894.00 B
|
|
17
|
+
ESM ⚡️ Build success in 54ms
|
|
18
|
+
DTS Build start
|
|
19
|
+
DTS ⚡️ Build success in 3166ms
|
|
20
|
+
DTS dist/cli.d.ts 108.00 B
|
|
21
|
+
DTS dist/index.d.ts 1.18 KB
|
|
22
|
+
DTS dist/cli.d.mts 108.00 B
|
|
23
|
+
DTS dist/index.d.mts 1.18 KB
|
package/dist/index.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ import { Issue, IssueType, ScanOptions, ToolScoringOutput } from '@aiready/core'
|
|
|
4
4
|
/**
|
|
5
5
|
* Dependency Health Tool Provider
|
|
6
6
|
*/
|
|
7
|
-
declare const
|
|
7
|
+
declare const DEPS_PROVIDER: _aiready_core.ToolProvider;
|
|
8
8
|
|
|
9
9
|
interface DepsOptions extends ScanOptions {
|
|
10
10
|
/** The year the AI model was trained. Defaults to 2023. */
|
|
@@ -37,4 +37,4 @@ declare function analyzeDeps(options: DepsOptions): Promise<DepsReport>;
|
|
|
37
37
|
*/
|
|
38
38
|
declare function calculateDepsScore(report: DepsReport): ToolScoringOutput;
|
|
39
39
|
|
|
40
|
-
export { type DepsIssue, type DepsOptions,
|
|
40
|
+
export { DEPS_PROVIDER, type DepsIssue, type DepsOptions, type DepsReport, analyzeDeps, calculateDepsScore };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Issue, IssueType, ScanOptions, ToolScoringOutput } from '@aiready/core'
|
|
|
4
4
|
/**
|
|
5
5
|
* Dependency Health Tool Provider
|
|
6
6
|
*/
|
|
7
|
-
declare const
|
|
7
|
+
declare const DEPS_PROVIDER: _aiready_core.ToolProvider;
|
|
8
8
|
|
|
9
9
|
interface DepsOptions extends ScanOptions {
|
|
10
10
|
/** The year the AI model was trained. Defaults to 2023. */
|
|
@@ -37,4 +37,4 @@ declare function analyzeDeps(options: DepsOptions): Promise<DepsReport>;
|
|
|
37
37
|
*/
|
|
38
38
|
declare function calculateDepsScore(report: DepsReport): ToolScoringOutput;
|
|
39
39
|
|
|
40
|
-
export { type DepsIssue, type DepsOptions,
|
|
40
|
+
export { DEPS_PROVIDER, type DepsIssue, type DepsOptions, type DepsReport, analyzeDeps, calculateDepsScore };
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
|
|
23
|
+
DEPS_PROVIDER: () => DEPS_PROVIDER,
|
|
24
24
|
analyzeDeps: () => analyzeDeps,
|
|
25
25
|
calculateDepsScore: () => calculateDepsScore
|
|
26
26
|
});
|
|
@@ -204,7 +204,7 @@ function evaluateHealth(type, deps, path, issues) {
|
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
// src/provider.ts
|
|
207
|
-
var
|
|
207
|
+
var DEPS_PROVIDER = (0, import_core2.createProvider)({
|
|
208
208
|
id: import_core2.ToolName.DependencyHealth,
|
|
209
209
|
alias: ["deps", "deps-health", "packages"],
|
|
210
210
|
version: "0.9.5",
|
|
@@ -258,10 +258,10 @@ function calculateDepsScore(report) {
|
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
// src/index.ts
|
|
261
|
-
import_core4.ToolRegistry.register(
|
|
261
|
+
import_core4.ToolRegistry.register(DEPS_PROVIDER);
|
|
262
262
|
// Annotate the CommonJS export names for ESM import in node:
|
|
263
263
|
0 && (module.exports = {
|
|
264
|
-
|
|
264
|
+
DEPS_PROVIDER,
|
|
265
265
|
analyzeDeps,
|
|
266
266
|
calculateDepsScore
|
|
267
267
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
groupIssuesByFile,
|
|
13
13
|
buildSimpleProviderScore
|
|
14
14
|
} from "@aiready/core";
|
|
15
|
-
var
|
|
15
|
+
var DEPS_PROVIDER = createProvider({
|
|
16
16
|
id: ToolName.DependencyHealth,
|
|
17
17
|
alias: ["deps", "deps-health", "packages"],
|
|
18
18
|
version: "0.9.5",
|
|
@@ -70,9 +70,9 @@ function calculateDepsScore(report) {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
// src/index.ts
|
|
73
|
-
ToolRegistry.register(
|
|
73
|
+
ToolRegistry.register(DEPS_PROVIDER);
|
|
74
74
|
export {
|
|
75
|
-
|
|
75
|
+
DEPS_PROVIDER,
|
|
76
76
|
analyzeDeps,
|
|
77
77
|
calculateDepsScore
|
|
78
78
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiready/deps",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.11",
|
|
4
4
|
"description": "AI-Readiness: Dependency Health & Cutoff Skew",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"commander": "^14.0.0",
|
|
10
10
|
"picocolors": "^1.0.0",
|
|
11
11
|
"semver": "^7.6.0",
|
|
12
|
-
"@aiready/core": "0.24.
|
|
12
|
+
"@aiready/core": "0.24.12"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@types/node": "^24.0.0",
|
|
@@ -1,45 +1,12 @@
|
|
|
1
|
-
import { describe, it, expect
|
|
2
|
-
import {
|
|
3
|
-
import * as analyzer from '../analyzer';
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { DEPS_PROVIDER } from '../provider';
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
describe('Dependency Health Provider', () => {
|
|
10
|
-
it('should analyze and return SpokeOutput', async () => {
|
|
11
|
-
vi.mocked(analyzer.analyzeDeps).mockResolvedValue({
|
|
12
|
-
summary: {
|
|
13
|
-
filesAnalyzed: 1,
|
|
14
|
-
packagesAnalyzed: 10,
|
|
15
|
-
score: 95,
|
|
16
|
-
rating: 'excellent',
|
|
17
|
-
},
|
|
18
|
-
issues: [],
|
|
19
|
-
rawData: {
|
|
20
|
-
totalPackages: 10,
|
|
21
|
-
outdatedPackages: 0,
|
|
22
|
-
deprecatedPackages: 0,
|
|
23
|
-
trainingCutoffSkew: 0,
|
|
24
|
-
},
|
|
25
|
-
recommendations: [],
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const output = await DepsProvider.analyze({ rootDir: '.' });
|
|
29
|
-
|
|
30
|
-
expect(output.summary.filesAnalyzed).toBe(1);
|
|
31
|
-
expect(output.metadata!.toolName).toBe('dependency-health');
|
|
4
|
+
describe('Deps Provider', () => {
|
|
5
|
+
it('should have correct ID', () => {
|
|
6
|
+
expect(DEPS_PROVIDER.id).toBe('deps');
|
|
32
7
|
});
|
|
33
8
|
|
|
34
|
-
it('should
|
|
35
|
-
|
|
36
|
-
summary: { score: 85, recommendations: ['Update things'] } as any,
|
|
37
|
-
metadata: { rawData: {} },
|
|
38
|
-
results: [],
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const scoring = DepsProvider.score(mockOutput as any, { rootDir: '.' });
|
|
42
|
-
expect(scoring.score).toBe(85);
|
|
43
|
-
expect(scoring.recommendations[0].action).toBe('Update things');
|
|
9
|
+
it('should have alias', () => {
|
|
10
|
+
expect(DEPS_PROVIDER.alias).toContain('dependency-health');
|
|
44
11
|
});
|
|
45
12
|
});
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ToolRegistry } from '@aiready/core';
|
|
2
|
-
import {
|
|
2
|
+
import { DEPS_PROVIDER } from './provider';
|
|
3
3
|
|
|
4
4
|
// Register with global registry
|
|
5
|
-
ToolRegistry.register(
|
|
5
|
+
ToolRegistry.register(DEPS_PROVIDER);
|
|
6
6
|
|
|
7
7
|
export * from './types';
|
|
8
8
|
export * from './analyzer';
|
|
9
9
|
export * from './scoring';
|
|
10
|
-
export {
|
|
10
|
+
export { DEPS_PROVIDER };
|
package/src/provider.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { DepsOptions } from './types';
|
|
|
11
11
|
/**
|
|
12
12
|
* Dependency Health Tool Provider
|
|
13
13
|
*/
|
|
14
|
-
export const
|
|
14
|
+
export const DEPS_PROVIDER = createProvider({
|
|
15
15
|
id: ToolName.DependencyHealth,
|
|
16
16
|
alias: ['deps', 'deps-health', 'packages'],
|
|
17
17
|
version: '0.9.5',
|
package/dist/chunk-4D7DCOHZ.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, Severity, IssueType } 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: IssueType.DependencyHealth,
|
|
45
|
-
severity: 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: IssueType.DependencyHealth,
|
|
54
|
-
severity: 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-77JXPNC4.mjs
DELETED
|
@@ -1,179 +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 || name === "lodash" && type === "npm") {
|
|
166
|
-
outdated++;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
if (deps.some((d) => ["react", "next", "typescript"].includes(d))) {
|
|
170
|
-
skew = 0.5;
|
|
171
|
-
}
|
|
172
|
-
skew = Math.max(skew, Math.min(1, deps.length / 50));
|
|
173
|
-
return { outdated, deprecated, skew };
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export {
|
|
177
|
-
__require,
|
|
178
|
-
analyzeDeps
|
|
179
|
-
};
|