Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 4e6f48c

Browse files
authored
Sparkle for updates (#950)
1 parent 4a7de60 commit 4e6f48c

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

.vscode/topgrade.code-snippets

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@
3232
"}"
3333
]
3434
},
35+
"Require Binary": {
36+
"scope": "rust",
37+
"prefix": "req",
38+
"description": "Require a binary to be installed",
39+
"body": [
40+
"let ${1:binary} = require(\"${1:binary}\")?;"
41+
]
42+
},
3543
"macos": {
3644
"scope": "rust",
3745
"prefix": "macos",

src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ pub enum Step {
124124
Sheldon,
125125
Shell,
126126
Snap,
127+
Sparkle,
127128
Spicetify,
128129
Stack,
129130
System,

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ fn run() -> Result<()> {
386386

387387
#[cfg(target_os = "macos")]
388388
{
389+
runner.execute(Step::Sparkle, "Sparkle", || macos::run_sparkle(&ctx))?;
389390
runner.execute(Step::Mas, "App Store", || macos::run_mas(run_type))?;
390391
runner.execute(Step::System, "System upgrade", || macos::upgrade_macos(&ctx))?;
391392
}

src/steps/os/macos.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
use crate::execution_context::ExecutionContext;
2-
use crate::executor::RunType;
2+
use crate::executor::{CommandExt, RunType};
33
use crate::terminal::{print_separator, prompt_yesno};
44
use crate::{error::TopgradeError, utils::require, Step};
55
use anyhow::Result;
66
use log::debug;
7+
use std::fs;
78
use std::process::Command;
89

910
pub fn run_macports(ctx: &ExecutionContext) -> Result<()> {
@@ -72,3 +73,23 @@ fn system_update_available() -> Result<bool> {
7273
debug!("{:?}", string_output);
7374
Ok(!string_output.contains("No new software available"))
7475
}
76+
77+
pub fn run_sparkle(ctx: &ExecutionContext) -> Result<()> {
78+
let sparkle = require("sparkle")?;
79+
80+
print_separator("Sparkle");
81+
82+
for application in (fs::read_dir("/Applications")?).flatten() {
83+
let probe = Command::new(&sparkle)
84+
.args(&["--probe", "--application"])
85+
.arg(application.path())
86+
.check_output();
87+
if probe.is_ok() {
88+
let mut command = ctx.run_type().execute(&sparkle);
89+
command.args(&["bundle", "--check-immediately", "--application"]);
90+
command.arg(application.path());
91+
command.spawn()?.wait()?;
92+
}
93+
}
94+
Ok(())
95+
}

0 commit comments

Comments
 (0)