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(core): automatically add root to the project.json projects #9977
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
eaf6c0c
to
4a9e792
Compare
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.
I'm going to go ahead and approve this. I left a few comments, one / two nitpicks and a suggestion that would ease future work.
@@ -1,6 +1,6 @@ | |||
import { readFileSync, readdirSync, statSync } from 'fs'; | |||
import * as path from 'path'; | |||
import type { Tree } from 'nx/src/config/tree'; |
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.
We could put a TS file called nx-reexports.ts
or something in packages/devkit/src to avoid all of these deep imports.... I'm not sure that its worth changing NOW, but it may be good to do eventually to limit the places they happen.
import { toNewFormat, toOldFormatOrNull } from 'nx/src/config/workspaces'; | ||
import { Generator, GeneratorCallback } from 'nx/src/config/misc-interfaces'; | ||
import { parseJson, serializeJson } from 'nx/src/utils/json'; | ||
import { join, relative } from 'path'; | ||
import { join, relative, dirname } from 'path'; |
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.
Is dirname
actually used in here? I see it added, but no usage added.
@@ -637,6 +640,9 @@ export function buildWorkspaceConfigurationFromGlobs( | |||
// directory as a package.json should overwrite the inferred package.json | |||
// project configuration. | |||
const configuration = readJson(file); | |||
|
|||
configuration.root = directory; |
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.
Given that we are now doing a little bit more, maybe we should abstract this out. Something like below. This isn't super important right now, but if we add any token support in the file, it will get more so.
function buildProjectConfigurationFromProjectJson(filePath) {
const c = readJson<ProjectConfiguration>(filePath)
c.root = dirname(filePath)
return c
}
7fc8c77
to
9a513da
Compare
* fix(core): automatically add root to the project.json projects * chore(core): move project-configuration generator utils to nx package * fix(core): add migrations to remove root
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
project.json
requiresroot
to be defined even though.. it sits at the project root.Expected Behavior
project.json
does not need to defineroot
Related Issue(s)
Fixes #