foobara-empty-ruby-project-generator 0.0.20 → 0.0.21
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/src/write_empty_ruby_project_to_disk.rb +71 -60
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2b61d99024ebd625a84d1c39fa2dbc52a9535f67d38c55b5b34268e31d3c37a
|
4
|
+
data.tar.gz: 3059a9f887c3bfa08d9a059d8019be6e8267559be9992a12657b0ebf5edd1a62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f6d0cd0812dea545d4dc7e2498bb4830e2688dfc63109d0877fb9a3dde07b26fc29d56214977f14ad41c9f41884a6855a35b266e44637867a8463aba439680d
|
7
|
+
data.tar.gz: d1e492b3b824500c4675f8f69d2d74816617341bd0742bb627a89b30ad177d3d1e3c2f4beed2d1022b0991368b724f6f5e4cafca100ea26be5a51bdf1bc48881
|
data/CHANGELOG.md
CHANGED
@@ -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
|
-
|
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
|
114
|
+
Bundler.with_unbundled_env do
|
115
|
+
run_cmd_and_return_output(cmd)
|
116
|
+
end
|
122
117
|
else
|
123
118
|
# :nocov:
|
124
|
-
|
119
|
+
run_cmd_and_return_output(cmd)
|
125
120
|
# :nocov:
|
126
121
|
end
|
127
122
|
end
|
@@ -129,15 +124,15 @@ module Foobara
|
|
129
124
|
def rubocop_autocorrect
|
130
125
|
puts "linting..."
|
131
126
|
|
132
|
-
|
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
|
-
|
131
|
+
run_cmd_and_return_output(cmd)
|
137
132
|
end
|
138
133
|
else
|
139
134
|
# :nocov:
|
140
|
-
|
135
|
+
run_cmd_and_return_output(cmd)
|
141
136
|
# :nocov:
|
142
137
|
end
|
143
138
|
end
|
@@ -145,90 +140,106 @@ module Foobara
|
|
145
140
|
def make_bin_files_executable
|
146
141
|
Dir["bin/*"].each do |file|
|
147
142
|
if File.file?(file)
|
148
|
-
|
143
|
+
cmd = "chmod u+x #{file}"
|
144
|
+
begin
|
145
|
+
run_cmd_and_return_output(cmd)
|
146
|
+
rescue CouldNotExecuteError => e
|
147
|
+
# :nocov:
|
148
|
+
warn e.message
|
149
|
+
# :nocov:
|
150
|
+
end
|
149
151
|
end
|
150
152
|
end
|
151
153
|
end
|
152
154
|
|
153
155
|
def git_init
|
154
|
-
|
156
|
+
return if use_git_failed
|
155
157
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
end
|
158
|
+
cmd = "git init"
|
159
|
+
run_cmd_and_return_output(cmd)
|
160
|
+
rescue CouldNotExecuteError => e
|
161
|
+
# :nocov:
|
162
|
+
self.use_git_failed = true
|
163
|
+
warn e.message
|
164
|
+
# :nocov:
|
164
165
|
end
|
165
166
|
|
166
167
|
def git_add_all
|
167
|
-
|
168
|
+
return if use_git_failed
|
168
169
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
end
|
170
|
+
cmd = "git add ."
|
171
|
+
run_cmd_and_return_output(cmd)
|
172
|
+
rescue CouldNotExecuteError => e
|
173
|
+
# :nocov:
|
174
|
+
self.use_git_failed = true
|
175
|
+
warn e.message
|
176
|
+
# :nocov:
|
177
177
|
end
|
178
178
|
|
179
179
|
def git_commit
|
180
|
-
|
180
|
+
return if use_git_failed
|
181
|
+
|
182
|
+
cmd = "git commit -m 'Create ruby project files'"
|
183
|
+
run_cmd_and_return_output(cmd)
|
184
|
+
rescue CouldNotExecuteError => e
|
181
185
|
# :nocov:
|
182
|
-
|
183
|
-
|
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
|
186
|
+
self.use_git_failed = true
|
187
|
+
warn e.message
|
188
188
|
# :nocov:
|
189
189
|
end
|
190
190
|
|
191
191
|
def github_create_repo
|
192
|
+
return if push_to_github_failed
|
193
|
+
|
192
194
|
puts "pushing to github..."
|
193
195
|
|
194
196
|
cmd = "gh repo create --private #{project_config.org_slash_project_kebab}"
|
195
|
-
run_cmd_and_write_output(cmd, raise_if_fails: false)
|
197
|
+
exit_status = run_cmd_and_write_output(cmd, raise_if_fails: false)
|
198
|
+
|
199
|
+
unless exit_status&.success?
|
200
|
+
self.push_to_github_failed = true
|
201
|
+
end
|
196
202
|
end
|
197
203
|
|
198
204
|
def git_add_remote_origin
|
199
|
-
|
205
|
+
return if push_to_github_failed
|
206
|
+
|
207
|
+
cmd = "git remote add origin git@github.com:#{project_config.org_slash_project_kebab}.git"
|
208
|
+
exit_status = run_cmd_and_write_output(cmd, raise_if_fails: false)
|
209
|
+
|
210
|
+
unless exit_status&.success?
|
200
211
|
# :nocov:
|
201
|
-
|
212
|
+
self.push_to_github_failed = true
|
202
213
|
# :nocov:
|
203
214
|
end
|
204
215
|
end
|
205
216
|
|
206
217
|
def git_branch_main
|
207
|
-
|
218
|
+
return if use_git_failed
|
219
|
+
|
220
|
+
cmd = "git branch -M main"
|
221
|
+
exit_status = run_cmd_and_write_output(cmd, raise_if_fails: false)
|
222
|
+
|
223
|
+
unless exit_status&.success?
|
208
224
|
# :nocov:
|
209
|
-
|
225
|
+
self.use_git_failed = true
|
210
226
|
# :nocov:
|
211
227
|
end
|
212
228
|
end
|
213
229
|
|
214
230
|
def push_to_github
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
231
|
+
return if push_to_github_failed
|
232
|
+
|
233
|
+
cmd = "git push -u origin main"
|
234
|
+
run_cmd_and_return_output(cmd)
|
235
|
+
rescue CouldNotExecuteError => e
|
236
|
+
self.push_to_github_failed = true
|
237
|
+
warn e.message
|
221
238
|
end
|
222
239
|
|
223
240
|
def rbenv_bundler_on
|
224
|
-
|
225
|
-
|
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:
|
241
|
+
cmd = "rbenv bundler on"
|
242
|
+
run_cmd_and_write_output(cmd, raise_if_fails: false)
|
232
243
|
end
|
233
244
|
|
234
245
|
def output
|