builder/lib/tasks/enhanceManifest.js

  1. import manifestEnhancer from "../processors/manifestEnhancer.js";
  2. import fsInterface from "@ui5/fs/fsInterface";
  3. /* eslint "jsdoc/check-param-names": ["error", {"disableExtraPropertyReporting":true}] */
  4. /**
  5. * Task for transforming the manifest.json file.
  6. * Adds missing information based on the available project resources,
  7. * for example the locales supported by the present i18n resources.
  8. *
  9. * @public
  10. * @function default
  11. * @static
  12. *
  13. * @param {object} parameters Parameters
  14. * @param {@ui5/fs/DuplexCollection} parameters.workspace DuplexCollection to read and write files
  15. * @param {object} parameters.options Options
  16. * @param {string} parameters.options.projectNamespace Namespace of the application
  17. * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
  18. */
  19. export default async function({workspace, options}) {
  20. const {projectNamespace} = options;
  21. // Note: all "manifest.json" files in the given namespace
  22. const resources = await workspace.byGlob(`/resources/${projectNamespace}/**/manifest.json`);
  23. const processedResources = await manifestEnhancer({
  24. resources,
  25. fs: fsInterface(workspace),
  26. });
  27. await Promise.all(processedResources.map((resource) => workspace.write(resource)));
  28. }