rails_app_generator 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.builders/generators/project-plan.rb +4 -3
- data/CHANGELOG.md +7 -0
- data/Rakefile +2 -0
- data/after_templates/addons/rails_html_sanitizer/index.html.erb +31 -0
- data/after_templates/addons/rails_html_sanitizer.rb +15 -0
- data/after_templates/rag_devise/application.html.erb +20 -0
- data/after_templates/rag_devise/application_controller.rb +10 -0
- data/after_templates/rag_devise/config/initializers/devise_turbo.rb +30 -0
- data/after_templates/rag_devise/layouts/_alerts.html.erb +3 -0
- data/after_templates/rag_devise/layouts/_footer.html.erb +3 -0
- data/after_templates/rag_devise/layouts/_navbar.html.erb +14 -0
- data/after_templates/rag_devise/layouts/application.html.erb +24 -0
- data/after_templates/rag_devise/post/_post.html.erb +14 -0
- data/after_templates/rag_devise/post/post.rb +3 -0
- data/after_templates/rag_devise/post/posts_controller.rb +72 -0
- data/after_templates/rag_devise/seed_data.rb +8 -0
- data/after_templates/rag_devise/turbo_controller.rb +24 -0
- data/after_templates/rag_devise/user.rb +8 -0
- data/after_templates/rag_devise.rb +45 -0
- data/after_templates/rag_printspeak/application_controller.rb +22 -0
- data/after_templates/rag_printspeak/faq.html.erb +189 -0
- data/after_templates/rag_printspeak/layouts/_footer.html.erb +72 -0
- data/after_templates/rag_printspeak/layouts/_head.html.erb +17 -0
- data/after_templates/rag_printspeak/layouts/_navbar.html.erb +30 -0
- data/after_templates/rag_printspeak/layouts/application.html.erb +22 -0
- data/after_templates/rag_printspeak/page/_footer.html.erb +184 -0
- data/after_templates/rag_printspeak/page/architecture.html.erb +33 -0
- data/after_templates/rag_printspeak/page/blog.html.erb +44 -0
- data/after_templates/rag_printspeak/page/faq.html.erb +2 -0
- data/after_templates/rag_printspeak/page/home.html.erb +32 -0
- data/after_templates/rag_printspeak/page/page_controller.rb +27 -0
- data/after_templates/rag_printspeak/page/readme.html.erb +49 -0
- data/after_templates/rag_printspeak.rb +36 -0
- data/docs/project-plan/project.drawio +37 -40
- data/docs/project-plan/project_in_progress.svg +1 -1
- data/docs/project-plan/project_todo.svg +1 -1
- data/exe/rag +1 -1
- data/lib/rails_app_generator/addons/annotate.rb +3 -3
- data/lib/rails_app_generator/addons/devise.rb +17 -7
- data/lib/rails_app_generator/addons/rails_html_sanitizer.rb +14 -0
- data/lib/rails_app_generator/addons/xmen.rb +17 -0
- data/lib/rails_app_generator/app_generator.rb +170 -0
- data/lib/rails_app_generator/diff/processor.rb +13 -0
- data/lib/rails_app_generator/options/rails_options.rb +4 -0
- data/lib/rails_app_generator/version.rb +1 -1
- data/package-lock.json +2 -2
- data/package.json +1 -1
- data/profiles/addons/rails-html-sanitizer.json +12 -0
- data/profiles/rag-devise.json +12 -0
- data/profiles/rag-printspeak.json +11 -0
- data/tasks/addon.thor +71 -0
- data/tasks/profile.thor +12 -0
- data/templates/thor_task/addon/addon.tt +21 -0
- metadata +40 -2
@@ -7,8 +7,154 @@ module RailsAppGenerator
|
|
7
7
|
class AppGenerator < Rails::Generators::AppGenerator
|
8
8
|
class_option :test , type: :string , default: 'rspec'
|
9
9
|
|
10
|
+
# acts_as_list 0.9.19 1.0.4 ~> 0.9 default
|
11
|
+
# arel 7.1.4 9.0.0
|
12
|
+
# bigdecimal 1.4.4 3.1.2 ~> 1.4 development, test
|
13
|
+
# binding_of_caller 0.8.0 1.0.0 ~> 0.8 default
|
14
|
+
# browser 2.7.1 5.3.1 ~> 2.3 default
|
15
|
+
# capistrano-bundler 1.6.0 2.1.0 ~> 1.2 development, test
|
16
|
+
# capybara 3.33.0 3.37.1 = 3.33.0 development, test
|
17
|
+
# chartkick 2.3.5 4.2.0 ~> 2.3 default
|
18
|
+
# childprocess 3.0.0 4.1.0
|
19
|
+
# clamby 1.6.6 1.6.8 = 1.6.6 default
|
20
|
+
# createsend 5.1.1 6.0.0 ~> 5.1 default
|
21
|
+
# database_cleaner 1.7.0 2.0.1 = 1.7.0 development, test
|
22
|
+
# factory_bot 5.2.0 6.2.1
|
23
|
+
# factory_bot_rails 5.2.0 6.2.0 = 5.2.0 development, test
|
24
|
+
# faker 1.9.6 2.22.0 ~> 1.7 default
|
25
|
+
# groupdate 4.3.0 6.1.0 ~> 4.1 default
|
26
|
+
# guard-bundler 2.2.1 3.0.0 = 2.2.1 development, test
|
27
|
+
# guard-rubocop 1.4.0 1.5.0 = 1.4.0 development, test
|
28
|
+
# hashie 3.6.0 5.0.0
|
29
|
+
# http-accept 1.7.0 2.1.1
|
30
|
+
# k_log 0.0.18 0.0.33 = 0.0.18 development, test
|
31
|
+
# net-ssh 6.1.0 7.0.1
|
32
|
+
# oauth2 1.4.10 2.0.6
|
33
|
+
# omniauth-oauth2 1.7.3 1.8.0
|
34
|
+
# paper_trail 10.3.1 12.3.0 ~> 10.3 default
|
35
|
+
# pg 0.21.0 1.4.2 ~> 0.20 default
|
36
|
+
# pg_search 2.3.0 2.3.6 ~> 2.0 default
|
37
|
+
# pry 0.13.1 0.14.1
|
38
|
+
# public_suffix 2.0.5 5.0.0 ~> 2.0 default
|
39
|
+
# pusher 1.4.3 2.0.2 ~> 1.3 default
|
40
|
+
# rack-mini-profiler 0.10.7 3.0.0 ~> 0.10 default
|
41
|
+
# rack-test 0.6.3 2.0.2
|
42
|
+
# rails 5.0.7.2 7.0.3.1 = 5.0.7.2 default
|
43
|
+
# railties 5.0.7.2 7.0.3.1
|
44
|
+
# ransack 1.8.10 3.2.1 ~> 1.8 default
|
45
|
+
# redis 3.3.5 4.7.1 ~> 3.3 default
|
46
|
+
# redis-store 1.6.0 1.9.1
|
47
|
+
# regexp_parser 1.8.2 2.5.0
|
48
|
+
# rspec 3.10.0 3.11.0
|
49
|
+
# rspec-core 3.10.1 3.11.0 = 3.10.1 development, test
|
50
|
+
# rspec-expectations 3.10.1 3.11.0 = 3.10.1 development, test
|
51
|
+
# rspec-mocks 3.10.2 3.11.1 = 3.10.2 development, test
|
52
|
+
# rspec-rails 4.1.2 5.1.2 = 4.1.2 development, test
|
53
|
+
# rspec-support 3.10.2 3.11.0 = 3.10.2 development, test
|
54
|
+
# rubyzip 1.3.0 2.3.2 ~> 1.3 default
|
55
|
+
# scenic 1.5.4 1.6.0 = 1.5.4 default
|
56
|
+
# scout_apm 4.1.2 5.2.0 ~> 4.1 default
|
57
|
+
# selenium-webdriver 3.142.7 4.3.0 = 3.142.7 development, test
|
58
|
+
# shoulda-matchers 4.0.1 5.1.0 = 4.0.1 development, test
|
59
|
+
# sidekiq 4.2.10 6.5.1 ~> 4.2 default
|
60
|
+
# sidekiq-pool 1.9.3 2.0.1 ~> 1.8 default
|
61
|
+
# sidekiq-unique-jobs 6.0.25 7.1.27 ~> 6.0 default
|
62
|
+
# spring 2.1.1 4.0.0 ~> 2.0 development, test
|
63
|
+
# sprockets 3.7.2 4.1.1 ~> 3.7 default
|
64
|
+
# sprockets-rails 3.2.2 3.4.2
|
65
|
+
# timecop 0.8.1 0.9.5 = 0.8.1 development, test
|
66
|
+
# tzinfo 1.2.10 2.0.5
|
67
|
+
# uglifier 3.2.0 4.2.0 ~> 3.2 default
|
68
|
+
# unicorn 5.8.0 6.1.0 ~> 5.3 default
|
69
|
+
# webmock 3.13.0 3.14.0 = 3.13.0 development, test
|
70
|
+
# websocket-driver 0.6.5 0.7.5
|
71
|
+
|
72
|
+
# gem "rails-html-sanitizer", "1.3.0"
|
73
|
+
# gem "unicorn", "5.3.0"
|
74
|
+
# gem "honeybadger", "4.6.0"
|
75
|
+
# gem "pg", "0.20.0"
|
76
|
+
# gem "redis", "3.3.3"
|
77
|
+
# gem "redis-namespace", "1.5.3"
|
78
|
+
# gem "redis-rails", "5.0.2"
|
79
|
+
# gem "devise", "4.7.1"
|
80
|
+
# gem "twilio-ruby", "5.23.0"
|
81
|
+
# gem "google-api-client", "0.9"
|
82
|
+
# gem "sinatra", "1.4.8", require: nil # used for the /sidekiq admin screen
|
83
|
+
# gem "sidekiq", "4.2.10"
|
84
|
+
# gem "sidekiq-unique-jobs", "6.0.25"
|
85
|
+
# gem "sidekiq-pool", "1.8.1"
|
86
|
+
# gem "faker", "1.7.3"
|
87
|
+
# gem "clearbit", "0.2.8"
|
88
|
+
# gem "groupdate", "4.1.2"
|
89
|
+
# gem "acts_as_commentable", "4.0.2"
|
90
|
+
# gem "acts_as_list", "0.9.5"
|
91
|
+
# gem "kaminari", "1.2.1"
|
92
|
+
# gem "chartkick", "4.1.2"
|
93
|
+
# gem "jbuilder", "2.6.3"
|
94
|
+
# gem "rest-client", "2.0.1"
|
95
|
+
# gem "json", "2.3.0"
|
96
|
+
# gem "httparty", "0.14.0"
|
97
|
+
# gem "mini_magick", "4.9.4"
|
98
|
+
# gem "skeptick", "0.2.1"
|
99
|
+
# gem "aws-sdk", "3.0.2"
|
100
|
+
# gem "phony_rails", "0.14.11"
|
101
|
+
# gem "pg_search", "2.0.1"
|
102
|
+
# gem "omniauth", "1.8.1", group: %i[development staging production worker]
|
103
|
+
# gem "omniauth-google-oauth2", "0.3.0"
|
104
|
+
# gem "redcarpet", "3.5.1"
|
105
|
+
# gem "binding_of_caller", "0.8.0"
|
106
|
+
# gem "bcrypt-ruby", "3.1.5"
|
107
|
+
# gem "rb-readline", "0.5.5"
|
108
|
+
# gem "has_secure_token", "1.0.0"
|
109
|
+
# gem "stackprof", "0.2.10"
|
110
|
+
# gem "createsend", "5.1.0"
|
111
|
+
# gem "rubyzip", "1.3.0"
|
112
|
+
# gem "chronic", "0.10.2"
|
113
|
+
# gem "unread", "0.9.0"
|
114
|
+
# gem "browser", "2.3.0"
|
115
|
+
# gem "public_suffix", "2.0.5"
|
116
|
+
# gem "sassc-rails", "2.1.0"
|
117
|
+
# gem "bootstrap-sass", "3.4.1"
|
118
|
+
# gem "sprockets", "3.7.2"
|
119
|
+
# gem "uglifier", "3.2.0"
|
120
|
+
# gem "jquery-rails", "4.1.1"
|
121
|
+
# gem "remotipart", "1.3.1"
|
122
|
+
# gem "rack-mini-profiler", "0.10.2", require: false
|
123
|
+
# gem "flamegraph", "0.9.5"
|
124
|
+
# gem "activerecord-import", "0.18.1"
|
125
|
+
# gem "parallel", "1.11.1"
|
126
|
+
# gem "ruby-progressbar", "1.8.1"
|
127
|
+
# gem "css_parser", "1.5.0"
|
128
|
+
# gem "guess", "0.1.1"
|
129
|
+
# gem "fastimage", "2.1.0"
|
130
|
+
# gem "thread", "0.2.2"
|
131
|
+
# gem "parse-cron", "0.1.4"
|
132
|
+
# gem "thread-parent", "1.0.4"
|
133
|
+
# gem "hexapdf", "0.5.0"
|
134
|
+
# gem "geocoder", "1.6.1"
|
135
|
+
# gem "sd_notify", "0.1.1"
|
136
|
+
# gem "attr_encrypted", "3.1.0"
|
137
|
+
# gem "clamby", "1.6.6"
|
138
|
+
# gem "scout_apm", "5.1.0"
|
139
|
+
# gem "pusher", "1.3.0"
|
140
|
+
# gem "phony", "2.18.18"
|
141
|
+
# gem "recaptcha", "5.7.0"
|
142
|
+
# gem "ransack", "1.8.10"
|
143
|
+
# gem "configatron", "4.5.1"
|
144
|
+
# gem "fuzzy-string-match", "1.0.1"
|
145
|
+
# gem "jwt", "1.5.6"
|
146
|
+
# gem "htmlentities", "4.3.4"
|
147
|
+
# gem "scenic", "1.5.4"
|
148
|
+
# gem "rack-cors", "1.0.6"
|
149
|
+
# gem "rails_same_site_cookie", "0.1.8"
|
150
|
+
# gem "paper_trail", "10.3.0"
|
151
|
+
# gem "net-sftp", "3.0.0"
|
152
|
+
# gem "prawn", "2.4.0"
|
153
|
+
# gem "prawn-table", "0.2.2"
|
154
|
+
|
10
155
|
class_option :add_irbrc , type: :boolean, default: false
|
11
156
|
class_option :add_foreman , type: :boolean, default: false
|
157
|
+
class_option :add_devise , type: :boolean, default: false
|
12
158
|
class_option :add_dotenv , type: :boolean, default: false
|
13
159
|
class_option :add_docker , type: :boolean, default: false
|
14
160
|
class_option :add_docker_compose , type: :boolean, default: false
|
@@ -27,6 +173,9 @@ module RailsAppGenerator
|
|
27
173
|
class_option :add_factory_bot , type: :boolean, default: false
|
28
174
|
class_option :add_shoulda , type: :boolean, default: false
|
29
175
|
|
176
|
+
# NEW GEM ADDONS
|
177
|
+
class_option :add_rails_html_sanitizer , type: :boolean, default: false
|
178
|
+
|
30
179
|
class << self
|
31
180
|
# points to the original rails templates
|
32
181
|
attr_writer :rails_template_path
|
@@ -157,6 +306,7 @@ module RailsAppGenerator
|
|
157
306
|
puts 'finish template'
|
158
307
|
|
159
308
|
add_if(:annotate)
|
309
|
+
add_if(:devise)
|
160
310
|
add_if(:continuous_integration)
|
161
311
|
add_if(:high_voltage)
|
162
312
|
add_if(:generators)
|
@@ -175,21 +325,30 @@ module RailsAppGenerator
|
|
175
325
|
no_commands do
|
176
326
|
# Template command examples
|
177
327
|
# gac 'base rails 7 image created'
|
328
|
+
# force_copy
|
178
329
|
# add_controller('home', 'index')
|
179
330
|
# add_scaffold('people', 'first_name', 'last_name', 'age:integer', 'address:text')
|
180
331
|
# route("root 'home#index'")
|
181
332
|
# css_install('tailwind')
|
182
333
|
# rails_command('db:migrate')
|
334
|
+
# db_migrate
|
183
335
|
# bundle_add('hotwire-rails')
|
184
336
|
# rails_command('hotwire:install')
|
185
337
|
# run('bin/importmap pin sortablejs')
|
186
338
|
# run('npm install daisyui')
|
187
339
|
# create_file 'app/assets/stylesheets/custom-bootstrap-import.scss' , read_template('custom-bootstrap-import.scss')
|
188
340
|
# append_to_file 'app/assets/config/manifest.js' , read_template('manifest.js')
|
341
|
+
# insert_into_file 'app/views/layouts/application.html.erb', read_template('application.html.erb')
|
189
342
|
# insert_into_file 'app/views/layouts/application.html.erb', read_template('application.html.erb'),
|
343
|
+
# before: %( <%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>)
|
344
|
+
|
190
345
|
# gsub_file 'app/views/layouts/application.html.erb', %(container mx-auto mt-28 px-5 flex), 'container mx-auto px-5'
|
191
346
|
# template 'home.css', 'app/assets/stylesheets/home.css'
|
192
347
|
|
348
|
+
def local_template_base(xxx)
|
349
|
+
File.join(File.dirname(xxx), File.basename(xxx, '.*'))
|
350
|
+
end
|
351
|
+
|
193
352
|
# force_copy? # defaults to false
|
194
353
|
# force_copy(true) # set to true
|
195
354
|
# force_copy(false) # set to false
|
@@ -226,6 +385,10 @@ module RailsAppGenerator
|
|
226
385
|
rails_command('db:migrate')
|
227
386
|
end
|
228
387
|
|
388
|
+
def db_seed
|
389
|
+
rails_command('db:seed')
|
390
|
+
end
|
391
|
+
|
229
392
|
def add_stimulus(name, *args)
|
230
393
|
generate(:stimulus, name, *args)
|
231
394
|
end
|
@@ -256,6 +419,13 @@ module RailsAppGenerator
|
|
256
419
|
super(source, destination, **args)
|
257
420
|
end
|
258
421
|
|
422
|
+
def template(source, *args, &block)
|
423
|
+
config = args.last.is_a?(Hash) ? args.pop : {}
|
424
|
+
config[:force] = true if force_copy?
|
425
|
+
args << config
|
426
|
+
super(source, *args, &block)
|
427
|
+
end
|
428
|
+
|
259
429
|
def read_template(template_file)
|
260
430
|
path = find_in_source_paths(template_file)
|
261
431
|
|
@@ -7,6 +7,19 @@ module RailsAppGenerator
|
|
7
7
|
attr_reader :lhs_path
|
8
8
|
attr_reader :rhs_path
|
9
9
|
|
10
|
+
# Consider the Thor Diff Method below
|
11
|
+
# see: gems/thor-1.2.1/lib/thor/shell/basic.rb
|
12
|
+
|
13
|
+
# def show_diff(destination, content) #:nodoc:
|
14
|
+
# diff_cmd = ENV["THOR_DIFF"] || ENV["RAILS_DIFF"] || "diff -u"
|
15
|
+
# require "tempfile"
|
16
|
+
# Tempfile.open(File.basename(destination), File.dirname(destination)) do |temp|
|
17
|
+
# temp.write content
|
18
|
+
# temp.rewind
|
19
|
+
# system %(#{diff_cmd} "#{destination}" "#{temp.path}")
|
20
|
+
# end
|
21
|
+
# end
|
22
|
+
|
10
23
|
DEFAULT_EXCLUSION = lambda do |_file, relative_file|
|
11
24
|
relative_file.start_with?('tmp') ||
|
12
25
|
relative_file.start_with?('node_modules') ||
|
@@ -39,6 +39,7 @@ module RailsAppGenerator
|
|
39
39
|
|
40
40
|
register_option :add_irbrc , type: :boolean, default: false
|
41
41
|
register_option :add_foreman , type: :boolean, default: false
|
42
|
+
register_option :add_devise , type: :boolean, default: false
|
42
43
|
register_option :add_dotenv , type: :boolean, default: false
|
43
44
|
register_option :add_docker , type: :boolean, default: false
|
44
45
|
register_option :add_docker_compose , type: :boolean, default: false
|
@@ -57,6 +58,9 @@ module RailsAppGenerator
|
|
57
58
|
register_option :add_factory_bot , type: :boolean, default: false
|
58
59
|
register_option :add_shoulda , type: :boolean, default: false
|
59
60
|
|
61
|
+
# NEW GEM ADDONS
|
62
|
+
register_option :add_rails_html_sanitizer , type: :boolean, default: false
|
63
|
+
|
60
64
|
# if options[:minimal]
|
61
65
|
# self.options = options.merge(
|
62
66
|
# skip_action_cable: true,
|
data/package-lock.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "rails_app_generator",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.9",
|
4
4
|
"lockfileVersion": 2,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "rails_app_generator",
|
9
|
-
"version": "0.1.
|
9
|
+
"version": "0.1.9",
|
10
10
|
"dependencies": {
|
11
11
|
"daisyui": "^2.20.0"
|
12
12
|
},
|
data/package.json
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
{
|
2
|
+
"args": {
|
3
|
+
"app_path": "rails-html-sanitizer",
|
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/rails_html_sanitizer.rb",
|
10
|
+
"add_rails_html_sanitizer": true
|
11
|
+
}
|
12
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
{
|
2
|
+
"args": {
|
3
|
+
"app_path": "devise",
|
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_devise.rb",
|
10
|
+
"add_devise": true
|
11
|
+
}
|
12
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
{
|
2
|
+
"args": {
|
3
|
+
"app_path": "p7",
|
4
|
+
"destination_root": "/Users/davidcruwys/dev/printspeak"
|
5
|
+
},
|
6
|
+
"opts": {
|
7
|
+
"skip_test": true,
|
8
|
+
"template": "/Users/davidcruwys/dev/kgems/rails_app_generator/after_templates/rag_printspeak.rb",
|
9
|
+
"javascript": "esbuild"
|
10
|
+
}
|
11
|
+
}
|
data/tasks/addon.thor
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# https://codecrate.com/2014/01/replace-rake-with-thor.html
|
4
|
+
|
5
|
+
require 'pry'
|
6
|
+
require 'net/http'
|
7
|
+
require 'json'
|
8
|
+
|
9
|
+
# Thor task to create a new AddOn for Rails App Generator
|
10
|
+
class AddOn < Thor
|
11
|
+
include Thor::Actions
|
12
|
+
|
13
|
+
source_root(File.expand_path('../templates/thor_task', File.dirname(__FILE__)))
|
14
|
+
|
15
|
+
GemInfo = Struct.new(:name, :version, :description, keyword_init: true)
|
16
|
+
|
17
|
+
attr_accessor :name
|
18
|
+
attr_accessor :addon_config_code
|
19
|
+
|
20
|
+
# method_option :from, :required => true
|
21
|
+
desc 'new', 'Create a new Addon for Rails App Generator'
|
22
|
+
method_option :gem , type: :string, default: nil, desc: 'Add required_gem helper to the AddOn. Gem name is looked up to find version and description'
|
23
|
+
method_option :force, type: :boolean, default: false, desc: 'Overwrite existing files'
|
24
|
+
method_option :depends_on, type: :string, desc: 'This AddOn depends on another AddOn/Gem. active_record is a common dependency'
|
25
|
+
def new(name)
|
26
|
+
self.name = name
|
27
|
+
|
28
|
+
code = [build_depends_on_code, build_required_gem_code].compact
|
29
|
+
code << '' if code.any?
|
30
|
+
self.addon_config_code = code.join("\n")
|
31
|
+
|
32
|
+
template('addon/addon', "lib/rails_app_generator/addons/#{name}.rb", force: options[:force])
|
33
|
+
end
|
34
|
+
|
35
|
+
no_commands do
|
36
|
+
def build_depends_on_code
|
37
|
+
return nil unless options[:depends_on]
|
38
|
+
|
39
|
+
" depends_on :#{options[:depends_on]}"
|
40
|
+
end
|
41
|
+
|
42
|
+
def build_required_gem_code
|
43
|
+
return nil unless options[:gem]
|
44
|
+
|
45
|
+
gem_name = options[:gem] == 'gem' ? name : options[:gem]
|
46
|
+
|
47
|
+
info = gem_info(gem_name)
|
48
|
+
|
49
|
+
" required_gem gem.version('#{info.name}', '#{info.version}', '#{info.description}')"
|
50
|
+
end
|
51
|
+
|
52
|
+
# example: 'https://rubygems.org/api/v1/gems/draper.json'
|
53
|
+
def gem_info(name)
|
54
|
+
link = "https://rubygems.org/api/v1/gems/#{name.downcase}.json"
|
55
|
+
info = Net::HTTP.get(URI.parse(link))
|
56
|
+
json = JSON.parse(info)
|
57
|
+
|
58
|
+
GemInfo.new(
|
59
|
+
name: json['name'],
|
60
|
+
version: json['version'],
|
61
|
+
description: json['info']
|
62
|
+
)
|
63
|
+
rescue SocketError
|
64
|
+
abort 'Internet connection cannot be established to RubyGems.org'
|
65
|
+
rescue JSON::ParserError
|
66
|
+
abort "Check you have entered the right Gem name\n#{link}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
# /Users/davidcruwys/dev/kgems/rails_app_generator/templates/thor/addon
|
71
|
+
# /Users/davidcruwys/dev/kgems/rails_app_generator/lib/templates/thor
|
data/tasks/profile.thor
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# https://codecrate.com/2014/01/replace-rake-with-thor.html
|
4
|
+
|
5
|
+
# Thor task to create a new Profile for Rails App Generator
|
6
|
+
class Profile < Thor
|
7
|
+
desc 'new', 'Create a new Profile for testing Rails App Generator settings'
|
8
|
+
def new(name)
|
9
|
+
# do something here
|
10
|
+
puts "new #{name}"
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
5
|
+
module AddOns
|
6
|
+
# Add <%= Thor::Util.camel_case(name) %> to rails application
|
7
|
+
class <%= Thor::Util.camel_case(name) %> < AddOn
|
8
|
+
<%= addon_config_code %>
|
9
|
+
def apply
|
10
|
+
# say 'Setting up <%= Thor::Util.camel_case(name)%>'
|
11
|
+
# template('<%= Thor::Util.snake_case(name)%>_template.rb', 'target/<%= Thor::Util.snake_case(name)%>.rb', force: true)
|
12
|
+
# template('app/javascript/stylesheets/components.scss')
|
13
|
+
# create_file('target/<%= Thor::Util.snake_case(name)%>.rb', 'put your content here')
|
14
|
+
# directory 'app/template', 'app/target', force: true
|
15
|
+
# empty_directory 'app/target'
|
16
|
+
# inject_into_file('app/application.js', "some content")
|
17
|
+
# rails_command('tailwindcss:install')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_app_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cruwys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bootsnap
|
@@ -146,6 +146,8 @@ files:
|
|
146
146
|
- README.md
|
147
147
|
- Rakefile
|
148
148
|
- after_templates/README.md
|
149
|
+
- after_templates/addons/rails_html_sanitizer.rb
|
150
|
+
- after_templates/addons/rails_html_sanitizer/index.html.erb
|
149
151
|
- after_templates/rag_bootstrap.rb
|
150
152
|
- after_templates/rag_bootstrap/application-yield.html.erb
|
151
153
|
- after_templates/rag_bootstrap/application.html.erb
|
@@ -162,10 +164,38 @@ files:
|
|
162
164
|
- after_templates/rag_bootstrap/custom-using-css.css
|
163
165
|
- after_templates/rag_bootstrap/custom-using-scss.scss
|
164
166
|
- after_templates/rag_bootstrap/manifest.js
|
167
|
+
- after_templates/rag_devise.rb
|
168
|
+
- after_templates/rag_devise/application.html.erb
|
169
|
+
- after_templates/rag_devise/application_controller.rb
|
170
|
+
- after_templates/rag_devise/config/initializers/devise_turbo.rb
|
171
|
+
- after_templates/rag_devise/layouts/_alerts.html.erb
|
172
|
+
- after_templates/rag_devise/layouts/_footer.html.erb
|
173
|
+
- after_templates/rag_devise/layouts/_navbar.html.erb
|
174
|
+
- after_templates/rag_devise/layouts/application.html.erb
|
175
|
+
- after_templates/rag_devise/post/_post.html.erb
|
176
|
+
- after_templates/rag_devise/post/post.rb
|
177
|
+
- after_templates/rag_devise/post/posts_controller.rb
|
178
|
+
- after_templates/rag_devise/seed_data.rb
|
179
|
+
- after_templates/rag_devise/turbo_controller.rb
|
180
|
+
- after_templates/rag_devise/user.rb
|
165
181
|
- after_templates/rag_import_map.rb
|
166
182
|
- after_templates/rag_import_map/component-sortable.html
|
167
183
|
- after_templates/rag_import_map/home.css
|
168
184
|
- after_templates/rag_import_map/position_controller.js
|
185
|
+
- after_templates/rag_printspeak.rb
|
186
|
+
- after_templates/rag_printspeak/application_controller.rb
|
187
|
+
- after_templates/rag_printspeak/faq.html.erb
|
188
|
+
- after_templates/rag_printspeak/layouts/_footer.html.erb
|
189
|
+
- after_templates/rag_printspeak/layouts/_head.html.erb
|
190
|
+
- after_templates/rag_printspeak/layouts/_navbar.html.erb
|
191
|
+
- after_templates/rag_printspeak/layouts/application.html.erb
|
192
|
+
- after_templates/rag_printspeak/page/_footer.html.erb
|
193
|
+
- after_templates/rag_printspeak/page/architecture.html.erb
|
194
|
+
- after_templates/rag_printspeak/page/blog.html.erb
|
195
|
+
- after_templates/rag_printspeak/page/faq.html.erb
|
196
|
+
- after_templates/rag_printspeak/page/home.html.erb
|
197
|
+
- after_templates/rag_printspeak/page/page_controller.rb
|
198
|
+
- after_templates/rag_printspeak/page/readme.html.erb
|
169
199
|
- after_templates/rag_simple.rb
|
170
200
|
- after_templates/rag_tailwind.rb
|
171
201
|
- after_templates/rag_tailwind/component-cta.html
|
@@ -263,6 +293,7 @@ files:
|
|
263
293
|
- lib/rails_app_generator/addons/irbrc.rb
|
264
294
|
- lib/rails_app_generator/addons/lograge.rb
|
265
295
|
- lib/rails_app_generator/addons/pundit.rb
|
296
|
+
- lib/rails_app_generator/addons/rails_html_sanitizer.rb
|
266
297
|
- lib/rails_app_generator/addons/rspec.rb
|
267
298
|
- lib/rails_app_generator/addons/rubocop.rb
|
268
299
|
- lib/rails_app_generator/addons/scaffold.rb
|
@@ -272,6 +303,7 @@ files:
|
|
272
303
|
- lib/rails_app_generator/addons/stimulus_components.rb
|
273
304
|
- lib/rails_app_generator/addons/tailwind.rb
|
274
305
|
- lib/rails_app_generator/addons/views.rb
|
306
|
+
- lib/rails_app_generator/addons/xmen.rb
|
275
307
|
- lib/rails_app_generator/app_builder.rb
|
276
308
|
- lib/rails_app_generator/app_generator.rb
|
277
309
|
- lib/rails_app_generator/cli/diff.rb
|
@@ -306,9 +338,12 @@ files:
|
|
306
338
|
- lib/rails_app_generator/version.rb
|
307
339
|
- package-lock.json
|
308
340
|
- package.json
|
341
|
+
- profiles/addons/rails-html-sanitizer.json
|
309
342
|
- profiles/rag-add-some-pages.json
|
310
343
|
- profiles/rag-bootstrap.json
|
344
|
+
- profiles/rag-devise.json
|
311
345
|
- profiles/rag-import-map.json
|
346
|
+
- profiles/rag-printspeak.json
|
312
347
|
- profiles/rag-sample.json
|
313
348
|
- profiles/rag-simple.json
|
314
349
|
- profiles/rag-tailwind-daisyui.json
|
@@ -319,6 +354,8 @@ files:
|
|
319
354
|
- profiles/rag-tailwind-hotwire.json
|
320
355
|
- profiles/rag-tailwind.json
|
321
356
|
- sig/rails_app_generator.rbs
|
357
|
+
- tasks/addon.thor
|
358
|
+
- tasks/profile.thor
|
322
359
|
- templates/Gemfile-original-r7
|
323
360
|
- templates/Gemfile-original-schienenzeppelin.erb
|
324
361
|
- templates/Gemfile.erb
|
@@ -374,6 +411,7 @@ files:
|
|
374
411
|
- templates/app_x/views/shared/_footer.html.erb.tt
|
375
412
|
- templates/app_x/views/shared/_navbar.html.erb.tt
|
376
413
|
- templates/app_x/workers/application_worker.rb
|
414
|
+
- templates/thor_task/addon/addon.tt
|
377
415
|
homepage: http://appydave.com/gems/rails_app_generator
|
378
416
|
licenses:
|
379
417
|
- MIT
|