diff --git a/src/config.rs b/src/config.rs index deafae4f..8919efaa 100644 --- a/src/config.rs +++ b/src/config.rs @@ -163,6 +163,7 @@ pub enum Step { Vim, VoltaPackages, Vscode, + Vscodium, Waydroid, Winget, Wsl, diff --git a/src/main.rs b/src/main.rs index 63551426..73a03f0d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -372,6 +372,9 @@ fn run() -> Result<()> { runner.execute(Step::Vscode, "Visual Studio Code extensions", || { generic::run_vscode_extensions_update(&ctx) })?; + runner.execute(Step::Vscodium, "VSCodium extensions", || { + generic::run_vscodium_extensions_update(&ctx) + })?; runner.execute(Step::Conda, "conda", || generic::run_conda_update(&ctx))?; runner.execute(Step::Mamba, "mamba", || generic::run_mamba_update(&ctx))?; runner.execute(Step::Pixi, "pixi", || generic::run_pixi_update(&ctx))?; diff --git a/src/steps/generic.rs b/src/steps/generic.rs index 760845be..b6e1337f 100644 --- a/src/steps/generic.rs +++ b/src/steps/generic.rs @@ -400,6 +400,48 @@ pub fn run_vcpkg_update(ctx: &ExecutionContext) -> Result<()> { command.args(["upgrade", "--no-dry-run"]).status_checked() } +/// Make VSCodium a separate step because: +/// +/// 1. Users could use both VSCode and VSCoium +/// 2. Just in case, VSCodium could have incompatible changes with VSCode +pub fn run_vscodium_extensions_update(ctx: &ExecutionContext) -> Result<()> { + // Calling vscodoe in WSL may install a server instead of updating extensions (https://github.com/topgrade-rs/topgrade/issues/594#issuecomment-1782157367) + if is_wsl()? { + return Err(SkipStep(String::from("Should not run in WSL")).into()); + } + + let vscodium = require("codium")?; + + // VSCode has update command only since 1.86 version ("january 2024" update), disable the update for prior versions + // Use command `code --version` which returns 3 lines: version, git commit, instruction set. We parse only the first one + // + // This should apply to VSCodium as well. + let version: Result = match Command::new(&vscodium) + .arg("--version") + .output_checked_utf8()? + .stdout + .lines() + .next() + { + Some(item) => Version::parse(item).map_err(|err| err.into()), + _ => return Err(SkipStep(String::from("Cannot find vscodium version")).into()), + }; + + if !matches!(version, Ok(version) if version >= Version::new(1, 86, 0)) { + return Err(SkipStep(String::from( + "Too old vscodium version to have update extensions command", + )) + .into()); + } + + print_separator("VSCodium extensions"); + + ctx.run_type() + .execute(vscodium) + .arg("--update-extensions") + .status_checked() +} + pub fn run_vscode_extensions_update(ctx: &ExecutionContext) -> Result<()> { // Calling vscode in WSL may install a server instead of updating extensions (https://github.com/topgrade-rs/topgrade/issues/594#issuecomment-1782157367) if is_wsl()? {