rails-interactive 0.1.1 → 0.1.5
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/workflows/main.yml +53 -12
- data/.github/workflows/rspec_rubocop.yml +17 -0
- data/Gemfile +1 -3
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/bin/console +1 -1
- data/bin/{interactive → rails-interactive} +2 -2
- data/bin/setup +1 -1
- data/lib/{interactive → rails_interactive}/message.rb +2 -5
- data/lib/{interactive → rails_interactive}/prompt.rb +3 -1
- 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/version.rb +5 -0
- data/lib/{interactive.rb → rails_interactive.rb} +20 -3
- data/rails-interactive.gemspec +2 -2
- metadata +13 -9
- data/lib/interactive/ascii.txt +0 -0
- data/lib/interactive/version.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1d6d7de1b01f37818e7d8f40a4ea4f70e4f7419e0a9289a09a345f8761728bf
|
4
|
+
data.tar.gz: 6eb6ad5b7193fd37f1d8abadc238806e4a37892bc0f422821f2ef2ec62c69726
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa7219d9f1233d37defe9944d032e5367bdcc0aeda2b4e3e78d8e49b21470f1d4b0f0d39fda2ac87a77782c3801d8e33c450fd3abce5ddcb2c86170735b3ddff
|
7
|
+
data.tar.gz: 54af5dfed258953ce0439154e4f2cfbc7d239aecd7f3d4c7a15ae12fbfbffdaa51753f647fab8d275a6b3d8b02bced5c94df83252cafefe3e8a8d142db80cc40
|
data/.github/workflows/main.yml
CHANGED
@@ -1,16 +1,57 @@
|
|
1
|
-
name:
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
name: Release and Publish
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches:
|
5
|
+
- main
|
5
6
|
jobs:
|
6
7
|
build:
|
7
8
|
runs-on: ubuntu-latest
|
8
9
|
steps:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
- name: Wait for tests to succeed
|
11
|
+
uses: lewagon/wait-on-check-action@v1.0.0
|
12
|
+
with:
|
13
|
+
ref: ${{ github.ref }}
|
14
|
+
check-name: 'Run tests'
|
15
|
+
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
16
|
+
wait-interval: 10
|
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
|
26
|
+
uses: ruby/setup-ruby@v1
|
27
|
+
if: ${{ steps.release.outputs.release_created }}
|
28
|
+
with:
|
29
|
+
ruby-version: 3.0.2
|
30
|
+
bundler-cache: true
|
31
|
+
- name: Bundle Install
|
32
|
+
run: bundle install
|
33
|
+
if: ${{ steps.release.outputs.release_created }}
|
34
|
+
- name: Set Credentials
|
35
|
+
run: |
|
36
|
+
mkdir -p $HOME/.gem
|
37
|
+
touch $HOME/.gem/credentials
|
38
|
+
chmod 0600 $HOME/.gem/credentials
|
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}}'
|
45
|
+
- name: Publish to GitHub Packages
|
46
|
+
run: |
|
47
|
+
export OWNER=$( echo ${{ github.repository }} | cut -d "/" -f 1 )
|
48
|
+
gem build *.gemspec
|
49
|
+
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
50
|
+
gem push *.gem
|
51
|
+
if: ${{ steps.release.outputs.release_created }}
|
52
|
+
- name: Publish to RubyGems
|
53
|
+
run: |
|
54
|
+
gem build *.gemspec
|
55
|
+
gem push --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
56
|
+
gem push *.gem
|
57
|
+
if: ${{ steps.release.outputs.release_created }}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
name: Run tests
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
name: Run tests
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
steps:
|
10
|
+
- uses: actions/checkout@v2
|
11
|
+
- name: Set up Ruby
|
12
|
+
uses: ruby/setup-ruby@v1
|
13
|
+
with:
|
14
|
+
ruby-version: 3.0.2
|
15
|
+
bundler-cache: true
|
16
|
+
- name: Run the default task
|
17
|
+
run: bundle exec rake
|
data/Gemfile
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
# Specify your gem's dependencies in
|
5
|
+
# Specify your gem's dependencies in rails_interactive.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
8
|
gem "rails"
|
@@ -13,6 +13,4 @@ gem "rspec", "~> 3.0"
|
|
13
13
|
|
14
14
|
gem "rubocop", "~> 1.7"
|
15
15
|
|
16
|
-
gem "byebug", "~> 11.1.2"
|
17
|
-
|
18
16
|
gem "tty-prompt"
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/bin/console
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require "bundler/setup"
|
5
|
-
require "
|
5
|
+
require "rails_interactive"
|
6
6
|
|
7
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
8
8
|
# with your gem easier. You can also use a different console, if you like.
|
data/bin/setup
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "colorize"
|
4
4
|
|
5
|
-
module
|
5
|
+
module RailsInteractive
|
6
6
|
# Utils class for the interactive CLI module
|
7
7
|
class Message
|
8
8
|
def self.greet
|
@@ -32,10 +32,7 @@ module Interactive
|
|
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
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "tty/prompt"
|
4
4
|
|
5
|
-
module
|
5
|
+
module RailsInteractive
|
6
6
|
# Prompt class for commands
|
7
7
|
class Prompt
|
8
8
|
# Create a new instance
|
@@ -30,6 +30,8 @@ module Interactive
|
|
30
30
|
@prompt.ask(@msg, required: @required)
|
31
31
|
when "select"
|
32
32
|
@prompt.select(@msg, @options, required: @required)
|
33
|
+
when "multi_select"
|
34
|
+
@prompt.multi_select(@msg, @options)
|
33
35
|
else
|
34
36
|
puts "Invalid parameter"
|
35
37
|
end
|
@@ -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")
|
@@ -1,9 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
4
|
-
require "
|
3
|
+
require "rails_interactive/prompt"
|
4
|
+
require "rails_interactive/message"
|
5
|
+
require "fileutils"
|
5
6
|
|
6
|
-
module
|
7
|
+
module RailsInteractive
|
7
8
|
# CLI class for the interactive CLI module
|
8
9
|
class CLI
|
9
10
|
def initialize
|
@@ -31,6 +32,9 @@ module Interactive
|
|
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]
|
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 Interactive
|
|
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 Interactive
|
|
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
|
data/rails-interactive.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "lib/
|
3
|
+
require_relative "lib/rails_interactive/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "rails-interactive"
|
7
|
-
spec.version =
|
7
|
+
spec.version = RailsInteractive::VERSION
|
8
8
|
spec.authors = ["Oguzhan Ince"]
|
9
9
|
spec.email = ["oguzhan824@gmail.com"]
|
10
10
|
|
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.5
|
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
|
@@ -113,12 +113,13 @@ email:
|
|
113
113
|
- oguzhan824@gmail.com
|
114
114
|
executables:
|
115
115
|
- console
|
116
|
-
- interactive
|
116
|
+
- rails-interactive
|
117
117
|
- setup
|
118
118
|
extensions: []
|
119
119
|
extra_rdoc_files: []
|
120
120
|
files:
|
121
121
|
- ".github/workflows/main.yml"
|
122
|
+
- ".github/workflows/rspec_rubocop.yml"
|
122
123
|
- ".gitignore"
|
123
124
|
- ".rspec"
|
124
125
|
- ".rubocop.yml"
|
@@ -130,13 +131,16 @@ files:
|
|
130
131
|
- README.md
|
131
132
|
- Rakefile
|
132
133
|
- bin/console
|
133
|
-
- bin/interactive
|
134
|
+
- bin/rails-interactive
|
134
135
|
- bin/setup
|
135
|
-
- lib/
|
136
|
-
- lib/
|
137
|
-
- lib/
|
138
|
-
- lib/
|
139
|
-
- lib/
|
136
|
+
- lib/rails_interactive.rb
|
137
|
+
- lib/rails_interactive/message.rb
|
138
|
+
- lib/rails_interactive/prompt.rb
|
139
|
+
- lib/rails_interactive/templates/setup_cancancan.rb
|
140
|
+
- lib/rails_interactive/templates/setup_devise.rb
|
141
|
+
- lib/rails_interactive/templates/setup_omniauth.rb
|
142
|
+
- lib/rails_interactive/templates/setup_pundit.rb
|
143
|
+
- lib/rails_interactive/version.rb
|
140
144
|
- rails-interactive.gemspec
|
141
145
|
homepage: https://github.com/oguzsh/rails-interactive
|
142
146
|
licenses:
|
data/lib/interactive/ascii.txt
DELETED
File without changes
|