diff --git a/src/amber/cli/templates/app.cr b/src/amber/cli/templates/app.cr index b6e26b306..5df9749eb 100644 --- a/src/amber/cli/templates/app.cr +++ b/src/amber/cli/templates/app.cr @@ -10,11 +10,17 @@ module Amber::CLI @model : String @db_url : String @wait_for : String + @author : String + @email : String + @github_name : String def initialize(@name, @database = "pg", @language = "slang", @model = "granite") @db_url = "" @wait_for = "" @database_name_base = generate_database_name_base + @author = fetch_author + @email = fetch_email + @github_name = fetch_github_name end def filter(entries) @@ -24,5 +30,33 @@ module Amber::CLI private def generate_database_name_base @name.gsub('-', '_') end + + def which_git_command + system("which git >/dev/null") + end + + def fetch_author + if which_git_command + user_name = `git config --get user.name`.strip + user_name = nil if user_name.empty? + end + user_name || "your-name-here" + end + + def fetch_email + if which_git_command + user_email = `git config --get user.email`.strip + user_email = nil if user_email.empty? + end + user_email || "your-email-here" + end + + def fetch_github_name + if which_git_command + github_user = `git config --get github.user`.strip + github_user = nil if github_user.empty? + end + github_user || "your-github-user" + end end end diff --git a/src/amber/cli/templates/app/README.md.ecr b/src/amber/cli/templates/app/README.md.ecr index 15ee9c113..d8bdc622b 100644 --- a/src/amber/cli/templates/app/README.md.ecr +++ b/src/amber/cli/templates/app/README.md.ecr @@ -1,47 +1,82 @@ # <%= @name %> -Your description here +A new project using [Amber Framework](https://amberframework.org/) ## Installation +Install back-end and front-end dependencies. + +``` +shards install +npm install +``` + Configure the `config/environments/development.yml` and set the `database_url` with your credentials to your database. Then: -```shellsession -shards update +``` amber db create migrate ``` ## Usage -To run the demo: +### Development + +To build crystal files: + +``` +amber watch +``` + +To build assets: + +``` +npm run watch +``` + +### Production + +To setup `AMBER_ENV`: -```shellsession -$ shards build src/<%= @name %>.cr -./<%= @name %> ``` +export AMBER_ENV=production +``` + +To build a production release: + +``` +shards build --production --release <%= @name %> +``` + +To build production assets: + +``` +npm run release +``` + +To use encrypted enviroment settings see [documentation](https://github.com/amberframework/online-docs/blob/master/getting-started/cli/encrypt.md#encrypt-command) ## Docker Compose -This will start an instance of postgres, migrate the database, +This will start an instance of <%= @database == "pg" ? "postgres" : "mysql" %>, migrate the database, and launch the site at http://localhost:3000 -```shellsession +``` docker-compose up -d ``` To view the logs: -```shellsession +``` docker-compose logs -f ``` -Note: The Docker images are compatible with Heroku. +> Note: The Docker images are compatible with Heroku. ## Contributing -1. Fork it ( https://github.com/[your-github-name]/your_project/fork ) +1. Fork it ( https://github.com/<%= @github_name %>/<%= @name %>/fork ) 2. Create your feature branch (git checkout -b my-new-feature) 3. Commit your changes (git commit -am 'Add some feature') 4. Push to the branch (git push origin my-new-feature) @@ -49,4 +84,4 @@ Note: The Docker images are compatible with Heroku. ## Contributors -- [your_github_name](https://github.com/your_github_name) your_name - creator, maintainer +- [<%= @github_name %>](https://github.com/<%= @github_name %>) <%= @author %> - creator, maintainer diff --git a/src/amber/cli/templates/app/shard.yml.ecr b/src/amber/cli/templates/app/shard.yml.ecr index 267acb6f2..895a74eaa 100644 --- a/src/amber/cli/templates/app/shard.yml.ecr +++ b/src/amber/cli/templates/app/shard.yml.ecr @@ -2,7 +2,7 @@ name: <%= @name %> version: 0.1.0 authors: - - Amber + - <%= @author %> <<%= @email %>> crystal: <%= Crystal::VERSION %> @@ -23,16 +23,16 @@ dependencies: <% case @model when "crecto" -%> crecto: github: Crecto/crecto - version: ~> 0.7.1 + version: ~> 0.8.1 <% else -%> granite_orm: github: amberframework/granite-orm - version: ~> 0.7.7 + version: ~> 0.7.8 <% end -%> quartz_mailer: github: amberframework/quartz-mailer - version: ~> 0.2.0 + version: ~> 0.3.0 jasper_helpers: github: amberframework/jasper-helpers