@@ -45,7 +45,11 @@ pub struct Makefile {}
4545pub struct GhCI { }
4646
4747#[ derive( Template ) ]
48- #[ template( path = ".cpa/prettier.json" , escape = "none" ) ]
48+ #[ template( path = "base/ci.yaml" , escape = "none" ) ]
49+ pub struct GhCIBase { }
50+
51+ #[ derive( Template ) ]
52+ #[ template( path = ".ci/prettier.json" , escape = "none" ) ]
4953pub struct Prettier { }
5054
5155#[ derive( Template ) ]
@@ -54,17 +58,19 @@ pub struct PreCommitConfig {
5458 pub language : String ,
5559}
5660
61+ #[ derive( Template ) ]
62+ #[ template( path = "base/.pre-commit-config.yaml" , escape = "none" ) ]
63+ pub struct PreCommitConfigBase {
64+ pub language : String ,
65+ }
66+
5767////////////////////////////////////
5868// PYTHON
5969////////////////////////////////////
6070#[ derive( Template ) ]
6171#[ template( path = "python/Dockerfile" , escape = "none" ) ]
6272pub struct PyDockerfile { }
6373
64- #[ derive( Template ) ]
65- #[ template( path = "python/main.py" , escape = "none" ) ]
66- pub struct PyMain { }
67-
6874#[ derive( Template ) ]
6975#[ template( path = "python/pyproject.toml" , escape = "none" ) ]
7076pub struct PyProject {
@@ -74,7 +80,7 @@ pub struct PyProject {
7480}
7581
7682#[ derive( Template ) ]
77- #[ template( path = ".cpa /flake8.cfg" , escape = "none" ) ]
83+ #[ template( path = ".ci /flake8.cfg" , escape = "none" ) ]
7884pub struct Flake8 { }
7985
8086////////////////////////////////////
@@ -98,7 +104,7 @@ pub fn common(name: &str, create: bool, lang: &Language) -> String {
98104 let prefix: String = if create { format ! ( "./{}" , name) } else { "./" . to_string ( ) } ;
99105
100106 // Create needed dirs
101- let _ = fs:: create_dir_all ( format ! ( "{}/.cpa " , prefix) ) ;
107+ let _ = fs:: create_dir_all ( format ! ( "{}/.ci " , prefix) ) ;
102108 let _ = fs:: create_dir_all ( format ! ( "{}/.vscode" , prefix) ) ;
103109 let _ = fs:: create_dir_all ( format ! ( "{}/.github/workflows" , prefix) ) ;
104110
@@ -110,7 +116,7 @@ pub fn common(name: &str, create: bool, lang: &Language) -> String {
110116 language : lang. language . to_string ( ) ,
111117 }
112118 . write ( & prefix, ".pre-commit-config.yaml" ) ;
113- Prettier { } . write ( & prefix, ".cpa /prettier.json" ) ;
119+ Prettier { } . write ( & prefix, ".ci /prettier.json" ) ;
114120 VSCodeSettings { } . write ( & prefix, ".vscode/settings.json" ) ;
115121 VSCodeExtensions { } . write ( & prefix, ".vscode/extensions.json" ) ;
116122 prefix
@@ -120,8 +126,7 @@ pub fn python(name: &str, prefix: &str, lang: &Language) {
120126 let black_target_ver = format ! ( "py{}" , lang. ver. replace( '.' , "" ) ) ;
121127
122128 // Render Python-specific files
123- Flake8 { } . write ( prefix, ".cpa/flake8.cfg" ) ;
124- PyMain { } . write ( prefix, "main.py" ) ;
129+ Flake8 { } . write ( prefix, ".ci/flake8.cfg" ) ;
125130 PyDockerfile { } . write ( prefix, "Dockerfile" ) ;
126131
127132 let pyproj: PyProject = PyProject {
@@ -140,3 +145,22 @@ pub fn rust(name: &str, prefix: &str) {
140145 CargoToml { name : name. to_string ( ) } . write ( prefix, "Cargo.toml" ) ;
141146 RustFmt { } . write ( prefix, "rustfmt.toml" ) ;
142147}
148+
149+ pub fn base ( name : & str , create : bool , lang : & Language ) -> String {
150+ let prefix: String = if create { format ! ( "./{}" , name) } else { "./" . to_string ( ) } ;
151+
152+ // Create needed dirs
153+ let _ = fs:: create_dir_all ( format ! ( "{}/.ci" , prefix) ) ;
154+ let _ = fs:: create_dir_all ( format ! ( "{}/.github/workflows" , prefix) ) ;
155+
156+ // Render common files
157+ GhCIBase { } . write ( & prefix, ".github/workflows/ci.yaml" ) ;
158+ GitIgnore { } . write ( & prefix, ".gitignore" ) ;
159+ Makefile { } . write ( & prefix, "Makefile" ) ;
160+ PreCommitConfigBase {
161+ language : lang. language . to_string ( ) ,
162+ }
163+ . write ( & prefix, ".pre-commit-config.yaml" ) ;
164+ Prettier { } . write ( & prefix, ".ci/prettier.json" ) ;
165+ prefix
166+ }
0 commit comments