Skip to content

Commit

Permalink
Change default generated app to build a generic target (#742)
Browse files Browse the repository at this point in the history
This allows for easier devops/DX by being able to have a reliable bin/app generated on build
Which greatly cleans up universal Dockerfiles

Resolves #735
  • Loading branch information
grepsedawk authored Mar 27, 2022
1 parent cb8e4cd commit ff2c0da
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
1 change: 0 additions & 1 deletion spec/integration/init_web_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ describe "Initializing a new web project" do

File.delete("test-project/.env")
compile_and_run_specs_on_test_project
File.read("test-project/Procfile").should contain "test_project"
File.read(".github/workflows/ci.yml").should contain "postgres"
File.read("test-project/public/mix-manifest.json").should contain "images/cat.gif"
File.exists?("test-project/public/favicon.ico").should eq true
Expand Down
5 changes: 5 additions & 0 deletions src/generators/web.cr
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class LuckyCli::Generators::Web
def run
ensure_directory_does_not_exist
generate_default_crystal_project
rename_shard_target_to_app
add_deps_to_shard_file
remove_generated_src_files
remove_generated_spec_files
Expand Down Expand Up @@ -150,6 +151,10 @@ class LuckyCli::Generators::Web
error: STDERR
end

private def rename_shard_target_to_app
replace_text "shard.yml", from: "#{project_name}:", to: "app:"
end

private def add_deps_to_shard_file
append_text to: "shard.yml", text: <<-DEPS_LIST
dependencies:
Expand Down
9 changes: 9 additions & 0 deletions src/lucky_cli/generator_helpers.cr
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ module LuckyCli::GeneratorHelpers
end
end

def replace_text(filename, from, to)
within_project do
File.write(
filename,
File.read(filename).gsub(from, to)
)
end
end

def run_command(command)
within_project do
Process.run command,
Expand Down
2 changes: 2 additions & 0 deletions src/web_app_skeleton/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
web: bin/app
release: lucky db.migrate
2 changes: 0 additions & 2 deletions src/web_app_skeleton/Procfile.ecr

This file was deleted.

0 comments on commit ff2c0da

Please sign in to comment.