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