diff --git a/include/Frate/Project/Config.hpp b/include/Frate/Project/Config.hpp index 5b90c08..80f101d 100644 --- a/include/Frate/Project/Config.hpp +++ b/include/Frate/Project/Config.hpp @@ -21,7 +21,7 @@ namespace Frate::Project { Config() = default; bool loaded_json{false}; std::filesystem::path template_path; - TemplateMeta current_template; + TemplateRenderer current_template; std::vector template_files; std::vector script_files; std::string name{"default"}; @@ -40,7 +40,7 @@ namespace Frate::Project { //Moving to local [[deprecated("Use Local::build_command")]] - std::string build_command{"cmake --build ."}; + std::string build_command{"cmake"}; [[deprecated("Use Local::test_command")]] std::string test_command{"ctest"}; [[deprecated("Use Local::run_command")]] diff --git a/include/Frate/Template/Manager.hpp b/include/Frate/Template/Manager.hpp index 12fddc6..b4eaab7 100644 --- a/include/Frate/Template/Manager.hpp +++ b/include/Frate/Template/Manager.hpp @@ -12,7 +12,7 @@ namespace Frate::Project { std::string branch; std::unordered_map> + std::unordered_map> installed; bool index_loaded = false; @@ -26,7 +26,7 @@ namespace Frate::Project { * @param hash the hash of the template if it is installed * @return true if the template is installed */ - Project::TemplateMeta &find_template(const std::string &name, + Project::TemplateRenderer &find_template(const std::string &name, std::string &hash); /* * Checks if a template specifed is installed @@ -53,7 +53,7 @@ namespace Frate::Project { /* * Installs a template based on the local index, if hash is not provided then it will defult to the latest hash */ - TemplateMeta install(TemplateIndexEntry &entry); + TemplateRenderer install(TemplateIndexEntry &entry); /* * Install the local latest based on the latest hash in the index is * installed @@ -61,9 +61,9 @@ namespace Frate::Project { * install that template * @param git url of the template to install */ - TemplateMeta getLatest(std::string &git_url); - TemplateMeta get(std::string &name,std::string &hash); - TemplateMeta promptList(); + TemplateRenderer getLatest(std::string &git_url); + TemplateRenderer get(std::string &name,std::string &hash); + TemplateRenderer promptList(); /* * Uninstalls a template * @param name the name of the template to uninstall @@ -96,7 +96,7 @@ namespace Frate::Project { * @return a vector of TemplateMeta objects */ std::unordered_map> & + std::unordered_map> & getInstalled(); /* * Grabs the current index from the the github repo, if called more than diff --git a/include/Frate/Template/Meta.hpp b/include/Frate/Template/Meta.hpp index fb83db1..b55537c 100644 --- a/include/Frate/Template/Meta.hpp +++ b/include/Frate/Template/Meta.hpp @@ -12,7 +12,7 @@ namespace Frate::Lua { namespace Frate::Project { class Config; - class TemplateMeta { + class TemplateRenderer { private: std::string name; std::string description; @@ -52,13 +52,13 @@ namespace Frate::Project { void run_prompts(std::shared_ptr config); public: - TemplateMeta(); - TemplateMeta(const nlohmann::json &json_obj); - TemplateMeta(TemplateIndexEntry &entry); - friend void from_json(const nlohmann::json &json_obj, TemplateMeta &temp); - friend void to_json(nlohmann::json &json_obj, const TemplateMeta &temp); + TemplateRenderer(); + TemplateRenderer(const nlohmann::json &json_obj); + TemplateRenderer(TemplateIndexEntry &entry); + friend void from_json(const nlohmann::json &json_obj, TemplateRenderer &temp); + friend void to_json(nlohmann::json &json_obj, const TemplateRenderer &temp); friend std::ostream &operator<<(std::ostream &os_stream, - const TemplateMeta &temp); + const TemplateRenderer &temp); /* * Builds the template into the the project path * and transfers the template config to the project config diff --git a/src/Command/Actions/New.cpp b/src/Command/Actions/New.cpp index 9c0e41f..93a191f 100644 --- a/src/Command/Actions/New.cpp +++ b/src/Command/Actions/New.cpp @@ -44,7 +44,7 @@ namespace Frate::Command::New { bool create(std::shared_ptr inter) { Utils::info << "Creating Project" << std::endl; - Project::TemplateMeta current_template; + Project::TemplateRenderer current_template; inter->templates->installAll(); diff --git a/src/Command/Actions/Run.cpp b/src/Command/Actions/Run.cpp index 86b9b04..f204fa9 100644 --- a/src/Command/Actions/Run.cpp +++ b/src/Command/Actions/Run.cpp @@ -13,7 +13,6 @@ namespace Frate::Command::Run { bool run(std::shared_ptr inter) { options(inter); - // inter->loadProjectJson(); inter->pro->load(); inter->pro->current_template.refresh(inter->pro, inter->local); std::cout << "Running project: " << inter->pro->name << std::endl; diff --git a/src/Template/Manager.cpp b/src/Template/Manager.cpp index 6c6d0f0..16e6309 100644 --- a/src/Template/Manager.cpp +++ b/src/Template/Manager.cpp @@ -112,7 +112,7 @@ namespace Frate::Project { return is_installed(entry.getName(), branch); } - Project::TemplateMeta &TemplateManager::find_template(const std::string &name, + Project::TemplateRenderer &TemplateManager::find_template(const std::string &name, std::string &hash) { if (!is_installed(name, hash)) { throw TemplateNotInstalled("Template not installed"); @@ -168,7 +168,7 @@ namespace Frate::Project { } std::unordered_map> & + std::unordered_map> & TemplateManager::getInstalled() { return installed; } @@ -227,7 +227,7 @@ namespace Frate::Project { } } - TemplateMeta TemplateManager::getLatest(std::string &git_url) { + TemplateRenderer TemplateManager::getLatest(std::string &git_url) { load_index(); for (TemplateIndexEntry template_info : index) { @@ -244,7 +244,7 @@ namespace Frate::Project { throw TemplateNotFoundInIndex("Template " + git_url + " not found in index"); } - TemplateMeta TemplateManager::promptList(){ + TemplateRenderer TemplateManager::promptList(){ load_index(); @@ -270,7 +270,7 @@ namespace Frate::Project { } throw TemplateNotFoundInIndex("Template " + template_name + " not found in index"); }; - TemplateMeta TemplateManager::get(std::string &name, std::string &hash) { + TemplateRenderer TemplateManager::get(std::string &name, std::string &hash) { load_index(); for (TemplateIndexEntry template_info : index) { @@ -290,7 +290,7 @@ namespace Frate::Project { throw TemplateNotFoundInIndex("Template " + name + " not found in index"); } - TemplateMeta TemplateManager::install(TemplateIndexEntry &template_info) { + TemplateRenderer TemplateManager::install(TemplateIndexEntry &template_info) { Utils::info << "Installing template: " << template_info.getName() << " on branch: " << branch << std::endl; diff --git a/src/Template/Meta.cpp b/src/Template/Meta.cpp index ad1f7d6..6facde2 100644 --- a/src/Template/Meta.cpp +++ b/src/Template/Meta.cpp @@ -15,22 +15,22 @@ namespace Frate::Project { using std::filesystem::directory_entry; - TemplateMeta::TemplateMeta(const nlohmann::json &json_obj): install_path(Constants::INSTALLED_TEMPLATE_PATH / this->name / this->hash) { + TemplateRenderer::TemplateRenderer(const nlohmann::json &json_obj): install_path(Constants::INSTALLED_TEMPLATE_PATH / this->name / this->hash) { Utils::verbose << "Creating template meta from json with contents: " << json_obj << std::endl; from_json(json_obj, *this); } - TemplateMeta::TemplateMeta(): install_path(Constants::INSTALLED_TEMPLATE_PATH / this->name / this->hash) { + TemplateRenderer::TemplateRenderer(): install_path(Constants::INSTALLED_TEMPLATE_PATH / this->name / this->hash) { } - TemplateMeta::TemplateMeta(TemplateIndexEntry &entry) + TemplateRenderer::TemplateRenderer(TemplateIndexEntry &entry) : name(entry.getName()), description(entry.getDescription()), hash(entry.getBranchHash(Constants::TEMPLATE_BRANCH)), git(entry.getGit()), install_path(Constants::INSTALLED_TEMPLATE_PATH / this->name / this->hash) {} - void from_json(const nlohmann::json &json_obj, TemplateMeta &temp) { + void from_json(const nlohmann::json &json_obj, TemplateRenderer &temp) { FROM_JSON_FIELD(temp, name); FROM_JSON_FIELD(temp, description); FROM_JSON_FIELD(temp, hash); @@ -39,14 +39,14 @@ namespace Frate::Project { temp.install_path = Constants::INSTALLED_TEMPLATE_PATH / temp.name / temp.hash; } - void to_json(nlohmann::json &json_obj, const TemplateMeta &temp) { + void to_json(nlohmann::json &json_obj, const TemplateRenderer &temp) { TO_JSON_FIELD(temp, name); TO_JSON_FIELD(temp, description); TO_JSON_FIELD(temp, hash); TO_JSON_FIELD(temp, git); } - std::ostream &operator<<(std::ostream &os_stream, const TemplateMeta &temp) { + std::ostream &operator<<(std::ostream &os_stream, const TemplateRenderer &temp) { os_stream << "Name: " << temp.name << std::endl; os_stream << "Description: " << temp.description << std::endl; os_stream << "Hash: " << temp.hash << std::endl; @@ -54,7 +54,7 @@ namespace Frate::Project { return os_stream; } - void TemplateMeta::build(std::shared_ptr config, std::shared_ptr local) { + void TemplateRenderer::build(std::shared_ptr config, std::shared_ptr local) { Utils::verbose << "Building template from template at: " << install_path << std::endl; @@ -108,7 +108,7 @@ namespace Frate::Project { render(config,local); } - void TemplateMeta::refresh(std::shared_ptr config, std::shared_ptr local) { + void TemplateRenderer::refresh(std::shared_ptr config, std::shared_ptr local) { std::filesystem::path override_path = config->path / "override"; @@ -144,7 +144,7 @@ namespace Frate::Project { render(config,local); } - void TemplateMeta::load_scripts() { + void TemplateRenderer::load_scripts() { if (file_map.empty()) { throw TemplateFileMapEmpty("File map is empty"); } @@ -206,7 +206,7 @@ namespace Frate::Project { scripts_loaded = true; } - void TemplateMeta::run_prompts(std::shared_ptr config){ + void TemplateRenderer::run_prompts(std::shared_ptr config){ for (auto [key, tmpl_prompt] : config->prompts) { Utils::CLI::Prompt prompt(tmpl_prompt.text, tmpl_prompt.default_value); if (tmpl_prompt.type == "bool") { @@ -230,7 +230,7 @@ namespace Frate::Project { } } - void TemplateMeta::install_cpm(std::shared_ptr config) { + void TemplateRenderer::install_cpm(std::shared_ptr config) { std::string cpm; cpm = Utils::fetchText("https://raw.githubusercontent.com/cpm-cmake/" @@ -250,7 +250,7 @@ namespace Frate::Project { cpm_file << cpm; } - void TemplateMeta::render(std::shared_ptr config, std::shared_ptr local) { + void TemplateRenderer::render(std::shared_ptr config, std::shared_ptr local) { Utils::info << "Rendering template" << std::endl; Utils::verbose << *this << std::endl; this->env = std::make_shared(config,local);