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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1131b1845ea01796436e2f9b8365bf7ca6cacd48684b365e9f877fe9281d8793
4
- data.tar.gz: 75513f09d007ee151c3d2f0300185eba131c3ae6aa4de8cb85f0df78af9873e1
3
+ metadata.gz: 75d2314dfc92d4b4b435a0d460ead1cdd929c4a38a4b1e7d61ac4c6348153865
4
+ data.tar.gz: caa1efa0259cbdb5390235f10e13d280b126e3b179b2063fab5754a52949b7b7
5
5
  SHA512:
6
- metadata.gz: 64401e715a895a69224790cea8172f2638f0f57201439ae610b736fafb406867096b439c4f5881bbd435e8df8a59ea21113df4ed2e7ea846cfd33b846c2c7010
7
- data.tar.gz: e313ffb15b81f39b7275389f935b2a38a6a3ef72a6bc4fd77653ff0d3c6cf06030309e399daaa9bb8bd8b2aa767b54eb4de2ec27e28fbfb2203073f46143d608
6
+ metadata.gz: 60eed5fe9853045e1b5b56ab5345ca5d4ab56709eed27a11473de6d9661e95e70a4ab42aeca75ca0df2bc13378291458a23449a1b5afbe7acf384f9ed35436cd
7
+ data.tar.gz: af53d57979c6a78ac62dbc1e7571d0db39e491a6c3c6582c2c048e5287a6db96a20725b464aa596f58848b681592e7f02632b53e22f76e049e7b312e8968adce
data/.github/FUNDING.yml CHANGED
@@ -1,2 +1,3 @@
1
- patreon: oguzsh # Replace with a single Patreon username
1
+ patreon: oguzsh
2
+ custom: https://www.buymeacoffee.com/oguzhanince
2
3
 
@@ -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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails-interactive (0.1.6)
4
+ rails-interactive (0.1.9)
5
5
  tty-prompt
6
6
 
7
7
  GEM
@@ -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,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ run 'bundle add awesome_print --group "development"'
4
+ Bundler.with_unbundled_env { run "bundle install" }
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ gem_group :development do
4
+ gem "better_errors"
5
+ gem "binding_of_caller"
6
+ end
7
+
8
+ Bundler.with_unbundled_env { run "bundle install" }
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ run "bundle add bullet --group 'development'"
4
+
5
+ Bundler.with_unbundled_env { run "bundle install" }
6
+
7
+ run "bundle exec rails g bullet:install"
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ run "bundle add faker --group 'development' 'test'"
4
+
5
+ Bundler.with_unbundled_env { run "bundle install" }
@@ -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,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,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,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,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.6"
4
+ VERSION = "0.1.9"
5
5
  end
@@ -24,20 +24,20 @@ 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 brakeman sidekiq]
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
- @inputs[:features].each do |feature|
52
- system("bin/rails app:template LOCATION=templates/setup_#{feature}.rb")
53
- end
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.6
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 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
@@ -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