@@ -168,7 +168,7 @@ class LibraryFormatter extends AbstractUi5Formatter {
168
168
namespace = libraryNs . replace ( / \. / g, "/" ) ;
169
169
170
170
const namespacePath = this . getNamespaceFromFsPath ( fsNamespacePath ) ;
171
- if ( namespacePath !== namespace ) {
171
+ if ( false && namespacePath !== namespace ) {
172
172
throw new Error (
173
173
`Detected namespace "${ namespace } " does not match detected directory ` +
174
174
`structure "${ namespacePath } " for project ${ this . _project . metadata . name } ` ) ;
@@ -337,32 +337,61 @@ class LibraryFormatter extends AbstractUi5Formatter {
337
337
if ( this . _pDotLibrary ) {
338
338
return this . _pDotLibrary ;
339
339
}
340
- const basePath = this . getSourceBasePath ( ) ;
341
- return this . _pDotLibrary = glob ( "**/.library" , {
342
- cwd : basePath ,
343
- followSymbolicLinks : false
344
- } ) . then ( async ( dotLibraryResources ) => {
345
- if ( ! dotLibraryResources . length ) {
346
- throw new Error ( `Could not find .library file for project ${ this . _project . metadata . name } ` ) ;
347
- }
348
- if ( dotLibraryResources . length > 1 ) {
349
- throw new Error ( `Found multiple (${ dotLibraryResources . length } ) .library files ` +
350
- `for project ${ this . _project . metadata . name } ` ) ;
351
- }
352
- const fsPath = path . join ( basePath , dotLibraryResources [ 0 ] ) ;
353
- const content = await readFile ( fsPath ) ;
354
- const xml2js = require ( "xml2js" ) ;
355
- const parser = new xml2js . Parser ( {
356
- explicitArray : false ,
357
- ignoreAttrs : true
340
+ if ( this . _project . _zipAdapter ) {
341
+ const basePath = this . getSourceBasePath ( ) ;
342
+ console . log ( "/" + this . _project . resources . pathMappings [ "/resources/" ] + "/**/.library" ) ;
343
+ return this . _pDotLibrary = this . _project . _zipAdapter . byGlob (
344
+ "/" + this . _project . resources . pathMappings [ "/resources/" ] + "/**/.library" )
345
+ . then ( async ( dotLibraryResources ) => {
346
+ if ( ! dotLibraryResources . length ) {
347
+ throw new Error ( `Could not find .library file for project ${ this . _project . metadata . name } ` ) ;
348
+ }
349
+ if ( dotLibraryResources . length > 1 ) {
350
+ throw new Error ( `Found multiple (${ dotLibraryResources . length } ) .library files ` +
351
+ `for project ${ this . _project . metadata . name } ` ) ;
352
+ }
353
+ const fsPath = path . join ( basePath , dotLibraryResources [ 0 ] . getPath ( ) ) ;
354
+ const content = await dotLibraryResources [ 0 ] . getBuffer ( ) ;
355
+ const xml2js = require ( "xml2js" ) ;
356
+ const parser = new xml2js . Parser ( {
357
+ explicitArray : false ,
358
+ ignoreAttrs : true
359
+ } ) ;
360
+ const readXML = promisify ( parser . parseString ) ;
361
+ const contentJson = await readXML ( content ) ;
362
+ return {
363
+ content : contentJson ,
364
+ fsPath
365
+ } ;
366
+ } ) ;
367
+ } else {
368
+ const basePath = this . getSourceBasePath ( ) ;
369
+ return this . _pDotLibrary = glob ( "**/.library" , {
370
+ cwd : basePath ,
371
+ followSymbolicLinks : false
372
+ } ) . then ( async ( dotLibraryResources ) => {
373
+ if ( ! dotLibraryResources . length ) {
374
+ throw new Error ( `Could not find .library file for project ${ this . _project . metadata . name } ` ) ;
375
+ }
376
+ if ( dotLibraryResources . length > 1 ) {
377
+ throw new Error ( `Found multiple (${ dotLibraryResources . length } ) .library files ` +
378
+ `for project ${ this . _project . metadata . name } ` ) ;
379
+ }
380
+ const fsPath = path . join ( basePath , dotLibraryResources [ 0 ] ) ;
381
+ const content = await readFile ( fsPath ) ;
382
+ const xml2js = require ( "xml2js" ) ;
383
+ const parser = new xml2js . Parser ( {
384
+ explicitArray : false ,
385
+ ignoreAttrs : true
386
+ } ) ;
387
+ const readXML = promisify ( parser . parseString ) ;
388
+ const contentJson = await readXML ( content ) ;
389
+ return {
390
+ content : contentJson ,
391
+ fsPath
392
+ } ;
358
393
} ) ;
359
- const readXML = promisify ( parser . parseString ) ;
360
- const contentJson = await readXML ( content ) ;
361
- return {
362
- content : contentJson ,
363
- fsPath
364
- } ;
365
- } ) ;
394
+ }
366
395
}
367
396
368
397
/**
@@ -445,22 +474,22 @@ class LibraryFormatter extends AbstractUi5Formatter {
445
474
446
475
const absoluteSrcPath = path . join ( project . path , project . resources . configuration . paths . src ) ;
447
476
const absoluteTestPath = path . join ( project . path , project . resources . configuration . paths . test ) ;
448
- return Promise . all ( [
449
- this . dirExists ( absoluteSrcPath ) . then ( function ( bExists ) {
450
- if ( ! bExists ) {
451
- throw new Error ( `Could not find source directory of project ${ project . id } : ` +
452
- `${ absoluteSrcPath } ` ) ;
453
- }
454
- } ) ,
455
- this . dirExists ( absoluteTestPath ) . then ( function ( bExists ) {
456
- if ( ! bExists ) {
457
- log . verbose ( `Could not find (optional) test directory of project ${ project . id } : ` +
458
- `${ absoluteTestPath } ` ) ;
459
- // Current signal to following consumers that "test" is not available is null
460
- project . resources . configuration . paths . test = null ;
461
- }
462
- } )
463
- ] ) ;
477
+ // return Promise.all([
478
+ // this.dirExists(absoluteSrcPath).then(function(bExists) {
479
+ // if (!bExists) {
480
+ // throw new Error(`Could not find source directory of project ${project.id}: ` +
481
+ // `${absoluteSrcPath}`);
482
+ // }
483
+ // }),
484
+ // this.dirExists(absoluteTestPath).then(function(bExists) {
485
+ // if (!bExists) {
486
+ // log.verbose(`Could not find (optional) test directory of project ${project.id}: ` +
487
+ // `${absoluteTestPath}`);
488
+ // // Current signal to following consumers that "test" is not available is null
489
+ // project.resources.configuration.paths.test = null;
490
+ // }
491
+ // })
492
+ // ]);
464
493
} ) ;
465
494
}
466
495
}
0 commit comments