Expand description
============================================================================== Universal Sidecar Vendor - Rust Edition
This program automates downloading and organizing full distributions of various sidecar runtimes (like Node.js) for a Tauri application. It is a Rust rewrite of the original shell script, enhanced with modern features.
Key Features:
- Asynchronous, Concurrent Downloads: Leverages Tokio to download multiple binaries in parallel, significantly speeding up the process.
- Intelligent Caching: Maintains a
Cache.jsonfile to track downloaded versions. It automatically detects if a newer patch version is available for a requested major version and updates the binary. - Git LFS Management: Automatically creates or updates the
.gitattributesfile to ensure large binaries are tracked by Git LFS. - Extensible Design: Easily configured to support new sidecars, versions, and platforms.
- Robust Error Handling: Uses
anyhowfor clear and concise error reporting. - Preserved File Structure: The final output directory structure remains
identical to the original script (
Architecture/SidecarName/Version).
==============================================================================
StructsΒ§
- Download
Cache π - Represents the structure of the
Cache.jsonfile. It uses a HashMap to map a unique key (representing a specific sidecar/version/platform) to the full version string that was last downloaded. - Download
Task π - Contains all the necessary information to perform a single download and installation task. An instance of this struct is created for each binary that needs to be downloaded.
- Node
Version πInfo - Represents a specific version of Node.js as returned by the official index.
Used for deserializing the JSON response from
nodejs.org. - Platform
Target π - Represents a single platform target for which binaries will be downloaded. This struct holds all the necessary identifiers for a given platform.
EnumsΒ§
- Archive
Type π - Defines the type of archive being handled, which determines the extraction logic.
ConstantsΒ§
- LogEnv
- Environment variable for setting the log level.
FunctionsΒ§
- Download
File π - Downloads a file from a URL to a specified path.
- Extract
Archive π - Extracts the contents of a downloaded archive to a target directory. This function now performs a full extraction to ensure a complete distribution.
- Fetch
Node πVersions - Fetches the official Node.js versions index from nodejs.org.
- Fn
- GetBase
Sidecar πDirectory - Returns the root directory where all sidecars will be stored. This is determined dynamically by navigating up from the executableβs location and detecting the SideCar project root. It handles both:
- GetPlatform
Matrix π - Defines the matrix of platforms to target. Each entry specifies how to download and identify binaries for a specific architecture.
- GetSidecars
ToFetch π - Defines which sidecars and versions to fetch. This structure makes it easy to add more sidecars like Deno in the future.
- Logger
- Sets up the global logger for the application.
- Process
Download πTask - The main asynchronous function for processing a single download task. This function is designed to be run concurrently for multiple tasks.
- Resolve
Latest πPatch Version - Resolves a major version string (e.g., β22β) to the latest full patch version (e.g., βv22.3.0β) using the fetched version index.
- Update
Gitattributes π - Manages the
.gitattributesfile to ensure binaries are tracked by Git LFS. If the file does not exist, it is created. If it exists, missing rules are appended. - main π
- Main executable function.