This repository has been archived by the owner on Jul 17, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
138 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
use serde::Deserialize; | ||
use std::collections::HashMap; | ||
|
||
#[derive(Debug, Default, Deserialize)] | ||
#[serde(default, rename_all = "kebab-case")] | ||
pub struct PlatformMapper { | ||
pub archive_prefix: Option<String>, | ||
pub bin_path: Option<String>, | ||
pub checksum_file: Option<String>, | ||
pub download_file: String, | ||
} | ||
|
||
#[derive(Debug, Default, Deserialize)] | ||
#[serde(default, rename_all = "kebab-case")] | ||
pub struct DetectSchema { | ||
pub version_files: Option<Vec<String>>, | ||
} | ||
|
||
#[derive(Debug, Default, Deserialize)] | ||
#[serde(default, rename_all = "kebab-case")] | ||
pub struct InstallSchema { | ||
pub arch: HashMap<String, String>, | ||
pub checksum_url: Option<String>, | ||
pub checksum_url_canary: Option<String>, | ||
pub download_url: String, | ||
pub download_url_canary: Option<String>, | ||
} | ||
|
||
#[derive(Debug, Default, Deserialize)] | ||
#[serde(default, rename_all = "kebab-case")] | ||
pub struct GlobalsSchema { | ||
pub install_args: Option<Vec<String>>, | ||
pub lookup_dirs: Vec<String>, | ||
pub package_prefix: Option<String>, | ||
pub uninstall_args: Option<Vec<String>>, | ||
} | ||
|
||
#[derive(Debug, Deserialize)] | ||
#[serde(default, rename_all = "kebab-case")] | ||
pub struct ResolveSchema { | ||
// Manifest | ||
pub manifest_url: Option<String>, | ||
pub manifest_version_key: String, | ||
// Tags | ||
pub git_url: Option<String>, | ||
pub git_tag_pattern: String, | ||
} | ||
|
||
impl Default for ResolveSchema { | ||
fn default() -> Self { | ||
ResolveSchema { | ||
manifest_url: None, | ||
manifest_version_key: "version".to_string(), | ||
git_url: None, | ||
git_tag_pattern: r"^v?((\d+)\.(\d+)\.(\d+)(-[a-zA-Z\.\d]+)?(+[-a-zA-Z\.\d]+)?)$" | ||
.to_string(), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug, Deserialize)] | ||
#[serde(default, rename_all = "kebab-case")] | ||
pub struct ShimSchema { | ||
pub local: bool, | ||
pub global: bool, | ||
pub parent_bin: Option<String>, | ||
} | ||
|
||
impl Default for ShimSchema { | ||
fn default() -> Self { | ||
ShimSchema { | ||
local: false, | ||
global: true, | ||
parent_bin: None, | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug, Default, Deserialize)] | ||
#[serde(rename_all = "kebab-case")] | ||
pub enum SchemaType { | ||
#[default] | ||
Language, | ||
DependencyManager, | ||
Cli, | ||
} | ||
|
||
#[derive(Debug, Default, Deserialize)] | ||
#[serde(default, rename_all = "kebab-case")] | ||
pub struct Schema { | ||
pub name: String, | ||
#[serde(rename = "type")] | ||
pub type_of: SchemaType, | ||
pub platform: HashMap<String, PlatformMapper>, | ||
|
||
pub detect: DetectSchema, | ||
pub install: InstallSchema, | ||
pub globals: GlobalsSchema, | ||
pub resolve: ResolveSchema, | ||
pub shim: ShimSchema, | ||
} |