Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb51be0732 | ||
|
|
56a717dcc6 | ||
|
|
ee353ccb66 | ||
|
|
33cea0e5b6 | ||
|
|
78a491a976 | ||
|
|
9553be04e4 | ||
|
|
81928f55a2 | ||
|
|
4e56bf07f3 | ||
|
|
9f424f03c3 | ||
|
|
1e14b3bf28 |
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -2055,7 +2055,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "topgrade"
|
name = "topgrade"
|
||||||
version = "10.2.2"
|
version = "10.2.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ keywords = ["upgrade", "update"]
|
|||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
# license-file = "LICENSE"
|
# license-file = "LICENSE"
|
||||||
repository = "https://github.com/topgrade-rs/topgrade"
|
repository = "https://github.com/topgrade-rs/topgrade"
|
||||||
version = "10.2.2"
|
version = "10.2.3"
|
||||||
authors = ["Roey Darwish Dror <roey.ghost@gmail.com>", "Thomas Schönauer <t.schoenauer@hgs-wt.at>"]
|
authors = ["Roey Darwish Dror <roey.ghost@gmail.com>", "Thomas Schönauer <t.schoenauer@hgs-wt.at>"]
|
||||||
exclude = ["doc/screenshot.gif"]
|
exclude = ["doc/screenshot.gif"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|||||||
@@ -73,10 +73,10 @@ type Commands = BTreeMap<String, String>;
|
|||||||
pub enum Step {
|
pub enum Step {
|
||||||
Asdf,
|
Asdf,
|
||||||
Atom,
|
Atom,
|
||||||
|
Bin,
|
||||||
BrewCask,
|
BrewCask,
|
||||||
BrewFormula,
|
BrewFormula,
|
||||||
Bun,
|
Bun,
|
||||||
Bin,
|
|
||||||
Cargo,
|
Cargo,
|
||||||
Chezmoi,
|
Chezmoi,
|
||||||
Chocolatey,
|
Chocolatey,
|
||||||
@@ -87,8 +87,8 @@ pub enum Step {
|
|||||||
Containers,
|
Containers,
|
||||||
CustomCommands,
|
CustomCommands,
|
||||||
DebGet,
|
DebGet,
|
||||||
Distrobox,
|
|
||||||
Deno,
|
Deno,
|
||||||
|
Distrobox,
|
||||||
Dotnet,
|
Dotnet,
|
||||||
Emacs,
|
Emacs,
|
||||||
Firmware,
|
Firmware,
|
||||||
@@ -100,15 +100,17 @@ pub enum Step {
|
|||||||
Ghcup,
|
Ghcup,
|
||||||
GithubCliExtensions,
|
GithubCliExtensions,
|
||||||
GitRepos,
|
GitRepos,
|
||||||
|
GnomeShellExtensions,
|
||||||
Go,
|
Go,
|
||||||
Guix,
|
Guix,
|
||||||
Haxelib,
|
Haxelib,
|
||||||
GnomeShellExtensions,
|
Helm,
|
||||||
HomeManager,
|
HomeManager,
|
||||||
Jetpack,
|
Jetpack,
|
||||||
Julia,
|
Julia,
|
||||||
Juliaup,
|
Juliaup,
|
||||||
Kakoune,
|
Kakoune,
|
||||||
|
Helix,
|
||||||
Krew,
|
Krew,
|
||||||
Macports,
|
Macports,
|
||||||
Mas,
|
Mas,
|
||||||
@@ -120,10 +122,11 @@ pub enum Step {
|
|||||||
Pacdef,
|
Pacdef,
|
||||||
Pacstall,
|
Pacstall,
|
||||||
Pearl,
|
Pearl,
|
||||||
Pipx,
|
|
||||||
Pip3,
|
Pip3,
|
||||||
|
Pipx,
|
||||||
Pkg,
|
Pkg,
|
||||||
Pkgin,
|
Pkgin,
|
||||||
|
Pnpm,
|
||||||
Powershell,
|
Powershell,
|
||||||
Protonup,
|
Protonup,
|
||||||
Raco,
|
Raco,
|
||||||
@@ -152,6 +155,7 @@ pub enum Step {
|
|||||||
Winget,
|
Winget,
|
||||||
Wsl,
|
Wsl,
|
||||||
Yadm,
|
Yadm,
|
||||||
|
Yarn,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Default, Debug)]
|
#[derive(Deserialize, Default, Debug)]
|
||||||
|
|||||||
@@ -348,7 +348,7 @@ fn run() -> Result<()> {
|
|||||||
runner.execute(Step::Go, "gup", || go::run_go_gup(run_type))?;
|
runner.execute(Step::Go, "gup", || go::run_go_gup(run_type))?;
|
||||||
runner.execute(Step::Emacs, "Emacs", || emacs.upgrade(&ctx))?;
|
runner.execute(Step::Emacs, "Emacs", || emacs.upgrade(&ctx))?;
|
||||||
runner.execute(Step::Opam, "opam", || generic::run_opam_update(&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::Pipx, "pipx", || generic::run_pipx_update(run_type))?;
|
||||||
runner.execute(Step::Conda, "conda", || generic::run_conda_update(&ctx))?;
|
runner.execute(Step::Conda, "conda", || generic::run_conda_update(&ctx))?;
|
||||||
runner.execute(Step::Pip3, "pip3", || generic::run_pip3_update(run_type))?;
|
runner.execute(Step::Pip3, "pip3", || generic::run_pip3_update(run_type))?;
|
||||||
@@ -367,13 +367,15 @@ fn run() -> Result<()> {
|
|||||||
runner.execute(Step::Vim, "The Ultimate vimrc", || vim::upgrade_ultimate_vimrc(&ctx))?;
|
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::Vim, "voom", || vim::run_voom(&base_dirs, run_type))?;
|
||||||
runner.execute(Step::Kakoune, "Kakoune", || kakoune::upgrade_kak_plug(&ctx))?;
|
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, "npm", || node::run_npm_upgrade(&ctx))?;
|
||||||
runner.execute(Step::Node, "yarn", || node::run_yarn_upgrade(&ctx))?;
|
runner.execute(Step::Yarn, "yarn", || node::run_yarn_upgrade(&ctx))?;
|
||||||
runner.execute(Step::Node, "pnpm", || node::run_pnpm_upgrade(&ctx))?;
|
runner.execute(Step::Pnpm, "pnpm", || node::run_pnpm_upgrade(&ctx))?;
|
||||||
runner.execute(Step::Containers, "Containers", || containers::run_containers(&ctx))?;
|
runner.execute(Step::Containers, "Containers", || containers::run_containers(&ctx))?;
|
||||||
runner.execute(Step::Deno, "deno", || node::deno_upgrade(&ctx))?;
|
runner.execute(Step::Deno, "deno", || node::deno_upgrade(&ctx))?;
|
||||||
runner.execute(Step::Composer, "composer", || generic::run_composer_update(&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::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::Gem, "gem", || generic::run_gem(&base_dirs, run_type))?;
|
||||||
runner.execute(Step::RubyGems, "rubygems", || {
|
runner.execute(Step::RubyGems, "rubygems", || {
|
||||||
generic::run_rubygems(&base_dirs, run_type)
|
generic::run_rubygems(&base_dirs, run_type)
|
||||||
|
|||||||
@@ -89,7 +89,11 @@ pub fn run_rubygems(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
|
|||||||
|
|
||||||
print_separator("RubyGems");
|
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<()> {
|
pub fn run_haxelib_update(ctx: &ExecutionContext) -> Result<()> {
|
||||||
@@ -260,14 +264,27 @@ pub fn run_opam_update(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_vcpkg_update(run_type: RunType) -> Result<()> {
|
pub fn run_vcpkg_update(ctx: &ExecutionContext) -> Result<()> {
|
||||||
let vcpkg = utils::require("vcpkg")?;
|
let vcpkg = utils::require("vcpkg")?;
|
||||||
print_separator("vcpkg");
|
print_separator("vcpkg");
|
||||||
|
|
||||||
run_type
|
#[cfg(unix)]
|
||||||
.execute(vcpkg)
|
let is_root_install = !&vcpkg.starts_with("/home");
|
||||||
.args(["upgrade", "--no-dry-run"])
|
|
||||||
.status_checked()
|
#[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<()> {
|
pub fn run_pipx_update(run_type: RunType) -> Result<()> {
|
||||||
@@ -471,30 +488,53 @@ pub fn run_composer_update(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
pub fn run_dotnet_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
pub fn run_dotnet_upgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||||
let dotnet = utils::require("dotnet")?;
|
let dotnet = utils::require("dotnet")?;
|
||||||
|
|
||||||
let output = Command::new(dotnet)
|
let dotnet_help_output = ctx.run_type().execute(&dotnet).arg("-h").output().err().unwrap();
|
||||||
.args(["tool", "list", "--global"])
|
|
||||||
.output_checked_utf8()?;
|
|
||||||
|
|
||||||
if !output.stdout.starts_with("Package Id") {
|
if dotnet_help_output.to_string().contains("tool") {
|
||||||
return Err(SkipStep(String::from("dotnet did not output packages")).into());
|
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}"))?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
let mut packages = output.stdout.lines().skip(2).filter(|line| !line.is_empty()).peekable();
|
pub fn run_helix_grammars(ctx: &ExecutionContext) -> Result<()> {
|
||||||
|
utils::require("helix")?;
|
||||||
|
|
||||||
if packages.peek().is_none() {
|
print_separator("Helix");
|
||||||
return Err(SkipStep(String::from("No dotnet global tools installed")).into());
|
|
||||||
}
|
|
||||||
|
|
||||||
print_separator(".NET");
|
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!")?;
|
||||||
|
|
||||||
for package in packages {
|
ctx.run_type()
|
||||||
let package_name = package.split_whitespace().next().unwrap();
|
.execute(ctx.sudo().as_ref().ok_or(TopgradeError::SudoRequired)?)
|
||||||
ctx.run_type()
|
.args(["helix", "--grammar", "build"])
|
||||||
.execute("dotnet")
|
.status_checked()
|
||||||
.args(["tool", "update", package_name, "--global"])
|
.with_context(|| "Failed to build helix grammars!")?;
|
||||||
.status_checked()
|
|
||||||
.with_context(|| format!("Failed to update .NET package {package_name}"))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -546,3 +586,10 @@ pub fn update_julia_packages(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
.args(["-e", "using Pkg; Pkg.update()"])
|
.args(["-e", "using Pkg; Pkg.update()"])
|
||||||
.status_checked()
|
.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()
|
||||||
|
}
|
||||||
|
|||||||
@@ -102,6 +102,12 @@ pub fn run_fisher(run_type: RunType) -> Result<()> {
|
|||||||
.and_then(|output| Path::new(&output.stdout.trim()).require().map(|_| ()))
|
.and_then(|output| Path::new(&output.stdout.trim()).require().map(|_| ()))
|
||||||
.map_err(|err| SkipStep(format!("`fish_plugins` path doesn't exist: {err}")))?;
|
.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");
|
print_separator("Fisher");
|
||||||
|
|
||||||
let version_str = run_type
|
let version_str = run_type
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ use which_crate::which;
|
|||||||
use crate::command::CommandExt;
|
use crate::command::CommandExt;
|
||||||
use crate::report::StepResult;
|
use crate::report::StepResult;
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
|
use crate::terminal;
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
use crate::utils::which;
|
use crate::utils::which;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref TERMINAL: Mutex<Terminal> = Mutex::new(Terminal::new());
|
static ref TERMINAL: Mutex<Terminal> = Mutex::new(Terminal::new());
|
||||||
}
|
}
|
||||||
@@ -105,7 +106,7 @@ impl Terminal {
|
|||||||
command.args(["-a", "Topgrade", "Topgrade"]);
|
command.args(["-a", "Topgrade", "Topgrade"]);
|
||||||
command.arg(message.as_ref());
|
command.arg(message.as_ref());
|
||||||
if let Err(err) = command.output_checked() {
|
if let Err(err) = command.output_checked() {
|
||||||
tracing::error!("{err:?}");
|
terminal::print_warning("Senfing notification failed with {err:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user