boring_generators 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75b70f624969fe4703d011e6eb9885aec618fa1292ed919610a151257126bbf0
4
- data.tar.gz: e34d25d853079666eeb09c4a5c27b306f4a8a835a8d5e3f300ad7a126eb81b23
3
+ metadata.gz: 66c4c0c7499756d66e0d992e4ec79ad105f310b40384a49d99b1a3f96ebfaeab
4
+ data.tar.gz: '074778686e124d14e6010e6a886b209484abf2774e0836e48631c900738f3ae8'
5
5
  SHA512:
6
- metadata.gz: 042b85804c5a7fc75f79596d55ab2ca4ec688268781717dbb2d02755bc5b9d40ffe17b60951f46fb2c2365c8560c466b4161a029f2d3da1e8987f6306d1bd6ee
7
- data.tar.gz: a643190096fbd0c4b78e798547219f56d1877e4f91110ff8919448c56a77a7c9a8d4170eadfc70353615e73b886fb6101bfabea290f6b52ad4b815c068096609
6
+ metadata.gz: 44e5a7cfde50201a16ce39cd6c1e28618efe002229e81f15613278bdfdb5f448a4d02532d974b7fe232742cd5d6b5c55ac9aa851b84cad8bc90c1cb7c9efdb77
7
+ data.tar.gz: 7ec572ba9730632511e08d4aa6a943a8c97db89ae93c0b5d2db4813b9ece7ac53b586b1690d2f636d1bd7fcff6c46572501ec69752af1008b43c949e1789e456
@@ -0,0 +1,12 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4
+ patreon: # Replace with a single Patreon username
5
+ open_collective: boring_generators
6
+ ko_fi: # Replace with a single Ko-fi username
7
+ tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ liberapay: # Replace with a single Liberapay username
10
+ issuehunt: # Replace with a single IssueHunt username
11
+ otechie: # Replace with a single Otechie username
12
+ custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
@@ -1,6 +1,14 @@
1
1
  # Changelog
2
2
 
3
3
  ## master (unreleased)
4
+
5
+ ## 0.6.0 (January 10th, 2021)
6
+ * Updates default ruby version of GitHub Actions install generator. ([@jamesglover][])
7
+ * Simplify generated GitHub Actions install ([@jamesglover][])
8
+ * Adds boring generator CLI ([@luathn][])
9
+ * Adds Devise Facebook Omniauth generator. ([@abhaynikam][])
10
+
11
+ ## 0.5.0 (December 20th, 2020)
4
12
  * Adds favicon build generator. ([@abhaynikam][])
5
13
  * Adds Pundit install generator. ([@CiTroNaK][])
6
14
  * Adds GraphQL generator. ([@abhaynikam][])
@@ -34,3 +42,5 @@
34
42
 
35
43
  [@abhaynikam]: https://github.com/abhaynikam
36
44
  [@CiTroNaK]: https://github.com/CiTroNaK
45
+ [@jamesglover]: https://github.com/JamesGlover
46
+ [@luathn]: https://github.com/luathn
data/Gemfile CHANGED
@@ -3,6 +3,11 @@ source "https://rubygems.org"
3
3
  # Specify your gem's dependencies in boring_generators.gemspec
4
4
  gemspec
5
5
 
6
+ gem "rails", "~> 6.0.3.4"
6
7
  gem "rake", "~> 12.0"
7
8
  gem "minitest", "~> 5.0"
8
9
  gem "byebug"
10
+
11
+ platforms :ruby do
12
+ gem "sqlite3", "~> 1.4"
13
+ end
@@ -1,12 +1,29 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- boring_generators (0.4.0)
4
+ boring_generators (0.5.0)
5
5
  railties
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ actioncable (6.0.3.4)
11
+ actionpack (= 6.0.3.4)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (>= 0.6.1)
14
+ actionmailbox (6.0.3.4)
15
+ actionpack (= 6.0.3.4)
16
+ activejob (= 6.0.3.4)
17
+ activerecord (= 6.0.3.4)
18
+ activestorage (= 6.0.3.4)
19
+ activesupport (= 6.0.3.4)
20
+ mail (>= 2.7.1)
21
+ actionmailer (6.0.3.4)
22
+ actionpack (= 6.0.3.4)
23
+ actionview (= 6.0.3.4)
24
+ activejob (= 6.0.3.4)
25
+ mail (~> 2.5, >= 2.5.4)
26
+ rails-dom-testing (~> 2.0)
10
27
  actionpack (6.0.3.4)
11
28
  actionview (= 6.0.3.4)
12
29
  activesupport (= 6.0.3.4)
@@ -14,12 +31,31 @@ GEM
14
31
  rack-test (>= 0.6.3)
15
32
  rails-dom-testing (~> 2.0)
16
33
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
34
+ actiontext (6.0.3.4)
35
+ actionpack (= 6.0.3.4)
36
+ activerecord (= 6.0.3.4)
37
+ activestorage (= 6.0.3.4)
38
+ activesupport (= 6.0.3.4)
39
+ nokogiri (>= 1.8.5)
17
40
  actionview (6.0.3.4)
18
41
  activesupport (= 6.0.3.4)
19
42
  builder (~> 3.1)
20
43
  erubi (~> 1.4)
21
44
  rails-dom-testing (~> 2.0)
22
45
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
46
+ activejob (6.0.3.4)
47
+ activesupport (= 6.0.3.4)
48
+ globalid (>= 0.3.6)
49
+ activemodel (6.0.3.4)
50
+ activesupport (= 6.0.3.4)
51
+ activerecord (6.0.3.4)
52
+ activemodel (= 6.0.3.4)
53
+ activesupport (= 6.0.3.4)
54
+ activestorage (6.0.3.4)
55
+ actionpack (= 6.0.3.4)
56
+ activejob (= 6.0.3.4)
57
+ activerecord (= 6.0.3.4)
58
+ marcel (~> 0.3.1)
23
59
  activesupport (6.0.3.4)
24
60
  concurrent-ruby (~> 1.0, >= 1.0.2)
25
61
  i18n (>= 0.7, < 2)
@@ -30,20 +66,44 @@ GEM
30
66
  byebug (11.1.3)
31
67
  concurrent-ruby (1.1.7)
32
68
  crass (1.0.6)
33
- erubi (1.9.0)
69
+ erubi (1.10.0)
70
+ globalid (0.4.2)
71
+ activesupport (>= 4.2.0)
34
72
  i18n (1.8.5)
35
73
  concurrent-ruby (~> 1.0)
36
- loofah (2.7.0)
74
+ loofah (2.8.0)
37
75
  crass (~> 1.0.2)
38
76
  nokogiri (>= 1.5.9)
77
+ mail (2.7.1)
78
+ mini_mime (>= 0.1.1)
79
+ marcel (0.3.3)
80
+ mimemagic (~> 0.3.2)
39
81
  method_source (1.0.0)
82
+ mimemagic (0.3.5)
83
+ mini_mime (1.0.2)
40
84
  mini_portile2 (2.4.0)
41
85
  minitest (5.14.2)
86
+ nio4r (2.5.4)
42
87
  nokogiri (1.10.10)
43
88
  mini_portile2 (~> 2.4.0)
44
89
  rack (2.2.3)
45
90
  rack-test (1.1.0)
46
91
  rack (>= 1.0, < 3)
92
+ rails (6.0.3.4)
93
+ actioncable (= 6.0.3.4)
94
+ actionmailbox (= 6.0.3.4)
95
+ actionmailer (= 6.0.3.4)
96
+ actionpack (= 6.0.3.4)
97
+ actiontext (= 6.0.3.4)
98
+ actionview (= 6.0.3.4)
99
+ activejob (= 6.0.3.4)
100
+ activemodel (= 6.0.3.4)
101
+ activerecord (= 6.0.3.4)
102
+ activestorage (= 6.0.3.4)
103
+ activesupport (= 6.0.3.4)
104
+ bundler (>= 1.3.0)
105
+ railties (= 6.0.3.4)
106
+ sprockets-rails (>= 2.0.0)
47
107
  rails-dom-testing (2.0.3)
48
108
  activesupport (>= 4.2.0)
49
109
  nokogiri (>= 1.6)
@@ -56,11 +116,22 @@ GEM
56
116
  rake (>= 0.8.7)
57
117
  thor (>= 0.20.3, < 2.0)
58
118
  rake (12.3.3)
119
+ sprockets (4.0.2)
120
+ concurrent-ruby (~> 1.0)
121
+ rack (> 1, < 3)
122
+ sprockets-rails (3.2.2)
123
+ actionpack (>= 4.0)
124
+ activesupport (>= 4.0)
125
+ sprockets (>= 3.0.0)
126
+ sqlite3 (1.4.2)
59
127
  thor (1.0.1)
60
128
  thread_safe (0.3.6)
61
- tzinfo (1.2.7)
129
+ tzinfo (1.2.9)
62
130
  thread_safe (~> 0.1)
63
- zeitwerk (2.4.0)
131
+ websocket-driver (0.7.3)
132
+ websocket-extensions (>= 0.1.0)
133
+ websocket-extensions (0.1.5)
134
+ zeitwerk (2.4.2)
64
135
 
65
136
  PLATFORMS
66
137
  ruby
@@ -69,7 +140,9 @@ DEPENDENCIES
69
140
  boring_generators!
70
141
  byebug
71
142
  minitest (~> 5.0)
143
+ rails (~> 6.0.3.4)
72
144
  rake (~> 12.0)
145
+ sqlite3 (~> 1.4)
73
146
 
74
147
  BUNDLED WITH
75
148
  2.1.4
data/README.md CHANGED
@@ -32,6 +32,11 @@ Or install it yourself as:
32
32
 
33
33
  $ gem install boring_generators
34
34
 
35
+ And then you can use it this way:
36
+
37
+ $ boring generate boring:simple_form:install --css_framework=<css_framework>
38
+ $ boring g boring:pry:install
39
+
35
40
  ## Usage
36
41
 
37
42
  The boring generator introduces following generators:
@@ -55,11 +60,17 @@ The boring generator introduces following generators:
55
60
  - Install GraphQL: `rails generate boring:graphql:install`
56
61
  - Install SimpleForm: `rails generate boring:simple_form:install --css_framework=<css_framework>`
57
62
  - Install Devise: `rails generate boring:devise:install`
63
+ - Install Devise Facebook Omniauth: `rails generate boring:oauth:facebook:install`
58
64
 
59
65
  ## Development
60
66
 
61
67
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
62
68
 
69
+ You can also run specific test cases using following commands:
70
+ ```
71
+ bundle exec ruby -w -Itest test/generators/tailwind_install_generator_test.rb
72
+ ```
73
+
63
74
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
64
75
 
65
76
  ## Contributing
@@ -27,5 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
29
 
30
- spec.add_dependency 'railties'
30
+ spec.add_dependency "railties"
31
31
  end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/boring_generators/cli"
4
+
5
+ BoringGenerators::CLI.start(ARGV)
@@ -1,4 +1,5 @@
1
1
  require "boring_generators/version"
2
+ require 'bundler'
2
3
 
3
4
  module BoringGenerators
4
5
  class Error < StandardError; end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+ require "rails/generators"
3
+ require_relative "../boring_generators"
4
+
5
+ module BoringGenerators
6
+ class CLI < Thor
7
+ map "g" => :generate
8
+ map %w(--version -v) => :__print_version
9
+
10
+ desc "generate GENERATOR [options]", "Add gem to the application"
11
+ def generate(generator, *options)
12
+ Rails::Generators.invoke(generator, options)
13
+ end
14
+
15
+ desc "--version, -v", "Print gem version"
16
+ def __print_version
17
+ puts "Boring generators #{BoringGenerators::VERSION}"
18
+ end
19
+
20
+ class << self
21
+ def exit_on_failure?
22
+ true
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module BoringGenerators
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -7,12 +7,14 @@ module Boring
7
7
  desc "Adds Github Action to the application"
8
8
  source_root File.expand_path("templates", __dir__)
9
9
 
10
- DEFAULT_RUBY_VERSION = "2.7.1"
10
+ RUBY_VERSION_FILE = ".ruby-version"
11
+
12
+ DEFAULT_RUBY_VERSION = ".ruby-version"
11
13
  DEFAULT_NODE_VERSION = "10.13.0"
12
14
  DEFAULT_REPOSITORY_NAME = "boring_generators"
13
15
 
14
16
  class_option :ruby_version, type: :string, aliases: "-v",
15
- desc: "Tell us the ruby version which you use for the application. Default to Ruby #{DEFAULT_RUBY_VERSION}"
17
+ desc: "Tell us the ruby version which you use for the application. Default to Ruby #{DEFAULT_RUBY_VERSION}, which will cause the action to use the version specified in the #{RUBY_VERSION_FILE} file."
16
18
  class_option :node_version, type: :string, aliases: "-v",
17
19
  desc: "Tell us the node version which you use for the application. Default to Node #{DEFAULT_NODE_VERSION}"
18
20
  class_option :repository_name, type: :string, aliases: "-rn",
@@ -24,6 +26,18 @@ module Boring
24
26
  @repository_name = options[:repository_name] ? options[:repository_name] : DEFAULT_REPOSITORY_NAME
25
27
 
26
28
  template("ci.yml", ".github/workflows/ci.yml")
29
+
30
+ if @ruby_version == DEFAULT_RUBY_VERSION && !ruby_version_file_exists?
31
+ say <<~WARNING, :red
32
+ WARNING: The action was configured to use the ruby version specified in the .ruby-version
33
+ file, but no such file was present. Either create an appropriate .ruby-version file, or
34
+ update .github/workflows/ci.yml to use an explicit ruby version.
35
+ WARNING
36
+ end
37
+ end
38
+
39
+ def ruby_version_file_exists?
40
+ Pathname.new(destination_root).join(RUBY_VERSION_FILE).exist?
27
41
  end
28
42
  end
29
43
  end
@@ -20,17 +20,7 @@ jobs:
20
20
  uses: ruby/setup-ruby@v1
21
21
  with:
22
22
  ruby-version: <%= @ruby_version %>
23
- - name: Ruby gem cache
24
- uses: actions/cache@v1
25
- with:
26
- path: vendor/bundle
27
- key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
28
- restore-keys: |
29
- ${{ runner.os }}-gems-
30
- - name: Install gems
31
- run: |
32
- bundle config path vendor/bundle
33
- bundle install --jobs 4 --retry 3
23
+ bundler-cache: true
34
24
  - name: Setup Node
35
25
  uses: actions/setup-node@v1
36
26
  with:
@@ -22,12 +22,16 @@ module Boring
22
22
  gem 'devise', '~> 4.7'
23
23
  RUBY
24
24
  append_to_file "Gemfile", devise_gem
25
- run "bundle install"
25
+ Bundler.with_unbundled_env do
26
+ run "bundle install"
27
+ end
26
28
  end
27
29
 
28
30
  def generating_devise_defaults
29
31
  say "Generating devise defaults", :green
30
- run "DISABLE_SPRING=1 rails generate devise:install"
32
+ Bundler.with_unbundled_env do
33
+ run "DISABLE_SPRING=1 bundle exec rails generate devise:install"
34
+ end
31
35
  end
32
36
 
33
37
  def add_devise_action_mailer_development_config
@@ -44,7 +48,9 @@ module Boring
44
48
  say "Adding devise user model", :green
45
49
  model_name = options[:model_name] || DEFAULT_DEVISE_MODEL_NAME
46
50
 
47
- run "DISABLE_SPRING=1 rails generate devise #{model_name}"
51
+ Bundler.with_unbundled_env do
52
+ run "DISABLE_SPRING=1 bundle exec rails generate devise #{model_name}"
53
+ end
48
54
  end
49
55
 
50
56
  def add_devise_authentication_filter_to_application_controller
@@ -60,7 +66,9 @@ module Boring
60
66
  say "Adding devise views", :green
61
67
  model_name = options[:model_name] || DEFAULT_DEVISE_MODEL_NAME
62
68
 
63
- run "rails generate devise:views #{model_name.pluralize}"
69
+ Bundler.with_unbundled_env do
70
+ run "DISABLE_SPRING=1 bundle exec rails generate devise:views #{model_name.pluralize}"
71
+ end
64
72
  end
65
73
  end
66
74
  end
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler'
4
+
5
+ module Boring
6
+ module Oauth
7
+ module Facebook
8
+ class InstallGenerator < Rails::Generators::Base
9
+ class MissingDeviseConfigurationError < StandardError; end
10
+
11
+ desc "Adds facebook OmniAuth to the application"
12
+ source_root File.expand_path("templates", __dir__)
13
+
14
+ def add_facebook_omniauth_gem
15
+ say "Adding Facebook OmniAuth gem", :green
16
+ facebook_omniauth_gem = <<~RUBY
17
+ \n
18
+ # for omniauth facebook
19
+ gem 'omniauth-facebook', '~> 8.0'
20
+ RUBY
21
+ append_to_file "Gemfile", facebook_omniauth_gem
22
+ Bundler.with_unbundled_env do
23
+ run "bundle install"
24
+ end
25
+ end
26
+
27
+ def add_provider_and_uuid_user_details
28
+ say "Adding migration to add provider and uuid columns to users", :green
29
+ Bundler.with_unbundled_env do
30
+ run "DISABLE_SPRING=1 bundle exec rails generate migration AddOmniauthToUsers provider:string uid:string"
31
+ end
32
+ end
33
+
34
+ def configure_devise_omniauth_facebook
35
+ say "Adding omniauth devise configuration", :green
36
+ if File.exist?("config/initializers/devise.rb")
37
+ insert_into_file "config/initializers/devise.rb", <<~RUBY, after: /Devise.setup do \|config\|/
38
+ \n
39
+ \tconfig.omniauth :facebook, "APP_ID", "APP_SECRET"
40
+ RUBY
41
+ else
42
+ raise MissingDeviseConfigurationError, <<~ERROR
43
+ Looks like the devise installation is incomplete. Could not find devise.rb in config/initializers.
44
+ ERROR
45
+ end
46
+ end
47
+
48
+ def add_omniauth_callback_routes
49
+ devise_route = '# devise_for :users, controllers: { omniauth_callbacks: "users/omniauth_callbacks" }'.dup
50
+ route devise_route
51
+ end
52
+
53
+ def add_omniauth_callback_controller
54
+ say "Copying omniauth_callbacks_controller.rb", :green
55
+ template("omniauth_callbacks_controller.rb", "app/controllers/users/omniauth_callbacks_controller.rb")
56
+ end
57
+
58
+ def configure_and_add_devise_setting_in_user_model
59
+ say "Configuring facebook omniauth for user model", :green
60
+ insert_into_file "app/models/user.rb", <<~RUBY, after: /class User < ApplicationRecord/
61
+
62
+ \tdevise :omniauthable, omniauth_providers: %i[facebook]
63
+
64
+ \tdef self.from_omniauth(auth)
65
+ \twhere(provider: auth.provider, uid: auth.uid).first_or_create do |user|
66
+ \tuser.email = auth.info.email
67
+ \tuser.password = Devise.friendly_token[0, 20]
68
+ \tuser.name = auth.info.name # assuming the user model has a name
69
+ \t# user.image = auth.info.image # assuming the user model has an image
70
+ \t# If you are using confirmable and the provider(s) you use validate emails,
71
+ \t# uncomment the line below to skip the confirmation emails.
72
+ \t# user.skip_confirmation!
73
+ \tend
74
+ \tend
75
+ RUBY
76
+ end
77
+
78
+ def add_the_facebook_devise_omniauth_view
79
+ insert_into_file "app/views/users/sessions/new.html.erb", <<~RUBY, after: /<%= render "users\/shared\/links" %>/
80
+
81
+ <%= link_to "Sign in with Facebook", user_facebook_omniauth_authorize_path %>
82
+ RUBY
83
+ end
84
+
85
+ def show_readme
86
+ readme "README"
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end