rails-interactive 0.1.5 → 0.1.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1d6d7de1b01f37818e7d8f40a4ea4f70e4f7419e0a9289a09a345f8761728bf
4
- data.tar.gz: 6eb6ad5b7193fd37f1d8abadc238806e4a37892bc0f422821f2ef2ec62c69726
3
+ metadata.gz: 603090ac1b9b8c849321c7cba9861f54577c33ca2140fba83f06ba898c229a0a
4
+ data.tar.gz: 8cd7ce670ce1806e6039486aa0a6d26a3b237c571cea9ce501306a3ab5a795c5
5
5
  SHA512:
6
- metadata.gz: aa7219d9f1233d37defe9944d032e5367bdcc0aeda2b4e3e78d8e49b21470f1d4b0f0d39fda2ac87a77782c3801d8e33c450fd3abce5ddcb2c86170735b3ddff
7
- data.tar.gz: 54af5dfed258953ce0439154e4f2cfbc7d239aecd7f3d4c7a15ae12fbfbffdaa51753f647fab8d275a6b3d8b02bced5c94df83252cafefe3e8a8d142db80cc40
6
+ metadata.gz: bd590968411d6381d448f0466d3afd4fb2b43e2599ef51142c22a80d921b317523f943d57f3baa6ec5a89bf4370af0766fb36622ac44bd81cfd088926edd15aa
7
+ data.tar.gz: a11ed5e1d003b4aa98ba0584da41dd6a270735b324c76690632ab627b93ec387f6ae8b354e007145a06ed3dc222efe9b086672af49e9413fa96dd2f5db841a86
@@ -0,0 +1,3 @@
1
+ patreon: oguzsh
2
+ custom: https://www.buymeacoffee.com/oguzhanince
3
+
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails-interactive (0.1.5)
4
+ rails-interactive (0.1.8)
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.3-x86_64-darwin)
114
+ nokogiri (1.13.4-x86_64-darwin)
115
115
  racc (~> 1.4)
116
- nokogiri (1.13.3-x86_64-linux)
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)
@@ -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,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ run 'bundle add brakeman --group "development"'
4
+ Bundler.with_unbundled_env { run "bundle install" }
5
+ run "bundle binstubs brakeman"
6
+ run "bin/brakeman"
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ run "rails db:prepare"
4
+ run "bundle add graphql"
5
+
6
+ Bundler.with_unbundled_env { run "bundle install" }
7
+
8
+ rails_command("generate graphql:install")
9
+
10
+ puts "GraphQL is installed!"
@@ -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,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ run "bundle add kaminari"
4
+
5
+ Bundler.with_unbundled_env { run "bundle install" }
6
+
7
+ puts "Kaminari is 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,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ run "spring stop"
4
+
5
+ gem_group :development, :test do
6
+ gem "rspec-rails"
7
+ end
8
+
9
+ Bundler.with_unbundled_env { run "bundle install" }
10
+
11
+ rails_command "generate rspec:install"
12
+
13
+ puts "RSpec is installed!"
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ gem_group :development do
4
+ gem "rubocop", require: false
5
+ end
6
+
7
+ Bundler.with_unbundled_env { run "bundle install" }
8
+
9
+ run "rubocop --auto-gen-config"
10
+ run "bundle binstubs rubocop"
@@ -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
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ gem_group :development, :test do
4
+ gem "standard"
5
+ end
6
+
7
+ Bundler.with_unbundled_env { run "bundle install" }
8
+
9
+ puts "You can then run Standard from the command line with:"
10
+ puts "bundle exec standardrb"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsInteractive
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.8"
5
5
  end
@@ -24,16 +24,14 @@ module RailsInteractive
24
24
  end
25
25
 
26
26
  def initialize_project
27
- @inputs[:name] = Prompt.new("Enter the name of the project: ", "ask", required: true).perform
28
-
29
- types = { "App" => "", "API" => "--api" }
30
- @inputs[:type] = Prompt.new("Choose project type: ", "select", types, required: true).perform
31
-
32
- database_types = { "PostgreSQL" => "-d postgresql", "MySQL" => "-d mysql", "SQLite" => "" }
33
- @inputs[:database] = Prompt.new("Choose project's database: ", "select", database_types, required: true).perform
34
-
35
- features = %w[devise cancancan omniauth pundit]
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
37
35
 
38
36
  create
39
37
  end
@@ -48,9 +46,21 @@ module RailsInteractive
48
46
 
49
47
  # Move to project folder and install gems
50
48
  Dir.chdir "./#{@inputs[:name]}"
51
- @inputs[:features].each do |feature|
52
- system("bin/rails app:template LOCATION=templates/setup_#{feature}.rb")
53
- end
49
+
50
+ # Features Templates
51
+ handle_multi_options(key: :features)
52
+
53
+ # Code Quality Template
54
+ system("bin/rails app:template LOCATION=templates/setup_#{@inputs[:code_quality_tool]}.rb")
55
+
56
+ # HTML Template Engines
57
+ system("bin/rails app:template LOCATION=templates/setup_#{@inputs[:template_engine]}.rb")
58
+
59
+ # Admin Panel Template
60
+ system("bin/rails app:template LOCATION=templates/setup_#{@inputs[:admin_panel]}.rb")
61
+
62
+ # Testing tools Template
63
+ handle_multi_options(key: :testing_tools)
54
64
 
55
65
  # Prepare project requirements and give instructions
56
66
  Message.prepare
@@ -60,7 +70,7 @@ module RailsInteractive
60
70
  base = "rails new"
61
71
  cmd = ""
62
72
 
63
- @inputs.each { |_key, value| cmd += "#{value} " }
73
+ @inputs.first(3).each { |_key, value| cmd += "#{value} " }
64
74
 
65
75
  "#{base} #{cmd}".strip!
66
76
  end
@@ -68,5 +78,62 @@ module RailsInteractive
68
78
  def copy_templates_to_project
69
79
  FileUtils.cp_r "#{__dir__}/rails_interactive/templates", "./#{@inputs[:name]}"
70
80
  end
81
+
82
+ private
83
+
84
+ def handle_multi_options(key:)
85
+ @inputs[key].each do |value|
86
+ system("bin/rails app:template LOCATION=templates/setup_#{value}.rb")
87
+ end
88
+ end
89
+
90
+ def name
91
+ @inputs[:name] = Prompt.new("Enter the name of the project: ", "ask", required: true).perform
92
+ end
93
+
94
+ def type
95
+ types = { "App" => "", "API" => "--api" }
96
+ @inputs[:type] = Prompt.new("Choose project type: ", "select", types, required: true).perform
97
+ end
98
+
99
+ def database
100
+ database_types = { "PostgreSQL" => "-d postgresql", "MySQL" => "-d mysql", "SQLite" => "" }
101
+
102
+ @inputs[:database] = Prompt.new("Choose project's database: ", "select", database_types, required: true).perform
103
+ end
104
+
105
+ def features
106
+ features = %w[devise cancancan omniauth pundit brakeman sidekiq graphql kaminari]
107
+
108
+ @inputs[:features] = Prompt.new("Choose project features: ", "multi_select", features).perform
109
+ end
110
+
111
+ def code_quality_tool
112
+ code_quality_tool = { "Rubocop" => "rubocop", "StandardRB" => "standardrb" }
113
+
114
+ @inputs[:code_quality_tool] =
115
+ Prompt.new("Choose project code quality tool: ", "select", code_quality_tool).perform
116
+ end
117
+
118
+ def admin_panel
119
+ admin_panel = { "RailsAdmin" => "rails_admin", "Avo" => "avo" }
120
+
121
+ @inputs[:admin_panel] =
122
+ Prompt.new("Choose project's admin panel: ", "select", admin_panel).perform
123
+ end
124
+
125
+ def testing_tools
126
+ testing_tools = %w[rspec]
127
+
128
+ @inputs[:testing_tools] =
129
+ Prompt.new("Choose project's testing tools: ", "multi_select", testing_tools).perform
130
+ end
131
+
132
+ def template_engines
133
+ template_engines = { "HAML" => "haml", "SLIM" => "slim" }
134
+
135
+ @inputs[:template_engine] =
136
+ Prompt.new("Choose project's template engine: ", "select", template_engines).perform
137
+ end
71
138
  end
72
139
  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.5
4
+ version: 0.1.8
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 00:00:00.000000000 Z
11
+ date: 2022-04-24 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,10 +137,21 @@ 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_avo.rb
141
+ - lib/rails_interactive/templates/setup_brakeman.rb
139
142
  - lib/rails_interactive/templates/setup_cancancan.rb
140
143
  - lib/rails_interactive/templates/setup_devise.rb
144
+ - lib/rails_interactive/templates/setup_graphql.rb
145
+ - lib/rails_interactive/templates/setup_haml.rb
146
+ - lib/rails_interactive/templates/setup_kaminari.rb
141
147
  - lib/rails_interactive/templates/setup_omniauth.rb
142
148
  - lib/rails_interactive/templates/setup_pundit.rb
149
+ - lib/rails_interactive/templates/setup_rails_admin.rb
150
+ - lib/rails_interactive/templates/setup_rspec.rb
151
+ - lib/rails_interactive/templates/setup_rubocop.rb
152
+ - lib/rails_interactive/templates/setup_sidekiq.rb
153
+ - lib/rails_interactive/templates/setup_slim.rb
154
+ - lib/rails_interactive/templates/setup_standardrb.rb
143
155
  - lib/rails_interactive/version.rb
144
156
  - rails-interactive.gemspec
145
157
  homepage: https://github.com/oguzsh/rails-interactive