rails_app_generator 0.2.21 → 0.2.24
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/.builders/generators/project-plan.rb +16 -2
- data/CHANGELOG.md +24 -0
- data/after_templates/addons/avo/_.rb +54 -0
- data/after_templates/addons/avo/app/controllers/home_controller.rb +4 -0
- data/after_templates/addons/avo/app/views/home/index.html.erb +3 -0
- data/after_templates/addons/avo/app/views/layouts/_footer.html.erb +3 -0
- data/after_templates/addons/avo/app/views/layouts/_navbar.html.erb +8 -0
- data/after_templates/addons/avo/app/views/layouts/application.html.erb +23 -0
- data/after_templates/addons/avo/db/seeds.rb +132 -0
- data/after_templates/addons/devise/_.rb +70 -0
- data/after_templates/addons/devise/app/controllers/home_controller.rb +4 -0
- data/after_templates/addons/devise/app/controllers/posts_controller.rb +81 -0
- data/after_templates/addons/devise/app/models/post.rb +11 -0
- data/after_templates/addons/devise/app/models/user.rb +17 -0
- data/after_templates/addons/devise/app/views/home/index.html.erb +40 -0
- data/after_templates/addons/devise/app/views/layouts/_footer.html.erb +1 -0
- data/after_templates/addons/devise/app/views/layouts/_navbar.html.erb +10 -0
- data/after_templates/addons/devise/app/views/layouts/application.html.erb +38 -0
- data/after_templates/addons/devise/app/views/posts/_form.html.erb +27 -0
- data/after_templates/addons/devise/app/views/posts/_post.html.erb +14 -0
- data/after_templates/addons/devise/app/views/posts/index.html.erb +12 -0
- data/after_templates/addons/devise/app/views/posts/show.html.erb +8 -0
- data/after_templates/addons/devise/db/seeds.rb +11 -0
- data/after_templates/addons/minimal_css/_.rb +62 -0
- data/after_templates/addons/minimal_css/app/controllers/home_controller.rb +4 -0
- data/after_templates/addons/minimal_css/app/views/home/index.html.erb +140 -0
- data/after_templates/addons/minimal_css/app/views/layouts/_footer.html.erb +1 -0
- data/after_templates/addons/minimal_css/app/views/layouts/_navbar.html.erb +3 -0
- data/after_templates/addons/minimal_css/app/views/layouts/application.html.erb +29 -0
- data/after_templates/addons/minimal_css/db/seeds.rb +5 -0
- data/after_templates/rag/devise/_.rb +14 -17
- data/after_templates/rag/devise/app/controllers/home_controller.rb +4 -0
- data/after_templates/rag/devise/{post → app/controllers}/posts_controller.rb +0 -0
- data/after_templates/rag/devise/{post → app/models}/post.rb +0 -0
- data/after_templates/rag/devise/app/views/home/index.html.erb +3 -0
- data/after_templates/rag/devise/app/views/layouts/_footer.html.erb +3 -0
- data/after_templates/rag/devise/app/views/layouts/_navbar.html.erb +8 -0
- data/after_templates/rag/devise/app/views/layouts/application.html.erb +24 -0
- data/after_templates/rag/devise/{post → app/views/post}/_post.html.erb +0 -0
- data/after_templates/rag/test/_.rb +64 -0
- data/after_templates/rag/test/app/controllers/home_controller.rb +4 -0
- data/after_templates/rag/test/app/views/home/index.html.erb +3 -0
- data/after_templates/rag/test/app/views/layouts/_footer.html.erb +1 -0
- data/after_templates/rag/test/app/views/layouts/_navbar.html.erb +5 -0
- data/after_templates/rag/test/app/views/layouts/application.html.erb +29 -0
- data/after_templates/rag/test/db/seeds.rb +7 -0
- data/after_templates/rag/testy/_.rb +64 -0
- data/after_templates/rag/testy/app/controllers/home_controller.rb +4 -0
- data/after_templates/rag/testy/app/views/home/index.html.erb +3 -0
- data/after_templates/rag/testy/app/views/layouts/_footer.html.erb +1 -0
- data/after_templates/rag/testy/app/views/layouts/_navbar.html.erb +5 -0
- data/after_templates/rag/testy/app/views/layouts/application.html.erb +29 -0
- data/after_templates/rag/testy/db/seeds.rb +7 -0
- data/docs/last_run/app_generator_class.json +58 -34
- data/docs/last_run/app_generator_data.json +13 -10
- data/docs/last_run/rails_options_class.json +48 -24
- data/docs/last_run/rails_options_data.json +13 -10
- data/docs/project-plan/project.drawio +65 -59
- data/docs/project-plan/project_done.svg +1 -1
- data/lib/rails_app_generator/addon.rb +20 -2
- data/lib/rails_app_generator/addons/avo.rb +27 -0
- data/lib/rails_app_generator/addons/devise.rb +78 -28
- data/lib/rails_app_generator/addons/devise_old.rb +22 -0
- data/lib/rails_app_generator/addons/minimal_css.rb +70 -0
- data/lib/rails_app_generator/app_generator.rb +39 -20
- data/lib/rails_app_generator/gem_query.rb +34 -0
- data/lib/rails_app_generator/rag_initializer.rb +24 -8
- data/lib/rails_app_generator/version.rb +1 -1
- data/lib/rails_app_generator.rb +1 -0
- data/package-lock.json +2 -2
- data/package.json +1 -1
- data/profiles/addons/avo.json +16 -0
- data/profiles/addons/devise.json +16 -0
- data/profiles/addons/minimal_css.json +15 -0
- data/profiles/rag/testy.json +12 -0
- data/tasks/addon.thor +7 -3
- data/tasks/profile.thor +3 -3
- data/templates/Gemfile.erb +1 -0
- data/{after_templates/rag/devise/turbo_controller.rb → templates/addons/devise/app/controllers/turbo_devise_controller.rb} +4 -10
- data/templates/addons/devise/app/controllers/users/registrations_controller.rb +62 -0
- data/templates/addons/devise/app/views/devise/registrations/edit.html.erb +40 -54
- data/templates/addons/devise/app/views/devise/registrations/new.html.erb +32 -43
- data/templates/addons/devise/app/views/layouts/_alerts.html.erb +2 -0
- data/{after_templates/rag → templates/addons}/devise/config/initializers/devise_turbo.rb +1 -1
- data/templates/thor_task/profile/after_template.rb +1 -1
- data/templates/thor_task/profile/app/views/layouts/_footer.html.erb.tt +1 -3
- data/templates/thor_task/profile/app/views/layouts/_navbar.html.erb +5 -8
- data/templates/thor_task/profile/app/views/layouts/application.html.erb.tt +8 -2
- data/templates/thor_task/profile/db/seeds.rb +2 -11
- metadata +64 -17
- data/after_templates/rag/devise/application.html.erb +0 -20
- data/tasks/gem_info.rb +0 -47
- data/templates/addons/devise/app/views/devise/confirmations/new.html.erb +0 -24
- data/templates/addons/devise/app/views/devise/passwords/edit.html.erb +0 -34
- data/templates/addons/devise/app/views/devise/passwords/new.html.erb +0 -23
- data/templates/addons/devise/app/views/devise/sessions/new.html.erb +0 -33
- data/templates/addons/devise/app/views/devise/shared/_error_messages.html.erb +0 -15
- data/templates/addons/devise/app/views/devise/shared/_form_wrap.html.erb +0 -5
- data/templates/addons/devise/app/views/devise/shared/_links.html.erb +0 -25
- data/templates/addons/devise/app/views/devise/unlocks/new.html.erb +0 -22
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RailsAppGenerator
|
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
|
5
|
+
module AddOns
|
|
6
|
+
# Add Avo to rails application
|
|
7
|
+
class Avo < RailsAppGenerator::Addon
|
|
8
|
+
required_gem gem.version('avo', '2.12.0', 'Avo full-featured admin panel abstracts away the common parts of building apps, letting your engineers work on your apps essential components.')
|
|
9
|
+
|
|
10
|
+
def apply
|
|
11
|
+
# copy_file 'config/initializers/avo.rb'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def before_template
|
|
15
|
+
say 'Setting up Avo - before custom template'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def before_bundle
|
|
19
|
+
say 'Setting up Avo - before bundle install'
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def after_bundle
|
|
23
|
+
say 'Setting up Avo - after bundle install'
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -3,58 +3,108 @@
|
|
|
3
3
|
module RailsAppGenerator
|
|
4
4
|
# Custom add-ons for RailsAppGenerator
|
|
5
5
|
module AddOns
|
|
6
|
-
# Add Devise
|
|
6
|
+
# Add Devise to rails application
|
|
7
7
|
class Devise < RailsAppGenerator::Addon
|
|
8
8
|
depends_on :active_record
|
|
9
9
|
|
|
10
10
|
required_gem gem.version('devise', '4.8.1', 'Flexible authentication solution for Rails with Warden')
|
|
11
11
|
|
|
12
|
-
# Requires Testing
|
|
13
12
|
def apply
|
|
14
13
|
generate('devise:install', capture: true)
|
|
15
|
-
generate(:devise, 'User', 'name', '
|
|
14
|
+
generate(:devise, 'User', 'name', 'role:integer', capture: true)
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
update_migration
|
|
18
17
|
|
|
18
|
+
add_trackable if option?(:devise_has_trackable)
|
|
19
|
+
add_confirmable if option?(:devise_has_confirmable)
|
|
20
|
+
add_lockable if option?(:devise_has_lockable)
|
|
21
|
+
|
|
22
|
+
add_turbo_support
|
|
23
|
+
|
|
24
|
+
generate('devise:views', capture: true)
|
|
19
25
|
generate('devise:controllers', 'users', capture: true)
|
|
20
26
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
update_routes_with_devise_controllers
|
|
28
|
+
|
|
29
|
+
copy_file('app/controllers/users/registrations_controller.rb', 'app/controllers/users/registrations_controller.rb', force: true)
|
|
30
|
+
|
|
31
|
+
enable_devise_mailer
|
|
32
|
+
|
|
33
|
+
directory('app/views', force: true)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def before_bundle
|
|
37
|
+
prepend_to_file 'db/seeds.rb', seed, force: true
|
|
26
38
|
end
|
|
27
39
|
|
|
28
40
|
private
|
|
29
41
|
|
|
30
|
-
def
|
|
31
|
-
|
|
32
|
-
|
|
42
|
+
def update_migration
|
|
43
|
+
in_root do
|
|
44
|
+
migration = Dir.glob('db/migrate/*').max_by { |f| File.mtime(f) }
|
|
45
|
+
gsub_file migration, /:role/, ':role, default: 0'
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def enable_devise_mailer
|
|
50
|
+
inject_into_file 'config/environments/development.rb', <<-RUBY, after: %(config.action_mailer.raise_delivery_errors = false)
|
|
33
51
|
|
|
34
52
|
# Enable devise mailer
|
|
35
53
|
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
|
|
36
|
-
|
|
37
|
-
end
|
|
54
|
+
RUBY
|
|
38
55
|
end
|
|
39
56
|
|
|
40
|
-
def
|
|
57
|
+
def update_routes_with_devise_controllers
|
|
41
58
|
in_root do
|
|
42
|
-
|
|
43
|
-
gsub_file migration, /:admin/, ':admin, default: false'
|
|
59
|
+
gsub_file 'config/routes.rb', /devise_for :users/, 'devise_for :users, controllers: { sessions: "users/sessions", registrations: "users/registrations" }'
|
|
44
60
|
end
|
|
45
61
|
end
|
|
46
62
|
|
|
47
|
-
def
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
def add_trackable
|
|
64
|
+
# TODO: remove these comments in generated file
|
|
65
|
+
|
|
66
|
+
## Trackable
|
|
67
|
+
# t.integer :sign_in_count, default: 0, null: false
|
|
68
|
+
# t.datetime :current_sign_in_at
|
|
69
|
+
# t.datetime :last_sign_in_at
|
|
70
|
+
# t.string :current_sign_in_ip
|
|
71
|
+
# t.string :last_sign_in_ip
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def add_confirmable
|
|
75
|
+
# TODO: remove these comments in generated file
|
|
76
|
+
|
|
77
|
+
## Confirmable
|
|
78
|
+
# t.string :confirmation_token
|
|
79
|
+
# t.datetime :confirmed_at
|
|
80
|
+
# t.datetime :confirmation_sent_at
|
|
81
|
+
# t.string :unconfirmed_email # Only if using reconfirmable
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def add_lockable
|
|
85
|
+
# TODO: remove these comments in generated file
|
|
86
|
+
|
|
87
|
+
## Lockable
|
|
88
|
+
# t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
|
|
89
|
+
# t.string :unlock_token # Only if unlock strategy is :email or :both
|
|
90
|
+
# t.datetime :locked_at
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def add_turbo_support
|
|
94
|
+
copy_file('app/controllers/turbo_devise_controller.rb', 'app/controllers/turbo_devise_controller.rb')
|
|
95
|
+
copy_file('config/initializers/devise_turbo.rb', 'config/initializers/devise_turbo.rb')
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def seed
|
|
99
|
+
<<~RUBY
|
|
100
|
+
# Create an initial admin user for development
|
|
101
|
+
User.find_or_create_by(email: "admin@admin.com") do |user|
|
|
102
|
+
user.name = 'Admin'
|
|
103
|
+
user.password = 'password'
|
|
104
|
+
user.role = :admin
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
RUBY
|
|
58
108
|
end
|
|
59
109
|
end
|
|
60
110
|
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RailsAppGenerator
|
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
|
5
|
+
module AddOns
|
|
6
|
+
# Add Devise authentication to rails application
|
|
7
|
+
class DeviseXxxx < RailsAppGenerator::Addon
|
|
8
|
+
depends_on :active_record
|
|
9
|
+
|
|
10
|
+
required_gem gem.version('devise', '4.8.1', 'Flexible authentication solution for Rails with Warden')
|
|
11
|
+
|
|
12
|
+
# Requires Testing
|
|
13
|
+
def apply
|
|
14
|
+
update_development_rb
|
|
15
|
+
gsub_file 'config/initializers/devise.rb', /# config.pepper = .+/, " # config.pepper = 'pepper'"
|
|
16
|
+
gsub_file 'config/initializers/devise.rb', /# config.secret_key = .+/, " # config.secret_key = 'secret_key'"
|
|
17
|
+
db_changes
|
|
18
|
+
create_seed
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RailsAppGenerator
|
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
|
5
|
+
module AddOns
|
|
6
|
+
# Add MinimalCss to rails application
|
|
7
|
+
class MinimalCss < RailsAppGenerator::Addon
|
|
8
|
+
LIBRARIES = {
|
|
9
|
+
water: {
|
|
10
|
+
source: 'https://watercss.kognise.dev',
|
|
11
|
+
content: '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">'
|
|
12
|
+
},
|
|
13
|
+
picnic: {
|
|
14
|
+
source: 'https://picnicss.com',
|
|
15
|
+
content: '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/picnic">'
|
|
16
|
+
},
|
|
17
|
+
chota: {
|
|
18
|
+
source: 'https://jenil.github.io/chota/',
|
|
19
|
+
content: '<link rel="stylesheet" href="https://unpkg.com/chota@latest">'
|
|
20
|
+
}
|
|
21
|
+
}.freeze
|
|
22
|
+
|
|
23
|
+
# https://purecss.io/
|
|
24
|
+
# https://bulma.io/
|
|
25
|
+
# https://get.foundation/
|
|
26
|
+
# https://www.blazeui.com/
|
|
27
|
+
# https://getbase.org/
|
|
28
|
+
# https://cirrus-ui.netlify.app/
|
|
29
|
+
# https://vanillaframework.io/
|
|
30
|
+
# https://www.patternfly.org/v4/
|
|
31
|
+
# https://tachyons.io/
|
|
32
|
+
# https://nostalgic-css.github.io/NES.css/
|
|
33
|
+
# https://selekkt.dk/skelet/v3/
|
|
34
|
+
# https://picturepan2.github.io/spectre/
|
|
35
|
+
# https://kylelogue.github.io/mustard-ui/
|
|
36
|
+
# https://www.bonsaicss.com/
|
|
37
|
+
# https://ajusa.github.io/lit/
|
|
38
|
+
# https://www.cutestrap.com/
|
|
39
|
+
# https://kbrsh.github.io/wing/
|
|
40
|
+
# https://devinhunt.github.io/typebase.css/
|
|
41
|
+
# http://getskeleton.com/
|
|
42
|
+
# https://semantic-ui.com/
|
|
43
|
+
# https://getuikit.com/
|
|
44
|
+
|
|
45
|
+
# ANIMATION
|
|
46
|
+
# https://animate.style/
|
|
47
|
+
# https://www.csswand.dev/
|
|
48
|
+
# http://animation.kaustubhmenon.com/
|
|
49
|
+
# https://www.minimamente.com/project/magic/
|
|
50
|
+
|
|
51
|
+
def apply; end
|
|
52
|
+
|
|
53
|
+
def after_bundle
|
|
54
|
+
library_key = (options[:minimal_css_library] || 'water').to_sym
|
|
55
|
+
|
|
56
|
+
insert_into_file 'app/views/layouts/application.html.erb', head(library_key), before: %r{^\s+</head>}, force: true
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
private
|
|
60
|
+
|
|
61
|
+
def head(library_key)
|
|
62
|
+
library = LIBRARIES[library_key] || LIBRARIES[:water]
|
|
63
|
+
|
|
64
|
+
content = library[:content]
|
|
65
|
+
|
|
66
|
+
" #{content}\n"
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -170,27 +170,38 @@ module RailsAppGenerator
|
|
|
170
170
|
add_if(:acts_as_list) # tested
|
|
171
171
|
add_if(:administrate) # tested
|
|
172
172
|
add_if(:annotate) # tested
|
|
173
|
-
add_if(:
|
|
173
|
+
add_if(:avo) # tested
|
|
174
174
|
add_if(:bcrypt) # tested
|
|
175
|
-
add_if(:
|
|
176
|
-
add_if(:
|
|
177
|
-
add_if(:
|
|
178
|
-
add_if(:
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
add_if(:
|
|
182
|
-
add_if(:
|
|
183
|
-
add_if(:
|
|
184
|
-
add_if(:
|
|
185
|
-
add_if(:
|
|
186
|
-
add_if(:
|
|
187
|
-
add_if(:
|
|
188
|
-
add_if(:
|
|
189
|
-
add_if(:
|
|
190
|
-
add_if(:
|
|
191
|
-
add_if(:
|
|
192
|
-
add_if(:
|
|
193
|
-
add_if(:
|
|
175
|
+
add_if(:browser) # tested
|
|
176
|
+
add_if(:chartkick) # tested
|
|
177
|
+
add_if(:continuous_integration) # TODO: needs work
|
|
178
|
+
add_if(:devise) # tested
|
|
179
|
+
# docker_compose
|
|
180
|
+
# docker
|
|
181
|
+
add_if(:dotenv) # tested
|
|
182
|
+
add_if(:factory_bot) # TODO: needs testing
|
|
183
|
+
add_if(:faker) # tested
|
|
184
|
+
add_if(:generators) # TODO: needs testing
|
|
185
|
+
add_if(:groupdate) # TODO: does not have a profile
|
|
186
|
+
add_if(:hexapdf) # tested
|
|
187
|
+
add_if(:httparty) # tested
|
|
188
|
+
add_if(:high_voltage) # TODO: needs testing
|
|
189
|
+
add_if(:honeybadger) # tested
|
|
190
|
+
add_if(:lograge) # tested
|
|
191
|
+
add_if(:minimal_css) # tested (this is NOT a GEM)
|
|
192
|
+
add_if(:mini_magick) # tested
|
|
193
|
+
add_if(:motor_magick) # tested
|
|
194
|
+
add_if(:public_suffix) # tested
|
|
195
|
+
add_if(:phony_rails) # tested
|
|
196
|
+
add_if(:pundit) # TODO: needs testing
|
|
197
|
+
add_if(:rails_html_sanitizer) # tested
|
|
198
|
+
add_if(:rails_app_generator) # TODO: needs testing
|
|
199
|
+
add_if(:redcarpet) # tested
|
|
200
|
+
add_if(:services) # TODO: needs testing
|
|
201
|
+
add_if(:shoulda) # TODO: needs testing
|
|
202
|
+
add_if(:sidekiq) # TODO: needs testing
|
|
203
|
+
add_if(:rubocop) # tested
|
|
204
|
+
add_if(:twilio_ruby) # tested
|
|
194
205
|
add(:views, :errors, :scaffold) if active?(:views)
|
|
195
206
|
|
|
196
207
|
# invoke :rails_customization
|
|
@@ -200,6 +211,10 @@ module RailsAppGenerator
|
|
|
200
211
|
|
|
201
212
|
# Fire any callbacks defined on addons either before running the custom template
|
|
202
213
|
def apply_rails_template
|
|
214
|
+
# currently running prepare_environment in the template
|
|
215
|
+
# this is doing a bundle install
|
|
216
|
+
# unfortunately this bundle install happens before the normal bundle install, but for now
|
|
217
|
+
# I have to do it until I figure out the why I need the prepare_environment method anyway.
|
|
203
218
|
addon_instances.select { |addon| addon.respond_to?(:before_template) }.each(&:before_template)
|
|
204
219
|
super
|
|
205
220
|
end
|
|
@@ -422,6 +437,10 @@ module RailsAppGenerator
|
|
|
422
437
|
add_flag?(option_name) # || !skip_flag?(option_name)
|
|
423
438
|
end
|
|
424
439
|
|
|
440
|
+
def option?(option_name)
|
|
441
|
+
!options[option_name.to_sym].nil?
|
|
442
|
+
end
|
|
443
|
+
|
|
425
444
|
def uses?(addon)
|
|
426
445
|
return false unless active?(addon)
|
|
427
446
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Retrieve GemInfo from RubyGems.org
|
|
4
|
+
module RailsAppGenerator
|
|
5
|
+
# GemQuery queries RubyGems for GemEntry.
|
|
6
|
+
class GemQuery
|
|
7
|
+
class << self
|
|
8
|
+
def get(name)
|
|
9
|
+
gem_info = query_ruby_gems(name)
|
|
10
|
+
|
|
11
|
+
return gem_info if gem_info
|
|
12
|
+
|
|
13
|
+
return query_ruby_gems(name.gsub('_', '-')) if name.include?('_')
|
|
14
|
+
return query_ruby_gems(name.gsub('-', '_')) if name.include?('-')
|
|
15
|
+
|
|
16
|
+
abort "Cannot find GEM (#{name}) on RubyGems.org"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def query_ruby_gems(name)
|
|
22
|
+
link = "https://rubygems.org/api/v1/gems/#{name.downcase}.json"
|
|
23
|
+
info = Net::HTTP.get(URI.parse(link))
|
|
24
|
+
json = JSON.parse(info)
|
|
25
|
+
|
|
26
|
+
Rails::Generators::AppBase::GemfileEntry.new(json['name'], json['version'], json['description'])
|
|
27
|
+
rescue SocketError
|
|
28
|
+
abort 'Internet connection cannot be established to RubyGems.org'
|
|
29
|
+
rescue JSON::ParserError
|
|
30
|
+
nil
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -86,17 +86,12 @@ KConfig.configure do |config|
|
|
|
86
86
|
|
|
87
87
|
# rag.add_option :add_irbrc , type: :boolean, default: false
|
|
88
88
|
# rag.add_option :add_foreman , type: :boolean, default: false
|
|
89
|
-
rag.add_option :add_devise , type: :boolean, default: false
|
|
90
|
-
rag.add_option :add_dotenv , type: :boolean, default: false
|
|
91
89
|
# rag.add_option :add_docker , type: :boolean, default: false
|
|
92
90
|
# rag.add_option :add_docker_compose , type: :boolean, default: false
|
|
93
|
-
rag.add_option :add_rubocop , type: :boolean, default: false
|
|
94
|
-
rag.add_option :add_annotate , type: :boolean, default: false
|
|
95
91
|
# rag.add_option :add_continuous_integration , type: :boolean, default: false
|
|
96
92
|
# rag.add_option :add_high_voltage , type: :boolean, default: false
|
|
97
93
|
# rag.add_option :add_generators , type: :boolean, default: false
|
|
98
|
-
rag.add_option :
|
|
99
|
-
# rag.add_option :add_pundit , type: :boolean, default: false
|
|
94
|
+
# rag.add_option :add_pundit , type: :boolean, default: false # cancancan vs action_policy vs pundit
|
|
100
95
|
# rag.add_option :add_services , type: :boolean, default: false
|
|
101
96
|
# rag.add_option :add_sidekiq , type: :boolean, default: false
|
|
102
97
|
# rag.add_option :add_views , type: :boolean, default: false
|
|
@@ -104,24 +99,45 @@ KConfig.configure do |config|
|
|
|
104
99
|
# rag.add_option :add_scaffold , type: :boolean, default: false
|
|
105
100
|
# rag.add_option :add_factory_bot , type: :boolean, default: false
|
|
106
101
|
# rag.add_option :add_shoulda , type: :boolean, default: false
|
|
102
|
+
# letter_opener
|
|
107
103
|
|
|
108
104
|
# NEW GEM ADDONS
|
|
109
105
|
rag.add_option :add_acts_as_list , type: :boolean, default: false
|
|
110
106
|
rag.add_option :add_administrate , type: :boolean, default: false
|
|
111
|
-
rag.add_option :
|
|
107
|
+
rag.add_option :add_annotate , type: :boolean, default: false
|
|
108
|
+
rag.add_option :add_avo , type: :boolean, default: false
|
|
112
109
|
rag.add_option :add_bcrypt , type: :boolean, default: false
|
|
110
|
+
rag.add_option :add_browser , type: :boolean, default: false
|
|
113
111
|
rag.add_option :add_chartkick , type: :boolean, default: false
|
|
112
|
+
# continuous_integration
|
|
113
|
+
rag.add_option :add_devise , type: :boolean, default: false
|
|
114
|
+
# docker_compose
|
|
115
|
+
# docker
|
|
116
|
+
rag.add_option :add_dotenv , type: :boolean, default: false
|
|
117
|
+
# factory_bot
|
|
114
118
|
rag.add_option :add_faker , type: :boolean, default: false
|
|
119
|
+
# generators
|
|
115
120
|
rag.add_option :add_groupdate , type: :boolean, default: false
|
|
116
121
|
rag.add_option :add_hexapdf , type: :boolean, default: false
|
|
117
122
|
rag.add_option :add_httparty , type: :boolean, default: false
|
|
123
|
+
# high_voltage
|
|
118
124
|
rag.add_option :add_honeybadger , type: :boolean, default: false
|
|
125
|
+
rag.add_option :add_lograge , type: :boolean, default: false
|
|
126
|
+
rag.add_option :add_minimal_css , type: :boolean, default: false
|
|
127
|
+
rag.add_option :minimal_css_library , type: :string, default: 'water.css', description: "Minimal CSS library to get you started. [options: water.css (default)]"
|
|
119
128
|
rag.add_option :add_mini_magick , type: :boolean, default: false
|
|
120
129
|
rag.add_option :add_motor_admin , type: :boolean, default: false
|
|
121
|
-
rag.add_option :add_phony_rails , type: :boolean, default: false
|
|
122
130
|
rag.add_option :add_public_suffix , type: :boolean, default: false
|
|
131
|
+
rag.add_option :add_phony_rails , type: :boolean, default: false
|
|
132
|
+
# pundit
|
|
123
133
|
rag.add_option :add_rails_html_sanitizer , type: :boolean, default: false
|
|
134
|
+
# rails_app_generator
|
|
135
|
+
# RANSACK
|
|
124
136
|
rag.add_option :add_redcarpet , type: :boolean, default: false
|
|
137
|
+
# services
|
|
138
|
+
# shoulda
|
|
139
|
+
# sidekiq
|
|
140
|
+
rag.add_option :add_rubocop , type: :boolean, default: false
|
|
125
141
|
rag.add_option :add_twilio_ruby , type: :boolean, default: false
|
|
126
142
|
end
|
|
127
143
|
|
data/lib/rails_app_generator.rb
CHANGED
|
@@ -28,6 +28,7 @@ require 'rails_app_generator/options/options_builder'
|
|
|
28
28
|
require 'rails_app_generator/options/rails_options'
|
|
29
29
|
require 'rails_app_generator/context'
|
|
30
30
|
require 'rails_app_generator/dependencies'
|
|
31
|
+
require 'rails_app_generator/gem_query'
|
|
31
32
|
require 'rails_app_generator/addon'
|
|
32
33
|
require 'rails_app_generator/addon_util'
|
|
33
34
|
require 'rails_app_generator/formatted_gem_entry'
|
data/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rails_app_generator",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.24",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "rails_app_generator",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.24",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"daisyui": "^2.20.0"
|
|
12
12
|
},
|
data/package.json
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"args": {
|
|
3
|
+
"app_path": "avo",
|
|
4
|
+
"destination_root": "/Users/davidcruwys/dev/kgems/rails_app_generator/a/addons"
|
|
5
|
+
},
|
|
6
|
+
"opts": {
|
|
7
|
+
"skip_git": true,
|
|
8
|
+
"skip_test": true,
|
|
9
|
+
"template": "/Users/davidcruwys/dev/kgems/rails_app_generator/after_templates/addons/avo/_.rb",
|
|
10
|
+
"add_annotate": true,
|
|
11
|
+
"add_avo": true,
|
|
12
|
+
"add_devise": true,
|
|
13
|
+
"add_faker": true,
|
|
14
|
+
"add_rubocop": true
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"args": {
|
|
3
|
+
"app_path": "devise",
|
|
4
|
+
"destination_root": "/Users/davidcruwys/dev/kgems/rails_app_generator/a/addons"
|
|
5
|
+
},
|
|
6
|
+
"opts": {
|
|
7
|
+
"skip_git": true,
|
|
8
|
+
"skip_test": true,
|
|
9
|
+
"template": "/Users/davidcruwys/dev/kgems/rails_app_generator/after_templates/addons/devise/_.rb",
|
|
10
|
+
"notes": "javascript: esbuild is used for the demonstration of this addon so that the destroy_user_session_path can be used as a link using turbo_method: :delete",
|
|
11
|
+
"javascript": "esbuild",
|
|
12
|
+
"add_annotate": true,
|
|
13
|
+
"add_devise": true,
|
|
14
|
+
"add_faker": true
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"args": {
|
|
3
|
+
"app_path": "minimal_css",
|
|
4
|
+
"destination_root": "/Users/davidcruwys/dev/kgems/rails_app_generator/a/addons"
|
|
5
|
+
},
|
|
6
|
+
"opts": {
|
|
7
|
+
"skip_git": true,
|
|
8
|
+
"skip_test": true,
|
|
9
|
+
"note": "minimal_css_library is optional and will default to water if not specified.",
|
|
10
|
+
"template": "/Users/davidcruwys/dev/kgems/rails_app_generator/after_templates/addons/minimal_css/_.rb",
|
|
11
|
+
"add_faker": true,
|
|
12
|
+
"add_minimal_css": true,
|
|
13
|
+
"minimal_css_library": "water"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"args": {
|
|
3
|
+
"app_path": "testy",
|
|
4
|
+
"destination_root": "/Users/davidcruwys/dev/kgems/rails_app_generator/a/rag"
|
|
5
|
+
},
|
|
6
|
+
"opts": {
|
|
7
|
+
"skip_git": true,
|
|
8
|
+
"skip_test": true,
|
|
9
|
+
"template": "/Users/davidcruwys/dev/kgems/rails_app_generator/after_templates/rag/testy/_.rb",
|
|
10
|
+
"javascript": "esbuild"
|
|
11
|
+
}
|
|
12
|
+
}
|
data/tasks/addon.thor
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
require 'net/http'
|
|
6
6
|
require 'json'
|
|
7
|
-
|
|
7
|
+
require 'pry'
|
|
8
|
+
require 'cmdlet'
|
|
9
|
+
require 'rails_app_generator'
|
|
8
10
|
|
|
9
11
|
# Thor task to create a new Addon for Rails App Generator
|
|
10
12
|
class Addon < Thor
|
|
@@ -46,9 +48,11 @@ class Addon < Thor
|
|
|
46
48
|
end
|
|
47
49
|
|
|
48
50
|
def build_required_gem_code
|
|
51
|
+
return nil unless options[:gem]
|
|
52
|
+
|
|
49
53
|
info = gem_info
|
|
50
54
|
|
|
51
|
-
" required_gem gem.version('#{info.name}', '#{info.version}', '#{info.
|
|
55
|
+
" required_gem gem.version('#{info.name}', '#{info.version}', '#{info.comment}')"
|
|
52
56
|
end
|
|
53
57
|
|
|
54
58
|
# example: 'https://rubygems.org/api/v1/gems/draper.json'
|
|
@@ -57,7 +61,7 @@ class Addon < Thor
|
|
|
57
61
|
|
|
58
62
|
gem_name = options[:gem] == 'gem' ? name : options[:gem]
|
|
59
63
|
|
|
60
|
-
::
|
|
64
|
+
RailsAppGenerator::GemQuery.get(gem_name)
|
|
61
65
|
end
|
|
62
66
|
|
|
63
67
|
def build_data
|
data/tasks/profile.thor
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# https://codecrate.com/2014/01/replace-rake-with-thor.html
|
|
4
4
|
|
|
5
|
-
require_relative 'gem_info'
|
|
6
5
|
require 'cmdlet'
|
|
6
|
+
require 'rails_app_generator'
|
|
7
7
|
|
|
8
8
|
# Thor task to create a new Profile for Rails App Generator
|
|
9
9
|
class Profile < Thor
|
|
@@ -70,7 +70,7 @@ class Profile < Thor
|
|
|
70
70
|
def build_data
|
|
71
71
|
gi = gem_info(name)
|
|
72
72
|
|
|
73
|
-
description = gi ? gi.
|
|
73
|
+
description = gi ? gi.comment : 'Description goes here'
|
|
74
74
|
|
|
75
75
|
Data.new(
|
|
76
76
|
name: name,
|
|
@@ -104,7 +104,7 @@ class Profile < Thor
|
|
|
104
104
|
|
|
105
105
|
gem_name = options[:gem] == 'gem' ? name : options[:gem]
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
RailsAppGenerator::GemQuery.get(gem_name)
|
|
108
108
|
end
|
|
109
109
|
|
|
110
110
|
def human(value)
|
data/templates/Gemfile.erb
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
class
|
|
2
|
-
|
|
3
|
-
# This is required for Devise to work.
|
|
4
|
-
# See: https://youtu.be/m3uhldUGVes?t=1432
|
|
5
|
-
#
|
|
6
|
-
# Having issues with devise/turbo.
|
|
7
|
-
# See: https://gorails.com/episodes/devise-hotwire-turbo
|
|
1
|
+
class TurboDeviseController < ApplicationController
|
|
8
2
|
class Responder < ActionController::Responder
|
|
9
3
|
def to_turbo_stream
|
|
10
4
|
controller.render(options.merge(formats: :html))
|
|
11
|
-
rescue ActionView::MissingTemplate =>
|
|
5
|
+
rescue ActionView::MissingTemplate => e
|
|
12
6
|
if get?
|
|
13
|
-
raise
|
|
7
|
+
raise e
|
|
14
8
|
elsif has_errors? && default_action
|
|
15
9
|
render rendering_options.merge(formats: :html, status: :unprocessable_entity)
|
|
16
10
|
else
|
|
@@ -21,4 +15,4 @@ class TurboController < ApplicationController
|
|
|
21
15
|
|
|
22
16
|
self.responder = Responder
|
|
23
17
|
respond_to :html, :turbo_stream
|
|
24
|
-
end
|
|
18
|
+
end
|