committed by
GitHub
parent
af3f5ddc76
commit
dcf58911bd
9
.vscode/topgrade.code-snippets
vendored
9
.vscode/topgrade.code-snippets
vendored
@@ -19,7 +19,7 @@
|
|||||||
"scope": "rust",
|
"scope": "rust",
|
||||||
"prefix": "skipstep",
|
"prefix": "skipstep",
|
||||||
"body": [
|
"body": [
|
||||||
"return Err(SkipStep(format!(\"$1\").into()));"
|
"return Err(SkipStep(format!(\"$1\")).into());"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"Step": {
|
"Step": {
|
||||||
@@ -31,5 +31,12 @@
|
|||||||
" Ok(())",
|
" Ok(())",
|
||||||
"}"
|
"}"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"macos": {
|
||||||
|
"scope": "rust",
|
||||||
|
"prefix": "macos",
|
||||||
|
"body": [
|
||||||
|
"#[cfg(target_os = \"macos\")]"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ fn run() -> Result<()> {
|
|||||||
runner.execute(Step::ConfigUpdate, "config-update", || linux::run_config_update(&ctx))?;
|
runner.execute(Step::ConfigUpdate, "config-update", || linux::run_config_update(&ctx))?;
|
||||||
|
|
||||||
runner.execute(Step::BrewFormula, "Brew", || {
|
runner.execute(Step::BrewFormula, "Brew", || {
|
||||||
unix::run_brew_formula(&ctx, unix::BrewVariant::Linux)
|
unix::run_brew_formula(&ctx, unix::BrewVariant::Path)
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,12 +172,18 @@ fn run() -> Result<()> {
|
|||||||
runner.execute(Step::BrewFormula, "Brew (Intel)", || {
|
runner.execute(Step::BrewFormula, "Brew (Intel)", || {
|
||||||
unix::run_brew_formula(&ctx, unix::BrewVariant::MacIntel)
|
unix::run_brew_formula(&ctx, unix::BrewVariant::MacIntel)
|
||||||
})?;
|
})?;
|
||||||
|
runner.execute(Step::BrewFormula, "Brew", || {
|
||||||
|
unix::run_brew_formula(&ctx, unix::BrewVariant::Path)
|
||||||
|
})?;
|
||||||
runner.execute(Step::BrewCask, "Brew Cask (ARM)", || {
|
runner.execute(Step::BrewCask, "Brew Cask (ARM)", || {
|
||||||
unix::run_brew_cask(&ctx, unix::BrewVariant::MacArm)
|
unix::run_brew_cask(&ctx, unix::BrewVariant::MacArm)
|
||||||
})?;
|
})?;
|
||||||
runner.execute(Step::BrewCask, "Brew Cask (Intel)", || {
|
runner.execute(Step::BrewCask, "Brew Cask (Intel)", || {
|
||||||
unix::run_brew_cask(&ctx, unix::BrewVariant::MacIntel)
|
unix::run_brew_cask(&ctx, unix::BrewVariant::MacIntel)
|
||||||
})?;
|
})?;
|
||||||
|
runner.execute(Step::BrewCask, "Brew Cask", || {
|
||||||
|
unix::run_brew_cask(&ctx, unix::BrewVariant::Path)
|
||||||
|
})?;
|
||||||
runner.execute(Step::Macports, "MacPorts", || macos::run_macports(&ctx))?;
|
runner.execute(Step::Macports, "MacPorts", || macos::run_macports(&ctx))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
#[cfg(target_os = "linux")]
|
use crate::error::{SkipStep, TopgradeError};
|
||||||
use crate::error::SkipStep;
|
|
||||||
use crate::error::TopgradeError;
|
|
||||||
use crate::execution_context::ExecutionContext;
|
use crate::execution_context::ExecutionContext;
|
||||||
use crate::executor::{CommandExt, Executor, ExecutorExitStatus, RunType};
|
use crate::executor::{CommandExt, Executor, ExecutorExitStatus, RunType};
|
||||||
use crate::terminal::print_separator;
|
use crate::terminal::print_separator;
|
||||||
@@ -23,7 +21,7 @@ const ARM_BREW: &str = "/opt/homebrew/bin/brew";
|
|||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub enum BrewVariant {
|
pub enum BrewVariant {
|
||||||
Linux,
|
Path,
|
||||||
MacIntel,
|
MacIntel,
|
||||||
MacArm,
|
MacArm,
|
||||||
}
|
}
|
||||||
@@ -31,12 +29,17 @@ pub enum BrewVariant {
|
|||||||
impl BrewVariant {
|
impl BrewVariant {
|
||||||
fn binary_name(self) -> &'static str {
|
fn binary_name(self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
BrewVariant::Linux => "brew",
|
BrewVariant::Path => "brew",
|
||||||
BrewVariant::MacIntel => INTEL_BREW,
|
BrewVariant::MacIntel => INTEL_BREW,
|
||||||
BrewVariant::MacArm => ARM_BREW,
|
BrewVariant::MacArm => ARM_BREW,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
fn is_path(&self) -> bool {
|
||||||
|
matches!(self, BrewVariant::Path)
|
||||||
|
}
|
||||||
|
|
||||||
fn both_both_exist() -> bool {
|
fn both_both_exist() -> bool {
|
||||||
Path::new(INTEL_BREW).exists() && Path::new(ARM_BREW).exists()
|
Path::new(INTEL_BREW).exists() && Path::new(ARM_BREW).exists()
|
||||||
}
|
}
|
||||||
@@ -65,6 +68,11 @@ impl BrewVariant {
|
|||||||
_ => run_type.execute(self.binary_name()),
|
_ => run_type.execute(self.binary_name()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
fn is_macos_custom(binary_name: PathBuf) -> bool {
|
||||||
|
!(binary_name.as_os_str() == INTEL_BREW || binary_name.as_os_str() == ARM_BREW)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_fisher(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
|
pub fn run_fisher(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
|
||||||
@@ -178,7 +186,16 @@ pub fn upgrade_gnome_extensions(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_brew_formula(ctx: &ExecutionContext, variant: BrewVariant) -> Result<()> {
|
pub fn run_brew_formula(ctx: &ExecutionContext, variant: BrewVariant) -> Result<()> {
|
||||||
require(variant.binary_name())?;
|
#[allow(unused_variables)]
|
||||||
|
let binary_name = require(variant.binary_name())?;
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
if variant.is_path() && !BrewVariant::is_macos_custom(binary_name) {
|
||||||
|
return Err(SkipStep("Not a custom brew for macOS".to_string()).into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
print_separator(variant.step_title());
|
print_separator(variant.step_title());
|
||||||
let run_type = ctx.run_type();
|
let run_type = ctx.run_type();
|
||||||
|
|
||||||
@@ -197,7 +214,10 @@ pub fn run_brew_formula(ctx: &ExecutionContext, variant: BrewVariant) -> Result<
|
|||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
pub fn run_brew_cask(ctx: &ExecutionContext, variant: BrewVariant) -> Result<()> {
|
pub fn run_brew_cask(ctx: &ExecutionContext, variant: BrewVariant) -> Result<()> {
|
||||||
require(variant.binary_name())?;
|
let binary_name = require(variant.binary_name())?;
|
||||||
|
if variant.is_path() && !BrewVariant::is_macos_custom(binary_name) {
|
||||||
|
return Err(SkipStep("Not a custom brew for macOS".to_string()).into());
|
||||||
|
}
|
||||||
print_separator(format!("{} - Cask", variant.step_title()));
|
print_separator(format!("{} - Cask", variant.step_title()));
|
||||||
let run_type = ctx.run_type();
|
let run_type = ctx.run_type();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user