@@ -45,7 +45,11 @@ pub struct Makefile {}
45
45
pub struct GhCI { }
46
46
47
47
#[ 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" ) ]
49
53
pub struct Prettier { }
50
54
51
55
#[ derive( Template ) ]
@@ -54,17 +58,19 @@ pub struct PreCommitConfig {
54
58
pub language : String ,
55
59
}
56
60
61
+ #[ derive( Template ) ]
62
+ #[ template( path = "base/.pre-commit-config.yaml" , escape = "none" ) ]
63
+ pub struct PreCommitConfigBase {
64
+ pub language : String ,
65
+ }
66
+
57
67
////////////////////////////////////
58
68
// PYTHON
59
69
////////////////////////////////////
60
70
#[ derive( Template ) ]
61
71
#[ template( path = "python/Dockerfile" , escape = "none" ) ]
62
72
pub struct PyDockerfile { }
63
73
64
- #[ derive( Template ) ]
65
- #[ template( path = "python/main.py" , escape = "none" ) ]
66
- pub struct PyMain { }
67
-
68
74
#[ derive( Template ) ]
69
75
#[ template( path = "python/pyproject.toml" , escape = "none" ) ]
70
76
pub struct PyProject {
@@ -74,7 +80,7 @@ pub struct PyProject {
74
80
}
75
81
76
82
#[ derive( Template ) ]
77
- #[ template( path = ".cpa /flake8.cfg" , escape = "none" ) ]
83
+ #[ template( path = ".ci /flake8.cfg" , escape = "none" ) ]
78
84
pub struct Flake8 { }
79
85
80
86
////////////////////////////////////
@@ -98,7 +104,7 @@ pub fn common(name: &str, create: bool, lang: &Language) -> String {
98
104
let prefix: String = if create { format ! ( "./{}" , name) } else { "./" . to_string ( ) } ;
99
105
100
106
// Create needed dirs
101
- let _ = fs:: create_dir_all ( format ! ( "{}/.cpa " , prefix) ) ;
107
+ let _ = fs:: create_dir_all ( format ! ( "{}/.ci " , prefix) ) ;
102
108
let _ = fs:: create_dir_all ( format ! ( "{}/.vscode" , prefix) ) ;
103
109
let _ = fs:: create_dir_all ( format ! ( "{}/.github/workflows" , prefix) ) ;
104
110
@@ -110,7 +116,7 @@ pub fn common(name: &str, create: bool, lang: &Language) -> String {
110
116
language : lang. language . to_string ( ) ,
111
117
}
112
118
. write ( & prefix, ".pre-commit-config.yaml" ) ;
113
- Prettier { } . write ( & prefix, ".cpa /prettier.json" ) ;
119
+ Prettier { } . write ( & prefix, ".ci /prettier.json" ) ;
114
120
VSCodeSettings { } . write ( & prefix, ".vscode/settings.json" ) ;
115
121
VSCodeExtensions { } . write ( & prefix, ".vscode/extensions.json" ) ;
116
122
prefix
@@ -120,8 +126,7 @@ pub fn python(name: &str, prefix: &str, lang: &Language) {
120
126
let black_target_ver = format ! ( "py{}" , lang. ver. replace( '.' , "" ) ) ;
121
127
122
128
// Render Python-specific files
123
- Flake8 { } . write ( prefix, ".cpa/flake8.cfg" ) ;
124
- PyMain { } . write ( prefix, "main.py" ) ;
129
+ Flake8 { } . write ( prefix, ".ci/flake8.cfg" ) ;
125
130
PyDockerfile { } . write ( prefix, "Dockerfile" ) ;
126
131
127
132
let pyproj: PyProject = PyProject {
@@ -140,3 +145,22 @@ pub fn rust(name: &str, prefix: &str) {
140
145
CargoToml { name : name. to_string ( ) } . write ( prefix, "Cargo.toml" ) ;
141
146
RustFmt { } . write ( prefix, "rustfmt.toml" ) ;
142
147
}
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