rails-interactive 0.1.6 → 0.1.9
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 -1
- data/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +9 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/lib/rails_interactive/templates/setup_avo.rb +10 -0
- data/lib/rails_interactive/templates/setup_awesome_print.rb +4 -0
- data/lib/rails_interactive/templates/setup_better_errors.rb +8 -0
- data/lib/rails_interactive/templates/setup_bullet.rb +7 -0
- data/lib/rails_interactive/templates/setup_faker.rb +5 -0
- data/lib/rails_interactive/templates/setup_friendly_id.rb +26 -0
- data/lib/rails_interactive/templates/setup_graphql.rb +10 -0
- data/lib/rails_interactive/templates/setup_haml.rb +18 -0
- data/lib/rails_interactive/templates/setup_kaminari.rb +7 -0
- data/lib/rails_interactive/templates/setup_letter_opener.rb +15 -0
- data/lib/rails_interactive/templates/setup_rails_admin.rb +10 -0
- data/lib/rails_interactive/templates/setup_rspec.rb +13 -0
- data/lib/rails_interactive/templates/setup_rubocop.rb +10 -0
- data/lib/rails_interactive/templates/setup_slim.rb +19 -0
- data/lib/rails_interactive/templates/setup_standardrb.rb +10 -0
- data/lib/rails_interactive/version.rb +1 -1
- data/lib/rails_interactive.rb +101 -14
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75d2314dfc92d4b4b435a0d460ead1cdd929c4a38a4b1e7d61ac4c6348153865
|
4
|
+
data.tar.gz: caa1efa0259cbdb5390235f10e13d280b126e3b179b2063fab5754a52949b7b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60eed5fe9853045e1b5b56ab5345ca5d4ab56709eed27a11473de6d9661e95e70a4ab42aeca75ca0df2bc13378291458a23449a1b5afbe7acf384f9ed35436cd
|
7
|
+
data.tar.gz: af53d57979c6a78ac62dbc1e7571d0db39e491a6c3c6582c2c048e5287a6db96a20725b464aa596f58848b681592e7f02632b53e22f76e049e7b312e8968adce
|
data/.github/FUNDING.yml
CHANGED
@@ -0,0 +1,9 @@
|
|
1
|
+
## What's up?
|
2
|
+
|
3
|
+
In this PR, Rails interactive have `gem` integration. In this way, when users select `gem` to install their rails project, CLI will install `gem` to the related project with the use of rails templates
|
4
|
+
|
5
|
+
## Issue
|
6
|
+
Related Issue: `issue_link`
|
7
|
+
|
8
|
+
## Closed Issue
|
9
|
+
Closes `issue_link`
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
### [0.1.9](https://www.github.com/oguzsh/rails-interactive/compare/v0.1.8...v0.1.9) (2022-04-24)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* file name typo ([#60](https://www.github.com/oguzsh/rails-interactive/issues/60)) ([542c76f](https://www.github.com/oguzsh/rails-interactive/commit/542c76fa57fd37cf583a7238b2a9b527aeba1778))
|
9
|
+
|
3
10
|
## [0.1.0] - 2022-03-11
|
4
11
|
|
5
12
|
- Initial release
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
run "rails db:prepare"
|
4
|
+
run "bundle add avo"
|
5
|
+
|
6
|
+
Bundler.with_unbundled_env { run "bundle install" }
|
7
|
+
|
8
|
+
rails_command("generate avo:install")
|
9
|
+
|
10
|
+
puts "Avo is installed! You can go to http://localhost:3000/avo for next steps"
|
@@ -0,0 +1,26 @@
|
|
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
|
@@ -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,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,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/rails_interactive.rb
CHANGED
@@ -24,20 +24,20 @@ module RailsInteractive
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def initialize_project
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
@inputs[:features] = Prompt.new("Choose project features: ", "multi_select", features).perform
|
27
|
+
name
|
28
|
+
type
|
29
|
+
database
|
30
|
+
features
|
31
|
+
code_quality_tool
|
32
|
+
template_engines
|
33
|
+
admin_panel
|
34
|
+
testing_tools
|
35
|
+
development_tools
|
37
36
|
|
38
37
|
create
|
39
38
|
end
|
40
39
|
|
40
|
+
# rubocop:disable Metrics/MethodLength
|
41
41
|
def create
|
42
42
|
# Install gems
|
43
43
|
system("bin/setup")
|
@@ -48,19 +48,36 @@ module RailsInteractive
|
|
48
48
|
|
49
49
|
# Move to project folder and install gems
|
50
50
|
Dir.chdir "./#{@inputs[:name]}"
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
|
52
|
+
# Features Templates
|
53
|
+
handle_multi_options(key: :features)
|
54
|
+
|
55
|
+
# Code Quality Template
|
56
|
+
system("bin/rails app:template LOCATION=templates/setup_#{@inputs[:code_quality_tool]}.rb")
|
57
|
+
|
58
|
+
# HTML Template Engines
|
59
|
+
system("bin/rails app:template LOCATION=templates/setup_#{@inputs[:template_engine]}.rb")
|
60
|
+
|
61
|
+
# Admin Panel Template
|
62
|
+
system("bin/rails app:template LOCATION=templates/setup_#{@inputs[:admin_panel]}.rb")
|
63
|
+
|
64
|
+
# Testing tools Template
|
65
|
+
handle_multi_options(key: :testing_tools)
|
66
|
+
|
67
|
+
# Development tools Template
|
68
|
+
handle_multi_options(key: :development_tools)
|
54
69
|
|
55
70
|
# Prepare project requirements and give instructions
|
71
|
+
sign_project
|
56
72
|
Message.prepare
|
57
73
|
end
|
74
|
+
# rubocop:enable Metrics/MethodLength
|
58
75
|
|
59
76
|
def setup
|
60
77
|
base = "rails new"
|
61
78
|
cmd = ""
|
62
79
|
|
63
|
-
@inputs.each { |_key, value| cmd += "#{value} " }
|
80
|
+
@inputs.first(3).each { |_key, value| cmd += "#{value} " }
|
64
81
|
|
65
82
|
"#{base} #{cmd}".strip!
|
66
83
|
end
|
@@ -68,5 +85,75 @@ module RailsInteractive
|
|
68
85
|
def copy_templates_to_project
|
69
86
|
FileUtils.cp_r "#{__dir__}/rails_interactive/templates", "./#{@inputs[:name]}"
|
70
87
|
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def handle_multi_options(key:)
|
92
|
+
@inputs[key].each do |value|
|
93
|
+
system("bin/rails app:template LOCATION=templates/setup_#{value}.rb")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def name
|
98
|
+
@inputs[:name] = Prompt.new("Enter the name of the project: ", "ask", required: true).perform
|
99
|
+
end
|
100
|
+
|
101
|
+
def type
|
102
|
+
types = { "App" => "", "API" => "--api" }
|
103
|
+
@inputs[:type] = Prompt.new("Choose project type: ", "select", types, required: true).perform
|
104
|
+
end
|
105
|
+
|
106
|
+
def database
|
107
|
+
database_types = { "PostgreSQL" => "-d postgresql", "MySQL" => "-d mysql", "SQLite" => "" }
|
108
|
+
|
109
|
+
@inputs[:database] = Prompt.new("Choose project's database: ", "select", database_types, required: true).perform
|
110
|
+
end
|
111
|
+
|
112
|
+
def features
|
113
|
+
features = %w[devise cancancan omniauth pundit brakeman sidekiq graphql kaminari]
|
114
|
+
|
115
|
+
@inputs[:features] = Prompt.new("Choose project features: ", "multi_select", features).perform
|
116
|
+
end
|
117
|
+
|
118
|
+
def code_quality_tool
|
119
|
+
code_quality_tool = { "Rubocop" => "rubocop", "StandardRB" => "standardrb" }
|
120
|
+
|
121
|
+
@inputs[:code_quality_tool] =
|
122
|
+
Prompt.new("Choose project code quality tool: ", "select", code_quality_tool).perform
|
123
|
+
end
|
124
|
+
|
125
|
+
def admin_panel
|
126
|
+
admin_panel = { "RailsAdmin" => "rails_admin", "Avo" => "avo" }
|
127
|
+
|
128
|
+
@inputs[:admin_panel] =
|
129
|
+
Prompt.new("Choose project's admin panel: ", "select", admin_panel).perform
|
130
|
+
end
|
131
|
+
|
132
|
+
def testing_tools
|
133
|
+
testing_tools = %w[rspec]
|
134
|
+
|
135
|
+
@inputs[:testing_tools] =
|
136
|
+
Prompt.new("Choose project's testing tools: ", "multi_select", testing_tools).perform
|
137
|
+
end
|
138
|
+
|
139
|
+
def template_engines
|
140
|
+
template_engines = { "HAML" => "haml", "SLIM" => "slim" }
|
141
|
+
|
142
|
+
@inputs[:template_engine] =
|
143
|
+
Prompt.new("Choose project's template engine: ", "select", template_engines).perform
|
144
|
+
end
|
145
|
+
|
146
|
+
def development_tools
|
147
|
+
development_tools = %w[bullet faker friendly_id better_errors letter_opener awesome_print]
|
148
|
+
|
149
|
+
@inputs[:development_tools] =
|
150
|
+
Prompt.new("Choose project's development tools: ", "multi_select", development_tools).perform
|
151
|
+
end
|
152
|
+
|
153
|
+
def sign_project
|
154
|
+
file = "README.md"
|
155
|
+
msg = "\n> This project was generated by [Rails Interactive CLI](https://github.com/oguzsh/rails-interactive)"
|
156
|
+
File.write(file, msg, mode: "a+")
|
157
|
+
end
|
71
158
|
end
|
72
159
|
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.9
|
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-04-
|
11
|
+
date: 2022-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -119,6 +119,7 @@ extensions: []
|
|
119
119
|
extra_rdoc_files: []
|
120
120
|
files:
|
121
121
|
- ".github/FUNDING.yml"
|
122
|
+
- ".github/PULL_REQUEST_TEMPLATE/pull_request_template.md"
|
122
123
|
- ".github/workflows/main.yml"
|
123
124
|
- ".github/workflows/rspec_rubocop.yml"
|
124
125
|
- ".gitignore"
|
@@ -137,12 +138,27 @@ files:
|
|
137
138
|
- lib/rails_interactive.rb
|
138
139
|
- lib/rails_interactive/message.rb
|
139
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
|
140
144
|
- lib/rails_interactive/templates/setup_brakeman.rb
|
145
|
+
- lib/rails_interactive/templates/setup_bullet.rb
|
141
146
|
- lib/rails_interactive/templates/setup_cancancan.rb
|
142
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
|
143
154
|
- lib/rails_interactive/templates/setup_omniauth.rb
|
144
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
|
145
159
|
- lib/rails_interactive/templates/setup_sidekiq.rb
|
160
|
+
- lib/rails_interactive/templates/setup_slim.rb
|
161
|
+
- lib/rails_interactive/templates/setup_standardrb.rb
|
146
162
|
- lib/rails_interactive/version.rb
|
147
163
|
- rails-interactive.gemspec
|
148
164
|
homepage: https://github.com/oguzsh/rails-interactive
|