foobara-empty-ruby-project-generator 0.0.19 → 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 +8 -0
- data/src/manifests/project_config.rb +3 -1
- data/src/write_empty_ruby_project_to_disk.rb +100 -68
- 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
@@ -1,3 +1,11 @@
|
|
1
|
+
## [0.0.21] - 2025-05-03
|
2
|
+
|
3
|
+
- Make optional things fail-safe when shelling out and simplify the code a bit, too
|
4
|
+
|
5
|
+
## [0.0.20] - 2025-05-03
|
6
|
+
|
7
|
+
- Add use_git, push_to_github, and turn_on_rbenv_bundler options and default them to false
|
8
|
+
|
1
9
|
## [0.0.19] - 2025-05-03
|
2
10
|
|
3
11
|
- Do not fail just because gh isn't installed
|
@@ -19,7 +19,9 @@ module Foobara
|
|
19
19
|
author_names [:string]
|
20
20
|
author_emails [:string]
|
21
21
|
homepage_url :string
|
22
|
-
|
22
|
+
use_git :boolean, default: false
|
23
|
+
push_to_github :boolean, default: false
|
24
|
+
turn_on_rbenv_bundler :boolean, default: false
|
23
25
|
license :string, :allow_nil, one_of: ["MIT", "Apache-2.0", "MPL-2.0", "Apache-2.0 OR MIT"]
|
24
26
|
end
|
25
27
|
|
@@ -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
|
@@ -61,6 +63,18 @@ module Foobara
|
|
61
63
|
project_config.org_slash_project_kebab
|
62
64
|
end
|
63
65
|
|
66
|
+
def push_to_github?
|
67
|
+
project_config.push_to_github
|
68
|
+
end
|
69
|
+
|
70
|
+
def turn_on_rbenv_bundler?
|
71
|
+
project_config.turn_on_rbenv_bundler
|
72
|
+
end
|
73
|
+
|
74
|
+
def use_git?
|
75
|
+
project_config.use_git
|
76
|
+
end
|
77
|
+
|
64
78
|
def generate_file_contents
|
65
79
|
puts "generating..."
|
66
80
|
# TODO: just pass this in as the inputs instead of the command??
|
@@ -72,35 +86,37 @@ module Foobara
|
|
72
86
|
bundle_install
|
73
87
|
make_bin_files_executable
|
74
88
|
rubocop_autocorrect
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
89
|
+
|
90
|
+
if use_git?
|
91
|
+
git_init unless extract_from_another_repo?
|
92
|
+
git_add_all
|
93
|
+
git_commit
|
94
|
+
git_branch_main
|
95
|
+
|
96
|
+
if push_to_github?
|
97
|
+
github_create_repo
|
98
|
+
git_add_remote_origin
|
99
|
+
push_to_github
|
100
|
+
end
|
101
|
+
|
102
|
+
if turn_on_rbenv_bundler?
|
103
|
+
rbenv_bundler_on
|
104
|
+
end
|
105
|
+
end
|
83
106
|
end
|
84
107
|
end
|
85
108
|
|
86
109
|
def bundle_install
|
87
110
|
puts "bundling..."
|
88
|
-
|
89
|
-
Open3.popen3("bundle install") do |_stdin, _stdout, stderr, wait_thr|
|
90
|
-
exit_status = wait_thr.value
|
91
|
-
unless exit_status.success?
|
92
|
-
# :nocov:
|
93
|
-
raise "could not bundle install. #{stderr.read}"
|
94
|
-
# :nocov:
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
111
|
+
cmd = "bundle install"
|
98
112
|
|
99
113
|
if Bundler.respond_to?(:with_unbundled_env)
|
100
|
-
Bundler.with_unbundled_env
|
114
|
+
Bundler.with_unbundled_env do
|
115
|
+
run_cmd_and_return_output(cmd)
|
116
|
+
end
|
101
117
|
else
|
102
118
|
# :nocov:
|
103
|
-
|
119
|
+
run_cmd_and_return_output(cmd)
|
104
120
|
# :nocov:
|
105
121
|
end
|
106
122
|
end
|
@@ -108,15 +124,15 @@ module Foobara
|
|
108
124
|
def rubocop_autocorrect
|
109
125
|
puts "linting..."
|
110
126
|
|
111
|
-
|
127
|
+
cmd = "bundle exec rubocop --no-server -A"
|
112
128
|
|
113
129
|
if Bundler.respond_to?(:with_unbundled_env)
|
114
130
|
Bundler.with_unbundled_env do
|
115
|
-
|
131
|
+
run_cmd_and_return_output(cmd)
|
116
132
|
end
|
117
133
|
else
|
118
134
|
# :nocov:
|
119
|
-
|
135
|
+
run_cmd_and_return_output(cmd)
|
120
136
|
# :nocov:
|
121
137
|
end
|
122
138
|
end
|
@@ -124,90 +140,106 @@ module Foobara
|
|
124
140
|
def make_bin_files_executable
|
125
141
|
Dir["bin/*"].each do |file|
|
126
142
|
if File.file?(file)
|
127
|
-
|
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
|
128
151
|
end
|
129
152
|
end
|
130
153
|
end
|
131
154
|
|
132
155
|
def git_init
|
133
|
-
|
156
|
+
return if use_git_failed
|
134
157
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
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:
|
143
165
|
end
|
144
166
|
|
145
167
|
def git_add_all
|
146
|
-
|
168
|
+
return if use_git_failed
|
147
169
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
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:
|
156
177
|
end
|
157
178
|
|
158
179
|
def git_commit
|
159
|
-
|
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
|
160
185
|
# :nocov:
|
161
|
-
|
162
|
-
|
163
|
-
unless exit_status.success?
|
164
|
-
raise "could not git commit -m 'Initial commit'. OUTPUT\n#{stdout.read}\nERROR:#{stderr.read}"
|
165
|
-
end
|
166
|
-
end
|
186
|
+
self.use_git_failed = true
|
187
|
+
warn e.message
|
167
188
|
# :nocov:
|
168
189
|
end
|
169
190
|
|
170
191
|
def github_create_repo
|
192
|
+
return if push_to_github_failed
|
193
|
+
|
171
194
|
puts "pushing to github..."
|
172
195
|
|
173
196
|
cmd = "gh repo create --private #{project_config.org_slash_project_kebab}"
|
174
|
-
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
|
175
202
|
end
|
176
203
|
|
177
204
|
def git_add_remote_origin
|
178
|
-
|
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?
|
179
211
|
# :nocov:
|
180
|
-
|
212
|
+
self.push_to_github_failed = true
|
181
213
|
# :nocov:
|
182
214
|
end
|
183
215
|
end
|
184
216
|
|
185
217
|
def git_branch_main
|
186
|
-
|
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?
|
187
224
|
# :nocov:
|
188
|
-
|
225
|
+
self.use_git_failed = true
|
189
226
|
# :nocov:
|
190
227
|
end
|
191
228
|
end
|
192
229
|
|
193
230
|
def push_to_github
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
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
|
200
238
|
end
|
201
239
|
|
202
240
|
def rbenv_bundler_on
|
203
|
-
|
204
|
-
|
205
|
-
exit_status = wait_thr.value
|
206
|
-
unless exit_status.success?
|
207
|
-
warn "WARNING: could not rbenv bundler on \n #{stderr.read}"
|
208
|
-
end
|
209
|
-
end
|
210
|
-
# :nocov:
|
241
|
+
cmd = "rbenv bundler on"
|
242
|
+
run_cmd_and_write_output(cmd, raise_if_fails: false)
|
211
243
|
end
|
212
244
|
|
213
245
|
def output
|