diff --git a/.rubocop.yml b/.rubocop.yml
index 277c329..5c8aba4 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -19,4 +19,10 @@ Metrics/MethodLength:
Max: 12
Metrics/CyclomaticComplexity:
- Max: 25
\ No newline at end of file
+ Max: 25
+
+Metrics/PerceivedComplexity:
+ Max: 10
+
+Metrics/AbcSize:
+ Enabled: false
\ No newline at end of file
diff --git a/Gemfile.lock b/Gemfile.lock
index a8d9676..042a166 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,73 +1,73 @@
PATH
remote: .
specs:
- rails-interactive (2.1.2)
+ rails-interactive (2.1.3)
tty-prompt
GEM
remote: https://rubygems.org/
specs:
- actioncable (7.0.3)
- actionpack (= 7.0.3)
- activesupport (= 7.0.3)
+ actioncable (7.0.3.1)
+ actionpack (= 7.0.3.1)
+ activesupport (= 7.0.3.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
- actionmailbox (7.0.3)
- actionpack (= 7.0.3)
- activejob (= 7.0.3)
- activerecord (= 7.0.3)
- activestorage (= 7.0.3)
- activesupport (= 7.0.3)
+ actionmailbox (7.0.3.1)
+ actionpack (= 7.0.3.1)
+ activejob (= 7.0.3.1)
+ activerecord (= 7.0.3.1)
+ activestorage (= 7.0.3.1)
+ activesupport (= 7.0.3.1)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
- actionmailer (7.0.3)
- actionpack (= 7.0.3)
- actionview (= 7.0.3)
- activejob (= 7.0.3)
- activesupport (= 7.0.3)
+ actionmailer (7.0.3.1)
+ actionpack (= 7.0.3.1)
+ actionview (= 7.0.3.1)
+ activejob (= 7.0.3.1)
+ activesupport (= 7.0.3.1)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
- actionpack (7.0.3)
- actionview (= 7.0.3)
- activesupport (= 7.0.3)
+ actionpack (7.0.3.1)
+ actionview (= 7.0.3.1)
+ activesupport (= 7.0.3.1)
rack (~> 2.0, >= 2.2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
- actiontext (7.0.3)
- actionpack (= 7.0.3)
- activerecord (= 7.0.3)
- activestorage (= 7.0.3)
- activesupport (= 7.0.3)
+ actiontext (7.0.3.1)
+ actionpack (= 7.0.3.1)
+ activerecord (= 7.0.3.1)
+ activestorage (= 7.0.3.1)
+ activesupport (= 7.0.3.1)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
- actionview (7.0.3)
- activesupport (= 7.0.3)
+ actionview (7.0.3.1)
+ activesupport (= 7.0.3.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
- activejob (7.0.3)
- activesupport (= 7.0.3)
+ activejob (7.0.3.1)
+ activesupport (= 7.0.3.1)
globalid (>= 0.3.6)
- activemodel (7.0.3)
- activesupport (= 7.0.3)
- activerecord (7.0.3)
- activemodel (= 7.0.3)
- activesupport (= 7.0.3)
- activestorage (7.0.3)
- actionpack (= 7.0.3)
- activejob (= 7.0.3)
- activerecord (= 7.0.3)
- activesupport (= 7.0.3)
+ activemodel (7.0.3.1)
+ activesupport (= 7.0.3.1)
+ activerecord (7.0.3.1)
+ activemodel (= 7.0.3.1)
+ activesupport (= 7.0.3.1)
+ activestorage (7.0.3.1)
+ actionpack (= 7.0.3.1)
+ activejob (= 7.0.3.1)
+ activerecord (= 7.0.3.1)
+ activesupport (= 7.0.3.1)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
- activesupport (7.0.3)
+ activesupport (7.0.3.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
@@ -84,8 +84,9 @@ GEM
erubi (1.10.0)
globalid (1.0.0)
activesupport (>= 5.0)
- i18n (1.10.0)
+ i18n (1.12.0)
concurrent-ruby (~> 1.0)
+ json (2.6.2)
loofah (2.18.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
@@ -94,7 +95,7 @@ GEM
marcel (1.0.2)
method_source (1.0.0)
mini_mime (1.1.2)
- minitest (5.15.0)
+ minitest (5.16.2)
net-imap (0.2.3)
digest
net-protocol
@@ -110,9 +111,9 @@ GEM
net-protocol
timeout
nio4r (2.5.8)
- nokogiri (1.13.6-x86_64-darwin)
+ nokogiri (1.13.7-x86_64-darwin)
racc (~> 1.4)
- nokogiri (1.13.6-x86_64-linux)
+ nokogiri (1.13.7-x86_64-linux)
racc (~> 1.4)
parallel (1.22.1)
parser (3.1.2.0)
@@ -123,31 +124,31 @@ GEM
coderay (~> 1.1)
method_source (~> 1.0)
racc (1.6.0)
- rack (2.2.3.1)
- rack-test (1.1.0)
- rack (>= 1.0, < 3)
- rails (7.0.3)
- actioncable (= 7.0.3)
- actionmailbox (= 7.0.3)
- actionmailer (= 7.0.3)
- actionpack (= 7.0.3)
- actiontext (= 7.0.3)
- actionview (= 7.0.3)
- activejob (= 7.0.3)
- activemodel (= 7.0.3)
- activerecord (= 7.0.3)
- activestorage (= 7.0.3)
- activesupport (= 7.0.3)
+ rack (2.2.4)
+ rack-test (2.0.2)
+ rack (>= 1.3)
+ rails (7.0.3.1)
+ actioncable (= 7.0.3.1)
+ actionmailbox (= 7.0.3.1)
+ actionmailer (= 7.0.3.1)
+ actionpack (= 7.0.3.1)
+ actiontext (= 7.0.3.1)
+ actionview (= 7.0.3.1)
+ activejob (= 7.0.3.1)
+ activemodel (= 7.0.3.1)
+ activerecord (= 7.0.3.1)
+ activestorage (= 7.0.3.1)
+ activesupport (= 7.0.3.1)
bundler (>= 1.15.0)
- railties (= 7.0.3)
+ railties (= 7.0.3.1)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
- rails-html-sanitizer (1.4.2)
+ rails-html-sanitizer (1.4.3)
loofah (~> 2.3)
- railties (7.0.3)
- actionpack (= 7.0.3)
- activesupport (= 7.0.3)
+ railties (7.0.3.1)
+ actionpack (= 7.0.3.1)
+ activesupport (= 7.0.3.1)
method_source
rake (>= 12.2)
thor (~> 1.0)
@@ -169,7 +170,8 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-support (3.11.0)
- rubocop (1.30.0)
+ rubocop (1.31.2)
+ json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
@@ -178,7 +180,7 @@ GEM
rubocop-ast (>= 1.18.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
- rubocop-ast (1.18.0)
+ rubocop-ast (1.19.1)
parser (>= 3.1.1.0)
ruby-progressbar (1.11.0)
strscan (3.0.3)
@@ -196,13 +198,13 @@ GEM
tty-screen (0.8.1)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
- unicode-display_width (2.1.0)
+ unicode-display_width (2.2.0)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
wisper (2.0.1)
yaml (0.2.0)
- zeitwerk (2.5.4)
+ zeitwerk (2.6.0)
PLATFORMS
x86_64-darwin-20
diff --git a/README.md b/README.md
index e9d04a3..59ef073 100644
--- a/README.md
+++ b/README.md
@@ -1,34 +1,69 @@
-[](https://asciinema.org/a/mFutWNTzym5aZPqK7AgBSMjLE)
+
+

+
Rails Interactive
+
+
+
+
+ Rails Interactive is a CLI for Rails 7. Developers can create their Ruby on Rails projects with just a few keyboard clicks ๐
+
+
+ ยท
+ Report Bug
+ ยท
+ Request Feature
+
+
-# Rails::Interactive
-[](https://badge.fury.io/rb/rails-interactive)
+
+
+ [](https://badge.fury.io/rb/rails-interactive)
+
+
-## Installation
+
+### โก๏ธ Prerequisites
+
+- Ruby >= 2.7.5
+
+## โ๏ธ Installation
+Make sure you have Ruby installed ([Ruby Homebrew](https://formulae.brew.sh/formula/ruby)). Version 2.7.5 or higher is required.
```bash
$ gem install rails-interactive
```
-## Usage
+## ๐ก Usage
```bash
$ rails-interactive new
```
+
-## Development
+## ๐ Contributing
-After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
+If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
+Don't forget to give the project a star! Thanks again!
-To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
+1. Fork the Project
+2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
+3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
+4. Push to the Branch (`git push origin feature/AmazingFeature`)
+5. Open a Pull Request
-## Contributing
+## โ Supporters
+Rails Interactive is an open source project that get motivate on donations ๐ฅณ If you want to support Rails Interactive, you can โ buy a coffee [here](https://www.buymeacoffee.com/oguzhanince) or be patron on [Patreon](https://patreon.com/oguzsh)
-Bug reports and pull requests are welcome on GitHub at https://github.com/oguzsh/rails-interactive. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/oguzsh/rails-interactive/blob/master/CODE_OF_CONDUCT.md).
+| | User | Donation |
+|------------------------- |------: |---------: |
+|
| [@sahin](https://github.com/sahin) | Gold Sponsor |
+|
| [@sadikay](https://github.com/sadikay) | Silver Sponsor |
+|
| [@adamdilek](https://github.com/adamdilek) | Silver Sponsor |
-## License
+## โ ๏ธ License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
-## Code of Conduct
+## Contact
-Everyone interacting in the Rails::Interactive project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/oguzsh/rails-interactive/blob/master/CODE_OF_CONDUCT.md).
+Oguzhan Ince - [@oguz_sh](https://twitter.com/oguz_sh) - oguzhan824@gmail.com
diff --git a/lib/cli/config/categories.yml b/lib/cli/config/categories.yml
index 26cc738..e3cadd2 100644
--- a/lib/cli/config/categories.yml
+++ b/lib/cli/config/categories.yml
@@ -25,32 +25,42 @@
type: "select"
required: false
-
- name: code_quality
+ name: frontend
weight: 6
type: "select"
required: false
-
- name: background_job
+ name: css_framework
weight: 7
type: "select"
required: false
-
- name: security
+ name: background_job
weight: 8
type: "select"
required: false
-
- name: admin_panel
+ name: code_quality
weight: 9
type: "select"
required: false
-
- name: features
+ name: security
weight: 10
+ type: "select"
+ required: false
+-
+ name: admin_panel
+ weight: 11
+ type: "select"
+ required: false
+-
+ name: features
+ weight: 12
type: "multi_select"
required: false
-
name: development
- weight: 11
+ weight: 13
type: "multi_select"
required: false
\ No newline at end of file
diff --git a/lib/cli/config/commands.yml b/lib/cli/config/commands.yml
index cf495e8..0ad6539 100644
--- a/lib/cli/config/commands.yml
+++ b/lib/cli/config/commands.yml
@@ -151,4 +151,22 @@
name: Capybara
category: end_to_end_testing
description: "Acceptance test framework for web applications. For details: https://github.com/teamcapybara/capybara"
+ dependencies: null
+-
+ identifier: stimulus
+ name: StimulusJS
+ category: frontend
+ description: "A modest JavaScript framework for the HTML you already have. For details: https://github.com/hotwired/stimulus"
+ dependencies: null
+-
+ identifier: react
+ name: ReactJS
+ category: frontend
+ description: "A declarative, efficient, and flexible JavaScript library for building user interfaces. For details: https://github.com/facebook/react/"
+ dependencies: null
+-
+ identifier: tailwind
+ name: Tailwind
+ category: css_framework
+ description: "A utility-first CSS framework for rapid UI development. For details: https://github.com/tailwindlabs/tailwindcss"
dependencies: null
\ No newline at end of file
diff --git a/lib/cli/templates/setup_avo.rb b/lib/cli/templates/setup_avo.rb
deleted file mode 100644
index 898e201..0000000
--- a/lib/cli/templates/setup_avo.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# frozen_string_literal: true
-
-run "rails db:prepare"
-run "bundle add avo"
-
-Bundler.with_unbundled_env { run "bundle install" }
-
-rails_command("generate avo:install")
-
-puts "Avo is installed! You can go to http://localhost:3000/avo for next steps"
diff --git a/lib/cli/templates/setup_awesome_print.rb b/lib/cli/templates/setup_awesome_print.rb
deleted file mode 100644
index 52fff42..0000000
--- a/lib/cli/templates/setup_awesome_print.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-# frozen_string_literal: true
-
-run 'bundle add awesome_print --group "development"'
-Bundler.with_unbundled_env { run "bundle install" }
diff --git a/lib/cli/templates/setup_better_errors.rb b/lib/cli/templates/setup_better_errors.rb
deleted file mode 100644
index 8fe50cb..0000000
--- a/lib/cli/templates/setup_better_errors.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-# frozen_string_literal: true
-
-gem_group :development do
- gem "better_errors"
- gem "binding_of_caller"
-end
-
-Bundler.with_unbundled_env { run "bundle install" }
diff --git a/lib/cli/templates/setup_brakeman.rb b/lib/cli/templates/setup_brakeman.rb
deleted file mode 100644
index b823c88..0000000
--- a/lib/cli/templates/setup_brakeman.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-# frozen_string_literal: true
-
-run 'bundle add brakeman --group "development"'
-Bundler.with_unbundled_env { run "bundle install" }
-run "bundle binstubs brakeman"
-run "bin/brakeman"
diff --git a/lib/cli/templates/setup_bullet.rb b/lib/cli/templates/setup_bullet.rb
deleted file mode 100644
index 9d58575..0000000
--- a/lib/cli/templates/setup_bullet.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-run "bundle add bullet --group 'development'"
-
-Bundler.with_unbundled_env { run "bundle install" }
-
-run "bundle exec rails g bullet:install"
diff --git a/lib/cli/templates/setup_cancancan.rb b/lib/cli/templates/setup_cancancan.rb
deleted file mode 100644
index 78e1e16..0000000
--- a/lib/cli/templates/setup_cancancan.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-run "bundle add cancancan"
-
-Bundler.with_unbundled_env { run "bundle install" }
-
-rails_command "generate cancan:ability"
diff --git a/lib/cli/templates/setup_faker.rb b/lib/cli/templates/setup_faker.rb
deleted file mode 100644
index 12889dd..0000000
--- a/lib/cli/templates/setup_faker.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# frozen_string_literal: true
-
-run "bundle add faker --group 'development' 'test'"
-
-Bundler.with_unbundled_env { run "bundle install" }
diff --git a/lib/cli/templates/setup_graphql.rb b/lib/cli/templates/setup_graphql.rb
deleted file mode 100644
index 6423ea4..0000000
--- a/lib/cli/templates/setup_graphql.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# frozen_string_literal: true
-
-run "rails db:prepare"
-run "bundle add graphql"
-
-Bundler.with_unbundled_env { run "bundle install" }
-
-rails_command("generate graphql:install")
-
-puts "GraphQL is installed!"
diff --git a/lib/cli/templates/setup_haml.rb b/lib/cli/templates/setup_haml.rb
deleted file mode 100644
index f7bbd68..0000000
--- a/lib/cli/templates/setup_haml.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-def bundle_install
- Bundler.with_unbundled_env { run "bundle install" }
-end
-
-run "bundle add haml"
-bundle_install
-
-if yes?("Would you like to convert your existing *.erb files to *.haml files? [y/n]")
- run "bundle add erb2haml --group 'development'"
- bundle_install
- if yes?("Would you like to keep the original *.erb files? [y/n]")
- rake "haml:convert_erbs"
- else
- rake "haml:replace_erbs"
- end
-end
diff --git a/lib/cli/templates/setup_kaminari.rb b/lib/cli/templates/setup_kaminari.rb
deleted file mode 100644
index c0d42f8..0000000
--- a/lib/cli/templates/setup_kaminari.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-run "bundle add kaminari"
-
-Bundler.with_unbundled_env { run "bundle install" }
-
-puts "Kaminari is installed!"
diff --git a/lib/cli/templates/setup_letter_opener.rb b/lib/cli/templates/setup_letter_opener.rb
deleted file mode 100644
index 5d621be..0000000
--- a/lib/cli/templates/setup_letter_opener.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-run 'bundle add letter_opener --group "development"'
-
-Bundler.with_unbundled_env { run "bundle install" }
-
-inject_into_file "config/environments/development.rb", after: "config.action_mailer.perform_caching = false\n" do
- <<-RUBY
-
- config.action_mailer.delivery_method = :letter_opener
- config.action_mailer.perform_deliveries = true
- RUBY
-end
-
-puts "Letter Opener is now installed!"
diff --git a/lib/cli/templates/setup_pundit.rb b/lib/cli/templates/setup_pundit.rb
deleted file mode 100644
index b9ac10f..0000000
--- a/lib/cli/templates/setup_pundit.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-run "bundle add pundit"
-
-puts "Add - Pundit module to Application Controller"
-puts ""
-
-inject_into_file "app/controllers/application_controller.rb",
- after: "class ApplicationController < ActionController::Base\n" do
- " include Pundit\n"
-end
-
-puts "Run - Pundit Generator"
-
-rails_command("generate pundit:install")
diff --git a/lib/cli/templates/setup_rails_admin.rb b/lib/cli/templates/setup_rails_admin.rb
deleted file mode 100644
index 57bb46e..0000000
--- a/lib/cli/templates/setup_rails_admin.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# frozen_string_literal: true
-
-run "rails db:prepare"
-run "bundle add rails_admin"
-
-Bundler.with_unbundled_env { run "bundle install" }
-
-rails_command("generate rails_admin:install")
-
-puts "RailsAdmin is installed! You can go to your admin panel at /admin"
diff --git a/lib/cli/templates/setup_react.rb b/lib/cli/templates/setup_react.rb
new file mode 100644
index 0000000..7227661
--- /dev/null
+++ b/lib/cli/templates/setup_react.rb
@@ -0,0 +1,100 @@
+# frozen_string_literal: true
+
+# NPM
+run "yarn init -y"
+run "yarn add esbuild react react-dom"
+
+# rubocop:disable Layout/LineLength
+run "npm set-script build 'esbuild app/javascript/*.* --bundle --sourcemap --loader:.js=jsx --outdir=app/assets/javascripts'"
+# rubocop:enable Layout/LineLength
+#
+# Foreman
+run "gem install foreman"
+run 'echo "#!/usr/bin/env bash\nforeman start -f Procfile.dev "$@"" > bin/dev'
+run "echo 'web: bin/rails server -p 3000\njs: yarn build --watch' > Procfile.dev"
+run "chmod u+x bin/dev"
+
+# Component Helper from Ruby on Rails
+inject_into_file "app/helpers/application_helper.rb", after: "module ApplicationHelper" do
+ <<~RB
+
+ def react_component(component_name, **props)
+ tag.div(data: {
+ react_component: component_name,
+ props: props.to_json
+ }) { '' }
+ end
+ RB
+end
+
+# Include JS to application.html.erb
+inject_into_file "app/views/layouts/application.html.erb", after: "<%= javascript_importmap_tags %>" do
+ <<~ERB
+
+ <%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>
+ ERB
+end
+
+# Component Mounter for JS
+create_file "app/javascript/mount.js" do
+ <<~JAVASCRIPT
+ import React from 'react';
+ import ReactDOM from 'react-dom';
+
+ export default function mount(components = {}) {
+ const mountPoints = document.querySelectorAll('[data-react-component]');
+ mountPoints.forEach((mountPoint) => {
+ const { dataset } = mountPoint;
+ const componentName = dataset.reactComponent;
+ const Component = components[componentName];
+
+ if (Component) {
+ const props = JSON.parse(dataset.props);
+ ReactDOM.render(, mountPoint);
+ }
+ });
+ }
+ JAVASCRIPT
+end
+
+# Example React Component
+create_file "app/javascript/components/hello.jsx" do
+ <<~JAVASCRIPT
+ import React from "react";
+
+ const Hello = () => HELLO WORLD!
+
+ export default Hello;
+ JAVASCRIPT
+end
+
+# rubocop:disable Layout/LineLength
+# Application JS file update
+inject_into_file "app/javascript/application.js",
+ after: "// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails" do
+ <<~JAVASCRIPT
+
+ // Components
+ import Hello from "./components/hello"
+
+ // Component Mounter
+ import mount from './mount'
+
+ // Mount Components
+ mount({ Hello });
+ JAVASCRIPT
+end
+# rubocop:enable Layout/LineLength
+
+run "yarn build"
+
+# Example Page for Component Test
+rails_command "g controller Home index"
+inject_into_file "app/views/home/index.html.erb", after: "Find me in app/views/home/index.html.erb
" do
+ <<~ERB
+
+ <%= react_component "Hello" %>
+ ERB
+end
+
+puts "React is installed! You can run bin/dev then go to home/index and see the Hello World component."
diff --git a/lib/cli/templates/setup_rspec.rb b/lib/cli/templates/setup_rspec.rb
deleted file mode 100644
index daa2bfb..0000000
--- a/lib/cli/templates/setup_rspec.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-run "spring stop"
-
-gem_group :development, :test do
- gem "rspec-rails"
-end
-
-Bundler.with_unbundled_env { run "bundle install" }
-
-rails_command "generate rspec:install"
-
-puts "RSpec is installed!"
diff --git a/lib/cli/templates/setup_rubocop.rb b/lib/cli/templates/setup_rubocop.rb
deleted file mode 100644
index 519b9ba..0000000
--- a/lib/cli/templates/setup_rubocop.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# frozen_string_literal: true
-
-gem_group :development do
- gem "rubocop", require: false
-end
-
-Bundler.with_unbundled_env { run "bundle install" }
-
-run "rubocop --auto-gen-config"
-run "bundle binstubs rubocop"
diff --git a/lib/cli/templates/setup_sidekiq.rb b/lib/cli/templates/setup_sidekiq.rb
deleted file mode 100644
index 75245b5..0000000
--- a/lib/cli/templates/setup_sidekiq.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-# frozen_string_literal: true
-
-def file_contains?(filename, string)
- File.foreach(filename).detect { |line| line.include?(string) }
-end
-
-run "bundle add sidekiq"
-run "bundle add redis" unless file_contains? "Gemfile", "Gem 'redis'"
-
-Bundler.with_unbundled_env { run "bundle install" }
-
-# rubocop:disable Naming/HeredocDelimiterNaming
-application do
- <<~EOF
- config.active_job.queue_adapter = :sidekiq
- EOF
-end
-
-inject_into_file "config/routes.rb" do
- <<~EOF
- require "sidekiq/web"
- if Rails.env.production?
- Sidekiq::Web.use Rack::Auth::Basic do |username, password|
- ActiveSupport::SecurityUtils.secure_compare(::Digest::SHA256.hexdigest(username), ::Digest::SHA256.hexdigest(ENV["SIDEKIQ_USERNAME"])) &
- ActiveSupport::SecurityUtils.secure_compare(::Digest::SHA256.hexdigest(password), ::Digest::SHA256.hexdigest(ENV["SIDEKIQ_PASSWORD"]))
- end
- end
- EOF
-end
-# rubocop:enable Naming/HeredocDelimiterNaming
-
-route 'mount Sidekiq::Web => "/sidekiq"'
diff --git a/lib/cli/templates/setup_slim.rb b/lib/cli/templates/setup_slim.rb
deleted file mode 100644
index bc62061..0000000
--- a/lib/cli/templates/setup_slim.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# frozen_string_literal: true
-
-def bundle_install
- Bundler.with_unbundled_env { run "bundle install" }
-end
-
-run "bundle add slim-rails"
-
-bundle_install
-
-if yes?("Would you like to convert your existing *.erb files to *.slim files? [y/n]")
- run "bundle add html2slim --group 'development'"
- bundle_install
- if yes?("Would you like to keep the original *.erb files? [y/n]")
- run "erb2slim app/views"
- else
- run "erb2slim app/views -d"
- end
-end
diff --git a/lib/cli/templates/setup_standardrb.rb b/lib/cli/templates/setup_standardrb.rb
deleted file mode 100644
index 4bb855e..0000000
--- a/lib/cli/templates/setup_standardrb.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# frozen_string_literal: true
-
-gem_group :development, :test do
- gem "standard"
-end
-
-Bundler.with_unbundled_env { run "bundle install" }
-
-puts "You can then run Standard from the command line with:"
-puts "bundle exec standardrb"
diff --git a/lib/cli/templates/setup_stimulus.rb b/lib/cli/templates/setup_stimulus.rb
new file mode 100644
index 0000000..4d48405
--- /dev/null
+++ b/lib/cli/templates/setup_stimulus.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+run "bundle add turbo-rails"
+run "bundle add stimulus-rails"
+
+Bundler.with_unbundled_env { run "bundle install" }
+
+rails_command "turbo:install stimulus:install"
diff --git a/lib/cli/templates/setup_tailwind.rb b/lib/cli/templates/setup_tailwind.rb
new file mode 100644
index 0000000..8e7a2b8
--- /dev/null
+++ b/lib/cli/templates/setup_tailwind.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+def package?(package)
+ require "json"
+
+ file = File.open("package.json") if File.file?("package.json")
+
+ packages = JSON.parse(file.read) if file
+
+ packages["dependencies"].include?(package) if packages
+end
+
+run "bundle add tailwindcss-rails"
+
+if package?("react")
+ run "rm Procfile.dev"
+ run "rm bin/dev"
+end
+
+rails_command "tailwindcss:install"
+
+if package?("react")
+ run "rm Procfile.dev"
+ run "echo 'web: bin/rails server -p 3000\njs: yarn build --watch\ncss: bin/rails tailwindcss:watch' > Procfile.dev"
+end
diff --git a/lib/cli/version.rb b/lib/cli/version.rb
index 7c1f8f7..9d99fab 100644
--- a/lib/cli/version.rb
+++ b/lib/cli/version.rb
@@ -2,6 +2,6 @@
module RailsInteractive
class CLI
- VERSION = "2.1.2"
+ VERSION = "2.1.3"
end
end
diff --git a/lib/rails_interactive.rb b/lib/rails_interactive.rb
index 0ffdc93..9b60e7c 100644
--- a/lib/rails_interactive.rb
+++ b/lib/rails_interactive.rb
@@ -63,7 +63,7 @@ def setup
@inputs.first(3).each { |_key, value| cmd += "#{value} " unless value.empty? }
- "#{base} #{cmd} -q"
+ "#{base} #{cmd} -q --skip-hotwire"
end
def create_project
@@ -72,7 +72,7 @@ def create_project
# Create project
system(setup)
# Install gems
- intall_gems
+ install_gems
# Prepare project requirements and give instructions
Utils.sign_project
Message.prepare
@@ -95,19 +95,21 @@ def create_command_list(commands, category_type)
list
end
- def intall_gems
+ def install_gems
# Copy template files to project folder
Utils.copy_templates_to_project(@inputs[:name])
@inputs.each do |key, value|
next if %i[name type database].include?(key) || value.is_a?(Array) && value.empty? || value.nil?
- dependencies = @commands.dependencies(value)
-
+ dependencies ||= @commands.dependencies(value)
@handler.handle_multi_options(value, dependencies) if value.is_a?(Array)
@handler.handle_option(value, dependencies) if value.is_a?(String)
end
+ # Prepare database for project everytime
+ system("bin/rails db:prepare")
+
# Remove templates folder from project folder
Utils.remove_templates(@inputs[:name])
end