feat: update icons migration schematics (#DS-4328) - #1920
Conversation
|
Visit the preview URL for this PR (updated for commit 1d60e7a): https://koobiq-next--prs-1920-2y9cis3u.web.app (expires Thu, 27 Aug 2026 10:28:14 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: c9e37e518febda70d0317d07e8ceb35ac43c534c |
There was a problem hiding this comment.
Pull request overview
This PR updates the deprecated-icons and new-icons-pack schematics to migrate icon usages using AST-based parsing (HTML + TypeScript), avoiding unsafe whole-file text replacement and improving correctness for “report-only” (fix: false) runs.
Changes:
- Introduces a shared AST-based icon migration utility that can migrate templates, inline TS templates, bare TS string literals, and styles/markdown (regex-based) with token-level precision.
- Refactors template/TS migration helpers to accept pluggable transforms, enabling reuse by multiple migrations.
- Expands and modernizes test coverage (including regressions ensuring unrelated selectors/classes/strings are not modified) and updates migration documentation.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/schematics/src/utils/typescript.ts | Adds a helper to walk string literals and supports TS-side scanning for safe migrations. |
| packages/schematics/src/utils/icon-migration.ts | New shared icon migration engine (template AST + TS string literals + boundary-safe regex for styles/markdown). |
| packages/schematics/src/utils/ast.ts | Adds token-list replacement helper and class.<token> binding parsing utility. |
| packages/schematics/src/utils/angular-parsing.ts | Refactors template/TS migration functions to accept a transform function; exports transformTemplateAttributes. |
| packages/schematics/src/migrations/new-icons-pack/README.md | Documents AST-based matching and the updated custom replacement-file shape. |
| packages/schematics/src/migrations/new-icons-pack/index.ts | Rewrites schematic to use the shared migration utility and improved scope/custom-data handling. |
| packages/schematics/src/migrations/new-icons-pack/index.spec.ts | Updates tests and adds regressions for “don’t touch unrelated tokens” + report-only behavior. |
| packages/schematics/src/migrations/new-icons-pack/data.ts | Introduces scope constant; deprecates legacy iconReplacements fragments. |
| packages/schematics/src/migrations/deprecated-icons/README.md | Updates docs for AST-based matching and documented limitations in styles. |
| packages/schematics/src/migrations/deprecated-icons/index.ts | Rewrites schematic to use the shared migration utility, including separate style token mapping behavior. |
| packages/schematics/src/migrations/deprecated-icons/index.spec.ts | Reworks tests to assert behavior directly (reducing reliance on snapshots) and adds regressions. |
| packages/schematics/src/migrations/deprecated-icons/data.ts | Introduces scope constant; deprecates legacy iconClassReplacements fragments. |
| packages/schematics/src/migrations/deprecated-icons/snapshots/index.spec.ts.snap | Removes large snapshot file now that tests assert behavior directly. |
Suppressed comments (1)
packages/schematics/src/utils/icon-migration.ts:408
- Edits are applied to the UpdateRecorder in ascending order, which can corrupt subsequent offsets after earlier removals/insertions. Other migrations in this repo apply updates from the end of the file to the start (descending offsets) to keep recorded positions stable.
edits.sort((a, b) => a.start - b.start);
const update = tree.beginUpdate(relativePath);
for (const edit of edits) {
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
What this does
Two of our CLI migration tools (
deprecated-iconsandnew-icons-pack) help users update old icon names in their projects.The problem: they worked by searching and replacing text everywhere in a file, so they sometimes changed things that had nothing to do with icons — like a component name, an unrelated CSS class, or a random string that happened to contain the same letters.
This PR makes both tools smarter. Instead of blindly searching for text, they now actually read and understand the code they're editing (the same way a compiler does), so they only touch real icon usages and leave everything else alone.
What changed for users