-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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): read project name from package json if not set in project json #26386
fix(core): read project name from package json if not set in project json #26386
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
☁️ Nx Cloud ReportCI is running/has finished running commands for commit bea9f46. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 6 targets
Sent with 💌 from NxCloud. |
12d3bd6
to
8d7724b
Compare
export function readNameFromPackageJson(path: string): string { | ||
try { | ||
const json = readJsonFile<PackageJson>(path); | ||
return buildProjectConfigurationFromPackageJson(json, path, {}).name; |
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.
Do not reuse this function. Just read the correct properties.
2e67567
to
22eb068
Compare
projectJson.name = toProjectName(root); | ||
writeJson(tree, `${root}/project.json`, projectJson); | ||
} | ||
} |
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.
Please format files.
// For existing projects, if the name is not set, we can inline it | ||
// based on the existing logic. This makes sure folks aren't caught | ||
// off guard by the new behavior. | ||
if (!projectJson.name) { |
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.
Check if we have really changed the name before updating.
packages/nx/migrations.json
Outdated
@@ -83,6 +83,12 @@ | |||
"version": "19.2.2-beta.0", | |||
"description": "Updates the nx wrapper.", | |||
"implementation": "./src/migrations/update-17-3-0/update-nxw" | |||
}, | |||
"19-2-3-set-project-name": { | |||
"version": "19.2.3-beta.0", |
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.
You'll have to update the version
b1f37e1
to
92b3112
Compare
92b3112
to
bea9f46
Compare
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
If
project.json
exists without a name, we infer one based on the root path. This can be confusing when there exists apackage.json
alongside it that contains a name which doesn't match our inferred name.Expected Behavior
If
project.json
andpackage.json
both exist, the name frompackage.json
will be used ifproject.json
contains no name.Related Issue(s)
Fixes #26347