effective_developer 0.4.16 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d56abcd9d4964e1ef609e137ee2e5cf0af65fef0b94420b75ece42f5dea60a9
4
- data.tar.gz: 626969c07fd04d4886b2b6044111ec3651c8f682dbb316318106f2528dca7dd1
3
+ metadata.gz: 5b1e21ed1c3b2080e07244e8e7d01cb9b611ce045c9c8ffa2073caded089f6c1
4
+ data.tar.gz: a0be18c08741489856b6aff27861d4b5408c4db12bd9e33b9e8898f072c47fd6
5
5
  SHA512:
6
- metadata.gz: 046a257cd7af7e70f2973f3d6082758a66c54982e8ee4b34f32ee91146ef43dd66c4c1b04dc7eb9d2503a5321d83d64f159d715d17f19bcf4b41d64f6427a555
7
- data.tar.gz: 904fe1dea98e96c21e87c7a74c6c2b7364025edc208719e6d657915566d3de47851892de84811b7e14ab6601edb65dcfecfd543aace4ec6f1bfa3edc5f47c15c
6
+ metadata.gz: 8c2822c02d0ce42a2f875ff1efa2dd84df01063e2d18dd14dcbb08b1379e9eaa19bcb6dafa1453943c953b8debaae210054973d6de7d6def7a3a4f0eb22ce6e0
7
+ data.tar.gz: a0f964f2d4e70ee5624618cd44819d8a97cd3875e9a3dac2531552fe12484d1a09031d96a12ac1729e28522c4110ece5208c49e9d8765acd0efa649537d2e1e2
@@ -1,4 +1,5 @@
1
1
  require 'effective_resources'
2
+ require 'rails/generators'
2
3
  require 'generators/effective/helpers'
3
4
  require 'effective_developer/engine'
4
5
  require 'effective_developer/version'
@@ -1,3 +1,3 @@
1
1
  module EffectiveDeveloper
2
- VERSION = '0.4.16'.freeze
2
+ VERSION = '0.5.4'.freeze
3
3
  end
@@ -6,17 +6,60 @@ namespace :pg do
6
6
  # bundle exec rake pg:pull[158.204.33.124]
7
7
  desc 'Creates a new backup on remote server and downloads it to latest.dump'
8
8
  task :pull, [:remote] => :environment do |t, args|
9
+
10
+ # Heroku mode
9
11
  if `git remote -v | grep heroku`.length > 0
10
- Rake::Task['heroku:pg:pull'].invoke(args[:remote])
11
- elsif (args[:remote] || ENV['HATCHBOX_IP']).to_s.count('.') == 3
12
- Rake::Task['hatchbox:pg:pull'].invoke(args[:remote])
13
- else
14
- puts "Unable to find pg:pull provider."
15
- puts "Please add a heroku git remote or a HATCHBOX_IP environment variable and try again"
16
- abort
12
+ args.with_defaults(remote: 'heroku')
13
+
14
+ puts "=== Pulling remote '#{args.remote}' database into latest.dump"
15
+
16
+ # Create a backup on heroku
17
+ unless system("heroku pg:backups:capture --remote #{args.remote}")
18
+ abort("Error capturing heroku backup")
19
+ end
20
+
21
+ # Download it to local
22
+ unless system("curl -o latest.dump `heroku pg:backups:public-url --remote #{args.remote}`")
23
+ abort("Error downloading database")
24
+ end
25
+
26
+ # Load it
27
+ Rake::Task['pg:load'].invoke
28
+ exit
29
+ end
30
+
31
+ # Hatchbox mode
32
+ if (ENV['HATCHBOX_IP'] || args[:remote]).count('.') == 3
33
+ args.with_defaults(
34
+ remote: ENV.fetch('HATCHBOX_IP'),
35
+ app: ENV['HATCHBOX_APP'] || `pwd`.split('/').last.chomp,
36
+ user: ENV['HATCHBOX_USER'] || 'deploy'
37
+ )
38
+
39
+ puts "=== Pulling hatchbox '#{args.remote}' #{args.app} database into latest.dump"
40
+
41
+ # SSH into hatchbox and call rake pg:save there to create latest.dump
42
+ unless(result = `ssh #{args.user}@#{args.remote} << EOF
43
+ cd ~/#{args.app}/current/
44
+ bundle exec rake pg:save[latest.dump]
45
+ `).include?('Saving database completed') # The output of pg:save down below
46
+ puts("Error calling ssh #{args.user}@#{args.remote} and running rake pg:save on hatchbox from ~/#{args.app}/current/")
47
+ abort(result)
48
+ end
49
+
50
+ # SCP to copy the hatchkbox latest.dump to local
51
+ unless system("scp #{args.user}@#{args.remote}:~/#{args.app}/current/latest.dump ./")
52
+ abort("Error downloading database")
53
+ end
54
+
55
+ # Load it
56
+ Rake::Task['pg:load'].invoke
57
+ exit
17
58
  end
18
59
 
19
- Rake::Task['pg:load'].invoke
60
+ puts "Unable to find pg:pull provider."
61
+ puts "Please add a heroku git remote or a HATCHBOX_IP environment variable and try again"
62
+ abort
20
63
  end
21
64
 
22
65
  # Drops and re-creates the local database then initializes database with latest.dump
@@ -29,6 +72,7 @@ namespace :pg do
29
72
 
30
73
  config = ActiveRecord::Base.configurations[Rails.env]
31
74
  db = { username: (config['username'] || `whoami`), password: config['password'], host: config['host'], port: (config['port'] || 5432), database: config['database'] }
75
+ db.transform_values! { |v| v.respond_to?(:chomp) ? v.chomp : v }
32
76
 
33
77
  puts "=== Loading #{args.file_name} into local '#{db[:database]}' database"
34
78
 
@@ -60,9 +104,11 @@ namespace :pg do
60
104
  { username: uri.user, password: uri.password, host: uri.host, port: (uri.port || 5432), database: uri.path.sub('/', '') }
61
105
  else
62
106
  config = ActiveRecord::Base.configurations[Rails.env]
63
- { username: (config['username'] || `whoami`), password: config['password'], host: config['host'], port: (config['port'] || 5432), database: config['database'] }
107
+ { username: (config['username'] || `whoami`.chomp), password: config['password'], host: config['host'], port: (config['port'] || 5432), database: config['database'] }
64
108
  end
65
109
 
110
+ db.transform_values! { |v| v.respond_to?(:chomp) ? v.chomp : v }
111
+
66
112
  puts "=== Saving local '#{db[:database]}' database to #{args.file_name}"
67
113
 
68
114
  if system("export PGPASSWORD=#{db[:password]}; pg_dump -Fc --no-acl --no-owner -h #{db[:host]} -p #{db[:port]} -U #{db[:username]} #{db[:database]} > #{args.file_name}")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_developer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.16
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-20 00:00:00.000000000 Z
11
+ date: 2020-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -95,8 +95,6 @@ files:
95
95
  - lib/scaffolds/models/model.rb
96
96
  - lib/scaffolds/views/_resource.html.haml
97
97
  - lib/tasks/effective_csv_importer.rake
98
- - lib/tasks/hatchbox.rake
99
- - lib/tasks/heroku.rake
100
98
  - lib/tasks/pg_pull.rake
101
99
  - lib/tasks/rename_class.rake
102
100
  - lib/tasks/reset_pk_sequence.rake
@@ -105,7 +103,7 @@ homepage: https://github.com/code-and-effect/effective_developer
105
103
  licenses:
106
104
  - MIT
107
105
  metadata: {}
108
- post_install_message:
106
+ post_install_message:
109
107
  rdoc_options: []
110
108
  require_paths:
111
109
  - lib
@@ -120,8 +118,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
118
  - !ruby/object:Gem::Version
121
119
  version: '0'
122
120
  requirements: []
123
- rubygems_version: 3.0.3
124
- signing_key:
121
+ rubygems_version: 3.1.2
122
+ signing_key:
125
123
  specification_version: 4
126
124
  summary: Provides some quality of life developer tools.
127
125
  test_files: []
@@ -1,17 +0,0 @@
1
- namespace :hatchbox do
2
- namespace :pg do
3
- # Creates a new backup on heroku, downloads that backup to latest.dump, and then calls pg:load
4
- #
5
- # bundle exec rake heroku:pull
6
- # bundle exec rake heroku:pull[staging]
7
- desc 'Pulls a newly captured backup from heroku (--remote heroku by default) and calls pg:load'
8
- task :pull, [:remote] => :environment do |t, args|
9
- args.with_defaults(remote: ENV['HATCHBOX_IP'])
10
-
11
- puts "=== Pulling remote '#{args.remote}' database into latest.dump"
12
-
13
- #scp deploy@159.203.32.114:~/cab/current/latest.dump ./
14
- end
15
-
16
- end
17
- end
@@ -1,27 +0,0 @@
1
- namespace :heroku do
2
- namespace :pg do
3
- # Creates a new backup on heroku, downloads that backup to latest.dump, and then calls pg:load
4
- #
5
- # bundle exec rake heroku:pg:pull
6
- # bundle exec rake heroku:pg:pull[staging]
7
- desc 'Pulls a newly captured backup from heroku (--remote heroku by default)'
8
- task :pull, [:remote] => :environment do |t, args|
9
- args.with_defaults(remote: 'heroku')
10
-
11
- puts "=== Pulling remote '#{args.remote}' database into latest.dump"
12
-
13
- Bundler.with_clean_env do
14
- unless system("heroku pg:backups:capture --remote #{args.remote}")
15
- abort("Error capturing heroku backup")
16
- end
17
-
18
- if system("curl -o latest.dump `heroku pg:backups:public-url --remote #{args.remote}`")
19
- puts("Downloading database completed")
20
- else
21
- abort("Error downloading database")
22
- end
23
- end
24
- end
25
-
26
- end
27
- end