boring_generators 0.5.0 → 0.10.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 +4 -4
- data/.github/FUNDING.yml +12 -0
- data/.github/workflows/ci.yml +7 -1
- data/CHANGELOG.md +27 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +94 -21
- data/README.md +27 -6
- data/Rakefile +1 -0
- data/boring_generators.gemspec +1 -1
- data/exe/boring +5 -0
- data/lib/boring_generators.rb +1 -0
- data/lib/boring_generators/cli.rb +26 -0
- data/lib/boring_generators/version.rb +1 -1
- data/lib/generators/boring/active_storage/aws/install/install_generator.rb +10 -8
- data/lib/generators/boring/active_storage/azure/install/install_generator.rb +9 -7
- data/lib/generators/boring/active_storage/google/install/install_generator.rb +9 -7
- data/lib/generators/boring/ahoy/install/install_generator.rb +31 -0
- data/lib/generators/boring/ahoy/install/templates/README +10 -0
- data/lib/generators/boring/audit/install/install_generator.rb +12 -9
- data/lib/generators/boring/bullet/install/install_generator.rb +4 -8
- data/lib/generators/boring/ci/github_action/install/install_generator.rb +16 -2
- data/lib/generators/boring/ci/github_action/install/templates/ci.yml.tt +1 -11
- data/lib/generators/boring/devise/install/install_generator.rb +12 -10
- data/lib/generators/boring/font_awesome/ruby_gem/install/install_generator.rb +3 -8
- data/lib/generators/boring/graphql/install/install_generator.rb +3 -7
- data/lib/generators/boring/oauth/base_generator.rb +63 -0
- data/lib/generators/boring/oauth/facebook/install/install_generator.rb +36 -0
- data/lib/generators/boring/oauth/facebook/install/templates/README +23 -0
- data/lib/generators/boring/oauth/facebook/install/templates/omniauth.rb +3 -0
- data/lib/generators/boring/oauth/facebook/install/templates/omniauth_callbacks_controller.rb +21 -0
- data/lib/generators/boring/oauth/github/install/install_generator.rb +36 -0
- data/lib/generators/boring/oauth/github/install/templates/README +23 -0
- data/lib/generators/boring/oauth/github/install/templates/omniauth_callbacks_controller.rb +21 -0
- data/lib/generators/boring/oauth/google/install/install_generator.rb +36 -0
- data/lib/generators/boring/oauth/google/install/templates/README +23 -0
- data/lib/generators/boring/oauth/google/install/templates/omniauth_callbacks_controller.rb +21 -0
- data/lib/generators/boring/oauth/twitter/install/install_generator.rb +36 -0
- data/lib/generators/boring/oauth/twitter/install/templates/README +23 -0
- data/lib/generators/boring/oauth/twitter/install/templates/omniauth_callbacks_controller.rb +21 -0
- data/lib/generators/boring/payments/stripe/install/install_generator.rb +43 -0
- data/lib/generators/boring/payments/stripe/install/templates/README +21 -0
- data/lib/generators/boring/payments/stripe/install/templates/controllers/stripe/checkouts_controller.rb +63 -0
- data/lib/generators/boring/payments/stripe/install/templates/stripe.rb +1 -0
- data/lib/generators/boring/payments/stripe/install/templates/views/stripe/checkouts/create.js.erb +13 -0
- data/lib/generators/boring/payments/stripe/install/templates/views/stripe/checkouts/show.html.erb +8 -0
- data/lib/generators/boring/pry/install/install_generator.rb +4 -9
- data/lib/generators/boring/pundit/install/install_generator.rb +3 -9
- data/lib/generators/boring/rubocop/install/install_generator.rb +3 -1
- data/lib/generators/boring/simple_form/install/install_generator.rb +4 -8
- data/lib/generators/boring/tailwind/install/install_generator.rb +12 -11
- data/lib/generators/boring/tailwind/install/templates/README +13 -0
- data/lib/generators/boring/twilio/install/install_generator.rb +26 -0
- data/lib/generators/boring/twilio/install/templates/README +11 -0
- data/lib/generators/boring/twilio/install/templates/twilio.rb +4 -0
- metadata +33 -664
@@ -0,0 +1,21 @@
|
|
1
|
+
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
2
|
+
# See https://github.com/omniauth/omniauth/wiki/FAQ#rails-session-is-clobbered-after-callback-on-developer-strategy
|
3
|
+
skip_before_action :verify_authenticity_token, only: :github
|
4
|
+
|
5
|
+
def github
|
6
|
+
# You need to implement the method below in your model (e.g. app/models/user.rb)
|
7
|
+
@user = User.from_omniauth(request.env["omniauth.auth"])
|
8
|
+
|
9
|
+
if @user.persisted?
|
10
|
+
sign_in_and_redirect @user, event: :authentication #this will throw if @user is not activated
|
11
|
+
set_flash_message(:notice, :success, kind: "GitHub") if is_navigational_format?
|
12
|
+
else
|
13
|
+
session["devise.github_data"] = request.env["omniauth.auth"].except(:extra) # Removing extra as it can overflow some session stores
|
14
|
+
redirect_to new_user_registration_url
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def failure
|
19
|
+
redirect_to root_path
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler'
|
4
|
+
require 'generators/boring/oauth/base_generator'
|
5
|
+
|
6
|
+
module Boring
|
7
|
+
module Oauth
|
8
|
+
module Google
|
9
|
+
class InstallGenerator < Rails::Generators::Base
|
10
|
+
include Boring::Oauth::BaseGenerator
|
11
|
+
|
12
|
+
class MissingDeviseConfigurationError < StandardError; end
|
13
|
+
|
14
|
+
desc "Adds Google OmniAuth to the application"
|
15
|
+
source_root File.expand_path("templates", __dir__)
|
16
|
+
|
17
|
+
def add_github_omniauth_gem
|
18
|
+
say "Adding GitHub OmniAuth gem", :green
|
19
|
+
Bundler.with_unbundled_env do
|
20
|
+
run "bundle add omniauth-google-oauth2"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def invoke_common_generator_methods
|
25
|
+
@oauth_name = :google_oauth2
|
26
|
+
add_provider_and_uuid_user_details
|
27
|
+
configure_devise_omniauth
|
28
|
+
add_omniauth_callback_routes
|
29
|
+
add_omniauth_callback_controller
|
30
|
+
configure_and_add_devise_setting_in_user_model
|
31
|
+
show_readme
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
===============================================================================
|
2
|
+
|
3
|
+
Some setup you must do manually if you haven't yet:
|
4
|
+
|
5
|
+
1. Ensure you have overridden or uncommented the routes for generated omniauth callback controllers in your routes.rb.
|
6
|
+
For example:
|
7
|
+
|
8
|
+
Rails.application.routes.draw do
|
9
|
+
devise_for :users, controllers: {
|
10
|
+
omniauth_callbacks: "users/omniauth_callbacks"
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
2. Update the devise google omniauth APP_ID and APP_SECRET in "config/initializers/devise.rb"
|
15
|
+
after registering the Rails application on: https://code.google.com/apis/console/
|
16
|
+
For example:
|
17
|
+
|
18
|
+
config.omniauth :google_auth, "APP_ID", "APP_SECRET"
|
19
|
+
|
20
|
+
3. Your omniauth callback URL will be: `<host>/users/auth/google_oauth2/callback`. Please update
|
21
|
+
callback URL in Google after registering your omniauth application.
|
22
|
+
|
23
|
+
===============================================================================
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
2
|
+
# See https://github.com/omniauth/omniauth/wiki/FAQ#rails-session-is-clobbered-after-callback-on-developer-strategy
|
3
|
+
skip_before_action :verify_authenticity_token, only: :google_auth
|
4
|
+
|
5
|
+
def google_auth
|
6
|
+
# You need to implement the method below in your model (e.g. app/models/user.rb)
|
7
|
+
@user = User.from_omniauth(request.env["omniauth.auth"])
|
8
|
+
|
9
|
+
if @user.persisted?
|
10
|
+
sign_in_and_redirect @user, event: :authentication #this will throw if @user is not activated
|
11
|
+
set_flash_message(:notice, :success, kind: "Google") if is_navigational_format?
|
12
|
+
else
|
13
|
+
session["devise.google_data"] = request.env["omniauth.auth"].except(:extra) # Removing extra as it can overflow some session stores
|
14
|
+
redirect_to new_user_registration_url
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def failure
|
19
|
+
redirect_to root_path
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler'
|
4
|
+
require 'generators/boring/oauth/base_generator'
|
5
|
+
|
6
|
+
module Boring
|
7
|
+
module Oauth
|
8
|
+
module Twitter
|
9
|
+
class InstallGenerator < Rails::Generators::Base
|
10
|
+
include Boring::Oauth::BaseGenerator
|
11
|
+
|
12
|
+
class MissingDeviseConfigurationError < StandardError; end
|
13
|
+
|
14
|
+
desc "Adds Twitter OmniAuth to the application"
|
15
|
+
source_root File.expand_path("templates", __dir__)
|
16
|
+
|
17
|
+
def add_twitter_omniauth_gem
|
18
|
+
say "Adding Twitter OmniAuth gem", :green
|
19
|
+
Bundler.with_unbundled_env do
|
20
|
+
run "bundle add omniauth-twitter"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def invoke_common_generator_methods
|
25
|
+
@oauth_name = :twitter
|
26
|
+
add_provider_and_uuid_user_details
|
27
|
+
configure_devise_omniauth
|
28
|
+
add_omniauth_callback_routes
|
29
|
+
add_omniauth_callback_controller
|
30
|
+
configure_and_add_devise_setting_in_user_model
|
31
|
+
show_readme
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
===============================================================================
|
2
|
+
|
3
|
+
Some setup you must do manually if you haven't yet:
|
4
|
+
|
5
|
+
1. Ensure you have overridden or uncommented the routes for generated omniauth callback controllers in your routes.rb.
|
6
|
+
For example:
|
7
|
+
|
8
|
+
Rails.application.routes.draw do
|
9
|
+
devise_for :users, controllers: {
|
10
|
+
omniauth_callbacks: "users/omniauth_callbacks"
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
2. Update the devise twitter omniauth APP_ID and APP_SECRET in "config/initializers/devise.rb"
|
15
|
+
after registering the Rails application on: https://developer.twitter.com/en/apps
|
16
|
+
For example:
|
17
|
+
|
18
|
+
config.omniauth :twitter, "APP_ID", "APP_SECRET"
|
19
|
+
|
20
|
+
3. Your omniauth callback URL will be: `<host>/users/auth/twitter/callback`. Please update
|
21
|
+
callback URL in Twitter after registering your omniauth application.
|
22
|
+
|
23
|
+
===============================================================================
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
2
|
+
# See https://github.com/omniauth/omniauth/wiki/FAQ#rails-session-is-clobbered-after-callback-on-developer-strategy
|
3
|
+
skip_before_action :verify_authenticity_token, only: :twitter
|
4
|
+
|
5
|
+
def twitter
|
6
|
+
# You need to implement the method below in your model (e.g. app/models/user.rb)
|
7
|
+
@user = User.from_omniauth(request.env["omniauth.auth"])
|
8
|
+
|
9
|
+
if @user.persisted?
|
10
|
+
sign_in_and_redirect @user, event: :authentication #this will throw if @user is not activated
|
11
|
+
set_flash_message(:notice, :success, kind: "Twitter") if is_navigational_format?
|
12
|
+
else
|
13
|
+
session["devise.twitter_data"] = request.env["omniauth.auth"].except(:extra) # Removing extra as it can overflow some session stores
|
14
|
+
redirect_to new_user_registration_url
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def failure
|
19
|
+
redirect_to root_path
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Boring
|
4
|
+
module Payments
|
5
|
+
module Stripe
|
6
|
+
class InstallGenerator < Rails::Generators::Base
|
7
|
+
desc "Adds stripe payment method to the application"
|
8
|
+
source_root File.expand_path("templates", __dir__)
|
9
|
+
|
10
|
+
def add_stripe_gem
|
11
|
+
say "Adding stripe gem", :green
|
12
|
+
Bundler.with_unbundled_env do
|
13
|
+
run "bundle add stripe"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_checkouts_resources
|
18
|
+
say "Adding stripe checkout resources"
|
19
|
+
copy_file("controllers/stripe/checkouts_controller.rb", "app/controllers/stripe/checkouts_controller.rb")
|
20
|
+
copy_file("views/stripe/checkouts/create.js.erb", "app/views/stripe/checkouts/create.js.erb")
|
21
|
+
copy_file("views/stripe/checkouts/show.html.erb", "app/views/stripe/checkouts/show.html.erb")
|
22
|
+
end
|
23
|
+
|
24
|
+
def add_stripe_routes
|
25
|
+
route <<~ROUTE
|
26
|
+
namespace :stripe do
|
27
|
+
resource :checkout, only: [:create, :show]
|
28
|
+
end
|
29
|
+
ROUTE
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_stripe_initializer
|
33
|
+
say "Adding stripe initalizers"
|
34
|
+
copy_file("stripe.rb", "config/initializers/stripe.rb")
|
35
|
+
end
|
36
|
+
|
37
|
+
def show_readme
|
38
|
+
readme "README"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
===============================================================================
|
2
|
+
|
3
|
+
Some setup you must do manually if you haven't yet:
|
4
|
+
|
5
|
+
1. Register your Rails application on: https://dashboard.stripe.com/register
|
6
|
+
2. Update the stripe PUBLISHABLE_KEY in "config/initializers/stripe.rb"
|
7
|
+
For example:
|
8
|
+
|
9
|
+
Stripe.api_key = ENV['STRIPE_SECRET_KEY']
|
10
|
+
|
11
|
+
3. Update stripe PUBLISHABLE_KEY in the "views/stripe/checkouts/create.js.erb"
|
12
|
+
For example:
|
13
|
+
|
14
|
+
var stripe = Stripe(ENV["STRIPE_PUBLISHABLE_KEY"]);
|
15
|
+
|
16
|
+
4. Update "controllers/stripe/checkouts_controller.rb" with stripe checkout
|
17
|
+
line_items, success and failure callback URLs.
|
18
|
+
|
19
|
+
5. Go to: http://localhost:3000/stripe/checkout and try the checkout flow.
|
20
|
+
|
21
|
+
===============================================================================
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Stripe::CheckoutsController < ApplicationController
|
4
|
+
def create
|
5
|
+
begin
|
6
|
+
@stripe_session = Stripe::Checkout::Session.create(checkout_payload)
|
7
|
+
|
8
|
+
respond_to :js
|
9
|
+
rescue Stripe::CardError => e
|
10
|
+
puts "Status is: #{e.http_status}"
|
11
|
+
puts "Type is: #{e.error.type}"
|
12
|
+
puts "Charge ID is: #{e.error.charge}"
|
13
|
+
# The following fields are optional
|
14
|
+
puts "Code is: #{e.error.code}" if e.error.code
|
15
|
+
puts "Decline code is: #{e.error.decline_code}" if e.error.decline_code
|
16
|
+
puts "Param is: #{e.error.param}" if e.error.param
|
17
|
+
puts "Message is: #{e.error.message}" if e.error.message
|
18
|
+
rescue Stripe::RateLimitError => e
|
19
|
+
# Too many requests made to the API too quickly
|
20
|
+
rescue Stripe::InvalidRequestError => e
|
21
|
+
# Invalid parameters were supplied to Stripe's API
|
22
|
+
rescue Stripe::AuthenticationError => e
|
23
|
+
# Authentication with Stripe's API failed
|
24
|
+
# (maybe you changed API keys recently)
|
25
|
+
rescue Stripe::APIConnectionError => e
|
26
|
+
# Network communication with Stripe failed
|
27
|
+
rescue Stripe::StripeError => e
|
28
|
+
# Display a very generic error to the user, and maybe send
|
29
|
+
# yourself an email
|
30
|
+
rescue => e
|
31
|
+
# Something else happened, completely unrelated to Stripe
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def show
|
36
|
+
render
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
# In the payload, the line items consists of list of items the customer is purchasing.
|
41
|
+
# Refer the guides to learn more about parameters accepted by the <line_items>
|
42
|
+
# https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items
|
43
|
+
#
|
44
|
+
# Sample: <line_items> looks like as follows:
|
45
|
+
# line_items: [{
|
46
|
+
# price_data: {
|
47
|
+
# currency: 'usd', # Three-letter ISO currency code, in lowercase
|
48
|
+
# product: <product_id> # Product ID created on stripe.
|
49
|
+
# product_data: { name: 'T-shirt' }, # Product Data (Either product_data or product is requried).
|
50
|
+
# unit_amount: 2000, # A non-negative integer in cents representing how much to charge
|
51
|
+
# },
|
52
|
+
# quantity: 1,
|
53
|
+
# }]
|
54
|
+
def checkout_payload
|
55
|
+
{
|
56
|
+
payment_method_types: ['card'], # https://stripe.com/docs/api/payment_methods/object#payment_method_object-type
|
57
|
+
line_items: @line_items || [],
|
58
|
+
mode: 'payment',
|
59
|
+
success_url: root_url, # <custom_success_path>
|
60
|
+
cancel_url: root_url, # <custom_cancellation_path>
|
61
|
+
}
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Stripe.api_key = ENV['STRIPE_SECRET_KEY']
|
data/lib/generators/boring/payments/stripe/install/templates/views/stripe/checkouts/create.js.erb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
// TODO: Please update the stripe publishable key here.
|
2
|
+
var stripe = Stripe(ENV["STRIPE_PUBLISHABLE_KEY"]);
|
3
|
+
|
4
|
+
stripe.redirectToCheckout({
|
5
|
+
sessionId: "<%= @stripe_session.id %>"
|
6
|
+
}).then(function(result) {
|
7
|
+
// If `redirectToCheckout` fails due to a browser or network
|
8
|
+
// error, you should display the localized error message to your
|
9
|
+
// customer using `error.message`.
|
10
|
+
if (result.error) {
|
11
|
+
alert(result.error.message);
|
12
|
+
}
|
13
|
+
});
|
data/lib/generators/boring/payments/stripe/install/templates/views/stripe/checkouts/show.html.erb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<div style="text-align:center;">
|
2
|
+
<h1>Checkout View</h1>
|
3
|
+
<h5>(from <a href="https://github.com/abhaynikam/boring_generators">Boring Generator Gem</a>)</h5>
|
4
|
+
|
5
|
+
<%= button_to "Try Checkout", stripe_checkout_path, remote: true, class: "btn btn-primary" %>
|
6
|
+
<script src="https://js.stripe.com/v3/"></script>
|
7
|
+
</div>
|
8
|
+
|
@@ -7,15 +7,10 @@ module Boring
|
|
7
7
|
source_root File.expand_path("templates", __dir__)
|
8
8
|
|
9
9
|
def add_bullet_gem
|
10
|
-
say "Adding
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
gem "pry"
|
15
|
-
gem "pry-rails"
|
16
|
-
RUBY
|
17
|
-
append_to_file "Gemfile", pry_gem_content
|
18
|
-
run "bundle install"
|
10
|
+
say "Adding pry gems", :green
|
11
|
+
Bundler.with_unbundled_env do
|
12
|
+
run "bundle add pry pry-rails"
|
13
|
+
end
|
19
14
|
end
|
20
15
|
|
21
16
|
def add_pryrc_configuration
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'bundler'
|
4
|
-
|
5
3
|
module Boring
|
6
4
|
module Pundit
|
7
5
|
class InstallGenerator < Rails::Generators::Base
|
@@ -16,13 +14,9 @@ module Boring
|
|
16
14
|
|
17
15
|
def add_pundit_gem
|
18
16
|
say "Adding Pundit gem", :green
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
gem 'pundit', '~> 2.1'
|
23
|
-
RUBY
|
24
|
-
append_to_file "Gemfile", pundit_gem
|
25
|
-
run "bundle install"
|
17
|
+
Bundler.with_unbundled_env do
|
18
|
+
run "bundle add pundit"
|
19
|
+
end
|
26
20
|
end
|
27
21
|
|
28
22
|
def run_pundit_generator
|
@@ -23,7 +23,9 @@ module Boring
|
|
23
23
|
\tgem "rubocop-performance", require: false
|
24
24
|
RUBY
|
25
25
|
insert_into_file "Gemfile", bullet_gem_content, after: /group :development do/
|
26
|
-
|
26
|
+
Bundler.with_unbundled_env do
|
27
|
+
run "bundle install"
|
28
|
+
end
|
27
29
|
end
|
28
30
|
|
29
31
|
def add_rails_prefered_rubocop_rules
|
@@ -15,13 +15,9 @@ module Boring
|
|
15
15
|
|
16
16
|
def add_bullet_gem
|
17
17
|
say "Adding SimpleForm gem", :green
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
gem 'simple_form', '~> 5.0'
|
22
|
-
RUBY
|
23
|
-
append_to_file "Gemfile", simple_form_content
|
24
|
-
run "bundle install"
|
18
|
+
Bundler.with_unbundled_env do
|
19
|
+
run "bundle add simple_form"
|
20
|
+
end
|
25
21
|
end
|
26
22
|
|
27
23
|
def run_simple_form_generator
|
@@ -29,7 +25,7 @@ module Boring
|
|
29
25
|
|
30
26
|
say "Running SimpleForm Generator", :green
|
31
27
|
if options[:css_framework].present? && ALLOWED_CSS_FRAMEWORK.include?(options[:css_framework])
|
32
|
-
run "rails generate simple_form:install --#{options[:css_framework]}"
|
28
|
+
run "DISABLE_SPRING=1 bundle exec rails generate simple_form:install --#{options[:css_framework]}"
|
33
29
|
elsif options[:css_framework].present?
|
34
30
|
say <<~WARNING, :red
|
35
31
|
ERROR: Invalid option css_framework: #{options[:css_framework]}. Generator allows css_framework: #{ALLOWED_CSS_FRAMEWORK.join(", ")}
|
@@ -6,18 +6,12 @@ module Boring
|
|
6
6
|
desc "Adds Tailwind CSS to the application"
|
7
7
|
source_root File.expand_path("templates", __dir__)
|
8
8
|
|
9
|
-
class_option :skip_tailwind_css_ui, type: :boolean, aliases: "-sui",
|
10
|
-
desc: "Skip adding @tailwindcss/ui package"
|
11
9
|
class_option :skip_tailwind_init_full, type: :boolean, aliases: "-sif",
|
12
10
|
desc: "Skip running tailwindcss init with --full option"
|
13
11
|
|
14
12
|
def add_tailwind_package
|
15
13
|
say "Adding tailwind package", :green
|
16
|
-
|
17
|
-
run "yarn add tailwindcss"
|
18
|
-
else
|
19
|
-
run "yarn add tailwindcss @tailwindcss/ui"
|
20
|
-
end
|
14
|
+
run "yarn add tailwindcss@latest postcss@latest autoprefixer@latest"
|
21
15
|
end
|
22
16
|
|
23
17
|
def create_tailwind_config
|
@@ -54,9 +48,12 @@ module Boring
|
|
54
48
|
|
55
49
|
def insert_stylesheet_in_the_application
|
56
50
|
if File.exist?("app/javascript/packs/application.js")
|
57
|
-
|
58
|
-
|
59
|
-
|
51
|
+
stylesheet_tailwind_imports = <<~RUBY
|
52
|
+
\n
|
53
|
+
import "stylesheets/application"
|
54
|
+
RUBY
|
55
|
+
|
56
|
+
append_to_file "app/javascript/packs/application.js", stylesheet_tailwind_imports
|
60
57
|
else
|
61
58
|
say <<~WARNING, :red
|
62
59
|
ERROR: Looks like the webpacker installation is incomplete. Could not find application.js in app/javascript/packs.
|
@@ -69,6 +66,10 @@ module Boring
|
|
69
66
|
\t\t<%= stylesheet_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
|
70
67
|
RUBY
|
71
68
|
end
|
69
|
+
|
70
|
+
def show_readme
|
71
|
+
readme "README"
|
72
|
+
end
|
72
73
|
end
|
73
74
|
end
|
74
|
-
end
|
75
|
+
end
|