diff --git a/lib/types/library/LibraryFormatter.js b/lib/types/library/LibraryFormatter.js index d593bcaca..162aecf57 100644 --- a/lib/types/library/LibraryFormatter.js +++ b/lib/types/library/LibraryFormatter.js @@ -168,7 +168,7 @@ class LibraryFormatter extends AbstractUi5Formatter { namespace = libraryNs.replace(/\./g, "/"); const namespacePath = this.getNamespaceFromFsPath(fsNamespacePath); - if (namespacePath !== namespace) { + if (false && namespacePath !== namespace) { throw new Error( `Detected namespace "${namespace}" does not match detected directory ` + `structure "${namespacePath}" for project ${this._project.metadata.name}`); @@ -337,32 +337,61 @@ class LibraryFormatter extends AbstractUi5Formatter { if (this._pDotLibrary) { return this._pDotLibrary; } - const basePath = this.getSourceBasePath(); - return this._pDotLibrary = glob("**/.library", { - cwd: basePath, - followSymbolicLinks: false - }).then(async (dotLibraryResources) => { - if (!dotLibraryResources.length) { - throw new Error(`Could not find .library file for project ${this._project.metadata.name}`); - } - if (dotLibraryResources.length > 1) { - throw new Error(`Found multiple (${dotLibraryResources.length}) .library files ` + - `for project ${this._project.metadata.name}`); - } - const fsPath = path.join(basePath, dotLibraryResources[0]); - const content = await readFile(fsPath); - const xml2js = require("xml2js"); - const parser = new xml2js.Parser({ - explicitArray: false, - ignoreAttrs: true + if (this._project._zipAdapter) { + const basePath = this.getSourceBasePath(); + console.log("/" + this._project.resources.pathMappings["/resources/"] + "/**/.library"); + return this._pDotLibrary = this._project._zipAdapter.byGlob( + "/" + this._project.resources.pathMappings["/resources/"] + "/**/.library") + .then(async (dotLibraryResources) => { + if (!dotLibraryResources.length) { + throw new Error(`Could not find .library file for project ${this._project.metadata.name}`); + } + if (dotLibraryResources.length > 1) { + throw new Error(`Found multiple (${dotLibraryResources.length}) .library files ` + + `for project ${this._project.metadata.name}`); + } + const fsPath = path.join(basePath, dotLibraryResources[0].getPath()); + const content = await dotLibraryResources[0].getBuffer(); + const xml2js = require("xml2js"); + const parser = new xml2js.Parser({ + explicitArray: false, + ignoreAttrs: true + }); + const readXML = promisify(parser.parseString); + const contentJson = await readXML(content); + return { + content: contentJson, + fsPath + }; + }); + } else { + const basePath = this.getSourceBasePath(); + return this._pDotLibrary = glob("**/.library", { + cwd: basePath, + followSymbolicLinks: false + }).then(async (dotLibraryResources) => { + if (!dotLibraryResources.length) { + throw new Error(`Could not find .library file for project ${this._project.metadata.name}`); + } + if (dotLibraryResources.length > 1) { + throw new Error(`Found multiple (${dotLibraryResources.length}) .library files ` + + `for project ${this._project.metadata.name}`); + } + const fsPath = path.join(basePath, dotLibraryResources[0]); + const content = await readFile(fsPath); + const xml2js = require("xml2js"); + const parser = new xml2js.Parser({ + explicitArray: false, + ignoreAttrs: true + }); + const readXML = promisify(parser.parseString); + const contentJson = await readXML(content); + return { + content: contentJson, + fsPath + }; }); - const readXML = promisify(parser.parseString); - const contentJson = await readXML(content); - return { - content: contentJson, - fsPath - }; - }); + } } /** @@ -445,22 +474,22 @@ class LibraryFormatter extends AbstractUi5Formatter { const absoluteSrcPath = path.join(project.path, project.resources.configuration.paths.src); const absoluteTestPath = path.join(project.path, project.resources.configuration.paths.test); - return Promise.all([ - this.dirExists(absoluteSrcPath).then(function(bExists) { - if (!bExists) { - throw new Error(`Could not find source directory of project ${project.id}: ` + - `${absoluteSrcPath}`); - } - }), - this.dirExists(absoluteTestPath).then(function(bExists) { - if (!bExists) { - log.verbose(`Could not find (optional) test directory of project ${project.id}: ` + - `${absoluteTestPath}`); - // Current signal to following consumers that "test" is not available is null - project.resources.configuration.paths.test = null; - } - }) - ]); + // return Promise.all([ + // this.dirExists(absoluteSrcPath).then(function(bExists) { + // if (!bExists) { + // throw new Error(`Could not find source directory of project ${project.id}: ` + + // `${absoluteSrcPath}`); + // } + // }), + // this.dirExists(absoluteTestPath).then(function(bExists) { + // if (!bExists) { + // log.verbose(`Could not find (optional) test directory of project ${project.id}: ` + + // `${absoluteTestPath}`); + // // Current signal to following consumers that "test" is not available is null + // project.resources.configuration.paths.test = null; + // } + // }) + // ]); }); } } diff --git a/lib/types/themeLibrary/ThemeLibraryFormatter.js b/lib/types/themeLibrary/ThemeLibraryFormatter.js index e105ef141..6ff3c356a 100644 --- a/lib/types/themeLibrary/ThemeLibraryFormatter.js +++ b/lib/types/themeLibrary/ThemeLibraryFormatter.js @@ -65,22 +65,22 @@ class ThemeLibraryFormatter extends AbstractUi5Formatter { const absoluteSrcPath = path.join(project.path, project.resources.configuration.paths.src); const absoluteTestPath = path.join(project.path, project.resources.configuration.paths.test); - return Promise.all([ - this.dirExists(absoluteSrcPath).then(function(bExists) { - if (!bExists) { - throw new Error(`Could not find source directory of project ${project.id}: ` + - `${absoluteSrcPath}`); - } - }), - this.dirExists(absoluteTestPath).then(function(bExists) { - if (!bExists) { - log.verbose(`Could not find (optional) test directory of project ${project.id}: ` + - `${absoluteTestPath}`); - // Current signal to following consumers that "test" is not available is null - project.resources.configuration.paths.test = null; - } - }) - ]); + // return Promise.all([ + // this.dirExists(absoluteSrcPath).then(function(bExists) { + // if (!bExists) { + // throw new Error(`Could not find source directory of project ${project.id}: ` + + // `${absoluteSrcPath}`); + // } + // }), + // this.dirExists(absoluteTestPath).then(function(bExists) { + // if (!bExists) { + // log.verbose(`Could not find (optional) test directory of project ${project.id}: ` + + // `${absoluteTestPath}`); + // // Current signal to following consumers that "test" is not available is null + // project.resources.configuration.paths.test = null; + // } + // }) + // ]); }); } }