rails-interactive 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -0
- data/Gemfile.lock +77 -72
- data/bin/console +2 -9
- data/lib/cli/categories.rb +18 -0
- data/lib/cli/commands.rb +22 -0
- data/lib/cli/config/categories.yml +51 -0
- data/lib/cli/config/commands.yml +128 -0
- data/lib/cli/message.rb +55 -0
- data/lib/cli/prompt.rb +42 -0
- data/lib/cli/templates/setup_avo.rb +10 -0
- data/lib/cli/templates/setup_awesome_print.rb +4 -0
- data/lib/cli/templates/setup_better_errors.rb +8 -0
- data/lib/cli/templates/setup_brakeman.rb +6 -0
- data/lib/cli/templates/setup_bullet.rb +7 -0
- data/lib/cli/templates/setup_cancancan.rb +7 -0
- data/lib/cli/templates/setup_devise.rb +10 -0
- data/lib/cli/templates/setup_faker.rb +5 -0
- data/lib/cli/templates/setup_friendly_id.rb +5 -0
- data/lib/cli/templates/setup_graphql.rb +10 -0
- data/lib/cli/templates/setup_haml.rb +18 -0
- data/lib/cli/templates/setup_kaminari.rb +7 -0
- data/lib/cli/templates/setup_letter_opener.rb +15 -0
- data/lib/cli/templates/setup_omniauth.rb +61 -0
- data/lib/cli/templates/setup_pundit.rb +15 -0
- data/lib/cli/templates/setup_rails_admin.rb +10 -0
- data/lib/cli/templates/setup_rspec.rb +13 -0
- data/lib/cli/templates/setup_rubocop.rb +10 -0
- data/lib/cli/templates/setup_sidekiq.rb +32 -0
- data/lib/cli/templates/setup_slim.rb +19 -0
- data/lib/cli/templates/setup_standardrb.rb +10 -0
- data/lib/cli/utils.rb +48 -0
- data/lib/{rails_interactive → cli}/version.rb +3 -1
- data/lib/rails_interactive.rb +72 -35
- data/rails-interactive.gemspec +4 -2
- metadata +59 -5
- data/lib/rails_interactive/message.rb +0 -54
- data/lib/rails_interactive/prompt.rb +0 -40
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
def bundle_install
|
4
|
+
Bundler.with_unbundled_env { run "bundle install" }
|
5
|
+
end
|
6
|
+
|
7
|
+
run "bundle add haml"
|
8
|
+
bundle_install
|
9
|
+
|
10
|
+
if yes?("Would you like to convert your existing *.erb files to *.haml files? [y/n]")
|
11
|
+
run "bundle add erb2haml --group 'development'"
|
12
|
+
bundle_install
|
13
|
+
if yes?("Would you like to keep the original *.erb files? [y/n]")
|
14
|
+
rake "haml:convert_erbs"
|
15
|
+
else
|
16
|
+
rake "haml:replace_erbs"
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
run 'bundle add letter_opener --group "development"'
|
4
|
+
|
5
|
+
Bundler.with_unbundled_env { run "bundle install" }
|
6
|
+
|
7
|
+
inject_into_file "config/environments/development.rb", after: "config.action_mailer.perform_caching = false\n" do
|
8
|
+
<<-RUBY
|
9
|
+
|
10
|
+
config.action_mailer.delivery_method = :letter_opener
|
11
|
+
config.action_mailer.perform_deliveries = true
|
12
|
+
RUBY
|
13
|
+
end
|
14
|
+
|
15
|
+
puts "Letter Opener is now installed!"
|
@@ -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,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
run "rails db:prepare"
|
4
|
+
run "bundle add rails_admin"
|
5
|
+
|
6
|
+
Bundler.with_unbundled_env { run "bundle install" }
|
7
|
+
|
8
|
+
rails_command("generate rails_admin:install")
|
9
|
+
|
10
|
+
puts "RailsAdmin is installed! You can go to your admin panel at /admin"
|
@@ -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"'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
def bundle_install
|
4
|
+
Bundler.with_unbundled_env { run "bundle install" }
|
5
|
+
end
|
6
|
+
|
7
|
+
run "bundle add slim-rails"
|
8
|
+
|
9
|
+
bundle_install
|
10
|
+
|
11
|
+
if yes?("Would you like to convert your existing *.erb files to *.slim files? [y/n]")
|
12
|
+
run "bundle add html2slim --group 'development'"
|
13
|
+
bundle_install
|
14
|
+
if yes?("Would you like to keep the original *.erb files? [y/n]")
|
15
|
+
run "erb2slim app/views"
|
16
|
+
else
|
17
|
+
run "erb2slim app/views -d"
|
18
|
+
end
|
19
|
+
end
|
data/lib/cli/utils.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "fileutils"
|
4
|
+
|
5
|
+
module RailsInteractive
|
6
|
+
class CLI
|
7
|
+
class Utils
|
8
|
+
def self.humanize(value)
|
9
|
+
return nil if value.nil?
|
10
|
+
|
11
|
+
value
|
12
|
+
.gsub(/^[\s_]+|[\s_]+$/, "")
|
13
|
+
.gsub(/[_\s]+/, " ")
|
14
|
+
.gsub(/^[a-z]/, &:upcase)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.remove_templates(_project_name)
|
18
|
+
FileUtils.rm_rf("templates")
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.go_to_project_directory(project_name)
|
22
|
+
Dir.chdir "./#{project_name}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.copy_templates_to_project(project_name)
|
26
|
+
FileUtils.cp_r "#{__dir__}/templates", "./#{project_name}"
|
27
|
+
|
28
|
+
go_to_project_directory(project_name)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.handle_multi_options(multi_options)
|
32
|
+
multi_options.each do |value|
|
33
|
+
system("bin/rails app:template LOCATION=templates/setup_#{value}.rb")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.handle_option(option)
|
38
|
+
system("bin/rails app:template LOCATION=templates/setup_#{option}.rb")
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.sign_project
|
42
|
+
file = "README.md"
|
43
|
+
msg = "\n> This project was generated by [Rails Interactive CLI](https://github.com/oguzsh/rails-interactive)"
|
44
|
+
File.write(file, msg, mode: "a+")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/rails_interactive.rb
CHANGED
@@ -1,14 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
4
|
-
require "
|
5
|
-
require "
|
3
|
+
require "cli/prompt"
|
4
|
+
require "cli/message"
|
5
|
+
require "cli/commands"
|
6
|
+
require "cli/categories"
|
7
|
+
require "cli/utils"
|
6
8
|
|
7
9
|
module RailsInteractive
|
8
10
|
# CLI class for the interactive CLI module
|
9
11
|
class CLI
|
10
12
|
def initialize
|
11
13
|
@inputs = {}
|
14
|
+
@commands = Commands.new
|
15
|
+
@categories = Categories.new
|
12
16
|
end
|
13
17
|
|
14
18
|
def perform(key)
|
@@ -23,67 +27,100 @@ module RailsInteractive
|
|
23
27
|
end
|
24
28
|
end
|
25
29
|
|
30
|
+
private
|
31
|
+
|
32
|
+
def categories_with_commands
|
33
|
+
@categories.all.each do |category|
|
34
|
+
commands = []
|
35
|
+
@commands.all.each { |command| commands << command if command["category"] == category["name"] }
|
36
|
+
category["commands"] = commands
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
26
40
|
def initialize_project
|
27
41
|
name
|
28
42
|
type
|
29
43
|
database
|
30
|
-
css_frameworks
|
31
44
|
|
32
|
-
|
45
|
+
categories_with_commands.each do |category|
|
46
|
+
category_name = category["name"]
|
47
|
+
category_type = category["type"]
|
48
|
+
category_command_list = create_command_list(category["commands"], category_type)
|
49
|
+
|
50
|
+
@inputs[category_name.to_sym] =
|
51
|
+
Prompt.new("Choose #{Utils.humanize(category_name)} gems: ", category_type.to_s,
|
52
|
+
category_command_list).perform
|
53
|
+
end
|
54
|
+
|
55
|
+
create_project
|
56
|
+
end
|
57
|
+
|
58
|
+
def setup
|
59
|
+
base = "rails new"
|
60
|
+
cmd = ""
|
61
|
+
|
62
|
+
@inputs.first(3).each { |_key, value| cmd += "#{value} " unless value.empty? }
|
63
|
+
|
64
|
+
"#{base} #{cmd} -q"
|
33
65
|
end
|
34
66
|
|
35
|
-
def
|
67
|
+
def create_project
|
36
68
|
# Install gems
|
37
69
|
system("bin/setup")
|
38
|
-
|
39
70
|
# Create project
|
40
71
|
system(setup)
|
41
|
-
|
72
|
+
# Install gems
|
73
|
+
intall_gems
|
42
74
|
# Prepare project requirements and give instructions
|
43
|
-
|
44
|
-
system("rails db:create")
|
45
|
-
|
46
|
-
sign_project
|
75
|
+
Utils.sign_project
|
47
76
|
Message.prepare
|
48
77
|
end
|
49
78
|
|
50
|
-
def
|
51
|
-
|
52
|
-
cmd = ""
|
79
|
+
def create_command_list(commands, category_type)
|
80
|
+
return nil if commands.nil? || category_type.nil?
|
53
81
|
|
54
|
-
|
82
|
+
list = category_type == "select" ? {} : []
|
55
83
|
|
56
|
-
|
84
|
+
commands.each do |command|
|
85
|
+
if list.is_a?(Hash)
|
86
|
+
list["None"] = nil
|
87
|
+
list[command["name"]] = command["identifier"]
|
88
|
+
else
|
89
|
+
list << command["identifier"]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
list
|
57
94
|
end
|
58
95
|
|
59
|
-
|
96
|
+
def intall_gems
|
97
|
+
# Copy template files to project folder
|
98
|
+
Utils.copy_templates_to_project(@inputs[:name])
|
99
|
+
|
100
|
+
@inputs.each do |key, value|
|
101
|
+
next if %i[name type database].include?(key) || value.is_a?(Array) && value.empty? || value.nil?
|
102
|
+
|
103
|
+
Utils.handle_multi_options(value) if value.is_a?(Array)
|
104
|
+
Utils.handle_option(value) if value.is_a?(String)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Remove templates folder from project folder
|
108
|
+
Utils.remove_templates(@inputs[:name])
|
109
|
+
end
|
60
110
|
|
61
111
|
def name
|
62
|
-
@inputs[:name] = Prompt.new("
|
112
|
+
@inputs[:name] = Prompt.new("Project name: ", "ask", required: true).perform
|
63
113
|
end
|
64
114
|
|
65
115
|
def type
|
66
|
-
types = { "App" => "", "
|
67
|
-
@inputs[:type] = Prompt.new("
|
116
|
+
types = { "App" => "", "Api" => "--api" }
|
117
|
+
@inputs[:type] = Prompt.new("Type: ", "select", types, required: true).perform
|
68
118
|
end
|
69
119
|
|
70
120
|
def database
|
71
121
|
database_types = { "PostgreSQL" => "-d postgresql", "MySQL" => "-d mysql", "SQLite" => "" }
|
72
122
|
|
73
|
-
@inputs[:database] = Prompt.new("
|
74
|
-
end
|
75
|
-
|
76
|
-
def css_frameworks
|
77
|
-
css_frameworks = { "None" => "", "Bootstrap" => "--css=bootstrap", "Tailwind" => "--css=tailwind" }
|
78
|
-
|
79
|
-
@inputs[:css_framework] =
|
80
|
-
Prompt.new("Choose project's CSS framework: ", "select", css_frameworks, required: true).perform
|
81
|
-
end
|
82
|
-
|
83
|
-
def sign_project
|
84
|
-
file = "README.md"
|
85
|
-
msg = "\n> This project was generated by [Rails Interactive CLI](https://github.com/oguzsh/rails-interactive)"
|
86
|
-
File.write(file, msg, mode: "a+")
|
123
|
+
@inputs[:database] = Prompt.new("Database: ", "select", database_types, required: true).perform
|
87
124
|
end
|
88
125
|
end
|
89
126
|
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/cli/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "rails-interactive"
|
7
|
-
spec.version = RailsInteractive::VERSION
|
7
|
+
spec.version = RailsInteractive::CLI::VERSION
|
8
8
|
spec.authors = ["Oguzhan Ince"]
|
9
9
|
spec.email = ["oguzhan824@gmail.com"]
|
10
10
|
|
@@ -29,9 +29,11 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_development_dependency "bundler"
|
30
30
|
spec.add_development_dependency "byebug", "~> 11.1.2"
|
31
31
|
spec.add_development_dependency "colorize"
|
32
|
+
spec.add_development_dependency "pry"
|
32
33
|
spec.add_development_dependency "rake"
|
33
34
|
spec.add_development_dependency "rspec"
|
34
35
|
spec.add_development_dependency "rubocop"
|
36
|
+
spec.add_development_dependency "yaml"
|
35
37
|
|
36
38
|
spec.add_dependency "tty-prompt"
|
37
39
|
|
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:
|
4
|
+
version: 2.0.0
|
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-05-
|
11
|
+
date: 2022-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rake
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +108,20 @@ dependencies:
|
|
94
108
|
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: yaml
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
97
125
|
- !ruby/object:Gem::Dependency
|
98
126
|
name: tty-prompt
|
99
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -135,10 +163,36 @@ files:
|
|
135
163
|
- bin/console
|
136
164
|
- bin/rails-interactive
|
137
165
|
- bin/setup
|
166
|
+
- lib/cli/categories.rb
|
167
|
+
- lib/cli/commands.rb
|
168
|
+
- lib/cli/config/categories.yml
|
169
|
+
- lib/cli/config/commands.yml
|
170
|
+
- lib/cli/message.rb
|
171
|
+
- lib/cli/prompt.rb
|
172
|
+
- lib/cli/templates/setup_avo.rb
|
173
|
+
- lib/cli/templates/setup_awesome_print.rb
|
174
|
+
- lib/cli/templates/setup_better_errors.rb
|
175
|
+
- lib/cli/templates/setup_brakeman.rb
|
176
|
+
- lib/cli/templates/setup_bullet.rb
|
177
|
+
- lib/cli/templates/setup_cancancan.rb
|
178
|
+
- lib/cli/templates/setup_devise.rb
|
179
|
+
- lib/cli/templates/setup_faker.rb
|
180
|
+
- lib/cli/templates/setup_friendly_id.rb
|
181
|
+
- lib/cli/templates/setup_graphql.rb
|
182
|
+
- lib/cli/templates/setup_haml.rb
|
183
|
+
- lib/cli/templates/setup_kaminari.rb
|
184
|
+
- lib/cli/templates/setup_letter_opener.rb
|
185
|
+
- lib/cli/templates/setup_omniauth.rb
|
186
|
+
- lib/cli/templates/setup_pundit.rb
|
187
|
+
- lib/cli/templates/setup_rails_admin.rb
|
188
|
+
- lib/cli/templates/setup_rspec.rb
|
189
|
+
- lib/cli/templates/setup_rubocop.rb
|
190
|
+
- lib/cli/templates/setup_sidekiq.rb
|
191
|
+
- lib/cli/templates/setup_slim.rb
|
192
|
+
- lib/cli/templates/setup_standardrb.rb
|
193
|
+
- lib/cli/utils.rb
|
194
|
+
- lib/cli/version.rb
|
138
195
|
- lib/rails_interactive.rb
|
139
|
-
- lib/rails_interactive/message.rb
|
140
|
-
- lib/rails_interactive/prompt.rb
|
141
|
-
- lib/rails_interactive/version.rb
|
142
196
|
- rails-interactive.gemspec
|
143
197
|
homepage: https://github.com/oguzsh/rails-interactive
|
144
198
|
licenses:
|
@@ -1,54 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "colorize"
|
4
|
-
|
5
|
-
module RailsInteractive
|
6
|
-
# Utils class for the interactive CLI module
|
7
|
-
class Message
|
8
|
-
def self.greet
|
9
|
-
render_ascii
|
10
|
-
puts "Welcome to Rails Interactive CLI".colorize(:yellow)
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.help
|
14
|
-
puts "bin/interactive new - Create a new Rails Project".colorize(:yellow)
|
15
|
-
puts "bin/interactive help - List all commands".colorize(:yellow)
|
16
|
-
exit
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.render_ascii
|
20
|
-
# rubocop:disable Naming/HeredocDelimiterNaming
|
21
|
-
puts <<-'EOF'
|
22
|
-
_____ _ _ _____ _ _ _
|
23
|
-
| __ \ (_) | |_ _| | | | | (_)
|
24
|
-
| |__) |__ _ _| |___ | | _ __ | |_ ___ _ __ __ _ ___| |_ ___ _____
|
25
|
-
| _ // _` | | / __| | | | '_ \| __/ _ \ '__/ _` |/ __| __| \ \ / / _ \
|
26
|
-
| | \ \ (_| | | \__ \_| |_| | | | || __/ | | (_| | (__| |_| |\ V / __/
|
27
|
-
|_| \_\__,_|_|_|___/_____|_| |_|\__\___|_| \__,_|\___|\__|_| \_/ \___|
|
28
|
-
|
29
|
-
|
30
|
-
EOF
|
31
|
-
# rubocop:enable Naming/HeredocDelimiterNaming
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.prepare
|
35
|
-
puts ""
|
36
|
-
puts "Project created successfully ✅".colorize(:green)
|
37
|
-
puts "Go to your project folder and ready to go 🎉".colorize(:green)
|
38
|
-
rails_commands
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.rails_commands
|
42
|
-
puts "You can run several commands:".colorize(:green)
|
43
|
-
|
44
|
-
puts "Starts the webpack development server".colorize(:cyan)
|
45
|
-
puts "> bin/webpack-dev-server".colorize(:yellow)
|
46
|
-
|
47
|
-
puts "Starts the rails server".colorize(:cyan)
|
48
|
-
puts "> bin/rails s or bin/rails server".colorize(:yellow)
|
49
|
-
|
50
|
-
puts "Starts the rails console".colorize(:cyan)
|
51
|
-
puts "> bin/rails c or bin/rails console".colorize(:yellow)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|