bamboolab_kaboom 0.1.0 → 0.2.0

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
  SHA256:
3
- metadata.gz: b6131743c73049e741f8e78b6523a920f7f43a169f268d7dee816a35b1cbfe5c
4
- data.tar.gz: 0df5be6710bde734916305e1a9402ef83a040120cce5ede56430f289c8ce77f4
3
+ metadata.gz: c2d3d12227b3ca6043eff485522e59c28c87b8524aa3dc3ba899133ba781f158
4
+ data.tar.gz: cd4ed8f699457ce8bbb5c60e0f8829b19c2904a21b4fb0b9da7e25150a03790a
5
5
  SHA512:
6
- metadata.gz: 60d8e4c9ce9a98bcbcf2a52bf75f068d785c5e7192700fd51b95ce22eae1e013eb99dc1d128dc206a438fb1d8a50d156f2003abe10cc3ff8170a386bf82fb87a
7
- data.tar.gz: 5a5400c999c25135c3fb711df4805b2ce42eb6876a56ddc37805b4ee6728c7106879b4c48ee87d74042dea1917e2b58bab33558d5e6ba56e94e3a0c2c5d8b124
6
+ metadata.gz: d5bd9dae6cb9627f6810aac2671a7c13f093cbeccbf56b8dc3fdc7482322e3442f992a60cf4b6658fc192ee4f017d139504caa56c3c11bc96d4f90b70180ffc5
7
+ data.tar.gz: ef4bc7349dabdbcea264541be897b0bc07b836cdd784281665bbbac3e968b7914b042dc5fcc01647631b6c6bf37e6628919ecd4fd969c0c8e399f10d2f88e005
@@ -31,7 +31,7 @@ module Kaboom
31
31
  end
32
32
 
33
33
  if Bundler::Dsl.evaluate('Gemfile', nil, {})&.ruby_version&.versions&.first != RUBY_VERSION
34
- say_and_exit "Error: Ruby version in current projects Gemfile is not the same as the currently running Ruby version.", :red
34
+ say "Warning: Ruby version specified in the project's Gemfile is not the same as the currently running Ruby version.", :yellow
35
35
  end
36
36
  end
37
37
 
@@ -44,8 +44,11 @@ module Kaboom
44
44
  say_and_exit "Environment file #{env_file} not found, run 'kamal envify -d destination'", :red
45
45
  end
46
46
 
47
- destination_clear_envs = YAML.load_file("config/deploy.#{destination}.yml")['env']['clear']
48
- ENV.update(destination_clear_envs.transform_values(&:to_s))
47
+ destination_clear_envs = YAML.load_file("config/deploy.#{destination}.yml")&.dig('env', 'clear') || {}
48
+ clear_envs = YAML.load_file("config/deploy.yml")&.dig('env', 'clear') || {}
49
+ merged_clear_envs = clear_envs.merge(destination_clear_envs)
50
+
51
+ ENV.update(merged_clear_envs.transform_values(&:to_s))
49
52
  end
50
53
 
51
54
  def load_credentials(destination)
@@ -23,10 +23,10 @@ module Kaboom
23
23
  %Q{psql #{local_connection_string} -c "DROP DATABASE IF EXISTS #{config[:name]}" >/dev/null 2>&1},
24
24
  %Q{psql #{local_connection_string} -c "CREATE DATABASE #{config[:name]};" >/dev/null 2>&1},
25
25
  %Q{psql #{local_connection_string.gsub('template1', config[:name])} < #{backup_file} >/dev/null 2>&1},
26
- %Q{RAILS_MASTER_KEY=`cat config/credentials/development.key` env bin/rails db:environment:set RAILS_ENV=development >/dev/null 2>&1},
26
+ %Q{psql #{local_connection_string.gsub('template1', config[:name])} -c "UPDATE ar_internal_metadata SET value = 'development' WHERE key = 'environment';" >/dev/null 2>&1},
27
27
  %Q{psql #{local_connection_string} -c "ALTER DATABASE #{config[:name]} OWNER TO #{config[:username]};" >/dev/null 2>&1},
28
28
  ]
29
- #require 'pry'; binding.pry
29
+
30
30
  commands.all? { |cmd| system(cmd) }
31
31
  end
32
32
  end
data/lib/kaboom.rb CHANGED
@@ -42,12 +42,25 @@ module Kaboom
42
42
 
43
43
  desc 'ssh DESTINATION', 'Run a bash SSH for deployed apps, defaults to staging'
44
44
  method_option :role, aliases: '-r', type: :string, desc: 'Role to run the SSH at (web, sidekiq, cron...)', default: 'web'
45
- def ssh(destination = 'staging')
45
+ method_option :server, aliases: '-s', type: :boolean, desc: 'Connect to underlying server running the app'
46
+ def ssh(destination = nil)
47
+ if options[:server] && options[:role] != 'web'
48
+ say "Warning: server option is supplied, role option will be ignored", :yellow
49
+ end
50
+
51
+ destination ||= 'staging' # Use default if destination is nil
46
52
  validate_repository!
47
53
  validate_destination(destination)
48
-
54
+
49
55
  confirm_production_action('SSH') if destination == 'production'
50
- run_command("bash", destination)
56
+
57
+ if options[:server]
58
+ server_user, server_host = get_server_user_and_host(destination)
59
+ say "Running SSH on #{server_host} as #{server_user} (#{destination})...", :green
60
+ exec("ssh #{server_user}@#{server_host}")
61
+ else
62
+ run_command("bash", destination)
63
+ end
51
64
  end
52
65
 
53
66
  private
@@ -57,5 +70,13 @@ module Kaboom
57
70
  exec("kamal app exec -i --reuse -q '#{command}' -d #{destination} --roles=#{options[:role]}")
58
71
  end
59
72
 
73
+ def get_server_user_and_host(destination)
74
+ config = YAML.load_file("config/deploy.#{destination}.yml")
75
+ server = config.dig('servers', 'web', 'hosts')[0]
76
+ user = config.dig('ssh', 'user') || 'root'
77
+
78
+ say_and_exit "Error: Invalid destination file (config/deploy.#{destination}.yml)" , :red unless server
79
+ return user, server
80
+ end
60
81
  end
61
82
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bamboolab_kaboom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - Your Name
7
+ - Luka Bak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-16 00:00:00.000000000 Z
11
+ date: 2024-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -28,132 +28,158 @@ dependencies:
28
28
  name: dotenv
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '2.8'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '2.8'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: kamal
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 1.4.0
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: '2.0'
48
51
  type: :runtime
49
52
  prerelease: false
50
53
  version_requirements: !ruby/object:Gem::Requirement
51
54
  requirements:
52
55
  - - ">="
53
56
  - !ruby/object:Gem::Version
54
- version: '0'
57
+ version: 1.4.0
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '2.0'
55
61
  - !ruby/object:Gem::Dependency
56
- name: pry
62
+ name: tty-prompt
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
- - - ">="
65
+ - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: '0'
67
+ version: '0.2'
62
68
  type: :runtime
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
- - - ">="
72
+ - - "~>"
67
73
  - !ruby/object:Gem::Version
68
- version: '0'
74
+ version: '0.2'
69
75
  - !ruby/object:Gem::Dependency
70
- name: tty-prompt
76
+ name: yaml
71
77
  requirement: !ruby/object:Gem::Requirement
72
78
  requirements:
73
- - - ">="
79
+ - - "~>"
74
80
  - !ruby/object:Gem::Version
75
- version: '0'
81
+ version: '0.3'
76
82
  type: :runtime
77
83
  prerelease: false
78
84
  version_requirements: !ruby/object:Gem::Requirement
79
85
  requirements:
80
- - - ">="
86
+ - - "~>"
81
87
  - !ruby/object:Gem::Version
82
- version: '0'
88
+ version: '0.3'
83
89
  - !ruby/object:Gem::Dependency
84
- name: yaml
90
+ name: erb
85
91
  requirement: !ruby/object:Gem::Requirement
86
92
  requirements:
87
- - - ">="
93
+ - - "~>"
88
94
  - !ruby/object:Gem::Version
89
- version: '0'
95
+ version: '4'
90
96
  type: :runtime
91
97
  prerelease: false
92
98
  version_requirements: !ruby/object:Gem::Requirement
93
99
  requirements:
94
- - - ">="
100
+ - - "~>"
95
101
  - !ruby/object:Gem::Version
96
- version: '0'
102
+ version: '4'
97
103
  - !ruby/object:Gem::Dependency
98
- name: erb
104
+ name: google-cloud-storage
99
105
  requirement: !ruby/object:Gem::Requirement
100
106
  requirements:
101
- - - ">="
107
+ - - "~>"
102
108
  - !ruby/object:Gem::Version
103
- version: '0'
109
+ version: '1.5'
104
110
  type: :runtime
105
111
  prerelease: false
106
112
  version_requirements: !ruby/object:Gem::Requirement
107
113
  requirements:
108
- - - ">="
114
+ - - "~>"
109
115
  - !ruby/object:Gem::Version
110
- version: '0'
116
+ version: '1.5'
111
117
  - !ruby/object:Gem::Dependency
112
- name: google-cloud-storage
118
+ name: tty-progressbar
113
119
  requirement: !ruby/object:Gem::Requirement
114
120
  requirements:
115
- - - ">="
121
+ - - "~>"
116
122
  - !ruby/object:Gem::Version
117
- version: '0'
123
+ version: '0.18'
118
124
  type: :runtime
119
125
  prerelease: false
120
126
  version_requirements: !ruby/object:Gem::Requirement
121
127
  requirements:
122
- - - ">="
128
+ - - "~>"
123
129
  - !ruby/object:Gem::Version
124
- version: '0'
130
+ version: '0.18'
125
131
  - !ruby/object:Gem::Dependency
126
- name: tty-progressbar
132
+ name: activesupport
127
133
  requirement: !ruby/object:Gem::Requirement
128
134
  requirements:
129
135
  - - ">="
130
136
  - !ruby/object:Gem::Version
131
- version: '0'
137
+ version: '6.0'
138
+ - - "<"
139
+ - !ruby/object:Gem::Version
140
+ version: '8.0'
132
141
  type: :runtime
133
142
  prerelease: false
134
143
  version_requirements: !ruby/object:Gem::Requirement
135
144
  requirements:
136
145
  - - ">="
137
146
  - !ruby/object:Gem::Version
138
- version: '0'
147
+ version: '6.0'
148
+ - - "<"
149
+ - !ruby/object:Gem::Version
150
+ version: '8.0'
139
151
  - !ruby/object:Gem::Dependency
140
- name: activesupport
152
+ name: pry
153
+ requirement: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - "~>"
156
+ - !ruby/object:Gem::Version
157
+ version: '0.14'
158
+ type: :development
159
+ prerelease: false
160
+ version_requirements: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - "~>"
163
+ - !ruby/object:Gem::Version
164
+ version: '0.14'
165
+ - !ruby/object:Gem::Dependency
166
+ name: ruby-lsp
141
167
  requirement: !ruby/object:Gem::Requirement
142
168
  requirements:
143
169
  - - ">="
144
170
  - !ruby/object:Gem::Version
145
- version: '6.0'
146
- type: :runtime
171
+ version: 0.17.3
172
+ type: :development
147
173
  prerelease: false
148
174
  version_requirements: !ruby/object:Gem::Requirement
149
175
  requirements:
150
176
  - - ">="
151
177
  - !ruby/object:Gem::Version
152
- version: '6.0'
178
+ version: 0.17.3
153
179
  description: Kaboom is a CLI tool to handle app maintenence, SSH connections, database
154
180
  and assets backups for apps deployed by Kamal.
155
181
  email:
156
- - your.email@example.com
182
+ - bakluka@gmail.com
157
183
  executables:
158
184
  - kaboom
159
185
  extensions: []
@@ -166,7 +192,7 @@ files:
166
192
  - lib/kaboom/helpers/database_helper.rb
167
193
  - lib/kaboom/helpers/utils.rb
168
194
  - lib/kaboom/version.rb
169
- homepage:
195
+ homepage: https://bamboolab.eu
170
196
  licenses:
171
197
  - MIT
172
198
  metadata: {}
@@ -185,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
211
  - !ruby/object:Gem::Version
186
212
  version: '0'
187
213
  requirements: []
188
- rubygems_version: 3.5.11
214
+ rubygems_version: 3.5.3
189
215
  signing_key:
190
216
  specification_version: 4
191
217
  summary: A CLI for managing Rails apps deployed by Kamal.