-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
59 lines (57 loc) · 1.9 KB
/
index.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
import { extname } from 'path';
import {
getPomSpringBootVersion,
getXMLFromFile,
retrieveSimilarPomPackages,
retrieveSimilarPomProperties,
} from './pom.js';
import {
getGradleSpringBootVersion,
getJSFromFile,
retrieveSimilarGradlePackages,
} from './gradle.js';
export const checkDependencies = async () => {
const start = Date.now();
const filename = process.argv[2];
const fileExtension = extname(filename);
// console.log('filename', filename, 'fileExtension', fileExtension);
if (fileExtension === '.xml') {
console.log('Processing xml file');
const parsedPom = await getXMLFromFile(filename);
const springBootVersion = await getPomSpringBootVersion(parsedPom);
if (springBootVersion) {
console.log('Detected Spring Boot Version -', springBootVersion);
const declaredPackages = await retrieveSimilarPomPackages(
parsedPom,
springBootVersion,
);
const declaredProperties = await retrieveSimilarPomProperties(
parsedPom,
springBootVersion,
);
return {
packages: declaredPackages,
properties: declaredProperties,
};
}
} else if (fileExtension === '.gradle') {
console.log('Processing gradle file');
const parsedGradle = await getJSFromFile(filename);
const springBootVersion = await getGradleSpringBootVersion(parsedGradle);
if (springBootVersion) {
console.log('Detected Spring Boot Version -', springBootVersion);
const declaredPackages = await retrieveSimilarGradlePackages(
parsedGradle,
springBootVersion,
);
// await retrieveSimilarPomProperties(parsedPom, springBootVersion);
return { packages: declaredPackages, properties: [] };
}
} else {
console.log('Unknown extension, unable to process file.');
}
console.log(`Process took ${Date.now() - start} ms`);
};
// (async () => {
// await checkDependencies();
// })();