foobara-empty-ruby-project-generator 0.0.20 → 0.0.22

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: e82a8d6af3338fe69f43a3a4573720791a5d93064c50d2fa3d1e1f95a42f12aa
4
- data.tar.gz: 4d788a75115bf60b4bbb89089d3cfab7393fd95a3acb7b035f1e10fef6c93bf3
3
+ metadata.gz: d54c42677019038cc9b9265a2ccd89ff7642c72054cadd81c70d134b4343c2f4
4
+ data.tar.gz: 0d1c890589a1b4e0c7c30cfaaf2117eb7f90b139aba29e6ff53bd32871f4c179
5
5
  SHA512:
6
- metadata.gz: 875efa4b26a347baf98f9c4b347f15b472cc24bc1226691fe60cad7cf284db329b7df5d4c0ae8d73d486d6f0ceeeec4642f5e13550eb05128b4cf4425bd2310e
7
- data.tar.gz: f2ff5fbb32e62bf21d33ace1292257524f0023e35a6b1960561187529c7245ec21881cc570b06782c461622dfd7171cf2a276af4ece464e575dbfae8af9f8c2f
6
+ metadata.gz: 59e1f40a50d33313d88c9a5afbe046b52bf4f44af75d448874daf8dae5356e234c86edd5156eaa348e1436bc127d60e4a4ad7622aee2c77e5c5ce046aa1d8634
7
+ data.tar.gz: 5859021ff5ff1ada1c6146f30593532558afc9177239579cdc608f6e9991452231e904b33f3963065e6aa5e1320e8a0b3a020421026971f9091ea4d2028406c0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [0.0.22] - 2025-05-07
2
+
3
+ - Do not stop just because rubocop fails
4
+
5
+ ## [0.0.21] - 2025-05-03
6
+
7
+ - Make optional things fail-safe when shelling out and simplify the code a bit, too
8
+
1
9
  ## [0.0.20] - 2025-05-03
2
10
 
3
11
  - Add use_git, push_to_github, and turn_on_rbenv_bundler options and default them to false
@@ -35,6 +35,8 @@ module Foobara
35
35
  output
36
36
  end
37
37
 
38
+ attr_accessor :use_git_failed, :push_to_github_failed
39
+
38
40
  def create_output_directory_if_needed
39
41
  FileUtils.mkdir_p output_directory
40
42
  end
@@ -106,22 +108,15 @@ module Foobara
106
108
 
107
109
  def bundle_install
108
110
  puts "bundling..."
109
- do_it = proc do
110
- Open3.popen3("bundle install") do |_stdin, _stdout, stderr, wait_thr|
111
- exit_status = wait_thr.value
112
- unless exit_status.success?
113
- # :nocov:
114
- raise "could not bundle install. #{stderr.read}"
115
- # :nocov:
116
- end
117
- end
118
- end
111
+ cmd = "bundle install"
119
112
 
120
113
  if Bundler.respond_to?(:with_unbundled_env)
121
- Bundler.with_unbundled_env(&do_it)
114
+ Bundler.with_unbundled_env do
115
+ run_cmd_and_return_output(cmd)
116
+ end
122
117
  else
123
118
  # :nocov:
124
- do_it.call
119
+ run_cmd_and_return_output(cmd)
125
120
  # :nocov:
126
121
  end
127
122
  end
@@ -129,106 +124,126 @@ module Foobara
129
124
  def rubocop_autocorrect
130
125
  puts "linting..."
131
126
 
132
- do_it = -> { run_cmd_and_return_output("bundle exec rubocop --no-server -A") }
127
+ cmd = "bundle exec rubocop --no-server -A"
133
128
 
134
129
  if Bundler.respond_to?(:with_unbundled_env)
135
130
  Bundler.with_unbundled_env do
136
- do_it.call
131
+ run_cmd_and_return_output(cmd)
137
132
  end
138
133
  else
139
134
  # :nocov:
140
- do_it.call
135
+ run_cmd_and_return_output(cmd)
141
136
  # :nocov:
142
137
  end
138
+ rescue CouldNotExecuteError => e
139
+ # :nocov:
140
+ warn e.message
141
+ # :nocov:
143
142
  end
144
143
 
145
144
  def make_bin_files_executable
146
145
  Dir["bin/*"].each do |file|
147
146
  if File.file?(file)
148
- system("chmod u+x #{file}")
147
+ cmd = "chmod u+x #{file}"
148
+ begin
149
+ run_cmd_and_return_output(cmd)
150
+ rescue CouldNotExecuteError => e
151
+ # :nocov:
152
+ warn e.message
153
+ # :nocov:
154
+ end
149
155
  end
150
156
  end
151
157
  end
152
158
 
153
159
  def git_init
154
- cmd = "git init"
160
+ return if use_git_failed
155
161
 
156
- Open3.popen3(cmd) do |_stdin, _stdout, stderr, wait_thr|
157
- exit_status = wait_thr.value
158
- unless exit_status.success?
159
- # :nocov:
160
- raise "could not #{cmd}\n#{stderr.read}"
161
- # :nocov:
162
- end
163
- end
162
+ cmd = "git init"
163
+ run_cmd_and_return_output(cmd)
164
+ rescue CouldNotExecuteError => e
165
+ # :nocov:
166
+ self.use_git_failed = true
167
+ warn e.message
168
+ # :nocov:
164
169
  end
165
170
 
166
171
  def git_add_all
167
- cmd = "git add ."
172
+ return if use_git_failed
168
173
 
169
- Open3.popen3(cmd) do |_stdin, _stdout, stderr, wait_thr|
170
- exit_status = wait_thr.value
171
- unless exit_status.success?
172
- # :nocov:
173
- raise "could not #{cmd}\n#{stderr.read}"
174
- # :nocov:
175
- end
176
- end
174
+ cmd = "git add ."
175
+ run_cmd_and_return_output(cmd)
176
+ rescue CouldNotExecuteError => e
177
+ # :nocov:
178
+ self.use_git_failed = true
179
+ warn e.message
180
+ # :nocov:
177
181
  end
178
182
 
179
183
  def git_commit
180
- # TODO: set author/name with git config in CI so we don't have to skip this
184
+ return if use_git_failed
185
+
186
+ cmd = "git commit -m 'Create ruby project files'"
187
+ run_cmd_and_return_output(cmd)
188
+ rescue CouldNotExecuteError => e
181
189
  # :nocov:
182
- Open3.popen3("git commit -m 'Create ruby project files'") do |_stdin, stdout, stderr, wait_thr|
183
- exit_status = wait_thr.value
184
- unless exit_status.success?
185
- raise "could not git commit -m 'Initial commit'. OUTPUT\n#{stdout.read}\nERROR:#{stderr.read}"
186
- end
187
- end
190
+ self.use_git_failed = true
191
+ warn e.message
188
192
  # :nocov:
189
193
  end
190
194
 
191
195
  def github_create_repo
196
+ return if push_to_github_failed
197
+
192
198
  puts "pushing to github..."
193
199
 
194
200
  cmd = "gh repo create --private #{project_config.org_slash_project_kebab}"
195
- run_cmd_and_write_output(cmd, raise_if_fails: false)
201
+ exit_status = run_cmd_and_write_output(cmd, raise_if_fails: false)
202
+
203
+ unless exit_status&.success?
204
+ self.push_to_github_failed = true
205
+ end
196
206
  end
197
207
 
198
208
  def git_add_remote_origin
199
- unless system("git remote add origin git@github.com:#{project_config.org_slash_project_kebab}.git")
209
+ return if push_to_github_failed
210
+
211
+ cmd = "git remote add origin git@github.com:#{project_config.org_slash_project_kebab}.git"
212
+ exit_status = run_cmd_and_write_output(cmd, raise_if_fails: false)
213
+
214
+ unless exit_status&.success?
200
215
  # :nocov:
201
- raise "could not git remote add origin git@github.com:#{project_config.org_slash_project_kebab}.git"
216
+ self.push_to_github_failed = true
202
217
  # :nocov:
203
218
  end
204
219
  end
205
220
 
206
221
  def git_branch_main
207
- unless system("git branch -M main")
222
+ return if use_git_failed
223
+
224
+ cmd = "git branch -M main"
225
+ exit_status = run_cmd_and_write_output(cmd, raise_if_fails: false)
226
+
227
+ unless exit_status&.success?
208
228
  # :nocov:
209
- raise "could not git branch -M main"
229
+ self.use_git_failed = true
210
230
  # :nocov:
211
231
  end
212
232
  end
213
233
 
214
234
  def push_to_github
215
- Open3.popen3("git push -u origin main") do |_stdin, _stdout, stderr, wait_thr|
216
- exit_status = wait_thr.value
217
- unless exit_status.success?
218
- warn "WARNING: could not git push -u origin main \n #{stderr.read}"
219
- end
220
- end
235
+ return if push_to_github_failed
236
+
237
+ cmd = "git push -u origin main"
238
+ run_cmd_and_return_output(cmd)
239
+ rescue CouldNotExecuteError => e
240
+ self.push_to_github_failed = true
241
+ warn e.message
221
242
  end
222
243
 
223
244
  def rbenv_bundler_on
224
- # :nocov:
225
- Open3.popen3("rbenv bundler on") do |_stdin, _stdout, stderr, wait_thr|
226
- exit_status = wait_thr.value
227
- unless exit_status.success?
228
- warn "WARNING: could not rbenv bundler on \n #{stderr.read}"
229
- end
230
- end
231
- # :nocov:
245
+ cmd = "rbenv bundler on"
246
+ run_cmd_and_write_output(cmd, raise_if_fails: false)
232
247
  end
233
248
 
234
249
  def output
data/templates/Rakefile CHANGED
@@ -7,7 +7,7 @@ require "rubocop/rake_task"
7
7
 
8
8
  RuboCop::RakeTask.new
9
9
 
10
- task default: %i[spec rubocop]
10
+ task default: [:spec, :rubocop]
11
11
 
12
12
  task :environment do
13
13
  require_relative "boot"
@@ -2,7 +2,7 @@ ENV["FOOBARA_ENV"] ||= "development"
2
2
 
3
3
  require "bundler/setup"
4
4
 
5
- if %w[development test].include?(ENV["FOOBARA_ENV"])
5
+ if ["development", "test"].include?(ENV["FOOBARA_ENV"])
6
6
  require "pry"
7
7
  require "pry-byebug"
8
8
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara-empty-ruby-project-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20
4
+ version: 0.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-03 00:00:00.000000000 Z
10
+ date: 2025-05-08 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: extract-repo