use std::collections::BTreeMap;
use camino::Utf8PathBuf;
use cargo_dist_schema::{ArtifactId, EnvironmentVariables, Hosting, TripleName};
use homebrew::HomebrewFragments;
use macpkg::PkgInstallerInfo;
use serde::Serialize;
use crate::{
config::{JinjaInstallPathStrategy, LibraryStyle, ZipStyle},
platform::{PlatformSupport, RuntimeConditions},
InstallReceipt, ReleaseIdx,
};
use self::homebrew::HomebrewInstallerInfo;
use self::msi::MsiInstallerInfo;
use self::npm::NpmInstallerInfo;
pub mod homebrew;
pub mod macpkg;
pub mod msi;
pub mod npm;
pub mod powershell;
pub mod shell;
#[derive(Debug, Clone)]
#[allow(clippy::large_enum_variant)]
pub enum InstallerImpl {
Shell(InstallerInfo),
Powershell(InstallerInfo),
Npm(NpmInstallerInfo),
Homebrew(HomebrewImpl),
Msi(MsiInstallerInfo),
Pkg(PkgInstallerInfo),
}
#[derive(Debug, Clone)]
pub struct HomebrewImpl {
pub info: HomebrewInstallerInfo,
pub fragments: HomebrewFragments<ExecutableZipFragment>,
}
#[derive(Debug, Clone, Serialize)]
pub struct InstallerInfo {
#[serde(skip)]
pub release: ReleaseIdx,
pub dest_path: Utf8PathBuf,
pub app_name: String,
pub app_version: String,
pub base_urls: Vec<String>,
pub hosting: Hosting,
pub artifacts: Vec<ExecutableZipFragment>,
pub desc: String,
pub hint: String,
pub install_paths: Vec<JinjaInstallPathStrategy>,
pub install_success_msg: String,
pub receipt: Option<InstallReceipt>,
pub bin_aliases: BTreeMap<TripleName, BTreeMap<String, Vec<String>>>,
pub install_libraries: Vec<LibraryStyle>,
pub runtime_conditions: RuntimeConditions,
pub platform_support: Option<PlatformSupport>,
pub env_vars: Option<EnvironmentVariables>,
}
#[derive(Debug, Clone, Serialize)]
pub struct ExecutableZipFragment {
pub id: ArtifactId,
pub target_triple: TripleName,
pub executables: Vec<String>,
pub cdylibs: Vec<String>,
pub cstaticlibs: Vec<String>,
pub zip_style: ZipStyle,
pub updater: Option<UpdaterFragment>,
pub runtime_conditions: RuntimeConditions,
}
#[derive(Debug, Clone, Serialize)]
pub struct UpdaterFragment {
pub id: ArtifactId,
pub binary: ArtifactId,
}