hephaestus 0.8.12.1 → 0.8.13

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 +13 -0
  3. data/README.md +1 -175
  4. data/bin/hephaestus +17 -27
  5. data/lib/hephaestus/engine.rb +2 -1
  6. data/lib/hephaestus/generators/app_generator.rb +180 -121
  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: f10ca0de88c450f5e8febca532d785bb3e0b9ae1392e84a89e5bc69822936bf4
4
+ data.tar.gz: 5558246e1b43416722c74d86f35527b39894834524bb863c9cc7380233b661c5
5
5
  SHA512:
6
- metadata.gz: 1dcf277f2074215cbf3b207d99534f5bdcf2fd6deb9ed62d6c10e3c87680da8184a30a7e5cfce6ce58e05df6173fb1d808e1fc48edb45f4f1ee4627af2bf2054
7
- data.tar.gz: 96c5fbb95236e5fe15fd538742c89010e6d9a581b2cfbf3ce70677b7412a1a48301c8f58a68521b7f0b0d45a79f253ca0f5eb31f2475049584d322c491b6214a
6
+ metadata.gz: c38a22b9ac3409157e42f26aea6b82ea3b488c984b43e18918c8d4cf12aee16ec446fad81aa0d04cecad9ad5676130e4cc0990605d8502f2131af37e3d44d152
7
+ data.tar.gz: 04aa1224bad239a6f7ef662d1f00a61ffb0a560ab882472e7afcad07f820600f7f3e6f2aa70ef639338abfa5264f6544b99e096f75f0b4922c79425a77598ed9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ # [v0.8.13] - 17-12-2024
2
+ ## What's Changed
3
+ * Move content to clio by @gjtorikian in https://github.com/yettoapp/hephaestus/pull/99
4
+ * Remove outro, point to Clio by @gjtorikian in https://github.com/yettoapp/hephaestus/pull/100
5
+
6
+
7
+ **Full Changelog**: https://github.com/yettoapp/hephaestus/compare/v0.8.12.2...v0.8.13
8
+ # [v0.8.12.2] - 17-12-2024
9
+ ## What's Changed
10
+ * Fixups by @gjtorikian in https://github.com/yettoapp/hephaestus/pull/97
11
+
12
+
13
+ **Full Changelog**: https://github.com/yettoapp/hephaestus/compare/v0.8.12.1...v0.8.12.2
1
14
  # [v0.8.12.1] - 16-12-2024
2
15
  ## What's Changed
3
16
  * general updates by @gjtorikian in https://github.com/yettoapp/hephaestus/pull/95
data/README.md CHANGED
@@ -26,187 +26,13 @@ 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.
33
33
 
34
34
  If you're having trouble connecting to the Internet, you can set `HEPHAESTUS_NO_EXTERNAL=1`.
35
35
 
36
- ## Building upon the base
37
-
38
- Most of the files which Hephaestus creates for you shouldn't need much modification. The information below is part-informative, part-guidelines on how to extend the generated code for your specific plug.
39
-
40
- ### Controllers
41
-
42
- #### `ApplicationController`
43
-
44
- Your application controller inherits from `Hephaestus::ApplicationController`, and handles the basics of request/response cycles. Two common callbacks to add here are:
45
-
46
- - `before_action :set_request_span_context`, which lets you add data to the `OpenTelemetry` trace before a request occurs
47
- - `after_action :set_response_span_context`, similarly, lets you add to the trace after the response is sent
48
-
49
- For examples on how to integrate with these, check out `plug-email`.
50
-
51
- #### `SettingsController`
52
-
53
- Typically, your settings inherit directly from Hephaestus. We'll discuss more about how this works in `routes.rb`. Either way, you'll define two files:
54
-
55
- - `app/views/settings/new.json.jbuilder`
56
- - `app/views/settings/edit.json.jbuilder`
57
-
58
- Define the settings UI in these files. See `plug-email` for an example of a settings page with no customizations.
59
-
60
- However, for multi-step plugs, it's common to expect customized steps. If you'd like to extend the settings controller, create a file with one of two methods:
61
-
62
- - `new`
63
- - `edit`
64
-
65
- You only need to define these methods if you're actually overriding the action—often, this only means `edit`. If you do define methods in this controller, remember to add `before_action :ensure_json_request` at the top. For examples on settings pages which have _some_ customization, see `plug-github` and `plug-linear`. For an example of a totally custom settings page, see `plug-zendesk`.
66
-
67
- #### `AppController`
68
-
69
- The logic to communicate with your platform sits in `AppController`. Every plug is unique, so the requirements for your platform varies!
70
-
71
- At a minimum, though, you should place all the logic which authenticates requests in the `Authable` concern. See `plug-github` and `plug-linear` for practical examples.
72
-
73
- #### `YettoController`
74
-
75
- Place the logic which receives webhooks from Yetto in the `YettoController`. This controller must `include Hephaestus::ValidatesFromYetto`, and must define `before_action :from_yetto?`. Beyond that, you can respond to events as they come in, and fire jobs to perform the actions your platform needs to integrate with Yetto.
76
-
77
- ### Jobs
78
-
79
- Jobs are at the heart of plugs, because they perform time-sensitive work asynchronously. Since Hephaestus already creates an `ApplicationJob` which inherits from `Hephaestus::ApplicationJob`, there isn't much else you need to do, other than define your jobs.
80
-
81
- Whenever you need to integrate with Yetto, just pass the appropriate arguments to `Hephaestus::UpdateYettoJob`.
82
-
83
- The bulk of your plug logic should exist within these jobs. Keep the controllers as place to authenticate incoming requests and respond with appropriate status codes.
84
-
85
- ### Constants
86
-
87
- Place any and all constants in the file called `lib/constants.rb`.
88
-
89
- Note that Hepheastus provides several convenience methods and constants for you. These are:
90
-
91
- - `plug_shortname`: the downcased version of the plug (e.g., `Slack => slack`, `GitHub => github`)
92
- - `plug_name`: The proper name of the plug (e.g., `Slack`, `GitHub`)
93
- - `plug_url`: The plug's URL (e.g., `email{.plugs.yetto.app,.plugs.yetto.dev,.ngrok.io}`)
94
-
95
- ### Application Configuration
96
-
97
- The typical Rails' environment configs (`config/environments/{development.rb,test.rb,production.rb}`) are managed by Hephaestus. However, any plug can define their own environment files as well. These are added after Hephaestus' default configuration.
98
-
99
- The `test.rb` file in `plug-email` provides an example of this.
100
-
101
- #### Upgrading Rails
102
-
103
- Upgrading Rails always introduces breaking changes, even between minor releases. To ensure that a plug still works after a Rails upgrade, first, add
104
-
105
- ```ruby
106
- rails "x"
107
- ```
108
-
109
- to your plug's Gemfile (where `"x"` is the new Rails version.) Note that this means plugs can run Rails versions independently of what Hephaestus provides (although variance is not recommended, it can help during the upgrade process).
110
-
111
- Next, call `rails app:update:configs`. You can pretty much ignore every changed file, except the one that starts with `new_framework_defaults_`. Use these values to slowly reintroduce the new configuration changes, as described in [the Rails documentation](https://guides.rubyonrails.org/v8.0/upgrading_ruby_on_rails.html#configure-framework-defaults).
112
-
113
- ### Integrating the Plug with the Engine
114
-
115
- There are certain times where the child application needs to "inject" data into Hephaestus. These are typically customizations that are unique to the plug. Place these customizations in `config/application.rb`, inside of an `initializer :engines_blank_point do` block.
116
-
117
- At a minimum, you'll need to define your plug's API version, and the version of the Yetto API it's communicating with:
118
-
119
- ```ruby
120
- initializer :engines_blank_point do
121
- config.yetto_api_version = "2023-03-06"
122
- config.plug_api_version = "2023-03-06"
123
- end
124
- ```
125
-
126
- You can also define several other customizations:
127
-
128
- - `config.tracing_body_filters`: use this to scrub out any sensitive data coming in from your platform, to prevent it from leaking in our metrics aggregator. See the override in `plug-email` for an example. The default is to simply log everything (after running it through [Rails' `ParameterFilter`](https://api.rubyonrails.org/v7.1/classes/ActiveSupport/ParameterFilter.html), of course), which may not be a good idea!
129
- - `config.enhance_update_yetto_job`: use this to include any plug-specific logic which needs to occur as part of issuing calls to the Yetto API
130
-
131
- For an example of both these customizations, see `plug-email`.
132
-
133
- There's also middleware you can use to protect any endpoint with an OpenAPI schema. To do so, add:
134
-
135
- ```ruby
136
- require "hephaestus/middleware/openapi_validation"
137
- config.middleware.use(Hephaestus::Middleware::OpenapiValidation, match_path: "/app/2023-03-06/path/", limit_methods_to: ["POST"], spec: Rails.root.join("lib/schemas/path/2023-03-06/openapi.json"))
138
- ```
139
-
140
- In this example, any `POST` to `match_path` is protected by the OpenAPI `spec` provided.
141
-
142
- ### Services
143
-
144
- Place any HTTP communication necessary to communicate with your platform in this directory. All other code should which communicates to your plug should rely on methods defined in this file.
145
-
146
- See any of the plugs for an example of how to define this interaction, particularly with `httpsensible`.
147
-
148
- ### Routes
149
-
150
- If you do not have any custom actions to perform in the settings controller, define your settings pages as:
151
-
152
- ```ruby
153
- # you must always include this line when referring to `hephaestus_settings`
154
- HephaestusSettingsController = Hephaestus::SettingsController
155
-
156
- get "/api/#{Rails.application.config.plug_api_version}/settings", to: "hephaestus_settings#new"
157
- get "/api/#{Rails.application.config.plug_api_version}/settings/:organization_id/:inbox_id/:plug_installation_id/edit", to: "hephaestus_settings#edit"
158
- ```
159
-
160
- Otherwise, be sure to refer to `hephaestus_settings` only for any default settings related actions:
161
-
162
- ```ruby
163
- # you must always include this line when referring to `hephaestus_settings`
164
- HephaestusSettingsController = Hephaestus::SettingsController
165
-
166
- get "/api/#{Rails.application.config.plug_api_version}/settings", to: "hephaestus_settings#new"
167
- get "/api/#{Rails.application.config.plug_api_version}/settings/:organization_id/:inbox_id/:plug_installation_id/edit", to: "settings#edit"
168
- ```
169
-
170
- Otherwise, you can add any other routes your plug needs to `config/routes.rb`.
171
-
172
- ### Launching the server
173
-
174
- First, you'll note that you have a `script/ngrok` file, which launches an ngrok server at `https://${hostname}-plug-app.ngrok.io`, which maps locally to `http://localhost:6661`. Setting up ngrok can be essential when testing the platform locally for the first time. (Keep in mind that you still need to run `script/server` to actually start the local server—this is just to help facilitate communication with the platform.)
175
-
176
- ### Setting up routes
177
-
178
- You should probably open up config/routes.rb to make modifications to any incoming (from the platform) or outgoing (for Yetto) HTTP flows.
179
-
180
- ### Defining settings
181
-
182
- Next, you'll want to open `app/views/settings/new.json.jbuilder` and modify the JSON structure of the Settings form page users will see when they first install the plug. Note that this adheres to a strict schema.
183
-
184
- ### Accepting events
185
-
186
- After a user submits a plug installation on the Yetto side, it'll send a POST payload to `/api/:version/:event/:record_type`--for example, `/api/2023-03-06/after/plug_installation`. Open up the `yetto_controller.rb` file and decide what happens next!
187
-
188
- ### Creating services
189
-
190
- Any code which communicates with the third party should be placed in the `app/services` directory. A generic HTTP service is included.
191
-
192
- ### Writing tests
193
-
194
- In addition to writing tests for your plug interacting with its platform, many of your tests will also need to cover your plug's interaction with Yetto.
195
-
196
- Writing these tests well comes with time; it's not an easy thing to cover in a pithy paragraph. Regardless, here's a bit of hopefully helpful advice.
197
-
198
- Be sure to tests requests before _and_ after they occur. Typically, this takes the form of a `stub_request` and `assert_requested`. Similarly, be sure to:
199
-
200
- - `include Hephaestus::Webmocks::SlackWebmock` whenever a plug action is expected to error out to Slack
201
- - `include Hephaestus::Webmocks::YettoWebmock` whenever a plug needs to issue a request to Yetto
202
-
203
- Use `include Hephaestus::API::TestHelpers` whenever you need to write a test which either
204
-
205
- - match `"/#{plug_shortname}` routes (by issuing calls to `plug`). These are routes which your external server is calling into.
206
- - match `/api` routes (by issuing calls to `api`). These are routes which Yetto is calling into.
207
-
208
- For examples on when and how to use these methods, see `plug-github`.
209
-
210
36
  ## Acknowledgements
211
37
 
212
38
  The template generation for this project was heavily based on [thoughtbot/suspenders](https://github.com/thoughtbot/suspenders).
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,145 +97,161 @@ 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
196
248
  say(<<~OUTPUT)
197
249
 
198
- #{set_color("Congratulations!", :green)} You just made a Yetto plug.
199
-
200
- You'll need to `cd #{ARGV.first}` and run the following commands--I can't do it for you!
201
-
202
- * `bin/rails credentials:edit --environment development`
203
-
204
- #{set_color("WAIT!", :red)} After running this command, note that Rails credited a file called development.key in the config/credentials directory.
205
- Store this in 1Password, then change the .env file to use this value. Generate keys for staging/production, too:
206
-
207
- * `bin/rails credentials:edit --environment staging`
208
- `bin/rails credentials:edit --environment production`
250
+ #{set_color("Congratulations! You just made a Yetto plug.", :green)}
209
251
 
210
- Store this in 1Password too; you don't need the .env file for staging/production.
252
+ You'll need to `cd #{shell.base.result_dir}` and run some more commands--I can't do it for you!
211
253
 
212
- For `YETTO_SIGNING_SECRET` and `YETTO_PLUG_ID`, you'll need to generate those values yourself.
213
-
214
- Then, try running `bin/rails c` to ensure that everything was set up correctly.
215
- Running `rake test` is also a good idea.
216
-
217
- #{set_color("Also, after pushing to GitHub:", :yellow)}
218
-
219
- * Set `settings/branches` to protect `production`
220
- * ✅ Require status checks to pass before merging
221
- * 🖊️ Status checks that are required: `ruby / test_without_services`, `docker / test-build`, `ruby / brakeman`, `ruby / bundle-audit`.
222
-
223
- You can only set those 👆 after you've opened the first PR on GitHub. Crazy, I know!!
224
- But, doing so is *essential* for automerge to function properly.
225
-
226
- * In `/settings`:
227
- * ✅ Allow auto-merge
228
- * ✅ Automatically delete head branches
254
+ Check out the appropriate documentation on Clio for more information: engineering/plugs/building.md
229
255
  OUTPUT
230
256
  end
231
257
 
@@ -245,13 +271,46 @@ module Hephaestus
245
271
  !options[:skip_active_record]
246
272
  end
247
273
 
248
- private def capture_stdout
249
- out = StringIO.new
250
- $stdout = out
274
+ private def capture_stdout(&block)
275
+ capture_stream("stdout", &block)
276
+ end
277
+
278
+ private def capture_stderr(&block)
279
+ capture_stream("stderr", &block)
280
+ end
281
+
282
+ private def capture_stream(stream)
283
+ captured_stream = Tempfile.new(stream)
284
+ stream_io = eval("$#{stream}", binding, __FILE__, __LINE__) # rubocop:disable Security/Eval
285
+ origin_stream = stream_io.dup
286
+ stream_io.reopen(captured_stream)
287
+
251
288
  yield
252
- out.string
253
- ensure
254
- $stdout = STDOUT
289
+
290
+ stream_io.rewind
291
+ captured_stream.read
292
+
293
+ unless captured_stream.nil?
294
+ captured_stream.close
295
+ captured_stream.unlink
296
+ end
297
+ stream_io.reopen(origin_stream) unless stream_io.nil?
298
+ end
299
+
300
+ private def chmod_dir(dir)
301
+ Dir.glob(File.join(destination_root, dir, "**", "*")).each do |file|
302
+ next if File.directory?(file)
303
+
304
+ # Rails adds this
305
+ if file == ".keep"
306
+ remove_file(file)
307
+ next
308
+ end
309
+
310
+ # this is because we might have *.tt templates, which aren't executable,
311
+ # so we gotta re-execute-em all
312
+ chmod(file, 0o755)
313
+ end
255
314
  end
256
315
  end
257
316
  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.13"
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.13
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-18 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