lean_ctx_ext/core/
setup_report.rs1use std::path::PathBuf;
3
4use lean_ctx_time::UtcDateTime;
5use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct SetupReport {
9 pub schema_version: u32,
10 pub started_at: UtcDateTime,
11 pub finished_at: UtcDateTime,
12 pub success: bool,
13 pub platform: PlatformInfo,
14 pub steps: Vec<SetupStepReport>,
15 #[serde(default)]
16 pub warnings: Vec<String>,
17 #[serde(default)]
18 pub errors: Vec<String>,
19}
20
21#[derive(Debug, Clone, Serialize, Deserialize)]
22pub struct PlatformInfo {
23 pub os: String,
24 pub arch: String,
25}
26
27#[derive(Debug, Clone, Serialize, Deserialize)]
28pub struct SetupStepReport {
29 pub name: String,
30 pub ok: bool,
31 #[serde(default)]
32 pub items: Vec<SetupItem>,
33 #[serde(default)]
34 pub warnings: Vec<String>,
35 #[serde(default)]
36 pub errors: Vec<String>,
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
40pub struct SetupItem {
41 pub name: String,
42 pub status: String,
43 #[serde(default)]
44 pub path: Option<String>,
45 #[serde(default)]
46 pub note: Option<String>,
47}
48
49impl SetupReport {
50 pub fn default_path() -> Result<PathBuf, String> {
51 let data_dir = crate::core::data_dir::lean_ctx_data_dir()?;
52 Ok(data_dir.join("setup/latest.json"))
53 }
54}
55
56pub fn doctor_report_path() -> Result<PathBuf, String> {
57 Ok(crate::core::data_dir::lean_ctx_data_dir()?.join("doctor/latest.json"))
58}
59
60pub fn status_report_path() -> Result<PathBuf, String> {
61 Ok(crate::core::data_dir::lean_ctx_data_dir()?.join("status/latest.json"))
62}