From 3bd26b1ca9810e8da2ecfb0d4e10ccbd835fe516 Mon Sep 17 00:00:00 2001 From: Matt Busche Date: Fri, 24 May 2024 22:15:39 -0500 Subject: [PATCH] handle new spring boot docs site --- package-lock.json | 19 ++++++++++--------- package.json | 2 +- pom.js | 22 ++++++++++++++-------- shared.js | 18 +++++++++++------- 4 files changed, 36 insertions(+), 25 deletions(-) diff --git a/package-lock.json b/package-lock.json index 57d87fe..44c6c94 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "spring-boot-dependency-checker", - "version": "0.2.3", + "version": "0.2.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "spring-boot-dependency-checker", - "version": "0.2.3", + "version": "0.2.4", "license": "\tGPL-3.0-or-later", "dependencies": { "fast-xml-parser": "^4.3.6", @@ -115,13 +115,13 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, "license": "MIT", "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -433,9 +433,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, "license": "MIT", "dependencies": { @@ -572,6 +572,7 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", "dev": true, "license": "ISC", "dependencies": { diff --git a/package.json b/package.json index 2c54d6b..f39c959 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pom.js b/pom.js index 9fb9135..0330994 100644 --- a/pom.js +++ b/pom.js @@ -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.'); } @@ -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) { @@ -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; } diff --git a/shared.js b/shared.js index ab44ebb..9bab764 100644 --- a/shared.js +++ b/shared.js @@ -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.'); } @@ -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" @@ -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; }