Skip to content

fix(core): prevent Windows template path corruption - #1875

Merged
kdinev merged 10 commits into
masterfrom
ganastasov/windows-template-path-corruption
Nov 5, 2026
Merged

kdinev merged 10 commits into
masterfrom
ganastasov/windows-template-path-corruption

Conversation

@georgianastasov

@georgianastasov georgianastasov commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Closes: #1873

Description

Fix Windows-specific drive-letter casing issues where glob returns paths starting with an uppercase drive letter (C:/), while the CLI source path may use lowercase (c:/).

Case-sensitive path handling could cause:

  • False "already exists" errors during template validation.
  • Overwriting and emptying original template files during project generation.
  • AI skills failing to copy into generated projects.
  • Project generation reporting success even when template processing failed.

Changes:

  • Use glob with cwd and path.join() instead of string-based path replacement.
  • Prevent accidental source template overwrites.
  • Stop ig new and the interactive wizard when template processing fails, avoiding false success messages.
  • Remove obsolete React and Web Components template path overrides referencing missing directories.
  • Fix AI skills copying on Windows by using native path.relative() to handle drive-letter casing correctly.
  • Extend regression coverage for Windows path casing, special characters, template collisions, generation failures, AI skills copying, and template directory validation.

Related Issue

N/A

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring / code cleanup
  • Build / CI configuration change

Affected Packages

  • igniteui-cli (packages/cli)
  • @igniteui/cli-core (packages/core)
  • @igniteui/angular-templates (packages/igx-templates)
  • @igniteui/angular-schematics (packages/ng-schematics)
  • @igniteui/mcp-server (packages/igniteui-mcp)

Checklist

  • I have tested my changes locally (npm run test)
  • I have built the project successfully (npm run build)
  • I have run the linter (npm run lint)
  • I have added/updated tests as needed
  • My changes do not introduce new warnings or errors

Additional Context

Verification:

  • 23/23 FIXED CLI manual E2E tests passed across the original Windows regression scenarios.
  • Previously verified: 31 unit tests and 21 template collision tests passed.
  • Manual CLI tests passed for ig new (Angular, jQuery, React, Web Components), ig add, and ig generate.
  • Verified AI skills copying with lowercase Windows drive-letter paths.
  • Confirmed generated files are correct and original template sources remain unchanged.

@coveralls

coveralls commented Nov 3, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 95.379%. remained the same — ganastasov/windows-template-path-corruption into master

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.

🟡 Changes recommended

Critical gaps in the path guard allow symlink/junction aliases and transformed filenames to truncate or overwrite source templates when validation is disabled.

2 open issues
What changed in this PR

This PR addresses #1873 by replacing case-sensitive path substitution in core template processing, preventing Windows drive-letter casing differences from misdirecting generated files.

Changes:

  • Discover templates relative to their source directory and construct paths with path.join().
  • Add a guard against overwriting the current source template.
  • Add regression tests for special-character paths, collisions, and Windows drive-letter casing.
File Description
spec/​unit/​Util-spec.ts Adds filesystem-based regression tests for template generation and source preservation.
packages/​core/​util/​Util.ts Updates path construction in processing and validation, and adds a source-overwrite guard.

Review effort: Balanced

Comment thread packages/core/util/Util.ts Resolved
Comment thread packages/core/util/Util.ts Resolved

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.

🟢 Approval recommended

No active review issues block the template-processing and generation-failure handling changes.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

dkalinovInfra
dkalinovInfra previously approved these changes Nov 5, 2026
kdinev
kdinev previously approved these changes Nov 5, 2026
@Marina-L-Stoyanova

Copy link
Copy Markdown
Contributor

While testing this PR I notices that AI skills are not copied on Windows when the CLI path uses a lowercase drive letter. I think we can fix this as part of the current PR.
image

@georgianastasov

georgianastasov commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks. I reproduced the issue on Windows and confirmed that it also exists in the published CLI 15.8.2, so it's not a regression introduced by this PR. I also reproduced it with the current PR changes:

  • Uppercase C:\ - all 18 AI skill files copied successfully.
  • Lowercase c:\ - all 18 files failed to copy.

Since it's caused by the same Windows drive-letter casing issue, I'll include the fix and a regression test in this PR as well.

@kdinev
kdinev merged commit a8144cd into master Nov 5, 2026
4 checks passed
@kdinev
kdinev deleted the ganastasov/windows-template-path-corruption branch November 5, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: Lowercase drive-letter paths can corrupt CLI templates during project generation

6 participants