Skip to content

feat: update icons migration schematics (#DS-4328) - #1920

Open
NikGurev wants to merge 2 commits into
mainfrom
feat/DS-4328
Open

feat: update icons migration schematics (#DS-4328)#1920
NikGurev wants to merge 2 commits into
mainfrom
feat/DS-4328

Conversation

@NikGurev

@NikGurev NikGurev commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

What this does

Two of our CLI migration tools (deprecated-icons and new-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

  • Only real icon code gets updated — component names, CSS classes, and text that just happen to look similar are left untouched.
  • Running with the "just tell me what needs fixing" option no longer silently changes files — it now truly only reports, nothing gets edited.
  • A couple of small existing bugs were fixed along the way (e.g. an icon name inside a string wasn't being renamed correctly before).
  • more test coverage with regression tests

@NikGurev NikGurev self-assigned this Aug 21, 2026
@NikGurev
NikGurev requested a review from lskramarov as a code owner August 21, 2026 16:47
@NikGurev NikGurev added the enhancement New feature or request label Aug 21, 2026
@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/schematics/src/utils/icon-migration.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants