1use crate::{
2 FilterConfig, GlobalConfig, ProviderConfig, UiConfig,
3 builder::{CommandConfigBuilder, ConfigBuilder},
4};
5
6pub struct ConfigTemplates;
7
8impl ConfigTemplates {
9 pub fn default_config() -> GlobalConfig {
10 ConfigBuilder::new()
11 .providers(vec!["cargo".to_string(), "rustc".to_string()])
12 .cache_ttl(3600)
13 .parallel_execution(true)
14 .max_concurrent_jobs(4)
15 .ui_config(UiConfig {
16 color: Some(true),
17 progress: Some(true),
18 verbose: Some(false),
19 format: Some("default".to_string()),
20 })
21 .filter_config(FilterConfig {
22 priority_commands: vec!["test".to_string(), "build".to_string()],
23 ignore_commands: vec![],
24 auto_fix: Some(false),
25 show_warnings: Some(true),
26 })
27 .build()
28 }
29
30 pub fn web_development() -> GlobalConfig {
31 let mut builder = ConfigBuilder::new()
32 .providers(vec![
33 "cargo".to_string(),
34 "rustc".to_string(),
35 "leptos".to_string(),
36 "dioxus".to_string(),
37 ])
38 .cache_ttl(1800)
39 .parallel_execution(true)
40 .max_concurrent_jobs(8);
41
42 builder = builder
43 .command(
44 CommandConfigBuilder::new("serve", "cargo")
45 .args(vec!["leptos".to_string(), "serve".to_string()])
46 .description("Start Leptos development server")
47 .build(),
48 )
49 .command(
50 CommandConfigBuilder::new("dx-serve", "dx")
51 .arg("serve")
52 .description("Start Dioxus development server")
53 .build(),
54 )
55 .command(
56 CommandConfigBuilder::new("watch", "cargo")
57 .args(vec![
58 "watch".to_string(),
59 "-x".to_string(),
60 "run".to_string(),
61 ])
62 .description("Watch for changes and auto-rebuild")
63 .build(),
64 );
65
66 builder.build()
67 }
68
69 pub fn game_development() -> GlobalConfig {
70 let mut builder = ConfigBuilder::new()
71 .providers(vec![
72 "cargo".to_string(),
73 "rustc".to_string(),
74 "bevy".to_string(),
75 ])
76 .cache_ttl(3600)
77 .parallel_execution(true)
78 .max_concurrent_jobs(4);
79
80 let provider_config = ProviderConfig {
81 bevy: Some(toml::Value::Table(toml::toml! {
82 features = ["dynamic_linking", "bevy_dylib"]
83 fast_compile = true
84 })),
85 ..Default::default()
86 };
87
88 builder = builder
89 .provider_config(provider_config)
90 .command(
91 CommandConfigBuilder::new("run-fast", "cargo")
92 .arg("run")
93 .arg("--features")
94 .arg("bevy/dynamic_linking")
95 .env("CARGO_TARGET_DIR", "target-fast")
96 .description("Run with fast compile settings")
97 .build(),
98 )
99 .command(
100 CommandConfigBuilder::new("check-wasm", "cargo")
101 .args(vec![
102 "check".to_string(),
103 "--target".to_string(),
104 "wasm32-unknown-unknown".to_string(),
105 ])
106 .description("Check WASM compatibility")
107 .build(),
108 );
109
110 builder.build()
111 }
112
113 pub fn library_development() -> GlobalConfig {
114 let mut builder = ConfigBuilder::new()
115 .providers(vec!["cargo".to_string(), "rustc".to_string()])
116 .cache_ttl(7200)
117 .parallel_execution(true)
118 .max_concurrent_jobs(4);
119
120 builder = builder
121 .filter_config(FilterConfig {
122 priority_commands: vec![
123 "test".to_string(),
124 "doc".to_string(),
125 "clippy".to_string(),
126 ],
127 ignore_commands: vec![],
128 auto_fix: Some(true),
129 show_warnings: Some(true),
130 })
131 .command(
132 CommandConfigBuilder::new("test-all", "cargo")
133 .args(vec![
134 "test".to_string(),
135 "--all-features".to_string(),
136 "--".to_string(),
137 "--nocapture".to_string(),
138 ])
139 .description("Run all tests with all features")
140 .build(),
141 )
142 .command(
143 CommandConfigBuilder::new("doc-open", "cargo")
144 .args(vec![
145 "doc".to_string(),
146 "--no-deps".to_string(),
147 "--open".to_string(),
148 ])
149 .description("Build and open documentation")
150 .build(),
151 )
152 .command(
153 CommandConfigBuilder::new("publish-dry", "cargo")
154 .args(vec![
155 "publish".to_string(),
156 "--dry-run".to_string(),
157 "--allow-dirty".to_string(),
158 ])
159 .description("Test publishing without actually publishing")
160 .build(),
161 );
162
163 builder.build()
164 }
165
166 pub fn minimal() -> GlobalConfig {
167 ConfigBuilder::new()
168 .providers(vec!["cargo".to_string()])
169 .build()
170 }
171
172 pub fn list_templates() -> Vec<(&'static str, &'static str)> {
173 vec![
174 (
175 "default_config",
176 "Default configuration with cargo and rustc",
177 ),
178 ("web", "Web development with Leptos and Dioxus"),
179 ("game", "Game development with Bevy"),
180 ("library", "Library development with testing focus"),
181 ("minimal", "Minimal configuration with only cargo"),
182 ]
183 }
184
185 pub fn get_template(name: &str) -> Option<GlobalConfig> {
186 match name {
187 "default" | "default_config" => Some(Self::default_config()),
188 "web" => Some(Self::web_development()),
189 "game" => Some(Self::game_development()),
190 "library" => Some(Self::library_development()),
191 "minimal" => Some(Self::minimal()),
192 _ => None,
193 }
194 }
195}