lazy_rails 0.1.2 → 0.1.3
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 +4 -4
- data/README.md +6 -5
- data/lib/lazy_rails/cli.rb +23 -80
- data/lib/lazy_rails/commands/new.rb +48 -0
- data/lib/lazy_rails/commands/new_command/generator.rb +8 -0
- data/lib/lazy_rails/commands/new_command/options.rb +21 -0
- data/lib/lazy_rails/new_command/generator.rb +8 -0
- data/lib/lazy_rails/new_command/options.rb +23 -0
- data/lib/lazy_rails/prompt_generators.rb +74 -0
- data/lib/lazy_rails/version.rb +1 -1
- data/lib/lazy_rails.rb +52 -1
- metadata +8 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 796e281f26e8854d6b40a9dd57d91df307042b59bee30b18fe1e9582b701726e
|
4
|
+
data.tar.gz: db561c103f7a9068c15dfed934afa1abc8da970cff1005c6c972912d5129db58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b19a0ee24ed361427461a18c49b97c4bbd00ca6376bfb29facd8eaae8d59e39dbe05bf3e519ff8fe27afc2e512cd470c165f28cffedc75377944a92bfb40594d
|
7
|
+
data.tar.gz: d27caa2e47b0ea57f3475815677a1998884420e340e49a5cb0482d2c39fcbaa64f01a60b360222046ce9a552e9f122d10152029d6ace5a0cf390d4ea55741f91
|
data/README.md
CHANGED
@@ -38,23 +38,24 @@ Local installation: `bundle exec rake install`
|
|
38
38
|
|
39
39
|
## Roadmap
|
40
40
|
|
41
|
+
- [ ] test compatibility with other ruby/rails versions
|
41
42
|
- [ ] Selection of Rails version (at least last 3)
|
42
43
|
- [ ] View template selection (ERB, Haml, Slim)
|
43
44
|
- [ ] Test tool selection (RSpec, Minitest, Test::Unit)
|
44
45
|
- [ ] 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
46
|
- [ ] Basic setup customization (Action Cable, Active Job, Action Mailer, Action Mailbox)
|
50
47
|
- [ ] On-the-fly popular gem installation (Devise, Sidekiq, Solid Queue)
|
51
48
|
- [ ] Improve documentation
|
52
|
-
- [ ] Increase test coverage
|
53
49
|
- [ ] Enhance error handling and user feedback
|
54
50
|
|
55
51
|
✅ Completed:
|
56
52
|
- [x] Basic CLI structure
|
57
53
|
- [x] 'new' command for project generation
|
54
|
+
- [x] CSS processor selection (Tailwind, Bootstrap, Bulma, PostCSS, Sass)
|
55
|
+
- [x] JavaScript processor selection (Importmap, Bun, Webpack, esbuild, Rollup)
|
56
|
+
- [x] Database selection (SQLite3, MySQL, PostgreSQL)
|
57
|
+
- [x] Increase test coverage
|
58
|
+
- [x] App type selection (API, Web)
|
58
59
|
|
59
60
|
## Contributing
|
60
61
|
|
data/lib/lazy_rails/cli.rb
CHANGED
@@ -1,98 +1,35 @@
|
|
1
|
+
require "pry"
|
1
2
|
require "thor"
|
2
3
|
require "tty-prompt"
|
3
4
|
|
4
|
-
|
5
|
+
module CommandGenerators
|
6
|
+
autoload :Options, "lazy_rails/command_generators/options"
|
7
|
+
end
|
8
|
+
|
5
9
|
module LazyRails
|
6
10
|
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
|
-
|
36
11
|
desc "new", "Start new rails project"
|
37
12
|
def new
|
38
|
-
prompt = TTY::Prompt.new
|
39
|
-
|
40
13
|
puts "Welcome to the Rails Project Setup Wizard!"
|
41
14
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
q.messages[:valid?] = "Project name can only contain letters, numbers, underscores, and dashes"
|
48
|
-
end
|
49
|
-
|
50
|
-
# Database selection
|
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
|
57
|
-
|
58
|
-
# Project type
|
59
|
-
project_type = prompt.select("Choose your project type:", %w[web api], show_help: :always)
|
60
|
-
|
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)
|
15
|
+
command = CommandBuilder.new(
|
16
|
+
PromptGenerators::AskAppName.new(prompt).call
|
17
|
+
)
|
18
|
+
command.options << PromptGenerators::SelectDb.new(prompt).call
|
19
|
+
command.options << app_type = PromptGenerators::SelectAppType.new(prompt).call
|
64
20
|
|
65
|
-
|
66
|
-
|
21
|
+
if app_type == "web"
|
22
|
+
command.options << PromptGenerators::SelectJs.new(prompt).call
|
23
|
+
command.options << PromptGenerators::SelectCss.new(prompt).call
|
67
24
|
end
|
68
25
|
|
69
|
-
|
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
|
86
|
-
|
87
|
-
rails_new_command = RAILS_NEW_COMMAND.compact.join(" ")
|
88
|
-
# Display the final command
|
26
|
+
command.options << PromptGenerators::SelectTools.new(prompt).call
|
89
27
|
puts "\nYour Rails project will be created with the following command:"
|
90
|
-
puts
|
28
|
+
puts command.build
|
91
29
|
|
92
|
-
# Ask for confirmation
|
93
30
|
if prompt.yes?("Do you want to run this command now?")
|
94
|
-
system(
|
95
|
-
puts "Rails project '#{
|
31
|
+
system(command.build)
|
32
|
+
puts "Rails project '#{command.app_name}' has been created!"
|
96
33
|
else
|
97
34
|
puts "Command not executed. You can run it manually when you're ready."
|
98
35
|
end
|
@@ -102,5 +39,11 @@ module LazyRails
|
|
102
39
|
def version
|
103
40
|
puts "LazyRails version #{LazyRails::VERSION}"
|
104
41
|
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def prompt
|
46
|
+
@_prompt ||= TTY::Prompt.new
|
47
|
+
end
|
105
48
|
end
|
106
49
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "thor"
|
2
|
+
require "tty-prompt"
|
3
|
+
|
4
|
+
module LazyRails
|
5
|
+
module Commands
|
6
|
+
class New < Thor
|
7
|
+
include NewCommand::Options
|
8
|
+
|
9
|
+
RAILS_NEW_COMMAND = ["rails new"]
|
10
|
+
|
11
|
+
desc "new", "Start new rails project"
|
12
|
+
def new
|
13
|
+
puts "Welcome to the Rails Project Setup Wizard!"
|
14
|
+
|
15
|
+
app_name = PromptGenerators::AppName.new(prompt).call
|
16
|
+
selected_db = PromptGenerators.new(prompt).call
|
17
|
+
selected_app_type = PromptGenerators::SelectAppType.new(prompt).call
|
18
|
+
|
19
|
+
if selected_app_type == "web"
|
20
|
+
selected_js = PromptGenerators::SelectJs.new(prompt).call
|
21
|
+
selected_css = PromptGenerators::SelectCss.new(prompt).call
|
22
|
+
end
|
23
|
+
|
24
|
+
selected_tools = PromptGenerators::SelectTools.new(prompt).call
|
25
|
+
|
26
|
+
rails_new_command = RAILS_NEW_COMMAND.compact.join(" ")
|
27
|
+
|
28
|
+
# Display the final command
|
29
|
+
puts "\nYour Rails project will be created with the following command:"
|
30
|
+
puts rails_new_command
|
31
|
+
|
32
|
+
# Ask for confirmation
|
33
|
+
if prompt.yes?("Do you want to run this command now?")
|
34
|
+
system(rails_new_command)
|
35
|
+
puts "Rails project '#{project_name}' has been created!"
|
36
|
+
else
|
37
|
+
puts "Command not executed. You can run it manually when you're ready."
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def prompt
|
44
|
+
@_prompt ||= TTY::Prompt.new
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module NewCommand
|
2
|
+
OPTIONS = {
|
3
|
+
"api" => "--api",
|
4
|
+
"mysql" => "--database=mysql",
|
5
|
+
"postgresql" => "--database=postgresql",
|
6
|
+
"trilogy" => "--database=trilogy",
|
7
|
+
"esbuild" => "--javascript=esbuild",
|
8
|
+
"bun" => "--javascript=bun",
|
9
|
+
"rollup" => "--javascript=rollup",
|
10
|
+
"webpack" => "--javascript=webpack",
|
11
|
+
"tailwind" => "--css=tailwind",
|
12
|
+
"bootstrap" => "--css=bootstrap",
|
13
|
+
"bulma" => "--css=bulma",
|
14
|
+
"postcss" => "--css=postcss",
|
15
|
+
"sass" => "--css=sass",
|
16
|
+
"jbuilder" => "--skip-jbuilder",
|
17
|
+
"minitest" => "--skip-test",
|
18
|
+
"rubocop" => "--skip-rubocop",
|
19
|
+
"brakeman" => "--skip-brakeman"
|
20
|
+
}
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module LazyRails
|
2
|
+
module NewCommand
|
3
|
+
OPTIONS = {
|
4
|
+
"api" => "--api",
|
5
|
+
"mysql" => "--database=mysql",
|
6
|
+
"postgresql" => "--database=postgresql",
|
7
|
+
"trilogy" => "--database=trilogy",
|
8
|
+
"esbuild" => "--javascript=esbuild",
|
9
|
+
"bun" => "--javascript=bun",
|
10
|
+
"rollup" => "--javascript=rollup",
|
11
|
+
"webpack" => "--javascript=webpack",
|
12
|
+
"tailwind" => "--css=tailwind",
|
13
|
+
"bootstrap" => "--css=bootstrap",
|
14
|
+
"bulma" => "--css=bulma",
|
15
|
+
"postcss" => "--css=postcss",
|
16
|
+
"sass" => "--css=sass",
|
17
|
+
"jbuilder" => "--skip-jbuilder",
|
18
|
+
"minitest" => "--skip-test",
|
19
|
+
"rubocop" => "--skip-rubocop",
|
20
|
+
"brakeman" => "--skip-brakeman"
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module LazyRails
|
2
|
+
module PromptGenerators
|
3
|
+
class Base
|
4
|
+
attr_reader :prompt
|
5
|
+
|
6
|
+
def initialize(prompt)
|
7
|
+
@prompt = prompt
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class SelectAppType < Base
|
12
|
+
def call
|
13
|
+
prompt.select(
|
14
|
+
"Choose your project type:",
|
15
|
+
%w[web api],
|
16
|
+
show_help: :always
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class SelectDb < Base
|
22
|
+
def call
|
23
|
+
prompt.select("Choose your database:", show_help: :always) do |menu|
|
24
|
+
menu.choice "SQLite(default)", "sqlite3"
|
25
|
+
menu.choice "MySQL", "mysql"
|
26
|
+
menu.choice "Trilogy", "trilogy"
|
27
|
+
menu.choice "PostgreSQL", "postgresql"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class SelectJs < Base
|
33
|
+
def call
|
34
|
+
prompt.select(
|
35
|
+
"Choose your JavaScript approach:",
|
36
|
+
%w[importmap esbuild bun rollup webpack],
|
37
|
+
show_help: :always
|
38
|
+
)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class SelectCss < Base
|
43
|
+
def call
|
44
|
+
prompt.select(
|
45
|
+
"Choose your CSS processor:",
|
46
|
+
%w[none tailwind bootstrap bulma postcss sass],
|
47
|
+
show_help: :always
|
48
|
+
)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class AskAppName < Base
|
53
|
+
def call
|
54
|
+
prompt.ask("What is the name of your project?") do |q|
|
55
|
+
q.default "rails-app-#{Time.now.to_i}"
|
56
|
+
q.required true
|
57
|
+
q.validate(/\A[\w-]+\z/)
|
58
|
+
q.messages[:valid?] = "Project name can only contain letters, numbers, underscores, and dashes"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
class SelectTools < Base
|
64
|
+
def call
|
65
|
+
prompt.multi_select("SKIP RAILS DEFAULTS:", show_help: :always) do |menu|
|
66
|
+
menu.choice "jbuilder"
|
67
|
+
menu.choice "minitest"
|
68
|
+
menu.choice "rubocop"
|
69
|
+
menu.choice "brakeman"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/lib/lazy_rails/version.rb
CHANGED
data/lib/lazy_rails.rb
CHANGED
@@ -1,9 +1,60 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "lazy_rails/version"
|
4
|
+
require_relative "lazy_rails/prompt_generators"
|
4
5
|
require_relative "lazy_rails/cli"
|
6
|
+
# require_relative "lazy_rails/commands/new"
|
7
|
+
# require_relative "lazy_rails/commands/new_command/generator"
|
5
8
|
|
6
9
|
module LazyRails
|
10
|
+
module NewCommand
|
11
|
+
OPTIONS = {
|
12
|
+
"api" => "--api",
|
13
|
+
"mysql" => "--database=mysql",
|
14
|
+
"postgresql" => "--database=postgresql",
|
15
|
+
"trilogy" => "--database=trilogy",
|
16
|
+
"esbuild" => "--javascript=esbuild",
|
17
|
+
"bun" => "--javascript=bun",
|
18
|
+
"rollup" => "--javascript=rollup",
|
19
|
+
"webpack" => "--javascript=webpack",
|
20
|
+
"tailwind" => "--css=tailwind",
|
21
|
+
"bootstrap" => "--css=bootstrap",
|
22
|
+
"bulma" => "--css=bulma",
|
23
|
+
"postcss" => "--css=postcss",
|
24
|
+
"sass" => "--css=sass",
|
25
|
+
"jbuilder" => "--skip-jbuilder",
|
26
|
+
"minitest" => "--skip-test",
|
27
|
+
"rubocop" => "--skip-rubocop",
|
28
|
+
"brakeman" => "--skip-brakeman"
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
7
32
|
class Error < StandardError; end
|
8
|
-
|
33
|
+
|
34
|
+
class CommandBuilder
|
35
|
+
attr_accessor :app_name, :options
|
36
|
+
|
37
|
+
def initialize(app_name)
|
38
|
+
@app_name = app_name
|
39
|
+
@options = []
|
40
|
+
end
|
41
|
+
|
42
|
+
def build
|
43
|
+
if block_given?
|
44
|
+
yield self
|
45
|
+
end
|
46
|
+
command = base_command + build_options
|
47
|
+
command.compact.join(" ").strip
|
48
|
+
end
|
49
|
+
|
50
|
+
def build_options
|
51
|
+
options.flatten.map do |option|
|
52
|
+
NewCommand::OPTIONS[option]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def base_command
|
57
|
+
["rails new #{app_name}"]
|
58
|
+
end
|
59
|
+
end
|
9
60
|
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
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.3
|
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-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: thor
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: tty-prompt
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -65,6 +51,12 @@ files:
|
|
65
51
|
- bin/lazy_rails
|
66
52
|
- lib/lazy_rails.rb
|
67
53
|
- lib/lazy_rails/cli.rb
|
54
|
+
- lib/lazy_rails/commands/new.rb
|
55
|
+
- lib/lazy_rails/commands/new_command/generator.rb
|
56
|
+
- lib/lazy_rails/commands/new_command/options.rb
|
57
|
+
- lib/lazy_rails/new_command/generator.rb
|
58
|
+
- lib/lazy_rails/new_command/options.rb
|
59
|
+
- lib/lazy_rails/prompt_generators.rb
|
68
60
|
- lib/lazy_rails/version.rb
|
69
61
|
homepage: https://github.com/fagnerpereira/lazy_rails
|
70
62
|
licenses:
|