Skip to content

Commit

Permalink
FIX: create assets folder in generated web project - was breaking run
Browse files Browse the repository at this point in the history
FIX: use and generate routers_static - file was missing in generated project
  • Loading branch information
mi4uu committed Nov 17, 2023
1 parent 03d07fc commit 3a71fee
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/utils/create_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ fn write_project_file(

let (src_path, router_path) = create_basic_file(project_path, &handlebars, &data)?;


if is_web_site {
//templates
let template_path = project_path.join("templates");
Expand All @@ -202,9 +203,13 @@ fn write_project_file(
handle_404_file.write_all(handle_404_template_rendered.as_bytes())?;
//assets
let assets_path = project_path.join("assets");
std::fs::create_dir_all(&assets_path)?;


//assets/favicon.ico
let favicon_bytes = include_bytes!("../template/assets/favicon.ico");
let mut favicon_file = File::create(assets_path.join("favicon.ico"))?;

favicon_file.write_all(favicon_bytes)?;
if need_db_conn {
//assets/js
Expand Down Expand Up @@ -260,6 +265,13 @@ fn write_project_file(
let router_user_rendered = handlebars.render_template(router_user_template, &data)?;
let mut router_user_file = File::create(router_path.join("user.rs"))?;
router_user_file.write_all(router_user_rendered.as_bytes())?;

//src/router/static_routers.rs
let router_static_routers_template = include_str!("../template/src/routers/static_routers.hbs");
let router_static_routers_rendered = handlebars.render_template(router_static_routers_template, &data)?;
let mut router_static_routers_file = File::create(router_path.join("static_routers.rs"))?;
router_static_routers_file.write_all(router_static_routers_rendered.as_bytes())?;

//src/services
let services_path = src_path.join("services");
std::fs::create_dir_all(&services_path)?;
Expand All @@ -273,6 +285,7 @@ fn write_project_file(
let services_user_rendered = handlebars.render_template(services_user_template, &data)?;
let mut services_user_file = File::create(services_path.join("user.rs"))?;
services_user_file.write_all(services_user_rendered.as_bytes())?;

//src/utils
let utils_path = src_path.join("utils");
std::fs::create_dir_all(&utils_path)?;
Expand Down Expand Up @@ -649,6 +662,12 @@ fn create_basic_file(
let mut router_demo_file = File::create(router_path.join("demo.rs"))?;
router_demo_file.write_all(router_demo_rendered.as_bytes())?;

//src/router/static_routers.rs
// let router_static_routers_template = include_str!("../template/src/routers/static_routers.hbs");
// let router_static_routers_rendered = handlebars.render_template(router_static_routers_template, &data)?;
// let mut router_static_routers_file = File::create(router_path.join("static_routers.rs"))?;
// router_static_routers_file.write_all(router_static_routers_rendered.as_bytes())?;

Ok((src_path, router_path))
}

Expand Down

0 comments on commit 3a71fee

Please sign in to comment.