Skip to main content

idt/installers/
rio.rs

1use std::path::Path;
2
3use ytil_cmd::silent_cmd;
4
5use crate::installers::Installer;
6
7pub struct Rio<'a> {
8    pub dev_tools_dir: &'a Path,
9    pub bin_dir: &'a Path,
10}
11
12impl Installer for Rio<'_> {
13    fn bin_name(&self) -> &'static str {
14        "rio"
15    }
16
17    /// Builds Rio from source, symlinks the binary into `bin_dir`, and
18    /// copies `Rio.app` into `/Applications` (atomic swap).
19    fn install(&self) -> rootcause::Result<()> {
20        let source_dir = self.dev_tools_dir.join(self.bin_name()).join("source");
21
22        silent_cmd("sh")
23            .args([
24                "-c",
25                &format!(
26                    r#"
27                        ([ ! -d "{0}" ] && \
28                            git clone --depth=1 https://github.com/raphamorim/rio.git {0} || true) && \
29                        cd {0} && \
30                        git fetch origin main --depth=1 && \
31                        git checkout origin/main && \
32                        rustup target add aarch64-apple-darwin && \
33                        make release-macos
34                    "#,
35                    source_dir.display(),
36                ),
37            ])
38            .status()?
39            .exit_ok()?;
40
41        let app = source_dir.join("release").join("Rio.app");
42
43        crate::installers::install_macos_app(&app, self.bin_dir, self.bin_name())?;
44
45        Ok(())
46    }
47
48    fn health_check_args(&self) -> Option<&[&str]> {
49        Some(&["--version"])
50    }
51
52    fn should_verify_checksum(&self) -> bool {
53        false
54    }
55}