1mod bootstrap;
2mod commands;
3mod detect;
4mod drivers;
5mod execution;
6mod managed;
7mod manifest;
8mod model;
9mod profile;
10mod profile_blocks;
11mod profile_commands;
12mod profile_compose;
13mod render;
14mod resources;
15mod run_manifest;
16mod selection;
17
18use model::{
19 LoadedSysPreset, ResolvedSelection, SYS_PROFILE_PHASES, SelectionSource,
20 ShellProfileBlockPosition, SysDetection, SysDetectionProbe, SysDriverKind, SysInstall,
21 SysInstalledRow, SysItem, SysItemMode, SysItemOutcome, SysItemStatus, SysManifest,
22 SysPackageProvider, SysProfilePhase, SysShellIntegration, SysShellKind, SysUpdateRow,
23 SysUpgradeReport,
24};
25use render::sys_init_theme;
26
27use anyhow::{Context, Result};
28use std::path::Path;
29
30pub use commands::{handle_info, handle_init, handle_list, handle_status};
31pub use detect::detect_os_id;
32pub(crate) use managed::installed_managed;
33pub use managed::{
34 handle_apply, handle_uninstall, handle_upgrade_managed, handle_upgrade_managed_target,
35 managed_updates,
36};
37pub use profile_commands::{handle_profile_disable, handle_profile_enable};
38
39const SYS_TEMPLATE: &str = r#"# System bootstrap preset metadata for shine (schema v2).
40version = 2
41description = "My system bootstrap."
42default_profile = "recommended"
43
44[[items]]
45id = "my-tool"
46label = "My Tool"
47description = "Install and configure my tool."
48default = true
49detect = { kind = "command", command = "my-tool", version_args = ["--version"] }
50# Keep scripts inside this category. For Windows, use a .ps1 script instead.
51install = { kind = "script", path = "install/my-tool.sh" }
52
53[profiles.recommended]
54items = ["my-tool"]
55"#;
56
57pub async fn handle_init_template(force: bool) -> Result<()> {
58 let dir = std::env::current_dir().context("reading current directory")?;
59 let (path, overwritten) =
60 utils::init_template::write_shine_toml_template(&dir, force, SYS_TEMPLATE)?;
61 if overwritten {
62 println!("Updated sys preset template: {}", path.display());
63 } else {
64 println!("Created sys preset template: {}", path.display());
65 }
66 Ok(())
67}
68
69pub(crate) fn validate_preset_category(
70 name: &str,
71 root: &Path,
72) -> std::result::Result<bool, crate::preset_validation::PresetValidationFailure> {
73 manifest::validate_preset_category(name, root)?;
74 Ok(true)
75}