@@ -27,7 +27,8 @@ const processManifest = async (manifestResource) => {
2727 const manifestDependencies = manifestObject [ "sap.ui5" ] [ "dependencies" ] ;
2828 const result = {
2929 embeds : [ ] ,
30- libs : { }
30+ libs : { } ,
31+ id : undefined
3132 } ;
3233 if ( manifestDependencies ) {
3334 Object . keys ( manifestDependencies . libs ) . forEach ( ( libKey ) => {
@@ -91,19 +92,6 @@ const getManifestPath = (filePath, subPath) => {
9192 * @param {Map<string, DependencyInfos> } manifestHints
9293 */
9394const resolveTransitiveDependencies = ( manifestHints ) => {
94- // top level libraries
95- // // lib.a => lib.c, lib.b
96- // // lib.b => lib.d
97- // // lib.c => lib.e, lib.b (true)
98- // // lib.d => lib.e (true)
99- // // lib.e =>
100- // TODO optimize duplicate resolve (e.g. cache)
101-
102- // lib.c => lib.e, lib.b (true), lib.d
103- // lib.a => lib.c, lib.b, lib.d, lib.e
104- // lib.b => lib.d, lib.e (true)
105- // lib.d => lib.e (true)
106- // lib.e =>
10795 const keys = [ ...manifestHints . keys ( ) ] ;
10896 keys . sort ( ) ;
10997 const resolvedCache = new Map ( ) ;
@@ -125,7 +113,6 @@ const clone = (obj) => {
125113const setManifestHints = ( manifestHints , libName , newObject ) => {
126114 const existingEntry = manifestHints . get ( libName ) ;
127115 const newLibs = merge ( existingEntry && existingEntry , newObject ) ;
128- console . log ( ` setting ${ libName } ==> ${ Object . keys ( newLibs ) . join ( ", " ) } ` ) ;
129116 manifestHints . set ( libName , newLibs ) ;
130117} ;
131118
@@ -152,20 +139,22 @@ const merge = (existingEntry, newObject) => {
152139 * @returns {DependencyInfos } resolved dependencies
153140 */
154141const resolve = ( libName , manifestHints , resolvedCache ) => {
155- // lib.c get entries
156- // lib.c => lib.b (true)
157- // lib.b =>
142+ // check cache first
158143 if ( resolvedCache . has ( libName ) ) {
159144 return resolvedCache . get ( libName ) ;
160145 }
161146 const manifestHint = manifestHints . get ( libName ) ; // lib.c
162- console . log ( `:processing: ${ libName } ` ) ;
163- const keys = Object . keys ( manifestHint ) ; // [lib.b]
147+ // console.log(`:processing: ${libName}`);
164148 let resolved = { } ;
149+ if ( ! manifestHint ) {
150+ console . error ( `no manifest information in dependencies for ${ libName } ` ) ;
151+ resolvedCache . set ( libName , resolved ) ;
152+ return resolved ;
153+ }
154+ const keys = Object . keys ( manifestHint ) ; // [lib.b]
165155 keys . forEach ( ( childLibName ) => {
166156 const childResolved = resolve ( childLibName , manifestHints , resolvedCache ) ;
167157 resolved = merge ( resolved , childResolved ) ;
168- console . log ( `resolved ${ childLibName } with ${ Object . keys ( resolved ) . join ( ", " ) } ` ) ;
169158 } ) ;
170159 resolved = merge ( resolved , manifestHint ) ;
171160 setManifestHints ( manifestHints , libName , resolved ) ;
@@ -174,16 +163,6 @@ const resolve = (libName, manifestHints, resolvedCache) => {
174163} ;
175164
176165
177- const out = ( libs ) => {
178- const res = Object . keys ( libs ) . map ( ( libName ) => {
179- if ( libs [ libName ] . lazy ) {
180- return libName + " (" + libs [ libName ] . lazy + ")" ;
181- }
182- return libName ;
183- } ) ;
184- return res ;
185- } ;
186-
187166/**
188167 * Creates sap-ui-version.json.
189168 *
@@ -204,7 +183,6 @@ module.exports = async function({options}) {
204183 }
205184
206185 const buildTimestamp = getTimestamp ( ) ;
207- // TODO filter manifest.json if sap/embeds (we expect it contains the correct information)
208186
209187 const components = { } ;
210188 /**
@@ -229,11 +207,6 @@ module.exports = async function({options}) {
229207 return manifestHint . embeds ;
230208 } ) . then ( ( embeds ) => {
231209 // filter
232- embeds . forEach ( ( embed ) => {
233- embeddedInfoMap . set ( embed , {
234- library : libraryInfo . name
235- } ) ;
236- } ) ;
237210 const embeddedPaths = embeds . map ( ( embed ) => {
238211 return getManifestPath ( libraryInfo . mainManifest . getPath ( ) , embed ) ;
239212 } ) ;
@@ -245,6 +218,9 @@ module.exports = async function({options}) {
245218 return Promise . all ( relevantManifests . map ( ( relevantManifest ) => {
246219 return processManifest ( relevantManifest ) . then ( ( result ) => {
247220 dependencyInfoMap . set ( result . id , result . libs ) ;
221+ embeddedInfoMap . set ( result . id , {
222+ library : libraryInfo . name
223+ } ) ;
248224 } ) ;
249225 } ) ) ;
250226 } ) ;
@@ -254,19 +230,9 @@ module.exports = async function({options}) {
254230
255231 await Promise . all ( librariesPromises ) ;
256232
257- console . log ( "before:" ) ;
258- dependencyInfoMap . forEach ( ( manifestHint , key ) => {
259- console . log ( `${ key } => ${ out ( manifestHint ) . join ( ", " ) } ` ) ;
260- } ) ;
261-
262233 // resolve nested dependencies (transitive)
263234 resolveTransitiveDependencies ( dependencyInfoMap ) ;
264235
265- console . log ( "\nafter:" ) ;
266- dependencyInfoMap . forEach ( ( manifestHint , key ) => {
267- console . log ( `${ key } => ${ out ( manifestHint ) . join ( ", " ) } ` ) ;
268- } ) ;
269-
270236
271237 const libraries = options . libraryInfos . map ( ( libraryInfo ) => {
272238 const result = {
@@ -277,7 +243,6 @@ module.exports = async function({options}) {
277243 } ;
278244
279245 const libs = dependencyInfoMap . get ( libraryInfo . name ) ;
280- // TODO: sort the libs
281246 if ( Object . keys ( libs ) . length ) {
282247 result . manifestHints = {
283248 dependencies : {
@@ -290,9 +255,7 @@ module.exports = async function({options}) {
290255
291256 // TODO sort!
292257 embeddedInfoMap . forEach ( ( embeddedInfo , libName ) => {
293- components [ libName ] = {
294- library : embeddedInfo . library
295- } ;
258+ components [ libName ] = embeddedInfo ;
296259 const libs = dependencyInfoMap . get ( libName ) ;
297260 if ( libs && Object . keys ( libs ) . length ) {
298261 components [ libName ] . manifestHints = {
@@ -303,14 +266,11 @@ module.exports = async function({options}) {
303266 }
304267 } ) ;
305268
306- // sort alphabetically
269+ // sort libraries alphabetically
307270 libraries . sort ( ( a , b ) => {
308271 return a . name . localeCompare ( b . name ) ;
309272 } ) ;
310273
311-
312- // TODO enrich components
313-
314274 const versionJson = {
315275 name : options . rootProjectName ,
316276 version : options . rootProjectVersion , // TODO: insert current application version here
0 commit comments