@@ -20,7 +20,7 @@ function getTimestamp() {
20
20
/**
21
21
*
22
22
* @param {module:@ui5/fs.Resource } manifestResource
23
- * @returns {Promise<ManifestInfos > }
23
+ * @returns {Promise<ManifestInfo > }
24
24
*/
25
25
const processManifest = async ( manifestResource ) => {
26
26
const manifestContent = await manifestResource . getString ( ) ;
@@ -58,7 +58,7 @@ const processManifest = async (manifestResource) => {
58
58
/**
59
59
* Library Info
60
60
*
61
- * @typedef {object<string, object> } DependencyInfos
61
+ * @typedef {object<string, object> } ManifestLibs
62
62
*
63
63
* * @example
64
64
* {
@@ -72,8 +72,8 @@ const processManifest = async (manifestResource) => {
72
72
/**
73
73
* Manifest Hint
74
74
*
75
- * @typedef {object } ManifestInfos
76
- * @property {DependencyInfos } libs The library object
75
+ * @typedef {object } ManifestInfo
76
+ * @property {ManifestLibs } libs The library object
77
77
* @property {string[] } embeds embedded components, e.g. "sub/fold" (only relative path)
78
78
* @property {string } id the app id, e.g. "lib.a"
79
79
*
@@ -94,12 +94,14 @@ const processManifest = async (manifestResource) => {
94
94
95
95
96
96
/**
97
- * Library Info object
97
+ * Library Info
98
+ *
99
+ * contains information about the name the version of the library and its manifest, as well as the nested manifests.
98
100
*
99
101
* @typedef {object } LibraryInfo
100
102
* @property {string } name The library name
101
103
* @property {string } version The library version
102
- * @property {module:@ui5/fs.Resource } mainManifest main manifest resources
104
+ * @property {module:@ui5/fs.Resource } libraryManifest main manifest resources
103
105
* @property {module:@ui5/fs.Resource[] } manifestResources list of corresponding manifest resources
104
106
*/
105
107
@@ -112,23 +114,24 @@ const getManifestPath = (filePath, subPath) => {
112
114
} ;
113
115
114
116
/**
117
+ * Resolves the dependencies recursively
115
118
*
116
- * @param {Map<string, DependencyInfos > } libraryInfosMap
119
+ * @param {Map<string, DependencyInfo > } dependencyInfoMap
117
120
*/
118
- const resolveTransitiveDependencies = ( libraryInfosMap ) => {
119
- const keys = [ ...libraryInfosMap . keys ( ) ] ;
121
+ const resolveTransitiveDependencies = ( dependencyInfoMap ) => {
122
+ const keys = [ ...dependencyInfoMap . keys ( ) ] ;
120
123
keys . sort ( ) ;
121
124
keys . forEach ( ( libName ) => { // e.g. sap.ui.documentation
122
- const libraryInfo = libraryInfosMap . get ( libName ) ;
123
- libraryInfo . resolve ( libraryInfosMap ) ;
125
+ const libraryInfo = dependencyInfoMap . get ( libName ) ;
126
+ libraryInfo . resolve ( dependencyInfoMap ) ;
124
127
} ) ;
125
128
} ;
126
129
127
130
class DependencyInfoObject {
128
131
/**
129
132
*
130
133
* @param {string } name name of the dependency, e.g. sap.ui.documentation
131
- * @param {boolean } lazy
134
+ * @param {boolean } lazy lazy dependency
132
135
*/
133
136
constructor ( name , lazy ) {
134
137
this . name = name ;
@@ -146,11 +149,6 @@ class DependencyInfo {
146
149
this . libs = libs ;
147
150
this . name = name ;
148
151
149
- /**
150
- *
151
- * @type {string[] }
152
- */
153
- this . resolved = [ ] ;
154
152
/**
155
153
*
156
154
* @type {DependencyInfoObject[] }
@@ -190,7 +188,8 @@ class DependencyInfo {
190
188
/**
191
189
*
192
190
* @param {Map<string,DependencyInfo> } dependencyInfoMap
193
- * @param {boolean } [lazy]
191
+ * @param {boolean } [lazy] whether or not the dependency is lazy dependency which means
192
+ * all its dependencies should be treated as lazy
194
193
*/
195
194
resolve ( dependencyInfoMap , lazy ) {
196
195
if ( ! this . wasResolved || lazy ) {
@@ -238,7 +237,6 @@ const sortObjectKeys = (obj) => {
238
237
*/
239
238
const addManifestHints = ( result , dependencyInfo ) => {
240
239
if ( dependencyInfo && dependencyInfo . libs . length ) {
241
- // const sortedLibs = sortObjectKeys(libs.libs);
242
240
const libsObject = { } ;
243
241
dependencyInfo . libsResolved . forEach ( ( sortedLib ) => {
244
242
libsObject [ sortedLib . name ] = { } ;
@@ -261,19 +259,27 @@ const convertToDependencyInfoObjects = (libs) => {
261
259
} ) ;
262
260
} ;
263
261
262
+ /**
263
+ * Processes the library info and fills the maps <code>dependencyInfoMap</code> and <code>embeddedInfoMap</code>.
264
+ *
265
+ * @param {LibraryInfo } libraryInfo
266
+ * @param {Map<string, DependencyInfo> } dependencyInfoMap
267
+ * @param {Map<string, object> } embeddedInfoMap
268
+ * @returns {Promise<void> }
269
+ */
264
270
const processLibraryInfo = async ( libraryInfo , dependencyInfoMap , embeddedInfoMap ) => {
265
- if ( ! libraryInfo . mainManifest ) {
271
+ if ( ! libraryInfo . libraryManifest ) {
266
272
log . error ( `library manifest not found for ${ libraryInfo . name } ` ) ;
267
273
return ;
268
274
}
269
- const manifestInfo = await processManifest ( libraryInfo . mainManifest ) ;
275
+ const manifestInfo = await processManifest ( libraryInfo . libraryManifest ) ;
270
276
// gather shallow library information
271
277
const dependencyInfoObjects = convertToDependencyInfoObjects ( manifestInfo . libs ) ;
272
278
dependencyInfoMap . set ( libraryInfo . name , new DependencyInfo ( dependencyInfoObjects , libraryInfo . name ) ) ;
273
279
const embeds = manifestInfo . embeds ; // sdk
274
280
// filter
275
281
const embeddedPaths = embeds . map ( ( embed ) => {
276
- return getManifestPath ( libraryInfo . mainManifest . getPath ( ) , embed ) ;
282
+ return getManifestPath ( libraryInfo . libraryManifest . getPath ( ) , embed ) ;
277
283
} ) ;
278
284
// sap.ui.documentation.sdk
279
285
const relevantManifests = libraryInfo . manifestResources . filter ( ( manifestResource ) => {
@@ -307,7 +313,7 @@ const processLibraryInfo = async (libraryInfo, dependencyInfoMap, embeddedInfoMa
307
313
* {
308
314
* name: "library.xy",
309
315
* version: "1.0.0",
310
- * mainManifest : module:@ui 5/fs.Resource,
316
+ * libraryManifest : module:@ui 5/fs.Resource,
311
317
* manifestResources: module:@ui5/fs.Resource[]
312
318
* }
313
319
* </code>
@@ -336,6 +342,15 @@ module.exports = async function({options}) {
336
342
* @type {Map<string, DependencyInfo> }
337
343
*/
338
344
const dependencyInfoMap = new Map ( ) ;
345
+ /**
346
+ * @example
347
+ * {
348
+ * "sap.ui.integration.sdk": {
349
+ * "library": "sap.ui.integration"
350
+ * }
351
+ *
352
+ * @type {Map<string, object> }
353
+ */
339
354
const embeddedInfoMap = new Map ( ) ;
340
355
341
356
// gather all manifestHints
@@ -362,7 +377,6 @@ module.exports = async function({options}) {
362
377
return result ;
363
378
} ) ;
364
379
365
- // sort keys
366
380
embeddedInfoMap . forEach ( ( embeddedInfo , libName ) => {
367
381
components [ libName ] = embeddedInfo ;
368
382
const libs = dependencyInfoMap . get ( libName ) ;
0 commit comments