project/lib/specifications/extensions/ProjectShim.js

  1. import Extension from "../Extension.js";
  2. /**
  3. * ProjectShim
  4. *
  5. * @public
  6. * @class
  7. * @alias @ui5/project/specifications/extensions/ProjectShim
  8. * @extends @ui5/project/specifications/Extension
  9. * @hideconstructor
  10. */
  11. class ProjectShim extends Extension {
  12. constructor(parameters) {
  13. super(parameters);
  14. }
  15. /* === Attributes === */
  16. /**
  17. * @public
  18. */
  19. getDependencyShims() {
  20. return this._config.shims.dependencies || {};
  21. }
  22. /**
  23. * @public
  24. */
  25. getConfigurationShims() {
  26. return this._config.shims.configurations || {};
  27. }
  28. /**
  29. * @public
  30. */
  31. getCollectionShims() {
  32. return this._config.shims.collections || {};
  33. }
  34. /* === Internals === */
  35. /**
  36. * @private
  37. */
  38. async _validateConfig() {
  39. if (this._config.shims.collections) {
  40. const {
  41. default: path
  42. } = await import("path");
  43. for (const dependencyDefinition of Object.values(this._config.shims.collections)) {
  44. Object.values(dependencyDefinition.modules).forEach((depPath) => {
  45. if (path.isAbsolute(depPath)) {
  46. throw new Error("All module paths of collections defined in a project-shim must be relative");
  47. }
  48. });
  49. }
  50. }
  51. }
  52. }
  53. export default ProjectShim;