rails_steroids 0.2.0 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20eed22d7344f5356bef72c4d6e534fd8e4fcf2251592be8a0f5192f7039e4a1
4
- data.tar.gz: c7c65d09a396d27c747fb41f3a243a624e03e56df0aab8bfe741ef523cacf468
3
+ metadata.gz: 6ce6fbe0a8cf0bdac91965f3a73e05a01b415a68358d81899ed9745bc1777115
4
+ data.tar.gz: 9eefd09397f43fa4d36a6cb50989afdeb1b1902638f097765c8e9d9cb0fa7892
5
5
  SHA512:
6
- metadata.gz: f6dce3f695c637de507c9234d1823342c53a76e2ce90c565f2e92e95ba03f46903d96938e0656f20925375826941abca8976ce2b14bf2749972d48de593ce85a
7
- data.tar.gz: 17081a16d54b6a377f0eff92f59d70c76eed563690f023a03ae14cad4eab8f316c7234d585f6e02cfc259208dc84c298719861a110c14bb41e592962be2a887b
6
+ metadata.gz: 624785f5c35d1b51368c5629c94b16ab96b62528f4e003c26ca9f0707a1d9b3ac5c1f540ed4e1995eca01c8782b25653298b24fb459517e7254c164935356572
7
+ data.tar.gz: 186c3eac0b2e7368ae0b6da42cb67618ead70105f72db44ab0a16adc2c3813277d4a6c08e8cab44310617468b1349b20cf110141c3e1b981eda9b45245d5b815
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.1] - 2024-02-06
4
+
5
+ - Improvement in steroid recipe new_project : Code improvement (variable name for boolean_choices)
6
+ - Improvement in steroid generator : Add `require 'tty/prompt'` by default
7
+
8
+ ## [0.3.0] - 2024-02-05
9
+
10
+ - Improvement in steroid recipe new_project : Use of TTY-prompt for better interaction
11
+
3
12
  ## [0.2.0] - 2024-02-04
4
13
 
5
14
  - New steroid recipe: new_project (create new Rails project interactively)
data/Gemfile.lock CHANGED
@@ -3,8 +3,7 @@ PATH
3
3
  specs:
4
4
  rails_steroids (0.2.0)
5
5
  rails
6
- railties
7
- thor
6
+ tty-prompt
8
7
 
9
8
  GEM
10
9
  remote: https://rubygems.org/
@@ -135,6 +134,8 @@ GEM
135
134
  parser (3.3.0.5)
136
135
  ast (~> 2.4.1)
137
136
  racc
137
+ pastel (0.8.0)
138
+ tty-color (~> 0.5)
138
139
  psych (5.1.2)
139
140
  stringio
140
141
  racc (1.7.3)
@@ -214,6 +215,16 @@ GEM
214
215
  stringio (3.1.0)
215
216
  thor (1.3.0)
216
217
  timeout (0.4.1)
218
+ tty-color (0.6.0)
219
+ tty-cursor (0.7.1)
220
+ tty-prompt (0.23.1)
221
+ pastel (~> 0.8)
222
+ tty-reader (~> 0.8)
223
+ tty-reader (0.9.0)
224
+ tty-cursor (~> 0.7)
225
+ tty-screen (~> 0.8)
226
+ wisper (~> 2.0)
227
+ tty-screen (0.8.2)
217
228
  tzinfo (2.0.6)
218
229
  concurrent-ruby (~> 1.0)
219
230
  unicode-display_width (2.5.0)
@@ -221,6 +232,7 @@ GEM
221
232
  websocket-driver (0.7.6)
222
233
  websocket-extensions (>= 0.1.0)
223
234
  websocket-extensions (0.1.5)
235
+ wisper (2.0.1)
224
236
  zeitwerk (2.6.12)
225
237
 
226
238
  PLATFORMS
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'tty/prompt'
4
+
3
5
  module Steroid
4
6
  class NewProjectGenerator < Rails::Generators::Base
5
7
  desc "Adds New Project to the application"
@@ -7,43 +9,52 @@ module Steroid
7
9
 
8
10
  def add_new_project
9
11
  say "Injecting steroid: New Project"
10
- project_name = ask("What is the great name of your Rails project?")
11
- project_name_underscored = project_name.underscore
12
- empty_directory project_name_underscored
13
- ruby_version = ask("Which Ruby version would you like to use?").strip
14
- create_file "#{project_name_underscored}/.ruby_version" do
12
+ prompt = TTY::Prompt.new
13
+ project_name = prompt.ask("What is the great name of your Rails project?") do |q|
14
+ q.required true
15
+ q.modify :remove
16
+ end
17
+ empty_directory project_name
18
+
19
+ ruby_version = prompt.ask("Which Ruby version would you like to use?") do |q|
20
+ q.required true
21
+ q.modify :remove
22
+ end
23
+ create_file "#{project_name}/.ruby-version" do
15
24
  ruby_version
16
25
  end
17
- run "cd #{project_name_underscored}"
26
+
18
27
  cmd = ["rails"]
19
- current_rails_version = `rails --version`.gsub('Rails ', '')
20
- rails_version = ask("Which Rails version would you like to use? You can find Rails version from https://rubygems.org/gems/rails/versions. Current default version is #{current_rails_version}")
21
- rails_version = rails_version.present? ? rails_version : current_rails_version
28
+ current_rails_version = `rails --version`.gsub('Rails ', '').strip
29
+ rails_version = prompt.ask("Which Rails version would you like to use? You can find Rails version from https://rubygems.org/gems/rails/versions.", default: current_rails_version)
22
30
  cmd << "_#{rails_version}_"
23
31
  cmd << "new"
24
32
  cmd << project_name
25
33
 
26
- database_name = ask("Choose your database (options: mysql, trilogy, postgresql, sqlite3, oracle, sqlserver, jdbcmysql, jdbcsqlite3, jdbcpostgresql, jdbc)")
34
+ database_options = %w(mysql trilogy postgresql sqlite3 oracle sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc)
35
+ database_name = prompt.select("Choose your database:", database_options)
27
36
  cmd << "--database #{database_name}"
28
37
 
29
- asset_pipeline = ask("Choose your asset pipeline (options: sprockets, propshaft)")
38
+ asset_pipeline = prompt.select("Choose your asset pipeline:", %w(sprockets propshaft))
30
39
  cmd << "--asset-pipeline #{asset_pipeline}"
31
40
 
32
- css = ask("Choose CSS processor (options: tailwind, bootstrap, bulma, postcss, sass)")
41
+ css = prompt.select("Choose CSS processor:", %w(tailwind bootstrap bulma postcss sass))
33
42
  cmd << "--css #{css}"
34
43
 
35
- js = ask("Choose JavaScript approach (options: importmap, bun, webpack, esbuild, rollup)")
44
+ js = prompt.select("Choose JavaScript approach:", %w(importmap bun webpack esbuild rollup))
36
45
  cmd << "--javascript #{js}"
37
46
 
38
- cmd << "--api" if yes?("API only application? (yes/no)")
39
- cmd << "--skip-jbuilder" if yes?("Skip jbuilder? (yes/no)")
40
- cmd << "--skip-git" if yes?("Skip git init, .gitignore and .gitattributes? (yes/no)")
41
- cmd << "--skip-docker" if yes?("Skip Dockerfile, .dockerignore and bin/docker-entrypoint? (yes/no)")
42
- cmd << "--skip-action-cable" if yes?("Skip Action Cable files? (yes/no)")
43
- cmd << "--skip-hotwire" if yes?("Skip Hotwire integration? (yes/no)")
44
- cmd << "--skip-test" if yes?("Skip test files? (yes/no)")
45
- cmd << "--skip-system-test" if yes?("Skip system test files? (yes/no)")
46
- cmd << "--no-rc"
47
+ boolean_choices = [{name: "yes", value: true}, {name: "no", value: false}]
48
+ cmd << "--api" if prompt.select("API only application?", boolean_choices)
49
+ cmd << "--skip-jbuilder" if prompt.select("Skip jbuilder?", boolean_choices)
50
+ cmd << "--skip-git" if prompt.select("Skip git init, .gitignore and .gitattributes?", boolean_choices)
51
+ cmd << "--skip-docker" if prompt.select("Skip Dockerfile, .dockerignore and bin/docker-entrypoint?", boolean_choices)
52
+ cmd << "--skip-action-cable" if prompt.select("Skip Action Cable files?", boolean_choices)
53
+ cmd << "--skip-hotwire" if prompt.select("Skip Hotwire integration?", boolean_choices)
54
+ cmd << "--skip-test" if prompt.select("Skip test files?", boolean_choices)
55
+ cmd << "--skip-system-test" if prompt.select("Skip system test files?", boolean_choices)
56
+ cmd << "--no-rc" # To skip configurations from .railsrc
57
+ cmd << "--skip" # To skip overriding existing files
47
58
  run cmd.join(" ")
48
59
  end
49
60
  end
@@ -5,6 +5,8 @@ class SteroidGenerator < Rails::Generators::NamedBase
5
5
  create_file "lib/generators/steroid/#{name}/#{name}_generator.rb", <<~RUBY
6
6
  # frozen_string_literal: true
7
7
 
8
+ require 'tty/prompt'
9
+
8
10
  module Steroid
9
11
  class #{name.camelize}Generator < Rails::Generators::Base
10
12
  desc "Adds #{name.titlecase} to the application"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsSteroids
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.1"
5
5
  end
metadata CHANGED
@@ -1,31 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_steroids
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anand Bait
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-04 00:00:00.000000000 Z
11
+ date: 2024-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: railties
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
- - !ruby/object:Gem::Dependency
28
- name: thor
14
+ name: rails
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - ">="
@@ -39,7 +25,7 @@ dependencies:
39
25
  - !ruby/object:Gem::Version
40
26
  version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
- name: rails
28
+ name: tty-prompt
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - ">="