foobara-empty-ruby-project-generator 0.0.7 → 0.0.8
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/types/extract_inputs.rb +13 -0
- data/src/write_empty_ruby_project_to_disk.rb +38 -8
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b46cc5ab7c3af85b233e1f3d6ed50d28d9dd979efe491466cf35827a91af698b
|
4
|
+
data.tar.gz: ac13fa15cc0b6e929b5e4ddc1b2d63219b9f548cef73d6f3abd295003ad12069
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f431725b00d3f7d5c33fc644f977a63c3161634521b34d2ee88515264728a402426bef68455d65e0cdc23e9fd4568ad51ebac45f39269c3af3ec6dca72993b8
|
7
|
+
data.tar.gz: 269d8f29c559ee0444d7319f1e8719673eb33d6baafcefe2ccfcbf01ecc4cd10aba3be15d16678db3db6cc0b25454585f39edea32a19b6792d597cc166a74940
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
module Foobara
|
2
|
+
module Generators
|
3
|
+
module EmptyRubyProjectGenerator
|
4
|
+
class ExtractInputs < Foobara::Model
|
5
|
+
attributes do
|
6
|
+
repo :string, :required
|
7
|
+
paths [:string], :required
|
8
|
+
delete_extracted :boolean, default: false
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative "generate_empty_ruby_project"
|
2
|
+
require "extract_repo"
|
2
3
|
|
3
4
|
module Foobara
|
4
5
|
module Generators
|
@@ -10,15 +11,21 @@ module Foobara
|
|
10
11
|
end
|
11
12
|
end
|
12
13
|
|
13
|
-
depends_on GenerateEmptyRubyProject
|
14
|
+
depends_on GenerateEmptyRubyProject,
|
15
|
+
::ExtractRepo
|
14
16
|
|
15
17
|
inputs do
|
18
|
+
extract ExtractInputs
|
16
19
|
project_config ProjectConfig, :required
|
17
20
|
# TODO: should be able to delete this and inherit it
|
18
21
|
output_directory :string
|
19
22
|
end
|
20
23
|
|
21
24
|
def execute
|
25
|
+
create_output_directory_if_needed
|
26
|
+
if extract_from_another_repo?
|
27
|
+
extract_from_another_repo
|
28
|
+
end
|
22
29
|
generate_file_contents
|
23
30
|
write_all_files_to_disk
|
24
31
|
run_post_generation_tasks
|
@@ -26,6 +33,24 @@ module Foobara
|
|
26
33
|
output
|
27
34
|
end
|
28
35
|
|
36
|
+
def create_output_directory_if_needed
|
37
|
+
FileUtils.mkdir_p output_directory
|
38
|
+
end
|
39
|
+
|
40
|
+
def extract_from_another_repo?
|
41
|
+
!!extract
|
42
|
+
end
|
43
|
+
|
44
|
+
def extract_from_another_repo
|
45
|
+
run_subcommand!(
|
46
|
+
ExtractRepo,
|
47
|
+
repo_url: extract.repo,
|
48
|
+
paths: extract.paths,
|
49
|
+
delete_extracted: extract.delete_extracted,
|
50
|
+
output_path: output_directory
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
29
54
|
def output_directory
|
30
55
|
inputs[:output_directory] || default_output_directory
|
31
56
|
end
|
@@ -45,7 +70,7 @@ module Foobara
|
|
45
70
|
bundle_install
|
46
71
|
make_bin_files_executable
|
47
72
|
rubocop_autocorrect
|
48
|
-
git_init
|
73
|
+
git_init unless extract_from_another_repo?
|
49
74
|
git_add_all
|
50
75
|
git_commit
|
51
76
|
github_create_repo
|
@@ -112,17 +137,22 @@ module Foobara
|
|
112
137
|
end
|
113
138
|
|
114
139
|
def git_add_all
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
140
|
+
cmd = "git add ."
|
141
|
+
|
142
|
+
Open3.popen3(cmd) do |_stdin, _stdout, stderr, wait_thr|
|
143
|
+
exit_status = wait_thr.value
|
144
|
+
unless exit_status.success?
|
145
|
+
# :nocov:
|
146
|
+
raise "could not #{cmd}\n#{stderr.read}"
|
147
|
+
# :nocov:
|
148
|
+
end
|
119
149
|
end
|
120
150
|
end
|
121
151
|
|
122
152
|
def git_commit
|
123
153
|
# TODO: set author/name with git config in CI so we don't have to skip this
|
124
154
|
# :nocov:
|
125
|
-
Open3.popen3("git commit -m '
|
155
|
+
Open3.popen3("git commit -m 'Create ruby project files'") do |_stdin, stdout, stderr, wait_thr|
|
126
156
|
exit_status = wait_thr.value
|
127
157
|
unless exit_status.success?
|
128
158
|
raise "could not git commit -m 'Initial commit'. OUTPUT\n#{stdout.read}\nERROR:#{stderr.read}"
|
@@ -136,7 +166,7 @@ module Foobara
|
|
136
166
|
def github_create_repo
|
137
167
|
puts "pushing to github..."
|
138
168
|
|
139
|
-
cmd = "gh repo create --public
|
169
|
+
cmd = "gh repo create --public #{project_config.org_slash_project_kebab}"
|
140
170
|
|
141
171
|
Open3.popen3(cmd) do |_stdin, _stdout, _stderr, wait_thr|
|
142
172
|
exit_status = wait_thr.value
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
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.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: extract-repo
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: foobara
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -64,6 +78,7 @@ files:
|
|
64
78
|
- src/generators/project_generator.rb
|
65
79
|
- src/generators/version_generator.rb
|
66
80
|
- src/manifests/project_config.rb
|
81
|
+
- src/types/extract_inputs.rb
|
67
82
|
- src/write_empty_ruby_project_to_disk.rb
|
68
83
|
- templates/.bundle/config
|
69
84
|
- templates/.github/workflows/ci.yml.erb
|
@@ -116,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
131
|
- !ruby/object:Gem::Version
|
117
132
|
version: '0'
|
118
133
|
requirements: []
|
119
|
-
rubygems_version: 3.5.
|
134
|
+
rubygems_version: 3.5.23
|
120
135
|
signing_key:
|
121
136
|
specification_version: 4
|
122
137
|
summary: Generates empty ruby project boilerplate code from a template
|