Implemented support for SDKMAN! updates and upgrades (#167)
This commit is contained in:
committed by
Roey Darwish Dror
parent
12fdd326d7
commit
cb180d9c01
@@ -22,6 +22,7 @@ lazy_static! {
|
|||||||
m.insert("vim", Step::Vim);
|
m.insert("vim", Step::Vim);
|
||||||
m.insert("emacs", Step::Emacs);
|
m.insert("emacs", Step::Emacs);
|
||||||
m.insert("gem", Step::Gem);
|
m.insert("gem", Step::Gem);
|
||||||
|
m.insert("sdkman", Step::Sdkman);
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
m.insert("powershell", Step::Powershell);
|
m.insert("powershell", Step::Powershell);
|
||||||
@@ -43,6 +44,8 @@ pub enum Step {
|
|||||||
Emacs,
|
Emacs,
|
||||||
/// Don't upgrade ruby gems
|
/// Don't upgrade ruby gems
|
||||||
Gem,
|
Gem,
|
||||||
|
/// Don't upgrade SDKMAN! and its packages
|
||||||
|
Sdkman,
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
/// Don't update Powershell modules
|
/// Don't update Powershell modules
|
||||||
|
|||||||
12
src/main.rs
12
src/main.rs
@@ -468,6 +468,18 @@ fn run() -> Result<(), Error> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
{
|
||||||
|
if config.should_run(Step::Sdkman) {
|
||||||
|
execute(
|
||||||
|
&mut report,
|
||||||
|
"SDKMAN!",
|
||||||
|
|| unix::run_sdkman(&base_dirs, config.cleanup(), run_type),
|
||||||
|
config.no_retry(),
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !report.data().is_empty() {
|
if !report.data().is_empty() {
|
||||||
print_separator("Summary");
|
print_separator("Summary");
|
||||||
|
|
||||||
|
|||||||
@@ -84,3 +84,51 @@ pub fn run_pearl(run_type: RunType) -> Result<(), Error> {
|
|||||||
|
|
||||||
run_type.execute(&pearl).arg("update").check_run()
|
run_type.execute(&pearl).arg("update").check_run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn run_sdkman(base_dirs: &BaseDirs, cleanup: bool, run_type: RunType) -> Result<(), Error> {
|
||||||
|
let bash_path = require("bash").map(|p| format!("{}", &p.display()))?;
|
||||||
|
|
||||||
|
let sdkman_init_path = env::var("SDKMAN_DIR")
|
||||||
|
.map(PathBuf::from)
|
||||||
|
.unwrap_or_else(|_| base_dirs.home_dir().join(".sdkman"))
|
||||||
|
.join("bin")
|
||||||
|
.join("sdkman-init.sh")
|
||||||
|
.require()
|
||||||
|
.map(|p| format!("{}", &p.display()))?;
|
||||||
|
|
||||||
|
print_separator("SDKMAN!");
|
||||||
|
|
||||||
|
let cmd_selfupdate = format!("source {} && sdk selfupdate", &sdkman_init_path);
|
||||||
|
run_type
|
||||||
|
.execute(&bash_path)
|
||||||
|
.args(&["-c", cmd_selfupdate.as_str()])
|
||||||
|
.check_run()?;
|
||||||
|
|
||||||
|
let cmd_update = format!("source {} && sdk update", &sdkman_init_path);
|
||||||
|
run_type
|
||||||
|
.execute(&bash_path)
|
||||||
|
.args(&["-c", cmd_update.as_str()])
|
||||||
|
.check_run()?;
|
||||||
|
|
||||||
|
let cmd_upgrade = format!("source {} && sdk upgrade", &sdkman_init_path);
|
||||||
|
run_type
|
||||||
|
.execute(&bash_path)
|
||||||
|
.args(&["-c", cmd_upgrade.as_str()])
|
||||||
|
.check_run()?;
|
||||||
|
|
||||||
|
if cleanup {
|
||||||
|
let cmd_flush_archives = format!("source {} && sdk flush archives", &sdkman_init_path);
|
||||||
|
run_type
|
||||||
|
.execute(&bash_path)
|
||||||
|
.args(&["-c", cmd_flush_archives.as_str()])
|
||||||
|
.check_run()?;
|
||||||
|
|
||||||
|
let cmd_flush_temp = format!("source {} && sdk flush temp", &sdkman_init_path);
|
||||||
|
run_type
|
||||||
|
.execute(&bash_path)
|
||||||
|
.args(&["-c", cmd_flush_temp.as_str()])
|
||||||
|
.check_run()?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user