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

Sparkle for updates #950

Merged
merged 4 commits into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .vscode/topgrade.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ pub enum Step {
Sheldon,
Shell,
Snap,
Sparkle,
Spicetify,
Stack,
System,
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))?;
}
Expand Down
23 changes: 22 additions & 1 deletion src/steps/os/macos.rs
Original file line number Diff line number Diff line change
@@ -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<()> {
Expand Down Expand Up @@ -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(())
}