Skip to content

fix(core): init should use pr version when specified#30497

Merged
AgentEnder merged 1 commit intomasterfrom
fix/nx-init-pr-versions
Mar 26, 2025
Merged

fix(core): init should use pr version when specified#30497
AgentEnder merged 1 commit intomasterfrom
fix/nx-init-pr-versions

Conversation

@AgentEnder
Copy link
Copy Markdown
Member

Current Behavior

nx init always either installs next or latest versions of Nx. The intent here is that running npx nx init should always provide the latest version of Nx, and we added a condition to use next if we detected a beta version of Nx was running to facilitate easier testing of RC and beta releases. The full logic to determine which version of Nx to setup is below:

const version =
    process.env.NX_VERSION ?? (prerelease(nxVersion) ? 'next' : 'latest');

The goal here was to avoid hitting the npx cache and accidentally creating new workspaces with an older Nx version. This logic falls apart a bit when considering prereleases though, as npx nx@next init would always check the tag to make sure its up to date rather than using a cached version. This is the case when providing any tag to npx.

A bad side effect of the above is that when trying to test PR builds and the like, nx init will never setup the PR build when running npx nx@0.0.0-pr.... opting instead to setup next.

Expected Behavior

Running npx nx@0.0.0-pr.... init sets up an nx workspace using the specified PR release.

Related Issue(s)

Fixes #

@AgentEnder AgentEnder requested a review from a team as a code owner March 25, 2025 18:02
@AgentEnder AgentEnder requested a review from xiongemi March 25, 2025 18:02
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Mar 25, 2025 6:02pm

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented Mar 25, 2025

View your CI Pipeline Execution ↗ for commit 59b6bdd.

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 2m 14s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 20s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx format:check --base=50561... ✅ Succeeded 2s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 1s View ↗
nx documentation ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2025-03-25 19:49:25 UTC

Copy link
Copy Markdown
Contributor

@MaxKless MaxKless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@AgentEnder AgentEnder merged commit 9dd4766 into master Mar 26, 2025
12 checks passed
@AgentEnder AgentEnder deleted the fix/nx-init-pr-versions branch March 26, 2025 00:36
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 1, 2025

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 Apr 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants