rails_app_generator 0.1.11 → 0.1.14
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 +22 -0
- data/after_templates/addons/honeybadger/_.rb +46 -0
- data/after_templates/addons/honeybadger/app/controllers/application_controller.rb +9 -0
- data/after_templates/addons/honeybadger/app/controllers/errors_controller.rb +17 -0
- data/after_templates/addons/honeybadger/app/controllers/products_controller.rb +72 -0
- data/after_templates/addons/honeybadger/app/views/home/index.html.erb +49 -0
- data/after_templates/addons/honeybadger/public/404.html +69 -0
- data/after_templates/addons/honeybadger/public/500.html +68 -0
- data/after_templates/addons/rails_html_sanitizer/home/index.html.erb +30 -2
- data/after_templates/addons/twilio_ruby/_.rb +23 -0
- data/after_templates/addons/twilio_ruby/app/controllers/home_controller.rb +54 -0
- data/after_templates/addons/twilio_ruby/app/views/home/index.html.erb +27 -0
- data/after_templates/addons/twilio_ruby/config/initializers/twilio.rb +4 -0
- data/lib/rails_app_generator/add_on.rb +36 -0
- data/lib/rails_app_generator/addons/honeybadger.rb +19 -0
- data/lib/rails_app_generator/app_generator.rb +134 -116
- data/lib/rails_app_generator/options/rails_options.rb +3 -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 → honeybadger.json} +3 -3
- data/profiles/addons/twilio_ruby.json +12 -0
- data/tasks/addon.thor +45 -8
- data/tasks/profile.thor +26 -20
- data/templates/addons/honeybadger/en.yml +10 -0
- data/templates/addons/honeybadger/honeybadger.sample.yml +37 -0
- data/templates/thor_task/addon/addon.tt +13 -6
- data/templates/thor_task/profile/after_template.rb.tt +30 -1
- data/templates/thor_task/profile/home/index.html.erb.tt +10 -0
- metadata +18 -3
@@ -7,6 +7,77 @@ module RailsAppGenerator
|
|
7
7
|
class AppGenerator < Rails::Generators::AppGenerator
|
8
8
|
class_option :test , type: :string , default: 'rspec'
|
9
9
|
|
10
|
+
# Gem Current Latest Requested Groups
|
11
|
+
# acts_as_list 0.9.19 1.0.4 ~> 0.9 default
|
12
|
+
# arel 7.1.4 9.0.0
|
13
|
+
# aws-partitions 1.613.0 1.614.0
|
14
|
+
# aws-sdk-cognitoidentityprovider 1.67.0 1.68.0
|
15
|
+
# aws-sdk-core 3.131.5 3.131.6
|
16
|
+
# aws-sdk-personalize 1.42.0 1.43.0
|
17
|
+
# aws-sdk-resources 3.136.0 3.137.0
|
18
|
+
# aws-sdk-wafv2 1.40.0 1.41.0
|
19
|
+
# bigdecimal 1.4.4 3.1.2 ~> 1.4 development, test
|
20
|
+
# binding_of_caller 0.8.0 1.0.0 ~> 0.8 default
|
21
|
+
# browser 2.7.1 5.3.1 ~> 2.3 default
|
22
|
+
# capistrano-bundler 1.6.0 2.1.0 ~> 1.2 development, test
|
23
|
+
# capybara 3.33.0 3.37.1 = 3.33.0 development, test
|
24
|
+
# chartkick 2.3.5 4.2.1 ~> 2.3 default
|
25
|
+
# childprocess 3.0.0 4.1.0
|
26
|
+
# clamby 1.6.6 1.6.8 = 1.6.6 default
|
27
|
+
# createsend 5.1.1 6.0.0 ~> 5.1 default
|
28
|
+
# database_cleaner 1.7.0 2.0.1 = 1.7.0 development, test
|
29
|
+
# erubi 1.10.0 1.11.0
|
30
|
+
# factory_bot 5.2.0 6.2.1
|
31
|
+
# factory_bot_rails 5.2.0 6.2.0 = 5.2.0 development, test
|
32
|
+
# faker 1.9.6 2.22.0 ~> 1.7 default
|
33
|
+
# groupdate 4.3.0 6.1.0 ~> 4.1 default
|
34
|
+
# guard-bundler 2.2.1 3.0.0 = 2.2.1 development, test
|
35
|
+
# guard-rubocop 1.4.0 1.5.0 = 1.4.0 development, test
|
36
|
+
# hashie 3.6.0 5.0.0
|
37
|
+
# hexapdf 0.23.0 0.24.0 ~> 0.5 default
|
38
|
+
# http-accept 1.7.0 2.2.0
|
39
|
+
# k_log 0.0.18 0.0.33 = 0.0.18 development, test
|
40
|
+
# net-ssh 6.1.0 7.0.1
|
41
|
+
# oauth2 1.4.10 2.0.6
|
42
|
+
# omniauth-oauth2 1.7.3 1.8.0
|
43
|
+
# paper_trail 10.3.1 12.3.0 ~> 10.3 default
|
44
|
+
# pg 0.21.0 1.4.2 ~> 0.20 default
|
45
|
+
# pg_search 2.3.0 2.3.6 ~> 2.0 default
|
46
|
+
# pry 0.13.1 0.14.1
|
47
|
+
# public_suffix 2.0.5 5.0.0 ~> 2.0 default
|
48
|
+
# pusher 1.4.3 2.0.2 ~> 1.3 default
|
49
|
+
# rack-mini-profiler 0.10.7 3.0.0 ~> 0.10 default
|
50
|
+
# rack-test 0.6.3 2.0.2
|
51
|
+
# rails 5.0.7.2 7.0.3.1 = 5.0.7.2 default
|
52
|
+
# railties 5.0.7.2 7.0.3.1
|
53
|
+
# ransack 1.8.10 3.2.1 ~> 1.8 default
|
54
|
+
# redis 3.3.5 4.7.1 ~> 3.3 default
|
55
|
+
# redis-store 1.6.0 1.9.1
|
56
|
+
# regexp_parser 1.8.2 2.5.0
|
57
|
+
# rspec 3.10.0 3.11.0
|
58
|
+
# rspec-core 3.10.1 3.11.0 = 3.10.1 development, test
|
59
|
+
# rspec-expectations 3.10.1 3.11.0 = 3.10.1 development, test
|
60
|
+
# rspec-mocks 3.10.2 3.11.1 = 3.10.2 development, test
|
61
|
+
# rspec-rails 4.1.2 5.1.2 = 4.1.2 development, test
|
62
|
+
# rspec-support 3.10.2 3.11.0 = 3.10.2 development, test
|
63
|
+
# rubyzip 1.3.0 2.3.2 ~> 1.3 default
|
64
|
+
# scenic 1.5.4 1.6.0 = 1.5.4 default
|
65
|
+
# scout_apm 4.1.2 5.2.0 ~> 4.1 default
|
66
|
+
# selenium-webdriver 3.142.7 4.3.0 = 3.142.7 development, test
|
67
|
+
# shoulda-matchers 4.0.1 5.1.0 = 4.0.1 development, test
|
68
|
+
# sidekiq 4.2.10 6.5.1 ~> 4.2 default
|
69
|
+
# sidekiq-pool 1.9.3 2.0.1 ~> 1.8 default
|
70
|
+
# sidekiq-unique-jobs 6.0.25 7.1.27 ~> 6.0 default
|
71
|
+
# spring 2.1.1 4.0.0 ~> 2.0 development, test
|
72
|
+
# sprockets 3.7.2 4.1.1 ~> 3.7 default
|
73
|
+
# sprockets-rails 3.2.2 3.4.2
|
74
|
+
# timecop 0.8.1 0.9.5 = 0.8.1 development, test
|
75
|
+
# tzinfo 1.2.10 2.0.5
|
76
|
+
# uglifier 3.2.0 4.2.0 ~> 3.2 default
|
77
|
+
# unicorn 5.8.0 6.1.0 ~> 5.3 default
|
78
|
+
# webmock 3.13.0 3.16.0 = 3.13.0 development, test
|
79
|
+
# websocket-driver 0.6.5 0.7.5
|
80
|
+
|
10
81
|
# acts_as_list 0.9.19 1.0.4 ~> 0.9 default
|
11
82
|
# arel 7.1.4 9.0.0
|
12
83
|
# bigdecimal 1.4.4 3.1.2 ~> 1.4 development, test
|
@@ -69,87 +140,6 @@ module RailsAppGenerator
|
|
69
140
|
# webmock 3.13.0 3.14.0 = 3.13.0 development, test
|
70
141
|
# websocket-driver 0.6.5 0.7.5
|
71
142
|
|
72
|
-
# gem "honeybadger", "4.6.0"
|
73
|
-
# gem "pg", "0.20.0"
|
74
|
-
# gem "redis", "3.3.3"
|
75
|
-
# gem "redis-namespace", "1.5.3"
|
76
|
-
# gem "redis-rails", "5.0.2"
|
77
|
-
# gem "devise", "4.7.1"
|
78
|
-
# gem "twilio-ruby", "5.23.0"
|
79
|
-
# gem "google-api-client", "0.9"
|
80
|
-
# gem "sinatra", "1.4.8", require: nil # used for the /sidekiq admin screen
|
81
|
-
# gem "sidekiq", "4.2.10"
|
82
|
-
# gem "sidekiq-unique-jobs", "6.0.25"
|
83
|
-
# gem "sidekiq-pool", "1.8.1"
|
84
|
-
# gem "faker", "1.7.3"
|
85
|
-
# gem "clearbit", "0.2.8"
|
86
|
-
# gem "groupdate", "4.1.2"
|
87
|
-
# gem "acts_as_commentable", "4.0.2"
|
88
|
-
# gem "acts_as_list", "0.9.5"
|
89
|
-
# gem "kaminari", "1.2.1"
|
90
|
-
# gem "chartkick", "4.1.2"
|
91
|
-
# gem "jbuilder", "2.6.3"
|
92
|
-
# gem "rest-client", "2.0.1"
|
93
|
-
# gem "json", "2.3.0"
|
94
|
-
# gem "httparty", "0.14.0"
|
95
|
-
# gem "mini_magick", "4.9.4"
|
96
|
-
# gem "skeptick", "0.2.1"
|
97
|
-
# gem "aws-sdk", "3.0.2"
|
98
|
-
# gem "phony_rails", "0.14.11"
|
99
|
-
# gem "pg_search", "2.0.1"
|
100
|
-
# gem "omniauth", "1.8.1", group: %i[development staging production worker]
|
101
|
-
# gem "omniauth-google-oauth2", "0.3.0"
|
102
|
-
# gem "redcarpet", "3.5.1"
|
103
|
-
# gem "binding_of_caller", "0.8.0"
|
104
|
-
# gem "bcrypt-ruby", "3.1.5"
|
105
|
-
# gem "rb-readline", "0.5.5"
|
106
|
-
# gem "has_secure_token", "1.0.0"
|
107
|
-
# gem "stackprof", "0.2.10"
|
108
|
-
# gem "createsend", "5.1.0"
|
109
|
-
# gem "rubyzip", "1.3.0"
|
110
|
-
# gem "chronic", "0.10.2"
|
111
|
-
# gem "unread", "0.9.0"
|
112
|
-
# gem "browser", "2.3.0"
|
113
|
-
# gem "public_suffix", "2.0.5"
|
114
|
-
# gem "sassc-rails", "2.1.0"
|
115
|
-
# gem "bootstrap-sass", "3.4.1"
|
116
|
-
# gem "sprockets", "3.7.2"
|
117
|
-
# gem "uglifier", "3.2.0"
|
118
|
-
# gem "jquery-rails", "4.1.1"
|
119
|
-
# gem "remotipart", "1.3.1"
|
120
|
-
# gem "rack-mini-profiler", "0.10.2", require: false
|
121
|
-
# gem "flamegraph", "0.9.5"
|
122
|
-
# gem "activerecord-import", "0.18.1"
|
123
|
-
# gem "parallel", "1.11.1"
|
124
|
-
# gem "ruby-progressbar", "1.8.1"
|
125
|
-
# gem "css_parser", "1.5.0"
|
126
|
-
# gem "guess", "0.1.1"
|
127
|
-
# gem "fastimage", "2.1.0"
|
128
|
-
# gem "thread", "0.2.2"
|
129
|
-
# gem "parse-cron", "0.1.4"
|
130
|
-
# gem "thread-parent", "1.0.4"
|
131
|
-
# gem "hexapdf", "0.5.0"
|
132
|
-
# gem "geocoder", "1.6.1"
|
133
|
-
# gem "sd_notify", "0.1.1"
|
134
|
-
# gem "attr_encrypted", "3.1.0"
|
135
|
-
# gem "clamby", "1.6.6"
|
136
|
-
# gem "scout_apm", "5.1.0"
|
137
|
-
# gem "pusher", "1.3.0"
|
138
|
-
# gem "phony", "2.18.18"
|
139
|
-
# gem "recaptcha", "5.7.0"
|
140
|
-
# gem "ransack", "1.8.10"
|
141
|
-
# gem "configatron", "4.5.1"
|
142
|
-
# gem "fuzzy-string-match", "1.0.1"
|
143
|
-
# gem "jwt", "1.5.6"
|
144
|
-
# gem "htmlentities", "4.3.4"
|
145
|
-
# gem "scenic", "1.5.4"
|
146
|
-
# gem "rack-cors", "1.0.6"
|
147
|
-
# gem "rails_same_site_cookie", "0.1.8"
|
148
|
-
# gem "paper_trail", "10.3.0"
|
149
|
-
# gem "net-sftp", "3.0.0"
|
150
|
-
# gem "prawn", "2.4.0"
|
151
|
-
# gem "prawn-table", "0.2.2"
|
152
|
-
|
153
143
|
class_option :add_irbrc , type: :boolean, default: false
|
154
144
|
class_option :add_foreman , type: :boolean, default: false
|
155
145
|
class_option :add_devise , type: :boolean, default: false
|
@@ -172,7 +162,10 @@ module RailsAppGenerator
|
|
172
162
|
class_option :add_shoulda , type: :boolean, default: false
|
173
163
|
|
174
164
|
# NEW GEM ADDONS
|
165
|
+
class_option :add_acts_as_list , type: :boolean, default: false
|
166
|
+
class_option :add_honeybadger , type: :boolean, default: false
|
175
167
|
class_option :add_rails_html_sanitizer , type: :boolean, default: false
|
168
|
+
class_option :add_twilio_ruby , type: :boolean, default: false
|
176
169
|
|
177
170
|
class << self
|
178
171
|
# points to the original rails templates
|
@@ -300,48 +293,34 @@ module RailsAppGenerator
|
|
300
293
|
# # add(:rspec) if options[:testing_framework] == 'rspec'
|
301
294
|
# end
|
302
295
|
|
296
|
+
# rubocop:disable Metrics/AbcSize
|
303
297
|
def finish_template
|
304
298
|
puts 'finish template'
|
305
299
|
|
300
|
+
add_if(:acts_as_list)
|
306
301
|
add_if(:annotate)
|
307
302
|
add_if(:devise)
|
308
303
|
add_if(:continuous_integration)
|
304
|
+
add_if(:factory_bot)
|
309
305
|
add_if(:high_voltage)
|
306
|
+
add_if(:honeybadger)
|
310
307
|
add_if(:generators)
|
311
308
|
add_if(:lograge)
|
312
309
|
add_if(:pundit)
|
310
|
+
add_if(:rails_app_generator)
|
313
311
|
add_if(:services)
|
314
|
-
add_if(:sidekiq)
|
315
|
-
add(:views, :errors, :scaffold) if options[:add_views]
|
316
|
-
add_if(:factory_bot)
|
317
312
|
add_if(:shoulda)
|
313
|
+
add_if(:sidekiq)
|
314
|
+
add_if(:twilio_ruby)
|
315
|
+
add(:views, :errors, :scaffold) if active?(:views)
|
318
316
|
|
319
317
|
# invoke :rails_customization
|
320
318
|
super
|
321
319
|
end
|
320
|
+
# rubocop:enable Metrics/AbcSize
|
322
321
|
|
323
322
|
no_commands do
|
324
|
-
#
|
325
|
-
# gac 'base rails 7 image created'
|
326
|
-
# force_copy
|
327
|
-
# add_controller('home', 'index')
|
328
|
-
# add_scaffold('people', 'first_name', 'last_name', 'age:integer', 'address:text')
|
329
|
-
# route("root 'home#index'")
|
330
|
-
# css_install('tailwind')
|
331
|
-
# rails_command('db:migrate')
|
332
|
-
# db_migrate
|
333
|
-
# bundle_add('hotwire-rails')
|
334
|
-
# rails_command('hotwire:install')
|
335
|
-
# run('bin/importmap pin sortablejs')
|
336
|
-
# run('npm install daisyui')
|
337
|
-
# create_file 'app/assets/stylesheets/custom-bootstrap-import.scss' , read_template('custom-bootstrap-import.scss')
|
338
|
-
# append_to_file 'app/assets/config/manifest.js' , read_template('manifest.js')
|
339
|
-
# insert_into_file 'app/views/layouts/application.html.erb', read_template('application.html.erb')
|
340
|
-
# insert_into_file 'app/views/layouts/application.html.erb', read_template('application.html.erb'),
|
341
|
-
# before: %( <%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>)
|
342
|
-
|
343
|
-
# gsub_file 'app/views/layouts/application.html.erb', %(container mx-auto mt-28 px-5 flex), 'container mx-auto px-5'
|
344
|
-
# template 'home.css', 'app/assets/stylesheets/home.css'
|
323
|
+
# https://codingpackets.com/blog/rails-generators-cheat-sheet/
|
345
324
|
|
346
325
|
# OLD style will be removed soon
|
347
326
|
def local_template_base(xxx)
|
@@ -396,6 +375,10 @@ module RailsAppGenerator
|
|
396
375
|
run("bundle add #{name}")
|
397
376
|
end
|
398
377
|
|
378
|
+
def bundle_exec(name, *args)
|
379
|
+
run("bundle exec #{name} #{args.join(' ')}")
|
380
|
+
end
|
381
|
+
|
399
382
|
# If you need to manually install tailwind (instead of using the --template option)
|
400
383
|
# you can use css_install('tailwind')
|
401
384
|
def css_install(name)
|
@@ -435,6 +418,34 @@ module RailsAppGenerator
|
|
435
418
|
template_files.map { |template_file| read_template(template_file) }.join(join)
|
436
419
|
end
|
437
420
|
|
421
|
+
# Moves a file at given location, to another location. Both files are relative to the destination_root
|
422
|
+
#
|
423
|
+
# ==== Parameters
|
424
|
+
# path<String>:: source_path of the file to be moved (relative to destination_root)
|
425
|
+
# path<String>:: target_path of the file moving to (relative to destination_root)
|
426
|
+
# config<Hash>:: give :verbose => false to not log the status.
|
427
|
+
#
|
428
|
+
# ==== Example
|
429
|
+
#
|
430
|
+
# move_file 'README', 'readme.md'
|
431
|
+
# move_file 'config/xmen.sample.yml', 'config/xmen.yml
|
432
|
+
#
|
433
|
+
# rubocop:disable Metrics/AbcSize
|
434
|
+
def move_file(source_path, target_path, config = {})
|
435
|
+
source = File.expand_path(source_path, destination_root)
|
436
|
+
target = File.expand_path(target_path, destination_root)
|
437
|
+
config.merge!({ verbose: true })
|
438
|
+
|
439
|
+
say_status :move_file_source, relative_to_original_destination_root(source), config.fetch(:verbose, true)
|
440
|
+
say_status :move_file_source, relative_to_original_destination_root(target), config.fetch(:verbose, true)
|
441
|
+
|
442
|
+
return unless !options[:pretend] && File.exist?(source)
|
443
|
+
|
444
|
+
require 'fileutils'
|
445
|
+
::FileUtils.mv(source, target)
|
446
|
+
end
|
447
|
+
# rubocop:enable Metrics/AbcSize
|
448
|
+
|
438
449
|
# Local template path is handy when you want template files used when working with the --template flag
|
439
450
|
attr_accessor :local_template_path
|
440
451
|
|
@@ -466,17 +477,16 @@ module RailsAppGenerator
|
|
466
477
|
end
|
467
478
|
|
468
479
|
def add_if(addon)
|
469
|
-
|
470
|
-
add(addon) if options[option_name]
|
480
|
+
add(addon) if active?(addon)
|
471
481
|
end
|
472
482
|
|
473
|
-
def skip_flag?(option_name)
|
474
|
-
|
483
|
+
# def skip_flag?(option_name)
|
484
|
+
# value = options["skip_#{option_name}".to_sym]
|
475
485
|
|
476
|
-
|
486
|
+
# return true if value.nil?
|
477
487
|
|
478
|
-
|
479
|
-
end
|
488
|
+
# value == true
|
489
|
+
# end
|
480
490
|
|
481
491
|
def add_flag?(option_name)
|
482
492
|
value = options["add_#{option_name}".to_sym]
|
@@ -487,7 +497,7 @@ module RailsAppGenerator
|
|
487
497
|
end
|
488
498
|
|
489
499
|
def active?(option_name)
|
490
|
-
add_flag?(option_name) || !skip_flag?(option_name)
|
500
|
+
add_flag?(option_name) # || !skip_flag?(option_name)
|
491
501
|
end
|
492
502
|
|
493
503
|
def uses?(addon)
|
@@ -505,10 +515,18 @@ module RailsAppGenerator
|
|
505
515
|
end
|
506
516
|
end
|
507
517
|
|
508
|
-
def
|
518
|
+
def addon_classes
|
509
519
|
AddOns.constants
|
510
|
-
.
|
511
|
-
.
|
520
|
+
.map { |addon_klass_name| AddOns.const_get(addon_klass_name) }
|
521
|
+
.select { |klass| klass.is_a?(Class) && klass.respond_to?(:addon_name) }
|
522
|
+
end
|
523
|
+
|
524
|
+
def active_addon_classes
|
525
|
+
addon_classes.select { |klass| active?(klass.addon_name) }
|
526
|
+
end
|
527
|
+
|
528
|
+
def addon_gemfile_entries
|
529
|
+
active_addon_classes.flat_map(&:gem_entries)
|
512
530
|
end
|
513
531
|
end
|
514
532
|
|
@@ -59,7 +59,10 @@ module RailsAppGenerator
|
|
59
59
|
register_option :add_shoulda , type: :boolean, default: false
|
60
60
|
|
61
61
|
# NEW GEM ADDONS
|
62
|
+
register_option :add_acts_as_list , type: :boolean, default: false
|
63
|
+
register_option :add_honeybadger , type: :boolean, default: false
|
62
64
|
register_option :add_rails_html_sanitizer , type: :boolean, default: false
|
65
|
+
register_option :add_twilio_ruby , type: :boolean, default: false
|
63
66
|
|
64
67
|
# if options[:minimal]
|
65
68
|
# self.options = options.merge(
|
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.14",
|
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.14",
|
10
10
|
"dependencies": {
|
11
11
|
"daisyui": "^2.20.0"
|
12
12
|
},
|
data/package.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"args": {
|
3
|
-
"app_path": "
|
3
|
+
"app_path": "honeybadger",
|
4
4
|
"destination_root": "/Users/davidcruwys/dev/kgems/rails_app_generator/a/addons"
|
5
5
|
},
|
6
6
|
"opts": {
|
7
7
|
"skip_git": true,
|
8
8
|
"skip_test": true,
|
9
|
-
"template": "/Users/davidcruwys/dev/kgems/rails_app_generator/after_templates/addons/
|
10
|
-
"
|
9
|
+
"template": "/Users/davidcruwys/dev/kgems/rails_app_generator/after_templates/addons/honeybadger/_.rb",
|
10
|
+
"add_honeybadger": true
|
11
11
|
}
|
12
12
|
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
{
|
2
|
+
"args": {
|
3
|
+
"app_path": "twilio_ruby",
|
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/twilio_ruby/_.rb",
|
10
|
+
"add_twilio_ruby": true
|
11
|
+
}
|
12
|
+
}
|
data/tasks/addon.thor
CHANGED
@@ -12,10 +12,18 @@ class AddOn < Thor
|
|
12
12
|
|
13
13
|
source_root(File.expand_path('../templates/thor_task', File.dirname(__FILE__)))
|
14
14
|
|
15
|
-
|
15
|
+
Data = Struct.new(
|
16
|
+
:name,
|
17
|
+
:name_dash,
|
18
|
+
:name_snake,
|
19
|
+
:name_human,
|
20
|
+
:name_camel,
|
21
|
+
:addon_config_code,
|
22
|
+
keyword_init: true
|
23
|
+
)
|
16
24
|
|
17
25
|
attr_accessor :name
|
18
|
-
attr_accessor :
|
26
|
+
attr_accessor :data
|
19
27
|
|
20
28
|
# method_option :from, :required => true
|
21
29
|
desc 'new', 'Create a new Addon for Rails App Generator'
|
@@ -23,15 +31,13 @@ class AddOn < Thor
|
|
23
31
|
method_option :force, type: :boolean, default: false, desc: 'Overwrite existing files'
|
24
32
|
method_option :depends_on, type: :string, desc: 'This AddOn depends on another AddOn/Gem. active_record is a common dependency'
|
25
33
|
def new(name)
|
26
|
-
self.name = name
|
34
|
+
self.name = snake(name)
|
35
|
+
self.data = build_data
|
27
36
|
|
28
|
-
|
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])
|
37
|
+
template('addon/addon', "lib/rails_app_generator/addons/#{self.name}.rb", force: options[:force])
|
33
38
|
end
|
34
39
|
|
40
|
+
# rubocop:disable Metrics/BlockLength
|
35
41
|
no_commands do
|
36
42
|
def build_depends_on_code
|
37
43
|
return nil unless options[:depends_on]
|
@@ -53,5 +59,36 @@ class AddOn < Thor
|
|
53
59
|
|
54
60
|
::GemInfo.get(gem_name)
|
55
61
|
end
|
62
|
+
|
63
|
+
def build_data
|
64
|
+
code = [build_depends_on_code, build_required_gem_code].compact
|
65
|
+
code << '' if code.any?
|
66
|
+
|
67
|
+
Data.new(
|
68
|
+
name: name,
|
69
|
+
name_dash: dash(name),
|
70
|
+
name_snake: snake(name),
|
71
|
+
name_human: human(name),
|
72
|
+
name_camel: camel(name),
|
73
|
+
addon_config_code: code.join("\n")
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
def human(value)
|
78
|
+
Cmdlet::Case::Human.new.call(value)
|
79
|
+
end
|
80
|
+
|
81
|
+
def dash(value)
|
82
|
+
Cmdlet::Case::Dash.new.call(value)
|
83
|
+
end
|
84
|
+
|
85
|
+
def snake(value)
|
86
|
+
Cmdlet::Case::Snake.new.call(value)
|
87
|
+
end
|
88
|
+
|
89
|
+
def camel(value)
|
90
|
+
Cmdlet::Case::Camel.new.call(value)
|
91
|
+
end
|
56
92
|
end
|
93
|
+
# rubocop:enable Metrics/BlockLength
|
57
94
|
end
|
data/tasks/profile.thor
CHANGED
@@ -17,12 +17,14 @@ class Profile < Thor
|
|
17
17
|
:name_dash,
|
18
18
|
:name_snake,
|
19
19
|
:name_human,
|
20
|
+
:name_camel,
|
20
21
|
:description,
|
21
22
|
:destination_root,
|
22
23
|
:template_file,
|
23
24
|
keyword_init: true
|
24
25
|
)
|
25
26
|
|
27
|
+
attr_accessor :name
|
26
28
|
attr_accessor :data
|
27
29
|
|
28
30
|
desc 'new', 'Create a new Profile for testing Rails App Generator settings'
|
@@ -31,7 +33,8 @@ class Profile < Thor
|
|
31
33
|
method_option :force, type: :boolean, default: false, desc: 'Overwrite existing files'
|
32
34
|
# rubocop:disable Metrics/AbcSize
|
33
35
|
def new(name)
|
34
|
-
|
36
|
+
self.name = snake(name)
|
37
|
+
self.data = build_data
|
35
38
|
|
36
39
|
say "Creating profile #{name}"
|
37
40
|
puts "Variant: #{options[:variant]}"
|
@@ -44,18 +47,6 @@ class Profile < Thor
|
|
44
47
|
|
45
48
|
# rubocop:disable Metrics/BlockLength
|
46
49
|
no_commands do
|
47
|
-
def human(value)
|
48
|
-
Cmdlet::Case::Human.new.call(value)
|
49
|
-
end
|
50
|
-
|
51
|
-
def dash(value)
|
52
|
-
Cmdlet::Case::Dash.new.call(value)
|
53
|
-
end
|
54
|
-
|
55
|
-
def snake(value)
|
56
|
-
Cmdlet::Case::Snake.new.call(value)
|
57
|
-
end
|
58
|
-
|
59
50
|
def profile_path(file)
|
60
51
|
path = 'profiles'
|
61
52
|
path = File.join(path, options[:variant]) if options[:variant]
|
@@ -69,21 +60,20 @@ class Profile < Thor
|
|
69
60
|
File.join(path, file)
|
70
61
|
end
|
71
62
|
|
72
|
-
def build_data
|
63
|
+
def build_data
|
73
64
|
gi = gem_info(name)
|
74
65
|
|
75
|
-
name_dash = dash(name)
|
76
|
-
name_snake = snake(name)
|
77
66
|
description = gi ? gi.description : 'Description goes here'
|
78
67
|
|
79
68
|
Data.new(
|
80
69
|
name: name,
|
81
|
-
name_dash:
|
82
|
-
name_snake:
|
83
|
-
name_human: human(
|
70
|
+
name_dash: dash(name),
|
71
|
+
name_snake: name,
|
72
|
+
name_human: human(name),
|
73
|
+
name_camel: camel(name),
|
84
74
|
description: description,
|
85
75
|
destination_root: build_destination_root,
|
86
|
-
template_file: build_template_file(
|
76
|
+
template_file: build_template_file(name)
|
87
77
|
)
|
88
78
|
end
|
89
79
|
|
@@ -109,6 +99,22 @@ class Profile < Thor
|
|
109
99
|
|
110
100
|
GemInfo.get(gem_name)
|
111
101
|
end
|
102
|
+
|
103
|
+
def human(value)
|
104
|
+
Cmdlet::Case::Human.new.call(value)
|
105
|
+
end
|
106
|
+
|
107
|
+
def dash(value)
|
108
|
+
Cmdlet::Case::Dash.new.call(value)
|
109
|
+
end
|
110
|
+
|
111
|
+
def snake(value)
|
112
|
+
Cmdlet::Case::Snake.new.call(value)
|
113
|
+
end
|
114
|
+
|
115
|
+
def camel(value)
|
116
|
+
Cmdlet::Case::Camel.new.call(value)
|
117
|
+
end
|
112
118
|
end
|
113
119
|
# rubocop:enable Metrics/BlockLength
|
114
120
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
honeybadger:
|
2
|
+
feedback:
|
3
|
+
heading: "Care to help us fix this?"
|
4
|
+
explanation: "Any information you can provide will help us fix the problem."
|
5
|
+
submit: "Send"
|
6
|
+
thanks: "Thanks for the feedback!"
|
7
|
+
labels:
|
8
|
+
name: "Your name"
|
9
|
+
email: "Your email address"
|
10
|
+
comment: "Comment (required)"
|
@@ -0,0 +1,37 @@
|
|
1
|
+
---
|
2
|
+
# For more options, see https://docs.honeybadger.io/lib/ruby/gem-reference/configuration
|
3
|
+
|
4
|
+
api_key: 'hbp_f56DVeEaIvMMjqbMJAT7haJpQ7qfLP1ezvc0'
|
5
|
+
|
6
|
+
# The environment your app is running in.
|
7
|
+
env: "<%= Rails.env %>"
|
8
|
+
|
9
|
+
# The absolute path to your project folder.
|
10
|
+
root: "<%= Rails.root.to_s %>"
|
11
|
+
|
12
|
+
# Honeybadger won't report errors in these environments.
|
13
|
+
development_environments:
|
14
|
+
- test
|
15
|
+
- development
|
16
|
+
- cucumber
|
17
|
+
|
18
|
+
# By default, Honeybadger won't report errors in the development_environments.
|
19
|
+
# You can override this by explicitly setting report_data to true or false.
|
20
|
+
# report_data: true
|
21
|
+
|
22
|
+
# The current Git revision of your project. Defaults to the last commit hash.
|
23
|
+
# revision: null
|
24
|
+
|
25
|
+
# Enable verbose debug logging (useful for troubleshooting).
|
26
|
+
debug: false
|
27
|
+
|
28
|
+
# Displaying the Error ID
|
29
|
+
# Add to your html: <!-- HONEYBADGER ERROR -->
|
30
|
+
user_informer:
|
31
|
+
enabled: true
|
32
|
+
info: "Error ID: {{error_id}}"
|
33
|
+
|
34
|
+
# Displaying a Feedback Form
|
35
|
+
# Add to your html: <!-- HONEYBADGER FEEDBACK -->
|
36
|
+
feedback:
|
37
|
+
enabled: true
|
@@ -1,16 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# NEW GEM ADDONS
|
4
|
+
# lib/rails_app_generator/app_generator.rb
|
5
|
+
# class_option :add_<%= data.name_snake %>, type: :boolean, default: false
|
6
|
+
# add_if(:<%= data.name_snake %>)
|
7
|
+
# lib/rails_app_generator/options/rails_options.rb
|
8
|
+
# register_option :add_<%= data.name_snake %>, type: :boolean, default: false
|
9
|
+
|
3
10
|
module RailsAppGenerator
|
4
11
|
# Custom add-ons for RailsAppGenerator
|
5
12
|
module AddOns
|
6
|
-
# Add <%=
|
7
|
-
class <%=
|
8
|
-
<%= addon_config_code %>
|
13
|
+
# Add <%= data.name_camel %> to rails application
|
14
|
+
class <%= data.name_camel %> < AddOn
|
15
|
+
<%= data.addon_config_code %>
|
9
16
|
def apply
|
10
|
-
# say 'Setting up <%=
|
11
|
-
# template('<%=
|
17
|
+
# say 'Setting up <%= data.name_camel %>'
|
18
|
+
# template('<%= data.name_snake%>_template.rb', 'target/<%= data.name_snake%>.rb', force: true)
|
12
19
|
# template('app/javascript/stylesheets/components.scss')
|
13
|
-
# create_file('target/<%=
|
20
|
+
# create_file('target/<%= data.name_snake%>.rb', 'put your content here')
|
14
21
|
# directory 'app/template', 'app/target', force: true
|
15
22
|
# empty_directory 'app/target'
|
16
23
|
# inject_into_file('app/application.js', "some content")
|