From 1e14b3bf284bdc5efbfbad7edc3283d673b87844 Mon Sep 17 00:00:00 2001 From: Thomas Kosiewski Date: Thu, 8 Dec 2022 22:47:57 +0100 Subject: [PATCH 1/9] Add `helm` (#255) (#256) * Add `helm` (#255) Signed-off-by: Thomas Kosiewski * Sorted steps alphabetically Signed-off-by: Thomas Kosiewski Signed-off-by: Thomas Kosiewski --- src/config.rs | 9 +++++---- src/main.rs | 1 + src/steps/generic.rs | 7 +++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/config.rs b/src/config.rs index 552d3d89..91127684 100644 --- a/src/config.rs +++ b/src/config.rs @@ -73,10 +73,10 @@ type Commands = BTreeMap; pub enum Step { Asdf, Atom, + Bin, BrewCask, BrewFormula, Bun, - Bin, Cargo, Chezmoi, Chocolatey, @@ -87,8 +87,8 @@ pub enum Step { Containers, CustomCommands, DebGet, - Distrobox, Deno, + Distrobox, Dotnet, Emacs, Firmware, @@ -100,10 +100,11 @@ pub enum Step { Ghcup, GithubCliExtensions, GitRepos, + GnomeShellExtensions, Go, Guix, Haxelib, - GnomeShellExtensions, + Helm, HomeManager, Jetpack, Julia, @@ -120,8 +121,8 @@ pub enum Step { Pacdef, Pacstall, Pearl, - Pipx, Pip3, + Pipx, Pkg, Pkgin, Powershell, diff --git a/src/main.rs b/src/main.rs index c4f55dff..21c5fa9d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -374,6 +374,7 @@ fn run() -> Result<()> { runner.execute(Step::Deno, "deno", || node::deno_upgrade(&ctx))?; runner.execute(Step::Composer, "composer", || generic::run_composer_update(&ctx))?; runner.execute(Step::Krew, "krew", || generic::run_krew_upgrade(run_type))?; + runner.execute(Step::Helm, "helm", || generic::run_helm_repo_update(run_type))?; runner.execute(Step::Gem, "gem", || generic::run_gem(&base_dirs, run_type))?; runner.execute(Step::RubyGems, "rubygems", || { generic::run_rubygems(&base_dirs, run_type) diff --git a/src/steps/generic.rs b/src/steps/generic.rs index 7abf6c9d..16791199 100644 --- a/src/steps/generic.rs +++ b/src/steps/generic.rs @@ -546,3 +546,10 @@ pub fn update_julia_packages(ctx: &ExecutionContext) -> Result<()> { .args(["-e", "using Pkg; Pkg.update()"]) .status_checked() } + +pub fn run_helm_repo_update(run_type: RunType) -> Result<()> { + let helm = utils::require("helm")?; + + print_separator("Helm"); + run_type.execute(helm).arg("repo").arg("update").status_checked() +} From 9f424f03c3b2a2239b605bcdbc6cf6215700abb2 Mon Sep 17 00:00:00 2001 From: sandal Date: Wed, 14 Dec 2022 09:12:39 +0100 Subject: [PATCH 2/9] Added a step for fetching and building treesitter grammars for helix (#263) --- src/config.rs | 1 + src/main.rs | 1 + src/steps/generic.rs | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/src/config.rs b/src/config.rs index 91127684..76ea4bea 100644 --- a/src/config.rs +++ b/src/config.rs @@ -110,6 +110,7 @@ pub enum Step { Julia, Juliaup, Kakoune, + Helix, Krew, Macports, Mas, diff --git a/src/main.rs b/src/main.rs index 21c5fa9d..83e0039d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -367,6 +367,7 @@ fn run() -> Result<()> { runner.execute(Step::Vim, "The Ultimate vimrc", || vim::upgrade_ultimate_vimrc(&ctx))?; runner.execute(Step::Vim, "voom", || vim::run_voom(&base_dirs, run_type))?; runner.execute(Step::Kakoune, "Kakoune", || kakoune::upgrade_kak_plug(&ctx))?; + runner.execute(Step::Helix, "helix", || generic::run_helix_grammars(&ctx))?; runner.execute(Step::Node, "npm", || node::run_npm_upgrade(&ctx))?; runner.execute(Step::Node, "yarn", || node::run_yarn_upgrade(&ctx))?; runner.execute(Step::Node, "pnpm", || node::run_pnpm_upgrade(&ctx))?; diff --git a/src/steps/generic.rs b/src/steps/generic.rs index 16791199..cb7c64fd 100644 --- a/src/steps/generic.rs +++ b/src/steps/generic.rs @@ -499,6 +499,26 @@ pub fn run_dotnet_upgrade(ctx: &ExecutionContext) -> Result<()> { Ok(()) } +pub fn run_helix_grammars(ctx: &ExecutionContext) -> Result<()> { + utils::require("helix")?; + + print_separator("Helix"); + + ctx.run_type() + .execute(ctx.sudo().as_ref().ok_or(TopgradeError::SudoRequired)?) + .args(["helix", "--grammar", "fetch"]) + .status_checked() + .with_context(|| "Failed to download helix grammars!")?; + + ctx.run_type() + .execute(ctx.sudo().as_ref().ok_or(TopgradeError::SudoRequired)?) + .args(["helix", "--grammar", "build"]) + .status_checked() + .with_context(|| "Failed to build helix grammars!")?; + + Ok(()) +} + pub fn run_raco_update(run_type: RunType) -> Result<()> { let raco = utils::require("raco")?; From 4e56bf07f3e65031bafbcffcd98c55a1cb14bb2f Mon Sep 17 00:00:00 2001 From: Mark Nefedov Date: Thu, 15 Dec 2022 00:42:48 +0300 Subject: [PATCH 3/9] Add options to disable Yarn and Pnpm individually. (#260) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add options to disable Yarn and Pnpm individualy. * cargo fmt Co-authored-by: Thomas Schönauer <37108907+DottoDev@users.noreply.github.com> --- src/config.rs | 2 ++ src/main.rs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/config.rs b/src/config.rs index 76ea4bea..62cad407 100644 --- a/src/config.rs +++ b/src/config.rs @@ -126,6 +126,7 @@ pub enum Step { Pipx, Pkg, Pkgin, + Pnpm, Powershell, Protonup, Raco, @@ -154,6 +155,7 @@ pub enum Step { Winget, Wsl, Yadm, + Yarn, } #[derive(Deserialize, Default, Debug)] diff --git a/src/main.rs b/src/main.rs index 83e0039d..dc4b85e3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -369,8 +369,8 @@ fn run() -> Result<()> { runner.execute(Step::Kakoune, "Kakoune", || kakoune::upgrade_kak_plug(&ctx))?; runner.execute(Step::Helix, "helix", || generic::run_helix_grammars(&ctx))?; runner.execute(Step::Node, "npm", || node::run_npm_upgrade(&ctx))?; - runner.execute(Step::Node, "yarn", || node::run_yarn_upgrade(&ctx))?; - runner.execute(Step::Node, "pnpm", || node::run_pnpm_upgrade(&ctx))?; + runner.execute(Step::Yarn, "yarn", || node::run_yarn_upgrade(&ctx))?; + runner.execute(Step::Pnpm, "pnpm", || node::run_pnpm_upgrade(&ctx))?; runner.execute(Step::Containers, "Containers", || containers::run_containers(&ctx))?; runner.execute(Step::Deno, "deno", || node::deno_upgrade(&ctx))?; runner.execute(Step::Composer, "composer", || generic::run_composer_update(&ctx))?; From 81928f55a2d9f84c6a282342656c82535b7d7871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sch=C3=B6nauer?= <37108907+DottoDev@users.noreply.github.com> Date: Thu, 15 Dec 2022 11:34:18 +0000 Subject: [PATCH 4/9] Fix notify not available (#257) --- src/terminal.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/terminal.rs b/src/terminal.rs index 8d17b3ad..3c6d03c1 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -21,8 +21,9 @@ use which_crate::which; use crate::command::CommandExt; use crate::report::StepResult; #[cfg(target_os = "linux")] +use crate::terminal; +#[cfg(target_os = "linux")] use crate::utils::which; - lazy_static! { static ref TERMINAL: Mutex = Mutex::new(Terminal::new()); } @@ -105,7 +106,7 @@ impl Terminal { command.args(["-a", "Topgrade", "Topgrade"]); command.arg(message.as_ref()); if let Err(err) = command.output_checked() { - tracing::error!("{err:?}"); + terminal::print_warning("Senfing notification failed with {err:?}"); } } } From 9553be04e4ed637baae7aaa66d9ffddb93fdf972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sch=C3=B6nauer?= <37108907+DottoDev@users.noreply.github.com> Date: Thu, 15 Dec 2022 11:39:25 +0000 Subject: [PATCH 5/9] Fixes vcpkg when installed as root (#266) --- src/main.rs | 2 +- src/steps/generic.rs | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index dc4b85e3..c071b8a1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -348,7 +348,7 @@ fn run() -> Result<()> { runner.execute(Step::Go, "gup", || go::run_go_gup(run_type))?; runner.execute(Step::Emacs, "Emacs", || emacs.upgrade(&ctx))?; runner.execute(Step::Opam, "opam", || generic::run_opam_update(&ctx))?; - runner.execute(Step::Vcpkg, "vcpkg", || generic::run_vcpkg_update(run_type))?; + runner.execute(Step::Vcpkg, "vcpkg", || generic::run_vcpkg_update(&ctx))?; runner.execute(Step::Pipx, "pipx", || generic::run_pipx_update(run_type))?; runner.execute(Step::Conda, "conda", || generic::run_conda_update(&ctx))?; runner.execute(Step::Pip3, "pip3", || generic::run_pip3_update(run_type))?; diff --git a/src/steps/generic.rs b/src/steps/generic.rs index cb7c64fd..375702a9 100644 --- a/src/steps/generic.rs +++ b/src/steps/generic.rs @@ -260,14 +260,27 @@ pub fn run_opam_update(ctx: &ExecutionContext) -> Result<()> { Ok(()) } -pub fn run_vcpkg_update(run_type: RunType) -> Result<()> { +pub fn run_vcpkg_update(ctx: &ExecutionContext) -> Result<()> { let vcpkg = utils::require("vcpkg")?; print_separator("vcpkg"); - run_type - .execute(vcpkg) - .args(["upgrade", "--no-dry-run"]) - .status_checked() + #[cfg(unix)] + let is_root_install = !&vcpkg.starts_with("/home"); + + #[cfg(not(unix))] + let is_root_install = false; + + let mut command = if is_root_install { + ctx.run_type().execute(&vcpkg) + } else { + let mut c = ctx + .run_type() + .execute(ctx.sudo().as_ref().ok_or(TopgradeError::SudoRequired)?); + c.arg(&vcpkg); + c + }; + + command.args(["upgrade", "--no-dry-run"]).status_checked() } pub fn run_pipx_update(run_type: RunType) -> Result<()> { From 78a491a97642af03b0c5a97933ee253170d36648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sch=C3=B6nauer?= <37108907+DottoDev@users.noreply.github.com> Date: Thu, 15 Dec 2022 20:27:27 +0000 Subject: [PATCH 6/9] Fixes rubygems on .deb distros (#268) Fixes rubygem on systems with the .deb ruby package --- src/steps/generic.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/steps/generic.rs b/src/steps/generic.rs index 375702a9..0af44507 100644 --- a/src/steps/generic.rs +++ b/src/steps/generic.rs @@ -89,7 +89,11 @@ pub fn run_rubygems(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> { print_separator("RubyGems"); - run_type.execute(gem).args(["update", "--system"]).status_checked() + if !std::path::Path::new("/usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb").exists() { + run_type.execute(gem).args(["update", "--system"]).status_checked() + } else { + Ok(()) + } } pub fn run_haxelib_update(ctx: &ExecutionContext) -> Result<()> { From 33cea0e5b67162f364234e4af91d738502af9be6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sch=C3=B6nauer?= <37108907+DottoDev@users.noreply.github.com> Date: Sun, 18 Dec 2022 14:07:31 +0000 Subject: [PATCH 7/9] 10.2.3 release (#271) 10.2.3 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 70ddef69..b4fd4c9f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2055,7 +2055,7 @@ dependencies = [ [[package]] name = "topgrade" -version = "10.2.2" +version = "10.2.3" dependencies = [ "cfg-if", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 0a567ad2..16152be3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ keywords = ["upgrade", "update"] license = "GPL-3.0" # license-file = "LICENSE" repository = "https://github.com/topgrade-rs/topgrade" -version = "10.2.2" +version = "10.2.3" authors = ["Roey Darwish Dror ", "Thomas Schönauer "] exclude = ["doc/screenshot.gif"] edition = "2021" From ee353ccb6652eb29957af41031cbd5fdc1411a31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sch=C3=B6nauer?= <37108907+DottoDev@users.noreply.github.com> Date: Sun, 18 Dec 2022 14:11:36 +0000 Subject: [PATCH 8/9] adds fish_update_completions to fish step (#270) --- src/steps/os/unix.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/steps/os/unix.rs b/src/steps/os/unix.rs index 9f89df5b..6d30ac92 100644 --- a/src/steps/os/unix.rs +++ b/src/steps/os/unix.rs @@ -102,6 +102,12 @@ pub fn run_fisher(run_type: RunType) -> Result<()> { .and_then(|output| Path::new(&output.stdout.trim()).require().map(|_| ())) .map_err(|err| SkipStep(format!("`fish_plugins` path doesn't exist: {err}")))?; + Command::new(&fish) + .args(["-c", "fish_update_completions"]) + .output_checked_utf8() + .map(|_| ()) + .map_err(|_| SkipStep("`fish_update_completions` is not available".to_owned()))?; + print_separator("Fisher"); let version_str = run_type From 56a717dcc63922399dc84408a8cb96eb44c291cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sch=C3=B6nauer?= <37108907+DottoDev@users.noreply.github.com> Date: Sun, 18 Dec 2022 14:12:36 +0000 Subject: [PATCH 9/9] Fixes dotnet if dotnet tool is not available (#229) * Fixes dotnet if dotnet tool si not available * dotnet: multi-lang support * Fixes dotnet for non-english terminals --- src/steps/generic.rs | 49 +++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/src/steps/generic.rs b/src/steps/generic.rs index 0af44507..2c30dfd6 100644 --- a/src/steps/generic.rs +++ b/src/steps/generic.rs @@ -488,31 +488,34 @@ pub fn run_composer_update(ctx: &ExecutionContext) -> Result<()> { pub fn run_dotnet_upgrade(ctx: &ExecutionContext) -> Result<()> { let dotnet = utils::require("dotnet")?; - let output = Command::new(dotnet) - .args(["tool", "list", "--global"]) - .output_checked_utf8()?; + let dotnet_help_output = ctx.run_type().execute(&dotnet).arg("-h").output().err().unwrap(); - if !output.stdout.starts_with("Package Id") { - return Err(SkipStep(String::from("dotnet did not output packages")).into()); + if dotnet_help_output.to_string().contains("tool") { + let output = Command::new(dotnet) + .args(["tool", "list", "--global"]) + .output_checked_utf8()?; + + if !output.stdout.starts_with("Package Id") { + return Err(SkipStep(String::from("dotnet did not output packages")).into()); + } + + let mut packages = output.stdout.lines().skip(2).filter(|line| !line.is_empty()).peekable(); + + if packages.peek().is_none() { + return Err(SkipStep(String::from("No dotnet global tools installed")).into()); + } + + print_separator(".NET"); + + for package in packages { + let package_name = package.split_whitespace().next().unwrap(); + ctx.run_type() + .execute("dotnet") + .args(["tool", "update", package_name, "--global"]) + .status_checked() + .with_context(|| format!("Failed to update .NET package {package_name}"))?; + } } - - let mut packages = output.stdout.lines().skip(2).filter(|line| !line.is_empty()).peekable(); - - if packages.peek().is_none() { - return Err(SkipStep(String::from("No dotnet global tools installed")).into()); - } - - print_separator(".NET"); - - for package in packages { - let package_name = package.split_whitespace().next().unwrap(); - ctx.run_type() - .execute("dotnet") - .args(["tool", "update", package_name, "--global"]) - .status_checked() - .with_context(|| format!("Failed to update .NET package {package_name}"))?; - } - Ok(()) }