pah 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c4da3899fe6bca1c8bed8832756d255616aafff
4
- data.tar.gz: 01a752f1bb9d27bd8d038e908a265792da52a1ed
3
+ metadata.gz: c6212ca852515a5d3a319e26a2679fbfabd8cedf
4
+ data.tar.gz: 926e305615e898e0c88197ae16acd5ee60d23c6f
5
5
  SHA512:
6
- metadata.gz: c83aadb0ca4d59769263e8a7c169bbb1aa40db5b99f2c9061a1cc054ae7db3a82cc4997741d6a958a33c9c00d3d8c3841c5b9354fc0ecf9440938c284830779b
7
- data.tar.gz: 9bf556fd7e1d6df48db25f13e8e7f768c9f15934affad914e3538dac8bee5ea797236a9ce4490eed8bd84009a45a76f288d534b4617cd36dcc19845955da2886
6
+ metadata.gz: 49d22795028acb466ca5995350d91ee7c141758ad7629c39968fa94e90136db571e4587fa3f48559fa3a456e08029b0f6c74057dbd21670d11c7ee2c30fe6377
7
+ data.tar.gz: cbff55dc3313b7d9f4079d6a883fb751a035afd90650a06af2b2514251a8e495bb9e56729a2fb78b7b9544a32214c48025743081709344d1af41365286545923
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.0.10 (November 5, 2013)
4
+
5
+ ### features
6
+
7
+ ### improvements
8
+
9
+ - Remove rvm dependency
10
+ - Remove staging app
11
+ - Remove ominiauth integration
12
+ - Refactoring bundle files
13
+ - Refactoring integration files
14
+ - Remove password from db config
15
+
16
+ ### bug fixes
17
+
18
+ - Integration now use app name hardcoded
19
+
3
20
  ## 0.0.9 (November 01, 2013)
4
21
 
5
22
  ### features
data/README.md CHANGED
@@ -11,6 +11,8 @@ Install Pah at the command prompt:
11
11
 
12
12
  gem install pah
13
13
 
14
+ If using [RVM see this tips](https://github.com/Helabs/pah/wiki/Using-Pah-with-RVM).
15
+
14
16
  ## Usage
15
17
 
16
18
  Run:
@@ -19,6 +21,18 @@ Run:
19
21
 
20
22
  This will create a Rails 4.0 app in `projectname` with ruby 2.0.0. This script creates a new git repository. It is not meant to be used against an existing repo.
21
23
 
24
+ ### RVM
25
+
26
+ If using the rvm is recomended before using pah, create and use a gemset, with the project name.
27
+
28
+ ```bash
29
+ $ rvm use 2.0.0@projectname --create
30
+ ```
31
+
32
+ Pah automatically create the .ruby-version and .ruby-gemset files.
33
+
34
+ ### Canonical host
35
+
22
36
  Be sure to set your canonical domain on Heroku:
23
37
  ```shell
24
38
  heroku config:add CANONICAL_HOST=yourdomain.com #or www.yourdomain.com
File without changes
@@ -1,22 +1,18 @@
1
1
  development:
2
2
  adapter: postgresql
3
- encoding: unicode
3
+ encoding: utf8
4
4
  database: PROJECT_development
5
5
  pool: 5
6
6
  username: postgres
7
- password:
8
7
  host: localhost
9
- encoding: utf8
10
8
  template: template0
11
9
 
12
10
  test:
13
11
  adapter: postgresql
14
- encoding: unicode
12
+ encoding: utf8
15
13
  database: PROJECT_test
16
14
  pool: 5
17
15
  username: postgres
18
- password:
19
16
  min_messages: WARNING
20
17
  host: localhost
21
- encoding: utf8
22
- template: template0
18
+ template: template0
@@ -4,8 +4,46 @@ def run_with_clean_env(command, capture_output=false)
4
4
  Bundler.with_clean_env { capture_output ? `#{command}` : sh(command) }
5
5
  end
6
6
 
7
+ def confirm(message)
8
+ print "\n#{message}\nAre you sure? [yN] "
9
+ raise 'Ok. Bye...' unless STDIN.gets.chomp.downcase == 'y'
10
+ end
11
+
12
+ def has_database?(app)
13
+ database_url = run_with_clean_env("heroku config -s --app #{app} | grep DATABASE_URL", true).strip
14
+ not database_url.blank?
15
+ end
16
+
17
+ def backup(app)
18
+ return unless has_database?(app)
19
+ puts "--> Backing up database via Heroku".magenta
20
+ run_with_clean_env("heroku pgbackups:capture --expire --app #{app}")
21
+ end
22
+
23
+ def migrate(app)
24
+ return unless has_database?(app)
25
+ puts "--> Migrating".magenta
26
+ run_with_clean_env("heroku run rake db:migrate --app #{app}")
27
+ end
28
+
29
+ def seed(app)
30
+ return unless has_database?(app)
31
+ puts "--> Seeding".magenta
32
+ run_with_clean_env("heroku run rake db:seed --app #{app}")
33
+ end
34
+
35
+ def restart(app)
36
+ puts "--> Restarting".magenta
37
+ run_with_clean_env("heroku restart --app #{app}")
38
+ end
39
+
40
+ def deploy(app)
41
+ puts "--> Pushing".magenta
42
+ run_with_clean_env("git push git@heroku.com:#{APP}.git HEAD:master")
43
+ end
44
+
7
45
  namespace :integration do
8
- APP = ENV['STAGING_APP'] || ENV['APP']
46
+ APP = 'PROJECT'
9
47
  USER = run_with_clean_env("git config --get user.name", true).strip
10
48
 
11
49
  namespace :heroku do
@@ -44,6 +82,15 @@ namespace :integration do
44
82
  puts "--> Unlocking Heroku integration".magenta
45
83
  run_with_clean_env("heroku config:unset INTEGRATING_BY --app #{APP}")
46
84
  end
85
+
86
+ desc "Deploy to heroku"
87
+ task :deploy do
88
+ backup(APP)
89
+ deploy(APP)
90
+ migrate(APP)
91
+ seed(APP)
92
+ restart(APP)
93
+ end
47
94
  end
48
95
  end
49
96
 
@@ -57,6 +104,6 @@ INTEGRATION_TASKS = %w(
57
104
  spec
58
105
  integration:coverage_verify
59
106
  integration:finish
60
- heroku:deploy:staging
107
+ integration:heroku:deploy
61
108
  integration:heroku:unlock
62
109
  )
@@ -1,8 +1,3 @@
1
- puts "Commiting new rails app ... ".magenta
2
-
3
- git :add => '.'
4
- git :commit => "-aqm 'Commit new rails app.'"
5
-
6
1
  puts "Removing unnecessary files ... ".magenta
7
2
 
8
3
  remove_file "README.rdoc"
@@ -3,4 +3,11 @@ gsub_file 'config/database.yml', /PROJECT/, @app_name
3
3
  git :add => 'config/database.yml'
4
4
  git :commit => "-qm 'Adding config/database.yml.'"
5
5
 
6
- puts "\n"
6
+ in_root do
7
+ run "rake db:create db:migrate db:test:clone"
8
+ end
9
+
10
+ git :add => 'db/schema.rb'
11
+ git :commit => "-qm 'Create database, adding db/schema.rb.'"
12
+
13
+ puts "\n"
@@ -8,9 +8,7 @@ copy_static_file 'config/unicorn.rb'
8
8
  copy_static_file 'Procfile'
9
9
  copy_static_file 'config/locales/pt-BR.yml'
10
10
  copy_static_file '.gitignore'
11
-
12
- create_file ".env"
13
- append_to_file '.env', "APP: #{@app_name}\n"
11
+ copy_static_file '.env'
14
12
 
15
13
  git :add => '.'
16
14
  git :commit => "-aqm 'Add default stuff.'"
@@ -1,7 +1,16 @@
1
- puts "Adding Gemfile... ".magenta
1
+ puts "Setting up bundler and installing bundled gems (may take a while) ... ".magenta
2
2
 
3
3
  copy_static_file 'Gemfile'
4
4
 
5
+ in_root do
6
+ # Since the gemset is likely empty, manually install bundler so it can install the rest
7
+ run "gem install bundler --no-ri --no-rdoc"
8
+
9
+ # Install all other gems needed from Gemfile
10
+ run "bundle install"
11
+ end
12
+
5
13
  git :add => 'Gemfile'
6
- git :commit => "-qm 'Adding Gemfile.'"
7
- puts "\n"
14
+ git :add => 'Gemfile.lock'
15
+ git :commit => "-qm 'Add Gemfile and Gemfile.lock.'"
16
+ puts "\n"
@@ -3,7 +3,7 @@ class HerokuApp < Rails::Generators::AppGenerator
3
3
 
4
4
  attr_reader :name, :description
5
5
 
6
- def initialize(name, description, staging=false)
6
+ def initialize(name, description)
7
7
  @name = name
8
8
  @description = description
9
9
 
@@ -11,12 +11,9 @@ class HerokuApp < Rails::Generators::AppGenerator
11
11
  add_secret_token
12
12
  add_timezone_config
13
13
  add_addons
14
-
15
- unless staging
16
- add_heroku_git_remote
17
- check_canonical_domain
18
- check_collaborators
19
- end
14
+ add_heroku_git_remote
15
+ check_canonical_domain
16
+ check_collaborators
20
17
  end
21
18
 
22
19
  def create
@@ -102,25 +99,9 @@ if would_you_like? "Create Heroku apps?".red
102
99
  end
103
100
 
104
101
  config = {}
105
- config['staging'] = would_you_like? "Create staging app?".red
106
102
  config['deploy'] = would_you_like? "Deploy immediately?".red
107
103
 
108
104
  production_app = HerokuApp.new(@app_name.gsub('_',''), "app")
109
- staging_app = HerokuApp.new("#{production_app.name}-staging", "staging app", true) if config['staging']
110
-
111
- if config['staging'] && staging_app.name.present?
112
- append_to_file '.env', "STAGING_APP: #{staging_app.name}\n"
113
- append_to_file '.env', "PRODUCTION_APP: #{production_app.name}\n"
114
-
115
- git add: '.env'
116
- git commit: "-qm 'Adding STAGING_APP and PRODUCTION_APP configs.'"
117
- else
118
- # The STAGING_APP is the default integration destination
119
- append_to_file '.env', "STAGING_APP: #{production_app.name}\n"
120
-
121
- git add: '.env'
122
- git commit: "-qm 'Adding STAGING_APP config.'"
123
- end
124
105
 
125
106
  production_app.open if config['deploy']
126
107
  end
@@ -1,9 +1,9 @@
1
1
  puts "Setting up Integration... ".magenta
2
2
 
3
3
  copy_static_file 'lib/tasks/integration.rake'
4
- copy_static_file 'lib/tasks/deploy.rake'
4
+ gsub_file 'lib/tasks/integration.rake', /PROJECT/, @app_name
5
5
 
6
- git :add => 'lib/tasks/integration.rake lib/tasks/deploy.rake'
6
+ git :add => 'lib/tasks/integration.rake'
7
7
  git :commit => "-qm 'Adding integration tasks.'"
8
8
 
9
9
  puts "\n"
@@ -0,0 +1,16 @@
1
+ puts "Setting up ruby env ... ".magenta
2
+
3
+ current_ruby = 'ruby-2.0.0'
4
+ current_gemset = @app_name
5
+
6
+ copy_static_file '.ruby-version'
7
+ gsub_file '.ruby-version', /RUBY_VERSION/, current_ruby
8
+
9
+ copy_static_file '.ruby-gemset'
10
+ gsub_file '.ruby-gemset', /GEMSET/, current_gemset
11
+
12
+ git :add => '.ruby-version'
13
+ git :add => '.ruby-gemset'
14
+ git :commit => "-qm 'Add .ruby-version and .ruby-gemset'"
15
+
16
+ puts "\n"
@@ -50,6 +50,7 @@ puts "=========================================================\n"
50
50
  # TODO: timezone, Add rspec extensions
51
51
 
52
52
  apply_n :git
53
+ apply_n :ruby_env
53
54
  apply_n :cleanup
54
55
  apply_n :gems
55
56
  apply_n :database
@@ -58,16 +59,13 @@ apply_n :default
58
59
  apply_n :stylesheets
59
60
  apply_n :secure_headers
60
61
  apply_n :secret_token
61
- apply_n :omniauth
62
62
  apply_n :capybara
63
63
  apply_n :generators
64
64
  apply_n :letter_opener
65
65
  apply_n :locale
66
66
  apply_n :canonical_host
67
- apply_n :rvm
68
67
  apply_n :unicorn
69
68
  apply_n :integration
70
- apply_n :finish
71
69
  apply_n :heroku
72
70
 
73
71
  # apply_n :omniauth # TODO: add spec support files
@@ -1,3 +1,3 @@
1
1
  module Pah
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
@@ -22,7 +22,6 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_dependency 'rails', '4.0.0'
24
24
  spec.add_dependency 'colored', '1.2'
25
- spec.add_dependency 'rvm', '1.11.3.8'
26
25
 
27
26
  spec.add_development_dependency "bundler", "~> 1.3"
28
27
  spec.add_development_dependency "rake"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pah
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - HE:labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-01 00:00:00.000000000 Z
11
+ date: 2013-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.2'
41
- - !ruby/object:Gem::Dependency
42
- name: rvm
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - '='
46
- - !ruby/object:Gem::Version
47
- version: 1.11.3.8
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - '='
53
- - !ruby/object:Gem::Version
54
- version: 1.11.3.8
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: bundler
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -99,6 +85,7 @@ files:
99
85
  - README.md
100
86
  - Rakefile
101
87
  - bin/pah
88
+ - lib/pah/files/.env
102
89
  - lib/pah/files/.gitignore
103
90
  - lib/pah/files/.ruby-gemset
104
91
  - lib/pah/files/.ruby-version
@@ -110,10 +97,8 @@ files:
110
97
  - lib/pah/files/app/views/application/_flash_messages.html.haml
111
98
  - lib/pah/files/app/views/layouts/application.html.haml
112
99
  - lib/pah/files/config/database.yml
113
- - lib/pah/files/config/initializers/omniauth.rb
114
100
  - lib/pah/files/config/locales/pt-BR.yml
115
101
  - lib/pah/files/config/unicorn.rb
116
- - lib/pah/files/lib/tasks/deploy.rake
117
102
  - lib/pah/files/lib/tasks/integration.rake
118
103
  - lib/pah/files/spec/acceptance/dummy_spec.rb
119
104
  - lib/pah/files/spec/spec_helper.rb
@@ -135,7 +120,6 @@ files:
135
120
  - lib/pah/partials/_cleanup.rb
136
121
  - lib/pah/partials/_database.rb
137
122
  - lib/pah/partials/_default.rb
138
- - lib/pah/partials/_finish.rb
139
123
  - lib/pah/partials/_gems.rb
140
124
  - lib/pah/partials/_generators.rb
141
125
  - lib/pah/partials/_git.rb
@@ -143,9 +127,8 @@ files:
143
127
  - lib/pah/partials/_integration.rb
144
128
  - lib/pah/partials/_letter_opener.rb
145
129
  - lib/pah/partials/_locale.rb
146
- - lib/pah/partials/_omniauth.rb
147
130
  - lib/pah/partials/_rspec.rb
148
- - lib/pah/partials/_rvm.rb
131
+ - lib/pah/partials/_ruby_env.rb
149
132
  - lib/pah/partials/_secret_token.rb
150
133
  - lib/pah/partials/_secure_headers.rb
151
134
  - lib/pah/partials/_stylesheets.rb
@@ -1,4 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- Rails.application.config.middleware.use OmniAuth::Builder do
3
- provider :facebook, ENV['FACEBOOK_APP_KEY'], ENV['FACEBOOK_APP_SECRET'], :scope => "email"
4
- end
@@ -1,109 +0,0 @@
1
- require 'colored' if Rails.env.development?
2
-
3
- def run_with_clean_env(command, capture_output=false)
4
- Bundler.with_clean_env { capture_output ? `#{command}` : sh(command) }
5
- end
6
-
7
- def confirm(message)
8
- print "\n#{message}\nAre you sure? [yN] "
9
- raise 'Ok. Bye...' unless STDIN.gets.chomp.downcase == 'y'
10
- end
11
-
12
- namespace :heroku do
13
- PRODUCTION_APP = ENV['PRODUCTION_APP'] || ENV['APP']
14
- STAGING_APP = ENV['STAGING_APP'] || ENV['APP']
15
-
16
- def has_database?(app)
17
- database_url = run_with_clean_env("heroku config -s --app #{app} | grep DATABASE_URL", true).strip
18
- not database_url.blank?
19
- end
20
-
21
- def backup(app)
22
- return unless has_database?(app)
23
- puts "--> Backing up database via Heroku".magenta
24
- run_with_clean_env("heroku pgbackups:capture --expire --app #{app}")
25
- end
26
-
27
- def migrate(app)
28
- return unless has_database?(app)
29
- puts "--> Migrating".magenta
30
- run_with_clean_env("heroku run rake db:migrate --app #{app}")
31
- end
32
-
33
- def seed(app)
34
- return unless has_database?(app)
35
- puts "--> Seeding".magenta
36
- run_with_clean_env("heroku run rake db:seed --app #{app}")
37
- end
38
-
39
- def restart(app)
40
- puts "--> Restarting".magenta
41
- run_with_clean_env("heroku restart --app #{app}")
42
- end
43
-
44
- namespace :deploy do
45
-
46
- desc "Deploy to staging"
47
- task :staging do
48
- APP = STAGING_APP
49
-
50
- backup(APP) if ENV['SKIP_BACKUP'] != "true"
51
-
52
- puts "--> Pushing".magenta
53
- run_with_clean_env("git push git@heroku.com:#{APP}.git HEAD:master")
54
-
55
- migrate(APP)
56
- seed(APP)
57
- restart(APP)
58
- end
59
-
60
- desc "Deploy to production"
61
- task :production do
62
- # This constant is defined to avoid problemd of copying and pasting from one environment to another
63
- APP = PRODUCTION_APP
64
-
65
- confirm("Going deploy to production [#{APP}]...".red)
66
-
67
- if ENV['SKIP_TESTS'] != "true"
68
- puts "--> Running all specs".magenta
69
- Rake::Task['spec'].invoke
70
- end
71
-
72
- print "\nPut #{APP} in maintenance mode? [Yn] ".red
73
- maintenance = (ENV['MAINTENANCE'] == "true" or (STDIN.gets.chomp.downcase == 'y'))
74
-
75
- if maintenance
76
- puts "--> Setting Maintenance on".magenta
77
- run_with_clean_env("heroku maintenance:on --app #{APP}")
78
-
79
- puts "--> Restarting".magenta
80
- run_with_clean_env("heroku restart --app #{APP}")
81
-
82
- puts "--> Waiting 20 seconds to app come back (in maintenance mode)".magenta
83
- sleep(20)
84
- end
85
-
86
- backup(APP) if ENV['SKIP_BACKUP'] != "true"
87
-
88
- iso_date = Time.now.strftime('%Y-%m-%dT%H%M%S')
89
- tag_name = "production-#{iso_date}"
90
-
91
- puts "--> Tagging as #{tag_name}".magenta
92
- run_with_clean_env("git tag #{tag_name} master")
93
-
94
- puts "--> Pushing".magenta
95
- run_with_clean_env("git push origin #{tag_name}")
96
- run_with_clean_env("git push git@heroku.com:#{APP}.git HEAD:master")
97
-
98
- migrate(APP)
99
- seed(APP)
100
-
101
- if maintenance
102
- puts "Setting Maintenance off".magenta
103
- run_with_clean_env("heroku maintenance:off --app #{APP}")
104
- end
105
-
106
- restart(APP)
107
- end
108
- end
109
- end
@@ -1,8 +0,0 @@
1
- in_root do
2
- run "rake db:create db:migrate db:test:clone"
3
- end
4
-
5
- git :add => 'db/schema.rb'
6
- git :commit => "-qm 'Create database, adding db/schema.rb.'"
7
-
8
- puts "\n"
@@ -1,13 +0,0 @@
1
- puts "Add omniauth support ...".magenta
2
-
3
- if would_you_like? "Add omniauth support?".red
4
- %w{omniauth.rb}.each do |component|
5
- copy_static_file "config/initializers/#{component}"
6
- end
7
-
8
- gsub_file 'Gemfile', /# gem 'omniauth/, "gem 'omniauth"
9
-
10
- git :add => '.'
11
- git :commit => "-aqm 'Add omniauth support.'"
12
- puts "\n"
13
- end
@@ -1,47 +0,0 @@
1
- # Set up rvm private gemset
2
- require 'rvm'
3
- puts "Setting up RVM gemset and installing bundled gems (may take a while) ... ".magenta
4
-
5
- # Need to strip colors in case rvm_pretty_print_flag is enabled in user's .rvmrc
6
- rvm_list = `rvm list`.gsub(Regexp.new("\e\\[.?.?.?m"), '')
7
-
8
- current_ruby = rvm_list.match(/=.? ([^ ]+)/)[1]
9
- desired_ruby = current_ruby.gsub(/\-p\d+/, "")
10
-
11
- @env = RVM::Environment.new(desired_ruby)
12
-
13
- gemset_name = @app_name
14
-
15
- puts "Creating gemset #{gemset_name} in #{desired_ruby}"
16
- @env.gemset_create(gemset_name)
17
- puts "Now using gemset #{gemset_name}"
18
- @env.gemset_use!(gemset_name)
19
-
20
- rvm_current = `rvm current`.match(/[\w\d.-]+@[\w\d\.-]+/)[0].strip.split('@').last
21
-
22
- if rvm_current != gemset_name
23
- puts "Error using gemset #{gemset_name}:".red
24
- puts "#{rvm_current} does not match the gemset #{gemset_name}".yellow
25
- exit
26
- end
27
-
28
- # Since the gemset is likely empty, manually install bundler so it can install the rest
29
- run "gem install bundler --no-ri --no-rdoc"
30
-
31
- # Install all other gems needed from Gemfile
32
- run "bundle install"
33
-
34
- copy_static_file '.ruby-version'
35
- gsub_file '.ruby-version', /RUBY_VERSION/, desired_ruby
36
-
37
- copy_static_file '.ruby-gemset'
38
- gsub_file '.ruby-gemset', /GEMSET/, gemset_name
39
-
40
- git :add => '.ruby-version'
41
- git :add => '.ruby-gemset'
42
- git :commit => "-qm 'Adding RVM config files.'"
43
-
44
- git :add => 'Gemfile.lock'
45
- git :commit => "-qm 'Adding Gemfile.lock.'"
46
-
47
- puts "\n"