-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
executable file
·64 lines (42 loc) · 1.24 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const treeify = require('treeify');
const {
fetchPackageFiles,
fetchProjectFiles
} = require('./services/scanner');
const {
findDependencies
} = require('./services/matcher');
//Draw map.
const drawMap = (list)=>{
let tree = {};
//Fill props.
list.forEach(l=>{
//Fill items.
let a = {};
if (l.dependencies.length>0)
l.dependencies.forEach(e=>a[e]=null);
else
a['Not found']=null;
//Add parent element.
tree[l.package]= a;
});
console.log(treeify.asTree(tree, true));
}
//Download and parse the projects to scan.
const createMaps = async ()=>{
console.log('> Scanning packages repositories...');
//Create a map with the packages and his versions and names.
const packagesMap = await fetchPackageFiles('21557425');
console.log('> Downloading projects and parsing...');
//Create a map with the project dependencies list.
const projectsMap = await fetchProjectFiles();
console.log(`> Found #${packagesMap.length} packages, #${projectsMap.length} projects...`);
//Create the dependencies list.
const list = findDependencies(packagesMap,projectsMap);
console.log('');
console.log('< Dependencies map >');
console.log('');
//Draw map list.
drawMap(list);
}
createMaps();