Skip to content

feat(core): implement metadata fetching for Node.js and Bun#6230

Merged
jdx merged 6 commits intomainfrom
09-07-feat_core_implement_metadata_fetching_for_node.js_and_bun
Sep 7, 2025
Merged

feat(core): implement metadata fetching for Node.js and Bun#6230
jdx merged 6 commits intomainfrom
09-07-feat_core_implement_metadata_fetching_for_node.js_and_bun

Conversation

@jdx
Copy link
Copy Markdown
Owner

@jdx jdx commented Sep 7, 2025

Add concrete implementations of Backend trait metadata fetching methods:

Node.js Implementation:

  • Implements get_tarball_url() for Node.js mirror-based downloads
  • Maps Platform enum to Node.js OS/arch naming (linux->linux, macos->darwin, x64->x64, arm64->arm64, etc.)
  • Handles flavor support for custom Node.js builds
  • Constructs proper download URLs like v{version}/{slug}.tar.gz

Bun Implementation:

  • Implements get_github_release_info() for GitHub release-based downloads
  • Maps Platform enum to Bun's naming conventions (macos->darwin, aarch64->aarch64)
  • Provides GitHub release metadata for asset pattern matching
  • Handles bun-{os}-{arch}.zip asset pattern

These implementations enable lockfile generation without tool installation by providing platform-specific download URLs directly from the tool's distribution source.

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

Copy link
Copy Markdown
Owner Author

jdx commented Sep 7, 2025

cursor[bot]

This comment was marked as outdated.

Update test expectations to match the new multi-version lockfile format:
- Change [tools.tool] to [[tools.tool]] in test assertions
- Update lockfile use and latest tests for consistency
- Maintain test functionality while adapting to new format

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@jdx jdx force-pushed the 09-07-feat_core_implement_metadata_fetching_for_node.js_and_bun branch from 1f1449f to b5de99a Compare September 7, 2025 18:13
@jdx jdx changed the base branch from 09-07-refactor_backend_extract_platformtarget_to_separate_module to graphite-base/6230 September 7, 2025 18:14
@jdx jdx force-pushed the graphite-base/6230 branch from fd92a47 to 2c494f6 Compare September 7, 2025 18:14
@jdx jdx changed the base branch from graphite-base/6230 to main September 7, 2025 18:14
- Fix import paths for PlatformTarget in bun.rs and node.rs
- Update lock.rs to use correct message for test compatibility
- Ensure all imports use platform_target::PlatformTarget path

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 7, 2025 18:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements metadata fetching capabilities for Node.js and Bun backends to enable lockfile generation without requiring tool installation. The implementation provides platform-specific download URLs by integrating with each tool's distribution mechanisms.

Key changes:

  • Implements get_tarball_url() for Node.js using mirror-based downloads with proper platform mapping
  • Implements get_github_release_info() for Bun using GitHub release-based downloads with asset pattern matching
  • Adds comprehensive test coverage for the new PlatformTarget functionality

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/plugins/core/node.rs Adds tarball URL generation with Node.js platform mapping and mirror URL construction
src/plugins/core/bun.rs Adds GitHub release info generation with Bun-specific platform naming conventions
src/backend/platform_target.rs Adds unit tests for PlatformTarget creation and platform parsing functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/plugins/core/node.rs
Comment on lines +537 to +538

// ========== Lockfile Metadata Fetching Implementation ==========
Copy link

Copilot AI Sep 7, 2025

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.

Copilot uses AI. Check for mistakes.
Comment thread src/plugins/core/bun.rs
Comment on lines +122 to +123

// ========== Lockfile Metadata Fetching Implementation ==========
Copy link

Copilot AI Sep 7, 2025

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.

Copilot uses AI. Check for mistakes.
Comment thread src/plugins/core/node.rs
"macos" => "darwin",
"linux" => "linux",
"windows" => "win32",
other => other,
Copy link

Copilot AI Sep 7, 2025

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 OS names to help with debugging platform mapping issues.

Suggested change
other => other,
other => {
eprintln!(
"Warning: Unknown OS name '{}' encountered in Node.js platform mapping. Passing through as-is.",
other
);
other
},

Copilot uses AI. Check for mistakes.
Comment thread src/plugins/core/node.rs
"aarch64" => "arm64",
"loongarch64" => "loong64",
"riscv64" => "riscv64",
other => other,
Copy link

Copilot AI Sep 7, 2025

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.

Suggested change
other => other,
other => {
eprintln!(
"Warning: Unknown architecture name '{}' encountered in build_platform_slug for target: {:?}. Using as-is.",
other,
target
);
other
},

Copilot uses AI. Check for mistakes.
jdx and others added 2 commits September 7, 2025 18:21
- Fix incorrect Windows platform mapping that generated wrong download URLs
- Extract platform mapping logic into static helper functions
- Add map_os() and map_arch() helpers for consistent OS/arch naming
- Update Bun plugin to use static methods for consistency

The build_platform_slug method was incorrectly mapping Windows to 'win32'
when it should use 'win' to match the existing Node.js download logic.
This fixes potential installation failures for Windows platforms.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…n backends

- Update Node.js os() and arch() functions to use map_os() and map_arch() helpers
- Update Bun os() function to use map_os_to_bun() helper
- Add get_bun_arch_with_variants() helper for complex Bun arch mappings
- Consolidate platform mapping logic for better consistency and maintainability

This ensures all platform mappings go through the same helper functions,
making the code more maintainable and reducing duplication.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
cursor[bot]

This comment was marked as outdated.

jdx and others added 2 commits September 7, 2025 18:32
Remove redundant cfg! conditionals since built_info::CFG_OS and OS
already provide the correct OS names ("linux", "macos", "windows").
The conditionals were just mapping these values back to themselves.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…erns

The get_github_release_info method was using simplified architecture
mapping that didn't account for Bun's complex variants (musl, baseline).
This caused mismatches between lockfile metadata and actual release assets.

Changes:
- Add get_bun_arch_for_target() to handle platform qualifiers
- Update asset pattern generation to use full arch variants
- Support musl, baseline, and musl-baseline variants

This ensures lockfile metadata correctly references existing Bun release
assets like bun-linux-x64-musl.zip and bun-darwin-x64-baseline.zip.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@jdx jdx enabled auto-merge (squash) September 7, 2025 18:43
@jdx jdx merged commit 450a82e into main Sep 7, 2025
18 checks passed
@jdx jdx deleted the 09-07-feat_core_implement_metadata_fetching_for_node.js_and_bun branch September 7, 2025 18:43
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Sep 7, 2025

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.9.5 x -- echo 19.1 ± 0.5 18.1 22.2 1.00
mise x -- echo 19.2 ± 0.6 18.2 22.7 1.01 ± 0.04

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.9.5 env 18.5 ± 0.6 17.6 22.4 1.00
mise env 18.8 ± 0.7 17.5 21.1 1.02 ± 0.05

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.9.5 hook-env 18.5 ± 0.6 17.3 20.1 1.00 ± 0.05
mise hook-env 18.5 ± 0.6 17.4 21.1 1.00

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.9.5 ls 16.6 ± 0.4 15.8 18.0 1.00 ± 0.04
mise ls 16.6 ± 0.6 15.7 20.6 1.00

xtasks/test/perf

Command mise-2025.9.5 mise Variance
install (cached) 165ms ✅ 102ms +61%
ls (cached) 62ms 61ms +1%
bin-paths (cached) 67ms 67ms +0%
task-ls (cached) 472ms 479ms -1%

✅ Performance improvement: install cached is 61%

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.

2 participants