Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide attributes for git config #434

Merged
merged 14 commits into from
Dec 13, 2017
34 changes: 34 additions & 0 deletions src/amber/cli/templates/app.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
61 changes: 48 additions & 13 deletions src/amber/cli/templates/app/README.md.ecr
Original file line number Diff line number Diff line change
@@ -1,52 +1,87 @@
# <%= @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.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line still valid?, Should we add amber encrypt reference to this README too? What steps are needed to setup production.yml? What about .encryption_key?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might live nicely in a Deployment section

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robacarp I added a link to amber encrypt documentation 👍


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)
5. Create a new Pull Request

## Contributors

- [your_github_name](https://github.com/your_github_name) your_name - creator, maintainer
- [<%= @github_name %>](https://github.com/<%= @github_name %>) <%= @author %> - creator, maintainer
8 changes: 4 additions & 4 deletions src/amber/cli/templates/app/shard.yml.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: <%= @name %>
version: 0.1.0

authors:
- Amber <amberframework.org>
- <%= @author %> <<%= @email %>>

crystal: <%= Crystal::VERSION %>

Expand All @@ -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
Expand Down