From 164a84d89f3e4d30fb1221e84a15de6ffe297e44 Mon Sep 17 00:00:00 2001 From: Michael Wagner Date: Mon, 26 Jun 2023 08:39:50 -0400 Subject: [PATCH 1/6] feat: more clean up of shard file gen --- src/lucky_cli/shard_file_generator.cr | 28 +++++++++++---------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/lucky_cli/shard_file_generator.cr b/src/lucky_cli/shard_file_generator.cr index bb2d07e0..42896104 100644 --- a/src/lucky_cli/shard_file_generator.cr +++ b/src/lucky_cli/shard_file_generator.cr @@ -21,16 +21,12 @@ class ShardFileGenerator def template_folder LuckyTemplate.create_folder do |top_dir| - top_dir.add_file("shard.yml", <<-YAML) - #{shard_info} - #{shard_deps} - #{shard_dev_deps} - YAML + top_dir.add_file("shard.yml", shard_yml.to_yaml) end end - def shard_info : String - normalize_yaml({ + def shard_yml + { "name" => project_name, "version" => "0.1.0", "targets" => { @@ -38,19 +34,21 @@ class ShardFileGenerator "main" => Path.new("src", "#{project_name}.cr").to_s, }, }, - "crystal" => ">= #{Crystal::VERSION}", - }) + "crystal" => ">= #{Crystal::VERSION}", + "dependencies" => shard_deps, + "development_dependencies" => shard_dev_deps, + } end - def shard_deps + private def shard_deps deps = project_base_deps if generate_auth? deps = deps.merge(project_auth_deps) end - normalize_yaml({"dependencies" => deps}) + deps end - def shard_dev_deps + private def shard_dev_deps deps = {} of String => String if browser? deps = deps.merge(project_browser_dev_deps) @@ -58,11 +56,7 @@ class ShardFileGenerator if with_sec_tester? deps = deps.merge(project_additional_dev_deps) end - normalize_yaml({"development_dependencies" => deps}) - end - - private def normalize_yaml(hash) : String - hash.to_yaml.lines[1..].join('\n') + deps end private def project_base_deps From cf52dcc78bdfb2dfcf2671b6ed6e38f6dc289b95 Mon Sep 17 00:00:00 2001 From: Michael Wagner Date: Thu, 13 Jul 2023 08:58:21 -0400 Subject: [PATCH 2/6] feat: browser_src_template to lucky_template --- .../{bs-config.js => bs-config.js.ecr} | 0 .../config/{html_page.cr => html_page.cr.ecr} | 0 .../{package.json => package.json.ecr} | 0 .../public/{favicon.ico => favicon.ico.ecr} | 0 ...ix-manifest.json => mix-manifest.json.ecr} | 0 .../public/{robots.txt => robots.txt.ecr} | 0 ...ky_flow.cr => configure_lucky_flow.cr.ecr} | 0 .../flows/{base_flow.cr => base_flow.cr.ecr} | 0 ...ase_component.cr => base_component.cr.ecr} | 0 .../shared/{field.cr => field.cr.ecr} | 0 .../{field_errors.cr => field_errors.cr.ecr} | 0 ...lash_messages.cr => flash_messages.cr.ecr} | 0 .../{layout_head.cr => layout_head.cr.ecr} | 0 .../src/css/{app.scss => app.scss.ecr} | 0 .../src/js/{app.js => app.js.ecr} | 0 .../errors/{show_page.cr => show_page.cr.ecr} | 0 .../{main_layout.cr => main_layout.cr.ecr} | 0 .../{webpack.mix.js => webpack.mix.js.ecr} | 0 src/lucky_cli/browser_src_template.cr | 117 +++++++++++++++++- 19 files changed, 115 insertions(+), 2 deletions(-) rename src/browser_app_skeleton/{bs-config.js => bs-config.js.ecr} (100%) rename src/browser_app_skeleton/config/{html_page.cr => html_page.cr.ecr} (100%) rename src/browser_app_skeleton/{package.json => package.json.ecr} (100%) rename src/browser_app_skeleton/public/{favicon.ico => favicon.ico.ecr} (100%) rename src/browser_app_skeleton/public/{mix-manifest.json => mix-manifest.json.ecr} (100%) rename src/browser_app_skeleton/public/{robots.txt => robots.txt.ecr} (100%) rename src/browser_app_skeleton/spec/setup/{configure_lucky_flow.cr => configure_lucky_flow.cr.ecr} (100%) rename src/browser_app_skeleton/spec/support/flows/{base_flow.cr => base_flow.cr.ecr} (100%) rename src/browser_app_skeleton/src/components/{base_component.cr => base_component.cr.ecr} (100%) rename src/browser_app_skeleton/src/components/shared/{field.cr => field.cr.ecr} (100%) rename src/browser_app_skeleton/src/components/shared/{field_errors.cr => field_errors.cr.ecr} (100%) rename src/browser_app_skeleton/src/components/shared/{flash_messages.cr => flash_messages.cr.ecr} (100%) rename src/browser_app_skeleton/src/components/shared/{layout_head.cr => layout_head.cr.ecr} (100%) rename src/browser_app_skeleton/src/css/{app.scss => app.scss.ecr} (100%) rename src/browser_app_skeleton/src/js/{app.js => app.js.ecr} (100%) rename src/browser_app_skeleton/src/pages/errors/{show_page.cr => show_page.cr.ecr} (100%) rename src/browser_app_skeleton/src/pages/{main_layout.cr => main_layout.cr.ecr} (100%) rename src/browser_app_skeleton/{webpack.mix.js => webpack.mix.js.ecr} (100%) diff --git a/src/browser_app_skeleton/bs-config.js b/src/browser_app_skeleton/bs-config.js.ecr similarity index 100% rename from src/browser_app_skeleton/bs-config.js rename to src/browser_app_skeleton/bs-config.js.ecr diff --git a/src/browser_app_skeleton/config/html_page.cr b/src/browser_app_skeleton/config/html_page.cr.ecr similarity index 100% rename from src/browser_app_skeleton/config/html_page.cr rename to src/browser_app_skeleton/config/html_page.cr.ecr diff --git a/src/browser_app_skeleton/package.json b/src/browser_app_skeleton/package.json.ecr similarity index 100% rename from src/browser_app_skeleton/package.json rename to src/browser_app_skeleton/package.json.ecr diff --git a/src/browser_app_skeleton/public/favicon.ico b/src/browser_app_skeleton/public/favicon.ico.ecr similarity index 100% rename from src/browser_app_skeleton/public/favicon.ico rename to src/browser_app_skeleton/public/favicon.ico.ecr diff --git a/src/browser_app_skeleton/public/mix-manifest.json b/src/browser_app_skeleton/public/mix-manifest.json.ecr similarity index 100% rename from src/browser_app_skeleton/public/mix-manifest.json rename to src/browser_app_skeleton/public/mix-manifest.json.ecr diff --git a/src/browser_app_skeleton/public/robots.txt b/src/browser_app_skeleton/public/robots.txt.ecr similarity index 100% rename from src/browser_app_skeleton/public/robots.txt rename to src/browser_app_skeleton/public/robots.txt.ecr diff --git a/src/browser_app_skeleton/spec/setup/configure_lucky_flow.cr b/src/browser_app_skeleton/spec/setup/configure_lucky_flow.cr.ecr similarity index 100% rename from src/browser_app_skeleton/spec/setup/configure_lucky_flow.cr rename to src/browser_app_skeleton/spec/setup/configure_lucky_flow.cr.ecr diff --git a/src/browser_app_skeleton/spec/support/flows/base_flow.cr b/src/browser_app_skeleton/spec/support/flows/base_flow.cr.ecr similarity index 100% rename from src/browser_app_skeleton/spec/support/flows/base_flow.cr rename to src/browser_app_skeleton/spec/support/flows/base_flow.cr.ecr diff --git a/src/browser_app_skeleton/src/components/base_component.cr b/src/browser_app_skeleton/src/components/base_component.cr.ecr similarity index 100% rename from src/browser_app_skeleton/src/components/base_component.cr rename to src/browser_app_skeleton/src/components/base_component.cr.ecr diff --git a/src/browser_app_skeleton/src/components/shared/field.cr b/src/browser_app_skeleton/src/components/shared/field.cr.ecr similarity index 100% rename from src/browser_app_skeleton/src/components/shared/field.cr rename to src/browser_app_skeleton/src/components/shared/field.cr.ecr diff --git a/src/browser_app_skeleton/src/components/shared/field_errors.cr b/src/browser_app_skeleton/src/components/shared/field_errors.cr.ecr similarity index 100% rename from src/browser_app_skeleton/src/components/shared/field_errors.cr rename to src/browser_app_skeleton/src/components/shared/field_errors.cr.ecr diff --git a/src/browser_app_skeleton/src/components/shared/flash_messages.cr b/src/browser_app_skeleton/src/components/shared/flash_messages.cr.ecr similarity index 100% rename from src/browser_app_skeleton/src/components/shared/flash_messages.cr rename to src/browser_app_skeleton/src/components/shared/flash_messages.cr.ecr diff --git a/src/browser_app_skeleton/src/components/shared/layout_head.cr b/src/browser_app_skeleton/src/components/shared/layout_head.cr.ecr similarity index 100% rename from src/browser_app_skeleton/src/components/shared/layout_head.cr rename to src/browser_app_skeleton/src/components/shared/layout_head.cr.ecr diff --git a/src/browser_app_skeleton/src/css/app.scss b/src/browser_app_skeleton/src/css/app.scss.ecr similarity index 100% rename from src/browser_app_skeleton/src/css/app.scss rename to src/browser_app_skeleton/src/css/app.scss.ecr diff --git a/src/browser_app_skeleton/src/js/app.js b/src/browser_app_skeleton/src/js/app.js.ecr similarity index 100% rename from src/browser_app_skeleton/src/js/app.js rename to src/browser_app_skeleton/src/js/app.js.ecr diff --git a/src/browser_app_skeleton/src/pages/errors/show_page.cr b/src/browser_app_skeleton/src/pages/errors/show_page.cr.ecr similarity index 100% rename from src/browser_app_skeleton/src/pages/errors/show_page.cr rename to src/browser_app_skeleton/src/pages/errors/show_page.cr.ecr diff --git a/src/browser_app_skeleton/src/pages/main_layout.cr b/src/browser_app_skeleton/src/pages/main_layout.cr.ecr similarity index 100% rename from src/browser_app_skeleton/src/pages/main_layout.cr rename to src/browser_app_skeleton/src/pages/main_layout.cr.ecr diff --git a/src/browser_app_skeleton/webpack.mix.js b/src/browser_app_skeleton/webpack.mix.js.ecr similarity index 100% rename from src/browser_app_skeleton/webpack.mix.js rename to src/browser_app_skeleton/webpack.mix.js.ecr diff --git a/src/lucky_cli/browser_src_template.cr b/src/lucky_cli/browser_src_template.cr index e1d58e87..7b863774 100644 --- a/src/lucky_cli/browser_src_template.cr +++ b/src/lucky_cli/browser_src_template.cr @@ -1,9 +1,122 @@ require "random/secure" -class BrowserSrcTemplate < Teeplate::FileTree - directory "#{__DIR__}/../browser_app_skeleton" +class BrowserSrcTemplate getter? generate_auth def initialize(@generate_auth : Bool) end + + def render(path : Path) + LuckyTemplate.write!(path, template_folder) + end + + def template_folder + LuckyTemplate.create_folder do |root_dir| + root_dir.add_file("bs-config.js") do |io| + ECR.embed("#{__DIR__}/../browser_app_skeleton/bs-config.js.ecr", io) + end + root_dir.add_file("package.json") do |io| + ECR.embed("#{__DIR__}/../browser_app_skeleton/package.json.ecr", io) + end + root_dir.add_file("webpack.mix.js") do |io| + ECR.embed("#{__DIR__}/../browser_app_skeleton/webpack.mix.js.ecr", io) + end + root_dir.add_folder("config") do |config_dir| + config_dir.add_file("html_page.cr") do |io| + ECR.embed("#{__DIR__}/../browser_app_skeleton/config/html_page.cr.ecr", io) + end + end + root_dir.add_folder("db") do |db_dir| + db_dir.add_file("migrations/.keep") + end + root_dir.add_folder("public") do |public_dir| + public_dir.add_file("favicon.ico") do |io| + ECR.embed("#{__DIR__}/../browser_app_skeleton/public/favicon.ico.ecr", io) + end + public_dir.add_file("mix-manifest.json") do |io| + ECR.embed("#{__DIR__}/../browser_app_skeleton/public/mix-manifest.json.ecr", io) + end + public_dir.add_file("robots.txt") do |io| + ECR.embed("#{__DIR__}/../browser_app_skeleton/public/robots.txt.ecr", io) + end + public_dir.add_file("assets/images/.keep") + end + root_dir.insert_folder("spec", spec_folder) + root_dir.insert_folder("src", src_folder) + end + end + + private def spec_folder + LuckyTemplate.create_folder do |spec_dir| + spec_dir.add_file("flows/.keep") + spec_dir.add_folder("setup") do |setup_dir| + setup_dir.add_file(".keep") + setup_dir.add_file("configure_lucky_flow.cr") do |io| + ECR.embed("#{__DIR__}/../browser_app_skeleton/spec/setup/configure_lucky_flow.cr.ecr", io) + end + end + spec_dir.add_folder("support") do |support_dir| + support_dir.add_file(".keep") + support_dir.add_file("factories/.keep") + support_dir.add_file("flows/base_flow.cr") do |io| + ECR.embed("#{__DIR__}/../browser_app_skeleton/spec/support/flows/base_flow.cr.ecr", io) + end + end + end + end + + private def src_folder + LuckyTemplate.create_folder do |src_dir| + src_dir.add_file("actions/browser_action.cr") do |io| + ECR.embed("#{__DIR__}/../browser_app_skeleton/src/actions/browser_action.cr.ecr", io) + end + src_dir.add_folder("components") do |components_dir| + components_dir.add_file(".keep") + components_dir.add_file("base_component.cr") do |io| + ECR.embed("#{__DIR__}/../browser_app_skeleton/src/components/base_component.cr.ecr", io) + end + components_dir.add_folder("shared") do |shared_dir| + shared_dir.add_file("field.cr") do |io| + ECR.embed("#{__DIR__}/../browser_app_skeleton/src/components/shared/field.cr.ecr", io) + end + shared_dir.add_file("field_errors.cr") do |io| + ECR.embed("#{__DIR__}/../browser_app_skeleton/src/components/shared/field_errors.cr.ecr", io) + end + shared_dir.add_file("flash_messages.cr") do |io| + ECR.embed("#{__DIR__}/../browser_app_skeleton/src/components/shared/flash_messages.cr.ecr", io) + end + shared_dir.add_file("layout_head.cr") do |io| + ECR.embed("#{__DIR__}/../browser_app_skeleton/src/components/shared/layout_head.cr.ecr", io) + end + end + end + src_dir.add_folder("css") do |css_dir| + css_dir.add_file("app.scss") do |io| + ECR.embed("#{__DIR__}/../browser_app_skeleton/src/css/app.scss.ecr", io) + end + css_dir.add_folder("components/.keep") + css_dir.add_folder("mixins/.keep") + css_dir.add_folder("variables/.keep") + end + src_dir.add_file("emails/.keep") + src_dir.add_file("js/app.js") do |io| + ECR.embed("#{__DIR__}/../browser_app_skeleton/src/js/app.js.ecr", io) + end + src_dir.add_folder("models") do |models_dir| + models_dir.add_file("mixins/.keep") + end + src_dir.add_folder("operations") do |ops_dir| + ops_dir.add_file(".keep") + ops_dir.add_file("mixins/.keep") + end + src_dir.add_folder("pages") do |pages_dir| + pages_dir.add_file("main_layout.cr") do |io| + ECR.embed("#{__DIR__}/../browser_app_skeleton/src/pages/main_layout.cr.ecr", io) + end + pages_dir.add_file("errors/show_page.cr") do |io| + ECR.embed("#{__DIR__}/../browser_app_skeleton/src/pages/show_page.cr.ecr", io) + end + end + end + end end From 91bd3748432505a39f10c96289258b9085c94a6f Mon Sep 17 00:00:00 2001 From: Michael Wagner Date: Sun, 30 Jul 2023 09:53:39 -0400 Subject: [PATCH 3/6] feat: migrated web_app_skeleton --- src/generators/web.cr | 6 +- src/lucky_cli/src_template.cr | 218 +++++++++++++++++- src/web_app_skeleton/{.env => .env.ecr} | 0 .../{Procfile => Procfile.ecr} | 0 .../{application.cr => application.cr.ecr} | 0 .../config/{colors.cr => colors.cr.ecr} | 0 .../config/{email.cr => email.cr.ecr} | 0 .../config/{env.cr => env.cr.ecr} | 0 ...{error_handler.cr => error_handler.cr.ecr} | 0 .../config/{log.cr => log.cr.ecr} | 0 .../{route_helper.cr => route_helper.cr.ecr} | 0 .../config/{watch.yml => watch.yml.ecr} | 0 ...ker-compose.yml => docker-compose.yml.ecr} | 0 .../{wait-for-it.sh => wait-for-it.sh.ecr} | 0 ...{function_helpers => function_helpers.ecr} | 0 .../{text_helpers => text_helpers.ecr} | 0 ...lean_database.cr => clean_database.cr.ecr} | 0 .../{reset_emails.cr => reset_emails.cr.ecr} | 0 ...etup_database.cr => setup_database.cr.ecr} | 0 .../{app_database.cr => app_database.cr.ecr} | 0 .../{base_email.cr => base_email.cr.ecr} | 0 .../{base_model.cr => base_model.cr.ecr} | 0 ..._project_name}}.cr => project_name.cr.ecr} | 0 ...e_serializer.cr => base_serializer.cr.ecr} | 0 ..._serializer.cr => error_serializer.cr.ecr} | 0 .../{tasks.cr => tasks.cr.ecr} | 0 ...{required_data.cr => required_data.cr.ecr} | 0 .../{sample_data.cr => sample_data.cr.ecr} | 0 28 files changed, 218 insertions(+), 6 deletions(-) rename src/web_app_skeleton/{.env => .env.ecr} (100%) rename src/web_app_skeleton/{Procfile => Procfile.ecr} (100%) rename src/web_app_skeleton/config/{application.cr => application.cr.ecr} (100%) rename src/web_app_skeleton/config/{colors.cr => colors.cr.ecr} (100%) rename src/web_app_skeleton/config/{email.cr => email.cr.ecr} (100%) rename src/web_app_skeleton/config/{env.cr => env.cr.ecr} (100%) rename src/web_app_skeleton/config/{error_handler.cr => error_handler.cr.ecr} (100%) rename src/web_app_skeleton/config/{log.cr => log.cr.ecr} (100%) rename src/web_app_skeleton/config/{route_helper.cr => route_helper.cr.ecr} (100%) rename src/web_app_skeleton/config/{watch.yml => watch.yml.ecr} (100%) rename src/web_app_skeleton/{docker-compose.yml => docker-compose.yml.ecr} (100%) rename src/web_app_skeleton/docker/{wait-for-it.sh => wait-for-it.sh.ecr} (100%) rename src/web_app_skeleton/script/helpers/{function_helpers => function_helpers.ecr} (100%) rename src/web_app_skeleton/script/helpers/{text_helpers => text_helpers.ecr} (100%) rename src/web_app_skeleton/spec/setup/{clean_database.cr => clean_database.cr.ecr} (100%) rename src/web_app_skeleton/spec/setup/{reset_emails.cr => reset_emails.cr.ecr} (100%) rename src/web_app_skeleton/spec/setup/{setup_database.cr => setup_database.cr.ecr} (100%) rename src/web_app_skeleton/src/{app_database.cr => app_database.cr.ecr} (100%) rename src/web_app_skeleton/src/emails/{base_email.cr => base_email.cr.ecr} (100%) rename src/web_app_skeleton/src/models/{base_model.cr => base_model.cr.ecr} (100%) rename src/web_app_skeleton/src/{{{crystal_project_name}}.cr => project_name.cr.ecr} (100%) rename src/web_app_skeleton/src/serializers/{base_serializer.cr => base_serializer.cr.ecr} (100%) rename src/web_app_skeleton/src/serializers/{error_serializer.cr => error_serializer.cr.ecr} (100%) rename src/web_app_skeleton/{tasks.cr => tasks.cr.ecr} (100%) rename src/web_app_skeleton/tasks/db/seed/{required_data.cr => required_data.cr.ecr} (100%) rename src/web_app_skeleton/tasks/db/seed/{sample_data.cr => sample_data.cr.ecr} (100%) diff --git a/src/generators/web.cr b/src/generators/web.cr index 47345b18..8e5432fe 100644 --- a/src/generators/web.cr +++ b/src/generators/web.cr @@ -115,7 +115,6 @@ class LuckyCli::Generators::Web end end - # TODO: migrate to lucky_template private def add_default_lucky_structure_to_src SrcTemplate.new( project_name, @@ -123,13 +122,12 @@ class LuckyCli::Generators::Web api_only: api_only?, with_sec_tester: with_sec_tester? ) - .render(project_dir, force: true) + .render(Path[project_dir]) end - # TODO: migrate to lucky_template private def add_browser_app_structure_to_src BrowserSrcTemplate.new(generate_auth: generate_auth?) - .render(project_dir, force: true) + .render(Path[project_dir]) end private def add_base_auth_to_src diff --git a/src/lucky_cli/src_template.cr b/src/lucky_cli/src_template.cr index 7ae56cc4..9b7308cb 100644 --- a/src/lucky_cli/src_template.cr +++ b/src/lucky_cli/src_template.cr @@ -1,7 +1,6 @@ require "random/secure" -class SrcTemplate < Teeplate::FileTree - directory "#{__DIR__}/../web_app_skeleton" +class SrcTemplate getter project_name getter? api_only, generate_auth, with_sec_tester getter crystal_project_name : String @@ -21,4 +20,219 @@ class SrcTemplate < Teeplate::FileTree def secret_key_base Random::Secure.base64(32) end + + def render(path : Path) + LuckyTemplate.write!(path, template_folder) + end + + def template_folder + LuckyTemplate.create_folder do |root_dir| + root_dir.add_file(".crystal-version") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/.crystal-version.ecr", io) + end + root_dir.add_file(".env") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/.env.ecr", io) + end + root_dir.add_file("docker-compose.yml") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/docker-compose.yml.ecr", io) + end + root_dir.add_file("Procfile") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/Procfile.ecr", io) + end + root_dir.add_file("Procfile.dev") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/Procfile.dev.ecr", io) + end + root_dir.add_file("README.md") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/README.md.ecr", io) + end + root_dir.add_file("tasks.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/tasks.cr.ecr", io) + end + root_dir.add_folder(".github") do |dot_gh_dir| + dot_gh_dir.add_folder("workflows") do |workflows_dir| + workflows_dir.add_file("ci.yml") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/.github/workflows/ci.yml.ecr", io) + end + end + end + root_dir.add_folder("config") do |config_dir| + config_dir.add_file("application.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/config/application.cr.ecr", io) + end + config_dir.add_file("colors.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/config/colors.cr.ecr", io) + end + config_dir.add_file("cookies.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/config/cookies.cr.ecr", io) + end + config_dir.add_file("database.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/config/database.cr.ecr", io) + end + config_dir.add_file("email.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/config/email.cr.ecr", io) + end + config_dir.add_file("env.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/config/env.cr.ecr", io) + end + config_dir.add_file("error_handler.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/config/error_handler.cr.ecr", io) + end + config_dir.add_file("log.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/config/log.cr.ecr", io) + end + config_dir.add_file("route_helper.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/config/route_helper.cr.ecr", io) + end + config_dir.add_file("server.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/config/server.cr.ecr", io) + end + config_dir.add_file("watch.yml") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/config/watch.yml.ecr", io) + end + end + root_dir.add_folder("db") do |db_dir| + db_dir.add_file("migrations/.keep") + end + root_dir.add_folder("docker") do |docker_dir| + docker_dir.add_file("dev_entrypoint.sh") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/docker/dev_entrypoint.sh.ecr", io) + end + docker_dir.add_file("development.dockerfile") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/docker/development.dockerfile.ecr", io) + end + docker_dir.add_file("wait-for-it.sh") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/docker/wait-for-it.sh.ecr", io) + end + end + root_dir.add_folder("script") do |script_dir| + script_dir.add_file("setup") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/script/setup.ecr", io) + end + script_dir.add_file("system_check") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/script/system_check.ecr", io) + end + script_dir.add_folder("helpers") do |helpers_dir| + helpers_dir.add_file("function_helpers") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/script/helpers/function_helpers.ecr", io) + end + helpers_dir.add_file("text_helpers") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/script/helpers/text_helpers.ecr", io) + end + end + end + root_dir.insert_folder("spec", spec_folder) + root_dir.insert_folder("src", src_folder) + root_dir.insert_folder("tasks", tasks_folder) + end + end + + private def spec_folder + LuckyTemplate.create_folder do |spec_dir| + spec_dir.add_file("spec_helper.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/spec/spec_helper.cr.ecr", io) + end + spec_dir.add_folder("setup") do |setup_dir| + setup_dir.add_file("clean_database.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/spec/setup/clean_database.cr.ecr", io) + end + setup_dir.add_file("reset_emails.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/spec/setup/reset_emails.cr.ecr", io) + end + setup_dir.add_file("setup_database.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/spec/setup/setup_database.cr.ecr", io) + end + setup_dir.add_file("start_app_server.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/spec/setup/start_app_server.cr.ecr", io) + end + end + spec_dir.add_folder("support") do |support_dir| + support_dir.add_file(".keep") + support_dir.add_file("api_client.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/spec/support/api_client.cr.ecr", io) + end + support_dir.add_file("factories/.keep") + end + end + end + + private def src_folder + LuckyTemplate.create_folder do |src_dir| + src_dir.add_file("app.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/src/app.cr.ecr", io) + end + src_dir.add_file("app_database.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/src/app_database.cr.ecr", io) + end + src_dir.add_file("app_server.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/src/app_server.cr.ecr", io) + end + src_dir.add_file("shards.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/src/shards.cr.ecr", io) + end + src_dir.add_file("start_server.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/src/start_server.cr.ecr", io) + end + src_dir.add_file("#{crystal_project_name}.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/src/project_name.cr.ecr", io) + end + src_dir.add_folder("actions") do |actions_dir| + actions_dir.add_file("api_action.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/src/actions/api_action.cr.ecr", io) + end + actions_dir.add_folder("errors") do |errors_dir| + errors_dir.add_file("show.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/src/actions/errors/show.cr.ecr", io) + end + end + actions_dir.add_folder("home") do |home_dir| + home_dir.add_file("index.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/src/actions/home/index.cr.ecr", io) + end + end + actions_dir.add_file("mixins/.keep") + end + src_dir.add_folder("emails") do |emails_dir| + emails_dir.add_file("base_email.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/src/emails/base_email.cr.ecr", io) + end + end + src_dir.add_folder("models") do |models_dir| + models_dir.add_file("base_model.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/src/models/base_model.cr.ecr", io) + end + models_dir.add_file("mixins/.keep") + end + src_dir.add_folder("operations") do |ops_dir| + ops_dir.add_file(".keep") + ops_dir.add_file("mixins/.keep") + end + src_dir.add_folder("queries") do |queries_dir| + queries_dir.add_file(".keep") + queries_dir.add_file("mixins/.keep") + end + src_dir.add_folder("serializers") do |serializers_dir| + serializers_dir.add_file(".keep") + serializers_dir.add_file("base_serializer.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/src/serializers/base_serializer.cr.ecr", io) + end + serializers_dir.add_file("error_serializer.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/src/serializers/error_serializer.cr.ecr", io) + end + end + end + end + + private def tasks_folder + LuckyTemplate.create_folder do |tasks_dir| + tasks_dir.add_file(".keep") + tasks_dir.add_folder("db/seed") do |seed_dir| + seed_dir.add_file("required_data.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/tasks/db/seed/required_data.cr.ecr", io) + end + seed_dir.add_file("sample_data.cr") do |io| + ECR.embed("#{__DIR__}/../web_app_skeleton/tasks/db/seed/sample_data.cr.ecr", io) + end + end + end + end end diff --git a/src/web_app_skeleton/.env b/src/web_app_skeleton/.env.ecr similarity index 100% rename from src/web_app_skeleton/.env rename to src/web_app_skeleton/.env.ecr diff --git a/src/web_app_skeleton/Procfile b/src/web_app_skeleton/Procfile.ecr similarity index 100% rename from src/web_app_skeleton/Procfile rename to src/web_app_skeleton/Procfile.ecr diff --git a/src/web_app_skeleton/config/application.cr b/src/web_app_skeleton/config/application.cr.ecr similarity index 100% rename from src/web_app_skeleton/config/application.cr rename to src/web_app_skeleton/config/application.cr.ecr diff --git a/src/web_app_skeleton/config/colors.cr b/src/web_app_skeleton/config/colors.cr.ecr similarity index 100% rename from src/web_app_skeleton/config/colors.cr rename to src/web_app_skeleton/config/colors.cr.ecr diff --git a/src/web_app_skeleton/config/email.cr b/src/web_app_skeleton/config/email.cr.ecr similarity index 100% rename from src/web_app_skeleton/config/email.cr rename to src/web_app_skeleton/config/email.cr.ecr diff --git a/src/web_app_skeleton/config/env.cr b/src/web_app_skeleton/config/env.cr.ecr similarity index 100% rename from src/web_app_skeleton/config/env.cr rename to src/web_app_skeleton/config/env.cr.ecr diff --git a/src/web_app_skeleton/config/error_handler.cr b/src/web_app_skeleton/config/error_handler.cr.ecr similarity index 100% rename from src/web_app_skeleton/config/error_handler.cr rename to src/web_app_skeleton/config/error_handler.cr.ecr diff --git a/src/web_app_skeleton/config/log.cr b/src/web_app_skeleton/config/log.cr.ecr similarity index 100% rename from src/web_app_skeleton/config/log.cr rename to src/web_app_skeleton/config/log.cr.ecr diff --git a/src/web_app_skeleton/config/route_helper.cr b/src/web_app_skeleton/config/route_helper.cr.ecr similarity index 100% rename from src/web_app_skeleton/config/route_helper.cr rename to src/web_app_skeleton/config/route_helper.cr.ecr diff --git a/src/web_app_skeleton/config/watch.yml b/src/web_app_skeleton/config/watch.yml.ecr similarity index 100% rename from src/web_app_skeleton/config/watch.yml rename to src/web_app_skeleton/config/watch.yml.ecr diff --git a/src/web_app_skeleton/docker-compose.yml b/src/web_app_skeleton/docker-compose.yml.ecr similarity index 100% rename from src/web_app_skeleton/docker-compose.yml rename to src/web_app_skeleton/docker-compose.yml.ecr diff --git a/src/web_app_skeleton/docker/wait-for-it.sh b/src/web_app_skeleton/docker/wait-for-it.sh.ecr similarity index 100% rename from src/web_app_skeleton/docker/wait-for-it.sh rename to src/web_app_skeleton/docker/wait-for-it.sh.ecr diff --git a/src/web_app_skeleton/script/helpers/function_helpers b/src/web_app_skeleton/script/helpers/function_helpers.ecr similarity index 100% rename from src/web_app_skeleton/script/helpers/function_helpers rename to src/web_app_skeleton/script/helpers/function_helpers.ecr diff --git a/src/web_app_skeleton/script/helpers/text_helpers b/src/web_app_skeleton/script/helpers/text_helpers.ecr similarity index 100% rename from src/web_app_skeleton/script/helpers/text_helpers rename to src/web_app_skeleton/script/helpers/text_helpers.ecr diff --git a/src/web_app_skeleton/spec/setup/clean_database.cr b/src/web_app_skeleton/spec/setup/clean_database.cr.ecr similarity index 100% rename from src/web_app_skeleton/spec/setup/clean_database.cr rename to src/web_app_skeleton/spec/setup/clean_database.cr.ecr diff --git a/src/web_app_skeleton/spec/setup/reset_emails.cr b/src/web_app_skeleton/spec/setup/reset_emails.cr.ecr similarity index 100% rename from src/web_app_skeleton/spec/setup/reset_emails.cr rename to src/web_app_skeleton/spec/setup/reset_emails.cr.ecr diff --git a/src/web_app_skeleton/spec/setup/setup_database.cr b/src/web_app_skeleton/spec/setup/setup_database.cr.ecr similarity index 100% rename from src/web_app_skeleton/spec/setup/setup_database.cr rename to src/web_app_skeleton/spec/setup/setup_database.cr.ecr diff --git a/src/web_app_skeleton/src/app_database.cr b/src/web_app_skeleton/src/app_database.cr.ecr similarity index 100% rename from src/web_app_skeleton/src/app_database.cr rename to src/web_app_skeleton/src/app_database.cr.ecr diff --git a/src/web_app_skeleton/src/emails/base_email.cr b/src/web_app_skeleton/src/emails/base_email.cr.ecr similarity index 100% rename from src/web_app_skeleton/src/emails/base_email.cr rename to src/web_app_skeleton/src/emails/base_email.cr.ecr diff --git a/src/web_app_skeleton/src/models/base_model.cr b/src/web_app_skeleton/src/models/base_model.cr.ecr similarity index 100% rename from src/web_app_skeleton/src/models/base_model.cr rename to src/web_app_skeleton/src/models/base_model.cr.ecr diff --git a/src/web_app_skeleton/src/{{crystal_project_name}}.cr b/src/web_app_skeleton/src/project_name.cr.ecr similarity index 100% rename from src/web_app_skeleton/src/{{crystal_project_name}}.cr rename to src/web_app_skeleton/src/project_name.cr.ecr diff --git a/src/web_app_skeleton/src/serializers/base_serializer.cr b/src/web_app_skeleton/src/serializers/base_serializer.cr.ecr similarity index 100% rename from src/web_app_skeleton/src/serializers/base_serializer.cr rename to src/web_app_skeleton/src/serializers/base_serializer.cr.ecr diff --git a/src/web_app_skeleton/src/serializers/error_serializer.cr b/src/web_app_skeleton/src/serializers/error_serializer.cr.ecr similarity index 100% rename from src/web_app_skeleton/src/serializers/error_serializer.cr rename to src/web_app_skeleton/src/serializers/error_serializer.cr.ecr diff --git a/src/web_app_skeleton/tasks.cr b/src/web_app_skeleton/tasks.cr.ecr similarity index 100% rename from src/web_app_skeleton/tasks.cr rename to src/web_app_skeleton/tasks.cr.ecr diff --git a/src/web_app_skeleton/tasks/db/seed/required_data.cr b/src/web_app_skeleton/tasks/db/seed/required_data.cr.ecr similarity index 100% rename from src/web_app_skeleton/tasks/db/seed/required_data.cr rename to src/web_app_skeleton/tasks/db/seed/required_data.cr.ecr diff --git a/src/web_app_skeleton/tasks/db/seed/sample_data.cr b/src/web_app_skeleton/tasks/db/seed/sample_data.cr.ecr similarity index 100% rename from src/web_app_skeleton/tasks/db/seed/sample_data.cr rename to src/web_app_skeleton/tasks/db/seed/sample_data.cr.ecr From 3fbfa2dcbc86af74c4afcac00bc5cf29268bb1b2 Mon Sep 17 00:00:00 2001 From: Michael Wagner Date: Sun, 30 Jul 2023 10:04:02 -0400 Subject: [PATCH 4/6] fix: typo --- src/lucky_cli/browser_src_template.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lucky_cli/browser_src_template.cr b/src/lucky_cli/browser_src_template.cr index 7b863774..d7156b85 100644 --- a/src/lucky_cli/browser_src_template.cr +++ b/src/lucky_cli/browser_src_template.cr @@ -114,7 +114,7 @@ class BrowserSrcTemplate ECR.embed("#{__DIR__}/../browser_app_skeleton/src/pages/main_layout.cr.ecr", io) end pages_dir.add_file("errors/show_page.cr") do |io| - ECR.embed("#{__DIR__}/../browser_app_skeleton/src/pages/show_page.cr.ecr", io) + ECR.embed("#{__DIR__}/../browser_app_skeleton/src/pages/errors/show_page.cr.ecr", io) end end end From 098fa3d5421f4cfc5529981281a6b88d21be25cd Mon Sep 17 00:00:00 2001 From: Michael Wagner Date: Sun, 30 Jul 2023 12:11:53 -0400 Subject: [PATCH 5/6] fix: script permissions --- shard.yml | 2 +- src/lucky_cli/src_template.cr | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/shard.yml b/shard.yml index 5015d652..f182ea44 100644 --- a/shard.yml +++ b/shard.yml @@ -18,7 +18,7 @@ dependencies: version: ~> 0.8.5 lucky_template: github: luckyframework/lucky_template - version: ~> 0.1.0 + version: ~> 0.2.0 lucky_task: github: luckyframework/lucky_task version: ~> 0.1.1 diff --git a/src/lucky_cli/src_template.cr b/src/lucky_cli/src_template.cr index 9b7308cb..262a8713 100644 --- a/src/lucky_cli/src_template.cr +++ b/src/lucky_cli/src_template.cr @@ -94,21 +94,21 @@ class SrcTemplate db_dir.add_file("migrations/.keep") end root_dir.add_folder("docker") do |docker_dir| - docker_dir.add_file("dev_entrypoint.sh") do |io| + docker_dir.add_file("dev_entrypoint.sh", 0o755) do |io| ECR.embed("#{__DIR__}/../web_app_skeleton/docker/dev_entrypoint.sh.ecr", io) end docker_dir.add_file("development.dockerfile") do |io| ECR.embed("#{__DIR__}/../web_app_skeleton/docker/development.dockerfile.ecr", io) end - docker_dir.add_file("wait-for-it.sh") do |io| + docker_dir.add_file("wait-for-it.sh", 0o755) do |io| ECR.embed("#{__DIR__}/../web_app_skeleton/docker/wait-for-it.sh.ecr", io) end end root_dir.add_folder("script") do |script_dir| - script_dir.add_file("setup") do |io| + script_dir.add_file("setup", 0o755) do |io| ECR.embed("#{__DIR__}/../web_app_skeleton/script/setup.ecr", io) end - script_dir.add_file("system_check") do |io| + script_dir.add_file("system_check", 0o755) do |io| ECR.embed("#{__DIR__}/../web_app_skeleton/script/system_check.ecr", io) end script_dir.add_folder("helpers") do |helpers_dir| From de137592d5d5dcfe10fc7c6587effef290d9c539 Mon Sep 17 00:00:00 2001 From: Michael Wagner Date: Wed, 20 Sep 2023 21:00:16 -0400 Subject: [PATCH 6/6] feat!: remove teeplate dependency --- shard.yml | 3 --- src/lucky_cli.cr | 1 - 2 files changed, 4 deletions(-) diff --git a/shard.yml b/shard.yml index f182ea44..dda5846d 100644 --- a/shard.yml +++ b/shard.yml @@ -13,9 +13,6 @@ crystal: ">= 1.6.0" license: MIT dependencies: - teeplate: - github: luckyframework/teeplate - version: ~> 0.8.5 lucky_template: github: luckyframework/lucky_template version: ~> 0.2.0 diff --git a/src/lucky_cli.cr b/src/lucky_cli.cr index 6852fb54..97f114bc 100644 --- a/src/lucky_cli.cr +++ b/src/lucky_cli.cr @@ -1,4 +1,3 @@ -require "teeplate" require "lucky_template" require "lucky_task" require "nox"