MCPcopy Create free account
hub / github.com/SAP/ui5-project / constructor

Method constructor

lib/graph/Module.js:44–87  ·  view source on GitHub ↗

* @param {object} parameters Module parameters * @param {string} parameters.id Unique ID for the module * @param {string} parameters.version Version of the module * @param {string} parameters.modulePath Absolute File System path of the module * @param {string} [parameters.configPath=ui5.yaml

({id, version, modulePath, configPath, configuration = [], shimCollection})

Source from the content-addressed store, hash-verified

42 * Collection of shims that might be relevant for this module
43 */
44 constructor({id, version, modulePath, configPath, configuration = [], shimCollection}) {
45 if (!id) {
46 throw new Error(`Could not create Module: Missing or empty parameter 'id'`);
47 }
48 if (!version) {
49 throw new Error(`Could not create Module: Missing or empty parameter 'version'`);
50 }
51 if (!modulePath) {
52 throw new Error(`Could not create Module: Missing or empty parameter 'modulePath'`);
53 }
54 if (!path.isAbsolute(modulePath)) {
55 throw new Error(`Could not create Module: Parameter 'modulePath' must contain an absolute path`);
56 }
57 if (
58 (
59 (Array.isArray(configuration) && configuration.length > 0) ||
60 (!Array.isArray(configuration) && typeof configuration === "object")
61 ) && configPath
62 ) {
63 throw new Error(
64 `Could not create Module: 'configPath' must not be provided in combination with 'configuration'`
65 );
66 }
67
68 this._id = id;
69 this._version = version;
70 this._modulePath = modulePath;
71 this._configPath = configPath || DEFAULT_CONFIG_PATH;
72 this._dependencies = Object.create(null);
73
74 if (!Array.isArray(configuration)) {
75 configuration = [configuration];
76 }
77 this._suppliedConfigs = configuration;
78
79 if (shimCollection) {
80 // Retrieve and clone shims in constructor
81 // Shims added to the collection at a later point in time should not be applied in this module
82 const shims = shimCollection.getProjectConfigurationShims(this.getId());
83 if (shims && shims.length) {
84 this._projectConfigShims = clone(shims);
85 }
86 }
87 }
88
89 getId() {
90 return this._id;

Callers

nothing calls this directly

Calls 4

getIdMethod · 0.95
createMethod · 0.80
cloneFunction · 0.70

Tested by

no test coverage detected