-
Notifications
You must be signed in to change notification settings - Fork 5
feat/Change-Detection - add CD strategy tag in the components tree #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
santoshyadavdev
merged 1 commit into
santoshyadavdev:main
from
abiramcodes:feat/Change-Detection
Sep 29, 2026
+389
−41
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ts/browser-agent-rpc-BXhoSh1z-BQdhADiM.js → ...ts/browser-agent-rpc-BXhoSh1z-CxaePWwp.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
58 changes: 29 additions & 29 deletions
58
extension/ui/assets/index-BPVPMcLi.js → extension/ui/assets/index-B5-EMQmo.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
packages/ng-devtools/src/rpc/__tests__/angular-version.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import { mkdirSync, writeFileSync } from 'node:fs'; | ||
| import { join } from 'node:path'; | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { fixtureDir } from './fixture-dir.ts'; | ||
| import { angularMajor } from '../angular-version.ts'; | ||
|
|
||
| describe('angularMajor', () => { | ||
| it('reads the major from the installed package', () => { | ||
| const dir = fixtureDir('ng-devtools-version-'); | ||
| const coreDir = join(dir, 'node_modules', '@angular', 'core'); | ||
| mkdirSync(coreDir, { recursive: true }); | ||
| writeFileSync(join(coreDir, 'package.json'), JSON.stringify({ version: '22.1.7' })); | ||
| expect(angularMajor(dir)).toBe(22); | ||
| }); | ||
|
|
||
| it('prefers the installed version over the declared range', () => { | ||
| const dir = fixtureDir('ng-devtools-version-'); | ||
| const coreDir = join(dir, 'node_modules', '@angular', 'core'); | ||
| mkdirSync(coreDir, { recursive: true }); | ||
| writeFileSync(join(coreDir, 'package.json'), JSON.stringify({ version: '22.1.7' })); | ||
| writeFileSync( | ||
| join(dir, 'package.json'), | ||
| JSON.stringify({ dependencies: { '@angular/core': '^20.0.0' } }), | ||
| ); | ||
| expect(angularMajor(dir)).toBe(22); | ||
| }); | ||
|
|
||
| it('falls back to a pinned or ^/~ range in package.json', () => { | ||
| const dir = fixtureDir('ng-devtools-version-'); | ||
| writeFileSync( | ||
| join(dir, 'package.json'), | ||
| JSON.stringify({ dependencies: { '@angular/core': '^21.0.0' } }), | ||
| ); | ||
| expect(angularMajor(dir)).toBe(21); | ||
|
|
||
| const dir2 = fixtureDir('ng-devtools-version-'); | ||
| writeFileSync( | ||
| join(dir2, 'package.json'), | ||
| JSON.stringify({ devDependencies: { '@angular/core': '~21.1.0' } }), | ||
| ); | ||
| expect(angularMajor(dir2)).toBe(21); | ||
| }); | ||
|
|
||
| it('gives up on a range that names no single version', () => { | ||
| const dir = fixtureDir('ng-devtools-version-'); | ||
| writeFileSync( | ||
| join(dir, 'package.json'), | ||
| JSON.stringify({ dependencies: { '@angular/core': '>=20.0.0' } }), | ||
| ); | ||
| expect(angularMajor(dir)).toBeUndefined(); | ||
|
|
||
| const dir2 = fixtureDir('ng-devtools-version-'); | ||
| writeFileSync( | ||
| join(dir2, 'package.json'), | ||
| JSON.stringify({ dependencies: { '@angular/core': 'latest' } }), | ||
| ); | ||
| expect(angularMajor(dir2)).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('returns undefined when nothing names a version at all', () => { | ||
| const dir = fixtureDir('ng-devtools-version-'); | ||
| expect(angularMajor(dir)).toBeUndefined(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('angularMajor with malformed metadata', () => { | ||
| it('yields undefined when package.json is not an object or its dependencies are', () => { | ||
| const arrayRoot = fixtureDir('ng-devtools-version-'); | ||
| writeFileSync(join(arrayRoot, 'package.json'), '[]'); | ||
| expect(angularMajor(arrayRoot)).toBeUndefined(); | ||
|
|
||
| const badDeps = fixtureDir('ng-devtools-version-'); | ||
| writeFileSync( | ||
| join(badDeps, 'package.json'), | ||
| JSON.stringify({ dependencies: 'nope', devDependencies: null }), | ||
| ); | ||
| expect(angularMajor(badDeps)).toBeUndefined(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { existsSync, readFileSync } from 'node:fs'; | ||
| import { join } from 'node:path'; | ||
|
|
||
| /** | ||
| * The major version of `@angular/core` the project builds against, or | ||
| * `undefined` when it cannot be told apart from the workspace root. | ||
| * | ||
| * Angular 22 made `OnPush` the implicit change detection strategy, so a | ||
| * component without a `changeDetection` key means something different | ||
| * depending on which major the project is on; this resolves that once per | ||
| * scan rather than per file. | ||
| * | ||
| * Only one version is resolved for the whole workspace root, so a monorepo | ||
| * that mixes Angular majors across packages is not distinguished per package. | ||
| */ | ||
| export function angularMajor(cwd: string): number | undefined { | ||
| const installed = readJson(join(cwd, 'node_modules', '@angular', 'core', 'package.json'))[ | ||
| 'version' | ||
| ]; | ||
| if (typeof installed === 'string') { | ||
| const major = majorOf(installed); | ||
| if (major !== undefined) return major; | ||
| } | ||
|
|
||
| const pkg = readJson(join(cwd, 'package.json')); | ||
| const range = { | ||
| ...asRecord(pkg['dependencies']), | ||
| ...asRecord(pkg['devDependencies']), | ||
| }['@angular/core']; | ||
| // Only a pinned or `^`/`~` range names one version; `>=20`, `latest`, | ||
| // `workspace:*` and the like could resolve to anything and are left alone | ||
| // rather than guessed at. | ||
| if (typeof range === 'string') return majorOf(range.replace(/^[\^~]/, '')); | ||
| return undefined; | ||
| } | ||
|
|
||
| function majorOf(version: string): number | undefined { | ||
| const match = /^(\d+)(?:\.|$)/.exec(version.trim()); | ||
| return match ? Number(match[1]) : undefined; | ||
| } | ||
|
|
||
| function asRecord(value: unknown): Record<string, unknown> { | ||
| return typeof value === 'object' && value !== null && !Array.isArray(value) | ||
| ? (value as Record<string, unknown>) | ||
| : {}; | ||
| } | ||
|
|
||
| function readJson(path: string): Record<string, unknown> { | ||
| try { | ||
| if (!existsSync(path)) return {}; | ||
| return asRecord(JSON.parse(readFileSync(path, 'utf-8'))); | ||
| } catch { | ||
| return {}; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.