hephaestus 0.1.3 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/README.md +27 -1
  4. data/bin/hephaestus +9 -3
  5. data/lib/hephaestus/app_builder.rb +26 -5
  6. data/lib/hephaestus/exit_on_failure.rb +4 -4
  7. data/lib/hephaestus/generators/app_generator.rb +148 -56
  8. data/lib/hephaestus/generators/config_generator.rb +30 -2
  9. data/lib/hephaestus/generators/core_generator.rb +30 -1
  10. data/lib/hephaestus/generators/deployment_generator.rb +9 -3
  11. data/lib/hephaestus/generators/lib_generator.rb +1 -0
  12. data/lib/hephaestus/generators/sorbet_generator.rb +1 -1
  13. data/lib/hephaestus/version.rb +1 -1
  14. data/lib/hephaestus.rb +8 -0
  15. data/templates/.dockerignore +39 -0
  16. data/templates/.env.sample +6 -0
  17. data/templates/.github/dependabot.yml +12 -7
  18. data/templates/.github/workflows/automerge.yml +5 -85
  19. data/templates/.github/workflows/deploy.yml +30 -0
  20. data/templates/.github/workflows/licenses.yml +11 -31
  21. data/templates/.github/workflows/lint.yml +14 -34
  22. data/templates/.github/workflows/security.yml +9 -32
  23. data/templates/.github/workflows/sorbet.yml +7 -37
  24. data/templates/.github/workflows/test.yml +7 -41
  25. data/templates/.licensed.yml +7 -3
  26. data/templates/.ruby-version +1 -0
  27. data/templates/Dockerfile +79 -0
  28. data/templates/Gemfile.erb +23 -26
  29. data/templates/Procfile.debug +1 -1
  30. data/templates/app/controllers/app_controller.rb +71 -0
  31. data/templates/app/controllers/application_controller.rb +14 -1
  32. data/templates/app/controllers/concerns/authable.rb +20 -2
  33. data/templates/app/controllers/settings_controller.rb +32 -2
  34. data/templates/app/jobs/update_yetto_job.rb +6 -7
  35. data/templates/app/lib/body_parameter/yetto_parameters.rb +32 -0
  36. data/templates/app/lib/path_parameter/settings_parameters.rb +22 -0
  37. data/templates/app/lib/plug_app/middleware/openapi_validation.rb +5 -5
  38. data/templates/app/lib/plug_app/middleware/tracing_attributes.rb +1 -1
  39. data/templates/app/services/http_service.rb +27 -0
  40. data/templates/app/services/yetto_service.rb +24 -32
  41. data/templates/app/views/settings/new.json.jbuilder +21 -0
  42. data/templates/bin/docker-entrypoint +14 -0
  43. data/templates/compose.yml +7 -0
  44. data/templates/config/initializers/environment.rb +5 -8
  45. data/templates/config/initializers/filter_parameter_logging.rb +3 -0
  46. data/templates/config/initializers/opentelemetry.rb +32 -0
  47. data/templates/config/locales/en.yml +32 -0
  48. data/templates/config/locales/settings/en.yml +5 -0
  49. data/templates/lib/plug_app/schemas/api/2023-03-06/components/schemas/yetto.json +2 -2
  50. data/templates/lib/plug_app/schemas/api/2023-03-06/openapi.json +4 -4
  51. data/templates/lib/plug_app/schemas/api/2023-03-06/paths/plug.json +1 -1
  52. data/templates/lib/plug_app/schemas/api/2023-03-06/paths/yetto/after_create_message.json +2 -2
  53. data/templates/lib/plug_app/schemas/api/2023-03-06/paths/yetto/after_create_plug_installation.json +2 -2
  54. data/templates/lib/tasks/test_tasks.rake +6 -2
  55. data/templates/script/edit-credentials +29 -0
  56. data/templates/script/hmac_text +1 -1
  57. data/templates/script/licenses +4 -48
  58. data/templates/script/server +62 -2
  59. data/templates/script/sorbet +7 -0
  60. data/templates/test/controllers/application_controller_test.rb +32 -0
  61. data/templates/test/controllers/settings_controller_test.rb +1 -1
  62. data/templates/test/controllers/yetto_controller_test.rb +1 -1
  63. data/templates/test/fixtures/files/fake_pem_file/fake.pem +27 -0
  64. data/templates/test/jobs/update_yetto_job_test.rb +3 -18
  65. data/templates/test/support/api.rb +1 -1
  66. data/templates/test/support/rails.rb +1 -1
  67. data/templates/test/support/webmocks/slack_webmock.rb +2 -2
  68. data/templates/test/support/webmocks/yetto_webmock.rb +119 -0
  69. data/templates/test/test_helper.rb +16 -3
  70. data/templates/vendor/fly/fly-production.toml +38 -0
  71. data/templates/vendor/fly/fly-staging.toml +33 -0
  72. metadata +39 -16
  73. data/templates/.env.test +0 -4
  74. data/templates/.github/actions/license/action.yml +0 -11
  75. data/templates/.github/actions/setup/action.yml +0 -10
  76. data/templates/.github/actions/sisyphus/action.yml +0 -11
  77. data/templates/.github/actions/sorbet/action.yml +0 -19
  78. data/templates/app/views/settings/index.json.jbuilder +0 -15
  79. data/templates/config/initializers/open_telemetry.rb +0 -27
  80. data/templates/script/security_checks/brakeman +0 -5
  81. data/templates/script/security_checks/bundle-audit +0 -5
  82. data/templates/script/server-debug +0 -5
  83. data/templates/script/typecheck +0 -44
  84. data/templates/test/fixtures/files/.keep +0 -0
  85. data/templates/test/support/webmocks/yetto.rb +0 -94
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.1.3
4
+ version: 0.2.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: 2023-03-15 00:00:00.000000000 Z
11
+ date: 2023-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -54,6 +54,21 @@ dependencies:
54
54
  - !ruby/object:Gem::Version
55
55
  version: 7.0.0
56
56
  force_ruby_platform: false
57
+ - !ruby/object:Gem::Dependency
58
+ name: rainbow
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '3.0'
64
+ type: :runtime
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '3.0'
71
+ force_ruby_platform: false
57
72
  - !ruby/object:Gem::Dependency
58
73
  name: minitest
59
74
  requirement: !ruby/object:Gem::Requirement
@@ -113,13 +128,11 @@ files:
113
128
  - lib/hephaestus/generators/rubocop_generator.rb
114
129
  - lib/hephaestus/generators/sorbet_generator.rb
115
130
  - lib/hephaestus/version.rb
116
- - templates/.env.test
117
- - templates/.github/actions/license/action.yml
118
- - templates/.github/actions/setup/action.yml
119
- - templates/.github/actions/sisyphus/action.yml
120
- - templates/.github/actions/sorbet/action.yml
131
+ - templates/.dockerignore
132
+ - templates/.env.sample
121
133
  - templates/.github/dependabot.yml
122
134
  - templates/.github/workflows/automerge.yml
135
+ - templates/.github/workflows/deploy.yml
123
136
  - templates/.github/workflows/licenses.yml
124
137
  - templates/.github/workflows/lint.yml
125
138
  - templates/.github/workflows/security.yml
@@ -127,13 +140,16 @@ files:
127
140
  - templates/.github/workflows/test.yml
128
141
  - templates/.licensed.yml
129
142
  - templates/.rubocop.yml
143
+ - templates/.ruby-version
130
144
  - templates/.vscode/extensions.json
131
145
  - templates/.vscode/launch.json
132
146
  - templates/.vscode/settings.json
147
+ - templates/Dockerfile
133
148
  - templates/Gemfile.erb
134
149
  - templates/Procfile.debug
135
150
  - templates/Procfile.dev
136
151
  - templates/README.md.erb
152
+ - templates/app/controllers/app_controller.rb
137
153
  - templates/app/controllers/application_controller.rb
138
154
  - templates/app/controllers/concerns/authable.rb
139
155
  - templates/app/controllers/root_controller.rb
@@ -148,6 +164,7 @@ files:
148
164
  - templates/app/lib/headers.rb
149
165
  - templates/app/lib/headers/yetto.rb
150
166
  - templates/app/lib/path_parameter.rb
167
+ - templates/app/lib/path_parameter/settings_parameters.rb
151
168
  - templates/app/lib/path_parameter/yetto_parameters.rb
152
169
  - templates/app/lib/plug_app/http.rb
153
170
  - templates/app/lib/plug_app/middleware/malformed_request.rb
@@ -156,16 +173,21 @@ files:
156
173
  - templates/app/lib/plug_app/middleware/tracing_attributes.rb
157
174
  - templates/app/lib/query_parameter.rb
158
175
  - templates/app/serializers/error_serializer.rb
176
+ - templates/app/services/http_service.rb
159
177
  - templates/app/services/yetto_service.rb
160
- - templates/app/views/settings/index.json.jbuilder
178
+ - templates/app/views/settings/new.json.jbuilder
179
+ - templates/bin/docker-entrypoint
180
+ - templates/compose.yml
161
181
  - templates/config/initializers/cors.rb
162
182
  - templates/config/initializers/environment.rb
163
183
  - templates/config/initializers/filter_parameter_logging.rb
164
184
  - templates/config/initializers/inflections.rb
165
185
  - templates/config/initializers/lograge.rb
166
- - templates/config/initializers/open_telemetry.rb
186
+ - templates/config/initializers/opentelemetry.rb
167
187
  - templates/config/initializers/sidekiq.rb
168
188
  - templates/config/initializers/slack_webhook_logger.rb
189
+ - templates/config/locales/en.yml
190
+ - templates/config/locales/settings/en.yml
169
191
  - templates/config/sidekiq.yml
170
192
  - templates/hephaestus_gitignore
171
193
  - templates/lib/plug_app/schemas/api/2023-03-06/components/parameters/headers/yetto.json
@@ -179,20 +201,19 @@ files:
179
201
  - templates/lib/plug_app/schemas/api/2023-03-06/paths/yetto/after_create_plug_installation.json
180
202
  - templates/lib/tasks/test_tasks.rake
181
203
  - templates/script/ci
204
+ - templates/script/edit-credentials
182
205
  - templates/script/hmac_text
183
206
  - templates/script/licenses
184
207
  - templates/script/ngrok
185
- - templates/script/security_checks/brakeman
186
- - templates/script/security_checks/bundle-audit
187
208
  - templates/script/server
188
- - templates/script/server-debug
209
+ - templates/script/sorbet
189
210
  - templates/script/test
190
- - templates/script/typecheck
191
211
  - templates/sorbet/custom.rbi
212
+ - templates/test/controllers/application_controller_test.rb
192
213
  - templates/test/controllers/root_controller_test.rb
193
214
  - templates/test/controllers/settings_controller_test.rb
194
215
  - templates/test/controllers/yetto_controller_test.rb
195
- - templates/test/fixtures/files/.keep
216
+ - templates/test/fixtures/files/fake_pem_file/fake.pem
196
217
  - templates/test/integration/.keep
197
218
  - templates/test/jobs/update_yetto_job_test.rb
198
219
  - templates/test/mailers/.keep
@@ -200,8 +221,10 @@ files:
200
221
  - templates/test/support/rails.rb
201
222
  - templates/test/support/webmocks.rb
202
223
  - templates/test/support/webmocks/slack_webmock.rb
203
- - templates/test/support/webmocks/yetto.rb
224
+ - templates/test/support/webmocks/yetto_webmock.rb
204
225
  - templates/test/test_helper.rb
226
+ - templates/vendor/fly/fly-production.toml
227
+ - templates/vendor/fly/fly-staging.toml
205
228
  homepage: http://github.com/yettoapp/hephaestus
206
229
  licenses:
207
230
  - MIT
@@ -222,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
245
  - !ruby/object:Gem::Version
223
246
  version: 3.4.7
224
247
  requirements: []
225
- rubygems_version: 3.4.8
248
+ rubygems_version: 3.4.19
226
249
  signing_key:
227
250
  specification_version: 4
228
251
  summary: Generate a Rails app that can be used to create plugs for Yetto.
data/templates/.env.test DELETED
@@ -1,4 +0,0 @@
1
- PLUG_APP_URL="plug-app.ngrok.io"
2
- YETTO_API_VERSION_TLD="yetto.ngrok.io/api"
3
-
4
- SLACK_LOG_URL=http://slack.com/the_log_room
@@ -1,11 +0,0 @@
1
- name: "Run License Check"
2
- description: "Validates that all the licenses are up to date."
3
-
4
- runs:
5
- using: "composite"
6
- steps:
7
- - uses: ./.github/actions/setup
8
-
9
- - name: Run license check
10
- shell: bash
11
- run: script/licenses --update
@@ -1,10 +0,0 @@
1
- name: "Set up Plug"
2
- description: "Do whatever is necessary to setup the plug."
3
-
4
- runs:
5
- using: "composite"
6
- steps:
7
- - uses: ruby/setup-ruby@v1
8
- with:
9
- bundler-cache: true
10
- rubygems: latest
@@ -1,11 +0,0 @@
1
- name: "Configure git"
2
- description: "Sets up Git creds for Sisyphus"
3
-
4
- runs:
5
- using: "composite"
6
- steps:
7
- - name: Run git config
8
- shell: bash
9
- run: |
10
- git config --local user.email "sisyphus@yetto.app"
11
- git config --local user.name "Sisyphus"
@@ -1,19 +0,0 @@
1
- name: "Run Sorbet Check"
2
- description: "Validates that all the Sorbet types are up to date."
3
-
4
- inputs:
5
- gh_token:
6
- description: 'A GitHub PAT'
7
- required: true
8
-
9
- runs:
10
- using: "composite"
11
- steps:
12
- - uses: ./.github/actions/setup
13
-
14
- - name: Update RBI files
15
- shell: bash
16
- id: update
17
- env:
18
- GITHUB_TOKEN: ${{ inputs.gh_token }}
19
- run: script/typecheck --update
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- json.version("2023-03-06")
4
- json.settings do
5
- json.array!([
6
- {
7
- component: "text_field",
8
-
9
- },
10
- {
11
- component: "email_field",
12
-
13
- },
14
- ])
15
- end
@@ -1,27 +0,0 @@
1
- # typed: false
2
- # frozen_string_literal: true
3
-
4
- require "opentelemetry/sdk"
5
- require "opentelemetry/semantic_conventions"
6
-
7
- if Rails.env.staging? || Rails.env.production?
8
- OpenTelemetry::SDK.configure do |c|
9
- c.logger = Rails.logger
10
-
11
- c.use_all
12
-
13
- if productionish?
14
- c.add_span_processor(
15
- OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(
16
- OpenTelemetry::Exporter::OTLP::Exporter.new,
17
- ),
18
- )
19
- else
20
- c.add_span_processor(
21
- OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessornew(
22
- OpenTelemetry::SDK::Trace::Export::SpanExporter.new,
23
- ),
24
- )
25
- end
26
- end
27
- end
@@ -1,5 +0,0 @@
1
- #!/bin/sh
2
-
3
- set -e
4
-
5
- bundle exec brakeman --color -o /dev/stdout -o security-results.json
@@ -1,5 +0,0 @@
1
- #!/bin/sh
2
-
3
- set -e
4
-
5
- bundle exec bundle-audit check --update
@@ -1,5 +0,0 @@
1
- #!/bin/sh
2
-
3
- set -e
4
-
5
- bin/foreman start -f Procfile.debug
@@ -1,44 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -e
4
-
5
- function usage() {
6
- echo "Usage:"
7
- echo "$0 [options]"
8
- echo ""
9
- echo " Options:"
10
- echo " -u/--update Update tapioca RBI files"
11
- echo " -v/--verify Verify tapioca RBI files"
12
- echo " -h/--help Display this help message"
13
- echo ""
14
- exit 1
15
- }
16
-
17
- while [ "$1" != "" ]; do
18
- case $1 in
19
- -u | --update)
20
- echo "Updating Tapioca RBI files ..."
21
- bin/tapioca gem
22
- echo "Updating Tapioca DSL files ..."
23
- bin/tapioca dsl
24
- echo "Updating Tapioca TODO files ..."
25
- bin/tapioca todo
26
- ;;
27
- -v | --verify)
28
- echo "Verify Sorbet types..."
29
- bin/bundle exec srb tc
30
- echo "Verify gem RBIs are up-to-date ..."
31
- bin/tapioca gem --verify
32
- echo "Verify duplicates in shims ..."
33
- bin/tapioca check-shims
34
- ;;
35
- -h | --help)
36
- usage
37
- ;;
38
- *)
39
- usage
40
- exit 1
41
- ;;
42
- esac
43
- shift
44
- done
File without changes
@@ -1,94 +0,0 @@
1
- # typed: false
2
- # frozen_string_literal: true
3
-
4
- module Webmocks
5
- module Yetto
6
- SHA256_DIGEST = OpenSSL::Digest.new("sha256")
7
-
8
- def yetto_auth_header(payload)
9
- "sha256=#{OpenSSL::HMAC.hexdigest(SHA256_DIGEST, YETTO_PLUG_APP_TOKEN, payload.to_json)}"
10
- end
11
-
12
- def assert_requested_get_plug_installation(organization_id, inbox_id, plug_installation_id)
13
- assert_requested(:get, "#{::YettoService::YETTO_API_VERSION_TLD}/organizations/#{organization_id}/inboxes/#{inbox_id}/plug_installations/#{plug_installation_id}")
14
- end
15
-
16
- def stub_get_plug_installation(organization_id, inbox_id, plug_installation_id, response = nil, status: 200)
17
- response ||= {
18
- installed_on_inbox: {
19
- id: inbox_id,
20
- organization: {
21
- id: organization_id,
22
- status: "active",
23
- },
24
- },
25
- plug: {
26
- id: "plg_#{Faker::Alphanumeric.alphanumeric(number: 26).upcase}",
27
- },
28
- settings: {
29
- from_email: "new@from.company",
30
- },
31
- }
32
-
33
- stub_request(:get, "#{::YettoService::YETTO_API_VERSION_TLD}/organizations/#{@organization_id}/inboxes/#{@inbox_id}/plug_installations/#{plug_installation_id}")
34
- .to_return(
35
- status: status,
36
- headers: { content_type: "application/json; charset=utf-8" },
37
- body: response.to_json,
38
- )
39
- end
40
-
41
- def assert_requested_update_installation(organization_id, inbox_id, plug_installation_id)
42
- assert_requested(:patch, "#{::YettoService::YETTO_API_VERSION_TLD}/organizations/#{@organization_id}/inboxes/#{@inbox_id}/plug_installations/#{plug_installation_id}")
43
- end
44
-
45
- def stub_update_installation(organization_id, inbox_id, plug_installation_id, params, response: {}, status: 200)
46
- stub_request(:patch, "#{::YettoService::YETTO_API_VERSION_TLD}/organizations/#{@organization_id}/inboxes/#{@inbox_id}/plug_installations/#{plug_installation_id}")
47
- .with(
48
- body: params,
49
- )
50
- .to_return(
51
- status: 200,
52
- headers: { content_type: "application/json; charset=utf-8" },
53
- body: response.to_json,
54
- )
55
- end
56
-
57
- def assert_requested_create_message(organization_id, inbox_id)
58
- assert_requested(:post, "#{::YettoService::YETTO_API_VERSION_TLD}/organizations/#{organization_id}/inboxes/#{inbox_id}/messages")
59
- end
60
-
61
- def stub_create_message(organization_id, inbox_id, creator_id, payload)
62
- stub_request(:post, "#{::YettoService::YETTO_API_VERSION_TLD}/organizations/#{organization_id}/inboxes/#{inbox_id}/messages")
63
- .with(
64
- body: payload,
65
- )
66
- .to_return(
67
- status: 200,
68
- headers: { content_type: "application/json; charset=utf-8" },
69
- body: {}.to_json,
70
- )
71
- end
72
-
73
- def assert_requested_create_switch(organization_id, inbox_id)
74
- assert_requested(:post, "#{::YettoService::YETTO_API_VERSION_TLD}/organizations/#{organization_id}/inboxes/#{inbox_id}/switches")
75
- end
76
-
77
- def stub_create_switch(organization_id, inbox_id, creator_id, params)
78
- payload = {
79
- name: "After install",
80
- creator: { id: creator_id },
81
- }
82
-
83
- stub_request(:post, "#{::YettoService::YETTO_API_VERSION_TLD}/organizations/#{organization_id}/inboxes/#{inbox_id}/switches")
84
- .with(
85
- body: payload,
86
- )
87
- .to_return(
88
- status: 200,
89
- headers: { content_type: "application/json; charset=utf-8" },
90
- body: {}.to_json,
91
- )
92
- end
93
- end
94
- end