dependency-detective 0.1.1 → 0.1.2

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/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { program } from 'commander';
4
- import packageJson from './package.json' assert { type: 'json' };
4
+ //import packageJson from './package.json' assert { type: 'json' };
5
5
  import { analyzeProject } from "./src/analyzer.js"
6
6
  import 'dotenv/config';
7
7
 
package/package.json CHANGED
@@ -1,36 +1,36 @@
1
- {
2
- "name": "dependency-detective",
3
- "version": "0.1.1",
4
- "description": "Analyzes your project's dependencies, identifies unused ones, forecasts potential security risks, and suggests better alternatives",
5
- "main": "index.js",
6
- "type": "module",
7
- "bin": {
8
- "dependency-detective": "./index.js"
9
- },
10
- "scripts": {
11
- "start": "node index.js",
12
- "test": "echo \"Error: no test specified\" && exit 1"
13
- },
14
- "keywords": [
15
- "dependencies",
16
- "npm",
17
- "node",
18
- "security",
19
- "optimization"
20
- ],
21
- "author": "Marvin Ackerman",
22
- "license": "MIT",
23
- "dependencies": {
24
- "axios": "^1.8.1",
25
- "chalk": "^5.4.1",
26
- "commander": "^13.1.0",
27
- "dotenv": "^16.4.7",
28
- "glob": "^11.0.1",
29
- "ora": "^8.2.0"
30
- },
31
- "repository": {
32
- "type": "git",
33
- "url": "https://github.com/Marvinkwame/dependency-detective"
34
- },
35
- "homepage": "https://github.com/Marvinkwame/dependency-detective#"
36
- }
1
+ {
2
+ "name": "dependency-detective",
3
+ "version": "0.1.2",
4
+ "description": "Analyzes your project's dependencies, identifies unused ones, forecasts potential security risks, and suggests better alternatives",
5
+ "main": "index.js",
6
+ "type": "module",
7
+ "bin": {
8
+ "dependency-detective": "./index.js"
9
+ },
10
+ "scripts": {
11
+ "start": "node index.js",
12
+ "test": "echo \"Error: no test specified\" && exit 1"
13
+ },
14
+ "keywords": [
15
+ "dependencies",
16
+ "npm",
17
+ "node",
18
+ "security",
19
+ "optimization"
20
+ ],
21
+ "author": "Marvin Ackerman",
22
+ "license": "MIT",
23
+ "dependencies": {
24
+ "axios": "^1.8.1",
25
+ "chalk": "^5.4.1",
26
+ "commander": "^13.1.0",
27
+ "dotenv": "^16.4.7",
28
+ "glob": "^11.0.1",
29
+ "ora": "^8.2.0"
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/Marvinkwame/dependency-detective"
34
+ },
35
+ "homepage": "https://github.com/Marvinkwame/dependency-detective#"
36
+ }
@@ -4,8 +4,6 @@ import axios from "axios";
4
4
  export async function suggestAlternatives(dependencies) {
5
5
  const alternatives = {};
6
6
 
7
- // In a production tool, you'd query actual package data from npm or similar
8
- // This is a simplified example with mock data
9
7
  for (const [depName, version] of Object.entries(dependencies)) {
10
8
  try {
11
9
  const suggestion = await findBetterAlternative(depName, version);
package/src/analyzer.js CHANGED
@@ -7,6 +7,7 @@ import { checkVulnerabilities } from './security-checker.js';
7
7
  import { suggestAlternatives } from './alternative-suggester.js';
8
8
 
9
9
  export async function analyzeProject(options) {
10
+ //default dependencies for react/nextjs project
10
11
  const REQUIRED_DEPENDENCIES = new Set([
11
12
  'react',
12
13
  'react-dom',
@@ -44,22 +45,22 @@ export async function analyzeProject(options) {
44
45
  )
45
46
  );
46
47
 
47
- // 1. Identify unused dependencies
48
+ // Identifing unused dependencies
48
49
  spinner.text = 'Scanning for unused dependencies...';
49
50
  const unusedDeps = await findUnusedDependencies(options.directory, filteredDependencies);
50
51
 
51
- // 2. Check for security vulnerabilities
52
+ // Checking for security vulnerabilities
52
53
  spinner.text = 'Checking for security vulnerabilities...';
53
54
  const vulnerabilities = await checkVulnerabilities(filteredDependencies);
54
55
 
55
- // 3. Suggest alternatives (if enabled)
56
+ // Suggesting alternatives (if enabled)
56
57
  let alternatives = {};
57
58
  if (options.suggestions !== false) {
58
59
  spinner.text = 'Finding better alternatives...';
59
60
  alternatives = await suggestAlternatives(filteredDependencies);
60
61
  }
61
62
 
62
- // Complete the analysis
63
+
63
64
  spinner.succeed('Analysis complete!');
64
65
 
65
66
  // Display results
@@ -70,10 +71,11 @@ export async function analyzeProject(options) {
70
71
  }
71
72
  }
72
73
 
73
- // analyzer.js or index.js
74
74
 
75
- // Define getSavingsEstimate function
75
+
76
+
76
77
  function getSavingsEstimate(unusedDeps) {
78
+
77
79
  // Average size of an npm package in MB
78
80
  const AVERAGE_PACKAGE_SIZE_MB = 5;
79
81
 
@@ -22,7 +22,7 @@ export async function checkVulnerabilities(dependencies) {
22
22
 
23
23
  export async function checkPackageVulnerabilities(packageName, version) {
24
24
  try {
25
- const SNYK_API_TOKEN = process.env.SNYK_API_TOKEN; // Ensure you set this environment variable
25
+ const SNYK_API_TOKEN = "5867f5b0-1275-4bff-99b3-c307c545b6dd";
26
26
  if (!SNYK_API_TOKEN) {
27
27
  throw new Error(
28
28
  "Snyk API token is missing. Please set the SNYK_API_TOKEN environment variable."
@@ -24,7 +24,7 @@ export async function findUnusedDependencies(directory, dependencies) {
24
24
  const version = dependencies[dep];
25
25
  let isUsed = false;
26
26
 
27
- // Common import/require patterns
27
+
28
28
  const importPatterns = [
29
29
  new RegExp(`import.*from\\s+['"]${dep}['\"]`),
30
30
  new RegExp(`import\\s+['"]${dep}['\"]`),