rails_cli 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c678f219df37199691b87a458b8e9d432bd0a705ac08c979e60c578f815e365c
4
+ data.tar.gz: 4644d00eaf0acdcd03df2f95caf39d6f59d67d1d27d9d3dca179a01135353f67
5
+ SHA512:
6
+ metadata.gz: c8af0871709ad352ad166502521f42dc3877de671350b9d74fa44d18832a13f6d7e1deb519a87840413e46b955894ca460c694d972195c3175235776791dfbbf
7
+ data.tar.gz: 12c4bbfe7915917dc1e6fb25fb8c70c595d317b4312b17b894003f61cc7d53934d8d4057b1d7bcb0568e60538ba93f33a63cab11d565cdf305195c48b3b944b7
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Alex Merkulov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Dd::Cli
2
+
3
+ TODO: Delete this and the text below, and describe your gem
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/dd/cli`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_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.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
14
+
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Development
24
+
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.
26
+
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).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/dd-cli.
32
+
33
+ ## License
34
+
35
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/exe/rails-cli ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'rails_cli'
5
+
6
+ RailsCLI.start
data/exe/rails_cli ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'rails_cli'
5
+
6
+ RailsCLI.start
@@ -0,0 +1,96 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsCLI
4
+ # CLI class
5
+ class CLI
6
+ DATABASES = %w[
7
+ postgresql
8
+ mysql
9
+ sqlite3
10
+ trilogy
11
+ oracle
12
+ sqlserver
13
+ jdbcmysql
14
+ jdbcsqlite3
15
+ jdbcpostgresql
16
+ jdbc
17
+ ].freeze
18
+
19
+ JS = %w[
20
+ importmap
21
+ bun
22
+ webpack
23
+ esbuild
24
+ rollup
25
+ ].freeze
26
+
27
+ CSS = %w[
28
+ tailwind
29
+ bootstrap
30
+ bulma
31
+ postcss
32
+ sass
33
+ ].freeze
34
+
35
+ SKIP_ACTIONS = {
36
+ 'action-mailer': 'Skip Action Mailer files',
37
+ 'action-mailbox': 'Skip Action Mailbox gem',
38
+ 'action-text': 'Skip Action Text gem',
39
+ 'active-record': 'Skip Active Record files',
40
+ 'active-job': 'Skip Active Job',
41
+ 'active-storage': 'Skip Active Storage files',
42
+ 'action-cable': 'Skip Action Cable files'
43
+ }.freeze
44
+
45
+ def self.start
46
+ new.start
47
+ end
48
+
49
+ def start
50
+ ::CLI::UI::Prompt.instructions_color = ::CLI::UI::Color::BLUE
51
+ @app_name = ::CLI::UI.ask('Rails app name:', default: 'my_app')
52
+ @database = select_database
53
+ @js = select_js
54
+ @css = select_css
55
+ @skip_actions = select_skip_actions
56
+
57
+ exec(command)
58
+ end
59
+
60
+ private
61
+
62
+ # @return [String]
63
+ def select_database
64
+ ::CLI::UI::Prompt.ask('Preconfigure for selected database:', options: DATABASES)
65
+ end
66
+
67
+ # @return [String]
68
+ def select_js
69
+ ::CLI::UI::Prompt.ask('Choose JavaScript approach:', options: JS)
70
+ end
71
+
72
+ # @return [String]
73
+ def select_css
74
+ ::CLI::UI::Prompt.ask('Choose CSS processor:', options: CSS)
75
+ end
76
+
77
+ # @return [Array<String>]
78
+ def select_skip_actions
79
+ ::CLI::UI::Prompt.ask('Skip selected', multiple: true) do |handler|
80
+ SKIP_ACTIONS.each do |key, value|
81
+ handler.option(value) { key }
82
+ end
83
+ end
84
+ end
85
+
86
+ # @return [String]
87
+ def command
88
+ "bundle exec rails new #{@app_name} --database=#{@database} --javascript=#{@js} #{skiped_actions} --skip-bundle"
89
+ end
90
+
91
+ # @return [String]
92
+ def skiped_actions
93
+ @skip_actions.map { |key| "--skip-#{key}" }.join(' ')
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsCLI
4
+ VERSION = '0.0.1'
5
+ end
data/lib/rails_cli.rb ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cli/ui'
4
+
5
+ # Base module for the Rails CLI gem
6
+ module RailsCLI
7
+ autoload :CLI, 'rails_cli/cli'
8
+
9
+ def self.start
10
+ CLI.start
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alex Merkulov
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-03-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cli-ui
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.2.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.2.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '7.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '7.0'
41
+ description: |-
42
+ Rails CLI gem simplifies the initiation of Rails projects by offering a guided interface for
43
+ selecting configurations, making it a must-have tool for junior developers and rapid project prototyping.
44
+ email:
45
+ - rormercury@gmail.com
46
+ executables:
47
+ - rails_cli
48
+ - rails-cli
49
+ extensions: []
50
+ extra_rdoc_files: []
51
+ files:
52
+ - LICENSE.txt
53
+ - README.md
54
+ - exe/rails-cli
55
+ - exe/rails_cli
56
+ - lib/rails_cli.rb
57
+ - lib/rails_cli/cli.rb
58
+ - lib/rails_cli/version.rb
59
+ homepage: https://github.com/bf-rb/rails_cli
60
+ licenses:
61
+ - MIT
62
+ metadata:
63
+ homepage_uri: https://github.com/bf-rb/rails_cli
64
+ changelog_uri: https://github.com/bf-rb/rails_cli/blob/main/CHANGELOG.md
65
+ source_code_uri: https://github.com/bf-rb/rails_cli
66
+ bug_tracker_uri: https://github.com/bf-rb/rails_cli/issues
67
+ rubygems_mfa_required: 'true'
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 3.2.0
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubygems_version: 3.5.6
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Rails CLI gem simplifies the initiation of Rails projects.
87
+ test_files: []