Skip to content

Conversation

AgentEnder
Copy link
Member

Current Behavior

getProjects(Tree) from project-configuration.ts does not return projects created in generators when called from generator callbacks. This happens because findCreatedProjectFiles only looks for changes with type === 'CREATE', but during callbacks, the tree has already been flushed to disk, so newly created project files are marked as 'UPDATE' instead of 'CREATE'.

Expected Behavior

getProjects(Tree) should return all projects, including those created during the current generator run, even when called from generator callbacks.

Changes Made

  • Modified findCreatedProjectFiles() to include both CREATE and UPDATE changes
  • Added deduplication using Set to prevent duplicate project files
  • Added comprehensive test coverage for the callback scenario

Related Issue(s)

Fixes #29852

🤖 Generated with Claude Code

@AgentEnder AgentEnder requested a review from a team as a code owner June 2, 2025 21:26
@AgentEnder AgentEnder requested a review from MaxKless June 2, 2025 21:26
Copy link

vercel bot commented Jun 2, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
nx-dev Ready Ready Preview Aug 21, 2025 2:28pm

@AgentEnder AgentEnder requested a review from Copilot June 2, 2025 21:27
Copy link
Contributor

@Copilot Copilot AI left a comment

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 fixes an issue in generator callbacks by modifying the logic to include both CREATE and UPDATE file changes when detecting newly created project files, and prevents duplicates by using deduplication with a Set. It also adds a comprehensive test to validate that project configurations created during generator callbacks are correctly returned by getProjects.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/nx/src/generators/utils/project-configuration.ts Modified findCreatedProjectFiles to include UPDATE changes and added deduplication logic to avoid duplicates.
packages/nx/src/generators/utils/project-configuration.spec.ts Added a new test case to verify project detection when files are marked as UPDATE in generator callbacks.

Copy link
Contributor

nx-cloud bot commented Jun 2, 2025

View your CI Pipeline Execution ↗ for commit 1979513

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 47m 18s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 2m 12s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 6s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 5s View ↗
nx documentation ✅ Succeeded 42s View ↗

☁️ Nx Cloud last updated this comment at 2025-08-21 15:18:51 UTC

…nerator callbacks

During generator callbacks, the tree has already applied changes, so newly
created project files are marked as UPDATE instead of CREATE. This caused
getProjects() to miss projects created during the generator run when called
from callbacks.

Changes:
- Modified findCreatedProjectFiles() to include both CREATE and UPDATE changes
- Added deduplication using Set to prevent duplicate project files
- Added test coverage for the callback scenario

Fixes #29852

Co-authored-by: AgentEnder <[email protected]>
@FrozenPandaz FrozenPandaz merged commit d298de5 into master Aug 21, 2025
5 checks passed
@FrozenPandaz FrozenPandaz deleted the claude/issue-29852-20250602_211257 branch August 21, 2025 15:54
FrozenPandaz pushed a commit that referenced this pull request Aug 22, 2025
…nerator callbacks (#31429)

## Current Behavior

getProjects(Tree) from project-configuration.ts does not return projects
created in generators when called from generator callbacks. This happens
because findCreatedProjectFiles only looks for changes with type ===
'CREATE', but during callbacks, the tree has already been flushed to
disk, so newly created project files are marked as 'UPDATE' instead of
'CREATE'.

## Expected Behavior

getProjects(Tree) should return all projects, including those created
during the current generator run, even when called from generator
callbacks.

## Changes Made

- Modified findCreatedProjectFiles() to include both CREATE and UPDATE
changes
- Added deduplication using Set to prevent duplicate project files
- Added comprehensive test coverage for the callback scenario

## Related Issue(s)

Fixes #29852

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: AgentEnder <[email protected]>
(cherry picked from commit d298de5)
Copy link
Contributor

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority: medium Medium Priority (not high, not low priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

getProjects fails when used in generator callback
2 participants