@@ -71,7 +71,7 @@ export const retrieveSimilarPomPackages = async (parsedPom, springBootVersion) =
7171 if ( declaredPackages . length ) {
7272 console . log ( 'Declared Pom Packages -' , declaredPackages ) ;
7373 }
74- return declaredPackages
74+ return declaredPackages ;
7575 } else {
7676 console . log ( 'Spring Boot default versions URL no longer exists.' ) ;
7777 return [ ] ;
@@ -125,37 +125,33 @@ const replaceVariable = (properties, version) => {
125125 return properties [ variableName ] ;
126126 }
127127 return version ;
128- }
128+ } ;
129129
130130const downloadSpringVersionProperties = async ( springBootVersion ) => {
131131 let url = `https://docs.spring.io/spring-boot/docs/${ springBootVersion } /reference/html/dependency-versions.html` ;
132132 let bodyIndex = 1 ;
133- if ( springBootVersion === '3.3.0' ) {
134- url = 'https://docs.spring.io/spring-boot/appendix/dependency-versions/properties.html' ;
133+ let response = await fetch ( url ) ;
134+ if ( response . status === 404 ) {
135+ url = `https://docs.spring.io/spring-boot/${ springBootVersion } /appendix/dependency-versions/properties.html` ;
135136 bodyIndex = 0 ;
137+ response = await fetch ( url ) ;
136138 }
137- const response = await fetch ( url ) ;
138139 const versions = [ ] ;
139- switch ( response . status ) {
140- // status "OK"
141- case 200 : {
142- const template = await response . text ( ) ;
143- const parsedTemplate = parse ( template ) ;
144- const tableBody = parsedTemplate . getElementsByTagName ( 'tbody' ) [ bodyIndex ] ;
140+ if ( response . ok ) {
141+ const template = await response . text ( ) ;
142+ const parsedTemplate = parse ( template ) ;
143+ const tableBody = parsedTemplate . getElementsByTagName ( 'tbody' ) [ bodyIndex ] ;
145144
146- // older versions of Spring Boot do not have property versions listed
147- if ( tableBody ) {
148- tableBody . childNodes . forEach ( child => // there's a header row we should skip
149- child . childNodes . length === 0 ? '' : versions . push ( {
150- property : child . childNodes [ 3 ] . rawText ,
151- } ) ) ;
152- }
153- await writeFileSync ( `${ cachePath } /properties_${ springBootVersion } .json` , JSON . stringify ( versions , null , 2 ) ) ;
154- break ;
145+ // older versions of Spring Boot do not have property versions listed
146+ if ( tableBody ) {
147+ tableBody . childNodes . forEach ( child => // there's a header row we should skip
148+ child . childNodes . length === 0 ? '' : versions . push ( {
149+ property : child . childNodes [ 3 ] . rawText ,
150+ } ) ) ;
155151 }
156- case 404 :
157- await writeFileSync ( ` ${ cachePath } /properties_ ${ springBootVersion } .json` , JSON . stringify ( versions , null , 2 ) ) ;
158- console . log ( 'URL not found - Spring Boot default versions URL no longer exists.' ) ;
159- break ;
152+ await writeFileSync ( ` ${ cachePath } /properties_ ${ springBootVersion } .json` , JSON . stringify ( versions , null , 2 ) ) ;
153+ } else {
154+ await writeFileSync ( ` ${ cachePath } /properties_ ${ springBootVersion } .json` , JSON . stringify ( versions , null , 2 ) ) ;
155+ console . log ( 'URL not found - Spring Boot default versions URL no longer exists.' ) ;
160156 }
161157} ;
0 commit comments