rails-interactive 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/cli/config/categories.yml +12 -7
- data/lib/cli/config/commands.yml +13 -1
- data/lib/cli/templates/setup_capybara.rb +24 -0
- data/lib/cli/templates/setup_devise.rb +6 -1
- data/lib/cli/templates/setup_minitest.rb +5 -0
- data/lib/cli/templates/setup_omniauth.rb +20 -13
- data/lib/cli/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5f8f264844d295476f2a3a1b5321d4a24efd197385a3e46476b9e6912fdd35d
|
4
|
+
data.tar.gz: 0a305f3ddd4307d3380034b784d5a2e8f2e708c65be9039b5603e479a0e29fbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11ba30482ac8c3892b7c103fd2e11e4e92fe6cf9fad851f264e526d2af50c2e2203240aabe18b4fcdccf0846a6f5d9fbe5773990d11fef9100d2d40875346f64
|
7
|
+
data.tar.gz: e3b1de0b4b081528d4a0260531e0ec30814d55da0b5e543e0b4dcece30954a3376593be483f14ddb191c52cb4f0a7ea8da940acb008c3a21ccbee68b8e5454f6
|
data/Gemfile.lock
CHANGED
@@ -15,37 +15,42 @@
|
|
15
15
|
type: "select"
|
16
16
|
required: false
|
17
17
|
-
|
18
|
-
name:
|
18
|
+
name: end_to_end_testing
|
19
19
|
weight: 4
|
20
20
|
type: "select"
|
21
21
|
required: false
|
22
22
|
-
|
23
|
-
name:
|
23
|
+
name: template_engine
|
24
24
|
weight: 5
|
25
25
|
type: "select"
|
26
26
|
required: false
|
27
27
|
-
|
28
|
-
name:
|
28
|
+
name: code_quality
|
29
29
|
weight: 6
|
30
30
|
type: "select"
|
31
31
|
required: false
|
32
32
|
-
|
33
|
-
name:
|
33
|
+
name: background_job
|
34
34
|
weight: 7
|
35
35
|
type: "select"
|
36
36
|
required: false
|
37
37
|
-
|
38
|
-
name:
|
38
|
+
name: security
|
39
39
|
weight: 8
|
40
40
|
type: "select"
|
41
41
|
required: false
|
42
42
|
-
|
43
|
-
name:
|
43
|
+
name: admin_panel
|
44
44
|
weight: 9
|
45
|
+
type: "select"
|
46
|
+
required: false
|
47
|
+
-
|
48
|
+
name: features
|
49
|
+
weight: 10
|
45
50
|
type: "multi_select"
|
46
51
|
required: false
|
47
52
|
-
|
48
53
|
name: development
|
49
|
-
weight:
|
54
|
+
weight: 11
|
50
55
|
type: "multi_select"
|
51
56
|
required: false
|
data/lib/cli/config/commands.yml
CHANGED
@@ -139,4 +139,16 @@
|
|
139
139
|
description: "The administration framework for Ruby on Rails applications. For details: https://github.com/activeadmin/activeadmin"
|
140
140
|
dependencies:
|
141
141
|
- sassc_rails
|
142
|
-
- devise
|
142
|
+
- devise
|
143
|
+
-
|
144
|
+
identifier: minitest
|
145
|
+
name: MiniTest ( Default )
|
146
|
+
category: testing
|
147
|
+
description: "minitest provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking. For details: https://github.com/minitest/minitest"
|
148
|
+
dependencies: null
|
149
|
+
-
|
150
|
+
identifier: capybara
|
151
|
+
name: Capybara
|
152
|
+
category: end_to_end_testing
|
153
|
+
description: "Acceptance test framework for web applications. For details: https://github.com/teamcapybara/capybara"
|
154
|
+
dependencies: null
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
gem_group :development, :test do
|
4
|
+
gem "capybara"
|
5
|
+
end
|
6
|
+
|
7
|
+
Bundler.with_unbundled_env { run "bundle install" }
|
8
|
+
|
9
|
+
if defined? RSpec
|
10
|
+
inject_into_file "spec/spec_helper.rb", before: "RSpec.configure do |config|" do
|
11
|
+
<<~RB
|
12
|
+
require 'capybara/rspec'
|
13
|
+
RB
|
14
|
+
end
|
15
|
+
elsif defined? MiniTest && !defined? RSpec
|
16
|
+
inject_into_file "test/test_helper.rb", before: "class ActiveSupport::TestCase" do
|
17
|
+
<<~RB
|
18
|
+
require 'capybara/rails'
|
19
|
+
require 'capybara/minitest'
|
20
|
+
RB
|
21
|
+
end
|
22
|
+
else
|
23
|
+
puts "No test framework detected or related test framework does not exist in RailsInteractive"
|
24
|
+
end
|
@@ -5,6 +5,11 @@ Bundler.with_unbundled_env { run "bundle install" }
|
|
5
5
|
|
6
6
|
rails_command "generate devise:install"
|
7
7
|
|
8
|
-
|
8
|
+
model_name = ask("What do you want to call your Devise model?")
|
9
|
+
model_name = model_name.empty? ? "user" : model_name
|
10
|
+
|
11
|
+
File.open("devise-model.txt", "w") { |f| f.write(model_name) }
|
12
|
+
|
13
|
+
run "rails generate devise #{model_name.capitalize}"
|
9
14
|
run "rails db:prepare"
|
10
15
|
run "rails db:migrate"
|
@@ -1,30 +1,36 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "fileutils"
|
4
|
+
|
3
5
|
run "bundle add omniauth"
|
4
6
|
|
5
7
|
run "bundle install"
|
6
8
|
|
9
|
+
devise_model_name = File.read("devise-model.txt")
|
10
|
+
FileUtils.rm("devise-model.txt")
|
11
|
+
|
7
12
|
# rubocop:disable Layout/LineLength
|
8
|
-
rails_command "generate model identity
|
13
|
+
rails_command "generate model identity #{devise_model_name}:references provider:string:index uid:string:index token:string:index refresh_token:string:index"
|
9
14
|
# rubocop:enable Layout/LineLength
|
10
15
|
|
11
|
-
rails_command "generate migration
|
16
|
+
rails_command "generate migration AddIdentityTo#{devise_model_name.capitalize}s identities_count:integer"
|
12
17
|
|
13
18
|
rails_command "db:migrate"
|
14
19
|
|
15
|
-
inject_into_file "config/routes.rb", after: "devise_for
|
16
|
-
" # devise_for
|
20
|
+
inject_into_file "config/routes.rb", after: "devise_for :#{devise_model_name}s\n" do
|
21
|
+
" # devise_for :#{devise_model_name}s, controllers: { omniauth_callbacks: 'omniauth' }"
|
17
22
|
end
|
18
23
|
|
19
|
-
inject_into_file "app/models
|
24
|
+
inject_into_file "app/models/#{devise_model_name}.rb", after: ":database_authenticatable, " do
|
20
25
|
":omniauthable, "
|
21
26
|
end
|
22
27
|
|
23
|
-
inject_into_file "app/models/identity.rb", after: "belongs_to
|
28
|
+
inject_into_file "app/models/identity.rb", after: "belongs_to :#{devise_model_name}" do
|
24
29
|
", counter_cache: true"
|
25
30
|
end
|
26
31
|
|
27
|
-
inject_into_file "app/models
|
32
|
+
inject_into_file "app/models/#{devise_model_name}.rb",
|
33
|
+
after: "class #{devise_model_name.capitalize} < ApplicationRecord\n" do
|
28
34
|
# rubocop:disable Naming/HeredocDelimiterNaming
|
29
35
|
<<-EOF
|
30
36
|
has_many :identities, dependent: :destroy
|
@@ -36,15 +42,15 @@ inject_into_file "app/models/user.rb", after: "class User < ApplicationRecord\n"
|
|
36
42
|
identity.token = auth.credentials.token
|
37
43
|
identity.refresh_token = auth.credentials.refresh_token
|
38
44
|
end
|
39
|
-
if identity.
|
40
|
-
user =
|
45
|
+
if identity.#{devise_model_name}.nil? && auth.info.email.present?
|
46
|
+
user = #{devise_model_name}.where(email: auth.info.email).first_or_initialize
|
41
47
|
user.name = auth.info.name
|
42
48
|
user.password = Devise.friendly_token if user.new_record?
|
43
49
|
user.save!
|
44
|
-
identity
|
50
|
+
identity.#{devise_model_name} = user
|
45
51
|
end
|
46
52
|
identity.save!
|
47
|
-
identity
|
53
|
+
identity.#{devise_model_name}
|
48
54
|
end
|
49
55
|
end
|
50
56
|
|
@@ -57,5 +63,6 @@ file "app/controllers/omniauth_controller.rb", <<~CODE
|
|
57
63
|
|
58
64
|
end
|
59
65
|
CODE
|
60
|
-
|
61
|
-
puts "IMPORTANT: Add devise_for
|
66
|
+
# rubocop:disable Layout/LineLength
|
67
|
+
puts "IMPORTANT: Add devise_for :#{devise_model_name}s, controllers: { omniauth_callbacks: 'omniauth' } to your routes.rb"
|
68
|
+
# rubocop:enable Layout/LineLength
|
data/lib/cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-interactive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oguzhan Ince
|
@@ -177,6 +177,7 @@ files:
|
|
177
177
|
- lib/cli/templates/setup_brakeman.rb
|
178
178
|
- lib/cli/templates/setup_bullet.rb
|
179
179
|
- lib/cli/templates/setup_cancancan.rb
|
180
|
+
- lib/cli/templates/setup_capybara.rb
|
180
181
|
- lib/cli/templates/setup_devise.rb
|
181
182
|
- lib/cli/templates/setup_faker.rb
|
182
183
|
- lib/cli/templates/setup_friendly_id.rb
|
@@ -184,6 +185,7 @@ files:
|
|
184
185
|
- lib/cli/templates/setup_haml.rb
|
185
186
|
- lib/cli/templates/setup_kaminari.rb
|
186
187
|
- lib/cli/templates/setup_letter_opener.rb
|
188
|
+
- lib/cli/templates/setup_minitest.rb
|
187
189
|
- lib/cli/templates/setup_omniauth.rb
|
188
190
|
- lib/cli/templates/setup_pundit.rb
|
189
191
|
- lib/cli/templates/setup_rails_admin.rb
|