mecha 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/README.md +24 -4
  4. data/TODO.md +9 -0
  5. data/lib/mecha/generators/app/app_builder.rb +16 -7
  6. data/lib/mecha/generators/app/app_generator.rb +10 -1
  7. data/lib/mecha/generators/app/templates/Gemfile.erb +10 -7
  8. data/lib/mecha/generators/app/templates/README.md.erb +13 -3
  9. data/lib/mecha/generators/app/templates/gitignore.erb +7 -0
  10. data/lib/mecha/generators/bitbucket_pipelines/bitbucket_pipelines_generator.rb +0 -1
  11. data/lib/mecha/generators/cpf_cnpj/cpf_cnpj_generator.rb +17 -0
  12. data/lib/mecha/generators/cpf_cnpj/templates/app/validators/cnpj_format_validator.rb +6 -0
  13. data/lib/mecha/generators/danger/danger_generator.rb +37 -0
  14. data/lib/mecha/generators/danger/templates/Dangerfile +68 -0
  15. data/lib/mecha/generators/devise/devise_generator.rb +18 -2
  16. data/lib/mecha/generators/guard/guard_generator.rb +3 -3
  17. data/lib/mecha/generators/guard/templates/Guardfile +43 -0
  18. data/lib/mecha/generators/heroku/heroku_generator.rb +99 -0
  19. data/lib/mecha/generators/heroku/templates/app.json +21 -0
  20. data/lib/mecha/generators/i18n/i18n_generator.rb +2 -4
  21. data/lib/mecha/generators/pronto/pronto_generator.rb +74 -0
  22. data/lib/mecha/generators/pronto/templates/flayignore +4 -0
  23. data/lib/mecha/generators/pronto/templates/reek +48 -0
  24. data/lib/mecha/generators/rubocop/templates/rubocop.yml +16 -1
  25. data/lib/mecha/generators/sentry/sentry_generator.rb +32 -18
  26. data/lib/mecha/generators/sentry/templates/_sentry.html.erb +2 -0
  27. data/lib/mecha/generators/sentry/templates/sentry.rb +5 -0
  28. data/lib/mecha/generators/simplecov/simplecov_generator.rb +34 -4
  29. data/lib/mecha/generators/tests/templates/spec/rails_helper.rb +18 -0
  30. data/lib/mecha/generators/tests/templates/spec/spec_helper.rb +27 -0
  31. data/lib/mecha/generators/tests/templates/spec/support/factory_bot.rb +3 -0
  32. data/lib/mecha/generators/tests/templates/test/test_helper.rb +10 -19
  33. data/lib/mecha/generators/tests/tests_generator.rb +37 -6
  34. data/lib/mecha/version.rb +3 -3
  35. data/lib/mecha.rb +30 -9
  36. data/mecha.gemspec +3 -6
  37. metadata +22 -53
  38. data/lib/mecha/generators/i18n/templates/config/locales/en.yml +0 -213
  39. data/lib/mecha/generators/i18n/templates/config/locales/pt-BR.yml +0 -221
  40. data/lib/mecha/generators/sentry/templates/rubocop.yml +0 -47
  41. data/lib/mecha/generators/simplecov/templates/simplecov +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f4bfaaf4d0c582b9c4cd4745fe762809bc8ba211
4
- data.tar.gz: e4422a8542e9f4203479df2d5998b580ee102f85
3
+ metadata.gz: c526cbf04a8f81ffdd132898d44e472033a92b29
4
+ data.tar.gz: 32bccefa978e04eb9aa0d1f92c6968d0502328f4
5
5
  SHA512:
6
- metadata.gz: 9ee898f6a81fd948fcd5923d853d5f33468cc1b3915450b2afafd8d7e1cc68fa723680fb8b775f03634f165fe6e9171f00a603a3baf7ec08aed7b8e4b09a043e
7
- data.tar.gz: '072928907be9afdd4d0199cafd24a22c08c7a71dabaca0e336f9d030cd1ef47fb1a8a2cfdd6ccf6bcb9b0e37aa311c908fbf3343335f92f8bcbbd5836c2fbd96'
6
+ metadata.gz: cbca63bf136c703e82ee24b68c71e53531839f2868a11f158cf6c906a67d15c38a114373005898df4ae1b322f47855ea911e3463f99a8106a9a7e39c88ea7bce
7
+ data.tar.gz: 7dcb1dfcd668c395a772e761e14d2bb26bfa49ea68b3a7f2d552e6111d4e261da19bcf93b2d16e577d9913a403ae0866c7cddb4dd7b90ea5dd8c0356de4667a9
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.4.0
1
+ 2.4.1
data/README.md CHANGED
@@ -22,22 +22,42 @@ gem install mecha
22
22
  mecha <projectname> --devise --bitbucket-pipelines --sentry
23
23
  ```
24
24
 
25
- This will create a Rails app with name `<projectname>` and add all our defaults. It configures the app to use sass, remove turbolinks and coffescript, configure Guard, Rubocop and Simplecov. Also, installs Factory Girl, Faker, Timecop, Capibara, Poltergeist, Database Rewinder.
25
+ This will create a Rails app with name `<projectname>` and add all our defaults. It configures the app to use sass, remove Turbolinks and CoffeeScript, configure Guard, Rubocop and Simplecov. Also, installs Factory Girl, Faker, Timecop, Capybara, Poltergeist, Database Rewinder.
26
26
 
27
27
  ### Available Generators
28
28
 
29
+ **Danger**
30
+
31
+ `--danger` installs and add config for [Danger](http://danger.systems/ruby/). If SimpleCov is installed `danger-simplecov_json` gem is also installed.
32
+
29
33
  **Devise**
30
34
 
31
- `--devise` installs Devise, generates `User`, i18n files and the internatinalized views for english and brazillian portuguese.
35
+ `--devise` installs Devise, generates `User`, i18n files and the internationalized views for English and Brazilian Portuguese.
32
36
 
33
37
  **Bitbucket Pipelines**
34
38
 
35
39
  `--bitbucket-pipelines` generates the `bitbucket-pipelines.yml` and a special database config for it.
36
40
 
41
+ **Pronto**
42
+
43
+ `--pronto` installs and add config for [Pronto](https://github.com/prontolabs/pronto). If SimpleCov is installed `pronto-simplecov` gem is also installed.
44
+
45
+ **RSpec**
46
+
47
+ `--rspec` installs RSpec and adds configs for tests.
48
+
37
49
  **Sentry**
38
50
 
39
- `--sentry` installs sentry and adds configs to `application.rb` and `application_controller.rb`. Remember to create an environment
40
- variable with you dsn key. `ENV['DNS']`.
51
+ `--sentry` installs Sentry and adds configs to `application.rb` and `application_controller.rb`. Remember to create an environment
52
+ variable with you DSN key. `ENV['DNS']`.
53
+
54
+ **Simplecov**
55
+
56
+ `--simplecov` installs Simplecov and adds configs to `test/test_helper.rb`.
57
+
58
+ **Heroku**
59
+
60
+ `--heroku` configure Heroku Pipeline with staging and production environments, and `--org` if you want to configure the project in a Heroku Org.
41
61
 
42
62
  ## Development
43
63
 
data/TODO.md ADDED
@@ -0,0 +1,9 @@
1
+ # TODO
2
+
3
+ ## Add Font Awesome Generator
4
+
5
+ https://github.com/bokmann/font-awesome-rails
6
+
7
+ ## Add Bootstrap Sass Generator
8
+
9
+ https://github.com/twbs/bootstrap-sass
@@ -32,17 +32,26 @@ module Mecha
32
32
  private
33
33
 
34
34
  def config_autoload_paths
35
- "config.autoload_paths += %W(\#{config.root}/lib \#{config.root}/app/uploaders \#{config.root}/services)"
35
+ <<-DOC
36
+ config.autoload_paths += [
37
+ Rails.root.join('app', 'constants'),
38
+ Rails.root.join('app', 'presenters'),
39
+ Rails.root.join('app', 'services'),
40
+ Rails.root.join('app', 'uploaders'),
41
+ Rails.root.join('app', 'validators'),
42
+ Rails.root.join('lib')
43
+ ]
44
+ DOC
36
45
  end
37
46
 
38
47
  def config_generators
39
48
  <<-DOC
40
- config.generators do |g|
41
- g.view_specs false
42
- g.routing_specs false
43
- g.stylesheets false
44
- g.javascripts false
45
- g.helper false
49
+ config.generators do |generator|
50
+ generator.view_specs false
51
+ generator.routing_specs false
52
+ generator.stylesheets false
53
+ generator.javascripts false
54
+ generator.helper false
46
55
  end
47
56
  DOC
48
57
  end
@@ -6,7 +6,6 @@ module Mecha
6
6
  module Generators
7
7
  class AppGenerator < Rails::Generators::AppGenerator
8
8
  class_option :database, type: :string, default: 'postgresql'
9
- class_option :skip_action_cable, type: :boolean, default: true
10
9
  class_option :skip_coffee, type: :boolean, default: true
11
10
  class_option :skip_turbolinks, type: :boolean, default: true
12
11
 
@@ -14,6 +13,16 @@ module Mecha
14
13
  source_paths << File.join(File.dirname(__FILE__), 'templates')
15
14
  source_root File.join(File.dirname(__FILE__), 'templates')
16
15
 
16
+ def say_warking
17
+ message = <<-MESSAGE.strip_heredoc
18
+
19
+ Please install PostgreSQL `brew install postgres` and NodeJS `brew install nodejs`.
20
+
21
+ MESSAGE
22
+
23
+ say message
24
+ end
25
+
17
26
  protected
18
27
 
19
28
  def get_builder_class
@@ -1,30 +1,33 @@
1
1
  source 'https://rubygems.org'
2
- ruby '<%= Mecha::RUBY_VERSION %>'
3
2
 
4
3
  git_source(:github) do |repo_name|
5
4
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
6
5
  "https://github.com/#{repo_name}.git"
7
6
  end
8
7
 
9
- gem 'rails', '<%= Mecha::RAILS_VERSION %>'
8
+ ruby '<%= RUBY_VERSION %>'
9
+
10
+ gem 'rails', '~> <%= Mecha::RAILS_VERSION %>'
10
11
 
11
12
  gem 'pg', '~> 0.18.4'
12
- gem 'puma', '~> 3.8.0'
13
+ gem 'puma', '~> 3.10.0'
13
14
 
14
15
  gem 'jquery-rails', '~> 4.3.1'
15
16
  gem 'sass-rails'
16
17
  gem 'uglifier', '~> 3.1.12'
17
18
 
18
19
  group :development, :test do
19
- gem 'byebug', platform: :mri
20
+ gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
21
+ gem 'capybara', '~> 2.13'
20
22
  gem 'dotenv-rails'
21
23
  gem 'pry'
22
24
  gem 'pry-byebug'
25
+ gem 'selenium-webdriver'
23
26
  end
24
27
 
25
28
  group :development do
26
- gem 'listen'
29
+ gem 'listen', '>= 3.0.5', '< 3.2'
27
30
  gem 'spring'
28
- gem 'spring-watcher-listen'
29
- gem 'web-console'
31
+ gem 'spring-watcher-listen', '~> 2.0.0'
32
+ gem 'web-console', '>= 3.3.0'
30
33
  end
@@ -8,13 +8,23 @@
8
8
 
9
9
  ## Dependencies
10
10
 
11
- - Ruby <%= Mecha::RUBY_VERSION %>
11
+ - Ruby >= <%= Mecha::RUBY_VERSION %>
12
12
  - PostgreSQL 9.6.1
13
- - PhantomJS 1.8.1
13
+
14
+ ### MacOS
14
15
 
15
16
  ```sh
16
17
  brew update
17
- brew install postgres phantomjs
18
+ brew install postgres
19
+ gem install bundler
20
+ ```
21
+
22
+ ### Ubuntu
23
+
24
+ ```sh
25
+ apt-get update
26
+ apt-get postgresql postgresql-contrib postgresql-server-dev-all cmake
27
+ gem install bundler
18
28
  ```
19
29
 
20
30
  ## Setup
@@ -1,4 +1,8 @@
1
1
  # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
2
6
 
3
7
  # Ignore bundler config.
4
8
  /.bundle
@@ -17,6 +21,9 @@
17
21
  !/tmp/.keep
18
22
  <% end -%>
19
23
 
24
+ /node_modules
25
+ /yarn-error.log
26
+
20
27
  # Ignore Byebug command history file.
21
28
  .byebug_history
22
29
 
@@ -8,7 +8,6 @@ module Mecha
8
8
  class_option :database, type: 'string', default: 'postgresql', aliases: '-d'
9
9
 
10
10
  def copy_bitbucket_pipelines
11
- puts(options)
12
11
  template("config/databases/#{options[:database]}.bitbucket.yml.erb", 'config/database.bitbucket.yml')
13
12
  template('bitbucket-pipelines.yml.erb', 'bitbucket-pipelines.yml')
14
13
  end
@@ -0,0 +1,17 @@
1
+ require 'rails/generators'
2
+
3
+ module Mecha
4
+ module Generators
5
+ class CpfCnpjGenerator < Rails::Generators::Base
6
+ source_root File.join(File.dirname(__FILE__), 'templates')
7
+
8
+ def add_gem
9
+ gem 'cpf_cnpj'
10
+ end
11
+
12
+ def validator_files
13
+ directory('app/validators', 'app/validators')
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,6 @@
1
+ class CnpjFormatValidator < ActiveModel::EachValidator
2
+ def validate_each(record, attribute, value)
3
+ return if CNPJ.valid?(value)
4
+ record.errors.add(attribute, :invalid)
5
+ end
6
+ end
@@ -0,0 +1,37 @@
1
+ require 'rails/generators'
2
+
3
+ module Mecha
4
+ module Generators
5
+ class DangerGenerator < Rails::Generators::Base
6
+ source_root File.join(File.dirname(__FILE__), 'templates')
7
+
8
+ class_option :simplecov, type: 'boolean', default: false
9
+
10
+ def copy_danger
11
+ template('Dangerfile', 'Dangerfile')
12
+
13
+ message = <<-MESSAGE.strip_heredoc
14
+
15
+ Review your Dangerfile and change the checks for your needs. Also, config the needed environment variables
16
+ in your CI:
17
+
18
+ DANGER_GITHUB_API_TOKEN: XXX
19
+
20
+ Take a look in the project documentation http://danger.systems/."
21
+
22
+ MESSAGE
23
+
24
+ say message
25
+ end
26
+
27
+ def add_danger_gems
28
+ gem_group :development, :test do
29
+ gem 'danger'
30
+ gem 'danger-github_ext'
31
+ gem 'danger-simplecov_json' if options[:simplecov]
32
+ gem 'danger-todoist'
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,68 @@
1
+ # MESSAGE CHECKLIST
2
+
3
+ message = <<-MESSAGE
4
+ ## Hello, hitchhiker. Not that anyone cares about what I say, but please, ensure you did check these things:
5
+
6
+ - [ ] Run all tests locally
7
+ - [ ] If you introduced front-end changes, are there desktop and mobile screenshots attached?
8
+ - [ ] Review the added i18n texts and ensure you added i18n keys for all needed cases
9
+ - [ ] Do manual tests in the pages affected by the changes you're introducing in this PR
10
+ - [ ] Fix all FIXME and remove all TODO comments
11
+ - [ ] [Rails Security Checklist](https://github.com/brunofacca/zen-rails-security-checklist)
12
+ - [ ] [Rails Style Guide](https://github.com/bbatsov/rails-style-guide)
13
+ - [ ] [Ruby Style Guide](https://github.com/bbatsov/ruby-style-guide)
14
+
15
+ MESSAGE
16
+
17
+ markdown(message)
18
+
19
+ # GIT & GITHUB
20
+
21
+ ## Make it more obvious that a pr is a work in progress and shouldn't be merged yet
22
+ warn('PR is classed as Work in Progress') if github.pr_title.include?('WIP')
23
+
24
+ ## Warn when there is a big pr
25
+ warn('Big PR') if git.lines_of_code > 500
26
+
27
+ ## If these are all empty something has gone wrong, better to raise it in a comment
28
+ if git.modified_files.empty? && git.added_files.empty? && git.deleted_files.empty?
29
+ raise('This PR has no changes at all, this is likely an issue during development.')
30
+ end
31
+
32
+ # DATABASE
33
+
34
+ added_migration = git.added_files.include?('db/migrate/*.rb')
35
+ has_schema_changes = git.modified_files.include?('db/schema.rb')
36
+
37
+ ## Added migrations and didn't update schema.rb
38
+ if added_migration && !has_schema_changes
39
+ warn('Run `db:migrate` and commit changes of `schema.rb` file!')
40
+ end
41
+
42
+ # TODOS
43
+
44
+ todoist.warn_for_todos
45
+ todoist.print_todos_table
46
+
47
+ # TESTS
48
+
49
+ has_app_changes = !git.modified_files.grep(/(lib|app)/).empty?
50
+ has_test_changes = !git.modified_files.grep(/(spec|test)/).empty?
51
+
52
+ ## Changed the code, but didn't added or updated a test case?
53
+ if has_app_changes && !has_test_changes
54
+ message = <<-MESSAGE
55
+ I think you ought to know I'm feeling very depressed with the fact that you didn't add any test case.
56
+ That's OK as long as you're refactoring existing code.
57
+ MESSAGE
58
+
59
+ warn(message.strip)
60
+ end
61
+
62
+ <% if options[:simplecov] %>
63
+
64
+ # CODE COVERAGE
65
+
66
+ simplecov.report('coverage/coverage.json')
67
+
68
+ <% end %>
@@ -9,8 +9,8 @@ module Mecha
9
9
  source_paths << Rails::Generators::AppGenerator.source_root << File.join(File.dirname(__FILE__), 'templates')
10
10
 
11
11
  def install_devise
12
- gem('devise', '~> 4.2')
13
- gem('devise-i18n', '~> 1.1.2')
12
+ gem('devise', '~> 4.3.0')
13
+ gem('devise-i18n', '~> 1.3.0')
14
14
  bundle_command('install')
15
15
 
16
16
  stop_spring
@@ -48,6 +48,22 @@ module Mecha
48
48
  )
49
49
  end
50
50
 
51
+ def config_routes
52
+ routes = <<-ROUTES.strip_heredoc
53
+ devise_for :users
54
+
55
+ authenticated :user do
56
+ root '/', as: :authenticated_root
57
+ end
58
+
59
+ devise_scope :user do
60
+ root 'devise/sessions#new'
61
+ end
62
+ ROUTES
63
+
64
+ inject_into_file('config/routes.rb', routes, after: "Rails.application.routes.draw do\n")
65
+ end
66
+
51
67
  private
52
68
 
53
69
  def stop_spring
@@ -11,10 +11,10 @@ module Mecha
11
11
 
12
12
  def add_development_gems
13
13
  gem_group :development do
14
- gem 'guard'
15
- gem 'guard-minitest'
14
+ gem 'guard', require: false
15
+ gem 'guard-minitest', require: false
16
16
  gem 'guard-rails', require: false
17
- gem 'guard-rubocop'
17
+ gem 'guard-rubocop', require: false
18
18
  end
19
19
  end
20
20
  end
@@ -13,6 +13,49 @@ guard :minitest, spring: 'bin/rails test' do
13
13
  watch(%r{^test/test_helper\.rb$}) { 'test' }
14
14
  end
15
15
 
16
+ guard :rspec, cmd: 'bundle exec rspec' do
17
+ require 'guard/rspec/dsl'
18
+ dsl = Guard::RSpec::Dsl.new(self)
19
+
20
+ # RSpec files
21
+ rspec = dsl.rspec
22
+ watch(rspec.spec_helper) { rspec.spec_dir }
23
+ watch(rspec.spec_support) { rspec.spec_dir }
24
+ watch(rspec.spec_files)
25
+
26
+ # Ruby files
27
+ ruby = dsl.ruby
28
+ dsl.watch_spec_files_for(ruby.lib_files)
29
+
30
+ # Rails files
31
+ rails = dsl.rails(view_extensions: %w[erb haml slim])
32
+ dsl.watch_spec_files_for(rails.app_files)
33
+ dsl.watch_spec_files_for(rails.views)
34
+
35
+ watch(rails.controllers) do |m|
36
+ [
37
+ rspec.spec.call("routing/#{m[1]}_routing"),
38
+ rspec.spec.call("controllers/#{m[1]}_controller"),
39
+ rspec.spec.call("acceptance/#{m[1]}")
40
+ ]
41
+ end
42
+
43
+ # Rails config changes
44
+ watch(rails.spec_helper) { rspec.spec_dir }
45
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
46
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
47
+
48
+ # Capybara features specs
49
+ watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
50
+ watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
51
+
52
+ # Turnip features and steps
53
+ watch(%r{^spec/acceptance/(.+)\.feature$})
54
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
55
+ Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance'
56
+ end
57
+ end
58
+
16
59
  guard :rubocop do
17
60
  watch(/.+\.rb$/)
18
61
  watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
@@ -0,0 +1,99 @@
1
+ require 'rails/generators'
2
+
3
+ module Mecha
4
+ module Generators
5
+ class HerokuAppGenerator < Rails::Generators::Base
6
+ source_root File.join(File.dirname(__FILE__), 'templates')
7
+
8
+ class_option :org, type: :string, default: '', desc: 'Configure the Apps in as projects of your Heroku Org'
9
+
10
+ def create_app_manifest
11
+ end
12
+
13
+ def create_pipeline
14
+ # run_heroku("heroku pipelines:create #{pipeline_name} -a #{staging_name}", 'staging')
15
+ # run_heroku("heroku pipelines:create #{pipeline_name} -a #{production_name}", 'production')
16
+ end
17
+
18
+ def create_staging_app
19
+ run_heroku("create #{staging_name}", 'staging')
20
+ add_to_pipeline(staging_name)
21
+ end
22
+
23
+ def create_production_app
24
+ run_heroku("create #{production_name}", 'production')
25
+ add_to_pipeline(production_name)
26
+ end
27
+
28
+ def config_git_remote
29
+ run('git config heroku.remote staging')
30
+ end
31
+
32
+ def set_rails_secrets
33
+ # %w(staging production).each do |environment|
34
+ # run_toolbelt_command(
35
+ # "config:add SECRET_KEY_BASE=#{generate_secret}",
36
+ # environment,
37
+ # )
38
+ # end
39
+ end
40
+
41
+ def set_heroku_application_host
42
+ # %w(staging production).each do |environment|
43
+ # run_toolbelt_command(
44
+ # "config:add APPLICATION_HOST=#{heroku_app_name}-#{environment}.herokuapp.com",
45
+ # environment,
46
+ # )
47
+ # end
48
+ end
49
+
50
+ def set_backup_schedule
51
+ # %w(staging production).each do |environment|
52
+ # run_toolbelt_command(
53
+ # "pg:backups:schedule DATABASE_URL --at '10:00 UTC'",
54
+ # environment,
55
+ # )
56
+ # end
57
+ end
58
+
59
+ def app_readme
60
+ # After setting up, you can run the application using [Heroku Local]:
61
+
62
+ # % heroku local
63
+
64
+ # [Heroku Local]: https://devcenter.heroku.com/articles/heroku-local
65
+ end
66
+
67
+ def add_config_to_setup_file_to_setup_apps_after_they_are_created
68
+ end
69
+
70
+ private
71
+
72
+ def staging_name
73
+ "#{app_name.dasherize}-staging"
74
+ end
75
+
76
+ def production_name
77
+ app_name.dasherize
78
+ end
79
+
80
+ def pipeline_name
81
+ app_name.dasherize
82
+ end
83
+
84
+ def name
85
+ app_name.dasherize
86
+ end
87
+
88
+ def add_to_pipeline(app)
89
+ run_heroku("pipelines:add -a #{app} #{pipeline_name}", 'staging')
90
+ end
91
+
92
+ def run_heroku(command, environment)
93
+ org_param = options[:org].present? ? " --org #{options[:org]}" : ''
94
+ params = "--remote #{environment} #{org_param}"
95
+ run("heroku #{command} #{params}")
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "<%= app_name.humanize %>",
3
+ "description": "<%= app_name.humanize %> Heroku Manifest",
4
+ "website": "http://rubyonrails.org",
5
+ "success_url": "/welcome",
6
+ "addons": ["heroku-postgresql:hobby-dev", "papertrail"],
7
+ "env": {
8
+ "RAILS_ENV": "production",
9
+ "COOKIE_SECRET": {
10
+ "description": "This gets generated",
11
+ "generator": "secret"
12
+ },
13
+ "SETUP_BY": {
14
+ "description": "Who initiated this setup",
15
+ "value": ""
16
+ }
17
+ },
18
+ "scripts": {
19
+ "postdeploy": "bundle exec rake db:migrate"
20
+ }
21
+ }
@@ -15,10 +15,8 @@ module Mecha
15
15
  CONFIG.each { |config| application(config) }
16
16
  end
17
17
 
18
- def create_defaults_locales
19
- copy_file('config/locales/pt-BR.yml', 'config/locales/rails/pt-BR.yml')
20
- copy_file('config/locales/en.yml', 'config/locales/rails/en.yml')
21
- remove_file('config/locales/en.yml')
18
+ def add_i18n_gem
19
+ gem 'rails-i18n', '~> 5.0.4'
22
20
  end
23
21
 
24
22
  def create_models_locales
@@ -0,0 +1,74 @@
1
+ require 'rails/generators'
2
+
3
+ module Mecha
4
+ module Generators
5
+ class ProntoGenerator < Rails::Generators::Base
6
+ source_root File.join(File.dirname(__FILE__), 'templates')
7
+
8
+ class_option :simplecov, type: 'boolean', default: false
9
+
10
+ def copy_reek
11
+ copy_file('reek', '.reek')
12
+ end
13
+
14
+ def copy_flayignore
15
+ copy_file('flayignore', '.flayignore')
16
+ end
17
+
18
+ def add_pronto_gems
19
+ gem_group :development, :test do
20
+ gem 'brakeman', require: false
21
+ gem 'bullet', require: false
22
+ gem 'fasterer', require: false
23
+ gem 'flay', require: false
24
+ gem 'rails_best_practices', require: false
25
+ gem 'reek', require: false
26
+
27
+ gem 'pronto'
28
+ gem 'pronto-brakeman', require: false
29
+ gem 'pronto-fasterer', require: false
30
+ gem 'pronto-flay', require: false
31
+ gem 'pronto-rails_best_practices', require: false
32
+ gem 'pronto-rails_schema', require: false
33
+ gem 'pronto-reek', require: false
34
+ gem 'pronto-rubocop', require: false
35
+ gem('pronto-simplecov', require: false) if options[:simplecov]
36
+ end
37
+ end
38
+
39
+ def add_bullet_config
40
+ config = <<-CONFIG.strip_heredoc
41
+ config.after_initialize do
42
+ Bullet.enable = true
43
+ Bullet.alert = false
44
+ Bullet.bullet_logger = true
45
+ Bullet.console = true
46
+ Bullet.rails_logger = true
47
+ Bullet.add_footer = true
48
+ end
49
+ end
50
+ CONFIG
51
+
52
+ application(config, env: 'development')
53
+ end
54
+
55
+ def say_config_message
56
+ message = <<-MESSAGE.strip_heredoc
57
+
58
+ If you want to use Pronto in your CI, please config the needed environment variables. Bellow is an example:
59
+
60
+ PRONTO_GITHUB_ACCESS_TOKEN: XXX
61
+ PRONTO_PULL_REQUEST_ID: "$(echo $CIRCLE_PULL_REQUEST | grep -o -E '[0-9]+')"
62
+ PRONTO_GITHUB_SLUG: "${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}"
63
+ PRONTO_FORMAT: "%{msg} [%{runner}:%{level}]"
64
+ PRONTO_VERBOSE: true
65
+
66
+ Take a look in the project documentation https://github.com/prontolabs/pronto
67
+
68
+ MESSAGE
69
+
70
+ say message
71
+ end
72
+ end
73
+ end
74
+ end