dependency-detective 0.1.0 → 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/LICENSE +21 -0
- package/index.js +1 -1
- package/package.json +36 -31
- package/src/alternative-suggester.js +0 -2
- package/src/analyzer.js +8 -6
- package/src/security-checker.js +1 -1
- package/src/unused-detector.js +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Marvin Ackerman
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
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,31 +1,36 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "dependency-detective",
|
|
3
|
-
"version": "0.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": "
|
|
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
|
-
|
|
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
|
-
//
|
|
48
|
+
// Identifing unused dependencies
|
|
48
49
|
spinner.text = 'Scanning for unused dependencies...';
|
|
49
50
|
const unusedDeps = await findUnusedDependencies(options.directory, filteredDependencies);
|
|
50
51
|
|
|
51
|
-
//
|
|
52
|
+
// Checking for security vulnerabilities
|
|
52
53
|
spinner.text = 'Checking for security vulnerabilities...';
|
|
53
54
|
const vulnerabilities = await checkVulnerabilities(filteredDependencies);
|
|
54
55
|
|
|
55
|
-
//
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
package/src/security-checker.js
CHANGED
|
@@ -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 =
|
|
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."
|
package/src/unused-detector.js
CHANGED
|
@@ -24,7 +24,7 @@ export async function findUnusedDependencies(directory, dependencies) {
|
|
|
24
24
|
const version = dependencies[dep];
|
|
25
25
|
let isUsed = false;
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
const importPatterns = [
|
|
29
29
|
new RegExp(`import.*from\\s+['"]${dep}['\"]`),
|
|
30
30
|
new RegExp(`import\\s+['"]${dep}['\"]`),
|