rails-interactive 0.1.3 → 0.1.6
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 +2 -0
- data/.github/workflows/main.yml +23 -3
- data/Gemfile.lock +3 -3
- data/README.md +1 -1
- data/lib/rails_interactive/message.rb +1 -4
- data/lib/rails_interactive/prompt.rb +2 -0
- data/lib/rails_interactive/templates/setup_brakeman.rb +6 -0
- data/lib/rails_interactive/templates/setup_cancancan.rb +7 -0
- data/lib/rails_interactive/templates/setup_devise.rb +10 -0
- data/lib/rails_interactive/templates/setup_omniauth.rb +61 -0
- data/lib/rails_interactive/templates/setup_pundit.rb +15 -0
- data/lib/rails_interactive/templates/setup_sidekiq.rb +32 -0
- data/lib/rails_interactive/version.rb +1 -1
- data/lib/rails_interactive.rb +17 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1131b1845ea01796436e2f9b8365bf7ca6cacd48684b365e9f877fe9281d8793
|
4
|
+
data.tar.gz: 75513f09d007ee151c3d2f0300185eba131c3ae6aa4de8cb85f0df78af9873e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64401e715a895a69224790cea8172f2638f0f57201439ae610b736fafb406867096b439c4f5881bbd435e8df8a59ea21113df4ed2e7ea846cfd33b846c2c7010
|
7
|
+
data.tar.gz: e313ffb15b81f39b7275389f935b2a38a6a3ef72a6bc4fd77653ff0d3c6cf06030309e399daaa9bb8bd8b2aa767b54eb4de2ec27e28fbfb2203073f46143d608
|
data/.github/FUNDING.yml
ADDED
data/.github/workflows/main.yml
CHANGED
@@ -14,24 +14,44 @@ jobs:
|
|
14
14
|
check-name: 'Run tests'
|
15
15
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
16
16
|
wait-interval: 10
|
17
|
-
-
|
17
|
+
- uses: GoogleCloudPlatform/release-please-action@v2
|
18
|
+
id: release
|
19
|
+
with:
|
20
|
+
release-type: ruby
|
21
|
+
package-name: rails-interactive
|
22
|
+
version-file: 'lib/rails_interactive/version.rb'
|
23
|
+
- uses: actions/checkout@v2
|
24
|
+
if: ${{ steps.release.outputs.release_created }}
|
25
|
+
- name: Set up Ruby
|
18
26
|
uses: ruby/setup-ruby@v1
|
27
|
+
if: ${{ steps.release.outputs.release_created }}
|
19
28
|
with:
|
20
29
|
ruby-version: 3.0.2
|
21
30
|
bundler-cache: true
|
31
|
+
- name: Bundle Install
|
32
|
+
run: bundle install
|
33
|
+
if: ${{ steps.release.outputs.release_created }}
|
22
34
|
- name: Set Credentials
|
23
35
|
run: |
|
24
36
|
mkdir -p $HOME/.gem
|
25
37
|
touch $HOME/.gem/credentials
|
26
38
|
chmod 0600 $HOME/.gem/credentials
|
27
|
-
printf -- "---\n:github: Bearer ${
|
28
|
-
printf -- "---\n:rubygems_api_key: ${
|
39
|
+
printf -- "---\n:github: Bearer ${GITHUB_TOKEN}\n" > $HOME/.gem/credentials
|
40
|
+
printf -- "---\n:rubygems_api_key: ${RUBYGEMS_TOKEN}\n" > $HOME/.gem/credentials
|
41
|
+
if: ${{ steps.release.outputs.release_created }}
|
42
|
+
env:
|
43
|
+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
44
|
+
RUBYGEMS_TOKEN: '${{secrets.RUBYGEMS_TOKEN}}'
|
29
45
|
- name: Publish to GitHub Packages
|
30
46
|
run: |
|
31
47
|
export OWNER=$( echo ${{ github.repository }} | cut -d "/" -f 1 )
|
32
48
|
gem build *.gemspec
|
33
49
|
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
50
|
+
gem push *.gem
|
51
|
+
if: ${{ steps.release.outputs.release_created }}
|
34
52
|
- name: Publish to RubyGems
|
35
53
|
run: |
|
36
54
|
gem build *.gemspec
|
55
|
+
gem push --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
37
56
|
gem push *.gem
|
57
|
+
if: ${{ steps.release.outputs.release_created }}
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rails-interactive (0.1.
|
4
|
+
rails-interactive (0.1.6)
|
5
5
|
tty-prompt
|
6
6
|
|
7
7
|
GEM
|
@@ -111,9 +111,9 @@ GEM
|
|
111
111
|
net-protocol
|
112
112
|
timeout
|
113
113
|
nio4r (2.5.8)
|
114
|
-
nokogiri (1.13.
|
114
|
+
nokogiri (1.13.4-x86_64-darwin)
|
115
115
|
racc (~> 1.4)
|
116
|
-
nokogiri (1.13.
|
116
|
+
nokogiri (1.13.4-x86_64-linux)
|
117
117
|
racc (~> 1.4)
|
118
118
|
parallel (1.21.0)
|
119
119
|
parser (3.1.1.0)
|
data/README.md
CHANGED
@@ -32,10 +32,7 @@ module RailsInteractive
|
|
32
32
|
def self.prepare
|
33
33
|
puts ""
|
34
34
|
puts "Project created successfully ✅".colorize(:green)
|
35
|
-
puts "Go to your project folder and
|
36
|
-
puts "> bundle install && yarn".colorize(:yellow)
|
37
|
-
puts "After that, ready to go 🎉".colorize(:green)
|
38
|
-
|
35
|
+
puts "Go to your project folder and ready to go 🎉".colorize(:green)
|
39
36
|
rails_commands
|
40
37
|
end
|
41
38
|
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
run "bundle add omniauth"
|
4
|
+
|
5
|
+
run "bundle install"
|
6
|
+
|
7
|
+
# rubocop:disable Layout/LineLength
|
8
|
+
rails_command "generate model identity user:references provider:string:index uid:string:index token:string:index refresh_token:string:index"
|
9
|
+
# rubocop:enable Layout/LineLength
|
10
|
+
|
11
|
+
rails_command "generate migration AddIdentityToUsers identities_count:integer"
|
12
|
+
|
13
|
+
rails_command "db:migrate"
|
14
|
+
|
15
|
+
inject_into_file "config/routes.rb", after: "devise_for :users\n" do
|
16
|
+
" # devise_for :users, controllers: { omniauth_callbacks: 'omniauth' }"
|
17
|
+
end
|
18
|
+
|
19
|
+
inject_into_file "app/models/user.rb", after: ":database_authenticatable, " do
|
20
|
+
":omniauthable, "
|
21
|
+
end
|
22
|
+
|
23
|
+
inject_into_file "app/models/identity.rb", after: "belongs_to :user" do
|
24
|
+
", counter_cache: true"
|
25
|
+
end
|
26
|
+
|
27
|
+
inject_into_file "app/models/user.rb", after: "class User < ApplicationRecord\n" do
|
28
|
+
# rubocop:disable Naming/HeredocDelimiterNaming
|
29
|
+
<<-EOF
|
30
|
+
has_many :identities, dependent: :destroy
|
31
|
+
|
32
|
+
def self.from_omniauth(auth)
|
33
|
+
if auth.present? && auth.provider.present? && auth.uid.present?
|
34
|
+
identity = Identity.where(provider: auth.provider, uid: auth.uid).first_or_initialize
|
35
|
+
if auth.credentials.present?
|
36
|
+
identity.token = auth.credentials.token
|
37
|
+
identity.refresh_token = auth.credentials.refresh_token
|
38
|
+
end
|
39
|
+
if identity.user.nil? && auth.info.email.present?
|
40
|
+
user = User.where(email: auth.info.email).first_or_initialize
|
41
|
+
user.name = auth.info.name
|
42
|
+
user.password = Devise.friendly_token if user.new_record?
|
43
|
+
user.save!
|
44
|
+
identity.user = user
|
45
|
+
end
|
46
|
+
identity.save!
|
47
|
+
identity.user
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
EOF
|
52
|
+
# rubocop:enable Naming/HeredocDelimiterNaming
|
53
|
+
end
|
54
|
+
|
55
|
+
file "app/controllers/omniauth_controller.rb", <<~CODE
|
56
|
+
class OmniauthController < Devise::OmniauthCallbacksController
|
57
|
+
|
58
|
+
end
|
59
|
+
CODE
|
60
|
+
|
61
|
+
puts "IMPORTANT: Add devise_for :users, controllers: { omniauth_callbacks: 'omniauth' } to your routes.rb"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
run "bundle add pundit"
|
4
|
+
|
5
|
+
puts "Add - Pundit module to Application Controller"
|
6
|
+
puts ""
|
7
|
+
|
8
|
+
inject_into_file "app/controllers/application_controller.rb",
|
9
|
+
after: "class ApplicationController < ActionController::Base\n" do
|
10
|
+
" include Pundit\n"
|
11
|
+
end
|
12
|
+
|
13
|
+
puts "Run - Pundit Generator"
|
14
|
+
|
15
|
+
rails_command("generate pundit:install")
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
def file_contains?(filename, string)
|
4
|
+
File.foreach(filename).detect { |line| line.include?(string) }
|
5
|
+
end
|
6
|
+
|
7
|
+
run "bundle add sidekiq"
|
8
|
+
run "bundle add redis" unless file_contains? "Gemfile", "Gem 'redis'"
|
9
|
+
|
10
|
+
Bundler.with_unbundled_env { run "bundle install" }
|
11
|
+
|
12
|
+
# rubocop:disable Naming/HeredocDelimiterNaming
|
13
|
+
application do
|
14
|
+
<<~EOF
|
15
|
+
config.active_job.queue_adapter = :sidekiq
|
16
|
+
EOF
|
17
|
+
end
|
18
|
+
|
19
|
+
inject_into_file "config/routes.rb" do
|
20
|
+
<<~EOF
|
21
|
+
require "sidekiq/web"
|
22
|
+
if Rails.env.production?
|
23
|
+
Sidekiq::Web.use Rack::Auth::Basic do |username, password|
|
24
|
+
ActiveSupport::SecurityUtils.secure_compare(::Digest::SHA256.hexdigest(username), ::Digest::SHA256.hexdigest(ENV["SIDEKIQ_USERNAME"])) &
|
25
|
+
ActiveSupport::SecurityUtils.secure_compare(::Digest::SHA256.hexdigest(password), ::Digest::SHA256.hexdigest(ENV["SIDEKIQ_PASSWORD"]))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
EOF
|
29
|
+
end
|
30
|
+
# rubocop:enable Naming/HeredocDelimiterNaming
|
31
|
+
|
32
|
+
route 'mount Sidekiq::Web => "/sidekiq"'
|
data/lib/rails_interactive.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "rails_interactive/prompt"
|
4
4
|
require "rails_interactive/message"
|
5
|
+
require "fileutils"
|
5
6
|
|
6
7
|
module RailsInteractive
|
7
8
|
# CLI class for the interactive CLI module
|
@@ -31,6 +32,9 @@ module RailsInteractive
|
|
31
32
|
database_types = { "PostgreSQL" => "-d postgresql", "MySQL" => "-d mysql", "SQLite" => "" }
|
32
33
|
@inputs[:database] = Prompt.new("Choose project's database: ", "select", database_types, required: true).perform
|
33
34
|
|
35
|
+
features = %w[devise cancancan omniauth pundit brakeman sidekiq]
|
36
|
+
@inputs[:features] = Prompt.new("Choose project features: ", "multi_select", features).perform
|
37
|
+
|
34
38
|
create
|
35
39
|
end
|
36
40
|
|
@@ -39,6 +43,15 @@ module RailsInteractive
|
|
39
43
|
system("bin/setup")
|
40
44
|
# Create project
|
41
45
|
system(setup)
|
46
|
+
|
47
|
+
copy_templates_to_project
|
48
|
+
|
49
|
+
# Move to project folder and install gems
|
50
|
+
Dir.chdir "./#{@inputs[:name]}"
|
51
|
+
@inputs[:features].each do |feature|
|
52
|
+
system("bin/rails app:template LOCATION=templates/setup_#{feature}.rb")
|
53
|
+
end
|
54
|
+
|
42
55
|
# Prepare project requirements and give instructions
|
43
56
|
Message.prepare
|
44
57
|
end
|
@@ -51,5 +64,9 @@ module RailsInteractive
|
|
51
64
|
|
52
65
|
"#{base} #{cmd}".strip!
|
53
66
|
end
|
67
|
+
|
68
|
+
def copy_templates_to_project
|
69
|
+
FileUtils.cp_r "#{__dir__}/rails_interactive/templates", "./#{@inputs[:name]}"
|
70
|
+
end
|
54
71
|
end
|
55
72
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-interactive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oguzhan Ince
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -118,6 +118,7 @@ executables:
|
|
118
118
|
extensions: []
|
119
119
|
extra_rdoc_files: []
|
120
120
|
files:
|
121
|
+
- ".github/FUNDING.yml"
|
121
122
|
- ".github/workflows/main.yml"
|
122
123
|
- ".github/workflows/rspec_rubocop.yml"
|
123
124
|
- ".gitignore"
|
@@ -136,6 +137,12 @@ files:
|
|
136
137
|
- lib/rails_interactive.rb
|
137
138
|
- lib/rails_interactive/message.rb
|
138
139
|
- lib/rails_interactive/prompt.rb
|
140
|
+
- lib/rails_interactive/templates/setup_brakeman.rb
|
141
|
+
- lib/rails_interactive/templates/setup_cancancan.rb
|
142
|
+
- lib/rails_interactive/templates/setup_devise.rb
|
143
|
+
- lib/rails_interactive/templates/setup_omniauth.rb
|
144
|
+
- lib/rails_interactive/templates/setup_pundit.rb
|
145
|
+
- lib/rails_interactive/templates/setup_sidekiq.rb
|
139
146
|
- lib/rails_interactive/version.rb
|
140
147
|
- rails-interactive.gemspec
|
141
148
|
homepage: https://github.com/oguzsh/rails-interactive
|