@@ -5,6 +5,7 @@ const {promisify} = require("util");
55const readFile = promisify ( fs . readFile ) ;
66const jsyaml = require ( "js-yaml" ) ;
77const typeRepository = require ( "@ui5/builder" ) . types . typeRepository ;
8+ const ZipArchive = require ( "@ui5/fs" ) . adapters . ZipArchive ;
89const { validate} = require ( "./validation/validator" ) ;
910
1011class ProjectPreprocessor {
@@ -391,15 +392,32 @@ class ProjectPreprocessor {
391392 try {
392393 configFile = await readFile ( configPath , { encoding : "utf8" } ) ;
393394 } catch ( err ) {
394- const errorText = "Failed to read configuration for project " +
395- `${ project . id } at "${ configPath } ". Error: ${ err . message } ` ;
396-
397- // Something else than "File or directory does not exist" or root project
398- if ( err . code !== "ENOENT" || project . _isRoot ) {
399- throw new Error ( errorText ) ;
395+ if ( project . path . endsWith ( ".zip" ) ) {
396+ try {
397+ project . _zipAdapter = new ZipArchive ( {
398+ virBasePath : "/" ,
399+ fsArchive : project . path
400+ } ) ;
401+ const resource = await project . _zipAdapter . byPath ( "/ui5.yaml" ) ;
402+ if ( ! resource ) {
403+ throw new Error ( `File not found in ZIP archive: /ui5.yaml` ) ;
404+ }
405+ configFile = await resource . getBuffer ( ) ;
406+ } catch ( err ) {
407+ throw new Error ( `Error file reading from ZIP file at ${ configPath } for project ` +
408+ `${ project . id } : ${ err . message } \n${ err . stack } ` ) ;
409+ }
400410 } else {
401- log . verbose ( errorText ) ;
402- return null ;
411+ const errorText = "Failed to read configuration for project " +
412+ `${ project . id } at "${ configPath } ". Error: ${ err . message } ` ;
413+
414+ // Something else than "File or directory does not exist" or root project
415+ if ( err . code !== "ENOENT" || project . _isRoot ) {
416+ throw new Error ( errorText ) ;
417+ } else {
418+ log . verbose ( errorText ) ;
419+ return null ;
420+ }
403421 }
404422 }
405423
0 commit comments