-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat(core): implement metadata fetching for Node.js and Bun #6230
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
Changes from 2 commits
b5de99a
cc36a2c
346f12e
5d9fb9c
4c13ad5
0ec2891
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||||||||||||||||
| use crate::backend::{Backend, VersionCacheManager}; | ||||||||||||||||||||
| use crate::backend::{Backend, VersionCacheManager, platform_target::PlatformTarget}; | ||||||||||||||||||||
| use crate::build_time::built_info; | ||||||||||||||||||||
| use crate::cache::CacheManagerBuilder; | ||||||||||||||||||||
| use crate::cli::args::BackendArg; | ||||||||||||||||||||
|
|
@@ -534,6 +534,68 @@ impl Backend for NodePlugin { | |||||||||||||||||||
| }) | ||||||||||||||||||||
| .clone() | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // ========== Lockfile Metadata Fetching Implementation ========== | ||||||||||||||||||||
|
Comment on lines
+537
to
+538
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| async fn get_tarball_url( | ||||||||||||||||||||
| &self, | ||||||||||||||||||||
| tv: &ToolVersion, | ||||||||||||||||||||
| target: &PlatformTarget, | ||||||||||||||||||||
| ) -> Result<Option<String>> { | ||||||||||||||||||||
| let version = &tv.version; | ||||||||||||||||||||
| let settings = Settings::get(); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // Build platform-specific filename like Node.js does | ||||||||||||||||||||
| let slug = self.build_platform_slug(version, target); | ||||||||||||||||||||
| let filename = if target.os_name() == "windows" { | ||||||||||||||||||||
| format!("{slug}.zip") | ||||||||||||||||||||
| } else { | ||||||||||||||||||||
| format!("{slug}.tar.gz") | ||||||||||||||||||||
| }; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // Use Node.js mirror URL to construct download URL | ||||||||||||||||||||
| let url = settings | ||||||||||||||||||||
| .node | ||||||||||||||||||||
| .mirror_url() | ||||||||||||||||||||
| .join(&format!("v{version}/{filename}")) | ||||||||||||||||||||
| .map_err(|e| eyre::eyre!("Failed to construct Node.js download URL: {e}"))?; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Ok(Some(url.to_string())) | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| impl NodePlugin { | ||||||||||||||||||||
| /// Build platform-specific slug for Node.js downloads | ||||||||||||||||||||
| /// This mirrors the logic from BuildOpts::new() and slug() function | ||||||||||||||||||||
| fn build_platform_slug(&self, version: &str, target: &PlatformTarget) -> String { | ||||||||||||||||||||
| let settings = Settings::get(); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // Map Platform enum to Node.js OS names | ||||||||||||||||||||
| let os = match target.os_name() { | ||||||||||||||||||||
| "macos" => "darwin", | ||||||||||||||||||||
| "linux" => "linux", | ||||||||||||||||||||
| "windows" => "win32", | ||||||||||||||||||||
| other => other, | ||||||||||||||||||||
|
||||||||||||||||||||
| other => other, | |
| other => { | |
| eprintln!( | |
| "Warning: Unknown OS name '{}' encountered in Node.js platform mapping. Passing through as-is.", | |
| other | |
| ); | |
| other | |
| }, |
Copilot
AI
Sep 7, 2025
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.
[nitpick] Consider logging a warning when encountering unknown architecture names to help with debugging platform mapping issues.
| other => other, | |
| other => { | |
| eprintln!( | |
| "Warning: Unknown architecture name '{}' encountered in build_platform_slug for target: {:?}. Using as-is.", | |
| other, | |
| target | |
| ); | |
| other | |
| }, |
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.
[nitpick] Remove the extra blank line before the comment to maintain consistent spacing with the rest of the file.