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 +4 -4
- data/README.md +58 -15
- data/lib/lazy_rails/cli.rb +64 -20
- data/lib/lazy_rails/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f21a8760eee41e80888c8c6ecd3a89d66498d7808f39808f68a1286e54cdcaea
|
4
|
+
data.tar.gz: d04a62658292e5ff484450de7449b134c6535ba0233d0719fa2d5918e1237d1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d97f95a95b4beae9aab0a2583be1180c93485ccdab927d2d2494dfe2b124a325452fa93af7978b37d0dac8dc7d71731305a24a0da82f17788be9fe5ad2414dc2
|
7
|
+
data.tar.gz: 394fa356d1f960c3a7c488897405cd4dd55712d019f49ff67b78218b3aa92f1dc43434df5c0a52901df95b9abdc2db68e02e02dbb17a793adae496707329ef09
|
data/README.md
CHANGED
@@ -1,35 +1,78 @@
|
|
1
1
|
# LazyRails
|
2
2
|
|
3
|
-
|
3
|
+
LazyRails simplifies Rails project creation and tool installation, addressing two common pain points:
|
4
4
|
|
5
|
-
|
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
|
-
##
|
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
|
-
|
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
|
-
|
13
|
+
## Installation
|
14
14
|
|
15
|
-
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
15
|
|
17
|
-
|
16
|
+
Install globally:
|
17
|
+
```bash
|
18
|
+
gem install lazy_rails
|
19
|
+
```
|
18
20
|
|
19
21
|
## Usage
|
20
22
|
|
21
|
-
|
23
|
+
Create a new Rails project:
|
24
|
+
```bash
|
25
|
+
lazy_rails new
|
26
|
+
```
|
22
27
|
|
23
|
-
|
28
|
+
![LazyRails Demo](lazy_rails_new_example2.gif)
|
24
29
|
|
25
|
-
|
30
|
+
## Development
|
26
31
|
|
27
|
-
|
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
|
-
|
61
|
+
Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
|
32
62
|
|
33
63
|
## License
|
34
64
|
|
35
|
-
|
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!
|
data/lib/lazy_rails/cli.rb
CHANGED
@@ -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
|
-
|
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
|
-
#
|
24
|
-
|
58
|
+
# Project type
|
59
|
+
project_type = prompt.select("Choose your project type:", %w[web api], show_help: :always)
|
25
60
|
|
26
|
-
|
27
|
-
|
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
|
-
|
30
|
-
|
31
|
-
|
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
|
-
#
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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
|
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(
|
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."
|
data/lib/lazy_rails/version.rb
CHANGED
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.
|
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-
|
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:
|
42
|
+
name: railties
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|