Skip to content

Commit fcc3b45

Browse files
committed
refactor(@angular/cli): remove unused resolveModule method from Host abstraction
Remove the `resolveModule` method from the `Host` interface, `LocalWorkspaceHost`, and `MockHost`. This method was not used by any of the MCP tools or server implementation, and removing it simplifies the abstraction layer.
1 parent 098bb00 commit fcc3b45

2 files changed

Lines changed: 5 additions & 18 deletions

File tree

packages/angular/cli/src/commands/mcp/host.ts

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,6 @@ export interface Host {
7171
options: { cwd: string },
7272
): AsyncIterable<{ name: string; parentPath: string; isFile(): boolean }>;
7373

74-
/**
75-
* Resolves a module request from a given path.
76-
* @param request The module request to resolve.
77-
* @param from The path from which to resolve the request.
78-
* @returns The resolved module path.
79-
*/
80-
resolveModule(request: string, from: string): string;
81-
8274
/**
8375
* Spawns a child process and returns a promise that resolves with the process's
8476
* output or rejects with a structured error.
@@ -178,10 +170,6 @@ export const LocalWorkspaceHost: Host = {
178170
return nodeGlob(pattern, { ...options, withFileTypes: true });
179171
},
180172

181-
resolveModule(request: string, from: string): string {
182-
return createRequire(from).resolve(request);
183-
},
184-
185173
runCommand: async (
186174
command: string,
187175
args: readonly string[],
@@ -341,13 +329,11 @@ export function createRootRestrictedHost(
341329
checkPath(options.cwd);
342330

343331
const firstWildcardIndex = pattern.search(/[*?[{]/);
344-
const basePath = firstWildcardIndex >= 0
345-
? pattern.substring(0, firstWildcardIndex)
346-
: pattern;
347-
332+
const basePath = firstWildcardIndex >= 0 ? pattern.substring(0, firstWildcardIndex) : pattern;
333+
348334
const targetDir = resolve(options.cwd, basePath);
349335
checkPath(targetDir);
350-
336+
351337
return baseHost.glob(pattern, options);
352338
},
353339
runCommand(command: string, args: readonly string[], options: { cwd?: string } = {}) {
@@ -356,6 +342,7 @@ export function createRootRestrictedHost(
356342
if (command.includes('/') || command.includes('\\')) {
357343
checkPath(resolve(effectiveCwd, command));
358344
}
345+
359346
return baseHost.runCommand(command, args, options);
360347
},
361348
spawn(command: string, args: readonly string[], options: { cwd?: string } = {}) {
@@ -364,6 +351,7 @@ export function createRootRestrictedHost(
364351
if (command.includes('/') || command.includes('\\')) {
365352
checkPath(resolve(effectiveCwd, command));
366353
}
354+
367355
return baseHost.spawn(command, args, options);
368356
},
369357
};

packages/angular/cli/src/commands/mcp/testing/mock-host.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export class MockHost implements Host {
1818
existsSync = jasmine.createSpy('existsSync');
1919
readFile = jasmine.createSpy('readFile').and.resolveTo('');
2020
glob = jasmine.createSpy('glob').and.returnValue((async function* () {})());
21-
resolveModule = jasmine.createSpy('resolveRequest').and.returnValue('/dev/null');
2221
spawn = jasmine.createSpy('spawn');
2322
getAvailablePort = jasmine.createSpy('getAvailablePort');
2423
isPortAvailable = jasmine.createSpy('isPortAvailable').and.resolveTo(true);

0 commit comments

Comments
 (0)