rails_steroids 0.7.0 → 0.7.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/bin/rails_steroids +5 -4
- data/lib/generators/steroid/controller/controller_generator.rb +6 -6
- data/lib/generators/steroid/migration/migration_generator.rb +15 -17
- data/lib/generators/steroid/model/model_generator.rb +6 -6
- data/lib/generators/steroid/new_project/new_project_generator.rb +16 -16
- data/lib/generators/steroid/steroid_generator.rb +1 -1
- data/lib/rails_steroids/cli.rb +6 -5
- data/lib/rails_steroids/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: df4e95abc0bcd978678c7fca5b7a63daaf98f652b4e117295453cc3314df8baf
|
|
4
|
+
data.tar.gz: '038b916212e3c2c092825e96ebd0e8bcbf50508330542f35182008bcfd5b6807'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 678f0a8b483a2f389652f1907e9b0ec3d87a7ffb5c110b26a3332f4a8c9905ec4b9f3f74b5e928c7cf97521ec750bad6568960c30792943f2ec13ebddfe7119b
|
|
7
|
+
data.tar.gz: 995c17f522d05f5fef7ba4957d52d23377a4ca249310d029bd73005a52e7e00cb793378318a76c42bf629f1a7ee0152bed5d96a92fdb4d6fc0c96db03e964143
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.7.1] - 2024-02-09
|
|
4
|
+
|
|
5
|
+
- Improvement: Formatting to terminal output for all steroids
|
|
6
|
+
- Improvement: Formatting of `rails_steroids list` output in table format
|
|
7
|
+
- Fix: RailsSteroids Banner display on terminal
|
|
8
|
+
|
|
3
9
|
## [0.7.0] - 2024-02-08
|
|
4
10
|
|
|
5
11
|
- Improvement in steroid recipe: migration
|
data/bin/rails_steroids
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
banner = <<-BANNER
|
|
4
4
|
____ _ __ _____ __ _ __
|
|
5
|
-
/ __
|
|
6
|
-
/ /_/ / __ `/ / / ___/
|
|
5
|
+
/ __ \\____ _(_) /____ / ___// /____ _________ (_)___/ /____
|
|
6
|
+
/ /_/ / __ `/ / / ___/ \\__ \\/ __/ _ \\/ ___/ __ \\/ / __ / ___/
|
|
7
7
|
/ _, _/ /_/ / / (__ ) ___/ / /_/ __/ / / /_/ / / /_/ (__ )
|
|
8
|
-
/_/ |_
|
|
8
|
+
/_/ |_|\\__,_/_/_/____/ /____/\\__/\\___/_/ \\____/_/\\__,_/____/
|
|
9
|
+
|
|
9
10
|
BANNER
|
|
10
11
|
|
|
11
12
|
puts banner
|
|
@@ -16,4 +17,4 @@ end
|
|
|
16
17
|
|
|
17
18
|
require "rails_steroids/cli"
|
|
18
19
|
|
|
19
|
-
RailsSteroids::CLI.start(ARGV)
|
|
20
|
+
RailsSteroids::CLI.start(ARGV)
|
|
@@ -8,22 +8,22 @@ module Steroid
|
|
|
8
8
|
source_root File.expand_path("templates", __dir__)
|
|
9
9
|
|
|
10
10
|
def add_controller
|
|
11
|
-
say "
|
|
11
|
+
say "Applying steroid: Controller", [:bold, :magenta]
|
|
12
12
|
cmd = ["rails generate controller"]
|
|
13
13
|
prompt = TTY::Prompt.new
|
|
14
|
-
controller_name = prompt.ask("
|
|
14
|
+
controller_name = prompt.ask("\nWhat is the great name of your controller?") do |q|
|
|
15
15
|
q.required true
|
|
16
16
|
q.modify :remove
|
|
17
17
|
end
|
|
18
18
|
cmd << controller_name
|
|
19
19
|
|
|
20
|
-
actions = prompt.multi_select("
|
|
20
|
+
actions = prompt.multi_select("\nChoose actions:", %w(index show new edit create update destroy))
|
|
21
21
|
cmd += actions
|
|
22
22
|
|
|
23
23
|
boolean_choices = [{name: "yes", value: true}, {name: "no", value: false}]
|
|
24
24
|
|
|
25
25
|
custom_actions = []
|
|
26
|
-
while prompt.select("
|
|
26
|
+
while prompt.select("\nWould you like to add more actions?", boolean_choices)
|
|
27
27
|
custom_actions << prompt.ask("Specify name of action:") do |q|
|
|
28
28
|
q.required true
|
|
29
29
|
q.modify :remove
|
|
@@ -31,8 +31,8 @@ module Steroid
|
|
|
31
31
|
end
|
|
32
32
|
cmd += custom_actions
|
|
33
33
|
|
|
34
|
-
cmd << "--skip-routes" if prompt.select("
|
|
35
|
-
cmd << "--no-helper" if prompt.select("
|
|
34
|
+
cmd << "--skip-routes" if prompt.select("\nSkip routes?", boolean_choices)
|
|
35
|
+
cmd << "--no-helper" if prompt.select("\nSkip helper?", boolean_choices)
|
|
36
36
|
|
|
37
37
|
run cmd.join(" ")
|
|
38
38
|
end
|
|
@@ -13,8 +13,7 @@ module Steroid
|
|
|
13
13
|
include ActiveRecord::Migration::JoinTable
|
|
14
14
|
|
|
15
15
|
def add_migration
|
|
16
|
-
say "
|
|
17
|
-
cmd = ["rails generate migration"]
|
|
16
|
+
say "Applying steroid: Migration", [:bold, :magenta]
|
|
18
17
|
|
|
19
18
|
action_choices = [
|
|
20
19
|
{name: 'Create table', value: 'create_table'},
|
|
@@ -22,39 +21,39 @@ module Steroid
|
|
|
22
21
|
{name: 'Drop table', value: 'drop_table'},
|
|
23
22
|
{name: 'Modify table columns/index', value: 'modify_table'},
|
|
24
23
|
]
|
|
25
|
-
@action = prompt.select("
|
|
24
|
+
@action = prompt.select("\nWhat would you like to do?", action_choices)
|
|
26
25
|
|
|
27
26
|
case @action
|
|
28
27
|
when 'create_table'
|
|
29
|
-
table_name = prompt.ask("
|
|
28
|
+
table_name = prompt.ask("\nWhat is the name of table to be created?", required: true) { |q| q.modify :remove }
|
|
30
29
|
@content = content_for_create_table(table_name, collect_columns_data)
|
|
31
30
|
migration_template "migration.rb", "#{db_migrate_path}/create_#{table_name}.rb"
|
|
32
31
|
when 'create_join_table'
|
|
33
|
-
table1_name = prompt.ask("
|
|
34
|
-
table2_name = prompt.ask("
|
|
35
|
-
table_name = prompt.ask("
|
|
32
|
+
table1_name = prompt.ask("\nWhat is the name of first table to be joined?", required: true) { |q| q.modify :remove }
|
|
33
|
+
table2_name = prompt.ask("\nWhat is the name of second table to be joined?", required: true) { |q| q.modify :remove }
|
|
34
|
+
table_name = prompt.ask("\nWhat is the custom name for join table?", default: find_join_table_name(table1_name, table2_name), required: true) { |q| q.modify :remove }
|
|
36
35
|
columns_data = []
|
|
37
|
-
if prompt.select("
|
|
36
|
+
if prompt.select("\nAdd `id` column?", boolean_choices)
|
|
38
37
|
columns_data << {name: 'id', type: 'primary_key'}
|
|
39
38
|
end
|
|
40
|
-
if prompt.select("
|
|
39
|
+
if prompt.select("\nAdd index for #{table1_name} foreign_key?", boolean_choices)
|
|
41
40
|
columns_data << {name: "#{table1_name.singularize}_id", type: 'index'}
|
|
42
41
|
end
|
|
43
|
-
if prompt.select("
|
|
42
|
+
if prompt.select("\nAdd index for #{table2_name} foreign_key?", boolean_choices)
|
|
44
43
|
columns_data << {name: "#{table2_name.singularize}_id", type: 'index'}
|
|
45
44
|
end
|
|
46
|
-
if prompt.select("
|
|
45
|
+
if prompt.select("\nAdd composite index for #{table1_name} and #{table2_name} foreign_key?", boolean_choices)
|
|
47
46
|
uniq_index_option = prompt.select("Unique combination index?", boolean_choices) ? {meta: {unique: true}} : {}
|
|
48
47
|
columns_data << {name: ["#{table2_name.singularize}_id", "#{table2_name.singularize}_id"], type: 'index'}.merge(uniq_index_option)
|
|
49
48
|
end
|
|
50
49
|
@content = content_for_create_join_table(table1_name, table2_name, table_name, (columns_data + collect_columns_data))
|
|
51
50
|
migration_template "migration.rb", "#{db_migrate_path}/create_join_table_#{table_name}.rb"
|
|
52
51
|
when 'drop_table'
|
|
53
|
-
table_name = prompt.ask("
|
|
52
|
+
table_name = prompt.ask("\nWhat is the name of table to be dropped?", required: true) { |q| q.modify :remove }
|
|
54
53
|
@content = content_for_drop_table(table_name)
|
|
55
54
|
migration_template "migration.rb", "#{db_migrate_path}/drop_#{table_name}.rb"
|
|
56
55
|
when 'modify_table'
|
|
57
|
-
table_name = prompt.ask("
|
|
56
|
+
table_name = prompt.ask("\nWhat is the name of table to add/remove columns/index?", required: true) { |q| q.modify :remove }
|
|
58
57
|
modify_table_choices = [
|
|
59
58
|
{name: 'Add column', value: 'add_column'}, {name: 'Remove column', value: 'remove_column'},
|
|
60
59
|
{name: 'Add index', value: 'add_index'}, {name: 'Remove index', value: 'remove_index'},
|
|
@@ -64,7 +63,7 @@ module Steroid
|
|
|
64
63
|
]
|
|
65
64
|
@content = []
|
|
66
65
|
file_name = []
|
|
67
|
-
while (modify_table_action = prompt.select("
|
|
66
|
+
while (modify_table_action = prompt.select("\nWhat would you like to do?", modify_table_choices)) != 'exit'
|
|
68
67
|
for_removal = modify_table_action.start_with?('remove_')
|
|
69
68
|
if modify_table_action.end_with?('_index') || modify_table_action.end_with?('_reference')
|
|
70
69
|
data = modify_table_action.end_with?('_index') ? ask_index_data(for_removal: for_removal) : ask_reference_data(for_removal: for_removal)
|
|
@@ -92,7 +91,7 @@ module Steroid
|
|
|
92
91
|
|
|
93
92
|
def collect_columns_data
|
|
94
93
|
columns_data = []
|
|
95
|
-
while prompt.select("
|
|
94
|
+
while prompt.select("\nWould you like to add model attributes(columns)?", boolean_choices)
|
|
96
95
|
columns_data << ask_column_data
|
|
97
96
|
end
|
|
98
97
|
timestamps_data = ask_timestamps_data
|
|
@@ -149,7 +148,6 @@ module Steroid
|
|
|
149
148
|
column_data[:meta][:index] = prompt.select("Unique index?", boolean_choices) ? :unique : true
|
|
150
149
|
end
|
|
151
150
|
end
|
|
152
|
-
|
|
153
151
|
column_data.merge!(name: column_name, type: column_type)
|
|
154
152
|
column_data
|
|
155
153
|
end
|
|
@@ -179,7 +177,7 @@ module Steroid
|
|
|
179
177
|
end
|
|
180
178
|
|
|
181
179
|
def ask_timestamps_data
|
|
182
|
-
if prompt.select("
|
|
180
|
+
if prompt.select("\nAdd timestamps?", boolean_choices)
|
|
183
181
|
{ type: 'timestamps' }
|
|
184
182
|
end
|
|
185
183
|
end
|
|
@@ -8,10 +8,10 @@ module Steroid
|
|
|
8
8
|
source_root File.expand_path("templates", __dir__)
|
|
9
9
|
|
|
10
10
|
def add_model
|
|
11
|
-
say "
|
|
11
|
+
say "Applying steroid: Model", [:bold, :magenta]
|
|
12
12
|
cmd = ["rails generate model"]
|
|
13
13
|
prompt = TTY::Prompt.new
|
|
14
|
-
model_name = prompt.ask("
|
|
14
|
+
model_name = prompt.ask("\nWhat is the great name of your model?") do |q|
|
|
15
15
|
q.required true
|
|
16
16
|
q.modify :remove
|
|
17
17
|
end
|
|
@@ -20,7 +20,7 @@ module Steroid
|
|
|
20
20
|
boolean_choices = [{name: "yes", value: true}, {name: "no", value: false}]
|
|
21
21
|
|
|
22
22
|
columns = []
|
|
23
|
-
while prompt.select("
|
|
23
|
+
while prompt.select("\nWould you like to add model attributes(columns)?", boolean_choices)
|
|
24
24
|
|
|
25
25
|
column_name = prompt.ask("Specify name of column:") do |q|
|
|
26
26
|
q.required true
|
|
@@ -67,9 +67,9 @@ module Steroid
|
|
|
67
67
|
end
|
|
68
68
|
cmd += columns
|
|
69
69
|
|
|
70
|
-
cmd << "--no-migration" if prompt.select("
|
|
71
|
-
cmd << "--no-timestamps" if prompt.select("
|
|
72
|
-
cmd << "--no-indexes" if prompt.select("
|
|
70
|
+
cmd << "--no-migration" if prompt.select("\nSkip migration?", boolean_choices)
|
|
71
|
+
cmd << "--no-timestamps" if prompt.select("\nSkip created_at, updated_at timestamps?", boolean_choices)
|
|
72
|
+
cmd << "--no-indexes" if prompt.select("\nSkip indexes?", boolean_choices)
|
|
73
73
|
|
|
74
74
|
run cmd.join(" ")
|
|
75
75
|
end
|
|
@@ -8,15 +8,15 @@ module Steroid
|
|
|
8
8
|
source_root File.expand_path("templates", __dir__)
|
|
9
9
|
|
|
10
10
|
def add_new_project
|
|
11
|
-
say "
|
|
11
|
+
say "Applying steroid: New Project", [:bold, :magenta]
|
|
12
12
|
prompt = TTY::Prompt.new
|
|
13
|
-
project_name = prompt.ask("
|
|
13
|
+
project_name = prompt.ask("\nWhat is the great name of your Rails project?") do |q|
|
|
14
14
|
q.required true
|
|
15
15
|
q.modify :remove
|
|
16
16
|
end
|
|
17
17
|
empty_directory project_name
|
|
18
18
|
|
|
19
|
-
ruby_version = prompt.ask("
|
|
19
|
+
ruby_version = prompt.ask("\nWhich Ruby version would you like to use?") do |q|
|
|
20
20
|
q.required true
|
|
21
21
|
q.modify :remove
|
|
22
22
|
end
|
|
@@ -26,33 +26,33 @@ module Steroid
|
|
|
26
26
|
|
|
27
27
|
cmd = ["rails"]
|
|
28
28
|
current_rails_version = `rails --version`.gsub('Rails ', '').strip
|
|
29
|
-
rails_version = prompt.ask("
|
|
29
|
+
rails_version = prompt.ask("\nWhich Rails version would you like to use? You can find Rails version from https://rubygems.org/gems/rails/versions.", default: current_rails_version)
|
|
30
30
|
cmd << "_#{rails_version}_"
|
|
31
31
|
cmd << "new"
|
|
32
32
|
cmd << project_name
|
|
33
33
|
|
|
34
34
|
database_options = %w(mysql trilogy postgresql sqlite3 oracle sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc)
|
|
35
|
-
database_name = prompt.select("
|
|
35
|
+
database_name = prompt.select("\nChoose your database:", database_options)
|
|
36
36
|
cmd << "--database #{database_name}"
|
|
37
37
|
|
|
38
|
-
asset_pipeline = prompt.select("
|
|
38
|
+
asset_pipeline = prompt.select("\nChoose your asset pipeline:", %w(sprockets propshaft))
|
|
39
39
|
cmd << "--asset-pipeline #{asset_pipeline}"
|
|
40
40
|
|
|
41
|
-
css = prompt.select("
|
|
41
|
+
css = prompt.select("\nChoose CSS processor:", %w(tailwind bootstrap bulma postcss sass))
|
|
42
42
|
cmd << "--css #{css}"
|
|
43
43
|
|
|
44
|
-
js = prompt.select("
|
|
44
|
+
js = prompt.select("\nChoose JavaScript approach:", %w(importmap bun webpack esbuild rollup))
|
|
45
45
|
cmd << "--javascript #{js}"
|
|
46
46
|
|
|
47
47
|
boolean_choices = [{name: "yes", value: true}, {name: "no", value: false}]
|
|
48
|
-
cmd << "--api" if prompt.select("
|
|
49
|
-
cmd << "--skip-jbuilder" if prompt.select("
|
|
50
|
-
cmd << "--skip-git" if prompt.select("
|
|
51
|
-
cmd << "--skip-docker" if prompt.select("
|
|
52
|
-
cmd << "--skip-action-cable" if prompt.select("
|
|
53
|
-
cmd << "--skip-hotwire" if prompt.select("
|
|
54
|
-
cmd << "--skip-test" if prompt.select("
|
|
55
|
-
cmd << "--skip-system-test" if prompt.select("
|
|
48
|
+
cmd << "--api" if prompt.select("\nAPI only application?", boolean_choices)
|
|
49
|
+
cmd << "--skip-jbuilder" if prompt.select("\nSkip jbuilder?", boolean_choices)
|
|
50
|
+
cmd << "--skip-git" if prompt.select("\nSkip git init, .gitignore and .gitattributes?", boolean_choices)
|
|
51
|
+
cmd << "--skip-docker" if prompt.select("\nSkip Dockerfile, .dockerignore and bin/docker-entrypoint?", boolean_choices)
|
|
52
|
+
cmd << "--skip-action-cable" if prompt.select("\nSkip Action Cable files?", boolean_choices)
|
|
53
|
+
cmd << "--skip-hotwire" if prompt.select("\nSkip Hotwire integration?", boolean_choices)
|
|
54
|
+
cmd << "--skip-test" if prompt.select("\nSkip test files?", boolean_choices)
|
|
55
|
+
cmd << "--skip-system-test" if prompt.select("\nSkip system test files?", boolean_choices)
|
|
56
56
|
cmd << "--no-rc" # To skip configurations from .railsrc
|
|
57
57
|
cmd << "--skip" # To skip overriding existing files
|
|
58
58
|
run cmd.join(" ")
|
|
@@ -13,7 +13,7 @@ class SteroidGenerator < Rails::Generators::NamedBase
|
|
|
13
13
|
source_root File.expand_path("templates", __dir__)
|
|
14
14
|
|
|
15
15
|
def add_#{name}
|
|
16
|
-
say "
|
|
16
|
+
say "Applying steroid: #{name.titlecase}", [:bold, :magenta]
|
|
17
17
|
# Add your other code here or any additional methods below this method
|
|
18
18
|
end
|
|
19
19
|
end
|
data/lib/rails_steroids/cli.rb
CHANGED
|
@@ -21,18 +21,19 @@ module RailsSteroids
|
|
|
21
21
|
|
|
22
22
|
desc "list", "Print list of steroids"
|
|
23
23
|
def list
|
|
24
|
-
|
|
25
|
-
puts "| Functionality | Command |"
|
|
26
|
-
puts "|---|---|"
|
|
24
|
+
say "RailsSteroids list", [:bold, :cyan]
|
|
27
25
|
steroid_names = [
|
|
28
26
|
'migration',
|
|
29
27
|
'model',
|
|
30
28
|
'controller',
|
|
31
29
|
'new_project',
|
|
32
30
|
]
|
|
31
|
+
arr = [['Functionality', 'Command']]
|
|
32
|
+
arr << ['===============', '================================================']
|
|
33
33
|
steroid_names.each do |steroid|
|
|
34
|
-
|
|
34
|
+
arr << [steroid.titlecase, "`rails_steroids inject steroid:#{steroid}`"]
|
|
35
35
|
end
|
|
36
|
+
print_table(arr, {borders: true})
|
|
36
37
|
# TODO: Glob all file and prepare a list of available generators
|
|
37
38
|
end
|
|
38
39
|
|
|
@@ -53,4 +54,4 @@ module RailsSteroids
|
|
|
53
54
|
"../generators/steroid/#{generator_name}/#{generator_name}_generator.rb"
|
|
54
55
|
end
|
|
55
56
|
end
|
|
56
|
-
end
|
|
57
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails_steroids
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.7.
|
|
4
|
+
version: 0.7.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-
|
|
11
|
+
date: 2024-02-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|