Crate Download

Crate Download 

Source

StructsΒ§

DownloadCache πŸ”’
Represents the structure of the Cache.json file. It uses a HashMap to map a unique key (representing a specific sidecar/version/platform) to the full version string that was last downloaded.
DownloadTask πŸ”’
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.
NodeVersionInfo πŸ”’
Represents a specific version of Node.js as returned by the official index. Used for deserializing the JSON response from nodejs.org.
PlatformTarget πŸ”’
Represents a single platform target for which binaries will be downloaded. This struct holds all the necessary identifiers for a given platform.

EnumsΒ§

ArchiveType πŸ”’
Defines the type of archive being handled, which determines the extraction logic.

ConstantsΒ§

LogEnv
Environment variable for setting the log level.

FunctionsΒ§

DownloadFile πŸ”’
Downloads a file from a URL to a specified path.
ExtractArchive πŸ”’
Extracts the contents of a downloaded archive to a target directory. This function now performs a full extraction to ensure a complete distribution.
FetchNodeVersions πŸ”’
Fetches the official Node.js versions index from nodejs.org.
Fn
GetBaseSidecarDirectory πŸ”’
Returns the root directory where all sidecars will be stored. This is determined dynamically by navigating up from the executable’s location. It assumes the executable is located in a path like .../SideCar/Target/release/, and it will resolve the base path to .../SideCar/.
GetPlatformMatrix πŸ”’
Defines the matrix of platforms to target. Each entry specifies how to download and identify binaries for a specific architecture.
GetSidecarsToFetch πŸ”’
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.
ProcessDownloadTask πŸ”’
The main asynchronous function for processing a single download task. This function is designed to be run concurrently for multiple tasks.
ResolveLatestPatchVersion πŸ”’
Resolves a major version string (e.g., β€œ22”) to the latest full patch version (e.g., β€œv22.3.0”) using the fetched version index.
UpdateGitattributes πŸ”’
Manages the .gitattributes file 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.