euv-cli 0.50.0

Cross-platform CLI tool for the euv native UI framework supporting run, build, check, fmt, doctor, new, and Hyperlane SSE dynamic updates across all supported platforms.
Documentation
use super::*;

/// Unified multi-platform build pipeline configuration resolved from CLI flags and optional `euv.toml`.
#[derive(Clone, Data, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct BuildPipelineConfig {
    /// Workspace or standalone crate root directory.
    pub(crate) workspace_root: PathBuf,
    /// Explicit targets or target groups requested via `--target`.
    pub(crate) targets: Vec<TargetArg>,
    /// Shorthand for `--target all` across all 36 production targets.
    #[get(type(copy))]
    pub(crate) all: bool,
    /// Optional Cargo package name override (`-p/--package`).
    pub(crate) package: Option<String>,
    /// Optional destination output directory (`--out-dir`).
    pub(crate) out_dir: Option<PathBuf>,
    /// Optional exact single-file output path (`--out-file`, e.g. Android APK).
    pub(crate) out_file: Option<PathBuf>,
    /// Optional destination archive file path (`--archive`, `.tar.gz` or `.zip`).
    pub(crate) archive: Option<PathBuf>,
    /// Optional URL base prefix for Web bundles (`--base`).
    pub(crate) base: Option<String>,
    /// When `true`, skips targets whose host OS or SDK prerequisites are missing instead of failing.
    #[get(type(copy))]
    pub(crate) skip_unavailable: bool,
    /// When `true`, executes independent targets concurrently across a bounded worker pool.
    #[get(type(copy))]
    pub(crate) parallel: bool,
    /// Optional concurrency ceiling (`-j/--jobs`) when parallel execution is enabled.
    #[get(type(copy))]
    pub(crate) jobs: Option<usize>,
    /// When `true`, writes a deterministic SHA-256 `euv-release.json` inventory for staged directories.
    #[get(type(copy))]
    pub(crate) manifest: bool,
    /// When `true`, verifies bundle integrity, SHA-256 manifests, zero-JS rules, and release AI-schema stripping.
    #[get(type(copy))]
    pub(crate) verify: bool,
    /// When `true`, builds raw `.wasm` + icons + `build-plan.json` without `wasm-bindgen-cli`.
    #[get(type(copy))]
    pub(crate) raw_wasm: bool,
    /// When `true`, skips optional binaryen `wasm-opt` optimization on Web and ecosystem WASM builds.
    #[get(type(copy))]
    pub(crate) skip_wasm_opt: bool,
    /// When `true`, builds `default` plus all `theme-*` feature variants for Web targets.
    #[get(type(copy))]
    pub(crate) theme_variants: bool,
    /// When `true`, skips automatic simulator/emulator launch after mobile builds.
    #[get(type(copy))]
    pub(crate) no_launch: bool,
    /// When `true`, installs built Android/Wear OS/HarmonyOS bundles onto a connected device.
    #[get(type(copy))]
    pub(crate) install: bool,
    /// When `true`, runs post-build headless smoke verification on desktop/terminal builds.
    #[get(type(copy))]
    pub(crate) smoke: bool,
    /// When `true`, also compiles and stages `euv` CLI binary alongside desktop app binaries.
    #[get(type(copy))]
    pub(crate) include_cli: bool,
    /// Optional explicit semantic version override (`--version`).
    pub(crate) version: Option<String>,
    /// Target native CPU ABIs (`--abi`, repeatable/comma-separated).
    pub(crate) abis: Vec<String>,
    /// Additional Cargo feature flags (`--features`, repeatable/comma-separated).
    pub(crate) features: Vec<String>,
    /// Optional device, simulator UDID, or AVD identifier (`--device`).
    pub(crate) device: Option<String>,
    /// Optional custom source PNG icon path overriding the default brand mark (`--icon`).
    pub(crate) icon: Option<PathBuf>,
    /// Optional HarmonyOS form factor profile (`--form-factor`).
    #[get(type(copy))]
    pub(crate) form_factor: HarmonyFormFactorArg,
    /// Optional render pipeline mode override (`--render`; defaults to `hardware` on Apple mobile/watch and `auto` elsewhere).
    #[get(type(copy))]
    pub(crate) render: Option<RenderArg>,
    /// When `true`, compiles targets in release optimization profile (`--release`).
    #[get(type(copy))]
    pub(crate) release: bool,
}

/// Execution outcome recorded for one target inside `BuildPipelineReport`.
#[derive(Clone, Data, Debug, Deserialize, Eq, New, PartialEq, Serialize)]
pub struct TargetBuildOutcome {
    /// Canonical lowercase target label (e.g. `"web"`, `"macos"`, `"android"`).
    pub(crate) target: String,
    /// Final target status (`Passed`, `SkippedUnavailable`, or `Failed`).
    #[get(type(copy))]
    pub(crate) status: TargetBuildStatus,
    /// Wall-clock target duration in milliseconds.
    #[get(type(copy))]
    pub(crate) elapsed_ms: u64,
    /// Primary generated artifact file or output directory path, when present.
    #[new(skip)]
    pub(crate) artifact_path: Option<String>,
    /// Packaged archive file path (`.tar.gz` / `.zip`), when created.
    #[new(skip)]
    pub(crate) archive_path: Option<String>,
    /// Generated `euv-release.json` manifest path, when created.
    #[new(skip)]
    pub(crate) manifest_path: Option<String>,
    /// Human-readable status detail, artifact summary, missing prerequisites, or error diagnostic.
    pub(crate) detail: String,
    /// Actionable install command hint when skipped due to missing SDK/toolchain prerequisites.
    #[new(skip)]
    pub(crate) install_hint: Option<String>,
}

/// Aggregate multi-platform build summary produced by `execute_build_pipeline`.
#[derive(Clone, Data, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct BuildPipelineReport {
    /// Resolved dynamic semantic version applied across all built targets.
    pub(crate) version: String,
    /// Resolved primary Cargo package name.
    pub(crate) package: String,
    /// Whether bounded parallel target execution was active.
    #[get(type(copy))]
    pub(crate) parallel: bool,
    /// Effective maximum concurrent target worker count.
    #[get(type(copy))]
    pub(crate) jobs: usize,
    /// Total number of targets that succeeded.
    #[get(type(copy))]
    pub(crate) passed_count: usize,
    /// Total number of targets skipped cleanly under `--skip-unavailable`.
    #[get(type(copy))]
    pub(crate) skipped_count: usize,
    /// Total number of targets that failed.
    #[get(type(copy))]
    pub(crate) failed_count: usize,
    /// Total wall-clock pipeline execution time in milliseconds.
    #[get(type(copy))]
    pub(crate) total_elapsed_ms: u64,
    /// Per-target execution outcomes in deterministic target order.
    pub(crate) outcomes: Vec<TargetBuildOutcome>,
}

/// Resolved workspace, config, and flag context shared across pipeline target builders.
pub(crate) struct ResolvedPipelineContext {
    /// Absolute or resolved workspace root directory.
    pub(crate) workspace_root: PathBuf,
    /// Resolved semantic version string.
    pub(crate) version: String,
    /// Resolved primary Cargo package name.
    pub(crate) package: String,
    /// Resolved app display label.
    pub(crate) app_label: Option<String>,
    /// Resolved reverse-DNS bundle identifier.
    pub(crate) bundle_id: Option<String>,
    /// Resolved URL base prefix for Web builds.
    pub(crate) base_url: String,
    /// Resolved optional custom PNG icon source path.
    pub(crate) icon_path: Option<PathBuf>,
    /// Resolved optional Android API level override.
    pub(crate) android_api_level: Option<String>,
    /// Resolved optional Android build-tools version override.
    pub(crate) android_build_tools: Option<String>,
    /// Effective `--raw-wasm` toggle combining CLI and `euv.toml`.
    pub(crate) raw_wasm: bool,
    /// Effective `--skip-wasm-opt` toggle combining CLI and `euv.toml`.
    pub(crate) skip_wasm_opt: bool,
    /// Effective `--include-cli` toggle combining CLI and `euv.toml`.
    pub(crate) include_cli: bool,
    /// Optional base output directory combining CLI and `euv.toml`.
    pub(crate) out_dir: Option<PathBuf>,
    /// Whether more than one concrete target is running in this pipeline invocation.
    pub(crate) multi_target: bool,
}