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

Method _resolveModules

lib/graph/Workspace.js:130–175  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

128 }
129
130 async _resolveModules() {
131 await this._validateConfig();
132 const resolutions = this.#configuration.dependencyManagement?.resolutions;
133 if (!resolutions?.length) {
134 return {
135 projectNameMap: new Map(),
136 moduleIdMap: new Map()
137 };
138 }
139
140 let resolvedModules = await Promise.all(resolutions.map(async (resolutionConfig) => {
141 if (!resolutionConfig.path) {
142 throw new Error(
143 `Missing property 'path' in dependency resolution configuration of workspace ${this.getName()}`);
144 }
145 return await this._getModulesFromPath(
146 this.#cwd, resolutionConfig.path);
147 }));
148
149 // Flatten array since package-workspaces might have resolved to multiple modules for a single resolution
150 resolvedModules = Array.prototype.concat.apply([], resolvedModules);
151
152 const projectNameMap = new Map();
153 const moduleIdMap = new Map();
154 await Promise.all(resolvedModules.map(async (module) => {
155 const {project, extensions} = await module.getSpecifications();
156 if (project || extensions.length) {
157 moduleIdMap.set(module.getId(), module);
158 } else {
159 log.warn(
160 `Failed to create a project or extensions from module ${module.getId()} at ${module.getPath()}`);
161 }
162 if (project) {
163 projectNameMap.set(project.getName(), module);
164 log.verbose(`Module ${module.getId()} contains project ${project.getName()}`);
165 }
166 if (extensions.length) {
167 const extensionNames = extensions.map((e) => e.getName()).join(", ");
168 log.verbose(`Module ${module.getId()} contains extensions: ${extensionNames}`);
169 }
170 }));
171 return {
172 projectNameMap,
173 moduleIdMap
174 };
175 }
176
177 async _getModulesFromPath(cwd, relPath, failOnMissingFiles = true) {
178 const nodePath = path.join(cwd, relPath);

Callers 1

_getResolvedModulesMethod · 0.95

Calls 7

_validateConfigMethod · 0.95
getNameMethod · 0.95
_getModulesFromPathMethod · 0.95
getSpecificationsMethod · 0.80
getPathMethod · 0.80
joinMethod · 0.80
getIdMethod · 0.45

Tested by

no test coverage detected