1use serde::{Deserialize, Serialize};
4use std::collections::HashMap;
5use std::path::PathBuf;
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct Template {
10 pub id: String,
12 pub name: String,
14 pub language: String,
16 pub content: String,
18 pub placeholders: Vec<Placeholder>,
20 pub metadata: TemplateMetadata,
22}
23
24#[derive(Debug, Clone, Default, Serialize, Deserialize)]
26pub struct TemplateMetadata {
27 pub description: Option<String>,
29 pub version: Option<String>,
31 pub author: Option<String>,
33}
34
35#[derive(Debug, Clone, Serialize, Deserialize)]
37pub struct Placeholder {
38 pub name: String,
40 pub description: String,
42 pub default: Option<String>,
44 pub required: bool,
46}
47
48#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
50pub enum CaseTransform {
51 PascalCase,
53 CamelCase,
55 SnakeCase,
57 KebabCase,
59 UpperCase,
61 LowerCase,
63}
64
65#[derive(Debug, Clone, Serialize, Deserialize)]
67pub struct TemplateContext {
68 pub values: HashMap<String, String>,
70 pub options: RenderOptions,
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76pub struct RenderOptions {
77 pub format_output: bool,
79 pub validate_syntax: bool,
81 pub preserve_whitespace: bool,
83}
84
85impl Default for RenderOptions {
86 fn default() -> Self {
87 Self {
88 format_output: true,
89 validate_syntax: true,
90 preserve_whitespace: false,
91 }
92 }
93}
94
95#[derive(Debug, Clone, Serialize, Deserialize)]
97pub struct RenderResult {
98 pub content: String,
100 pub warnings: Vec<String>,
102 pub placeholders_used: Vec<String>,
104}
105
106#[derive(Debug, Clone, Serialize, Deserialize)]
108pub struct Boilerplate {
109 pub id: String,
111 pub name: String,
113 pub description: String,
115 pub language: String,
117 pub files: Vec<BoilerplateFile>,
119 pub dependencies: Vec<Dependency>,
121 pub scripts: Vec<Script>,
123}
124
125#[derive(Debug, Clone, Serialize, Deserialize)]
127pub struct BoilerplateFile {
128 pub path: String,
130 pub template: String,
132 pub condition: Option<String>,
134}
135
136#[derive(Debug, Clone, Serialize, Deserialize)]
138pub struct Dependency {
139 pub name: String,
141 pub version: String,
143}
144
145#[derive(Debug, Clone, Serialize, Deserialize)]
147pub struct Script {
148 pub name: String,
150 pub command: String,
152}
153
154#[derive(Debug, Clone, Serialize, Deserialize)]
156pub struct BoilerplateMetadata {
157 pub id: String,
159 pub name: String,
161 pub description: String,
163 pub language: String,
165 pub source: BoilerplateSource,
167}
168
169#[derive(Debug, Clone, Serialize, Deserialize)]
171pub enum BoilerplateSource {
172 Global(PathBuf),
174 Project(PathBuf),
176}
177
178#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
180pub enum ConflictResolution {
181 Skip,
183 Overwrite,
185 Merge,
187}
188
189#[derive(Debug, Clone, Serialize, Deserialize)]
191pub struct BoilerplateDiscoveryResult {
192 pub boilerplates: Vec<BoilerplateMetadata>,
194 pub search_paths: Vec<PathBuf>,
196}
197
198#[derive(Debug, Clone, Serialize, Deserialize)]
200pub struct GeneratedFile {
201 pub path: String,
203 pub content: String,
205 pub language: String,
207}
208
209#[derive(Debug, Clone, Serialize, Deserialize)]
211pub struct ValidationResult {
212 pub valid: bool,
214 pub errors: Vec<ValidationError>,
216 pub warnings: Vec<ValidationWarning>,
218}
219
220impl Default for ValidationResult {
221 fn default() -> Self {
222 Self {
223 valid: true,
224 errors: Vec::new(),
225 warnings: Vec::new(),
226 }
227 }
228}
229
230#[derive(Debug, Clone, Serialize, Deserialize)]
232pub struct ValidationError {
233 pub file: String,
235 pub line: usize,
237 pub column: usize,
239 pub message: String,
241 pub code: Option<String>,
243}
244
245#[derive(Debug, Clone, Serialize, Deserialize)]
247pub struct ValidationWarning {
248 pub file: String,
250 pub line: usize,
252 pub column: usize,
254 pub message: String,
256 pub code: Option<String>,
258}
259
260#[derive(Debug, Clone, Serialize, Deserialize)]
262pub struct ValidationConfig {
263 pub check_syntax: bool,
265 pub run_linters: bool,
267 pub run_type_checking: bool,
269 pub warnings_as_errors: bool,
271}