boring_generators 0.1.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +12 -0
  3. data/.github/PULL_REQUEST_TEMPLATE.md +11 -0
  4. data/.github/workflows/ci.yml +17 -0
  5. data/CHANGELOG.md +36 -0
  6. data/Gemfile +6 -0
  7. data/Gemfile.lock +148 -0
  8. data/README.md +52 -6
  9. data/boring_generators.gemspec +3 -1
  10. data/exe/boring +5 -0
  11. data/lib/boring_generators.rb +1 -0
  12. data/lib/boring_generators/cli.rb +26 -0
  13. data/lib/boring_generators/version.rb +1 -1
  14. data/lib/generators/boring/active_storage/aws/install/install_generator.rb +48 -0
  15. data/lib/generators/boring/active_storage/azure/install/install_generator.rb +48 -0
  16. data/lib/generators/boring/active_storage/google/install/install_generator.rb +48 -0
  17. data/lib/generators/boring/audit/install/install_generator.rb +22 -0
  18. data/lib/generators/boring/bootstrap/install/install_generator.rb +67 -0
  19. data/lib/generators/boring/bootstrap/install/templates/application.scss +1 -0
  20. data/lib/generators/boring/bullet/install/install_generator.rb +31 -0
  21. data/lib/generators/boring/bullet/install/templates/bullet.rb +8 -0
  22. data/lib/generators/boring/ci/circleci/install/install_generator.rb +31 -0
  23. data/lib/generators/boring/ci/circleci/install/templates/config.psql.yml.tt +48 -0
  24. data/lib/generators/boring/ci/circleci/install/templates/config.sql.yml.tt +48 -0
  25. data/lib/generators/boring/ci/circleci/install/templates/database.yml.ci.tt +14 -0
  26. data/lib/generators/boring/ci/github_action/install/install_generator.rb +45 -0
  27. data/lib/generators/boring/ci/github_action/install/templates/ci.yml.tt +49 -0
  28. data/lib/generators/boring/ci/travisci/install/install_generator.rb +23 -0
  29. data/lib/generators/boring/ci/travisci/install/templates/.travis.yml.tt +35 -0
  30. data/lib/generators/boring/devise/install/install_generator.rb +75 -0
  31. data/lib/generators/boring/favicon/build/build_generator.rb +120 -0
  32. data/lib/generators/boring/favicon/build/templates/favicon.html.erb.tt +19 -0
  33. data/lib/generators/boring/font_awesome/ruby_gem/install/install_generator.rb +42 -0
  34. data/lib/generators/boring/font_awesome/yarn/install/install_generator.rb +53 -0
  35. data/lib/generators/boring/font_awesome/yarn/install/templates/application.scss +1 -0
  36. data/lib/generators/boring/graphql/install/install_generator.rb +51 -0
  37. data/lib/generators/boring/graphql/install/templates/base_resolver.rb +2 -0
  38. data/lib/generators/boring/graphql/install/templates/hello_world_resolver.rb +11 -0
  39. data/lib/generators/boring/jquery/install/install_generator.rb +32 -0
  40. data/lib/generators/boring/oauth/facebook/install/install_generator.rb +91 -0
  41. data/lib/generators/boring/oauth/facebook/install/templates/README +24 -0
  42. data/lib/generators/boring/oauth/facebook/install/templates/omniauth.rb +3 -0
  43. data/lib/generators/boring/oauth/facebook/install/templates/omniauth_callbacks_controller.rb +21 -0
  44. data/lib/generators/boring/pry/install/install_generator.rb +29 -0
  45. data/lib/generators/boring/pry/install/templates/pryrc +24 -0
  46. data/lib/generators/boring/pundit/install/install_generator.rb +85 -0
  47. data/lib/generators/boring/rubocop/install/install_generator.rb +37 -0
  48. data/lib/generators/boring/rubocop/install/templates/.rubocop.yml.tt +262 -0
  49. data/lib/generators/boring/simple_form/install/install_generator.rb +44 -0
  50. data/lib/generators/boring/tailwind/install/install_generator.rb +28 -20
  51. metadata +2527 -6
  52. data/.travis.yml +0 -6
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boring
4
+ module Ci
5
+ module Travisci
6
+ class InstallGenerator < Rails::Generators::Base
7
+ desc "Adds Github Action to the application"
8
+ source_root File.expand_path("templates", __dir__)
9
+
10
+ DEFAULT_RUBY_VERSION = "2.7.1"
11
+
12
+ class_option :ruby_version, type: :string, aliases: "-v",
13
+ desc: "Tell us the ruby version which you use for the application. Default to Ruby #{DEFAULT_RUBY_VERSION}"
14
+
15
+ def add_github_actions_configuration
16
+ @ruby_version = options[:ruby_version] ? options[:ruby_version] : DEFAULT_RUBY_VERSION
17
+
18
+ template(".travis.yml", ".travis.yml")
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,35 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - <%= @ruby_version %>
5
+
6
+ services:
7
+ - postgresql
8
+
9
+ cache:
10
+ bundler: true
11
+ directories:
12
+ - node_modules
13
+ yarn: true
14
+
15
+ env:
16
+ global:
17
+ - RAILS_ENV=test
18
+ - NODE_ENV=test
19
+
20
+ before_install:
21
+ - nvm install --lts
22
+
23
+ install:
24
+ - node -v
25
+ - yarn
26
+ - bundle
27
+
28
+ before_script:
29
+ - bundle install --jobs=3 --retry=3
30
+ - bundle exec rails db:create
31
+ - bundle exec rails db:schema:load
32
+
33
+ script:
34
+ - bundle exec rails db:schema:load
35
+ - bundle exec rails test
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boring
4
+ module Devise
5
+ class InstallGenerator < Rails::Generators::Base
6
+ desc "Adds devise to the application"
7
+
8
+ DEFAULT_DEVISE_MODEL_NAME = "User"
9
+
10
+ class_option :model_name, type: :string, aliases: "-m",
11
+ desc: "Tell us the user model name which will be used for authentication. Defaults to #{DEFAULT_DEVISE_MODEL_NAME}"
12
+ class_option :skip_devise_view, type: :boolean, aliases: "-sv",
13
+ desc: "Skip generating devise views"
14
+ class_option :skip_devise_model, type: :boolean, aliases: "-sm",
15
+ desc: "Skip generating devise model"
16
+
17
+ def add_devise_gem
18
+ say "Adding devise gem", :green
19
+ devise_gem = <<~RUBY
20
+ \n
21
+ # for authentication
22
+ gem 'devise', '~> 4.7'
23
+ RUBY
24
+ append_to_file "Gemfile", devise_gem
25
+ Bundler.with_unbundled_env do
26
+ run "bundle install"
27
+ end
28
+ end
29
+
30
+ def generating_devise_defaults
31
+ say "Generating devise defaults", :green
32
+ Bundler.with_unbundled_env do
33
+ run "DISABLE_SPRING=1 bundle exec rails generate devise:install"
34
+ end
35
+ end
36
+
37
+ def add_devise_action_mailer_development_config
38
+ say "Adding devise Action Mailer development configuration", :green
39
+ insert_into_file "config/environments/development.rb", <<~RUBY, after: /Rails.application.configure do/
40
+ \n
41
+ \tconfig.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
42
+ RUBY
43
+ end
44
+
45
+ def add_devise_user_model
46
+ return if options[:skip_devise_model]
47
+
48
+ say "Adding devise user model", :green
49
+ model_name = options[:model_name] || DEFAULT_DEVISE_MODEL_NAME
50
+
51
+ Bundler.with_unbundled_env do
52
+ run "DISABLE_SPRING=1 bundle exec rails generate devise #{model_name}"
53
+ end
54
+ end
55
+
56
+ def add_devise_authentication_filter_to_application_controller
57
+ insert_into_file "app/controllers/application_controller.rb", <<~RUBY, after: /class ApplicationController < ActionController::Base/
58
+ \n
59
+ \tbefore_action :authenticate_user!
60
+ RUBY
61
+ end
62
+
63
+ def add_devise_views
64
+ return if options[:skip_devise_view]
65
+
66
+ say "Adding devise views", :green
67
+ model_name = options[:model_name] || DEFAULT_DEVISE_MODEL_NAME
68
+
69
+ Bundler.with_unbundled_env do
70
+ run "DISABLE_SPRING=1 bundle exec rails generate devise:views #{model_name.pluralize}"
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,120 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boring
4
+ module Favicon
5
+ class BuildGenerator < Rails::Generators::Base
6
+ desc "Build favicons for all platforms"
7
+ source_root File.expand_path("templates", __dir__)
8
+
9
+ ICO_SIZES = %w(16 32)
10
+ APPLE_SIZES = %w(57 60 72 76 114 120 129 144 152)
11
+ APPLE_PRECOMPOSED_SIZES = %w(120 129 152)
12
+ SMALL_BREAK = 50
13
+ LARGE_BREAK = 150
14
+ MS_TILE_SIZES = %w(144)
15
+ FAVICON_DIR = "favicons"
16
+ FILE_FAVICO_DIR = "app/assets/images/#{FAVICON_DIR}"
17
+ DEFAULT_PRIMARY_COLOR = "#082472"
18
+ DEFAULT_FAVICON_LETTER = "B" # B for boring_generators :)
19
+ DEFAULT_IMAGE_PATH = "#{FILE_FAVICO_DIR}/template.png"
20
+
21
+ class_option :primary_color, type: :string, aliases: "-color",
22
+ desc: "Tell us the primary color to build favicon. Default to primary: #{DEFAULT_PRIMARY_COLOR}"
23
+ class_option :favico_letter, type: :string, aliases: "-letter",
24
+ desc: "Tell us the favicon letter to build favicon. Default to primary: #{DEFAULT_FAVICON_LETTER}"
25
+ class_option :font_file_path, type: :string, aliases: "-fp",
26
+ desc: "Tell us the font to be used generate favicon."
27
+ class_option :application_name, type: :string, aliases: "-app_name",
28
+ desc: "Tell us the application name to be used in favicon partial."
29
+
30
+ def build_favicon
31
+ @application_name = options[:application_name]
32
+ @primary_color = options[:primary_color]
33
+
34
+ unless /Version/m =~ (`convert -version`)
35
+ say <<~WARNING, :red
36
+ ERROR: You do not have ImageMagick installed.
37
+ WARNING
38
+ end
39
+ end
40
+
41
+ def create_favicon_directory
42
+ unless File.exists?(FILE_FAVICO_DIR)
43
+ Dir.mkdir FILE_FAVICO_DIR
44
+ end
45
+ end
46
+
47
+ def build_favicon_for_existing_template_image
48
+ return unless File.exist?(DEFAULT_IMAGE_PATH)
49
+
50
+ say "Converting template image to favicons..."
51
+ template_name = "#{FILE_FAVICO_DIR}/template.png"
52
+ template_small_name = "#{FILE_FAVICO_DIR}/template-small.png"
53
+ template_large_name = "#{FILE_FAVICO_DIR}/template-large.png"
54
+ template_small_name = template_name unless File.file?(template_small_name)
55
+ template_large_name = template_name unless File.file?(template_large_name)
56
+ ICO_SIZES.each do |size|
57
+ ico_template = template_name
58
+ ico_template = template_small_name if size.to_i <= SMALL_BREAK
59
+ ico_template = template_small_name if size.to_i >= LARGE_BREAK
60
+ (`convert #{ico_template} -resize #{size}x#{size} #{FILE_FAVICO_DIR}/favicon-#{size}x#{size}.ico`)
61
+ end
62
+ APPLE_SIZES.each do |size|
63
+ ico_template = template_name
64
+ ico_template = template_small_name if size.to_i <= SMALL_BREAK
65
+ ico_template = template_small_name if size.to_i >= LARGE_BREAK
66
+ (`convert #{ico_template} -resize #{size}x#{size} #{FILE_FAVICO_DIR}/apple-touch-icon-#{size}x#{size}.png`)
67
+ end
68
+ APPLE_PRECOMPOSED_SIZES.each do |size|
69
+ ico_template = template_name
70
+ ico_template = template_small_name if size.to_i <= SMALL_BREAK
71
+ ico_template = template_small_name if size.to_i >= LARGE_BREAK
72
+ (`convert #{ico_template} -resize #{size}x#{size} #{FILE_FAVICO_DIR}/apple-touch-icon-#{size}x#{size}-precomposed.png`)
73
+ end
74
+ MS_TILE_SIZES.each do |size|
75
+ ico_template = template_name
76
+ ico_template = template_small_name if size.to_i <= SMALL_BREAK
77
+ ico_template = template_small_name if size.to_i >= LARGE_BREAK
78
+ (`convert #{ico_template} -resize #{size}x#{size} #{FILE_FAVICO_DIR}/mstile-#{size}x#{size}.png`)
79
+ end
80
+ ico_template = template_name
81
+ ico_template = template_small_name if 152 <= SMALL_BREAK
82
+ ico_template = template_small_name if 152 >= LARGE_BREAK
83
+ (`convert #{ico_template} -resize 152x152 #{FILE_FAVICO_DIR}/apple-touch-icon.png`)
84
+ (`convert #{ico_template} -resize 152x152 #{FILE_FAVICO_DIR}/apple-touch-icon-precomposed.png`)
85
+ end
86
+
87
+ def generate_new_favicon_using_favico_letter
88
+ return if File.exist?(DEFAULT_IMAGE_PATH)
89
+ say "Creating favicons from application...", :green
90
+
91
+ favico_letter = options[:favico_letter] || @application_name.try(:first) || DEFAULT_FAVICON_LETTER
92
+ font_file_path = options[:font_file_path]
93
+ favicon_color = options[:primary_color] || DEFAULT_PRIMARY_COLOR
94
+
95
+ ICO_SIZES.each do |size|
96
+ (`convert -background "#{favicon_color}" -fill white -size #{size}x#{size} -gravity center #{font_file_path ? "-font #{font_file_path}" : ""} label:#{favico_letter} #{FILE_FAVICO_DIR}/favicon-#{size}x#{size}.ico`)
97
+ end
98
+ APPLE_SIZES.each do |size|
99
+ (`convert -background "#{favicon_color}" -fill white -size #{size}x#{size} -gravity center #{font_file_path ? "-font #{font_file_path}" : ""} label:#{favico_letter} #{FILE_FAVICO_DIR}/apple-touch-icon-#{size}x#{size}.png`)
100
+ end
101
+ APPLE_PRECOMPOSED_SIZES.each do |size|
102
+ (`convert -background "#{favicon_color}" -fill white -size #{size}x#{size} -gravity center #{font_file_path ? "-font #{font_file_path}" : ""} label:#{favico_letter} #{FILE_FAVICO_DIR}/apple-touch-icon-#{size}x#{size}-precomposed.png`)
103
+ end
104
+ MS_TILE_SIZES.each do |size|
105
+ (`convert -background "#{favicon_color}" -fill white -size #{size}x#{size} -gravity center #{font_file_path ? "-font #{font_file_path}" : ""} label:#{favico_letter} #{FILE_FAVICO_DIR}/mstile-#{size}x#{size}.png`)
106
+ end
107
+ (`convert -background "#{favicon_color}" -fill white -size 152x152 -gravity center #{font_file_path ? "-font #{font_file_path}" : ""} label:#{favico_letter} #{FILE_FAVICO_DIR}/apple-touch-icon.png`)
108
+ (`convert -background "#{favicon_color}" -fill white -size 152x152 -gravity center #{font_file_path ? "-font #{font_file_path}" : ""} label:#{favico_letter} #{FILE_FAVICO_DIR}/apple-touch-icon-precomposed.png`)
109
+ end
110
+
111
+ def add_favicon_partial
112
+ say "Copying favicon layout partial", :green
113
+ template("favicon.html.erb", "app/views/layouts/shared/_favicon.html.erb")
114
+ insert_into_file "app/views/layouts/application.html.erb", <<~RUBY, after: /head.*\n/
115
+ \t\t<%= render 'layouts/shared/favicon' %>
116
+ RUBY
117
+ end
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,19 @@
1
+ <%%= favicon_link_tag "favicons/favicon-16x16.ico", rel: 'shortcut icon', type: 'image/x-icon' %>
2
+ <%%= favicon_link_tag "favicons/favicon-32x32.ico", rel: 'shortcut icon', type: 'image/x-icon' %>
3
+ <%%= favicon_link_tag "favicons/apple-touch-icon-57x57.png", rel: 'apple-touch-icon', type: 'image/png', sizes: "57x57" %>
4
+ <%%= favicon_link_tag "favicons/apple-touch-icon-60x60.png", rel: 'apple-touch-icon', type: 'image/png', sizes: "60x60" %>
5
+ <%%= favicon_link_tag "favicons/apple-touch-icon-72x72.png", rel: 'apple-touch-icon', type: 'image/png', sizes: "72x72" %>
6
+ <%%= favicon_link_tag "favicons/apple-touch-icon-76x76.png", rel: 'apple-touch-icon', type: 'image/png', sizes: "76x76" %>
7
+ <%%= favicon_link_tag "favicons/apple-touch-icon-114x114.png", rel: 'apple-touch-icon', type: 'image/png', sizes: "114x114" %>
8
+ <%%= favicon_link_tag "favicons/apple-touch-icon-120x120.png", rel: 'apple-touch-icon', type: 'image/png', sizes: "120x120" %>
9
+ <%%= favicon_link_tag "favicons/apple-touch-icon-129x129.png", rel: 'apple-touch-icon', type: 'image/png', sizes: "129x129" %>
10
+ <%%= favicon_link_tag "favicons/apple-touch-icon-144x144.png", rel: 'apple-touch-icon', type: 'image/png', sizes: "144x144" %>
11
+ <%%= favicon_link_tag "favicons/apple-touch-icon-152x152.png", rel: 'apple-touch-icon', type: 'image/png', sizes: "152x152" %>
12
+ <%%= favicon_link_tag "favicons/apple-touch-icon.png", rel: 'apple-touch-icon', type: 'image/png' %>
13
+ <%%= favicon_link_tag "favicons/apple-touch-icon-120x120-precomposed.png", rel: 'apple-touch-icon-precomposed', type: 'image/png', sizes: "120x120" %>
14
+ <%%= favicon_link_tag "favicons/apple-touch-icon-129x129-precomposed.png", rel: 'apple-touch-icon-precomposed', type: 'image/png', sizes: "129x129" %>
15
+ <%%= favicon_link_tag "favicons/apple-touch-icon-152x152-precomposed.png", rel: 'apple-touch-icon-precomposed', type: 'image/png', sizes: "152x152" %>
16
+ <%%= favicon_link_tag "favicons/apple-touch-icon-precomposed.png", rel: 'apple-touch-icon-precomposed', type: 'image/png' %>
17
+ <meta name="msapplication-TileImage" content="<%%= image_path("favicons/mstile-144x144.png") %>" />
18
+ <meta name="msapplication-TileColor" content="<%= @primary_color %>" />
19
+ <meta name="application-name" content="<%= @application_name %>">
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boring
4
+ module FontAwesome
5
+ module RubyGem
6
+ class InstallGenerator < Rails::Generators::Base
7
+ desc "Adds fontawesome via yarn to the application"
8
+
9
+ def add_font_awesome_sass_gem
10
+ say "Adding font_awesome_sass gem", :green
11
+
12
+ font_awesome_sass_gem = <<~RUBY
13
+ \n
14
+ # for adding font-awesome icons
15
+ gem 'font-awesome-sass', '~> 5.13'
16
+ RUBY
17
+ append_to_file "Gemfile", font_awesome_sass_gem
18
+ run "bundle install"
19
+ end
20
+
21
+ def import_font_awesome_stylesheet
22
+ say "Adding font awesome stylesheets", :green
23
+ stylesheet_font_awesome_imports = <<~RUBY
24
+ \n
25
+ @import "font-awesome-sprockets";
26
+ @import "font-awesome";
27
+ RUBY
28
+
29
+ if File.exist?("app/assets/stylesheets/application.css.scss")
30
+ append_to_file "app/assets/stylesheets/application.css.scss", stylesheet_font_awesome_imports
31
+ elsif File.exist?("app/assets/stylesheets/application.scss")
32
+ append_to_file "app/assets/stylesheets/application.scss", stylesheet_font_awesome_imports
33
+ else
34
+ say <<~WARNING, :red
35
+ ERROR: Looks like the application.css.scss is missing. Please rename the file and re-run the generator.
36
+ WARNING
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boring
4
+ module FontAwesome
5
+ module Yarn
6
+ class InstallGenerator < Rails::Generators::Base
7
+ source_root File.expand_path("templates", __dir__)
8
+ desc "Adds fontawesome via rubygems to the application"
9
+
10
+ def add_font_awesome_package
11
+ say "Adding fontawesome packages", :green
12
+ run "yarn add @fortawesome/fontawesome-free"
13
+ end
14
+
15
+ def import_font_awesome_stylesheet
16
+ say "Adding font awesome stylesheets", :green
17
+ if File.exist?("app/javascript/stylesheets/application.scss")
18
+ stylesheet_font_awesome_imports = <<~RUBY
19
+ \n
20
+ @import '@fortawesome/fontawesome-free';
21
+ RUBY
22
+
23
+ append_to_file "app/javascript/stylesheets/application.scss", stylesheet_font_awesome_imports
24
+ else
25
+ say "Copying application.scss with FontAwesome imports", :green
26
+ template("application.scss", "app/javascript/stylesheets/application.scss")
27
+ end
28
+ end
29
+
30
+ def import_font_awesome_javascript
31
+ if File.exist?("app/javascript/packs/application.js")
32
+ javascript_font_awesome_imports = <<~RUBY
33
+ \n
34
+ import "@fortawesome/fontawesome-free/js/all"
35
+ RUBY
36
+
37
+ append_to_file "app/javascript/packs/application.js", javascript_font_awesome_imports
38
+ else
39
+ say <<~WARNING, :red
40
+ ERROR: Looks like the webpacker installation is incomplete. Could not find application.js in app/javascript/packs.
41
+ WARNING
42
+ end
43
+ end
44
+
45
+ def insert_stylesheet_packs_tag
46
+ insert_into_file "app/views/layouts/application.html.erb", <<~RUBY, after: /stylesheet_link_tag.*\n/
47
+ \t\t<%= stylesheet_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
48
+ RUBY
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1 @@
1
+ @import '@fortawesome/fontawesome-free';
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Boring
4
+ module Graphql
5
+ class InstallGenerator < Rails::Generators::Base
6
+ desc "Adds GraphQL to the application"
7
+ source_root File.expand_path("templates", __dir__)
8
+
9
+ OPTIONS = %w(relay batch playground no-graphiql schema)
10
+
11
+ class_option :skip_resolver_setup, type: :boolean, aliases: "-s",
12
+ desc: "Skips adding GraphQL resolver setup to the application"
13
+
14
+ def add_graphql_gem
15
+ say "Adding graphql gem", :green
16
+ graphql_gem = <<~RUBY
17
+ \n
18
+ # for building APIs
19
+ gem 'graphql', '~> 1.11'
20
+ RUBY
21
+ append_to_file "Gemfile", graphql_gem
22
+ run "bundle install"
23
+ end
24
+
25
+ def run_graphql_generator
26
+ say "Running GraphQL default generator", :green
27
+ run "bundle exec rails generate graphql:install"
28
+ run "bundle install"
29
+
30
+ graphiql_precompile_assets = <<~RUBY
31
+ \n
32
+ if Rails.env.development?
33
+ Rails.application.config.assets.precompile += %w[graphiql/rails/application.js graphiql/rails/application.css]
34
+ end
35
+ RUBY
36
+ append_to_file "config/initializers/assets.rb", graphiql_precompile_assets
37
+ end
38
+
39
+ def adds_graphql_resolver
40
+ return if options[:skip_resolver_setup]
41
+ template("base_resolver.rb", "app/graphql/resolvers/base_resolver.rb")
42
+ template("hello_world_resolver.rb", "app/graphql/resolvers/hello_world_resolver.rb")
43
+
44
+ insert_into_file "app/graphql/types/query_type.rb", <<~RUBY, after: /class QueryType < Types::BaseObject\n/
45
+ \t\t# TODO: remove me
46
+ \t\tfield :hello, resolver: Resolvers::HelloWorldResolver
47
+ RUBY
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,2 @@
1
+ class Resolvers::BaseResolver < GraphQL::Schema::Resolver
2
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Resolvers::HelloWorldResolver < Resolvers::BaseResolver
4
+ description "Returns hello world"
5
+
6
+ type String, null: false
7
+
8
+ def resolve
9
+ "Hello World"
10
+ end
11
+ end