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.
Files changed (3) hide show
  1. package/LICENSE +1 -1
  2. package/dist/index.js +52 -28
  3. package/package.json +24 -1
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026
3
+ Copyright (c) 2026 ravvdevv
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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
- const registryResponse = await axios_default.get(`${DependencyEvaluator.NPM_REGISTRY_BASE_URL}${dependency.name}`);
25600
- const metadata = registryResponse.data;
25601
- const latestVersion = metadata["dist-tags"].latest;
25602
- const latestReleaseDate = metadata.time[latestVersion];
25603
- const isDeprecated = metadata.versions[latestVersion].deprecated !== undefined;
25604
- const deprecationMessage = metadata.versions[latestVersion].deprecated;
25605
- const [weekRes, monthRes] = await Promise.all([
25606
- axios_default.get(`${DependencyEvaluator.NPM_DOWNLOADS_POINT_URL}last-week/${dependency.name}`),
25607
- axios_default.get(`${DependencyEvaluator.NPM_DOWNLOADS_POINT_URL}last-month/${dependency.name}`)
25608
- ]);
25609
- const weeklyDownloads = weekRes.data.downloads;
25610
- const monthlyDownloads = monthRes.data.downloads;
25611
- const weeklyAverage = monthlyDownloads / 4;
25612
- let trend = "stable";
25613
- if (weeklyDownloads < weeklyAverage * 0.8)
25614
- trend = "declining";
25615
- if (weeklyDownloads > weeklyAverage * 1.2)
25616
- trend = "increasing";
25617
- const score = this.calculateScore(latestReleaseDate, weeklyDownloads, isDeprecated, trend);
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: latestReleaseDate,
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
- const lastRelease = new Date(lastReleaseDate).getTime();
25649
- const now = Date.now();
25650
- const monthsSinceRelease = (now - lastRelease) / (1000 * 60 * 60 * 24 * 30);
25651
- if (monthsSinceRelease > 24)
25652
- score -= 40;
25653
- else if (monthsSinceRelease > 12)
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
- if (downloads < 1000)
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
- new Date(r.lastRelease).toLocaleDateString(),
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.1.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"