Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0565a59

Browse files
committed
fixup! refactor(@angular/cli): add a get Zoneless/OnPush MCP tool
1 parent 7c722ae commit 0565a59

File tree

6 files changed

+15
-30
lines changed

6 files changed

+15
-30
lines changed

‎packages/angular/cli/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,12 @@ ts_project(
125125
":angular-cli",
126126
":node_modules/@angular-devkit/core",
127127
":node_modules/@angular-devkit/schematics",
128+
":node_modules/@modelcontextprotocol/sdk",
128129
":node_modules/yargs",
129130
"//:node_modules/@types/semver",
130131
"//:node_modules/@types/yargs",
131132
"//:node_modules/semver",
133+
"//:node_modules/typescript",
132134
],
133135
)
134136

‎packages/angular/cli/src/commands/mcp/tools/onpush-zoneless-migration/analyze_for_unsupported_zone_uses.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import type { SourceFile, Node, ImportSpecifier } from 'typescript';
9+
import type { ImportSpecifier, Node, SourceFile } from 'typescript';
1010
import { createUnsupportedZoneUsagesMessage } from './prompts';
1111
import { getImportSpecifier, loadTypescript } from './ts_utils';
1212
import { MigrationResponse } from './types';

‎packages/angular/cli/src/commands/mcp/tools/onpush-zoneless-migration/migrate_test_file.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { glob } from 'node:fs/promises';
109
import * as fs from 'node:fs';
10+
import { glob } from 'node:fs/promises';
1111
import { dirname, join } from 'node:path';
1212
import type { SourceFile } from 'typescript';
1313
import { createFixResponseForZoneTests, createProvideZonelessForTestsSetupPrompt } from './prompts';
14-
import { MigrationResponse } from './types';
1514
import { loadTypescript } from './ts_utils';
15+
import { MigrationResponse } from './types';
1616

1717
export async function migrateTestFile(sourceFile: SourceFile): Promise<MigrationResponse | null> {
1818
const ts = await loadTypescript();
@@ -50,7 +50,7 @@ export async function searchForGlobalZoneless(startPath: string): Promise<boolea
5050
}
5151

5252
try {
53-
const files = awaitglob(`${angularJsonDir}/**/*.ts`);
53+
const files = glob(`${angularJsonDir}/**/*.ts`);
5454
for await (const file of files) {
5555
const content = fs.readFileSync(file, 'utf-8');
5656
if (

‎packages/angular/cli/src/commands/mcp/tools/onpush-zoneless-migration/prompts.ts

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
*/
88

99
import type { Node, SourceFile } from 'typescript';
10-
import { MigrationResponse } from './types';
1110
import { loadTypescript } from './ts_utils';
11+
import { MigrationResponse } from './types';
1212

1313
/* eslint-disable max-len */
1414

@@ -35,31 +35,13 @@ export function createProvideZonelessForTestsSetupPrompt(testFilePath: string):
3535
});
3636
\`\`\`
3737
38-
#### Step 2: Identify and Isolate Failing Tests
39-
40-
After enabling zoneless detection for the suite, some tests will likely fail. Your next task is to identify these failing tests and temporarily revert them to use Zone.js-based change detection. This isolates them for a future fix.
41-
42-
For each test (\`it\` block) or group of tests (\`describe\` block) that fails, override the testbed configuration to use \`provideZoneChangeDetection\`.
43-
44-
\`\`\`typescript
45-
// Example for a single failing test
46-
it('should do something that fails in zoneless', () => {
47-
TestBed.configureTestingModule({
48-
providers: [provideZoneChangeDetection()]
49-
});
50-
// ... rest of the test
51-
});
52-
\`\`\`
38+
#### Step 2: Identify and fix Failing Tests
5339
54-
### IMPORTANT: Rules and Constraints
40+
After enabling zoneless detection for the suite, some tests will likely fail. Your next task is to identify these failing tests and fix them.
5541
56-
You must follow these rules without exception:
57-
1. **DO** add \`provideZonelessChangeDetection()\` _once_ to the top-most \`describe\` in a \`beforeEach\` block as instructed in Step 1.
58-
2. **DO** run the tests after adding \`provideZonelessChangeDetection\` to see which ones fail. **DO NOT** make assumptions about which tests will might fail.
59-
3. **DO** add \`provideZoneChangeDetection()\` to the providers for each individual test or group of tests that fail after the change in Step 1.
60-
4. **DO NOT** attempt to fix the logic of the failing tests at this stage. The goal is only to enable zoneless for the suite and isolate the incompatible tests.
61-
5. **DO NOT** make any other changes to the test file or any application code.
62-
6. **DO NOT** move tests around or create new describe blocks if it can be avoided. Changes are easier to review when code moves around less.
42+
${testDebuggingGuideText(testFilePath)}
43+
8. **DO** add \`provideZonelessChangeDetection()\` _once_ to the top-most \`describe\` in a \`beforeEach\` block as instructed in Step 1.
44+
9. **DO** run the tests after adding \`provideZonelessChangeDetection\` to see which ones fail. **DO NOT** make assumptions about which tests will might fail.
6345
6446
### Final Step
6547
After you have applied all the required changes and followed all the rules, consult this tool again for the next steps in the migration process.`;

‎packages/angular/cli/src/commands/mcp/tools/onpush-zoneless-migration/ts_utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import * as fs from 'node:fs';
10-
import type { NodeArray,ImportSpecifier, SourceFile } from 'typescript';
10+
import type { ImportSpecifier,NodeArray, SourceFile } from 'typescript';
1111
import type ts from 'typescript';
1212

1313
let typescriptModule: typeof ts;
@@ -121,5 +121,6 @@ export async function createSourceFile(file: string) {
121121
const content = fs.readFileSync(file, 'utf8');
122122

123123
const ts = await loadTypescript();
124+
124125
return ts.createSourceFile(file, content, ts.ScriptTarget.Latest, true);
125126
}

‎packages/angular/cli/src/commands/mcp/tools/onpush-zoneless-migration/zoneless-migration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
import { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol';
1010
import { ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types';
11-
import { glob } from 'node:fs/promises';
1211
import * as fs from 'node:fs';
12+
import { glob } from 'node:fs/promises';
1313
import { type SourceFile } from 'typescript';
1414
import { z } from 'zod';
1515
import { declareTool } from '../tool-registry';

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /