Skip to content

Commit

Permalink
feat: add frontend developer (wip -- needs testing)
Browse files Browse the repository at this point in the history
  • Loading branch information
ffmcgee725 committed Jun 9, 2024
1 parent 0646465 commit dd19c59
Show file tree
Hide file tree
Showing 31 changed files with 3,420 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/target
/src/templates/web_server/target
# TODO: add frontend build path

.env
.DS_Store
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ For more information on obtaining an API key, visit the [OpenAI documentation](h
To interact with the application, simply run it and follow the terminal prompts to specify the type of website you want to build. The application will use different agents to generate the necessary code.

The generated backend code can be found in `src/templates/web_server/src/main.rs`.
The frontend is under development and will be added in future updates.
The generated frontend code can be found in ``src/templates/web_app/src`.

## Running Tests

Expand Down
332 changes: 331 additions & 1 deletion src/ai_functions/frontend.rs

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions src/helpers/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use reqwest::Client;
use serde::de::DeserializeOwned;

pub const WEB_SERVER_PROJECT_PATH: &str = "src/templates/web_server";
pub const WEB_APP_PROJECT_PATH: &str = "src/templates/web_app";
const CODE_TEMPLATE_PATH: &str = "src/templates/web_server/src/code_template.rs";
const EXEC_MAIN_PATH: &str = "src/templates/web_server/src/main.rs";
const API_SCHEMA_JSON: &str = "schemas/api_schema.json";
Expand Down Expand Up @@ -92,6 +93,16 @@ pub fn save_api_endpoints(api_endpoints: &String) {
fs::write(path, api_endpoints).expect("Failed to write API endpoints to file");
}

pub fn save_frontend_code(frontend_path: &String, contents: &String) {
let path: String = format!("{}{}", WEB_APP_PROJECT_PATH, frontend_path);
fs::write(path, contents).expect("Something went wrong saving the file");
}

pub fn read_frontend_code_contents(frontend_path: &String) -> String {
let path: String = format!("{}{}", WEB_APP_PROJECT_PATH, frontend_path);
fs::read_to_string(path).expect("Something went wrong reading the file")
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
Loading

0 comments on commit dd19c59

Please sign in to comment.