hephaestus 0.8.11 → 0.8.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/CHANGELOG.md +6 -0
  4. data/README.md +3 -1
  5. data/bin/hephaestus +31 -13
  6. data/lib/hephaestus/app_builder.rb +23 -145
  7. data/lib/hephaestus/app_name.rb +33 -0
  8. data/lib/hephaestus/generators/app_generator.rb +70 -72
  9. data/lib/hephaestus/generators/config_generator.rb +3 -114
  10. data/lib/hephaestus/generators/core_generator.rb +18 -58
  11. data/lib/hephaestus/generators/db_generator.rb +12 -0
  12. data/lib/hephaestus/generators/deployment_generator.rb +1 -6
  13. data/lib/hephaestus/generators/lib_generator.rb +0 -10
  14. data/lib/hephaestus/generators/license_generator.rb +4 -1
  15. data/lib/hephaestus/generators/rubocop_generator.rb +1 -1
  16. data/lib/hephaestus/version.rb +1 -1
  17. data/lib/hephaestus.rb +2 -0
  18. data/templates/Dockerfile +7 -75
  19. data/templates/Gemfile +73 -0
  20. data/templates/Procfile +2 -0
  21. data/templates/app/controllers/app_controller.rb.tt +35 -0
  22. data/templates/app/controllers/application_controller.rb +1 -7
  23. data/templates/app/controllers/concerns/authable.rb.tt +50 -0
  24. data/templates/app/controllers/settings_controller.rb +5 -28
  25. data/templates/app/controllers/yetto_controller.rb +9 -10
  26. data/templates/app/lib/body_parameter/yetto_parameters.rb +8 -29
  27. data/templates/app/lib/{constants/app.rb → constants.rb} +1 -3
  28. data/templates/app/services/{http_service.rb → app_service.rb.tt} +6 -6
  29. data/templates/app/views/settings/new.json.jbuilder.tt +18 -0
  30. data/templates/bin/bundle +115 -0
  31. data/templates/bin/docker-entrypoint +20 -10
  32. data/templates/bin/foreman +27 -0
  33. data/templates/bin/jobs +7 -0
  34. data/templates/bin/rails +6 -0
  35. data/templates/bin/rake +6 -0
  36. data/templates/bin/setup +28 -0
  37. data/templates/bin/tapioca +27 -0
  38. data/templates/config/application.rb.tt +36 -0
  39. data/templates/config/boot.rb +7 -0
  40. data/templates/config/environment.rb +8 -0
  41. data/templates/config/environments/blank.rb +7 -0
  42. data/templates/config/initializers/environment.rb +2 -36
  43. data/templates/config/locales/en.yml +5 -31
  44. data/templates/config/puma.rb +5 -0
  45. data/templates/config/routes.rb.tt +28 -0
  46. data/templates/config.ru +9 -0
  47. data/templates/db/queue_schema.rb +132 -0
  48. data/templates/db/schema.rb +17 -0
  49. data/templates/lib/schemas/api/2023-03-06/components/parameters/headers/yetto.json +42 -0
  50. data/templates/lib/schemas/api/2023-03-06/components/parameters/plugInstallation.json +12 -0
  51. data/templates/lib/schemas/api/2023-03-06/components/schemas/plug.json +9 -0
  52. data/templates/lib/schemas/api/2023-03-06/components/schemas/responses.json +64 -0
  53. data/templates/lib/schemas/api/2023-03-06/components/schemas/yetto.json +116 -0
  54. data/templates/lib/schemas/api/2023-03-06/openapi.json +30 -0
  55. data/templates/lib/schemas/api/2023-03-06/paths/app.json +90 -0
  56. data/templates/lib/schemas/api/2023-03-06/paths/yetto/message_created.json +51 -0
  57. data/templates/lib/schemas/api/2023-03-06/paths/yetto/plug_installation_created.json +51 -0
  58. data/templates/script/docker-build-prod.tt +11 -0
  59. data/templates/script/docker-run.tt +8 -0
  60. data/templates/script/edit-credentials +12 -3
  61. data/templates/script/hmac_text +1 -1
  62. data/templates/script/ngrok.tt +7 -0
  63. data/templates/script/server +6 -45
  64. data/templates/test/controllers/app_controller_test.rb.tt +188 -0
  65. data/templates/test/controllers/settings_controller_test.rb.tt +125 -0
  66. data/templates/test/controllers/yetto_controller_test.rb +100 -71
  67. data/templates/test/fixtures/files/plug_installation_settings/valid.json +1 -1
  68. data/templates/test/support/rails.rb +16 -36
  69. data/templates/test/support/webmocks/app_webmock.rb.tt +29 -0
  70. data/templates/test/test_helper.rb +1 -31
  71. data/templates/vendor/fly/{fly-production.toml → fly-production.toml.tt} +24 -11
  72. data/templates/vendor/fly/{fly-staging.toml → fly-staging.toml.tt} +18 -15
  73. metadata +46 -71
  74. data/templates/Gemfile.erb +0 -120
  75. data/templates/Procfile.debug +0 -2
  76. data/templates/Procfile.dev +0 -2
  77. data/templates/app/controllers/app_controller.rb +0 -72
  78. data/templates/app/controllers/concerns/authable.rb +0 -50
  79. data/templates/app/controllers/staff_controller.rb +0 -15
  80. data/templates/app/jobs/update_yetto_job.rb +0 -26
  81. data/templates/app/lib/headers/yetto.rb +0 -19
  82. data/templates/app/lib/headers.rb +0 -5
  83. data/templates/app/lib/path_parameter/settings_parameters.rb +0 -22
  84. data/templates/app/lib/path_parameter/yetto_parameters.rb +0 -28
  85. data/templates/app/lib/path_parameter.rb +0 -8
  86. data/templates/app/lib/plug_app/http.rb +0 -37
  87. data/templates/app/lib/plug_app/middleware/malformed_request.rb +0 -110
  88. data/templates/app/lib/plug_app/middleware/openapi_validation.rb +0 -83
  89. data/templates/app/lib/plug_app/middleware/tracing_attributes.rb +0 -46
  90. data/templates/app/lib/query_parameter.rb +0 -6
  91. data/templates/app/serializers/error_serializer.rb +0 -16
  92. data/templates/app/services/yetto_service.rb +0 -51
  93. data/templates/app/views/settings/new.json.jbuilder +0 -21
  94. data/templates/compose.yml +0 -5
  95. data/templates/config/initializers/000-oj.rb +0 -6
  96. data/templates/config/initializers/cors.rb +0 -19
  97. data/templates/config/initializers/filter_parameter_logging.rb +0 -25
  98. data/templates/config/initializers/inflections.rb +0 -20
  99. data/templates/config/initializers/lograge.rb +0 -25
  100. data/templates/config/initializers/opentelemetry.rb +0 -32
  101. data/templates/config/initializers/sidekiq.rb +0 -11
  102. data/templates/config/initializers/slack_webhook_logger.rb +0 -17
  103. data/templates/config/sidekiq.yml +0 -20
  104. data/templates/script/ngrok +0 -5
  105. data/templates/test/controllers/settings_controller_test.rb +0 -27
  106. data/templates/test/fixtures/plug_installation_settings/invalid.json +0 -3
  107. data/templates/test/fixtures/plug_installation_settings/valid.json +0 -3
  108. data/templates/test/jobs/update_yetto_job_test.rb +0 -26
  109. data/templates/test/support/api.rb +0 -76
  110. data/templates/test/support/webmocks/slack_webmock.rb +0 -24
  111. data/templates/test/support/webmocks/yetto_webmock.rb +0 -119
  112. data/templates/test/support/webmocks.rb +0 -5
@@ -3,21 +3,20 @@
3
3
 
4
4
  class YettoController < ApplicationController
5
5
  include BodyParameter::YettoParameters
6
- include PathParameter
7
- include PathParameter::YettoParameters
8
- include Authable
9
-
10
- include Headers::Yetto
6
+ include Hephaestus::ValidatesFromYetto
11
7
 
12
8
  before_action :from_yetto?
13
9
 
14
10
  def event
15
- case pparam_yetto_event
16
- when Headers::Yetto::EVENT_AFTER_CREATE
17
- case pparam_yetto_record_type
18
- when Headers::Yetto::RECORD_TYPE_PLUG_INSTALLATION
11
+ event = params[:event]
12
+ record_type = params[:record_type]
13
+
14
+ case event
15
+ when Hephaestus::Headers::EVENT_AFTER_CREATE
16
+ case record_type
17
+ when Hephaestus::Headers::RECORD_TYPE_PLUG_INSTALLATION
19
18
  no_content
20
- when Headers::Yetto::RECORD_TYPE_MESSAGE
19
+ when Hephaestus::Headers::RECORD_TYPE_MESSAGE
21
20
 
22
21
  no_content
23
22
  else
@@ -12,7 +12,7 @@ module BodyParameter
12
12
 
13
13
  sig { returns(String) }
14
14
  def bparam_inbox_id
15
- plug_installation_params[:yetto][:inbox][:id]
15
+ plug_installation_params[:yetto][:message][:conversation][:inbox][:id]
16
16
  end
17
17
 
18
18
  sig { returns(String) }
@@ -32,34 +32,12 @@ module BodyParameter
32
32
 
33
33
  sig { returns(T::Hash[Symbol, String]) }
34
34
  def plug_installation_params
35
- return {} if params.blank?
35
+ return {} if request.parameters.blank?
36
36
 
37
- yetto_params = params.fetch(:yetto, {})
38
- plug_installation = yetto_params.fetch(:plug_installation, {})
39
-
40
- plug_installation_id = plug_installation.fetch(:id, "")
41
- settings = plug_installation.fetch(:settings, {}).to_unsafe_hash
42
-
43
- organization_id = yetto_params.fetch(:organization, {}).fetch(:id, "")
44
- plug_id = yetto_params.fetch(:plug, {}).fetch(:id, "")
45
- inbox_id = yetto_params.fetch(:inbox, {}).fetch(:id, "")
37
+ yetto_params = request.parameters.fetch(:yetto, {})
46
38
 
47
39
  {
48
- yetto: {
49
- plug_installation: {
50
- id: plug_installation_id,
51
- settings: settings,
52
- },
53
- organization: {
54
- id: organization_id,
55
- },
56
- plug: {
57
- id: plug_id,
58
- },
59
- inbox: {
60
- id: inbox_id,
61
- },
62
- },
40
+ yetto: yetto_params,
63
41
  }
64
42
  end
65
43
 
@@ -95,9 +73,10 @@ module BodyParameter
95
73
 
96
74
  sig { returns(T::Hash[Symbol, String]) }
97
75
  def message_params
98
- return {} if params.blank?
76
+ return {} if request.parameters.blank?
77
+
78
+ yetto_params = request.parameters.fetch(:yetto, {})
99
79
 
100
- yetto_params = params.fetch(:yetto, {})
101
80
  message = yetto_params.fetch(:message, {})
102
81
  message_id = message.fetch(:id, "")
103
82
  text_content = message.fetch(:text_content, "")
@@ -108,7 +87,7 @@ module BodyParameter
108
87
  created_by_plug = message.fetch(:created_by_plug, {})
109
88
  author = created_by_membership.fetch(:user) || created_by_plug
110
89
  name = author.fetch(:name, "")
111
- metadata = message.fetch(:metadata, {}).to_unsafe_hash
90
+ metadata = message.fetch(:metadata, {})
112
91
 
113
92
  {
114
93
  yetto: {
@@ -2,7 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Constants
5
- module PlugApp
6
- PLUG_APP_API_VERSION = "2023-03-06"
7
- end
5
+ # TODO: put all app constants here
8
6
  end
@@ -1,17 +1,17 @@
1
- # typed: strict
1
+ # typed: false
2
2
  # frozen_string_literal: true
3
3
 
4
- class HTTPService
4
+ require "httpsensible"
5
+
6
+ class <%= capital_plug_name %>Service
5
7
  extend T::Sig
6
8
 
7
9
  class << self
8
10
  extend T::Sig
9
11
 
10
- CACHE_VERSION = "1"
11
-
12
- sig { returns(T.untyped) }
12
+ sig { returns(Httpsensible::Client) }
13
13
  def http_client
14
- Httpsensible::Client.new(user_agent: "PlugApp/#{PlugApp::Application::GIT_SHA}")
14
+ Httpsensible::Client.new(user_agent: "Plug<%= capital_plug_name %>/#{Hephaestus::Engine::GIT_SHA}")
15
15
  end
16
16
 
17
17
  sig { params(url: String, params: T::Hash[Symbol, T.untyped]).returns(T.untyped) }
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ json.version("2023-03-06")
4
+ json.settings do
5
+ json.step do
6
+ case @step
7
+ when 1
8
+ json.heading(t(:new_step_one_heading))
9
+ json.text(t(:new_step_one_text))
10
+ when 2
11
+ json.heading(t(:new_step_two_heading))
12
+ json.text(t(:new_step_two_text))
13
+ json.state(<%= upcase_plug_name %>_NONCE)
14
+ json.button_text(t(:new_step_two_oauth_button))
15
+ json.button_oauth_link("")
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,115 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bundle' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "rubygems"
12
+
13
+ m = Module.new do
14
+ module_function
15
+
16
+ def invoked_as_script?
17
+ File.expand_path($PROGRAM_NAME) == File.expand_path(__FILE__)
18
+ end
19
+
20
+ def env_var_version
21
+ ENV["BUNDLER_VERSION"]
22
+ end
23
+
24
+ def cli_arg_version
25
+ return unless invoked_as_script? # don't want to hijack other binstubs
26
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27
+
28
+ bundler_version = nil
29
+ update_index = nil
30
+ ARGV.each_with_index do |a, i|
31
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
32
+ bundler_version = a
33
+ end
34
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/o
35
+
36
+ bundler_version = Regexp.last_match(1)
37
+ update_index = i
38
+ end
39
+ bundler_version
40
+ end
41
+
42
+ def gemfile
43
+ gemfile = ENV["BUNDLE_GEMFILE"]
44
+ return gemfile if gemfile.present?
45
+
46
+ File.expand_path("../Gemfile", __dir__)
47
+ end
48
+
49
+ def lockfile
50
+ lockfile =
51
+ case File.basename(gemfile)
52
+ when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
53
+ else "#{gemfile}.lock"
54
+ end
55
+ File.expand_path(lockfile)
56
+ end
57
+
58
+ def lockfile_version
59
+ return unless File.file?(lockfile)
60
+
61
+ lockfile_contents = File.read(lockfile)
62
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/o
63
+
64
+ Regexp.last_match(1)
65
+ end
66
+
67
+ def bundler_requirement
68
+ @bundler_requirement ||=
69
+ env_var_version ||
70
+ cli_arg_version ||
71
+ bundler_requirement_for(lockfile_version)
72
+ end
73
+
74
+ def bundler_requirement_for(version)
75
+ return "#{Gem::Requirement.default}.a" unless version
76
+
77
+ bundler_gem_version = Gem::Version.new(version)
78
+
79
+ bundler_gem_version.approximate_recommendation
80
+ end
81
+
82
+ def load_bundler!
83
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
84
+
85
+ activate_bundler
86
+ end
87
+
88
+ def activate_bundler
89
+ gem_error = activation_error_handling do
90
+ gem("bundler", bundler_requirement)
91
+ end
92
+ return if gem_error.nil?
93
+
94
+ require_error = activation_error_handling do
95
+ require "bundler/version"
96
+ end
97
+ return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
98
+
99
+ warn("Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`")
100
+ exit(42)
101
+ end
102
+
103
+ def activation_error_handling
104
+ yield
105
+ nil
106
+ rescue StandardError, LoadError => e
107
+ e
108
+ end
109
+ end
110
+
111
+ m.load_bundler!
112
+
113
+ if m.invoked_as_script?
114
+ load Gem.bin_path("bundler", "bundle")
115
+ end
@@ -1,14 +1,24 @@
1
1
  #!/bin/bash -e
2
2
 
3
- # Add any container initialization steps here
4
- git config --global --add safe.directory /plug-app
5
-
6
- # allocate swap space
7
- fallocate -l 2GB /swapfile
8
- chmod 0600 /swapfile
9
- mkswap /swapfile
10
- echo 10 > /proc/sys/vm/swappiness
11
- swapon /swapfile
12
- echo 1 > /proc/sys/vm/overcommit_memory
3
+ # Set SOLID_QUEUE_CONFIG environment variable
4
+ SOLID_QUEUE_CONFIG="$(bundle show hephaestus | tr -d '\n')/config/queue.yml"
5
+ export SOLID_QUEUE_CONFIG
6
+
7
+ if [ "$(id -u)" -eq 0 ] && [ ! -f /swapfile ]; then
8
+ # allocate swap space
9
+ fallocate -l 2GB /swapfile
10
+ chmod 0600 /swapfile
11
+ mkswap /swapfile
12
+ echo 10 > /proc/sys/vm/swappiness
13
+ swapon /swapfile
14
+ echo 1 > /proc/sys/vm/overcommit_memory
15
+ # rerun this script as nobody
16
+ exec su nobody -s "$SHELL" -c "$0 $@"
17
+ fi
18
+
19
+ if [ "${1}" == "/app/bin/rails" ] && [ "${2}" == "server" ] && [ "$FLY_REGION" == "$PRIMARY_REGION" ]; then
20
+ # run the db migrations
21
+ /app/bin/rails db:migrate
22
+ fi
13
23
 
14
24
  exec "${@}"
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'foreman' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12
+
13
+ bundle_binstub = File.expand_path("bundle", __dir__)
14
+
15
+ if File.file?(bundle_binstub)
16
+ if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
17
+ load(bundle_binstub)
18
+ else
19
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
20
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21
+ end
22
+ end
23
+
24
+ require "rubygems"
25
+ require "bundler/setup"
26
+
27
+ load Gem.bin_path("foreman", "foreman")
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "../config/environment"
5
+ require "solid_queue/cli"
6
+
7
+ SolidQueue::Cli.start(ARGV)
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ APP_PATH = File.expand_path("../config/application", __dir__)
5
+ require_relative "../config/boot"
6
+ require "rails/commands"
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "../config/boot"
5
+ require "rake"
6
+ Rake.application.run
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "fileutils"
5
+
6
+ APP_ROOT = File.expand_path("..", __dir__)
7
+
8
+ def system!(*args)
9
+ system(*args, exception: true)
10
+ end
11
+
12
+ FileUtils.chdir(APP_ROOT) do
13
+ # This script is a way to set up or update your development environment automatically.
14
+ # This script is idempotent, so that you can run it at any time and get an expectable outcome.
15
+ # Add necessary setup steps to this file.
16
+
17
+ puts "== Installing dependencies =="
18
+ system("bundle check") || system!("bundle install")
19
+
20
+ puts "\n== Removing old logs and tempfiles =="
21
+ system! "bin/rails log:clear tmp:clear"
22
+
23
+ if ARGV.exclude?("--skip-server")
24
+ puts "\n== Starting development server =="
25
+ $stdout.flush # flush the output before exec(2) so that it displays
26
+ exec "bin/dev"
27
+ end
28
+ end
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'tapioca' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12
+
13
+ bundle_binstub = File.expand_path("bundle", __dir__)
14
+
15
+ if File.file?(bundle_binstub)
16
+ if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
17
+ load(bundle_binstub)
18
+ else
19
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
20
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21
+ end
22
+ end
23
+
24
+ require "rubygems"
25
+ require "bundler/setup"
26
+
27
+ load Gem.bin_path("tapioca", "tapioca")
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "boot"
4
+
5
+ # Pick the frameworks you want:
6
+ # require "active_model/railtie"
7
+ require "active_job/railtie"
8
+ require "active_record/railtie"
9
+ # require "active_storage/engine"
10
+ require "action_controller/railtie"
11
+ # require "action_mailer/railtie"
12
+ # require "action_mailbox/engine"
13
+ # require "action_text/engine"
14
+ require "action_view/railtie"
15
+ # require "action_cable/engine"
16
+ require "rails/test_unit/railtie"
17
+
18
+ # Require the gems listed in Gemfile, including any gems
19
+ # you've limited to :test, :development, or :production.
20
+ Bundler.require(*Rails.groups)
21
+
22
+ module Plug<%= capital_plug_name %>
23
+ class Application < Rails::Application
24
+ # Initialize configuration defaults for originally generated Rails version.
25
+ config.load_defaults(Rails::VERSION::STRING.to_f)
26
+
27
+ config.paths["config/database"] << Hephaestus::Engine.root.join("config/database.yml")
28
+
29
+ Hephaestus::Engine.load_environment
30
+
31
+ initializer :engines_blank_point do
32
+ config.yetto_api_version = "2023-03-06"
33
+ config.plug_api_version = "2023-03-06"
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,7 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
5
+
6
+ require "bundler/setup" # Set up gems listed in the Gemfile.
7
+ require "bootsnap/setup" # Speed up boot time by caching expensive operations.
@@ -0,0 +1,8 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ # Load the Rails application.
5
+ require_relative "application"
6
+
7
+ # Initialize the Rails application.
8
+ Rails.application.initialize!
@@ -0,0 +1,7 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ require "active_support/core_ext/integer/time"
5
+
6
+ Rails.application.configure do
7
+ end
@@ -1,40 +1,6 @@
1
1
  # typed: false
2
2
  # frozen_string_literal: true
3
3
 
4
- YETTO_URL = if Rails.env.production?
5
- "web.yetto.app"
6
- elsif Rails.env.staging?
7
- "web.yetto.dev"
8
- elsif Rails.env.development?
9
- "localhost:3000"
10
- elsif Rails.env.test?
11
- "web.yetto.test"
12
- end
4
+ # TODO: put global environment variables here, like:
13
5
 
14
- YETTO_API_TLD = ENV.fetch("YETTO_API_TLD", "#{YETTO_URL}/api")
15
- YETTO_API_VERSION = ENV.fetch("YETTO_API_VERSION", "2023-03-06")
16
-
17
- SLACK_LOG_URL = Rails.application.credentials.fetch(:SLACK_LOG_URL, ENV.fetch("SLACK_LOG_URL", "https://slack.com/the_log_room"))
18
-
19
- PROTOCOL = "https"
20
- PLUG_APP_URL = if Rails.env.production?
21
- "app.plugs.yetto.app"
22
- elsif Rails.env.staging?
23
- "app.plugs.yetto.dev"
24
- elsif Rails.env.development?
25
- "plug-app.ngrok.io"
26
- elsif Rails.env.test?
27
- "app.plugs.yetto.test"
28
- end
29
-
30
- YETTO_PLUG_PEM = Rails.application.credentials.fetch(:YETTO_PLUG_PEM, ENV.fetch("YETTO_PLUG_PEM", Rails.root.join("test/fixtures/files/fake_pem_file/fake.pem").read))
31
- SIGNING_SECRET = Rails.application.credentials.fetch(:SIGNING_SECRET, ENV.fetch("SIGNING_SECRET", "super-secret"))
32
- YETTO_PLUG_ID = Rails.application.credentials.fetch(:YETTO_PLUG_ID, ENV.fetch("YETTO_PLUG_ID", "super-secret"))
33
-
34
- def productionish?
35
- Rails.env.production? || Rails.env.staging?
36
- end
37
-
38
- def print_user_api_errors?
39
- (Rails.env.development? || Rails.env.staging?) || ENV.fetch("DEBUG", false)
40
- end
6
+ # APP_CLIENT_ID = fetch_vault_secret(label: "APP_CLIENT_ID", default: "super-secret")
@@ -1,32 +1,6 @@
1
- # Files in the config/locales directory are used for internationalization
2
- # and are automatically loaded by Rails. If you want to use locales other
3
- # than English, add the necessary files in this directory.
4
- #
5
- # To use the locales, use `I18n.t`:
6
- #
7
- # I18n.t "hello"
8
- #
9
- # In views, this is aliased to just `t`:
10
- #
11
- # <%= t("hello") %>
12
- #
13
- # To use a different locale, set it with `I18n.locale`:
14
- #
15
- # I18n.locale = :es
16
- #
17
- # This would use the information in config/locales/es.yml.
18
- #
19
- # The following keys must be escaped otherwise they will not be retrieved by
20
- # the default I18n backend:
21
- #
22
- # true, false, on, off, yes, no
23
- #
24
- # Instead, surround them with single quotes.
25
- #
26
- # en:
27
- # "true": "foo"
28
- #
29
- # To learn more, please read the Rails Internationalization guide
30
- # available at https://guides.rubyonrails.org/i18n.html.
31
-
32
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"
@@ -0,0 +1,5 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ # Load Hephaestus' config
5
+ load Hephaestus::Engine.root.join("config", "puma.rb").to_s
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.routes.draw do
4
+ # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
5
+
6
+ # Reveal health status on /up that returns 200 if the linear boots with no exceptions, otherwise 500.
7
+ # Can be used by load balancers and uptime monitors to verify that the linear is live.
8
+ get "up" => "rails/health#show", as: :rails_health_check
9
+
10
+ # Defines the root path route ("/")
11
+ root "root#index"
12
+
13
+ HephaestusSettingsController = Hephaestus::SettingsController
14
+
15
+ get "/api/#{Rails.application.config.plug_api_version}/settings", to: "hephaestus_settings#new"
16
+ get "/api/#{Rails.application.config.plug_api_version}/settings/:organization_id/:inbox_id/:plug_installation_id/edit", to: "settings#edit"
17
+
18
+ post "/api/#{Rails.application.config.plug_api_version}/:record_type/:event", to: "yetto#event"
19
+
20
+ # inbound message
21
+ post "/<%= plug_name %>/#{Rails.application.config.plug_api_version}/webhook", to: "<%= plug_name %>#webhook"
22
+ # for return from oauth approval
23
+ get "/<%= plug_name %>/#{Rails.application.config.plug_api_version}/callback", to: "<%= plug_name %>#callback"
24
+ # shows after the oauth dance successfully completes
25
+ get "/<%= plug_name %>/#{Rails.application.config.plug_api_version}/post-install", to: "<%= plug_name %>#show_post_install"
26
+ end
27
+
28
+ Hephaestus::Engine.insert_routes
@@ -0,0 +1,9 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ # This file is used by Rack-based servers to start the application.
5
+
6
+ require_relative "config/environment"
7
+
8
+ run Rails.application
9
+ Rails.application.load_server