Add zigup step (#1030)
* feat: add zigup step * feat(zigup): add various configuration options * feat(zigup): add cleanup option * feat(zigup): multiple version support and cleanup * refactor(zigup): remove set_default and simplify execution * fix(zigup): always pass path args to zigup for consistent behaviour * refactor(zigup): use shellexpand to expand tildes
This commit is contained in:
committed by
GitHub
parent
4624f11ba5
commit
da270ae7d9
@@ -290,3 +290,28 @@
|
||||
# in the startup file, which might cause the update run to fail.
|
||||
# (default: true)
|
||||
# startup_file = true
|
||||
|
||||
[zigup]
|
||||
# Version strings passed to zigup.
|
||||
# These may be pinned versions such as "0.13.0" or branches such as "master".
|
||||
# Each one will be updated in its own zigup invocation.
|
||||
# (default: ["master"])
|
||||
# target_versions = ["master", "0.13.0"]
|
||||
|
||||
# Specifies the directory that the zig files will be installed to.
|
||||
# If defined, passed with the --install-dir command line flag.
|
||||
# If not defined, zigup will use its default behaviour.
|
||||
# (default: not defined)
|
||||
# install_dir = "~/.zig"
|
||||
|
||||
# Specifies the path of the symlink which will be set to point at the default compiler version.
|
||||
# If defined, passed with the --path-link command line flag.
|
||||
# If not defined, zigup will use its default behaviour.
|
||||
# This is not meaningful if set_default is not enabled.
|
||||
# (default: not defined)
|
||||
# path_link = "~/.bin/zig"
|
||||
|
||||
# If enabled, run `zigup clean` after updating all versions.
|
||||
# If enabled, each updated version above will be marked with `zigup keep`.
|
||||
# (default: false)
|
||||
# cleanup = false
|
||||
|
||||
@@ -171,6 +171,7 @@ pub enum Step {
|
||||
Xcodes,
|
||||
Yadm,
|
||||
Yarn,
|
||||
Zigup,
|
||||
Zvm,
|
||||
}
|
||||
|
||||
@@ -461,6 +462,15 @@ pub struct JuliaConfig {
|
||||
startup_file: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Default, Debug, Merge)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Zigup {
|
||||
target_versions: Option<Vec<String>>,
|
||||
install_dir: Option<String>,
|
||||
path_link: Option<String>,
|
||||
cleanup: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Default, Debug, Merge)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
/// Configuration file
|
||||
@@ -530,6 +540,9 @@ pub struct ConfigFile {
|
||||
|
||||
#[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)]
|
||||
julia: Option<JuliaConfig>,
|
||||
|
||||
#[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)]
|
||||
zigup: Option<Zigup>,
|
||||
}
|
||||
|
||||
fn config_directory() -> PathBuf {
|
||||
@@ -1667,6 +1680,36 @@ impl Config {
|
||||
.and_then(|julia| julia.startup_file)
|
||||
.unwrap_or(true)
|
||||
}
|
||||
|
||||
pub fn zigup_target_versions(&self) -> Vec<String> {
|
||||
self.config_file
|
||||
.zigup
|
||||
.as_ref()
|
||||
.and_then(|zigup| zigup.target_versions.clone())
|
||||
.unwrap_or(vec!["master".to_owned()])
|
||||
}
|
||||
|
||||
pub fn zigup_install_dir(&self) -> Option<&str> {
|
||||
self.config_file
|
||||
.zigup
|
||||
.as_ref()
|
||||
.and_then(|zigup| zigup.install_dir.as_deref())
|
||||
}
|
||||
|
||||
pub fn zigup_path_link(&self) -> Option<&str> {
|
||||
self.config_file
|
||||
.zigup
|
||||
.as_ref()
|
||||
.and_then(|zigup| zigup.path_link.as_deref())
|
||||
}
|
||||
|
||||
pub fn zigup_cleanup(&self) -> bool {
|
||||
self.config_file
|
||||
.zigup
|
||||
.as_ref()
|
||||
.and_then(|zigup| zigup.cleanup)
|
||||
.unwrap_or(false)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -441,6 +441,7 @@ fn run() -> Result<()> {
|
||||
runner.execute(Step::Zvm, "ZVM", || generic::run_zvm(&ctx))?;
|
||||
runner.execute(Step::Aqua, "aqua", || generic::run_aqua(&ctx))?;
|
||||
runner.execute(Step::Bun, "bun", || generic::run_bun(&ctx))?;
|
||||
runner.execute(Step::Zigup, "zigup", || generic::run_zigup(&ctx))?;
|
||||
|
||||
if should_run_powershell {
|
||||
runner.execute(Step::Powershell, "Powershell Modules Update", || {
|
||||
|
||||
@@ -1221,3 +1221,48 @@ pub fn run_bun(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
ctx.run_type().execute(bun).arg("upgrade").status_checked()
|
||||
}
|
||||
|
||||
pub fn run_zigup(ctx: &ExecutionContext) -> Result<()> {
|
||||
let zigup = require("zigup")?;
|
||||
let config = ctx.config();
|
||||
|
||||
print_separator("zigup");
|
||||
|
||||
let mut path_args = Vec::new();
|
||||
if let Some(path) = config.zigup_path_link() {
|
||||
path_args.push("--path-link".to_owned());
|
||||
path_args.push(shellexpand::tilde(path).into_owned());
|
||||
}
|
||||
if let Some(path) = config.zigup_install_dir() {
|
||||
path_args.push("--install-dir".to_owned());
|
||||
path_args.push(shellexpand::tilde(path).into_owned());
|
||||
}
|
||||
|
||||
for zig_version in config.zigup_target_versions() {
|
||||
ctx.run_type()
|
||||
.execute(&zigup)
|
||||
.args(&path_args)
|
||||
.arg("fetch")
|
||||
.arg(&zig_version)
|
||||
.status_checked()?;
|
||||
|
||||
if config.zigup_cleanup() {
|
||||
ctx.run_type()
|
||||
.execute(&zigup)
|
||||
.args(&path_args)
|
||||
.arg("keep")
|
||||
.arg(&zig_version)
|
||||
.status_checked()?;
|
||||
}
|
||||
}
|
||||
|
||||
if config.zigup_cleanup() {
|
||||
ctx.run_type()
|
||||
.execute(zigup)
|
||||
.args(&path_args)
|
||||
.arg("clean")
|
||||
.status_checked()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user