deprisk 0.1.0 → 0.3.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/LICENSE +1 -1
- package/dist/index.js +52 -28
- package/package.json +24 -1
package/LICENSE
CHANGED
package/dist/index.js
CHANGED
|
@@ -25595,31 +25595,46 @@ class DependencyEvaluator {
|
|
|
25595
25595
|
static NPM_REGISTRY_BASE_URL = "https://registry.npmjs.org/";
|
|
25596
25596
|
static NPM_DOWNLOADS_POINT_URL = "https://api.npmjs.org/downloads/point/";
|
|
25597
25597
|
async evaluate(dependency) {
|
|
25598
|
+
const encodedName = dependency.name.startsWith("@") ? `@${encodeURIComponent(dependency.name.substring(1))}` : encodeURIComponent(dependency.name);
|
|
25599
|
+
let latestVersion = "unknown";
|
|
25600
|
+
let lastReleaseDate = "unknown";
|
|
25601
|
+
let isDeprecated = false;
|
|
25602
|
+
let deprecationMessage = undefined;
|
|
25603
|
+
let weeklyDownloads = 0;
|
|
25604
|
+
let monthlyDownloads = 0;
|
|
25605
|
+
let trend = "stable";
|
|
25598
25606
|
try {
|
|
25599
|
-
|
|
25600
|
-
|
|
25601
|
-
|
|
25602
|
-
|
|
25603
|
-
|
|
25604
|
-
|
|
25605
|
-
|
|
25606
|
-
|
|
25607
|
-
|
|
25608
|
-
|
|
25609
|
-
|
|
25610
|
-
|
|
25611
|
-
|
|
25612
|
-
|
|
25613
|
-
|
|
25614
|
-
|
|
25615
|
-
|
|
25616
|
-
|
|
25617
|
-
|
|
25607
|
+
try {
|
|
25608
|
+
const registryResponse = await axios_default.get(`${DependencyEvaluator.NPM_REGISTRY_BASE_URL}${encodedName}`, { timeout: 1e4 });
|
|
25609
|
+
const metadata = registryResponse.data;
|
|
25610
|
+
latestVersion = metadata["dist-tags"]?.latest || "unknown";
|
|
25611
|
+
if (latestVersion !== "unknown" && metadata.time) {
|
|
25612
|
+
lastReleaseDate = metadata.time[latestVersion] || "unknown";
|
|
25613
|
+
}
|
|
25614
|
+
if (latestVersion !== "unknown" && metadata.versions?.[latestVersion]) {
|
|
25615
|
+
isDeprecated = metadata.versions[latestVersion].deprecated !== undefined;
|
|
25616
|
+
deprecationMessage = metadata.versions[latestVersion].deprecated;
|
|
25617
|
+
}
|
|
25618
|
+
} catch (regError) {}
|
|
25619
|
+
try {
|
|
25620
|
+
const [weekRes, monthRes] = await Promise.all([
|
|
25621
|
+
axios_default.get(`${DependencyEvaluator.NPM_DOWNLOADS_POINT_URL}last-week/${encodedName}`, { timeout: 1e4 }),
|
|
25622
|
+
axios_default.get(`${DependencyEvaluator.NPM_DOWNLOADS_POINT_URL}last-month/${encodedName}`, { timeout: 1e4 })
|
|
25623
|
+
]);
|
|
25624
|
+
weeklyDownloads = weekRes.data.downloads || 0;
|
|
25625
|
+
monthlyDownloads = monthRes.data.downloads || 0;
|
|
25626
|
+
const weeklyAverage = monthlyDownloads / 4;
|
|
25627
|
+
if (weeklyDownloads < weeklyAverage * 0.8)
|
|
25628
|
+
trend = "declining";
|
|
25629
|
+
else if (weeklyDownloads > weeklyAverage * 1.2)
|
|
25630
|
+
trend = "increasing";
|
|
25631
|
+
} catch (dlError) {}
|
|
25632
|
+
const score = this.calculateScore(lastReleaseDate, weeklyDownloads, isDeprecated, trend);
|
|
25618
25633
|
return {
|
|
25619
25634
|
name: dependency.name,
|
|
25620
25635
|
currentVersion: dependency.version,
|
|
25621
25636
|
latestVersion,
|
|
25622
|
-
lastRelease:
|
|
25637
|
+
lastRelease: lastReleaseDate,
|
|
25623
25638
|
isDeprecated,
|
|
25624
25639
|
deprecationMessage,
|
|
25625
25640
|
weeklyDownloads,
|
|
@@ -25645,15 +25660,23 @@ class DependencyEvaluator {
|
|
|
25645
25660
|
if (isDeprecated)
|
|
25646
25661
|
return 0;
|
|
25647
25662
|
let score = 100;
|
|
25648
|
-
|
|
25649
|
-
|
|
25650
|
-
|
|
25651
|
-
|
|
25652
|
-
|
|
25653
|
-
|
|
25663
|
+
if (lastReleaseDate !== "unknown") {
|
|
25664
|
+
const lastRelease = new Date(lastReleaseDate).getTime();
|
|
25665
|
+
const now = Date.now();
|
|
25666
|
+
const monthsSinceRelease = (now - lastRelease) / (1000 * 60 * 60 * 24 * 30);
|
|
25667
|
+
if (monthsSinceRelease > 24)
|
|
25668
|
+
score -= 40;
|
|
25669
|
+
else if (monthsSinceRelease > 12)
|
|
25670
|
+
score -= 20;
|
|
25671
|
+
} else {
|
|
25654
25672
|
score -= 20;
|
|
25655
|
-
|
|
25673
|
+
}
|
|
25674
|
+
if (downloads > 0) {
|
|
25675
|
+
if (downloads < 1000)
|
|
25676
|
+
score -= 20;
|
|
25677
|
+
} else {
|
|
25656
25678
|
score -= 20;
|
|
25679
|
+
}
|
|
25657
25680
|
if (trend === "declining")
|
|
25658
25681
|
score -= 15;
|
|
25659
25682
|
return Math.max(0, score);
|
|
@@ -25708,10 +25731,11 @@ deprisk - Dependency Risk Advisor`));
|
|
|
25708
25731
|
const status = r.isDeprecated ? import_chalk2.default.red("DEPRECATED") : r.score < 50 ? import_chalk2.default.red("Low Maintenance") : import_chalk2.default.yellow("Declining");
|
|
25709
25732
|
const scoreColor2 = r.score < 50 ? import_chalk2.default.red : import_chalk2.default.yellow;
|
|
25710
25733
|
const trendColor = r.trend === "increasing" ? import_chalk2.default.green : r.trend === "declining" ? import_chalk2.default.red : import_chalk2.default.yellow;
|
|
25734
|
+
const releaseDate = r.lastRelease === "unknown" ? "Unknown" : new Date(r.lastRelease).toLocaleDateString();
|
|
25711
25735
|
tableData.push([
|
|
25712
25736
|
r.name,
|
|
25713
25737
|
scoreColor2(r.score.toString() + "%"),
|
|
25714
|
-
|
|
25738
|
+
releaseDate,
|
|
25715
25739
|
trendColor(r.trend),
|
|
25716
25740
|
status
|
|
25717
25741
|
]);
|
package/package.json
CHANGED
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deprisk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Dependency Risk Advisor for Node.js projects",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"dependency",
|
|
7
|
+
"risk",
|
|
8
|
+
"maintenance",
|
|
9
|
+
"audit",
|
|
10
|
+
"analysis",
|
|
11
|
+
"npm",
|
|
12
|
+
"node",
|
|
13
|
+
"deprecated",
|
|
14
|
+
"alternatives",
|
|
15
|
+
"advisor",
|
|
16
|
+
"technical-debt"
|
|
17
|
+
],
|
|
18
|
+
"homepage": "https://github.com/ravvdevv/deprisk#readme",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/ravvdevv/deprisk/issues"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"author": "ravvdevv <ravvdevv@gmail.com>",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/ravvdevv/deprisk.git"
|
|
27
|
+
},
|
|
5
28
|
"main": "dist/index.js",
|
|
6
29
|
"bin": {
|
|
7
30
|
"deprisk": "./dist/index.js"
|