97 lines
2.6 KiB
Rust
97 lines
2.6 KiB
Rust
#[macro_use]
|
|
extern crate miette;
|
|
|
|
#[macro_use]
|
|
extern crate serde;
|
|
|
|
mod install;
|
|
|
|
use std::path::{Path, PathBuf};
|
|
|
|
use miette::{IntoDiagnostic, Result, WrapErr};
|
|
|
|
use install::{Pipeline, RemoteResource, Step};
|
|
|
|
const SWTOOLS_PATH: &'static str = "C:\\SWTools";
|
|
|
|
pub fn swtools_path() -> &'static Path {
|
|
Path::new(SWTOOLS_PATH)
|
|
}
|
|
|
|
pub struct Context {
|
|
pub reqwest: reqwest::Client,
|
|
}
|
|
|
|
#[tokio::main(flavor = "current_thread")]
|
|
async fn main() -> Result<()> {
|
|
println!("Bootstrapping...");
|
|
|
|
if cfg!(not(windows)) {
|
|
bail!("Your platform is not supported.");
|
|
}
|
|
|
|
if !swtools_path().exists() {
|
|
bail!("Could not find or access {}", SWTOOLS_PATH);
|
|
}
|
|
|
|
let nppp_zip = swtools_path().join("temp").join("notepad-plus-plus.zip");
|
|
let epp_zip = swtools_path().join("temp").join("explorer-plus-plus.zip");
|
|
|
|
let utilities = [
|
|
Pipeline::new(
|
|
"Install Notepad++",
|
|
vec![
|
|
Step::DownloadFile {
|
|
file: nppp_zip.as_path().into(),
|
|
res: RemoteResource::GitHubArtifact {
|
|
repo: "notepad-plus-plus/notepad-plus-plus",
|
|
pattern: "npp.{{tag_name_strip_prefix}}.portable.x64.zip",
|
|
},
|
|
},
|
|
Step::ExtractFile {
|
|
file: nppp_zip.as_path().into(),
|
|
dest: swtools_path().join("notepad-plus-plus").into(),
|
|
},
|
|
],
|
|
),
|
|
Pipeline::new(
|
|
"Install Explorer++",
|
|
vec![
|
|
Step::DownloadFile {
|
|
file: epp_zip.as_path().into(),
|
|
res: RemoteResource::Url(
|
|
"https://explorerplusplus.com/software/explorer++_1.3.5_x64.zip",
|
|
),
|
|
},
|
|
Step::ExtractFile {
|
|
file: epp_zip.as_path().into(),
|
|
dest: swtools_path().join("explorer-plus-plus").into(),
|
|
},
|
|
],
|
|
),
|
|
Pipeline::new(
|
|
"Install Minecraft (Java Edition)",
|
|
vec![Step::DownloadFile {
|
|
file: swtools_path()
|
|
.join("minecraft")
|
|
.join("Minecraft.exe")
|
|
.into(),
|
|
res: RemoteResource::Url("https://launcher.mojang.com/download/Minecraft.exe"),
|
|
}],
|
|
),
|
|
];
|
|
|
|
let ctx = Context {
|
|
reqwest: reqwest::Client::builder()
|
|
.build()
|
|
.into_diagnostic()
|
|
.wrap_err("Could not initialize HTTP client.")?,
|
|
};
|
|
|
|
for utility in utilities {
|
|
utility.invoke(&ctx).await?;
|
|
}
|
|
|
|
Ok(())
|
|
}
|