rails-interactive 0.1.9 → 2.1.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/workflows/main.yml +57 -57
- data/.rubocop.yml +9 -0
- data/Gemfile.lock +77 -72
- data/README.md +1 -1
- data/bin/console +2 -9
- data/lib/cli/category.rb +18 -0
- data/lib/cli/command.rb +29 -0
- data/lib/cli/command_handler.rb +32 -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/{rails_interactive → cli}/templates/setup_avo.rb +0 -0
- data/lib/{rails_interactive → cli}/templates/setup_awesome_print.rb +0 -0
- data/lib/{rails_interactive → cli}/templates/setup_better_errors.rb +0 -0
- data/lib/{rails_interactive → cli}/templates/setup_brakeman.rb +0 -0
- data/lib/{rails_interactive → cli}/templates/setup_bullet.rb +0 -0
- data/lib/{rails_interactive → cli}/templates/setup_cancancan.rb +0 -0
- data/lib/{rails_interactive → cli}/templates/setup_devise.rb +0 -0
- data/lib/{rails_interactive → cli}/templates/setup_faker.rb +0 -0
- data/lib/cli/templates/setup_friendly_id.rb +5 -0
- data/lib/{rails_interactive → cli}/templates/setup_graphql.rb +0 -0
- data/lib/{rails_interactive → cli}/templates/setup_haml.rb +0 -0
- data/lib/{rails_interactive → cli}/templates/setup_kaminari.rb +0 -0
- data/lib/{rails_interactive → cli}/templates/setup_letter_opener.rb +0 -0
- data/lib/{rails_interactive → cli}/templates/setup_omniauth.rb +0 -0
- data/lib/{rails_interactive → cli}/templates/setup_pundit.rb +0 -0
- data/lib/{rails_interactive → cli}/templates/setup_rails_admin.rb +0 -0
- data/lib/{rails_interactive → cli}/templates/setup_rspec.rb +0 -0
- data/lib/{rails_interactive → cli}/templates/setup_rubocop.rb +0 -0
- data/lib/{rails_interactive → cli}/templates/setup_sidekiq.rb +0 -0
- data/lib/{rails_interactive → cli}/templates/setup_slim.rb +0 -0
- data/lib/{rails_interactive → cli}/templates/setup_standardrb.rb +0 -0
- data/lib/cli/utils.rb +38 -0
- data/lib/{rails_interactive → cli}/version.rb +3 -1
- data/lib/rails_interactive.rb +71 -100
- data/rails-interactive.gemspec +4 -2
- metadata +60 -26
- data/lib/rails_interactive/message.rb +0 -52
- data/lib/rails_interactive/prompt.rb +0 -40
- data/lib/rails_interactive/templates/setup_friendly_id.rb +0 -26
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.1.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-
|
11
|
+
date: 2022-05-30 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,31 +163,37 @@ files:
|
|
135
163
|
- bin/console
|
136
164
|
- bin/rails-interactive
|
137
165
|
- bin/setup
|
166
|
+
- lib/cli/category.rb
|
167
|
+
- lib/cli/command.rb
|
168
|
+
- lib/cli/command_handler.rb
|
169
|
+
- lib/cli/config/categories.yml
|
170
|
+
- lib/cli/config/commands.yml
|
171
|
+
- lib/cli/message.rb
|
172
|
+
- lib/cli/prompt.rb
|
173
|
+
- lib/cli/templates/setup_avo.rb
|
174
|
+
- lib/cli/templates/setup_awesome_print.rb
|
175
|
+
- lib/cli/templates/setup_better_errors.rb
|
176
|
+
- lib/cli/templates/setup_brakeman.rb
|
177
|
+
- lib/cli/templates/setup_bullet.rb
|
178
|
+
- lib/cli/templates/setup_cancancan.rb
|
179
|
+
- lib/cli/templates/setup_devise.rb
|
180
|
+
- lib/cli/templates/setup_faker.rb
|
181
|
+
- lib/cli/templates/setup_friendly_id.rb
|
182
|
+
- lib/cli/templates/setup_graphql.rb
|
183
|
+
- lib/cli/templates/setup_haml.rb
|
184
|
+
- lib/cli/templates/setup_kaminari.rb
|
185
|
+
- lib/cli/templates/setup_letter_opener.rb
|
186
|
+
- lib/cli/templates/setup_omniauth.rb
|
187
|
+
- lib/cli/templates/setup_pundit.rb
|
188
|
+
- lib/cli/templates/setup_rails_admin.rb
|
189
|
+
- lib/cli/templates/setup_rspec.rb
|
190
|
+
- lib/cli/templates/setup_rubocop.rb
|
191
|
+
- lib/cli/templates/setup_sidekiq.rb
|
192
|
+
- lib/cli/templates/setup_slim.rb
|
193
|
+
- lib/cli/templates/setup_standardrb.rb
|
194
|
+
- lib/cli/utils.rb
|
195
|
+
- lib/cli/version.rb
|
138
196
|
- lib/rails_interactive.rb
|
139
|
-
- lib/rails_interactive/message.rb
|
140
|
-
- lib/rails_interactive/prompt.rb
|
141
|
-
- lib/rails_interactive/templates/setup_avo.rb
|
142
|
-
- lib/rails_interactive/templates/setup_awesome_print.rb
|
143
|
-
- lib/rails_interactive/templates/setup_better_errors.rb
|
144
|
-
- lib/rails_interactive/templates/setup_brakeman.rb
|
145
|
-
- lib/rails_interactive/templates/setup_bullet.rb
|
146
|
-
- lib/rails_interactive/templates/setup_cancancan.rb
|
147
|
-
- lib/rails_interactive/templates/setup_devise.rb
|
148
|
-
- lib/rails_interactive/templates/setup_faker.rb
|
149
|
-
- lib/rails_interactive/templates/setup_friendly_id.rb
|
150
|
-
- lib/rails_interactive/templates/setup_graphql.rb
|
151
|
-
- lib/rails_interactive/templates/setup_haml.rb
|
152
|
-
- lib/rails_interactive/templates/setup_kaminari.rb
|
153
|
-
- lib/rails_interactive/templates/setup_letter_opener.rb
|
154
|
-
- lib/rails_interactive/templates/setup_omniauth.rb
|
155
|
-
- lib/rails_interactive/templates/setup_pundit.rb
|
156
|
-
- lib/rails_interactive/templates/setup_rails_admin.rb
|
157
|
-
- lib/rails_interactive/templates/setup_rspec.rb
|
158
|
-
- lib/rails_interactive/templates/setup_rubocop.rb
|
159
|
-
- lib/rails_interactive/templates/setup_sidekiq.rb
|
160
|
-
- lib/rails_interactive/templates/setup_slim.rb
|
161
|
-
- lib/rails_interactive/templates/setup_standardrb.rb
|
162
|
-
- lib/rails_interactive/version.rb
|
163
197
|
- rails-interactive.gemspec
|
164
198
|
homepage: https://github.com/oguzsh/rails-interactive
|
165
199
|
licenses:
|
@@ -1,52 +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
|
-
| || | | | || __/ | | (_| | (__| |_| |\ V / __/ _ < (_| | | \__ \
|
26
|
-
|___|_| |_|\__\___|_| \__,_|\___|\__|_| \_/ \___|_| \_\__,_|_|_|___/
|
27
|
-
|
28
|
-
EOF
|
29
|
-
# rubocop:enable Naming/HeredocDelimiterNaming
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.prepare
|
33
|
-
puts ""
|
34
|
-
puts "Project created successfully ✅".colorize(:green)
|
35
|
-
puts "Go to your project folder and ready to go 🎉".colorize(:green)
|
36
|
-
rails_commands
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.rails_commands
|
40
|
-
puts "You can run several commands:".colorize(:green)
|
41
|
-
|
42
|
-
puts "Starts the webpack development server".colorize(:cyan)
|
43
|
-
puts "> bin/webpack-dev-server".colorize(:yellow)
|
44
|
-
|
45
|
-
puts "Starts the rails server".colorize(:cyan)
|
46
|
-
puts "> bin/rails s or bin/rails server".colorize(:yellow)
|
47
|
-
|
48
|
-
puts "Starts the rails console".colorize(:cyan)
|
49
|
-
puts "> bin/rails c or bin/rails console".colorize(:yellow)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "tty/prompt"
|
4
|
-
|
5
|
-
module RailsInteractive
|
6
|
-
# Prompt class for commands
|
7
|
-
class Prompt
|
8
|
-
# Create a new instance
|
9
|
-
#
|
10
|
-
# @param msg [String] the message to display
|
11
|
-
# @param type [String] the type of prompt
|
12
|
-
# @param options [Array] the options to display
|
13
|
-
# @param required [Boolean] whether the prompt value is required
|
14
|
-
#
|
15
|
-
# @return [Interactive::Prompt] the new instance
|
16
|
-
def initialize(msg, type, options = nil, required: false)
|
17
|
-
@msg = msg
|
18
|
-
@type = type
|
19
|
-
@options = options
|
20
|
-
@required = required
|
21
|
-
@prompt = TTY::Prompt.new
|
22
|
-
end
|
23
|
-
|
24
|
-
# Perform the prompt
|
25
|
-
#
|
26
|
-
# @return [String] the value of the prompt
|
27
|
-
def perform
|
28
|
-
case @type
|
29
|
-
when "ask"
|
30
|
-
@prompt.ask(@msg, required: @required)
|
31
|
-
when "select"
|
32
|
-
@prompt.select(@msg, @options, required: @required)
|
33
|
-
when "multi_select"
|
34
|
-
@prompt.multi_select(@msg, @options)
|
35
|
-
else
|
36
|
-
puts "Invalid parameter"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
def ask_with_default(prompt, default)
|
4
|
-
value = ask("#{prompt} (default: #{default})")
|
5
|
-
value.present? ? value : default
|
6
|
-
end
|
7
|
-
|
8
|
-
run "bundle add 'friendly_id'"
|
9
|
-
|
10
|
-
rails_command "generate friendly_id"
|
11
|
-
|
12
|
-
while yes?("Do you want to use Friendly ID with an existing model? (y/n)")
|
13
|
-
model_name = ask_with_default("Model Name:", "Postr")
|
14
|
-
attribute = ask_with_default("Attribute:", "name")
|
15
|
-
next unless model_name && attribute
|
16
|
-
|
17
|
-
# We generate a migration to add the friendly id slug column.
|
18
|
-
generate(:migration, "AddSlugTo#{model_name.titleize.pluralize}", "slug:uniq")
|
19
|
-
string = <<~RUBY
|
20
|
-
extend FriendlyId
|
21
|
-
friendly_id :#{attribute}, use: :slugged
|
22
|
-
RUBY
|
23
|
-
# Inject the friendly id methods into the class.
|
24
|
-
inject_into_file "app/models/#{model_name.downcase}.rb", string,
|
25
|
-
after: "class #{model_name.titleize} < ApplicationRecord\n"
|
26
|
-
end
|