Skip to content

Commit

Permalink
10.2.3 release (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
s34m authored Dec 18, 2022
2 parents 51e7a31 + 56a717d commit eb51be0
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>", "Thomas Schönauer <[email protected]>"]
exclude = ["doc/screenshot.gif"]
edition = "2021"
Expand Down
12 changes: 8 additions & 4 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ type Commands = BTreeMap<String, String>;
pub enum Step {
Asdf,
Atom,
Bin,
BrewCask,
BrewFormula,
Bun,
Bin,
Cargo,
Chezmoi,
Chocolatey,
Expand All @@ -87,8 +87,8 @@ pub enum Step {
Containers,
CustomCommands,
DebGet,
Distrobox,
Deno,
Distrobox,
Dotnet,
Emacs,
Firmware,
Expand All @@ -100,15 +100,17 @@ pub enum Step {
Ghcup,
GithubCliExtensions,
GitRepos,
GnomeShellExtensions,
Go,
Guix,
Haxelib,
GnomeShellExtensions,
Helm,
HomeManager,
Jetpack,
Julia,
Juliaup,
Kakoune,
Helix,
Krew,
Macports,
Mas,
Expand All @@ -120,10 +122,11 @@ pub enum Step {
Pacdef,
Pacstall,
Pearl,
Pipx,
Pip3,
Pipx,
Pkg,
Pkgin,
Pnpm,
Powershell,
Protonup,
Raco,
Expand Down Expand Up @@ -152,6 +155,7 @@ pub enum Step {
Winget,
Wsl,
Yadm,
Yarn,
}

#[derive(Deserialize, Default, Debug)]
Expand Down
8 changes: 5 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))?;
Expand All @@ -367,13 +367,15 @@ 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))?;
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))?;
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)
Expand Down
95 changes: 71 additions & 24 deletions src/steps/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()> {
Expand Down Expand Up @@ -260,14 +264,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<()> {
Expand Down Expand Up @@ -471,30 +488,53 @@ 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()?;

let mut packages = output.stdout.lines().skip(2).filter(|line| !line.is_empty()).peekable();
if !output.stdout.starts_with("Package Id") {
return Err(SkipStep(String::from("dotnet did not output packages")).into());
}

if packages.peek().is_none() {
return Err(SkipStep(String::from("No dotnet global tools installed")).into());
}
let mut packages = output.stdout.lines().skip(2).filter(|line| !line.is_empty()).peekable();

print_separator(".NET");
if packages.peek().is_none() {
return Err(SkipStep(String::from("No dotnet global tools installed")).into());
}

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}"))?;
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(())
}

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(())
}
Expand Down Expand Up @@ -546,3 +586,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()
}
6 changes: 6 additions & 0 deletions src/steps/os/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Terminal> = Mutex::new(Terminal::new());
}
Expand Down Expand Up @@ -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:?}");
}
}
}
Expand Down

0 comments on commit eb51be0

Please sign in to comment.