Skip to content

feat: support to install the latest version - #147

Merged
Dargon789 merged 50 commits into
Dargon789-patch-2from
master
Mar 1, 2026
Merged

feat: support to install the latest version#147
Dargon789 merged 50 commits into
Dargon789-patch-2from
master

Conversation

@Dargon789

Copy link
Copy Markdown
Owner

No description provided.

nzhl and others added 30 commits November 18, 2022 01:11
Because GitHub actions approval button is missing
This reverts commit f5f2ca2.
we can revert the yarn changes and do it in a different PR
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
@vercel

vercel Bot commented Mar 1, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
fnm Canceled Canceled Mar 1, 2026 11:27pm

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @Dargon789, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@snyk-io

snyk-io Bot commented Mar 1, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
🔚 Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@Dargon789

Copy link
Copy Markdown
Owner Author

@Mergifyio update

@mergify

mergify Bot commented Mar 1, 2026

Copy link
Copy Markdown

update

☑️ Nothing to do, the required conditions are not met

Details
  • #commits-behind > 0 [📌 update requirement]
  • -closed [📌 update requirement]
  • -conflict [📌 update requirement]
  • queue-position = -1 [📌 update requirement]

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces the ability to install the very latest Node.js version directly, enhancing convenience for users. It also provides a new option for managing Node.js versions globally rather than per-shell session, offering greater flexibility. Significant updates to both Rust and JavaScript dependencies have been performed to maintain project health and leverage newer features. Additionally, the internal archive extraction process has been refined, and command-line documentation has been regenerated to reflect these and other minor changes, ensuring accuracy and clarity for users.

Highlights

  • Latest Version Installation: Added support for fnm install --latest to easily install the most recent Node.js version.
  • Global Version Management: Introduced a --global flag for fnm env to manage a single global Node.js version across all shell sessions, offering an alternative to the per-shell multishell solution.
  • Dependency Updates: Updated numerous Rust and JavaScript dependencies, including clap, chrono, execa, and prettier, ensuring the project uses more recent and stable versions.
  • Archive Extraction Refactoring: Refactored archive extraction logic in Rust, simplifying the Extract trait and improving conditional compilation for tar and zip modules.
  • Command Documentation Streamlining: Streamlined command-line help documentation for various fnm subcommands, reflecting updated options and descriptions.
  • Version Handling Simplification: Removed the SemverRange variant from UserVersion and related logic, simplifying version handling.
  • Atomic Symlink Operations: Implemented a two-phase symlinking mechanism for more robust and atomic symlink creation and replacement.
Changelog
  • .changeset/fifty-emus-type.md
    • Added a new changeset file for remote version sorting and filtering.
  • .changeset/warm-rice-appear.md
    • Added a new changeset file for fnm install --latest support.
  • Cargo.lock
    • Updated numerous Rust dependency versions.
    • Added new dependencies: shared_thread, sigchld, signal-hook, signal-hook-registry, windows-link, windows-sys (new version), windows-targets (new version).
    • Removed once_cell from duct dependencies.
  • Cargo.toml
    • Updated duct dependency version.
  • docs/commands.md
    • Updated command line help output for fnm and its subcommands.
    • Removed corepack-enabled and resolve-engines options from many commands.
    • Added fnm 1.32.0 version to the main fnm help.
    • Added log-level values all and error.
    • Added * local and * recursive descriptions for version-file-strategy.
    • Removed progress and use options from fnm install.
  • package.json
    • Downgraded fnm version from 1.39.0 to 1.38.1.
    • Changed repository URL and author.
    • Downgraded pnpm package manager version.
    • Downgraded @changesets/cli, cmd-ts, prettier versions.
    • Upgraded execa, which, zod versions.
    • Removed description, bugs, homepage, main, directories, keywords fields.
  • pnpm-lock.yaml
    • Updated numerous JavaScript dependency versions.
    • Removed @inquirer/external-editor, baseline-browser-mapping, quansync.
    • Added @ampproject/remapping, @sec-ant/readable-stream, @sindresorhus/merge-streams, babel-preset-current-node-syntax, external-editor, figures, get-stream, globals, is-plain-obj, is-unicode-supported, parse-ms, pretty-ms, tmp, unicorn-magic, yoctocolors.
  • src/archive/extract.rs
    • Modified extract_into trait method to take self by value instead of Box<Self>.
  • src/archive/mod.rs
    • Added conditional compilation attributes to tar and zip modules.
    • Changed extract_archive_into to directly call extract_into on the Tar or Zip struct.
  • src/archive/tar.rs
    • Modified extract_into trait method to take self by value.
    • Added unit tests for tar.gz and tar.xz extraction.
  • src/archive/zip.rs
    • Modified extract_into trait method to take self by value.
    • Changed Box::new(Zip::new(response)) to Zip::new(response) in tests.
  • src/commands/env.rs
    • Added #[allow(clippy::struct_excessive_bools)] attribute.
    • Added a global flag to Env command to support a single global Node.js version.
    • Modified make_symlink to use path instead of temp_dir for clarity.
    • Updated error message for CantCreateSymlink.
    • Added SettingGlobalVersionSymlink error variant.
    • Changed multishell_path logic to use two_phase_symlink for global version.
  • src/commands/install.rs
    • Removed Use import, ProgressConfig import, HookContext import, HooksManager import, UserVersionReader import.
    • Removed progress and r#use fields from Install struct.
    • Removed show_progress and use_installed variables.
    • Removed pre/post/install-failed hooks logic.
    • Removed enable_corepack and use_installed_version functions.
    • Modified get_safe_arch call to pass config.arch by reference.
    • Added logic to create LTS alias if lts flag is used.
    • Updated CantListRemoteVersions error source from remote_node_index::Error to crate::http::Error.
    • Removed CorepackError and UseError error variants.
    • Removed HookError error variant.
    • Updated test cases to reflect removed fields.
  • src/commands/ls_remote.rs
    • Added #[allow(clippy::option_option)] attribute.
    • Removed truncate_except_latest helper function.
    • Changed all_versions.truncate(1) to directly replace the helper function call.
    • Added all_versions.sort_by_key(|v| v.version.clone()); to ensure consistent sorting before truncation/reversal.
    • Updated RemoteListing error variant to HttpError and changed source from remote_node_index::Error to crate::http::Error.
  • src/commands/use.rs
    • Changed replace_symlink to crate::fs::two_phase_symlink.
    • Updated SymlinkingCreationIssue error source to crate::fs::TwoPhaseSymlinkError.
    • Removed replace_symlink function.
  • src/config.rs
    • Added current_global_version_path method to get the path for the global version symlink.
  • src/fs.rs
    • Added two_phase_symlink function for atomic symlink creation/replacement.
    • Added TwoPhaseSymlinkError enum.
  • src/remote_node_index.rs
    • Removed DecodeError import.
    • Removed Decode error variant.
    • Simplified list function to directly use resp.json() and removed manual serde_json::from_str and DecodeError handling.
    • Removed manual sorting as resp.json() likely handles it or it's handled elsewhere.
  • src/user_version.rs
    • Removed SemverRange variant from UserVersion enum.
    • Removed inferred_alias method.
    • Updated matches method to remove SemverRange logic.
    • Updated fmt implementation to remove SemverRange formatting.
    • Changed FromStr error type from node_semver::SemverError to semver::Error.
  • src/version.rs
    • Changed node_semver::Version to semver::Version in Version enum and parse method.
    • Changed first_letter_is_number to use map_or instead of is_some_and.
    • Changed v_str to use format!("{}", self).
    • Removed a TODO comment.
    • Changed FromStr error type from node_semver::SemverError to semver::Error.
    • Changed PartialEq<node_semver::Version> to PartialEq<semver::Version>.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@Dargon789

Copy link
Copy Markdown
Owner Author

@Mergifyio refresh

@mergify

mergify Bot commented Mar 1, 2026

Copy link
Copy Markdown

refresh

✅ Pull request refreshed

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new --global flag to the fnm env command, allowing users to manage a single global Node.js version across all shell sessions, utilizing a new two-phase symlinking mechanism to prevent race conditions. It also refines the fnm ls-remote command by ensuring remote Node.js versions are sorted before filtering for the latest version. However, the review comments highlight several issues: the package.json and pnpm-lock.yaml files appear to be incorrectly rebased, leading to version downgrades, authorship changes, and removal of important metadata and dev dependencies. Additionally, the fnm install command has lost its --progress and --use flags, along with associated hook and corepack enablement logic, which are considered significant feature regressions. The UserVersion enum has also removed the SemverRange variant, breaking support for semver ranges, likely due to an unintended change in the semver crate usage. The docs/commands.md file reflects these changes, showing reordered and simplified command help outputs, possibly due to an updated clap version. The src/archive module has been refactored to remove Box<dyn Extract> indirection and conditionally compile tar for Unix and zip for Windows, with new extraction tests added for tar archives.

I am having trouble creating individual review comments. Click here to see my feedback.

package.json (3)

critical

This change reverts package.json to an older state, downgrading the package version, changing authorship, and removing several important fields like description, bugs, and homepage. Many dev dependencies are also downgraded in this file and in pnpm-lock.yaml. This looks like a rebase error. Please rebase your branch on top of the latest main to fix this.

src/commands/install.rs (33-41)

critical

This change removes the --progress and --use flags from the install command. Further down in the file, the logic for hooks and corepack enablement is also removed. These are significant feature regressions. This was likely caused by an incorrect rebase. Please restore these features by rebasing your branch on the latest main.

src/commands/ls_remote.rs (59-66)

high

There's a logic error here for the --latest flag. The list of versions (all_versions) is truncated before it is sorted. Since remote_node_index::list no longer returns a sorted list, all_versions.truncate(1) will keep a random version, not the latest one.

To fix this, you should sort the versions before processing the --latest flag. Also, since the sort is ascending, you'll want to get the last element for --latest.

        all_versions.sort_by_key(|v| v.version.clone());

        if self.latest {
            if let Some(latest) = all_versions.pop() {
                all_versions.clear();
                all_versions.push(latest);
            }
        }

        if let SortingMethod::Descending = self.sort {
            all_versions.reverse();
        }

src/user_version.rs (8)

high

The SemverRange variant has been removed from UserVersion. This is a significant breaking change that removes support for specifying versions using semver ranges (e.g., ^14.0.0). This seems to be a side-effect of switching from the node-semver crate back to semver in version.rs. This was likely unintentional and caused by an incorrect rebase. Please restore this functionality.

@Dargon789
Dargon789 merged commit cf083cb into Dargon789-patch-2 Mar 1, 2026
12 of 17 checks passed
Dargon789 added a commit that referenced this pull request Mar 13, 2026
* feat: support to install the latest version

* chore: test & fmt & clippy

* docs: update command docs

* docs: update command docs

* Create warm-rice-appear.md

* Update change set to be a minor release

As this is a new feature

* chore: update workflow to install pnpm

* Remove `feat:` from changeset

Because GitHub actions approval button is missing

* run pnpm like other tasks

* Revert "run pnpm like other tasks"

This reverts commit f5f2ca2.
we can revert the yarn changes and do it in a different PR

* revert the changes in .github/workflows

* feat: add remote version sorting and filtering

* use `UserVersion` for filtering

* add additional lts filter

* refactor: use `Vec::retain` instead of filtering and collecting

* fix docstring for sort option

* change docstring for filter argument

* refactor vec filtering

Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>

* refactor to use `sort_by_key` and `reverse`

Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>

* add latest flag

* make filter an option as well

* move sort into command as it is presentational

* fix getting latest version

* refactors

* update docs/commands.md

* sort upon installation

* fix clippy

* don't mention rust structs in the cli docs

* test more stuff in archiving

* fnm env --global: considering if this is a good idea

technically i think that i can just mutate the 'default' alias instead. because now that i think about it,
it makes 0 sense to set current to 'default' every time a new shell is opened. so current _is_ default.

* chore(deps): update rust crate embed-resource to v2.5.2

* fix(deps): update rust crate tar to v0.4.44

* fix(deps): update rust crate thiserror to v1.0.69

* chore(deps): update clap-rs

* chore(deps): update rust crate chrono to v0.4.44

* chore(deps): update all dev dependencies

---------

Co-authored-by: Fred <nzhlfred@gmail.com>
Co-authored-by: Gal Schlezinger <gal@spitfire.co.il>
Co-authored-by: Ryan Cao <70191398+ryanccn@users.noreply.github.com>
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Dargon789 added a commit that referenced this pull request Mar 13, 2026
* feat: support to install the latest version

* chore: test & fmt & clippy

* docs: update command docs

* docs: update command docs

* Create warm-rice-appear.md

* Update change set to be a minor release

As this is a new feature

* chore: update workflow to install pnpm

* Remove `feat:` from changeset

Because GitHub actions approval button is missing

* run pnpm like other tasks

* Revert "run pnpm like other tasks"

This reverts commit f5f2ca2.
we can revert the yarn changes and do it in a different PR

* revert the changes in .github/workflows

* feat: add remote version sorting and filtering

* use `UserVersion` for filtering

* add additional lts filter

* refactor: use `Vec::retain` instead of filtering and collecting

* fix docstring for sort option

* change docstring for filter argument

* refactor vec filtering

Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>

* refactor to use `sort_by_key` and `reverse`

Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>

* add latest flag

* make filter an option as well

* move sort into command as it is presentational

* fix getting latest version

* refactors

* update docs/commands.md

* sort upon installation

* fix clippy

* don't mention rust structs in the cli docs

* test more stuff in archiving

* fnm env --global: considering if this is a good idea

technically i think that i can just mutate the 'default' alias instead. because now that i think about it,
it makes 0 sense to set current to 'default' every time a new shell is opened. so current _is_ default.

* chore(deps): update rust crate embed-resource to v2.5.2

* fix(deps): update rust crate tar to v0.4.44

* fix(deps): update rust crate thiserror to v1.0.69

* chore(deps): update clap-rs

* chore(deps): update rust crate chrono to v0.4.44

* chore(deps): update all dev dependencies

---------

Co-authored-by: Fred <nzhlfred@gmail.com>
Co-authored-by: Gal Schlezinger <gal@spitfire.co.il>
Co-authored-by: Ryan Cao <70191398+ryanccn@users.noreply.github.com>
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants