hephaestus 0.8.12.1 → 0.8.12.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/README.md +1 -1
  4. data/bin/hephaestus +17 -27
  5. data/lib/hephaestus/engine.rb +2 -1
  6. data/lib/hephaestus/generators/app_generator.rb +177 -92
  7. data/lib/hephaestus/generators/base.rb +0 -8
  8. data/lib/hephaestus/version.rb +1 -1
  9. data/lib/hephaestus.rb +2 -9
  10. data/templates/bin/bundle +1 -1
  11. data/templates/{Gemfile → root/Gemfile} +0 -4
  12. data/templates/root/compose.yml +5 -0
  13. data/templates/root/hephaestus_dockerignore +43 -0
  14. data/templates/root/hephaestus_gitattributes +5 -0
  15. data/templates/root/hephaestus_licensed.yml +56 -0
  16. data/templates/root/hephaestus_rubocop.yml +5 -0
  17. data/templates/root/hephaestus_ruby-version +1 -0
  18. metadata +15 -19
  19. data/lib/hephaestus/app_builder.rb +0 -79
  20. data/lib/hephaestus/generators/config_generator.rb +0 -18
  21. data/lib/hephaestus/generators/core_generator.rb +0 -38
  22. data/lib/hephaestus/generators/db_generator.rb +0 -12
  23. data/lib/hephaestus/generators/deployment_generator.rb +0 -25
  24. data/lib/hephaestus/generators/lib_generator.rb +0 -12
  25. data/lib/hephaestus/generators/license_generator.rb +0 -19
  26. data/lib/hephaestus/generators/rubocop_generator.rb +0 -18
  27. data/lib/hephaestus/generators/sorbet_generator.rb +0 -17
  28. data/lib/version.rb +0 -6
  29. /data/templates/{Dockerfile → root/Dockerfile} +0 -0
  30. /data/templates/{Procfile → root/Procfile} +0 -0
  31. /data/templates/{README.md.erb → root/README.md.tt} +0 -0
  32. /data/templates/{config.ru → root/config.ru} +0 -0
  33. /data/templates/{hephaestus_env.sample → root/hephaestus_env.sample} +0 -0
  34. /data/templates/{hephaestus_gitignore → root/hephaestus_gitignore} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89c0585bf79ff89a4a35d183a6bdec69ec180effa6c5254aec22467093efeefa
4
- data.tar.gz: 0aefd45fc0dd8549a845f49b510ba9ec7fbe991c85af3f7c9e65e79ed613c9ca
3
+ metadata.gz: 946513d5bfb959191872e0404f6eb0c95c4a6d4ded918425926ba0ca24f09dce
4
+ data.tar.gz: 0524cf36eb6e3717eb1c1b7fab0de51438cbce348b0882a77e50422d5c25747a
5
5
  SHA512:
6
- metadata.gz: 1dcf277f2074215cbf3b207d99534f5bdcf2fd6deb9ed62d6c10e3c87680da8184a30a7e5cfce6ce58e05df6173fb1d808e1fc48edb45f4f1ee4627af2bf2054
7
- data.tar.gz: 96c5fbb95236e5fe15fd538742c89010e6d9a581b2cfbf3ce70677b7412a1a48301c8f58a68521b7f0b0d45a79f253ca0f5eb31f2475049584d322c491b6214a
6
+ metadata.gz: 15f88a25cfea5f83d2fb5ac629d163ab2d8b1205bc3b5a99cf38282b8628cac6da86a31f68c99e4e9eb0511e6a5f270ce562aada76e76db9eebf31a2f25073aa
7
+ data.tar.gz: 4271659d3c4302dcfa5cb991b8b9c01f20a8d2e8d13b3b554cfea8a79417117ee86ee2228188984bc1a78b7f42e5a81325386ebade0714c32dd14a7d8a5168c0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # [v0.8.12.2] - 17-12-2024
2
+ ## What's Changed
3
+ * Fixups by @gjtorikian in https://github.com/yettoapp/hephaestus/pull/97
4
+
5
+
6
+ **Full Changelog**: https://github.com/yettoapp/hephaestus/compare/v0.8.12.1...v0.8.12.2
1
7
  # [v0.8.12.1] - 16-12-2024
2
8
  ## What's Changed
3
9
  * general updates by @gjtorikian in https://github.com/yettoapp/hephaestus/pull/95
data/README.md CHANGED
@@ -26,7 +26,7 @@ Where `app` represents the name of the platform you'd like to interact with, lik
26
26
  If you're working on updating/testing this gem locally, you may also try:
27
27
 
28
28
  ```
29
- rm -rf plug-app && DEBUG=1 bundle exec bin/hephaestus plug-app
29
+ rm -rf plug-app && DEBUG=1 bundle exec hephaestus/bin/hephaestus plug-app
30
30
  ```
31
31
 
32
32
  This way you can wipe the dir and quickly iterate on new changes.
data/bin/hephaestus CHANGED
@@ -67,44 +67,34 @@ if ENV.fetch("HEPHAESTUS_NO_EXTERNAL", "0") != "1"
67
67
  end
68
68
  end
69
69
 
70
- puts Rainbow("Looking good! Proceeding...").blue
71
-
72
- path = ARGV.first
73
- if File.exist?(path)
74
- puts Rainbow("\nError: The directory #{path} already exists.").red
75
- exit 1
76
- end
77
-
78
- unless path.start_with?("plug-")
79
- puts Rainbow("\nError: The directory name must start with 'plug-'").red
80
- exit 1
81
- end
82
-
83
- if path.split("-").length < 2
84
- puts Rainbow("\nError: The directory name must start with 'plug-'").red
85
- exit 1
86
- end
70
+ puts Rainbow("You're on the latest version of Hephaestus! Proceeding...").blue
87
71
 
88
72
  ENGINE_ROOT = File.expand_path("..", __dir__)
89
73
  ENGINE_PATH = File.expand_path("../lib/hephaestus/engine", __dir__)
90
74
  APP_PATH = File.expand_path("../test/dummy/config/application", __dir__)
91
75
 
92
76
  # Set up gems listed in the Gemfile.
93
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
94
- require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
77
+ # ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
78
+ # require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
95
79
 
96
80
  require "rails/all"
97
81
  require "hephaestus"
98
82
 
99
83
  templates_root = File.expand_path(File.join("..", "templates"), File.dirname(__FILE__))
100
84
  Hephaestus::AppGenerator.source_root(templates_root)
101
- Hephaestus::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root
102
-
103
- ARGV.push("--minimal")
104
- ARGV.push("--no-skip-active-job")
105
- ARGV.push("--skip-asset-pipeline")
106
- ARGV.push("--skip-active-record")
107
- ARGV.push("--skip-docker")
108
- ARGV.push("--skip_bundle")
85
+
86
+ # Since we're hijacking Rails' generation process,
87
+ # we *do not* want any of Rails' generators to interfere.
88
+ # Rails provides its own list of generators,
89
+ # and then attaches Hephaestus' generators to that list;
90
+ # so, we'll remove any generators that come before Hephaestus' generators.
91
+ config = Hephaestus::AppGenerator.all_commands
92
+
93
+ delete_keys = true
94
+ config.keys.each do |key|
95
+ break if key == "hephaestus_generator"
96
+
97
+ config.delete(key) if delete_keys
98
+ end
109
99
 
110
100
  Hephaestus::AppGenerator.start
@@ -16,7 +16,8 @@ module Hephaestus
16
16
  when "production", "staging"
17
17
  ENV["GIT_SHA"] || ""
18
18
  when "development"
19
- %x(git rev-parse HEAD)
19
+ result = %x(git rev-parse HEAD 2>&1)
20
+ $CHILD_STATUS == 0 ? result : "deadbeef" # check if the child process exited cleanly.
20
21
  when "test"
21
22
  "deadbeef"
22
23
  end.chomp
@@ -4,11 +4,16 @@
4
4
  require "rails/generators"
5
5
  require "rails/generators/rails/app/app_generator"
6
6
  require "tempfile"
7
+ require "bundler"
7
8
 
9
+ require "hephaestus/actions"
8
10
  require "hephaestus/app_name"
9
11
  module Hephaestus
10
12
  class AppGenerator < Rails::Generators::AppGenerator
11
13
  include Hephaestus::AppName
14
+ include Hephaestus::Actions
15
+
16
+ attr_reader :result_dir
12
17
 
13
18
  hide!
14
19
 
@@ -24,16 +29,29 @@ module Hephaestus
24
29
  group: :hephaestus,
25
30
  desc: "Show this help message and quit"
26
31
 
27
- def finish_template
28
- invoke(:hephaestus_initialize)
29
- # super
30
- end
31
-
32
- def hephaestus_initialize
32
+ # This method name is important as everything before it is added by
33
+ # Rails::Generators::AppGenerator; this is our true entrypoint.
34
+ def hephaestus_generator
33
35
  say(set_color("Invoking Hephaestus customizations...", :cyan))
34
36
 
35
- invoke(:init_git)
36
- invoke(:customize_gemfile)
37
+ path = ARGV.first
38
+ if File.exist?(path)
39
+ raise(Rainbow("\nError: The directory #{path} already exists.").red.to_s)
40
+ end
41
+
42
+ unless path.start_with?("plug-")
43
+ raise(Rainbow("\nError: The directory name must start with 'plug-'").red.to_s)
44
+ end
45
+
46
+ if path.split("-").length < 2
47
+ raise(Rainbow("\nError: The directory name must start with 'plug-'").red.to_s)
48
+ end
49
+
50
+ @destination_stack << @app_path
51
+
52
+ @result_dir = @destination_stack.join(File::SEPARATOR)
53
+
54
+ invoke(:copy_basics)
37
55
 
38
56
  invoke(:copy_github_actions)
39
57
  invoke(:copy_vscode_settings)
@@ -44,28 +62,20 @@ module Hephaestus
44
62
  invoke(:setup_test_environment)
45
63
 
46
64
  invoke(:configure_app)
47
- invoke(:leftovers)
48
- end
49
-
50
- def init_git
51
- run("git remote add origin https://github.com/yettoapp/#{app_name}.git")
52
- run("git branch -m production")
65
+ invoke(:finalize)
66
+ invoke(:first_commit)
67
+ invoke(:outro)
53
68
  end
54
69
 
55
- def customize_gemfile
56
- say(set_color("Customizing Gemfile...", :cyan))
57
- template("Gemfile", "Gemfile", force: true)
58
- # FIXME: unsure why, but when the generators are called, Rails expects Gemfiles in these locations?
59
- copy_file("Gemfile", File.join(Hephaestus::AppGenerator.source_root, "Gemfile"))
60
- copy_file("Gemfile", File.join(Hephaestus::AppGenerator.source_root, "..", "Gemfile"))
61
- replace_in_files(Hephaestus::AppGenerator.source_root, %|ruby File.read(".ruby-version").strip|, %|ruby "#{Hephaestus::RUBY_VERSION}"|)
70
+ def copy_basics
71
+ capture_stdout do
72
+ directory("root", ".")
62
73
 
63
- unless ENV.fetch("HEPHAESTUS_NO_EXTERNAL", "0") == "1"
64
- capture_stdout do
65
- run("BUNDLE_GEMFILE=\"#{destination_root}/Gemfile\" bundle install", abort_on_failure: false)
66
- run("BUNDLE_GEMFILE=\"#{destination_root}/Gemfile\" bundle update")
67
- run("BUNDLE_GEMFILE=\"#{destination_root}/Gemfile\" bundle lock --add-platform x86_64-linux")
74
+ Dir.glob(File.join(destination_root, "hephaestus_*")).each do |file|
75
+ File.rename(file, file.gsub("hephaestus_", "."))
68
76
  end
77
+
78
+ copy_file("root/hephaestus_env.sample", ".env")
69
79
  end
70
80
  end
71
81
 
@@ -87,109 +97,151 @@ module Hephaestus
87
97
 
88
98
  def setup_development_environment
89
99
  say(set_color("Setting up the development environment...", :cyan))
90
- build(:setup_dev_environment)
100
+
91
101
  capture_stdout do
92
- build(:copy_setup_scripts)
102
+ copy_file("config/environments/blank.rb", "config/environments/development.rb", force: true)
103
+
104
+ directory(Hephaestus.source_path("script"), "script")
105
+
106
+ chmod_dir("script")
93
107
  end
94
108
  end
95
109
 
96
110
  def setup_staging_environment
97
111
  say(set_color("Setting up the staging environment...", :cyan))
98
- build(:setup_staging_environment)
112
+
99
113
  capture_stdout do
114
+ copy_file("config/environments/blank.rb", "config/environments/staging.rb", force: true)
100
115
  end
101
116
  end
102
117
 
103
118
  def setup_production_environment
104
119
  say(set_color("Setting up the production environment...", :cyan))
105
- build(:setup_production_environment)
120
+
106
121
  capture_stdout do
122
+ copy_file("config/environments/blank.rb", "config/environments/production.rb", force: true)
107
123
  end
108
124
  end
109
125
 
110
126
  def setup_test_environment
111
127
  say(set_color("Setting up the test environment...", :cyan))
112
- build(:setup_test_environment)
128
+
129
+ capture_stdout do
130
+ copy_file("config/environments/blank.rb", "config/environments/test.rb", force: true)
131
+ end
113
132
  end
114
133
 
115
134
  def configure_app
116
135
  say(set_color("Configuring app...", :cyan))
117
136
 
118
137
  capture_stdout do
119
- remove_dir("bin")
120
- remove_dir("app/helpers")
121
- remove_dir("app/models")
122
- remove_dir("app/views/layouts")
123
- remove_dir("lib/assets")
124
- remove_file("lib/tasks/.keep")
125
- end
138
+ # This must be here, rather than a generator, because generators are run in a Rails environment,
139
+ # and the bootup process requires the fake PEM key file to be present.
140
+ # we do this to specify the template source, otherwise the generator wants to use its own `test` dir
141
+ source = File.join(Hephaestus::AppGenerator.source_root, "test")
142
+ directory(source, "test", force: true)
143
+
144
+ # This must be here, rather than a generator, because generators are run in a Rails environment,
145
+ # and the OpenAPI middleware, which is loaded when the app boots, requires the schema files to be present.
146
+ directory("lib/schemas/api/2023-03-06", "lib/schemas/api/2023-03-06")
126
147
 
127
- # This must be here, rather than a generator, because generators are run in a Rails environment,
128
- # and the bootup process requires the fake PEM key file to be present.
129
- # we do this to specify the template source, otherwise the generator wants to use its own `test` dir
130
- source = File.join(Hephaestus::AppGenerator.source_root, "test")
131
- directory(source, "test", force: true)
148
+ # we do this to specify the template source, otherwise the generator wants to use Rails own `bin` dir
149
+ source = File.join(Hephaestus::Engine.root, "templates", "bin")
150
+ directory(source, "bin", force: true)
151
+ chmod_dir("bin")
132
152
 
133
- # This must be here, rather than a generator, because generators are run in a Rails environment,
134
- # and the OpenAPI middleware, which is loaded when the app boots, requires the schema files to be present.
135
- capture_stdout do
136
- directory("lib/schemas/api/2023-03-06", "lib/schemas/api/2023-03-06")
137
- end
153
+ # we do this to specify the template source, otherwise the generator wants to use Rails' own dir
154
+ ["controllers", "jobs", "services", "views"].each do |dir|
155
+ source = File.join(Hephaestus::Engine.root, "templates", "app", dir)
156
+ directory(source, "app/#{dir}", force: true)
157
+ end
138
158
 
139
- # we do this to specify the template source, otherwise the generator wants to use Rails own `bin` dir
140
- source = File.join(Hephaestus::Engine.root, "templates", "bin")
141
- directory(source, "bin", force: true)
159
+ directory("db", "db")
142
160
 
143
- say(set_color("\n*** All these upcoming `HEAD` errors are okay to ignore! ***\n", :cyan))
161
+ directory("vendor/fly", "vendor/fly")
144
162
 
145
- capture_stdout do
146
- generate("hephaestus:core")
163
+ directory("lib/tasks", "lib/tasks")
147
164
 
148
- generate("hephaestus:db")
149
- generate("hephaestus:deployment")
150
- generate("hephaestus:lib")
165
+ remove_file("config/credentials.yml.enc")
151
166
 
152
167
  # keep this at the end
153
- generate("hephaestus:config")
168
+ directory("config", "config", force: true, exclude_pattern: /blank.rb/)
154
169
  end
155
170
  end
156
171
 
157
- # NOTE: this function name is important as it matches
158
- # a Rails function of the same name (that performs work
159
- # that we don't want to do). Think of this as the final step in the process
160
- # started by `finish_template`.
161
- def leftovers
162
- build(:replace_generic_variables)
172
+ # Think of this as the final step in the process
173
+ # started by `hephaestus_generator`. All the relevant commands are run in the context of the
174
+ # new app directory.
175
+ def finalize
176
+ File.rename(File.join(destination_root, "app", "controllers", "app_controller.rb"), File.join(destination_root, "app", "controllers", "#{plug_name}_controller.rb"))
177
+ File.rename(File.join(destination_root, "app", "services", "app_service.rb"), File.join(destination_root, "app", "services", "#{plug_name}_service.rb"))
178
+ File.rename(File.join(destination_root, "test", "controllers", "app_controller_test.rb"), File.join(destination_root, "test", "controllers", "#{plug_name}_controller_test.rb"))
179
+ File.rename(File.join(destination_root, "test", "support", "webmocks", "app_webmock.rb"), File.join(destination_root, "test", "support", "webmocks", "#{plug_name}_webmock.rb"))
163
180
 
164
- say(set_color("Generating `hephaestus:license`...", :cyan))
165
- capture_stdout do
166
- generate("hephaestus:license")
167
- end
181
+ replace_in_file(File.join("lib", "schemas", "api", "2023-03-06", "openapi.json"), %r{paths/app.json}, "paths/#{plug_name}.json")
182
+ File.rename(File.join(destination_root, "lib", "schemas", "api", "2023-03-06", "paths", "app.json"), File.join(destination_root, "lib", "schemas", "api", "2023-03-06", "paths", "#{plug_name}.json"))
168
183
 
169
- say(set_color("Generating `hephaestus:rubocop`...", :cyan))
170
- capture_stdout do
171
- generate("hephaestus:rubocop")
172
- end
184
+ Dir.chdir(shell.base.result_dir) do
185
+ unless ENV.fetch("HEPHAESTUS_NO_EXTERNAL", "0") == "1"
186
+ say(set_color("Installing gems...", :cyan))
187
+ capture_stdout do
188
+ run("bundle install", abort_on_failure: false)
189
+ run("bundle update")
190
+ run("bundle lock --add-platform x86_64-linux")
191
+ end
192
+ end
173
193
 
174
- # say(set_color("Generating `hephaestus:sorbet`...", :cyan))
175
- # capture_stdout do
176
- # generate("hephaestus:sorbet")
177
- # end
194
+ result = nil
195
+ say(set_color("Generating `hephaestus:license`...", :cyan))
196
+ Bundler.with_unbundled_env do
197
+ capture_stdout do
198
+ capture_stderr do
199
+ result = run("script/licenses --update", quiet: true, abort_on_failure: false)
200
+ end
201
+ end
202
+ end
178
203
 
179
- replace_in_file(File.join("lib", "schemas", "api", "2023-03-06", "openapi.json"), %r{app/paths.json}, "#{plug_name}/paths.json")
180
- File.rename(File.join(destination_root, "lib", "schemas", "api", "2023-03-06", "paths", "app.json"), File.join(destination_root, "lib", "schemas", "api", "2023-03-06", "paths", "#{plug_name}.json"))
204
+ unless result
205
+ say(set_color("Error generating licenses. When Hephaestus finishes executing, run `script/licenses --update`.", :red))
206
+ sleep(3)
207
+ end
181
208
 
182
- say(set_color("Creating first commit...", :cyan))
183
- capture_stdout do
184
- invoke(:commit)
185
- end
209
+ # say(set_color("Generating `hephaestus:sorbet`...", :cyan))
210
+ # Bundler.with_unbundled_env do
211
+ # run("bundle exec tapioca init")
212
+ # run("bundle exec tapioca require")
213
+ # run("script/sorbet --update")
214
+ # end
215
+
216
+ say(set_color("Generating `hephaestus:rubocop`...", :cyan))
217
+ Bundler.with_unbundled_env do
218
+ capture_stdout do
219
+ capture_stderr do
220
+ result = run("bundle exec rubocop -A", abort_on_failure: false)
221
+ end
222
+ end
223
+ end
186
224
 
187
- invoke(:outro)
225
+ unless result
226
+ say(set_color("Could not run Rubocop. When Hephaestus finishes executing, run `bundle exec rubocop -A`.", :red))
227
+ sleep(3)
228
+ end
229
+ end
188
230
  end
189
231
 
190
- def commit
191
- run("git add .")
192
- run("git commit -m 'Initial commit'", capture: true)
232
+ def first_commit
233
+ say(set_color("Creating first commit...", :cyan))
234
+
235
+ Dir.chdir(shell.base.result_dir) do
236
+ capture_stdout do
237
+ run("git init")
238
+ run("git remote add origin https://github.com/yettoapp/#{app_name}.git")
239
+ run("git branch -m production")
240
+
241
+ run("git add .")
242
+ run("git commit -m 'Initial commit'", capture: true)
243
+ end
244
+ end
193
245
  end
194
246
 
195
247
  def outro
@@ -245,13 +297,46 @@ module Hephaestus
245
297
  !options[:skip_active_record]
246
298
  end
247
299
 
248
- private def capture_stdout
249
- out = StringIO.new
250
- $stdout = out
300
+ private def capture_stdout(&block)
301
+ capture_stream("stdout", &block)
302
+ end
303
+
304
+ private def capture_stderr(&block)
305
+ capture_stream("stderr", &block)
306
+ end
307
+
308
+ private def capture_stream(stream)
309
+ captured_stream = Tempfile.new(stream)
310
+ stream_io = eval("$#{stream}", binding, __FILE__, __LINE__) # rubocop:disable Security/Eval
311
+ origin_stream = stream_io.dup
312
+ stream_io.reopen(captured_stream)
313
+
251
314
  yield
252
- out.string
253
- ensure
254
- $stdout = STDOUT
315
+
316
+ stream_io.rewind
317
+ captured_stream.read
318
+
319
+ unless captured_stream.nil?
320
+ captured_stream.close
321
+ captured_stream.unlink
322
+ end
323
+ stream_io.reopen(origin_stream) unless stream_io.nil?
324
+ end
325
+
326
+ private def chmod_dir(dir)
327
+ Dir.glob(File.join(destination_root, dir, "**", "*")).each do |file|
328
+ next if File.directory?(file)
329
+
330
+ # Rails adds this
331
+ if file == ".keep"
332
+ remove_file(file)
333
+ next
334
+ end
335
+
336
+ # this is because we might have *.tt templates, which aren't executable,
337
+ # so we gotta re-execute-em all
338
+ chmod(file, 0o755)
339
+ end
255
340
  end
256
341
  end
257
342
  end
@@ -32,14 +32,6 @@ module Hephaestus
32
32
 
33
33
  private
34
34
 
35
- def app_name
36
- Rails.app_class.module_parent_name.demodulize.underscore.dasherize
37
- end
38
-
39
- def short_app_name
40
- app_name.sub(/plug-/i, "")
41
- end
42
-
43
35
  def empty_directory_with_keep_file(destination)
44
36
  empty_directory(destination, {})
45
37
  keep_file(destination)
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Hephaestus
5
- VERSION = "0.8.12.1"
5
+ VERSION = "0.8.12.2"
6
6
  RAILS_VERSION = ">= 8.0"
7
7
  RUBY_VERSION = File
8
8
  .read("#{File.dirname(__FILE__)}/../../.ruby-version")
data/lib/hephaestus.rb CHANGED
@@ -8,24 +8,17 @@ def debugging?
8
8
  end
9
9
 
10
10
  require "debug" if debugging?
11
+ require "amazing_print" if debugging?
11
12
 
12
13
  require "hephaestus/version"
13
14
  require "hephaestus/engine"
14
15
 
15
16
  require "hephaestus/generators/app_generator"
16
- require "hephaestus/generators/config_generator"
17
- require "hephaestus/generators/core_generator"
18
- require "hephaestus/generators/db_generator"
19
- require "hephaestus/generators/deployment_generator"
20
- require "hephaestus/generators/lib_generator"
21
- require "hephaestus/generators/license_generator"
22
- require "hephaestus/generators/rubocop_generator"
23
- require "hephaestus/generators/sorbet_generator"
24
17
 
25
18
  require "hephaestus/actions"
26
19
  require "hephaestus/app_name"
20
+
27
21
  require "hephaestus/actions/strip_comments_action"
28
- require "hephaestus/app_builder"
29
22
 
30
23
  module Hephaestus
31
24
  class << self
data/templates/bin/bundle CHANGED
@@ -41,7 +41,7 @@ m = Module.new do
41
41
 
42
42
  def gemfile
43
43
  gemfile = ENV["BUNDLE_GEMFILE"]
44
- return gemfile if gemfile.present?
44
+ return gemfile if gemfile && !gemfile.empty? # rubocop:disable Rails/Present
45
45
 
46
46
  File.expand_path("../Gemfile", __dir__)
47
47
  end
@@ -13,10 +13,6 @@ gem "hephaestus", "~> 0.8"
13
13
 
14
14
  # !!! TODO: put your platform's dependencies here !!!
15
15
 
16
- # the one and only
17
- gem "octokit", "~> 9.1"
18
- gem "faraday-retry", "~> 2.2"
19
-
20
16
  group :development, :test do
21
17
  # better debug output with `ap`
22
18
  gem "amazing_print"
@@ -0,0 +1,5 @@
1
+ services:
2
+ redis-db:
3
+ image: redis:7-bookworm
4
+ ports:
5
+ - "6401:6401"
@@ -0,0 +1,43 @@
1
+ # See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.
2
+
3
+ # Ignore git directory.
4
+ /.git/
5
+
6
+ # Ignore bundler config.
7
+ /.bundle
8
+
9
+ # Ignore all environment files (except templates).
10
+ /.env*
11
+ !/.env*.erb
12
+
13
+ # Ignore all default key files.
14
+ /config/master.key
15
+ /config/credentials/*.key
16
+
17
+ # Ignore all logfiles and tempfiles.
18
+ /log/*
19
+ /tmp/*
20
+ !/log/.keep
21
+ !/tmp/.keep
22
+
23
+ # Ignore pidfiles, but keep the directory.
24
+ /tmp/pids/*
25
+ !/tmp/pids/.keep
26
+
27
+ # Ignore storage (uploaded files in development and any SQLite databases).
28
+ /storage/*
29
+ !/storage/.keep
30
+ /tmp/storage/*
31
+ !/tmp/storage/.keep
32
+
33
+ # Ignore assets.
34
+ /node_modules/
35
+ /app/assets/builds/*
36
+ !/app/assets/builds/.keep
37
+ /public/assets
38
+
39
+ # Use the one in the base Dockerfile
40
+ .ruby-version
41
+
42
+ security-results.json
43
+ coverage/
@@ -0,0 +1,5 @@
1
+ # See https://git-scm.com/docs/gitattributes for more about git attribute files.
2
+
3
+
4
+ # Mark any vendored files as having been vendored.
5
+ vendor/* linguist-vendored
@@ -0,0 +1,56 @@
1
+ cache_path: vendor/.licenses
2
+
3
+ allowed:
4
+ - apache-2.0
5
+ - bsd-2-clause
6
+ - bsd-3-clause
7
+ - isc
8
+ - mit
9
+ - cc0-1.0
10
+ - unlicense
11
+
12
+ ignored:
13
+ bundler:
14
+ - base64 # BSD-2-Clause ("This file is released under the same license as ruby.")
15
+ - benchmark # BSD-2-Clause
16
+ - bigdecimal # BSD-2-Clause ("This file is released under the same license as ruby.")
17
+ - bundler-audit # GPL-3.0; but also, only used in CI/test
18
+ - drb # BSD-2-Clause ("This file is released under the same license as ruby.")
19
+ - io-console # BSD-2-Clause
20
+ - logger # BSD-2-Clause
21
+ - mutex_m # BSD-2-Clause ("This file is released under the same license as ruby.")
22
+ - reline # BSD-2-Clause ("This file is released under the same license as ruby.")
23
+ - rdoc # BSD-2-Clause ("This file is released under the same license as ruby.")
24
+ - ruby2_keywords # BSD-2-Clause; ignored because of custom LICENSE text
25
+ - securerandom # BSD-2-Clause ("This file is released under the same license as ruby.")
26
+ - sidekiq # LGPL-3.0; ignored because of custom LICENSE text
27
+ - stringio # BSD-2-Clause ("This file is released under the same license as ruby.")
28
+ - uri # BSD-2-Clause
29
+
30
+ reviewed:
31
+ bundler:
32
+ - activerecord # MIT
33
+ - brakeman # BRAKEMAN PUBLIC USE LICENSE
34
+ - bundler # MIT
35
+ - concurrent-ruby # MIT
36
+ - date # BSD-2-Clause
37
+ - dry-core # MIT
38
+ - dry-transformer # MIT
39
+ - exponential-backoff # MIT
40
+ - faraday-net_http # MIT
41
+ - json # BSD-2-Clause
42
+ - jwt # MIT
43
+ - net-http # BSD-2-Clause
44
+ - net-imap # BSD-2-Clause
45
+ - net-pop # BSD-2-Clause
46
+ - net-protocol # BSD-2-Clause
47
+ - net-smtp # BSD-2-Clause
48
+ - nio4r # MIT
49
+ - parser # MIT
50
+ - pg # BSD-2-Clause
51
+ - racc # BSD-2-Clause
52
+ - timeout # BSD-2-Clause
53
+ - unf # BSD-2-Clause
54
+ - websocket-driver # Apache-2.0
55
+ - websocket-extensions # Apache-2.0
56
+
@@ -0,0 +1,5 @@
1
+ inherit_gem:
2
+ rubocop-standard:
3
+ - config/default.yml
4
+ - config/minitest.yml
5
+ - config/rails.yml
@@ -0,0 +1 @@
1
+ 3.3.6
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hephaestus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.12.1
4
+ version: 0.8.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-16 00:00:00.000000000 Z
11
+ date: 2024-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootsnap
@@ -427,19 +427,10 @@ files:
427
427
  - lib/hephaestus.rb
428
428
  - lib/hephaestus/actions.rb
429
429
  - lib/hephaestus/actions/strip_comments_action.rb
430
- - lib/hephaestus/app_builder.rb
431
430
  - lib/hephaestus/app_name.rb
432
431
  - lib/hephaestus/engine.rb
433
432
  - lib/hephaestus/generators/app_generator.rb
434
433
  - lib/hephaestus/generators/base.rb
435
- - lib/hephaestus/generators/config_generator.rb
436
- - lib/hephaestus/generators/core_generator.rb
437
- - lib/hephaestus/generators/db_generator.rb
438
- - lib/hephaestus/generators/deployment_generator.rb
439
- - lib/hephaestus/generators/lib_generator.rb
440
- - lib/hephaestus/generators/license_generator.rb
441
- - lib/hephaestus/generators/rubocop_generator.rb
442
- - lib/hephaestus/generators/sorbet_generator.rb
443
434
  - lib/hephaestus/http.rb
444
435
  - lib/hephaestus/middleware.rb
445
436
  - lib/hephaestus/middleware/malformed_request.rb
@@ -454,11 +445,6 @@ files:
454
445
  - lib/hephaestus/version.rb
455
446
  - lib/tasks/hephaestus_tasks.rake
456
447
  - lib/tasks/rubocop.rake
457
- - lib/version.rb
458
- - templates/Dockerfile
459
- - templates/Gemfile
460
- - templates/Procfile
461
- - templates/README.md.erb
462
448
  - templates/app/controllers/app_controller.rb.tt
463
449
  - templates/app/controllers/application_controller.rb
464
450
  - templates/app/controllers/concerns/authable.rb.tt
@@ -479,7 +465,6 @@ files:
479
465
  - templates/bin/rake
480
466
  - templates/bin/setup
481
467
  - templates/bin/tapioca
482
- - templates/config.ru
483
468
  - templates/config/application.rb.tt
484
469
  - templates/config/boot.rb
485
470
  - templates/config/environment.rb
@@ -491,7 +476,6 @@ files:
491
476
  - templates/config/routes.rb.tt
492
477
  - templates/db/queue_schema.rb
493
478
  - templates/db/schema.rb
494
- - templates/hephaestus_env.sample
495
479
  - templates/hephaestus_github/dependabot.yml
496
480
  - templates/hephaestus_github/workflows/automerge.yml
497
481
  - templates/hephaestus_github/workflows/deploy.yml
@@ -501,7 +485,6 @@ files:
501
485
  - templates/hephaestus_github/workflows/sorbet.yml
502
486
  - templates/hephaestus_github/workflows/test.yml.tt
503
487
  - templates/hephaestus_github/workflows/updater.yml
504
- - templates/hephaestus_gitignore
505
488
  - templates/hephaestus_vscode/extensions.json
506
489
  - templates/hephaestus_vscode/launch.json
507
490
  - templates/hephaestus_vscode/settings.json
@@ -524,6 +507,19 @@ files:
524
507
  - templates/lib/schemas/api/2023-03-06/paths/yetto/message_created.json
525
508
  - templates/lib/schemas/api/2023-03-06/paths/yetto/plug_installation_created.json
526
509
  - templates/lib/tasks/test_tasks.rake
510
+ - templates/root/Dockerfile
511
+ - templates/root/Gemfile
512
+ - templates/root/Procfile
513
+ - templates/root/README.md.tt
514
+ - templates/root/compose.yml
515
+ - templates/root/config.ru
516
+ - templates/root/hephaestus_dockerignore
517
+ - templates/root/hephaestus_env.sample
518
+ - templates/root/hephaestus_gitattributes
519
+ - templates/root/hephaestus_gitignore
520
+ - templates/root/hephaestus_licensed.yml
521
+ - templates/root/hephaestus_rubocop.yml
522
+ - templates/root/hephaestus_ruby-version
527
523
  - templates/script/ci
528
524
  - templates/script/docker-build-prod.tt
529
525
  - templates/script/docker-run.tt
@@ -1,79 +0,0 @@
1
- # typed: false
2
- # frozen_string_literal: true
3
-
4
- require "forwardable"
5
-
6
- module Hephaestus
7
- class AppBuilder < ::Rails::AppBuilder
8
- include Hephaestus::Actions
9
-
10
- extend Forwardable
11
-
12
- def readme
13
- template("README.md.erb", "README.md")
14
- end
15
-
16
- def gitignore
17
- copy_file("hephaestus_gitignore", ".gitignore")
18
- end
19
-
20
- def setup_dev_environment
21
- copy_file("config/environments/blank.rb", "config/environments/development.rb", force: true)
22
- end
23
-
24
- def copy_setup_scripts
25
- directory(Hephaestus.source_path("script"), "script")
26
- Dir.glob("script/**/*").each do |file|
27
- next if File.directory?(file)
28
-
29
- # Rails adds this
30
- if file == ".keep"
31
- remove_file(file)
32
- next
33
- end
34
-
35
- # this is because we might have *.tt templates, which aren't executable,
36
- # so we gotta re-execute-em all
37
- chmod(file, 0o755)
38
- end
39
- end
40
-
41
- def setup_staging_environment
42
- copy_file("config/environments/blank.rb", "config/environments/staging.rb", force: true)
43
- end
44
-
45
- def setup_production_environment
46
- copy_file("config/environments/blank.rb", "config/environments/production.rb", force: true)
47
- end
48
-
49
- def setup_test_environment
50
- copy_file("config/environments/blank.rb", "config/environments/test.rb", force: true)
51
- end
52
-
53
- def ruby_version
54
- create_file(".ruby-version", "#{Hephaestus::RUBY_VERSION}\n")
55
- end
56
-
57
- def replace_generic_variables
58
- say(set_color("Replacing generic file names...", :cyan))
59
-
60
- File.rename(File.join(destination_root, "app", "controllers", "app_controller.rb"), File.join(destination_root, "app", "controllers", "#{plug_name}_controller.rb"))
61
- File.rename(File.join(destination_root, "app", "services", "app_service.rb"), File.join(destination_root, "app", "services", "#{plug_name}_service.rb"))
62
- File.rename(File.join(destination_root, "test", "controllers", "app_controller_test.rb"), File.join(destination_root, "test", "controllers", "#{plug_name}_controller_test.rb"))
63
- File.rename(File.join(destination_root, "test", "support", "webmocks", "app_webmock.rb"), File.join(destination_root, "test", "support", "webmocks", "#{plug_name}_webmock.rb"))
64
-
65
- replace_in_file(File.join("lib", "schemas", "api", "2023-03-06", "openapi.json"), %r{app/paths.json}, "#{plug_name}/paths.json")
66
- File.rename(File.join(destination_root, "lib", "schemas", "api", "2023-03-06", "paths", "app.json"), File.join(destination_root, "lib", "schemas", "api", "2023-03-06", "paths", "#{plug_name}.json"))
67
- end
68
-
69
- private
70
-
71
- def root_path
72
- @root_path ||= Pathname(__dir__).join("..", "..").expand_path
73
- end
74
-
75
- def development_env?
76
- root_path.join("hephaestus.gemspec").exist?
77
- end
78
- end
79
- end
@@ -1,18 +0,0 @@
1
- # typed: false
2
- # frozen_string_literal: true
3
-
4
- require_relative "base"
5
-
6
- module Hephaestus
7
- class ConfigGenerator < Generators::Base
8
- include Hephaestus::AppName
9
-
10
- def config_application
11
- directory("config", "config", force: true, exclude_pattern: /blank.rb/)
12
- end
13
-
14
- def credentials
15
- remove_file("config/credentials.yml.enc")
16
- end
17
- end
18
- end
@@ -1,38 +0,0 @@
1
- # typed: false
2
- # frozen_string_literal: true
3
-
4
- # require_relative "base"
5
-
6
- module Hephaestus
7
- class CoreGenerator < Generators::Base
8
- include Hephaestus::AppName
9
-
10
- def gemfile
11
- # we do this to specify the template source, otherwise the generator wants to use Rails own `controllers` dir
12
- source = File.join(Hephaestus::Engine.root, "templates", "Gemfile")
13
- copy_file(source, "Gemfile", force: true)
14
- end
15
-
16
- def controllers
17
- # we do this to specify the template source, otherwise the generator wants to use Rails own `controllers` dir
18
- source = File.join(Hephaestus::Engine.root, "templates", "app", "controllers")
19
- directory(source, "app/controllers", force: true)
20
- end
21
-
22
- def jobs
23
- # we do this to specify the template source, otherwise the generator wants to use Rails own `jobs` dir
24
- source = File.join(Hephaestus::Engine.root, "templates", "app", "jobs")
25
- directory(source, "app/jobs", force: true)
26
- end
27
-
28
- def services
29
- source = File.join(Hephaestus::Engine.root, "templates", "app", "services")
30
- directory(source, "app/services", force: true)
31
- end
32
-
33
- def views
34
- source = File.join(Hephaestus::Engine.root, "templates", "app", "views")
35
- directory(source, "app/views", force: true)
36
- end
37
- end
38
- end
@@ -1,12 +0,0 @@
1
- # typed: false
2
- # frozen_string_literal: true
3
-
4
- require_relative "base"
5
-
6
- module Hephaestus
7
- class DbGenerator < Generators::Base
8
- def database
9
- directory("db", "db")
10
- end
11
- end
12
- end
@@ -1,25 +0,0 @@
1
- # typed: false
2
- # frozen_string_literal: true
3
-
4
- require_relative "base"
5
-
6
- module Hephaestus
7
- class DeploymentGenerator < Generators::Base
8
- def procfile
9
- copy_file("Procfile", "Procfile")
10
- end
11
-
12
- def dotenv
13
- copy_file("hephaestus_env.sample", ".env")
14
- copy_file("hephaestus_env.sample", ".env.sample")
15
- end
16
-
17
- def docker
18
- copy_file("Dockerfile", "Dockerfile")
19
- end
20
-
21
- def fly
22
- directory("vendor/fly", "vendor/fly")
23
- end
24
- end
25
- end
@@ -1,12 +0,0 @@
1
- # typed: false
2
- # frozen_string_literal: true
3
-
4
- require_relative "base"
5
-
6
- module Hephaestus
7
- class LibGenerator < Generators::Base
8
- def lib_tasks
9
- directory("lib/tasks", "lib/tasks")
10
- end
11
- end
12
- end
@@ -1,19 +0,0 @@
1
- # typed: false
2
- # frozen_string_literal: true
3
-
4
- require_relative "base"
5
-
6
- module Hephaestus
7
- class LicenseGenerator < Generators::Base
8
- def licensed
9
- copy_file(".licensed.yml", ".licensed.yml")
10
- end
11
-
12
- def generate_licenses
13
- unless run("script/licenses --update", abort_on_failure: false)
14
- say(set_color("Error generating licenses. When this is all over, run `script/licenses --update`.", :red))
15
- sleep(3)
16
- end
17
- end
18
- end
19
- end
@@ -1,18 +0,0 @@
1
- # typed: false
2
- # frozen_string_literal: true
3
-
4
- require_relative "base"
5
-
6
- module Hephaestus
7
- class RubocopGenerator < Generators::Base
8
- def rubocop
9
- copy_file(".rubocop.yml", ".rubocop.yml", force: true)
10
- end
11
-
12
- def lint
13
- Bundler.with_unbundled_env do
14
- run("bundle exec rubocop -A", abort_on_failure: false)
15
- end
16
- end
17
- end
18
- end
@@ -1,17 +0,0 @@
1
- # typed: false
2
- # frozen_string_literal: true
3
-
4
- require_relative "base"
5
-
6
- module Hephaestus
7
- class SorbetGenerator < Generators::Base
8
- def sorbet
9
- copy_file("sorbet/custom.rbi", "sorbet/custom.rbi")
10
- Bundler.with_unbundled_env do
11
- run("bundle exec tapioca init")
12
- run("bundle exec tapioca require")
13
- run("script/sorbet --update")
14
- end
15
- end
16
- end
17
- end
data/lib/version.rb DELETED
@@ -1,6 +0,0 @@
1
- # typed: false
2
- # frozen_string_literal: true
3
-
4
- module Hephaestus
5
- VERSION = "0.1.0"
6
- end
File without changes
File without changes
File without changes
File without changes