Skip to content

Commit

Permalink
Install from source (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevgo authored Nov 14, 2023
1 parent 74a0299 commit fd70a47
Show file tree
Hide file tree
Showing 29 changed files with 514 additions and 332 deletions.
29 changes: 29 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dirs = "5.0.1"
flate2 = "1.0.28"
minreq = { version = "2.11.0", features = ["https"] }
tar = "0.4.40"
which = "5.0.0"
zip = "0.6.6"

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
DPRINT_VERSION = 0.42.5
SHELLCHECK_VERSION = 0.9.0
SHFMT_VERSION = v3.7.0
SHFMT_VERSION = 3.7.0

.DEFAULT_GOAL := help
.SILENT:
Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
[![linux](https://github.com/kevgo/run-that-app/actions/workflows/ci_linux.yml/badge.svg)](https://github.com/kevgo/run-that-app/actions/workflows/ci_linux.yml)
[![windows](https://github.com/kevgo/run-that-app/actions/workflows/ci_windows.yml/badge.svg)](https://github.com/kevgo/run-that-app/actions/workflows/ci_windows.yml)

_Run-that-app_ installs and executes small third-party tools used by software
developers (linters, checkers , verifiers) that often have no good way of being
installed. Like Docker, _run-that-app_ works on Linux, Windows, and macOS.
Unlike Docker, _run-that-app_ is extremely lean, fast, has zero dependencies,
works inside Docker, and leaves a very small footprint on your computer.
_Why bother with installation when all you want is run a tool?_

_Run-that-app_ executes small third-party tools used by software developers
(linters, checkers , verifiers) that often have no good way of being installed.
Like Docker, _run-that-app_ works on Linux, Windows, and macOS. Unlike Docker,
_run-that-app_ is extremely lean, fast, has zero dependencies, doesn't create
the Docker in Docker problem, and leaves a very small footprint on your
computer.

### quickstart

Expand Down
40 changes: 23 additions & 17 deletions src/apps/alphavet.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use super::App;
use crate::detect::{Cpu, Os, Platform};
use crate::hosting::{GithubReleaseAsset, OnlineLocation};
use crate::install::{
ArtifactType, CompileFromGoSource, DownloadPrecompiledBinary, InstallationMethod,
};
use crate::yard::Yard;

pub struct Alphavet {}

Expand All @@ -20,22 +23,25 @@ impl App for Alphavet {
"https://github.com/skx/alphavet"
}

fn artifact_location(&self, version: &str, platform: Platform) -> Box<dyn OnlineLocation> {
let filename = format!(
"alphavet-{os}-{cpu}",
os = os_text(platform.os),
cpu = cpu_text(platform.cpu),
);
Box::new(GithubReleaseAsset {
organization: "skx",
repo: "alphavet",
version: format!("v{version}"),
filename,
})
}

fn file_to_extract_from_archive(&self, _version: &str, _platform: Platform) -> Option<String> {
None
fn installation_methods(
&self,
version: &str,
platform: Platform,
yard: &Yard,
) -> Vec<Box<dyn InstallationMethod>> {
vec![
Box::new(DownloadPrecompiledBinary {
name: self.name(),
url: format!("https://github.com/skx/alphavet/releases/download/v{version}/alphavet-{os}-{cpu}", os = os_text(platform.os), cpu = cpu_text(platform.cpu)),
artifact_type: ArtifactType::Executable,
file_on_disk: yard.app_file_path(self.name(), version, self.executable(platform)),
}),
Box::new(CompileFromGoSource {
import_path: format!("github.com/skx/alphavet/cmd/alphavet@{version}"),
target_folder: yard.app_folder(self.name(), version),
executable_filename: self.executable(platform),
}),
]
}
}

Expand Down
40 changes: 23 additions & 17 deletions src/apps/depth.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use super::App;
use crate::detect::{Cpu, Os, Platform};
use crate::hosting::{GithubReleaseAsset, OnlineLocation};
use crate::install::{
ArtifactType, CompileFromGoSource, DownloadPrecompiledBinary, InstallationMethod,
};
use crate::yard::Yard;

pub struct Depth {}

Expand All @@ -20,22 +23,25 @@ impl App for Depth {
"https://github.com/KyleBanks/depth"
}

fn artifact_location(&self, version: &str, platform: Platform) -> Box<dyn OnlineLocation> {
let filename = format!(
"depth_{version}_{os}_{cpu}",
os = os_text(platform.os),
cpu = cpu_text(platform.cpu),
);
Box::new(GithubReleaseAsset {
organization: "KyleBanks",
repo: "depth",
version: format!("v{version}"),
filename,
})
}

fn file_to_extract_from_archive(&self, _version: &str, _platform: Platform) -> Option<String> {
None
fn installation_methods(
&self,
version: &str,
platform: Platform,
yard: &Yard,
) -> Vec<Box<dyn InstallationMethod>> {
vec![
Box::new(DownloadPrecompiledBinary {
name: self.name(),
url: format!("https://github.com/KyleBanks/depth/releases/download/v{version}/depth_{version}_{os}_{cpu}", os = os_text(platform.os), cpu = cpu_text(platform.cpu)),
artifact_type: ArtifactType::Executable,
file_on_disk: yard.app_file_path(self.name(), version, self.executable(platform)),
}),
Box::new(CompileFromGoSource {
import_path: format!("github.com/KyleBanks/depth/cmd/depth@v{version}"),
target_folder: yard.app_folder(self.name(), version),
executable_filename: self.executable(platform),
}),
]
}
}

Expand Down
40 changes: 23 additions & 17 deletions src/apps/dprint.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use super::App;
use crate::detect::{Cpu, Os, Platform};
use crate::hosting::{GithubReleaseAsset, OnlineLocation};
use crate::install::{
ArtifactType, CompileFromRustSource, DownloadPrecompiledBinary, InstallationMethod,
};
use crate::yard::Yard;
use big_s::S;

pub struct Dprint {}
Expand All @@ -21,22 +24,25 @@ impl App for Dprint {
"https://dprint.dev"
}

fn artifact_location(&self, version: &str, platform: Platform) -> Box<dyn OnlineLocation> {
let filename = format!(
"dprint-{cpu}-{os}.zip",
os = os_text(platform.os),
cpu = cpu_text(platform.cpu),
);
Box::new(GithubReleaseAsset {
organization: "dprint",
repo: "dprint",
version: version.to_string(),
filename,
})
}

fn file_to_extract_from_archive(&self, _version: &str, platform: Platform) -> Option<String> {
Some(S(self.executable(platform)))
fn installation_methods(
&self,
version: &str,
platform: Platform,
yard: &Yard,
) -> Vec<Box<dyn InstallationMethod>> {
vec![
Box::new(DownloadPrecompiledBinary {
name: self.name(),
url: format!("https://github.com/dprint/dprint/releases/download/{version}/dprint-{cpu}-{os}.zip", os = os_text(platform.os), cpu = cpu_text(platform.cpu)),
artifact_type: ArtifactType::Archive { file_to_extract: S(self.executable(platform))},
file_on_disk: yard.app_file_path(self.name(), version, self.executable(platform)),
}),
Box::new(CompileFromRustSource {
crate_name: "dprint",
target_folder: yard.app_folder(self.name(), version),
executable_filename: self.executable(platform),
}),
]
}
}

Expand Down
35 changes: 15 additions & 20 deletions src/apps/gh.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use super::App;
use crate::detect::{Cpu, Os, Platform};
use crate::hosting::{GithubReleaseAsset, OnlineLocation};
use crate::install::{ArtifactType, DownloadPrecompiledBinary, InstallationMethod};
use crate::yard::Yard;

pub struct Gh {}

Expand All @@ -20,27 +21,21 @@ impl App for Gh {
"https://cli.github.com"
}

fn artifact_location(&self, version: &str, platform: Platform) -> Box<dyn OnlineLocation> {
let filename = format!(
"gh_{version}_{os}_{cpu}.{ext}",
os = os_text(platform.os),
cpu = cpu_text(platform.cpu),
ext = ext_text(platform.os)
);
Box::new(GithubReleaseAsset {
organization: "cli",
repo: "cli",
version: format!("v{version}"),
filename,
})
}

fn file_to_extract_from_archive(
fn installation_methods(
&self,
version: &str,
Platform { os, cpu }: Platform,
) -> Option<String> {
Some(format!("gh_{version}_{os}_{cpu}/bin/gh",))
platform: Platform,
yard: &Yard,
) -> Vec<Box<dyn InstallationMethod>> {
vec![
Box::new(DownloadPrecompiledBinary {
name: self.name(),
url: format!("https://github.com/cli/cli/releases/download/v{version}/gh_{version}_{os}_{cpu}.{ext}", os = os_text(platform.os), cpu = cpu_text(platform.cpu), ext =ext_text(platform.os)),
artifact_type: ArtifactType::Archive { file_to_extract: format!("gh_{version}_{os}_{cpu}/bin/gh", os=os_text(platform.os), cpu = cpu_text(platform.cpu))},
file_on_disk: yard.app_file_path(self.name(), version, self.executable(platform)),
}),
// installation from source seems more involved, see https://github.com/cli/cli/blob/trunk/docs/source.md
]
}
}

Expand Down
40 changes: 23 additions & 17 deletions src/apps/gofumpt.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use super::App;
use crate::detect::{Cpu, Os, Platform};
use crate::hosting::{GithubReleaseAsset, OnlineLocation};
use crate::install::{
ArtifactType, CompileFromGoSource, DownloadPrecompiledBinary, InstallationMethod,
};
use crate::yard::Yard;

pub struct Gofumpt {}

Expand All @@ -20,22 +23,25 @@ impl App for Gofumpt {
"https://github.com/mvdan/gofumpt"
}

fn artifact_location(&self, version: &str, platform: Platform) -> Box<dyn OnlineLocation> {
let filename = format!(
"gofumpt_{version}_{os}_{cpu}",
os = os_text(platform.os),
cpu = cpu_text(platform.cpu),
);
Box::new(GithubReleaseAsset {
organization: "mvdan",
repo: "gofumpt",
version: version.to_string(),
filename,
})
}

fn file_to_extract_from_archive(&self, _version: &str, _platform: Platform) -> Option<String> {
None
fn installation_methods(
&self,
version: &str,
platform: Platform,
yard: &Yard,
) -> Vec<Box<dyn InstallationMethod>> {
vec![
Box::new(DownloadPrecompiledBinary {
name: self.name(),
url: format!("https://github.com/mvdan/gofumpt/releases/download/v{version}/gofumpt_v{version}_{os}_{cpu}", os = os_text(platform.os), cpu = cpu_text(platform.cpu)),
artifact_type: ArtifactType::Executable,
file_on_disk: yard.app_file_path(self.name(), version, self.executable(platform)),
}),
Box::new(CompileFromGoSource {
import_path: format!("mvdan.cc/gofumpt@{version}"),
target_folder: yard.app_folder(self.name(), version),
executable_filename: self.executable(platform),
}),
]
}
}

Expand Down
Loading

0 comments on commit fd70a47

Please sign in to comment.