pah 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +47 -0
- data/CONTRIBUTING.md +6 -31
- data/README.md +17 -2
- data/bin/pah +2 -1
- data/lib/pah/files/.env +1 -0
- data/lib/pah/files/Gemfile +35 -28
- data/lib/pah/files/Procfile +1 -1
- data/lib/pah/files/README.md +15 -9
- data/lib/pah/files/app/assets/javascripts/application.js +6 -6
- data/lib/pah/files/app/assets/stylesheets/application.scss +4 -6
- data/lib/pah/files/app/assets/stylesheets/general.scss +38 -5
- data/lib/pah/files/app/views/layouts/application.html.haml +16 -14
- data/lib/pah/files/config/initializers/bullet.rb +14 -0
- data/lib/pah/files/config/initializers/database_connection.rb +12 -0
- data/lib/pah/files/config/initializers/rack_timeout.rb +1 -0
- data/lib/pah/files/config/locales/app.pt-BR.yml +13 -0
- data/lib/pah/files/config/locales/pt-BR.yml +21 -6
- data/lib/pah/files/config/locales/simple_form.pt-BR.yml +25 -0
- data/lib/pah/files/lib/tasks/jumpup.rake +3 -6
- data/lib/pah/files/public/404.html +69 -0
- data/lib/pah/files/public/500.html +59 -0
- data/lib/pah/files/spec/acceptance/dummy_spec.rb +1 -1
- data/lib/pah/files/spec/support/acceptance_helpers.rb +2 -2
- data/lib/pah/files/spec/support/acceptance_macros.rb +4 -4
- data/lib/pah/files/spec/support/capybara.rb +1 -1
- data/lib/pah/files/spec/support/database_cleaner.rb +18 -0
- data/lib/pah/files/spec/support/factory_girl.rb +10 -0
- data/lib/pah/files/spec/support/vcr.rb +6 -7
- data/lib/pah/partials/_assets.rb +4 -5
- data/lib/pah/partials/_bullet.rb +6 -0
- data/lib/pah/partials/_canonical_host.rb +2 -5
- data/lib/pah/partials/_capybara.rb +2 -5
- data/lib/pah/partials/_cleanup.rb +3 -11
- data/lib/pah/partials/_database.rb +5 -7
- data/lib/pah/partials/_gems.rb +4 -6
- data/lib/pah/partials/_generators.rb +2 -5
- data/lib/pah/partials/_git.rb +2 -6
- data/lib/pah/partials/_heroku.rb +11 -8
- data/lib/pah/partials/_jumpup.rb +3 -7
- data/lib/pah/partials/_layout.rb +4 -5
- data/lib/pah/partials/_letter_opener.rb +2 -5
- data/lib/pah/partials/_locale.rb +6 -7
- data/lib/pah/partials/_public.rb +9 -4
- data/lib/pah/partials/_puma.rb +4 -0
- data/lib/pah/partials/_rack_timeout.rb +4 -0
- data/lib/pah/partials/_readme.rb +2 -6
- data/lib/pah/partials/_rollbar.rb +5 -0
- data/lib/pah/partials/_rspec.rb +12 -8
- data/lib/pah/partials/_ruby_env.rb +6 -10
- data/lib/pah/partials/_secret_token.rb +3 -7
- data/lib/pah/partials/_secure_headers.rb +3 -5
- data/lib/pah/partials/_simple_form.rb +11 -0
- data/lib/pah/template.rb +35 -26
- data/lib/pah/version.rb +2 -1
- data/pah.gemspec +2 -2
- metadata +20 -10
- data/lib/pah/files/config/unicorn.rb +0 -43
- data/lib/pah/files/spec/support/omniauth.rb +0 -27
- data/lib/pah/files/spec/support/paperclip.rb +0 -4
- data/lib/pah/partials/_unicorn.rb +0 -33
@@ -1,12 +1,4 @@
|
|
1
|
-
|
1
|
+
git rm: "README.rdoc"
|
2
|
+
git rm: "app/views/layouts/application.html.erb"
|
2
3
|
|
3
|
-
|
4
|
-
remove_file "app/views/layouts/application.html.erb"
|
5
|
-
|
6
|
-
inside "public" do
|
7
|
-
remove_file "robots.txt"
|
8
|
-
end
|
9
|
-
|
10
|
-
git :add => '--all'
|
11
|
-
git :commit => "-aqm 'Removed unnecessary files left over from initial app generation.'"
|
12
|
-
puts "\n"
|
4
|
+
git_commit 'Remove unnecessary files left over from initial app generation.'
|
@@ -1,13 +1,11 @@
|
|
1
1
|
copy_static_file 'config/database.yml'
|
2
2
|
gsub_file 'config/database.yml', /PROJECT/, @app_name
|
3
|
-
git :
|
4
|
-
|
3
|
+
git add: 'config/database.yml'
|
4
|
+
git_commit 'Add config/database.yml.'
|
5
5
|
|
6
6
|
in_root do
|
7
|
-
run "rake db:create db:migrate db:test:clone"
|
7
|
+
run "bundle exec rake db:create db:migrate db:test:clone"
|
8
8
|
end
|
9
9
|
|
10
|
-
git :
|
11
|
-
|
12
|
-
|
13
|
-
puts "\n"
|
10
|
+
git add: 'db/schema.rb'
|
11
|
+
git_commit 'Create database, adding db/schema.rb.'
|
data/lib/pah/partials/_gems.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
puts "Setting up bundler and installing bundled gems (may take a while) ... ".magenta
|
2
|
-
|
3
1
|
copy_static_file 'Gemfile'
|
4
2
|
|
5
3
|
in_root do
|
4
|
+
gsub_file 'Gemfile', /RAILS_VERSION/, ::Pah::RAILS_VERSION
|
5
|
+
|
6
6
|
# Since the gemset is likely empty, manually install bundler so it can install the rest
|
7
7
|
run "gem install bundler --no-ri --no-rdoc"
|
8
8
|
|
@@ -10,7 +10,5 @@ in_root do
|
|
10
10
|
run "bundle install"
|
11
11
|
end
|
12
12
|
|
13
|
-
git :
|
14
|
-
|
15
|
-
git :commit => "-qm 'Add Gemfile and Gemfile.lock.'"
|
16
|
-
puts "\n"
|
13
|
+
git add: 'Gemfile*'
|
14
|
+
git_commit 'Add Gemfile and Gemfile.lock.'
|
@@ -1,5 +1,3 @@
|
|
1
|
-
puts "Adding generators... ".magenta
|
2
|
-
|
3
1
|
generators = <<GENERATORS
|
4
2
|
|
5
3
|
# Do not generate specs for views and requests. Also, do not generate assets.
|
@@ -21,6 +19,5 @@ in_root do
|
|
21
19
|
inject_into_file 'config/application.rb', generators, {after: "Rails::Application", verbose: false}
|
22
20
|
end
|
23
21
|
|
24
|
-
git :
|
25
|
-
|
26
|
-
|
22
|
+
git add: 'config/application.rb'
|
23
|
+
git_commit 'Add generators.'
|
data/lib/pah/partials/_git.rb
CHANGED
data/lib/pah/partials/_heroku.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class HerokuApp < Rails::Generators::AppGenerator
|
2
|
-
DEFAULT_ADDONS = %w(pgbackups:auto-month loggly:mole sendgrid:starter)
|
2
|
+
DEFAULT_ADDONS = %w(heroku-postgresql:dev pgbackups:auto-month loggly:mole sendgrid:starter rollbar)
|
3
3
|
|
4
4
|
attr_reader :name, :description, :config
|
5
5
|
|
@@ -12,6 +12,7 @@ class HerokuApp < Rails::Generators::AppGenerator
|
|
12
12
|
add_timezone_config
|
13
13
|
add_addons
|
14
14
|
add_heroku_git_remote
|
15
|
+
add_rollbar_initialize_file
|
15
16
|
check_canonical_domain
|
16
17
|
check_collaborators
|
17
18
|
end
|
@@ -50,12 +51,17 @@ class HerokuApp < Rails::Generators::AppGenerator
|
|
50
51
|
|
51
52
|
def open
|
52
53
|
say "Pushing application to heroku...".magenta
|
53
|
-
|
54
|
+
|
54
55
|
system "git push heroku master"
|
55
56
|
|
56
57
|
system "heroku open --app #{name}"
|
57
58
|
end
|
58
59
|
|
60
|
+
def add_rollbar_initialize_file
|
61
|
+
say "Adding rollbar to initializers".magenta
|
62
|
+
system "bundle exec rails generate rollbar"
|
63
|
+
end
|
64
|
+
|
59
65
|
private
|
60
66
|
def check_canonical_domain
|
61
67
|
domain = @config[:heroku][:domain]
|
@@ -71,15 +77,12 @@ class HerokuApp < Rails::Generators::AppGenerator
|
|
71
77
|
end
|
72
78
|
end
|
73
79
|
|
74
|
-
say "Configuring Heroku application...".magenta
|
75
|
-
|
76
80
|
copy_static_file 'Procfile'
|
77
|
-
git :
|
78
|
-
|
81
|
+
git add: 'Procfile'
|
82
|
+
git_commit 'Add Procfile'
|
79
83
|
|
80
84
|
if @config[:heroku][:create?]
|
81
|
-
|
82
85
|
production_app = HerokuApp.new @config
|
83
|
-
|
84
86
|
production_app.open if @config[:heroku][:deploy?]
|
87
|
+
apply_n :rollbar, 'Setting up rollbar...'
|
85
88
|
end
|
data/lib/pah/partials/_jumpup.rb
CHANGED
@@ -1,12 +1,8 @@
|
|
1
|
-
puts "Setting up Jumpup... ".magenta
|
2
|
-
|
3
1
|
copy_static_file 'lib/tasks/jumpup.rake'
|
4
2
|
copy_static_file 'config/initializers/jumpup_heroku.rb'
|
5
3
|
|
6
4
|
gsub_file 'config/initializers/jumpup_heroku.rb', /PROJECT/, (@config[:heroku][:name] || @app_name)
|
7
5
|
|
8
|
-
git :
|
9
|
-
git :
|
10
|
-
|
11
|
-
|
12
|
-
puts "\n"
|
6
|
+
git add: 'lib/tasks/jumpup.rake'
|
7
|
+
git add: 'config/initializers/jumpup_heroku.rb'
|
8
|
+
git_commit 'Add jumpup tasks and configuration.'
|
data/lib/pah/partials/_layout.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
puts "Adding layout files ...".magenta
|
2
|
-
|
3
1
|
copy_static_file 'app/views/layouts/application.html.haml'
|
4
2
|
copy_static_file 'app/views/application/_error_messages.html.haml'
|
5
3
|
copy_static_file 'app/views/application/_flash_messages.html.haml'
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
gsub_file 'app/views/layouts/application.html.haml', /= page_title(app_name: 'example')/, "= page_title(app_name: '#{@app_name}')"
|
6
|
+
|
7
|
+
git add: 'app/views/'
|
8
|
+
git_commit 'Add layout files.'
|
@@ -1,5 +1,3 @@
|
|
1
|
-
puts "Adding letter_opener... ".magenta
|
2
|
-
|
3
1
|
letter_opener_config = <<LETTER_OPENER
|
4
2
|
|
5
3
|
# Letter openner config
|
@@ -11,6 +9,5 @@ in_root do
|
|
11
9
|
inject_into_file 'config/environments/development.rb', letter_opener_config, { before: /^end/, verbose: false }
|
12
10
|
end
|
13
11
|
|
14
|
-
git :
|
15
|
-
|
16
|
-
|
12
|
+
git add: 'config/environments/development.rb'
|
13
|
+
git_commit 'Add letter_opener config.'
|
data/lib/pah/partials/_locale.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
puts "Adding locale... ".magenta
|
2
|
-
|
3
1
|
copy_static_file 'config/locales/pt-BR.yml'
|
4
|
-
|
5
|
-
|
2
|
+
copy_static_file 'config/locales/app.pt-BR.yml'
|
3
|
+
|
4
|
+
git add: 'config/locales/*.yml'
|
5
|
+
git_commit 'Add pt-BR locale files.'
|
6
6
|
|
7
7
|
time_zone_config = <<TIME_ZONE
|
8
8
|
|
@@ -24,6 +24,5 @@ in_root do
|
|
24
24
|
inject_into_file 'config/application.rb', locale_config, { after: "# config.i18n.default_locale = :de", verbose: false }
|
25
25
|
end
|
26
26
|
|
27
|
-
git :
|
28
|
-
|
29
|
-
|
27
|
+
git add: 'config/application.rb'
|
28
|
+
git_commit 'Add locale config.'
|
data/lib/pah/partials/_public.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
|
-
puts "Adding public files ...".magenta
|
2
|
-
|
3
1
|
inside "public" do
|
4
2
|
remove_file "robots.txt"
|
3
|
+
remove_file "404.html"
|
4
|
+
remove_file "500.html"
|
5
5
|
end
|
6
6
|
|
7
7
|
copy_static_file 'public/robots.txt'
|
8
|
+
copy_static_file 'public/404.html'
|
9
|
+
copy_static_file 'public/500.html'
|
10
|
+
|
11
|
+
git add: 'public/robots.txt'
|
12
|
+
git add: 'public/404.html'
|
13
|
+
git add: 'public/500.html'
|
8
14
|
|
9
|
-
|
10
|
-
git :commit => "-aqm 'Add public files.'"
|
15
|
+
git_commit 'Add public files.'
|
11
16
|
puts "\n"
|
data/lib/pah/partials/_readme.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
|
-
puts "Adding default README... ".magenta
|
2
|
-
|
3
1
|
copy_static_file 'README.md'
|
4
2
|
gsub_file 'README.md', /PROJECT/, @app_name
|
5
3
|
|
6
|
-
git :
|
7
|
-
|
8
|
-
|
9
|
-
puts "\n"
|
4
|
+
git add: 'README.md'
|
5
|
+
git_commit 'Add README file.'
|
@@ -0,0 +1,5 @@
|
|
1
|
+
gsub_file 'config/initializers/rollbar.rb', /Rails\.env\.test\?/, "Rails.env.production?"
|
2
|
+
gsub_file 'config/initializers/rollbar.rb', /config\.enabled = false/, "config.enabled = true"
|
3
|
+
|
4
|
+
git add: 'config/initializers/rollbar.rb'
|
5
|
+
git_commit 'Add rollbar initialize file.'
|
data/lib/pah/partials/_rspec.rb
CHANGED
@@ -1,13 +1,17 @@
|
|
1
|
-
puts "Setting up RSpec ... ".magenta
|
2
|
-
|
3
|
-
remove_dir 'test'
|
4
|
-
|
5
1
|
copy_static_file 'spec/spec_helper.rb'
|
6
2
|
|
7
|
-
%w{
|
3
|
+
%w{
|
4
|
+
database_cleaner.rb
|
5
|
+
deferred_garbage_collection.rb
|
6
|
+
factory_girl.rb
|
7
|
+
http_basic_auth.rb
|
8
|
+
matchers.rb
|
9
|
+
suppress_log.rb
|
10
|
+
uploaded_file.rb
|
11
|
+
vcr.rb
|
12
|
+
}.each do |component|
|
8
13
|
copy_static_file "spec/support/#{component}"
|
9
14
|
end
|
10
15
|
|
11
|
-
git :
|
12
|
-
|
13
|
-
puts "\n"
|
16
|
+
git add: 'spec'
|
17
|
+
git_commit 'Add RSpec support files'
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
current_ruby = 'ruby-2.1.0'
|
1
|
+
current_ruby = '2.1.1'
|
4
2
|
current_gemset = @app_name
|
5
3
|
|
6
4
|
copy_static_file '.ruby-version'
|
@@ -9,12 +7,10 @@ gsub_file '.ruby-version', /RUBY_VERSION/, current_ruby
|
|
9
7
|
copy_static_file '.ruby-gemset'
|
10
8
|
gsub_file '.ruby-gemset', /GEMSET/, current_gemset
|
11
9
|
|
12
|
-
git :
|
13
|
-
git :
|
14
|
-
|
10
|
+
git add: '.ruby-version'
|
11
|
+
git add: '.ruby-gemset'
|
12
|
+
git_commit 'Add .ruby-version and .ruby-gemset'
|
15
13
|
|
16
14
|
copy_static_file '.env'
|
17
|
-
git :
|
18
|
-
|
19
|
-
|
20
|
-
puts "\n"
|
15
|
+
git add: '.env'
|
16
|
+
git_commit 'Add .env file'
|
@@ -1,5 +1,3 @@
|
|
1
|
-
puts "Replacing secret token with environment variable...".magenta
|
2
|
-
|
3
1
|
in_root do
|
4
2
|
append_to_file '.env', "SECRET_TOKEN: #{SecureRandom::hex(60)}\n"
|
5
3
|
|
@@ -7,8 +5,6 @@ in_root do
|
|
7
5
|
gsub_file 'config/initializers/secret_token.rb', /config.secret_key_base = '(.*?)'/, "config.secret_key_base = ENV['SECRET_TOKEN']"
|
8
6
|
end
|
9
7
|
|
10
|
-
git :
|
11
|
-
git :
|
12
|
-
|
13
|
-
|
14
|
-
puts "\n"
|
8
|
+
git add: 'config/initializers/secret_token.rb'
|
9
|
+
git add: '.env'
|
10
|
+
git_commit 'Replace secret token with environment variable.'
|
@@ -1,4 +1,3 @@
|
|
1
|
-
puts "Adding secure headers... ".magenta
|
2
1
|
content = <<EOF
|
3
2
|
|
4
3
|
ensure_security_headers # See more: https://github.com/twitter/secureheaders
|
@@ -17,7 +16,6 @@ create_file "config/initializers/secure_headers.rb" do
|
|
17
16
|
end
|
18
17
|
EOF
|
19
18
|
end
|
20
|
-
git :
|
21
|
-
git :
|
22
|
-
|
23
|
-
puts "\n"
|
19
|
+
git add: 'app/controllers/application_controller.rb'
|
20
|
+
git add: 'config/initializers/secure_headers.rb'
|
21
|
+
git_commit 'Add secure headers.'
|
@@ -0,0 +1,11 @@
|
|
1
|
+
in_root do
|
2
|
+
run "bundle exec rails generate simple_form:install"
|
3
|
+
end
|
4
|
+
|
5
|
+
git add: 'config'
|
6
|
+
git add: 'lib/templates'
|
7
|
+
git_commit 'Run `rails generate simple_form:install`'
|
8
|
+
|
9
|
+
copy_static_file 'config/locales/simple_form.pt-BR.yml'
|
10
|
+
git add: 'config'
|
11
|
+
git_commit 'Add simple_form pt-BR locale.'
|
data/lib/pah/template.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require File.expand_path(File.join('..', 'pah', 'version.rb'), File.dirname(__FILE__))
|
2
|
+
|
1
3
|
%w{colored}.each do |component|
|
2
4
|
if Gem::Specification.find_all_by_name(component).empty?
|
3
5
|
run "gem install #{component}"
|
@@ -17,14 +19,16 @@ require "bundler"
|
|
17
19
|
|
18
20
|
# Copy a static file from the template into the new application
|
19
21
|
def copy_static_file(path)
|
20
|
-
# puts "Installing #{path}...".magenta
|
21
22
|
remove_file path
|
22
23
|
file path, File.read(File.join(@static_files, path))
|
23
|
-
# puts "\n"
|
24
24
|
end
|
25
25
|
|
26
|
-
def apply_n(partial)
|
26
|
+
def apply_n(partial, message='')
|
27
|
+
puts message.magenta
|
28
|
+
|
27
29
|
apply "#{@partials}/_#{partial}.rb"
|
30
|
+
|
31
|
+
puts "\n"
|
28
32
|
end
|
29
33
|
|
30
34
|
def will_you_like_to?(question)
|
@@ -43,36 +47,41 @@ def ask_unless_test(*params)
|
|
43
47
|
ask(*params)
|
44
48
|
end
|
45
49
|
|
50
|
+
def git_commit(message)
|
51
|
+
message = "#{message}\n\nGenerated by pah version #{Pah::VERSION}"
|
52
|
+
git commit: "-qm '#{message}'"
|
53
|
+
end
|
54
|
+
|
46
55
|
puts "\n========================================================="
|
47
56
|
puts " Pah".yellow.bold
|
48
57
|
puts "=========================================================\n"
|
49
58
|
|
50
|
-
# TODO: timezone, Add rspec extensions
|
51
59
|
|
52
60
|
apply_n :config
|
53
|
-
apply_n :git
|
54
|
-
apply_n :ruby_env
|
55
|
-
apply_n :cleanup
|
56
|
-
apply_n :gems
|
57
|
-
apply_n :database
|
58
|
-
apply_n :rspec
|
59
|
-
apply_n :layout
|
60
|
-
apply_n :assets
|
61
|
-
apply_n :public
|
62
|
-
apply_n :secure_headers
|
63
|
-
apply_n :secret_token
|
64
|
-
apply_n :capybara
|
65
|
-
apply_n :generators
|
66
|
-
apply_n :
|
67
|
-
apply_n :
|
68
|
-
apply_n :
|
69
|
-
apply_n :
|
70
|
-
apply_n :
|
71
|
-
apply_n :
|
72
|
-
apply_n :
|
61
|
+
apply_n :git, 'Initializing new Git repo...'
|
62
|
+
apply_n :ruby_env, 'Setting up ruby env...'
|
63
|
+
apply_n :cleanup, 'Removing unnecessary files...'
|
64
|
+
apply_n :gems, 'Setting up bundler and installing bundled gems (may take a while)...'
|
65
|
+
apply_n :database, 'Initializing databases...'
|
66
|
+
apply_n :rspec, 'Setting up RSpec...'
|
67
|
+
apply_n :layout, 'Adding layout files...'
|
68
|
+
apply_n :assets, 'Adding asset files...'
|
69
|
+
apply_n :public, 'Adding public files...'
|
70
|
+
apply_n :secure_headers, 'Adding secure headers...'
|
71
|
+
apply_n :secret_token, 'Replacing secret token with environment variable...'
|
72
|
+
apply_n :capybara, 'Adding capybara helpers...'
|
73
|
+
apply_n :generators, 'Adding generators...'
|
74
|
+
apply_n :simple_form, 'Configuring simple_form...'
|
75
|
+
apply_n :letter_opener, 'Adding letter_opener...'
|
76
|
+
apply_n :bullet, 'Setting up bullet...'
|
77
|
+
apply_n :locale, 'Adding locale...'
|
78
|
+
apply_n :canonical_host, 'Configuring canonical hosts...'
|
79
|
+
apply_n :puma, 'Configuring Puma...'
|
80
|
+
apply_n :rack_timeout, 'Setting up Rack::Timeout...'
|
81
|
+
apply_n :jumpup, 'Setting up Jumpup...'
|
82
|
+
apply_n :readme, 'Adding default README...'
|
83
|
+
apply_n :heroku, 'Configuring Heroku application...'
|
73
84
|
|
74
|
-
# apply_n :omniauth # TODO: add spec support files
|
75
|
-
# TODO: take care of facebook when user is not logged in on facebook (when app)
|
76
85
|
|
77
86
|
puts "\n========================================================="
|
78
87
|
puts " CONGRATS! INSTALLATION COMPLETE!".yellow.bold
|