hephaestus 0.8.12.2 → 0.8.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/README.md +0 -174
  4. data/bin/hephaestus +9 -1
  5. data/lib/hephaestus/app_name.rb +4 -4
  6. data/lib/hephaestus/generators/app_generator.rb +22 -39
  7. data/lib/hephaestus/version.rb +1 -1
  8. data/{templates/script → script}/edit-credentials +3 -3
  9. data/script/setup-vault +29 -0
  10. data/script/vault.json +68 -0
  11. data/templates/app/controllers/concerns/authable.rb.tt +0 -1
  12. data/templates/app/jobs/application_job.rb +3 -6
  13. data/templates/config/locales/en.yml.tt +5 -0
  14. data/templates/config/locales/settings/en.yml.tt +6 -0
  15. data/templates/root/Procfile +1 -0
  16. data/templates/root/README.md.tt +4 -0
  17. data/templates/root/Rakefile +8 -0
  18. metadata +8 -16
  19. data/templates/config/locales/en.yml +0 -6
  20. data/templates/config/locales/settings/en.yml +0 -5
  21. data/templates/lib/plug_app/schemas/api/2023-03-06/components/parameters/headers/yetto.json +0 -42
  22. data/templates/lib/plug_app/schemas/api/2023-03-06/components/parameters/plugInstallation.json +0 -12
  23. data/templates/lib/plug_app/schemas/api/2023-03-06/components/schemas/plug.json +0 -9
  24. data/templates/lib/plug_app/schemas/api/2023-03-06/components/schemas/responses.json +0 -64
  25. data/templates/lib/plug_app/schemas/api/2023-03-06/components/schemas/yetto.json +0 -116
  26. data/templates/lib/plug_app/schemas/api/2023-03-06/openapi.json +0 -30
  27. data/templates/lib/plug_app/schemas/api/2023-03-06/paths/plug.json +0 -90
  28. data/templates/lib/plug_app/schemas/api/2023-03-06/paths/yetto/message_created.json +0 -51
  29. data/templates/lib/plug_app/schemas/api/2023-03-06/paths/yetto/plug_installation_created.json +0 -51
  30. data/templates/script/ci +0 -7
  31. data/templates/script/test +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 946513d5bfb959191872e0404f6eb0c95c4a6d4ded918425926ba0ca24f09dce
4
- data.tar.gz: 0524cf36eb6e3717eb1c1b7fab0de51438cbce348b0882a77e50422d5c25747a
3
+ metadata.gz: c6f1564007f86900d81b992b6df2f93428859cb5a8c6c22a15a5cef29eb7d198
4
+ data.tar.gz: bd340377613e44ea895a03871835863cc059cd740c9800c64e56e19b481ecc4a
5
5
  SHA512:
6
- metadata.gz: 15f88a25cfea5f83d2fb5ac629d163ab2d8b1205bc3b5a99cf38282b8628cac6da86a31f68c99e4e9eb0511e6a5f270ce562aada76e76db9eebf31a2f25073aa
7
- data.tar.gz: 4271659d3c4302dcfa5cb991b8b9c01f20a8d2e8d13b3b554cfea8a79417117ee86ee2228188984bc1a78b7f42e5a81325386ebade0714c32dd14a7d8a5168c0
6
+ metadata.gz: 4b1399f84f3bb750c0b8de78a729d3e2b47c43bfb8abf5d6f611928162dd2a9c61b7044a39c4348626e2ff819f0eb9b4ff0e67f6dcb78a3c318616a3b42e452c
7
+ data.tar.gz: 855af63634afe1b2e6a6cb1af37358270f7508c2e8720426c512f0abb7c8b6e6b7eeae661b8237149906c3f86e806e08aeb53b7896f9eaff50c11b5ce4720d20
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ # [v0.8.14] - 19-12-2024
2
+ ## What's Changed
3
+ * Add scripting logic to Hephaestus by @gjtorikian in https://github.com/yettoapp/hephaestus/pull/102
4
+
5
+
6
+ **Full Changelog**: https://github.com/yettoapp/hephaestus/compare/v0.8.13...v0.8.14
7
+ # [v0.8.13] - 17-12-2024
8
+ ## What's Changed
9
+ * Move content to clio by @gjtorikian in https://github.com/yettoapp/hephaestus/pull/99
10
+ * Remove outro, point to Clio by @gjtorikian in https://github.com/yettoapp/hephaestus/pull/100
11
+
12
+
13
+ **Full Changelog**: https://github.com/yettoapp/hephaestus/compare/v0.8.12.2...v0.8.13
1
14
  # [v0.8.12.2] - 17-12-2024
2
15
  ## What's Changed
3
16
  * Fixups by @gjtorikian in https://github.com/yettoapp/hephaestus/pull/97
data/README.md CHANGED
@@ -33,180 +33,6 @@ 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
@@ -97,4 +97,12 @@ config.keys.each do |key|
97
97
  config.delete(key) if delete_keys
98
98
  end
99
99
 
100
- Hephaestus::AppGenerator.start
100
+
101
+ case ARGV[0]
102
+ when "run"
103
+ ENV["HEPHAESTUS_CAPITAL_PLUG_NAME"] = `grep 'module Plug\S*' config/application.rb | sed -E 's/module Plug//'`.strip
104
+ script_dir = File.join(ENGINE_ROOT, "script")
105
+ puts `#{File.join(script_dir, ARGV[1..-1].join(' '))}`
106
+ else
107
+ Hephaestus::AppGenerator.start
108
+ end
@@ -10,22 +10,22 @@ module Hephaestus
10
10
  "plug-#{Rails.application.class.module_parent.name.underscore[5..-1]}"
11
11
  end
12
12
 
13
- # like, `slack`
13
+ # like, `slack`, github, or `html_proofer`
14
14
  def plug_name
15
15
  app_name.split("-", 2).last
16
16
  end
17
17
 
18
- # like, `Slack`, or `html_proofer => HtmlProofer`
18
+ # like, `Slack`, `GitHub`, or `html_proofer
19
19
  def capital_plug_name
20
20
  plug_name.camelcase
21
21
  end
22
22
 
23
- # like, `SLACK`
23
+ # like, `SLACK` `GITHUB`, or `HTML_PROOFER`
24
24
  def upcase_plug_name
25
25
  plug_name.upcase
26
26
  end
27
27
 
28
- # like, `slack`, or `HTMLProofer => html_proofer``
28
+ # like, `slack`, `github`, or `html_proofer`
29
29
  def underscore_plug_name
30
30
  plug_name.underscore
31
31
  end
@@ -142,7 +142,7 @@ module Hephaestus
142
142
  directory(source, "test", force: true)
143
143
 
144
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.
145
+ # and the OpenAPI middleware, which is loaded when the app boots, requires the lib/schemas files to be present.
146
146
  directory("lib/schemas/api/2023-03-06", "lib/schemas/api/2023-03-06")
147
147
 
148
148
  # we do this to specify the template source, otherwise the generator wants to use Rails own `bin` dir
@@ -151,7 +151,7 @@ module Hephaestus
151
151
  chmod_dir("bin")
152
152
 
153
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|
154
+ ["controllers", "jobs", "lib", "services", "views"].each do |dir|
155
155
  source = File.join(Hephaestus::Engine.root, "templates", "app", dir)
156
156
  directory(source, "app/#{dir}", force: true)
157
157
  end
@@ -182,7 +182,9 @@ module Hephaestus
182
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"))
183
183
 
184
184
  Dir.chdir(shell.base.result_dir) do
185
- unless ENV.fetch("HEPHAESTUS_NO_EXTERNAL", "0") == "1"
185
+ if ENV.fetch("HEPHAESTUS_NO_EXTERNAL", "0") == "1"
186
+ say(set_color("Not installing gems...", :yellow))
187
+ else
186
188
  say(set_color("Installing gems...", :cyan))
187
189
  capture_stdout do
188
190
  run("bundle install", abort_on_failure: false)
@@ -232,52 +234,33 @@ module Hephaestus
232
234
  def first_commit
233
235
  say(set_color("Creating first commit...", :cyan))
234
236
 
237
+ result = nil
235
238
  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")
239
+ # capture_stdout do
240
+ run("git init")
241
+ run("git branch -m production")
240
242
 
241
- run("git add .")
242
- run("git commit -m 'Initial commit'", capture: true)
243
- end
243
+ run("git add .")
244
+ run("git commit -m 'Initial commit'", capture: true)
245
+
246
+ result = run("gh repo create yettoapp/#{app_name} --private --source . --push")
247
+ # end
248
+ end
249
+
250
+ unless result
251
+ say(set_color("Could not create repository on GitHub! Do you have the `gh` cli installed? ", :red))
252
+ sleep(3)
244
253
  end
245
254
  end
246
255
 
247
256
  def outro
248
257
  say(<<~OUTPUT)
249
258
 
250
- #{set_color("Congratulations!", :green)} You just made a Yetto plug.
251
-
252
- You'll need to `cd #{ARGV.first}` and run the following commands--I can't do it for you!
253
-
254
- * `bin/rails credentials:edit --environment development`
255
-
256
- #{set_color("WAIT!", :red)} After running this command, note that Rails credited a file called development.key in the config/credentials directory.
257
- Store this in 1Password, then change the .env file to use this value. Generate keys for staging/production, too:
258
-
259
- * `bin/rails credentials:edit --environment staging`
260
- `bin/rails credentials:edit --environment production`
261
-
262
- Store this in 1Password too; you don't need the .env file for staging/production.
263
-
264
- For `YETTO_SIGNING_SECRET` and `YETTO_PLUG_ID`, you'll need to generate those values yourself.
265
-
266
- Then, try running `bin/rails c` to ensure that everything was set up correctly.
267
- Running `rake test` is also a good idea.
268
-
269
- #{set_color("Also, after pushing to GitHub:", :yellow)}
270
-
271
- * Set `settings/branches` to protect `production`
272
- * ✅ Require status checks to pass before merging
273
- * 🖊️ Status checks that are required: `ruby / test_without_services`, `docker / test-build`, `ruby / brakeman`, `ruby / bundle-audit`.
259
+ #{set_color("Congratulations! You just made a Yetto plug.", :green)}
274
260
 
275
- You can only set those 👆 after you've opened the first PR on GitHub. Crazy, I know!!
276
- But, doing so is *essential* for automerge to function properly.
261
+ You'll need to `cd #{shell.base.result_dir}` and run some more commands--I can't do it for you!
277
262
 
278
- * In `/settings`:
279
- * ✅ Allow auto-merge
280
- * ✅ Automatically delete head branches
263
+ Check out the appropriate documentation on Clio for more information: engineering/plugs/building.md
281
264
  OUTPUT
282
265
  end
283
266
 
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Hephaestus
5
- VERSION = "0.8.12.2"
5
+ VERSION = "0.8.14"
6
6
  RAILS_VERSION = ">= 8.0"
7
7
  RUBY_VERSION = File
8
8
  .read("#{File.dirname(__FILE__)}/../../.ruby-version")
@@ -27,11 +27,11 @@ do
27
27
  done
28
28
 
29
29
  if [[ $development == true ]]; then
30
- RAILS_MASTER_KEY=$(op read "op://Plug-Email/Development Secrets/Common/RAILS_MASTER_KEY") bin/rails credentials:edit -e development
30
+ RAILS_MASTER_KEY=$(op read "op://Plug-$HEPHAESTUS_CAPITAL_PLUG_NAME/Development Secrets/Common/RAILS_MASTER_KEY") bin/rails credentials:edit -e development
31
31
  elif [[ $staging == true ]]; then
32
- RAILS_MASTER_KEY=$(op read "op://Plug-Email/Staging Secrets/Common/RAILS_MASTER_KEY") bin/rails credentials:edit -e staging
32
+ RAILS_MASTER_KEY=$(op read "op://Plug-$HEPHAESTUS_CAPITAL_PLUG_NAME/Staging Secrets/Common/RAILS_MASTER_KEY") bin/rails credentials:edit -e staging
33
33
  elif [[ $production == true ]]; then
34
- RAILS_MASTER_KEY=$(op read "op://Plug-Email/Production Secrets/Common/RAILS_MASTER_KEY") bin/rails credentials:edit -e production
34
+ RAILS_MASTER_KEY=$(op read "op://Plug-$HEPHAESTUS_CAPITAL_PLUG_NAME/Production Secrets/Common/RAILS_MASTER_KEY") bin/rails credentials:edit -e production
35
35
  else
36
36
  echo "Please specify a target environment with one of the following flags: --development, --staging, --production"
37
37
  exit 1
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+
6
+ # Get the current file location and its parent directory
7
+ current_file_location=$(realpath "$0")
8
+ parent_dir=$(dirname "$current_file_location")
9
+
10
+ vault_name="Plug-$HEPHAESTUS_CAPITAL_PLUG_NAME"
11
+ op vault create "$vault_name"
12
+
13
+ op item create \
14
+ --template="$parent_dir/vault.json" \
15
+ --vault "$vault_name" \
16
+ --title "Development secrets" \
17
+ --tags 'development'
18
+
19
+ op item create \
20
+ --template="$parent_dir/vault.json" \
21
+ --vault "$vault_name" \
22
+ --title "Staging secrets" \
23
+ --tags 'staging'
24
+
25
+ op item create \
26
+ --template="$parent_dir/vault.json" \
27
+ --vault "$vault_name" \
28
+ --title "Production secrets" \
29
+ --tags 'production'
data/script/vault.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "title": "",
3
+ "vault": {
4
+ "name": ""
5
+ },
6
+ "category": "SECURE_NOTE",
7
+ "sections": [
8
+ {
9
+ "id": "Yetto",
10
+ "label": "Yetto"
11
+ },
12
+ {
13
+ "id": "Unique",
14
+ "label": "Unique"
15
+ },
16
+ {
17
+ "id": "Common",
18
+ "label": "Common"
19
+ }
20
+ ],
21
+ "fields": [
22
+ {
23
+ "id": "YETTO_SIGNING_SECRET",
24
+ "section": {
25
+ "id": "Yetto"
26
+ },
27
+ "type": "CONCEALED",
28
+ "label": "YETTO_SIGNING_SECRET",
29
+ "value": "xxx"
30
+ },
31
+ {
32
+ "id": "YETTO_PLUG_PEM",
33
+ "section": {
34
+ "id": "Yetto"
35
+ },
36
+ "type": "CONCEALED",
37
+ "label": "YETTO_PLUG_PEM",
38
+ "value": "xxx"
39
+ },
40
+ {
41
+ "id": "YETTO_PLUG_ID",
42
+ "section": {
43
+ "id": "Yetto"
44
+ },
45
+ "type": "CONCEALED",
46
+ "label": "YETTO_PLUG_ID",
47
+ "value": "xxx"
48
+ },
49
+ {
50
+ "id": "NONCE",
51
+ "section": {
52
+ "id": "Unique"
53
+ },
54
+ "type": "CONCEALED",
55
+ "label": "NONCE",
56
+ "value": "xxx"
57
+ },
58
+ {
59
+ "id": "RAILS_MASTER_KEY",
60
+ "section": {
61
+ "id": "Common"
62
+ },
63
+ "type": "CONCEALED",
64
+ "label": "RAILS_MASTER_KEY",
65
+ "value": "xxx"
66
+ }
67
+ ]
68
+ }
@@ -15,7 +15,6 @@ module Authable
15
15
  sig { void }
16
16
  def <%= plug_name %>_calling_back?
17
17
  state = params.fetch(:state, "")
18
- state = params.fetch(:state, "")
19
18
 
20
19
  state_obj = parse_state(state)
21
20
  nonce = state_obj.fetch(:nonce, "")
@@ -1,10 +1,7 @@
1
1
  # typed: false
2
2
  # frozen_string_literal: true
3
3
 
4
- class ApplicationJob < ActiveJob::Base
5
- # Automatically retry jobs that encountered a deadlock
6
- # retry_on ActiveRecord::Deadlocked
7
-
8
- # Most jobs are safe to ignore if the underlying records are no longer available
9
- # discard_on ActiveJob::DeserializationError
4
+ class ApplicationJob < Hephaestus::ApplicationJob
5
+ # TODO: Add whatever configuration you need here;
6
+ # note that Hephaestus sets some defaults for you already.
10
7
  end
@@ -0,0 +1,5 @@
1
+ # Files in the config/locales directory are used for internationalization and
2
+ # are automatically loaded by Rails. If you want to use locales other than
3
+ # English, add the necessary files in this directory.
4
+
5
+ en:
@@ -0,0 +1,6 @@
1
+ en:
2
+ new_step_one_heading: "Before you continue..."
3
+ new_step_one_text: "This plug will ask you if the Yetto app can authorize with your <%= capital_plug_name %> account. Make sure you're an admin who is able to install apps."
4
+ new_step_two_heading: "Authenticate with Yetto's <%= capital_plug_name %> app"
5
+ new_step_two_text: "This will connect our <%= capital_plug_name %> app with your Yetto org"
6
+ new_step_two_oauth_button: "Click to auth with <%= capital_plug_name %>"
@@ -1,2 +1,3 @@
1
1
  web: $SERVER_CMD # defined in script/server
2
2
  supervisor: bin/jobs -c "$(bundle show hephaestus)/config/queue.yml"
3
+ ngrok: script/ngrok
@@ -1 +1,5 @@
1
1
  # <%= app_name.titlecase %>
2
+
3
+ Start your server with `script/server`, or `script/server --debug` to enable debugging.
4
+
5
+ Your plug is available at `${hostname}-plug-<%= plug_name %>.ngrok.io:6661`.
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
4
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
5
+
6
+ require_relative "config/application"
7
+
8
+ Rails.application.load_tasks
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.2
4
+ version: 0.8.14
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-17 00:00:00.000000000 Z
11
+ date: 2024-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootsnap
@@ -445,6 +445,9 @@ files:
445
445
  - lib/hephaestus/version.rb
446
446
  - lib/tasks/hephaestus_tasks.rake
447
447
  - lib/tasks/rubocop.rake
448
+ - script/edit-credentials
449
+ - script/setup-vault
450
+ - script/vault.json
448
451
  - templates/app/controllers/app_controller.rb.tt
449
452
  - templates/app/controllers/application_controller.rb
450
453
  - templates/app/controllers/concerns/authable.rb.tt
@@ -470,8 +473,8 @@ files:
470
473
  - templates/config/environment.rb
471
474
  - templates/config/environments/blank.rb
472
475
  - templates/config/initializers/environment.rb
473
- - templates/config/locales/en.yml
474
- - templates/config/locales/settings/en.yml
476
+ - templates/config/locales/en.yml.tt
477
+ - templates/config/locales/settings/en.yml.tt
475
478
  - templates/config/puma.rb
476
479
  - templates/config/routes.rb.tt
477
480
  - templates/db/queue_schema.rb
@@ -488,15 +491,6 @@ files:
488
491
  - templates/hephaestus_vscode/extensions.json
489
492
  - templates/hephaestus_vscode/launch.json
490
493
  - templates/hephaestus_vscode/settings.json
491
- - templates/lib/plug_app/schemas/api/2023-03-06/components/parameters/headers/yetto.json
492
- - templates/lib/plug_app/schemas/api/2023-03-06/components/parameters/plugInstallation.json
493
- - templates/lib/plug_app/schemas/api/2023-03-06/components/schemas/plug.json
494
- - templates/lib/plug_app/schemas/api/2023-03-06/components/schemas/responses.json
495
- - templates/lib/plug_app/schemas/api/2023-03-06/components/schemas/yetto.json
496
- - templates/lib/plug_app/schemas/api/2023-03-06/openapi.json
497
- - templates/lib/plug_app/schemas/api/2023-03-06/paths/plug.json
498
- - templates/lib/plug_app/schemas/api/2023-03-06/paths/yetto/message_created.json
499
- - templates/lib/plug_app/schemas/api/2023-03-06/paths/yetto/plug_installation_created.json
500
494
  - templates/lib/schemas/api/2023-03-06/components/parameters/headers/yetto.json
501
495
  - templates/lib/schemas/api/2023-03-06/components/parameters/plugInstallation.json
502
496
  - templates/lib/schemas/api/2023-03-06/components/schemas/plug.json
@@ -511,6 +505,7 @@ files:
511
505
  - templates/root/Gemfile
512
506
  - templates/root/Procfile
513
507
  - templates/root/README.md.tt
508
+ - templates/root/Rakefile
514
509
  - templates/root/compose.yml
515
510
  - templates/root/config.ru
516
511
  - templates/root/hephaestus_dockerignore
@@ -520,16 +515,13 @@ files:
520
515
  - templates/root/hephaestus_licensed.yml
521
516
  - templates/root/hephaestus_rubocop.yml
522
517
  - templates/root/hephaestus_ruby-version
523
- - templates/script/ci
524
518
  - templates/script/docker-build-prod.tt
525
519
  - templates/script/docker-run.tt
526
- - templates/script/edit-credentials
527
520
  - templates/script/hmac_text
528
521
  - templates/script/licenses
529
522
  - templates/script/ngrok.tt
530
523
  - templates/script/server
531
524
  - templates/script/sorbet
532
- - templates/script/test
533
525
  - templates/sorbet/custom.rbi
534
526
  - templates/test/controllers/app_controller_test.rb.tt
535
527
  - templates/test/controllers/application_controller_test.rb
@@ -1,6 +0,0 @@
1
- en:
2
- new_step_one_heading: "Before you continue..."
3
- new_step_one_text: "This plug can only be installed"
4
- new_step_two_heading: "Authenticate"
5
- new_step_two_text: "This will connect your previously installed app with your Yetto org"
6
- new_step_two_oauth_button: "Click to auth with"
@@ -1,5 +0,0 @@
1
- en:
2
- some_example_heading: "From name"
3
- some_example_label: "Some example"
4
- another_example_heading: "Reply-to email address"
5
- another_example_label: "Another example"
@@ -1,42 +0,0 @@
1
- {
2
- "Event": {
3
- "name": "X-Yetto-Event",
4
- "in": "header",
5
- "description": "The event from Yetto",
6
- "required": true,
7
- "schema": {
8
- "type": "string",
9
- "pattern": "^{created|updated|destroyed}$"
10
- }
11
- },
12
- "RecordType": {
13
- "name": "X-Yetto-RecordType",
14
- "in": "header",
15
- "description": "The record type from Yetto",
16
- "required": true,
17
- "schema": {
18
- "type": "string",
19
- "pattern": "^[a-z_]+$"
20
- }
21
- },
22
- "DeliveryID": {
23
- "name": "X-Yetto-DeliveryID",
24
- "in": "header",
25
- "description": "The delivery ID from Yetto",
26
- "required": true,
27
- "schema": {
28
- "type": "string",
29
- "pattern": "^[a-z0-9-]+$"
30
- }
31
- },
32
- "Signature": {
33
- "name": "X-Yetto-Signature",
34
- "in": "header",
35
- "description": "The signature from Yetto",
36
- "required": true,
37
- "schema": {
38
- "type": "string",
39
- "pattern": "^sha256=[a-f0-9]{64}$"
40
- }
41
- }
42
- }
@@ -1,12 +0,0 @@
1
- {
2
- "plugInstallationId": {
3
- "name": "plugInstallationId",
4
- "in": "path",
5
- "description": "The plug installation's unique ID",
6
- "required": true,
7
- "schema": {
8
- "type": "string",
9
- "pattern": "^pli_[A-Z0-9]{26}$"
10
- }
11
- }
12
- }
@@ -1,9 +0,0 @@
1
- {
2
- "InboundWebhook": {
3
- "type": "object",
4
- "required": [
5
- "From"
6
- ],
7
- "properties": {}
8
- }
9
- }
@@ -1,64 +0,0 @@
1
- {
2
- "202": {
3
- "type": "object",
4
- "required": [
5
- "message"
6
- ],
7
- "properties": {
8
- "message": {
9
- "type": "string",
10
- "value": "Accepted"
11
- }
12
- }
13
- },
14
- "204": {
15
- "type": "object",
16
- "required": [
17
- "message"
18
- ],
19
- "properties": {
20
- "message": {
21
- "type": "string",
22
- "value": "No Content"
23
- }
24
- }
25
- },
26
- "400": {
27
- "type": "object",
28
- "required": [
29
- "errors"
30
- ],
31
- "properties": {
32
- "errors": {
33
- "type": "array",
34
- "items": {
35
- "type": "object",
36
- "properties": {
37
- "message": {
38
- "type": "string"
39
- }
40
- }
41
- }
42
- }
43
- }
44
- },
45
- "404": {
46
- "type": "object",
47
- "required": [
48
- "errors"
49
- ],
50
- "properties": {
51
- "errors": {
52
- "type": "array",
53
- "items": {
54
- "type": "object",
55
- "properties": {
56
- "message": {
57
- "type": "string"
58
- }
59
- }
60
- }
61
- }
62
- }
63
- }
64
- }
@@ -1,116 +0,0 @@
1
- {
2
- "CreateAppMessage": {
3
- "type": "object",
4
- "required": [
5
- "yetto"
6
- ],
7
- "properties": {
8
- "yetto": {
9
- "type": "object",
10
- "required": [
11
- "plug_installation",
12
- "message"
13
- ],
14
- "properties": {
15
- "plug_installation": {
16
- "type": "object",
17
- "required": [
18
- "id",
19
- "settings"
20
- ],
21
- "properties": {
22
- "id": {
23
- "type": "string",
24
- "pattern": "^(?:pli)_[A-Z0-9]{26}$"
25
- },
26
- "settings": {
27
- "type": "object",
28
- "required": [],
29
- "properties": {}
30
- }
31
- }
32
- },
33
- "message": {
34
- "type": "object",
35
- "required": [
36
- "id",
37
- "conversation",
38
- "text_content",
39
- "metadata"
40
- ],
41
- "properties": {
42
- "id": {
43
- "type": "string",
44
- "pattern": "^(?:msg)_[A-Z0-9]{26}$"
45
- },
46
- "text_content": {
47
- "type": "string"
48
- },
49
- "metadata": {
50
- "type": "object"
51
- },
52
- "conversation": {
53
- "type": "object",
54
- "required": [
55
- "id",
56
- "title",
57
- "metadata"
58
- ],
59
- "properties": {
60
- "id": {
61
- "type": "string",
62
- "pattern": "^(?:cnv)_[A-Z0-9]{26}$"
63
- },
64
- "title": {
65
- "type": "string"
66
- },
67
- "metadata": {
68
- "type": "object"
69
- }
70
- }
71
- }
72
- }
73
- }
74
- },
75
- "additionalProperties": false
76
- }
77
- },
78
- "additionalProperties": false
79
- },
80
- "ConfigureApp": {
81
- "type": "object",
82
- "required": [
83
- "yetto"
84
- ],
85
- "properties": {
86
- "yetto": {
87
- "type": "object",
88
- "required": [
89
- "plug_installation",
90
- ],
91
- "properties": {
92
- "plug_installation": {
93
- "type": "object",
94
- "required": [
95
- "id",
96
- "settings"
97
- ],
98
- "properties": {
99
- "id": {
100
- "type": "string",
101
- "pattern": "^(?:pli)_[A-Z0-9]{26}$"
102
- },
103
- "settings": {
104
- "type": "object",
105
- "required": [],
106
- "properties": {}
107
- }
108
- }
109
- }
110
- },
111
- "additionalProperties": false
112
- }
113
- },
114
- "additionalProperties": false
115
- }
116
- }
@@ -1,30 +0,0 @@
1
- {
2
- "openapi": "3.0.0",
3
- "info": {
4
- "title": "App Plug API",
5
- "description": "An OpenAPI definition for the App Plug REST API.",
6
- "version": "2023-03-06",
7
- "termsOfService": "https://yetto.app/terms/",
8
- "license": {
9
- "name": "Apache 2.0",
10
- "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
11
- }
12
- },
13
- "servers": [
14
- {
15
- "url": "https://yetto.app/2023-03-06",
16
- "description": "Production basepath"
17
- }
18
- ],
19
- "paths": {
20
- "/api/2023-03-06/plug_installation/created": {
21
- "$ref": "paths/yetto/plug_installation_created.json"
22
- },
23
- "/api/2023-03-06/message/created": {
24
- "$ref": "paths/yetto/message_created.json"
25
- },
26
- "/app/2023-03-06/{plugInstallationId}": {
27
- "$ref": "paths/app.json"
28
- }
29
- }
30
- }
@@ -1,90 +0,0 @@
1
- {
2
- "post": {
3
- "tags": [
4
- "Inbound",
5
- "App"
6
- ],
7
- "description": "This represents something",
8
- "operationId": "Post a Yetto message",
9
- "parameters": [
10
- {
11
- "$ref": "../components/parameters/plugInstallation.json#/plugInstallationId"
12
- }
13
- ],
14
- "requestBody": {
15
- "required": true,
16
- "content": {
17
- "application/json": {
18
- "schema": {
19
- "$ref": "../components/schemas/plug.json#/something"
20
- }
21
- },
22
- "example": {
23
- "message": {
24
- "text_content": "Hello _World_",
25
- "is_public": true,
26
- "author": {
27
- "name": "John Doe"
28
- },
29
- "metadata": {}
30
- },
31
- "creator": {
32
- "id": "usr_1234567890"
33
- }
34
- }
35
- }
36
- },
37
- "responses": {
38
- "202": {
39
- "description": "Accepted",
40
- "content": {
41
- "application/json": {
42
- "schema": {
43
- "$ref": "../components/schemas/responses.json#/202"
44
- }
45
- }
46
- }
47
- },
48
- "204": {
49
- "description": "No Content",
50
- "content": {
51
- "application/json": {
52
- "schema": {
53
- "$ref": "../components/schemas/responses.json#/204"
54
- }
55
- }
56
- }
57
- },
58
- "400": {
59
- "description": "Bad Request",
60
- "content": {
61
- "application/json": {
62
- "schema": {
63
- "$ref": "../components/schemas/responses.json#/400"
64
- }
65
- }
66
- }
67
- },
68
- "403": {
69
- "description": "Forbidden",
70
- "content": {
71
- "application/json": {
72
- "schema": {
73
- "$ref": "../components/schemas/responses.json#/403"
74
- }
75
- }
76
- }
77
- },
78
- "503": {
79
- "description": "Service Unavailable",
80
- "content": {
81
- "application/json": {
82
- "schema": {
83
- "$ref": "../components/schemas/responses.json#/502"
84
- }
85
- }
86
- }
87
- }
88
- }
89
- }
90
- }
@@ -1,51 +0,0 @@
1
- {
2
- "post": {
3
- "tags": [
4
- "Yetto"
5
- ],
6
- "description": "After a message is created in Yetto, this delivers it.",
7
- "operationId": "Create a new message",
8
- "requestBody": {
9
- "required": true,
10
- "content": {
11
- "application/json": {
12
- "schema": {
13
- "$ref": "../../components/schemas/yetto.json#/CreateAppMessage"
14
- }
15
- }
16
- }
17
- },
18
- "responses": {
19
- "204": {
20
- "description": "No Content",
21
- "content": {
22
- "application/json": {
23
- "schema": {
24
- "$ref": "../../components/schemas/responses.json#/204"
25
- }
26
- }
27
- }
28
- },
29
- "400": {
30
- "description": "Bad Request",
31
- "content": {
32
- "application/json": {
33
- "schema": {
34
- "$ref": "../../components/schemas/responses.json#/400"
35
- }
36
- }
37
- }
38
- },
39
- "404": {
40
- "description": "Not Found",
41
- "content": {
42
- "application/json": {
43
- "schema": {
44
- "$ref": "../../components/schemas/responses.json#/404"
45
- }
46
- }
47
- }
48
- }
49
- }
50
- }
51
- }
@@ -1,51 +0,0 @@
1
- {
2
- "post": {
3
- "tags": [
4
- "Yetto"
5
- ],
6
- "description": "After a plug installation is created, this executes",
7
- "operationId": "Post a plug installation",
8
- "requestBody": {
9
- "required": true,
10
- "content": {
11
- "application/json": {
12
- "schema": {
13
- "$ref": "../../components/schemas/yetto.json#/ConfigureApp"
14
- }
15
- }
16
- }
17
- },
18
- "responses": {
19
- "204": {
20
- "description": "No Content",
21
- "content": {
22
- "application/json": {
23
- "schema": {
24
- "$ref": "../../components/schemas/responses.json#/204"
25
- }
26
- }
27
- }
28
- },
29
- "400": {
30
- "description": "Bad Request",
31
- "content": {
32
- "application/json": {
33
- "schema": {
34
- "$ref": "../../components/schemas/responses.json#/400"
35
- }
36
- }
37
- }
38
- },
39
- "404": {
40
- "description": "Not Found",
41
- "content": {
42
- "application/json": {
43
- "schema": {
44
- "$ref": "../../components/schemas/responses.json#/404"
45
- }
46
- }
47
- }
48
- }
49
- }
50
- }
51
- }
data/templates/script/ci DELETED
@@ -1,7 +0,0 @@
1
- #!/bin/sh
2
-
3
- set -e
4
-
5
- export CI=true
6
-
7
- script/test
@@ -1,5 +0,0 @@
1
- #!/bin/sh
2
-
3
- set -e
4
-
5
- bin/rails test "$@"