Sparkle for updates (#950)
This commit is contained in:
committed by
GitHub
parent
4a7de60e59
commit
4e6f48caef
8
.vscode/topgrade.code-snippets
vendored
8
.vscode/topgrade.code-snippets
vendored
@@ -32,6 +32,14 @@
|
||||
"}"
|
||||
]
|
||||
},
|
||||
"Require Binary": {
|
||||
"scope": "rust",
|
||||
"prefix": "req",
|
||||
"description": "Require a binary to be installed",
|
||||
"body": [
|
||||
"let ${1:binary} = require(\"${1:binary}\")?;"
|
||||
]
|
||||
},
|
||||
"macos": {
|
||||
"scope": "rust",
|
||||
"prefix": "macos",
|
||||
|
||||
@@ -124,6 +124,7 @@ pub enum Step {
|
||||
Sheldon,
|
||||
Shell,
|
||||
Snap,
|
||||
Sparkle,
|
||||
Spicetify,
|
||||
Stack,
|
||||
System,
|
||||
|
||||
@@ -386,6 +386,7 @@ fn run() -> Result<()> {
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
runner.execute(Step::Sparkle, "Sparkle", || macos::run_sparkle(&ctx))?;
|
||||
runner.execute(Step::Mas, "App Store", || macos::run_mas(run_type))?;
|
||||
runner.execute(Step::System, "System upgrade", || macos::upgrade_macos(&ctx))?;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
use crate::execution_context::ExecutionContext;
|
||||
use crate::executor::RunType;
|
||||
use crate::executor::{CommandExt, RunType};
|
||||
use crate::terminal::{print_separator, prompt_yesno};
|
||||
use crate::{error::TopgradeError, utils::require, Step};
|
||||
use anyhow::Result;
|
||||
use log::debug;
|
||||
use std::fs;
|
||||
use std::process::Command;
|
||||
|
||||
pub fn run_macports(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -72,3 +73,23 @@ fn system_update_available() -> Result<bool> {
|
||||
debug!("{:?}", string_output);
|
||||
Ok(!string_output.contains("No new software available"))
|
||||
}
|
||||
|
||||
pub fn run_sparkle(ctx: &ExecutionContext) -> Result<()> {
|
||||
let sparkle = require("sparkle")?;
|
||||
|
||||
print_separator("Sparkle");
|
||||
|
||||
for application in (fs::read_dir("/Applications")?).flatten() {
|
||||
let probe = Command::new(&sparkle)
|
||||
.args(&["--probe", "--application"])
|
||||
.arg(application.path())
|
||||
.check_output();
|
||||
if probe.is_ok() {
|
||||
let mut command = ctx.run_type().execute(&sparkle);
|
||||
command.args(&["bundle", "--check-immediately", "--application"]);
|
||||
command.arg(application.path());
|
||||
command.spawn()?.wait()?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user