systemprompt_cli/commands/web/validate/
asset_validation.rs1use std::fs;
7
8use super::super::paths::WebPaths;
9use super::super::types::ValidationIssue;
10
11pub fn validate_assets(
12 profile: &systemprompt_models::Profile,
13 web_paths: &WebPaths,
14 errors: &mut Vec<ValidationIssue>,
15 _warnings: &mut Vec<ValidationIssue>,
16) {
17 let web_config_path = profile.paths.web_config();
18 let assets_dir = &web_paths.assets;
19
20 if !assets_dir.exists() {
21 return;
22 }
23
24 let Ok(config_content) = fs::read_to_string(&web_config_path) else {
25 return;
26 };
27
28 let logo_refs = [
29 "logo.svg",
30 "logo.png",
31 "logo.webp",
32 "logo-dark.png",
33 "logo-512.png",
34 ];
35
36 for logo in logo_refs {
37 if config_content.contains(logo) {
38 let logo_path = assets_dir.join("logos").join(logo);
39 if !logo_path.exists() {
40 errors.push(ValidationIssue {
41 source: "assets".to_owned(),
42 message: format!("Referenced logo not found: {}", logo_path.display()),
43 suggestion: Some("Add the missing logo file".to_owned()),
44 });
45 }
46 }
47 }
48
49 if config_content.contains("favicon") {
50 let favicon_path = assets_dir.join("favicon.ico");
51 let favicon_svg = assets_dir.join("logos").join("logo.svg");
52 if !favicon_path.exists() && !favicon_svg.exists() {
53 errors.push(ValidationIssue {
54 source: "assets".to_owned(),
55 message: "Referenced favicon not found".to_owned(),
56 suggestion: Some("Add a favicon.ico or logo.svg file".to_owned()),
57 });
58 }
59 }
60}