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
fix(misc): fix moving projects with standalone configuration #6521
fix(misc): fix moving projects with standalone configuration #6521
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/nrwl/nx-dev/7HoJ5wg6fbDqkKcSi2skz3JD9uC5 |
Nx Cloud ReportCI ran the following commands for commit e2d317d. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch Sent with 💌 from NxCloud. |
* @param host - the file system tree | ||
* @param project - the project name | ||
*/ | ||
export function isStandaloneProject(host: Tree, project: string): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this and use getWorkspaceLayout(host).standaloneAsDefault
instead?
@@ -12,6 +13,7 @@ export function moveProjectConfiguration( | |||
schema: NormalizedSchema, | |||
projectConfig: ProjectConfiguration & NxJsonProjectConfiguration | |||
) { | |||
const isStandalone = isStandaloneProject(tree, schema.projectName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use getWorkspaceLayout(host).standaloneAsDefault
so we don't have to add the new function?
It should work in this case because the current move logic already moves the project.json
file appropriately.
From what I saw, this could also be solved somewhat hackily by moving addProjectConfiguration
after removeProjectConfiguration
. But I think reading whether it should be standalone or not and then explicitly saying to add a standalone is a better option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That wouldn't be right for a couple of reasons:
getWorkspaceLayout(host).standaloneAsDefault
will only betrue
if all projects in the workspace are configured as standalone, you'd expect that to normally be the case, either all or none, but that's an assumption, not a fact. Even our generator to convert projects into standalone config offers the ability to specify a project, it's not mandatory to convert the whole workspace.- It can't be solved by having
addProjectConfiguration
beforeremoveProjectConfiguration
, because there are cases where the project name for the destination is the same as the old destination (e.g. movingdomain-project
todomain/project
, both results in the namedomain-project
). A couple of issues have been created because of that, and I previously worked on solving those. In that scenario, if you try to add the project first, you get an error because it already exists.
The need here is to know if the project being moved is configured as standalone or not, that doesn't match what getWorkspaceLayout(host).standaloneAsDefault
returns (whether all projects in the workspace are configured as standalone).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay, I see
@@ -12,6 +13,7 @@ export function moveProjectConfiguration( | |||
schema: NormalizedSchema, | |||
projectConfig: ProjectConfiguration & NxJsonProjectConfiguration | |||
) { | |||
const isStandalone = isStandaloneProject(tree, schema.projectName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay, I see
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. |
Current Behavior
Moving a project with a standalone configuration adds the updated configuration to workspace.json instead of updating the corresponding project.json. This happens when not all the projects are using standalone configuration or when the project being moved is the only project in the workspace.
Expected Behavior
Moving a project with a standalone configuration should update the standalone configuration correctly.
Related Issue(s)
Fixes #6512