lazy_rails 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e11c83318617368bb163de32a786fe1f57a0864943e63294eb3272ed47ab7ea
4
- data.tar.gz: f2b61c194fdf1a7c08000a228bc3e3d8a115931ea07adb33ba0cab8cbb322f76
3
+ metadata.gz: f21a8760eee41e80888c8c6ecd3a89d66498d7808f39808f68a1286e54cdcaea
4
+ data.tar.gz: d04a62658292e5ff484450de7449b134c6535ba0233d0719fa2d5918e1237d1c
5
5
  SHA512:
6
- metadata.gz: 054ce64d6a312b867cedb033cfa05475a76ee3fce543ed4468d99d25a74273ae8435e5fb8fd06540fc8edc8ebf48206df1101b9cae52aaa7429aaf500b6c8c63
7
- data.tar.gz: 6c0e76272dcdab9874882eff419d22e181528e99b33f9b7393de4af9e55185cee2e4724494fa25065f0e7bcfec08c9d07ae828533740e2b681395a85906441bc
6
+ metadata.gz: d97f95a95b4beae9aab0a2583be1180c93485ccdab927d2d2494dfe2b124a325452fa93af7978b37d0dac8dc7d71731305a24a0da82f17788be9fe5ad2414dc2
7
+ data.tar.gz: 394fa356d1f960c3a7c488897405cd4dd55712d019f49ff67b78218b3aa92f1dc43434df5c0a52901df95b9abdc2db68e02e02dbb17a793adae496707329ef09
data/README.md CHANGED
@@ -1,35 +1,78 @@
1
1
  # LazyRails
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ LazyRails simplifies Rails project creation and tool installation, addressing two common pain points:
4
4
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/lazy_rails`. To experiment with that code, run `bin/console` for an interactive prompt.
5
+ 1. Simplifying the verbose command for creating new Rails apps.
6
+ 2. Customizing the default tools installed with a new Rails project.
6
7
 
7
- ## Installation
8
-
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
8
+ ## Features
10
9
 
11
- Install the gem and add to the application's Gemfile by executing:
10
+ - Interactive guide for creating new Rails projects
11
+ - On-the-fly addition and installation of popular gems and tools. No more open documentation and copy-paste commands.
12
12
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
13
+ ## Installation
14
14
 
15
- If bundler is not being used to manage dependencies, install the gem by executing:
16
15
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
16
+ Install globally:
17
+ ```bash
18
+ gem install lazy_rails
19
+ ```
18
20
 
19
21
  ## Usage
20
22
 
21
- TODO: Write usage instructions here
23
+ Create a new Rails project:
24
+ ```bash
25
+ lazy_rails new
26
+ ```
22
27
 
23
- ## Development
28
+ ![LazyRails Demo](lazy_rails_new_example2.gif)
24
29
 
25
- 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.
30
+ ## Development
26
31
 
27
- 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).
32
+ 1. Clone the repo: `git clone https://github.com/[USERNAME]/lazy_rails.git`
33
+ 2. Install dependencies: `bin/setup`
34
+ 3. Run tests: `rake spec`
35
+ 4. Start console: `bin/console`
36
+
37
+ Local installation: `bundle exec rake install`
38
+
39
+ ## Roadmap
40
+
41
+ - [ ] Selection of Rails version (at least last 3)
42
+ - [ ] View template selection (ERB, Haml, Slim)
43
+ - [ ] Test tool selection (RSpec, Minitest, Test::Unit)
44
+ - [ ] Linter selection (RuboCop, Standard)
45
+ - [ ] CSS processor selection (Tailwind, Bootstrap, Bulma, PostCSS, Sass)
46
+ - [ ] JavaScript processor selection (Importmap, Bun, Webpack, esbuild, Rollup)
47
+ - [ ] Database selection (SQLite3, MySQL, PostgreSQL)
48
+ - [ ] App type selection (API, Web)
49
+ - [ ] Basic setup customization (Action Cable, Active Job, Action Mailer, Action Mailbox)
50
+ - [ ] On-the-fly popular gem installation (Devise, Sidekiq, Solid Queue)
51
+ - [ ] Improve documentation
52
+ - [ ] Increase test coverage
53
+ - [ ] Enhance error handling and user feedback
54
+
55
+ ✅ Completed:
56
+ - [x] Basic CLI structure
57
+ - [x] 'new' command for project generation
28
58
 
29
59
  ## Contributing
30
60
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/lazy_rails.
61
+ Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
32
62
 
33
63
  ## License
34
64
 
35
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
65
+ This gem is available as open source under the [MIT License](https://opensource.org/licenses/MIT).
66
+
67
+ ## Thanks
68
+
69
+ - [Rails](https://github.com/rails/rails) - The web framework that inspired this gem
70
+ - [Thor](https://github.com/rails/thor) - The toolkit for building powerful command-line interfaces
71
+ - [@piotrmurach](https://github.com/piotrmurach) for [tty-prompt](https://github.com/piotrmurach/tty-prompt)
72
+ - [@excid3](https://github.com/excid3) for inspiration and guidance
73
+ - The entire Rails community workers for their continuous contributions and support
74
+
75
+ ---
76
+
77
+ This is my first gem as a Ruby/Rails developer. Sorry for very possible bugs.
78
+ Feedback and contributions are appreciated!
@@ -4,6 +4,35 @@ require "tty-prompt"
4
4
  # TODO: add a way to select rails version
5
5
  module LazyRails
6
6
  class CLI < Thor
7
+ RAILS_NEW_COMMAND = ["rails new"]
8
+ APP_TYPES = {
9
+ "api" => "--api"
10
+ }
11
+ DB_OPTIONS = {
12
+ "mysql" => "--database=mysql",
13
+ "postgresql" => "--database=postgresql",
14
+ "trilogy" => "--database=trilogy"
15
+ }
16
+ JS_OPTIONS = {
17
+ "esbuild" => "--javascript=esbuild",
18
+ "bun" => "--javascript=bun",
19
+ "rollup" => "--javascript=rollup",
20
+ "webpack" => "--javascript=webpack"
21
+ }
22
+ CSS_OPTIONS = {
23
+ "tailwind" => "--css=tailwind",
24
+ "bootstrap" => "--css=bootstrap",
25
+ "bulma" => "--css=bulma",
26
+ "postcss" => "--css=postcss",
27
+ "sass" => "--css=sass"
28
+ }
29
+ SKIP_OPTIONS = {
30
+ "jbuilder" => "--skip-jbuilder",
31
+ "minitest" => "--skip-test",
32
+ "rubocop" => "--skip-rubocop",
33
+ "brakeman" => "--skip-brakeman"
34
+ }
35
+
7
36
  desc "new", "Start new rails project"
8
37
  def new
9
38
  prompt = TTY::Prompt.new
@@ -12,42 +41,57 @@ module LazyRails
12
41
 
13
42
  # Project name
14
43
  project_name = prompt.ask("What is the name of your project?") do |q|
44
+ q.default "rails-app-#{Time.now.strftime("%Y%m%d%H%M%S")}"
15
45
  q.required true
16
46
  q.validate(/\A[\w-]+\z/)
17
47
  q.messages[:valid?] = "Project name can only contain letters, numbers, underscores, and dashes"
18
48
  end
19
49
 
20
50
  # Database selection
21
- database = prompt.select("Choose your database:", %w[sqlite3 mysql postgresql])
51
+ db_option = prompt.select("Choose your database:", show_help: :always) do |menu|
52
+ menu.choice "SQLite(default)", "sqlite3"
53
+ menu.choice "MySQL", "mysql"
54
+ menu.choice "Trilogy", "trilogy"
55
+ menu.choice "PostgreSQL", "postgresql"
56
+ end
22
57
 
23
- # JavaScript approach
24
- js_approach = prompt.select("Choose your JavaScript approach:", %w[importmap bun webpack esbuild rollup])
58
+ # Project type
59
+ project_type = prompt.select("Choose your project type:", %w[web api], show_help: :always)
25
60
 
26
- # CSS processor
27
- css_processor = prompt.select("Choose your CSS processor:", %w[tailwind bootstrap bulma postcss sass])
61
+ unless project_type == "api"
62
+ # JavaScript approach
63
+ js_option = prompt.select("Choose your JavaScript approach:", %w[importmap esbuild bun rollup webpack], show_help: :always)
28
64
 
29
- # Additional options
30
- skip_test = prompt.yes?("Skip test files?")
31
- skip_system_test = prompt.yes?("Skip system test files?")
32
- api_mode = prompt.yes?("Set up as API-only application?")
65
+ # CSS processor
66
+ css_option = prompt.select("Choose your CSS processor:", %w[none tailwind bootstrap bulma postcss sass], show_help: :always)
67
+ end
33
68
 
34
- # Build the command
35
- command = "rails new #{project_name} "
36
- command += "--database=#{database} "
37
- command += "--javascript=#{js_approach} "
38
- command += "--css=#{css_processor} "
39
- command += "--skip-test " if skip_test
40
- command += "--skip-system-test " if skip_system_test
41
- command += "--api " if api_mode
42
- command += "--minimal"
69
+ # Skip rails setup defaults
70
+ rails_setup_defaults = prompt.multi_select("SKIP RAILS DEFAULTS:", show_help: :always) do |menu|
71
+ menu.choice "jbuilder"
72
+ menu.choice "minitest"
73
+ menu.choice "rubocop"
74
+ menu.choice "brakeman"
75
+ end
76
+
77
+ RAILS_NEW_COMMAND << project_name
78
+ RAILS_NEW_COMMAND << DB_OPTIONS[db_option] if db_option
79
+ RAILS_NEW_COMMAND << APP_TYPES[project_type] if project_type
80
+ RAILS_NEW_COMMAND << JS_OPTIONS[js_option] if js_option
81
+ RAILS_NEW_COMMAND << CSS_OPTIONS[css_option] if css_option
82
+
83
+ rails_setup_defaults.each do |tool|
84
+ RAILS_NEW_COMMAND << SKIP_OPTIONS[tool]
85
+ end
43
86
 
87
+ rails_new_command = RAILS_NEW_COMMAND.compact.join(" ")
44
88
  # Display the final command
45
89
  puts "\nYour Rails project will be created with the following command:"
46
- puts command
90
+ puts rails_new_command
47
91
 
48
92
  # Ask for confirmation
49
93
  if prompt.yes?("Do you want to run this command now?")
50
- system(command)
94
+ system(rails_new_command)
51
95
  puts "Rails project '#{project_name}' has been created!"
52
96
  else
53
97
  puts "Command not executed. You can run it manually when you're ready."
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LazyRails
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazy_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fagner Pereira Rosa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-14 00:00:00.000000000 Z
11
+ date: 2024-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rails
42
+ name: railties
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="