Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spring-boot-dependency-checker",
"version": "0.2.3",
"version": "0.2.4",
"description": "Spring Boot Dependency Checker - validate that you're using the versions Spring Boot has approved with your project.",
"keywords": [
"spring boot",
Expand Down
22 changes: 14 additions & 8 deletions pom.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ export const retrieveSimilarPomProperties = async (parsedPom, springBootVersion)
return [];
};

const getSpringDefaultProperties = async (sbVersion) => {
const getSpringDefaultProperties = async (springBootVersion) => {
try {
await ensureDirExists();
if (!existsSync(`${cachePath}/properties_${sbVersion}.json`)) {
await downloadSpringVersionProperties(sbVersion);
if (!existsSync(`${cachePath}/properties_${springBootVersion}.json`)) {
await downloadSpringVersionProperties(springBootVersion);
// } else {
// console.log('Spring Boot default properties file already exists in cache.');
}
Expand All @@ -127,15 +127,21 @@ const replaceVariable = (properties, version) => {
return version;
}

const downloadSpringVersionProperties = async (sbVersion) => {
const response = await fetch(`https://docs.spring.io/spring-boot/docs/${sbVersion}/reference/html/dependency-versions.html`);
const downloadSpringVersionProperties = async (springBootVersion) => {
let url = `https://docs.spring.io/spring-boot/docs/${springBootVersion}/reference/html/dependency-versions.html`;
let bodyIndex = 1;
if (springBootVersion === '3.3.0') {
url = 'https://docs.spring.io/spring-boot/appendix/dependency-versions/properties.html';
bodyIndex = 0;
}
const response = await fetch(url);
const versions = [];
switch (response.status) {
// status "OK"
case 200: {
const template = await response.text();
const parsedTemplate = parse(template);
const tableBody = parsedTemplate.getElementsByTagName('tbody')[1];
const tableBody = parsedTemplate.getElementsByTagName('tbody')[bodyIndex];

// older versions of Spring Boot do not have property versions listed
if (tableBody) {
Expand All @@ -144,11 +150,11 @@ const downloadSpringVersionProperties = async (sbVersion) => {
property: child.childNodes[3].rawText,
}));
}
await writeFileSync(`${cachePath}/properties_${sbVersion}.json`, JSON.stringify(versions, null, 2));
await writeFileSync(`${cachePath}/properties_${springBootVersion}.json`, JSON.stringify(versions, null, 2));
break;
}
case 404:
await writeFileSync(`${cachePath}/properties_${sbVersion}.json`, JSON.stringify(versions, null, 2));
await writeFileSync(`${cachePath}/properties_${springBootVersion}.json`, JSON.stringify(versions, null, 2));
console.log('URL not found - Spring Boot default versions URL no longer exists.');
break;
}
Expand Down
18 changes: 11 additions & 7 deletions shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ export const getJsonFromFile = async (filename) => {
}
};

const getSpringDefaultVersions = async (sbVersion) => {
const getSpringDefaultVersions = async (springBootVersion) => {
try {
await ensureDirExists();
if (!existsSync(`${cachePath}/dependencies_${sbVersion}.json`)) {
await downloadSpringDefaultVersions(sbVersion);
if (!existsSync(`${cachePath}/dependencies_${springBootVersion}.json`)) {
await downloadSpringDefaultVersions(springBootVersion);
// } else {
// console.log('Spring Boot default versions file already exists in cache.');
}
Expand All @@ -31,8 +31,12 @@ const getSpringDefaultVersions = async (sbVersion) => {
}
};

const downloadSpringDefaultVersions = async (sbVersion) => {
const response = await fetch(`https://docs.spring.io/spring-boot/docs/${sbVersion}/reference/html/dependency-versions.html`);
const downloadSpringDefaultVersions = async (springBootVersion) => {
let url = `https://docs.spring.io/spring-boot/docs/${springBootVersion}/reference/html/dependency-versions.html`;
if (springBootVersion === '3.3.0') {
url = 'https://docs.spring.io/spring-boot/appendix/dependency-versions/coordinates.html';
}
const response = await fetch(url);
const versions = [];
switch (response.status) {
// status "OK"
Expand All @@ -47,11 +51,11 @@ const downloadSpringDefaultVersions = async (sbVersion) => {
name: child.childNodes[3].rawText,
version: child.childNodes[5].rawText,
}));
await writeFileSync(`${cachePath}/dependencies_${sbVersion}.json`, JSON.stringify(versions, null, 2));
await writeFileSync(`${cachePath}/dependencies_${springBootVersion}.json`, JSON.stringify(versions, null, 2));
break;
}
case 404:
await writeFileSync(`${cachePath}/dependencies_${sbVersion}.json`, JSON.stringify(versions, null, 2));
await writeFileSync(`${cachePath}/dependencies_${springBootVersion}.json`, JSON.stringify(versions, null, 2));
console.log('URL not found - Spring Boot default versions URL no longer exists.');
break;
}
Expand Down