|
|
@@ -0,0 +1,37 @@
|
|
|
+use std::fs;
|
|
|
+use std::path::Path;
|
|
|
+
|
|
|
+pub fn create(project_name: String) {
|
|
|
+ let path = Path::new(&project_name);
|
|
|
+ let fail_msg = "Creation failed";
|
|
|
+
|
|
|
+ fs::create_dir(path).expect(fail_msg);
|
|
|
+ fs::create_dir(path.join("routes")).expect(fail_msg);
|
|
|
+ fs::create_dir(path.join("assets")).expect(fail_msg);
|
|
|
+ fs::write(path.join(".gitignore"), "target/").expect(fail_msg);
|
|
|
+ fs::write(path.join("neovan.yml"), create_settings()).expect(fail_msg);
|
|
|
+ fs::write(path.join("routes").join("index.neovan"), hello_world_html()).expect(fail_msg);
|
|
|
+}
|
|
|
+
|
|
|
+fn create_settings() -> String {
|
|
|
+ r#"production: false
|
|
|
+routes_dir: routes
|
|
|
+build_dir: .build
|
|
|
+assets_dir: assets
|
|
|
+assets_route: /assets
|
|
|
+"#.to_string()
|
|
|
+}
|
|
|
+
|
|
|
+fn hello_world_html() -> String {
|
|
|
+ r#"<DOCTYPE html>
|
|
|
+<html lang="en">
|
|
|
+ <head>
|
|
|
+ <meta charset="utf-8">
|
|
|
+ <title>NeoVan</title>
|
|
|
+ </head>
|
|
|
+ <body>
|
|
|
+ <h1>Hello, World!</h1>
|
|
|
+ </body>
|
|
|
+</html>
|
|
|
+"#.to_string()
|
|
|
+}
|