gb-firestarter 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.metrics +13 -0
- data/.metrics.reek +3 -0
- data/.rspec +1 -0
- data/.rubocop.yml +64 -0
- data/.ruby-version +1 -1
- data/.travis.yml +5 -6
- data/Gemfile.lock +30 -11
- data/README.md +3 -1
- data/Rakefile +5 -5
- data/firestarter.gemspec +23 -20
- data/lib/firestarter.rb +4 -4
- data/lib/firestarter/actions.rb +1 -1
- data/lib/firestarter/app_builder.rb +108 -89
- data/lib/firestarter/generators/app_generator.rb +41 -41
- data/lib/firestarter/version.rb +2 -2
- data/spec/features/new_project_spec.rb +18 -20
- data/spec/spec_helper.rb +4 -9
- data/spec/support/firestarter.rb +16 -6
- data/templates/Gemfile.erb +35 -42
- data/templates/database_cleaner_rspec.rb +1 -1
- data/templates/development_seeds.rb +3 -3
- data/templates/factories_spec.rb +3 -3
- data/templates/factories_spec_rake_task.rb +4 -4
- data/templates/lint_rake_task.rb +5 -5
- data/templates/metrics +13 -0
- data/templates/metrics.reek +3 -0
- data/templates/puma.rb +5 -5
- data/templates/rack_timeout.rb +3 -1
- data/templates/{secret_token.rb → secret_token.rb.erb} +1 -1
- data/templates/smtp.rb +5 -5
- data/templates/spec_helper.rb +11 -12
- data/templates/staging.rb +1 -3
- data/templates/unobtrusive_pry.rb +2 -2
- metadata +27 -8
- data/templates/errors.rb +0 -28
@@ -1,34 +1,37 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "rails/generators"
|
2
|
+
require "rails/generators/rails/app/app_generator"
|
3
3
|
|
4
4
|
module Firestarter
|
5
|
-
class AppGenerator < Rails::Generators::AppGenerator
|
6
|
-
class_option :database, :
|
7
|
-
:
|
5
|
+
class AppGenerator < Rails::Generators::AppGenerator # rubocop:disable Metrics/ClassLength
|
6
|
+
class_option :database, type: :string, aliases: "-d", default: "postgresql",
|
7
|
+
desc: "Preconfigure for selected database (options: #{DATABASES.join('/')})"
|
8
8
|
|
9
|
-
class_option :github, :
|
10
|
-
:
|
9
|
+
class_option :github, type: :string, aliases: "-G", default: nil,
|
10
|
+
desc: "Create Github repository and add remote origin pointed to repo"
|
11
11
|
|
12
|
-
class_option :skip_test_unit, :
|
13
|
-
|
12
|
+
class_option :skip_test_unit, type: :boolean, aliases: "-T", default: true,
|
13
|
+
desc: "Skip Test::Unit files"
|
14
|
+
|
15
|
+
class_option :skip_bundle, type: :boolean, aliases: "-B", default: true,
|
16
|
+
desc: "Don't run bundle install"
|
14
17
|
|
15
18
|
def finish_template
|
16
19
|
invoke :firestarter_customization
|
17
20
|
super
|
18
21
|
end
|
19
22
|
|
20
|
-
def firestarter_customization
|
23
|
+
def firestarter_customization # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
21
24
|
invoke :customize_gemfile
|
25
|
+
invoke :bundle_install
|
22
26
|
invoke :setup_development_environment
|
23
27
|
invoke :setup_test_environment
|
24
28
|
invoke :setup_production_environment
|
25
29
|
invoke :setup_staging_environment
|
26
30
|
invoke :setup_secret_token
|
27
31
|
invoke :create_firestarter_views
|
28
|
-
invoke :
|
32
|
+
invoke :setup_javascript
|
29
33
|
invoke :configure_app
|
30
34
|
invoke :setup_stylesheets
|
31
|
-
invoke :copy_miscellaneous_files
|
32
35
|
invoke :customize_error_pages
|
33
36
|
invoke :remove_routes_comment_lines
|
34
37
|
invoke :setup_git
|
@@ -40,13 +43,12 @@ module Firestarter
|
|
40
43
|
def customize_gemfile
|
41
44
|
build :replace_gemfile
|
42
45
|
build :set_ruby_to_version_being_used
|
43
|
-
bundle_command 'install'
|
44
46
|
end
|
45
47
|
|
46
48
|
def setup_database
|
47
|
-
say
|
49
|
+
say "Setting up database"
|
48
50
|
|
49
|
-
if
|
51
|
+
if "postgresql" == options[:database]
|
50
52
|
build :use_postgres_config_template
|
51
53
|
end
|
52
54
|
|
@@ -58,7 +60,7 @@ module Firestarter
|
|
58
60
|
end
|
59
61
|
|
60
62
|
def setup_development_environment
|
61
|
-
say
|
63
|
+
say "Setting up the development environment"
|
62
64
|
build :raise_on_delivery_errors
|
63
65
|
build :raise_on_unpermitted_parameters
|
64
66
|
build :provide_setup_script
|
@@ -67,7 +69,7 @@ module Firestarter
|
|
67
69
|
end
|
68
70
|
|
69
71
|
def setup_test_environment
|
70
|
-
say
|
72
|
+
say "Setting up the test environment"
|
71
73
|
build :enable_factory_girl_syntax
|
72
74
|
build :test_factories_first
|
73
75
|
build :generate_rspec
|
@@ -78,36 +80,38 @@ module Firestarter
|
|
78
80
|
end
|
79
81
|
|
80
82
|
def setup_production_environment
|
81
|
-
say
|
83
|
+
say "Setting up the production environment"
|
82
84
|
build :configure_smtp
|
83
85
|
build :enable_rack_deflater
|
84
86
|
end
|
85
87
|
|
86
88
|
def setup_staging_environment
|
87
|
-
say
|
89
|
+
say "Setting up the staging environment"
|
88
90
|
build :setup_staging_environment
|
89
91
|
end
|
90
92
|
|
91
93
|
def setup_secret_token
|
92
|
-
say
|
94
|
+
say "Moving secret token out of version control"
|
93
95
|
build :setup_secret_token
|
94
96
|
end
|
95
97
|
|
96
98
|
def create_firestarter_views
|
97
|
-
say
|
99
|
+
say "Creating firestarter views"
|
98
100
|
build :create_partials_directory
|
99
101
|
build :create_shared_flashes
|
100
102
|
build :create_shared_javascripts
|
101
103
|
build :create_application_layout
|
102
104
|
end
|
103
105
|
|
104
|
-
def
|
105
|
-
say
|
106
|
+
def setup_javascript
|
107
|
+
say "Setting up JS defaults"
|
106
108
|
build :remove_turbolinks
|
109
|
+
build :remove_require_tree
|
110
|
+
build :add_retina_tag
|
107
111
|
end
|
108
112
|
|
109
|
-
def configure_app
|
110
|
-
say
|
113
|
+
def configure_app # rubocop:disable Metrics/MethodLength
|
114
|
+
say "Configuring app"
|
111
115
|
build :configure_action_mailer
|
112
116
|
build :configure_time_zone
|
113
117
|
build :configure_time_formats
|
@@ -117,16 +121,17 @@ module Firestarter
|
|
117
121
|
build :setup_default_rake_task
|
118
122
|
build :configure_puma
|
119
123
|
build :setup_foreman
|
124
|
+
build :use_rubocop_config
|
120
125
|
end
|
121
126
|
|
122
127
|
def setup_stylesheets
|
123
|
-
say
|
128
|
+
say "Set up stylesheets"
|
124
129
|
build :setup_stylesheets
|
125
130
|
end
|
126
131
|
|
127
132
|
def setup_git
|
128
|
-
|
129
|
-
say
|
133
|
+
unless options[:skip_git]
|
134
|
+
say "Initializing git"
|
130
135
|
invoke :setup_gitignore
|
131
136
|
invoke :init_git
|
132
137
|
end
|
@@ -140,13 +145,8 @@ module Firestarter
|
|
140
145
|
build :init_git
|
141
146
|
end
|
142
147
|
|
143
|
-
def copy_miscellaneous_files
|
144
|
-
say 'Copying miscellaneous support files'
|
145
|
-
build :copy_miscellaneous_files
|
146
|
-
end
|
147
|
-
|
148
148
|
def customize_error_pages
|
149
|
-
say
|
149
|
+
say "Customizing the 500/404/422 pages"
|
150
150
|
build :customize_error_pages
|
151
151
|
end
|
152
152
|
|
@@ -154,12 +154,12 @@ module Firestarter
|
|
154
154
|
build :remove_routes_comment_lines
|
155
155
|
end
|
156
156
|
|
157
|
-
def
|
158
|
-
|
157
|
+
def bundle_install
|
158
|
+
bundle_command "install"
|
159
159
|
end
|
160
160
|
|
161
|
-
def
|
162
|
-
|
161
|
+
def outro
|
162
|
+
say "Congratulations! You just started a fire."
|
163
163
|
end
|
164
164
|
|
165
165
|
def ruby_version_with_patch_level
|
@@ -168,7 +168,7 @@ module Firestarter
|
|
168
168
|
|
169
169
|
protected
|
170
170
|
|
171
|
-
def get_builder_class
|
171
|
+
def get_builder_class # rubocop:disable Style/AccessorMethodName
|
172
172
|
Firestarter::AppBuilder
|
173
173
|
end
|
174
174
|
|
@@ -177,8 +177,8 @@ module Firestarter
|
|
177
177
|
end
|
178
178
|
|
179
179
|
def patch_level
|
180
|
-
if RUBY_PATCHLEVEL == 0 && RUBY_VERSION >=
|
181
|
-
|
180
|
+
if RUBY_PATCHLEVEL == 0 && RUBY_VERSION >= "2.1.0"
|
181
|
+
""
|
182
182
|
else
|
183
183
|
"-p#{RUBY_PATCHLEVEL}"
|
184
184
|
end
|
data/lib/firestarter/version.rb
CHANGED
@@ -1,38 +1,36 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
RSpec.describe "ignite a new project with default configuration" do
|
4
|
+
before(:all) do
|
5
|
+
drop_dummy_database
|
6
|
+
remove_project_directory
|
5
7
|
run_firestarter
|
8
|
+
setup_app_dependencies
|
9
|
+
end
|
6
10
|
|
11
|
+
it "passes the specs" do
|
7
12
|
Dir.chdir(project_path) do
|
8
13
|
Bundler.with_clean_env do
|
9
|
-
expect(`rake`).to include(
|
14
|
+
expect(`rake`).to include("0 failures")
|
10
15
|
end
|
11
16
|
end
|
12
17
|
end
|
13
18
|
|
14
|
-
|
15
|
-
run_firestarter
|
16
|
-
|
19
|
+
it "inherits the staging config from production" do
|
17
20
|
staging_file = IO.read("#{project_path}/config/environments/staging.rb")
|
18
21
|
config_stub = "Dummy::Application.configure do"
|
19
|
-
expect(staging_file).to match(/^require_relative
|
22
|
+
expect(staging_file).to match(/^require_relative "production"/)
|
20
23
|
expect(staging_file).to match(/#{config_stub}/), staging_file
|
21
24
|
end
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
+
it "creates .ruby-version from Suspenders .ruby-version" do
|
27
|
+
ruby_version_file = IO.read("#{project_path}/.ruby-version")
|
28
|
+
expect(ruby_version_file).to eq "#{RUBY_VERSION}\n"
|
29
|
+
end
|
26
30
|
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
else
|
31
|
-
scenario '.ruby-version includes patchlevel for all pre-Ruby 2.1.0 versions' do
|
32
|
-
run_firestarter
|
31
|
+
it "downloads a .rubocop.yml" do
|
32
|
+
rubocop_file = IO.read("#{project_path}/.rubocop.yml")
|
33
33
|
|
34
|
-
|
35
|
-
expect(ruby_version_file).to eq "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}\n"
|
36
|
-
end
|
34
|
+
expect(rubocop_file).to match %r{Style/StringLiterals}
|
37
35
|
end
|
38
36
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "capybara/rspec"
|
2
|
+
require "bundler/setup"
|
3
3
|
|
4
4
|
Bundler.require(:default, :test)
|
5
5
|
|
6
|
-
require (Pathname.new(__FILE__).dirname
|
6
|
+
require File.join(Pathname.new(__FILE__).dirname, "../lib/firestarter")
|
7
7
|
|
8
|
-
Dir[
|
8
|
+
Dir["./spec/support/**/*.rb"].each { |file| require file }
|
9
9
|
|
10
10
|
RSpec.configure do |config|
|
11
11
|
config.include FirestarterTestHelpers
|
@@ -13,9 +13,4 @@ RSpec.configure do |config|
|
|
13
13
|
config.before(:all) do
|
14
14
|
create_tmp_directory
|
15
15
|
end
|
16
|
-
|
17
|
-
config.before(:each) do
|
18
|
-
drop_dummy_database
|
19
|
-
remove_project_directory
|
20
|
-
end
|
21
16
|
end
|
data/spec/support/firestarter.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module FirestarterTestHelpers
|
2
|
-
APP_NAME =
|
2
|
+
APP_NAME = "dummy"
|
3
3
|
|
4
4
|
def remove_project_directory
|
5
5
|
FileUtils.rm_rf(project_path)
|
@@ -12,15 +12,15 @@ module FirestarterTestHelpers
|
|
12
12
|
def run_firestarter(arguments = nil)
|
13
13
|
Dir.chdir(tmp_path) do
|
14
14
|
Bundler.with_clean_env do
|
15
|
-
ENV[
|
15
|
+
ENV["TESTING"] = "1"
|
16
16
|
|
17
|
-
|
17
|
+
`bundle exec #{firestarter_bin} #{APP_NAME} #{arguments}`
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
def drop_dummy_database
|
23
|
-
if File.
|
23
|
+
if File.exist?(project_path)
|
24
24
|
Dir.chdir(project_path) do
|
25
25
|
Bundler.with_clean_env do
|
26
26
|
`rake db:drop`
|
@@ -29,6 +29,16 @@ module FirestarterTestHelpers
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
def setup_app_dependencies
|
33
|
+
if File.exist?(project_path)
|
34
|
+
Dir.chdir(project_path) do
|
35
|
+
Bundler.with_clean_env do
|
36
|
+
`bundle check || bundle install`
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
32
42
|
def project_path
|
33
43
|
@project_path ||= Pathname.new("#{tmp_path}/#{APP_NAME}")
|
34
44
|
end
|
@@ -40,10 +50,10 @@ module FirestarterTestHelpers
|
|
40
50
|
end
|
41
51
|
|
42
52
|
def firestarter_bin
|
43
|
-
File.join(root_path,
|
53
|
+
File.join(root_path, "bin", "firestarter")
|
44
54
|
end
|
45
55
|
|
46
56
|
def root_path
|
47
|
-
File.expand_path(
|
57
|
+
File.expand_path("../../../", __FILE__)
|
48
58
|
end
|
49
59
|
end
|
data/templates/Gemfile.erb
CHANGED
@@ -1,56 +1,49 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
|
-
ruby
|
3
|
+
ruby "<%= RUBY_VERSION %>"
|
4
4
|
|
5
|
-
gem
|
6
|
-
gem
|
7
|
-
gem
|
8
|
-
gem
|
9
|
-
gem
|
10
|
-
gem
|
11
|
-
gem
|
12
|
-
gem
|
13
|
-
gem
|
14
|
-
gem
|
15
|
-
gem 'rails', '~> <%= Firestarter::RAILS_VERSION %>'
|
16
|
-
gem 'recipient_interceptor'
|
17
|
-
gem 'sass-rails'
|
18
|
-
gem 'slim-rails'
|
19
|
-
gem 'title'
|
20
|
-
gem 'uglifier'
|
5
|
+
gem "clearance"
|
6
|
+
gem "foreman"
|
7
|
+
gem "jquery-rails"
|
8
|
+
gem "pg"
|
9
|
+
gem "pry-rails"
|
10
|
+
gem "puma"
|
11
|
+
gem "rails", "~> <%= Firestarter::RAILS_VERSION %>"
|
12
|
+
gem "retina_tag", github: "naps62/retina_tag", ref: "9389bec"
|
13
|
+
gem "sass-rails"
|
14
|
+
gem "slim-rails"
|
21
15
|
|
22
16
|
group :development do
|
23
|
-
gem
|
24
|
-
gem
|
25
|
-
gem
|
17
|
+
gem "better_errors"
|
18
|
+
gem "binding_of_caller"
|
19
|
+
gem "letter_opener"
|
20
|
+
gem "quiet_assets"
|
21
|
+
gem "spring", require: false
|
22
|
+
gem "spring-commands-rspec", require: false
|
26
23
|
end
|
27
24
|
|
28
25
|
group :development, :test do
|
29
|
-
gem
|
30
|
-
gem
|
31
|
-
gem
|
32
|
-
gem
|
33
|
-
gem
|
26
|
+
gem "factory_girl_rails"
|
27
|
+
gem "pry-remote", github: "Mon-Ouie/pry-remote"
|
28
|
+
gem "rspec-rails", "~> 3.0"
|
29
|
+
gem "rubocop", require: false
|
30
|
+
gem "scss_lint", require: false
|
34
31
|
end
|
35
32
|
|
36
33
|
group :test do
|
37
|
-
gem
|
38
|
-
gem
|
39
|
-
gem
|
40
|
-
gem
|
41
|
-
gem
|
42
|
-
gem 'webmock'
|
43
|
-
end
|
34
|
+
gem "capybara"
|
35
|
+
gem "database_cleaner"
|
36
|
+
gem "simplecov", require: false
|
37
|
+
gem "timecop"
|
38
|
+
gem "webmock"
|
44
39
|
|
45
|
-
|
46
|
-
|
40
|
+
install_if -> { `cat /etc/os-release 2> /dev/null` !~ /Arch Linux/ } do
|
41
|
+
gem "capybara-webkit"
|
42
|
+
end
|
47
43
|
end
|
48
44
|
|
49
|
-
group :
|
50
|
-
gem
|
51
|
-
gem
|
52
|
-
gem
|
53
|
-
gem 'capistrano-bundler', require: false
|
54
|
-
gem 'capistrano3-env', require: false
|
55
|
-
gem 'capistrano-foreman', github: 'groupbuddies/capistrano-foreman', branch: :master
|
45
|
+
group :production, :staging do
|
46
|
+
gem "rack-timeout"
|
47
|
+
gem "rails_12factor"
|
48
|
+
gem "uglifier"
|
56
49
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
if Rails.env.development?
|
2
|
-
require
|
2
|
+
require "factory_girl"
|
3
3
|
|
4
4
|
namespace :dev do
|
5
|
-
desc
|
6
|
-
task setup:
|
5
|
+
desc "Seed data for development environment"
|
6
|
+
task setup: "db:setup" do
|
7
7
|
FactoryGirl.find_definitions
|
8
8
|
include FactoryGirl::Syntax::Methods
|
9
9
|
|