@@ -98,8 +98,8 @@ export const getPomSpringBootVersion = async (parsedPom) => {
9898 }
9999 }
100100 if (
101- parsedPom . project ?. dependencyManagement ?. [ 0 ] ?. dependencies . dependency . groupId === 'org.springframework.boot' &&
102- parsedPom . project ?. dependencyManagement ?. [ 0 ] ?. dependencies . dependency . artifactId === 'spring-boot-dependencies'
101+ parsedPom . project ?. dependencyManagement ?. [ 0 ] ?. dependencies ? .dependency ? .groupId === 'org.springframework.boot' &&
102+ parsedPom . project ?. dependencyManagement ?. [ 0 ] ?. dependencies ? .dependency ? .artifactId === 'spring-boot-dependencies'
103103 ) {
104104 return replaceVariable ( parsedPom . project . properties , parsedPom . project . dependencyManagement [ 0 ] . dependencies . dependency . version ) ;
105105 }
@@ -120,19 +120,20 @@ export const retrieveSimilarPomPackages = async (parsedPom, springBootVersion) =
120120
121121 if ( defaultVersions . length ) {
122122 const declaredPackages = [ ] ;
123- pomDependenciesWithVersions . forEach ( ( pomDependency ) =>
124- defaultVersions . forEach ( ( bootPackage ) => {
123+ for ( const pomDependency of pomDependenciesWithVersions ) {
124+ for ( const bootPackage of defaultVersions ) {
125125 if ( pomDependency . groupId === bootPackage . group && pomDependency . artifactId === bootPackage . name ) {
126126 const pomVersion = replaceVariable ( parsedPom . project . properties , pomDependency . version ) ;
127127 const existingMatches = declaredPackages . find (
128128 ( declaredPackage ) => declaredPackage . group === pomDependency . groupId && declaredPackage . name === pomDependency . artifactId ,
129129 ) ;
130130 if ( ! existingMatches ) {
131131 declaredPackages . push ( new Package ( pomDependency . groupId , pomDependency . artifactId , pomVersion , bootPackage . version ) ) ;
132+ break ;
132133 }
133134 }
134- } ) ,
135- ) ;
135+ }
136+ }
136137
137138 console . log ( 'Declared Pom Package Count -' , declaredPackages . length ) ;
138139 if ( declaredPackages . length ) {
@@ -154,13 +155,14 @@ export const retrieveSimilarPomProperties = async (parsedPom, springBootVersion)
154155
155156 if ( defaultProperties . length ) {
156157 const declaredProperties = [ ] ;
157- pomProperties . forEach ( ( pomProperty ) =>
158- defaultProperties . forEach ( ( defaultProperty ) => {
158+ for ( const pomProperty of pomProperties ) {
159+ for ( const defaultProperty of defaultProperties ) {
159160 if ( pomProperty === defaultProperty . property ) {
160161 declaredProperties . push ( pomProperty ) ;
162+ break ;
161163 }
162- } ) ,
163- ) ;
164+ }
165+ }
164166
165167 console . log ( 'Declared Pom Properties Count -' , declaredProperties . length ) ;
166168 if ( declaredProperties . length ) {
@@ -190,8 +192,14 @@ const getSpringDefaultProperties = async (springBootVersion) => {
190192
191193const replaceVariable = ( properties , version ) => {
192194 if ( String ( version ) . startsWith ( '${' ) ) {
195+ const flatProperties = { } ;
196+ properties . forEach ( ( property ) => {
197+ for ( const [ key , value ] of Object . entries ( property ) ) {
198+ flatProperties [ key ] = value ;
199+ }
200+ } ) ;
193201 const variableName = version . replace ( '${' , '' ) . replace ( '}' , '' ) ;
194- return properties [ 0 ] [ variableName ] ;
202+ return flatProperties [ variableName ] ;
195203 }
196204 return version ;
197205} ;
0 commit comments