rails_app_generator 0.0.5 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/.vscode/settings.json +3 -0
- data/CHANGELOG.md +23 -0
- data/README.md +9 -0
- data/after_templates/README.md +3 -0
- data/after_templates/___base_template.rb +1 -0
- data/after_templates/___r7_hotwire.rb +1 -0
- data/after_templates/rag_bootstrap/application-yield.html.erb +5 -0
- data/after_templates/rag_bootstrap/application.html.erb +4 -0
- data/after_templates/rag_bootstrap/component-cards-fancy.css +84 -0
- data/after_templates/rag_bootstrap/component-cards-fancy.html +80 -0
- data/after_templates/rag_bootstrap/component-cards-staff.css +90 -0
- data/after_templates/rag_bootstrap/component-cards-staff.html +140 -0
- data/after_templates/rag_bootstrap/component-cards-styled.html +31 -0
- data/after_templates/rag_bootstrap/component-footer.html +34 -0
- data/after_templates/rag_bootstrap/component-hero.html +15 -0
- data/after_templates/rag_bootstrap/component-nav.html +36 -0
- data/after_templates/rag_bootstrap/custom-bootstrap-import.scss +5 -0
- data/after_templates/rag_bootstrap/custom-using-css.css +3 -0
- data/after_templates/rag_bootstrap/custom-using-scss.scss +5 -0
- data/after_templates/rag_bootstrap/manifest.js +3 -0
- data/after_templates/rag_bootstrap.rb +1 -0
- data/after_templates/rag_simple.rb +25 -0
- data/after_templates/rag_tailwind.rb +74 -0
- data/exe/rag +41 -0
- data/lib/rails_app_generator/add_on.rb +73 -0
- data/lib/rails_app_generator/addons/annotate.rb +15 -0
- data/lib/rails_app_generator/addons/continuous_integration.rb +14 -0
- data/lib/rails_app_generator/addons/devise.rb +50 -0
- data/lib/rails_app_generator/addons/docker.rb +14 -0
- data/lib/rails_app_generator/addons/docker_compose.rb +13 -0
- data/lib/rails_app_generator/addons/dotenv.rb +13 -0
- data/lib/rails_app_generator/addons/factory_bot.rb +19 -0
- data/lib/rails_app_generator/addons/foreman.rb +15 -0
- data/lib/rails_app_generator/addons/generators.rb +31 -0
- data/lib/rails_app_generator/addons/high_voltage.rb +15 -0
- data/lib/rails_app_generator/addons/inline_svg.rb +11 -0
- data/lib/rails_app_generator/addons/irbrc.rb +13 -0
- data/lib/rails_app_generator/addons/lograge.rb +13 -0
- data/lib/rails_app_generator/addons/pundit.rb +16 -0
- data/lib/rails_app_generator/addons/rspec.rb +17 -0
- data/lib/rails_app_generator/addons/rubocop.rb +13 -0
- data/lib/rails_app_generator/addons/scaffold.rb +15 -0
- data/lib/rails_app_generator/addons/services.rb +13 -0
- data/lib/rails_app_generator/addons/sidekiq.rb +18 -0
- data/lib/rails_app_generator/addons/stimulus.rb +15 -0
- data/lib/rails_app_generator/addons/stimulus_components.rb +33 -0
- data/lib/rails_app_generator/addons/tailwind.rb +22 -0
- data/lib/rails_app_generator/addons/views.rb +21 -0
- data/lib/rails_app_generator/app_builder.rb +7 -5
- data/lib/rails_app_generator/app_generator.rb +187 -99
- data/lib/rails_app_generator/context.rb +75 -0
- data/lib/rails_app_generator/dependencies.rb +34 -0
- data/lib/rails_app_generator/notes/a1.txt +1 -1
- data/lib/rails_app_generator/notes/a2.txt +1 -1
- data/lib/rails_app_generator/notes/kw01-b.txt +86 -0
- data/lib/rails_app_generator/notes/kw01.txt +91 -0
- data/lib/rails_app_generator/options/map_option_string.rb +2 -0
- data/lib/rails_app_generator/options/rails_options.rb +52 -32
- data/lib/rails_app_generator/starter.rb +17 -8
- data/lib/rails_app_generator/version.rb +1 -1
- data/lib/rails_app_generator.rb +5 -1
- data/package-lock.json +2 -2
- data/package.json +1 -1
- data/profiles/rag-add-some-pages.json +11 -0
- data/profiles/rag-bootstrap.json +12 -0
- data/profiles/rag-simple.json +11 -0
- data/profiles/rag-tailwind.json +12 -0
- data/templates/README.md.erb +43 -0
- data/templates/addons/annotate/auto_annotate_models.rake +60 -0
- data/templates/addons/continuous_integration/.github/workflows/build.yml.erb +49 -0
- data/templates/addons/devise/app/views/devise/confirmations/new.html.erb +24 -0
- data/templates/addons/devise/app/views/devise/passwords/edit.html.erb +34 -0
- data/templates/addons/devise/app/views/devise/passwords/new.html.erb +23 -0
- data/templates/addons/devise/app/views/devise/registrations/edit.html.erb +62 -0
- data/templates/addons/devise/app/views/devise/registrations/new.html.erb +45 -0
- data/templates/addons/devise/app/views/devise/sessions/new.html.erb +33 -0
- data/templates/addons/devise/app/views/devise/shared/_error_messages.html.erb +15 -0
- data/templates/addons/devise/app/views/devise/shared/_form_wrap.html.erb +5 -0
- data/templates/addons/devise/app/views/devise/shared/_links.html.erb +25 -0
- data/templates/addons/devise/app/views/devise/unlocks/new.html.erb +22 -0
- data/templates/addons/docker/.dockerignore.erb +51 -0
- data/templates/addons/docker/Dockerfile.erb +45 -0
- data/templates/addons/docker_compose/docker-compose.yml.erb +21 -0
- data/templates/addons/dotenv/.env.development.erb +3 -0
- data/templates/addons/foreman/.foreman.erb +1 -0
- data/templates/addons/foreman/Procfile.dev.erb +7 -0
- data/templates/addons/foreman/Procfile.erb +4 -0
- data/templates/addons/generators/lib/generators/rails/navigation/USAGE +6 -0
- data/templates/addons/generators/lib/generators/rails/navigation/navigation_generator.rb +16 -0
- data/templates/addons/generators/lib/generators/rails/scaffold_controller_generator.rb +12 -0
- data/templates/addons/high_voltage/config/initializers/high_voltage.rb +6 -0
- data/templates/addons/irbrc/.irbrc.erb +13 -0
- data/templates/addons/lograge/config/initializers/lograge.rb +5 -0
- data/templates/addons/pundit/app/controllers/authorized_controller.rb.erb +10 -0
- data/templates/addons/pundit/app/policies/application_policy.rb +57 -0
- data/templates/addons/rspec/spec/rails_helper.rb +26 -0
- data/templates/addons/rspec/spec/spec_helper.rb +61 -0
- data/templates/addons/rubocop/.rubocop.yml.erb +37 -0
- data/templates/addons/scaffold/lib/templates/erb/scaffold/_form.html.erb +39 -0
- data/templates/addons/scaffold/lib/templates/erb/scaffold/edit.html.erb +7 -0
- data/templates/addons/scaffold/lib/templates/erb/scaffold/index.html.erb +34 -0
- data/templates/addons/scaffold/lib/templates/erb/scaffold/new.html.erb +7 -0
- data/templates/addons/scaffold/lib/templates/erb/scaffold/show.html.erb +18 -0
- data/templates/addons/services/app/services/application_service.rb +15 -0
- data/templates/app_x/controllers/authorized_controller.rb.erb +10 -0
- data/templates/app_x/controllers/errors_controller.rb.erb +24 -0
- data/templates/app_x/javascript/images/checkmark.svg +1 -0
- data/templates/app_x/javascript/images/logo.svg +1 -0
- data/templates/app_x/javascript/stylesheets/components.scss +206 -0
- data/templates/app_x/views/errors/internal_error.html.erb +14 -0
- data/templates/app_x/views/errors/not_found.html.erb +14 -0
- data/templates/app_x/views/errors/unacceptable.html.erb +14 -0
- data/templates/app_x/views/layouts/application.html.erb.tt +30 -0
- data/templates/app_x/views/pages/home.html.erb.tt +20 -0
- data/templates/app_x/views/shared/_flashes.html.erb.tt +12 -0
- data/templates/app_x/views/shared/_footer.html.erb.tt +21 -0
- data/templates/app_x/views/shared/_navbar.html.erb.tt +55 -0
- data/templates/app_x/workers/application_worker.rb +5 -0
- metadata +207 -3
@@ -7,54 +7,84 @@ module RailsAppGenerator
|
|
7
7
|
class AppGenerator < Rails::Generators::AppGenerator
|
8
8
|
class_option :test, type: :string, default: 'rspec'
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
10
|
+
class_option :add_irbrc , type: :boolean, default: false
|
11
|
+
class_option :add_foreman , type: :boolean, default: false
|
12
|
+
class_option :add_dotenv , type: :boolean, default: false
|
13
|
+
class_option :add_docker , type: :boolean, default: false
|
14
|
+
class_option :add_docker_compose , type: :boolean, default: false
|
15
|
+
class_option :add_rubocop , type: :boolean, default: false
|
16
|
+
class_option :add_annotate , type: :boolean, default: false
|
17
|
+
class_option :add_continuous_integration , type: :boolean, default: false
|
18
|
+
class_option :add_high_voltage , type: :boolean, default: false
|
19
|
+
class_option :add_generators , type: :boolean, default: false
|
20
|
+
class_option :add_lograge , type: :boolean, default: false
|
21
|
+
class_option :add_pundit , type: :boolean, default: false
|
22
|
+
class_option :add_services , type: :boolean, default: false
|
23
|
+
class_option :add_sidekiq , type: :boolean, default: false
|
24
|
+
class_option :add_views , type: :boolean, default: false
|
25
|
+
class_option :add_errors , type: :boolean, default: false
|
26
|
+
class_option :add_scaffold , type: :boolean, default: false
|
27
|
+
class_option :add_factory_bot , type: :boolean, default: false
|
28
|
+
class_option :add_shoulda , type: :boolean, default: false
|
29
|
+
|
30
|
+
class << self
|
31
|
+
# points to the original rails templates
|
32
|
+
attr_writer :rails_template_path
|
33
|
+
|
34
|
+
def rails_template_path
|
35
|
+
@rails_template_path ||= gem_template_path('railties', 'lib/rails/generators/rails/app/templates')
|
36
|
+
end
|
37
|
+
|
38
|
+
# points to the custom templates related to rails
|
39
|
+
attr_writer :override_template_path
|
40
|
+
|
41
|
+
def override_template_path
|
42
|
+
@override_template_path ||= gem_template_path('rails_app_generator', 'templates')
|
43
|
+
end
|
44
|
+
|
45
|
+
# points to templates related to rails addons
|
46
|
+
attr_writer :addon_template_path
|
47
|
+
|
48
|
+
def addon_template_path
|
49
|
+
@addon_template_path ||= gem_template_path('rails_app_generator', 'templates/addons/%<addon>')
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def gem_template_path(gem_name, template_path)
|
55
|
+
gem_path = gem_path(gem_name)
|
56
|
+
|
57
|
+
File.join(gem_path, template_path)
|
58
|
+
end
|
59
|
+
|
60
|
+
def gem_path(gem_name)
|
61
|
+
gem = Gem.loaded_specs[gem_name]
|
62
|
+
return gem.full_gem_path if gem
|
63
|
+
|
64
|
+
puts "gem not available for '#{gem_name}'"
|
65
|
+
|
66
|
+
return Dir.pwd if Dir.pwd.end_with?('dev/kgems/rails_app_generator') # code smell: this is for my local development environment
|
67
|
+
|
68
|
+
raise "'#{gem_name}' not available"
|
69
|
+
end
|
35
70
|
end
|
36
71
|
|
37
|
-
# def
|
72
|
+
# def initialize(*args)
|
38
73
|
# super
|
39
74
|
|
40
|
-
# #
|
41
|
-
# #
|
42
|
-
# #
|
43
|
-
# # add(:docker)
|
44
|
-
# # add(:docker_compose)
|
45
|
-
# # add(:rubocop)
|
46
|
-
# end
|
47
|
-
|
48
|
-
# include KLog::Logging
|
75
|
+
# # puts '----------------------------------------------------'
|
76
|
+
# # puts options
|
77
|
+
# # puts '----------------------------------------------------'
|
49
78
|
|
50
|
-
#
|
51
|
-
# puts 'finish template'
|
52
|
-
# invoke :rails_customization
|
53
|
-
# super
|
54
|
-
# end
|
79
|
+
# # return unless options[:api]
|
55
80
|
|
56
|
-
#
|
57
|
-
#
|
81
|
+
# # self.options = options.merge(
|
82
|
+
# # skip_errors: true,
|
83
|
+
# # skip_high_voltage: true,
|
84
|
+
# # skip_stimulus: true,
|
85
|
+
# # skip_tailwind: true,
|
86
|
+
# # skip_views: true
|
87
|
+
# # ).freeze
|
58
88
|
# end
|
59
89
|
|
60
90
|
# def rails_customization
|
@@ -100,84 +130,142 @@ module RailsAppGenerator
|
|
100
130
|
# # generate("suspenders:advisories")
|
101
131
|
# end
|
102
132
|
|
103
|
-
|
133
|
+
def create_root_files
|
134
|
+
super
|
135
|
+
|
136
|
+
add_if(:irbrc)
|
137
|
+
add_if(:foreman)
|
138
|
+
add_if(:dotenv)
|
139
|
+
add_if(:docker)
|
140
|
+
add_if(:docker_compose)
|
141
|
+
add_if(:rubocop)
|
142
|
+
end
|
143
|
+
|
144
|
+
# def create_test_files
|
145
|
+
# return if options[:skip_test]
|
146
|
+
|
147
|
+
# super if options[:test] == 'minitest'
|
148
|
+
|
149
|
+
# # puts options[:testing_framework]
|
150
|
+
|
151
|
+
# # add(:rspec) if options[:testing_framework] == 'rspec'
|
152
|
+
# end
|
153
|
+
|
154
|
+
def finish_template
|
155
|
+
puts 'finish template'
|
156
|
+
|
157
|
+
add_if(:annotate)
|
158
|
+
add_if(:continuous_integration)
|
159
|
+
add_if(:high_voltage)
|
160
|
+
add_if(:generators)
|
161
|
+
add_if(:lograge)
|
162
|
+
add_if(:pundit)
|
163
|
+
add_if(:services)
|
164
|
+
add_if(:sidekiq)
|
165
|
+
add(:views, :errors, :scaffold) if options[:add_views]
|
166
|
+
add_if(:factory_bot)
|
167
|
+
add_if(:shoulda)
|
168
|
+
|
169
|
+
# invoke :rails_customization
|
170
|
+
super
|
171
|
+
end
|
104
172
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
173
|
+
no_commands do
|
174
|
+
# USED BY AFTER_TEMPLATE
|
175
|
+
def gac(message)
|
176
|
+
return unless active?(:git)
|
109
177
|
|
110
|
-
|
111
|
-
|
178
|
+
git add: '.'
|
179
|
+
git commit: " -m '#{message}'"
|
180
|
+
end
|
112
181
|
|
113
|
-
|
182
|
+
def add_controller(name, *args)
|
183
|
+
generate(:controller, name, *args)
|
184
|
+
end
|
114
185
|
|
115
|
-
|
116
|
-
|
186
|
+
def add_scaffold(name, *args)
|
187
|
+
generate(:scaffold, name, *args)
|
188
|
+
end
|
117
189
|
|
118
|
-
|
119
|
-
|
190
|
+
def read_template(template_file)
|
191
|
+
path = find_in_source_paths(template_file)
|
120
192
|
|
121
|
-
|
122
|
-
|
123
|
-
# puts "2 #{Suspenders::AppGenerator.source_root}"
|
124
|
-
# puts "3 #{Suspenders::AppGenerator.source_paths}"
|
125
|
-
# puts "4 #{Rails::Generators::AppGenerator.source_root}"
|
193
|
+
File.read(path)
|
194
|
+
end
|
126
195
|
|
127
|
-
|
196
|
+
def join_templates(*template_files, join: "\n\n")
|
197
|
+
template_files.map { |template_file| read_template(template_file) }.join(join)
|
198
|
+
end
|
128
199
|
|
129
|
-
|
130
|
-
|
131
|
-
# FileUtils.rm_rf(output_folder)
|
200
|
+
# Local template path is handy when you want template files used when working with the --template flag
|
201
|
+
attr_accessor :local_template_path
|
132
202
|
|
133
|
-
|
134
|
-
|
203
|
+
def source_paths
|
204
|
+
paths = local_template_path ? [local_template_path] : []
|
205
|
+
paths << context.rails_override_template_path
|
206
|
+
paths << context.rails_template_path
|
207
|
+
paths
|
208
|
+
end
|
135
209
|
|
136
|
-
|
137
|
-
|
138
|
-
|
210
|
+
# Context wraps the configured options and can be made available to addons
|
211
|
+
# TODO: should I add local_template_path to the context?
|
212
|
+
def context
|
213
|
+
@context ||= Context.new(
|
214
|
+
self.class.rails_template_path,
|
215
|
+
self.class.override_template_path,
|
216
|
+
self.class.addon_template_path,
|
217
|
+
options
|
218
|
+
)
|
219
|
+
end
|
139
220
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
# puts "4 #{Rails::Generators::AppGenerator.source_root}"
|
221
|
+
def add(*addons)
|
222
|
+
addons.each do |addon|
|
223
|
+
addon = addon.to_s.capitalize.camelize
|
224
|
+
addon = "RailsAppGenerator::AddOns::#{addon}"
|
145
225
|
|
146
|
-
|
226
|
+
addon.constantize.apply(context)
|
227
|
+
end
|
228
|
+
end
|
147
229
|
|
148
|
-
|
149
|
-
|
150
|
-
|
230
|
+
def add_if(addon)
|
231
|
+
option_name = "add_#{addon}".to_sym
|
232
|
+
add(addon) if options[option_name]
|
233
|
+
end
|
151
234
|
|
152
|
-
|
153
|
-
|
235
|
+
def skip_flag?(option_name)
|
236
|
+
value = options["skip_#{option_name}".to_sym]
|
154
237
|
|
155
|
-
|
156
|
-
# @dry_run_info = DryRunInfo.new(
|
157
|
-
# output_folder: output_folder
|
158
|
-
# )
|
238
|
+
return false if value.nil?
|
159
239
|
|
160
|
-
|
240
|
+
value == true
|
241
|
+
end
|
161
242
|
|
162
|
-
|
243
|
+
def add_flag?(option_name)
|
244
|
+
value = options["add_#{option_name}".to_sym]
|
163
245
|
|
164
|
-
|
165
|
-
# # Rails::Generators::AppGenerator
|
246
|
+
return false if value.nil?
|
166
247
|
|
167
|
-
|
168
|
-
|
169
|
-
# # generator.destination_root = destination_root
|
170
|
-
# # generator.destination_root
|
171
|
-
# generator.source_paths
|
172
|
-
# generator.class.source_root
|
173
|
-
# # => ["/Users/davidcruwys/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/railties-7.0.3.1/lib/rails/generators/rails/app/templates"]
|
174
|
-
# # g.find_in_source_paths('README.MD')
|
248
|
+
value == true
|
249
|
+
end
|
175
250
|
|
176
|
-
|
251
|
+
def active?(option_name)
|
252
|
+
add_flag?(option_name) || !skip_flag?(option_name)
|
253
|
+
end
|
177
254
|
|
178
|
-
|
255
|
+
def uses?(addon)
|
256
|
+
return false unless active?(addon)
|
179
257
|
|
180
|
-
|
181
|
-
|
258
|
+
addon = AddOn.get(addon)
|
259
|
+
Dependencies.new(addon, context).satisfied?
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
protected
|
264
|
+
|
265
|
+
# rubocop:disable Naming/AccessorMethodName
|
266
|
+
def get_builder_class
|
267
|
+
RailsAppGenerator::AppBuilder
|
268
|
+
end
|
269
|
+
# rubocop:enable Naming/AccessorMethodName
|
182
270
|
end
|
183
271
|
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Context passes
|
5
|
+
class Context
|
6
|
+
attr_reader :rails_template_path
|
7
|
+
attr_reader :rails_override_template_path
|
8
|
+
attr_reader :addon_template_path
|
9
|
+
|
10
|
+
attr_reader :options
|
11
|
+
|
12
|
+
# Build a context object from the given arguments to be passed around within Rails Generator and AddOns.
|
13
|
+
#
|
14
|
+
# @param rails_template_path [String] The path to the Rails template.
|
15
|
+
# @param rails_override_template_path [String] This is the path to the templates that will override the default Rails templates.
|
16
|
+
# @param addon_template_path [String] The path to the addon's templates.
|
17
|
+
# @param options [Hash] A hash of options that can be used to customize the template. Defaults to {}
|
18
|
+
def initialize(rails_template_path, rails_override_template_path, addon_template_path, options = {})
|
19
|
+
@rails_template_path = rails_template_path
|
20
|
+
@rails_override_template_path = rails_override_template_path
|
21
|
+
@addon_template_path = addon_template_path
|
22
|
+
|
23
|
+
@options = options
|
24
|
+
end
|
25
|
+
|
26
|
+
def addons
|
27
|
+
AddOns.constants.select { |klass| AddOns.const_get(klass).is_a?(Class) }.map { |klass| AddOns.const_get(klass) }
|
28
|
+
.map(&:to_s) # .map(&:name) only works in Ruby 3.0+
|
29
|
+
.map(&:underscore)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Skippable parts of the default Rails generator, e.g. active_record, active_job...
|
33
|
+
def default_addons
|
34
|
+
addon_options = addons.map { |option| "skip_#{option}".to_sym }
|
35
|
+
skip_options = RailsAppGenerator::AppGenerator.class_options.keys.grep(/skip_/)
|
36
|
+
(skip_options - addon_options).map { |option| option.to_s.delete_prefix('skip_').to_sym }
|
37
|
+
end
|
38
|
+
|
39
|
+
def debug
|
40
|
+
kv('rails_template_path', rails_template_path)
|
41
|
+
kv('rails_override_template_path', rails_override_template_path)
|
42
|
+
kv('addon_template_path', addon_template_path)
|
43
|
+
|
44
|
+
debug_default_addons
|
45
|
+
debug_addons
|
46
|
+
debug_options
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def debug_default_addons
|
52
|
+
puts '-[ default_addons ]--------------------------------------------'
|
53
|
+
default_addons.each { |addon| puts addon }
|
54
|
+
end
|
55
|
+
|
56
|
+
def debug_addons
|
57
|
+
puts '-[ addons ]----------------------------------------------------'
|
58
|
+
addons.each { |addon| puts addon }
|
59
|
+
end
|
60
|
+
|
61
|
+
def debug_options
|
62
|
+
puts '-[ options ]----------------------------------------------------'
|
63
|
+
options.each { |key, value| kv(key, value) }
|
64
|
+
end
|
65
|
+
|
66
|
+
def kv(label, value, len = 35)
|
67
|
+
return ' ' * len if label.nil?
|
68
|
+
|
69
|
+
label = label.to_s if label.is_a?(Symbol)
|
70
|
+
label = label.length > len ? label.slice(0..len) : label.ljust(len, ' ')
|
71
|
+
|
72
|
+
puts "#{label}: #{value}"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# XXXX
|
5
|
+
class Dependencies
|
6
|
+
def initialize(addon, context)
|
7
|
+
@addon = addon
|
8
|
+
@context = context
|
9
|
+
@options = context.options
|
10
|
+
end
|
11
|
+
|
12
|
+
def satisfied?
|
13
|
+
@addon.dependencies.each do |dependency|
|
14
|
+
return false unless dependencies_satisfied?(dependency)
|
15
|
+
end
|
16
|
+
|
17
|
+
true
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def dependencies_satisfied?(addon, visited = [])
|
23
|
+
return false if @options["skip_#{addon}".to_sym]
|
24
|
+
|
25
|
+
return true if @context.default_addons.include?(addon)
|
26
|
+
|
27
|
+
visited << addon
|
28
|
+
dependencies = AddOn.get(addon).dependencies - visited
|
29
|
+
dependencies.each do |dependency|
|
30
|
+
return false unless dependencies_satisfied?(dependency, visited)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
create
|
2
|
+
create README.md
|
3
|
+
create Rakefile
|
4
|
+
create .ruby-version
|
5
|
+
create config.ru
|
6
|
+
create Gemfile
|
7
|
+
create app
|
8
|
+
create app/assets/config/manifest.js
|
9
|
+
create app/assets/stylesheets/application.css
|
10
|
+
create app/channels/application_cable/channel.rb
|
11
|
+
create app/channels/application_cable/connection.rb
|
12
|
+
create app/controllers/application_controller.rb
|
13
|
+
create app/helpers/application_helper.rb
|
14
|
+
create app/jobs/application_job.rb
|
15
|
+
create app/mailers/application_mailer.rb
|
16
|
+
create app/models/application_record.rb
|
17
|
+
create app/views/layouts/application.html.erb
|
18
|
+
create app/views/layouts/mailer.html.erb
|
19
|
+
create app/views/layouts/mailer.text.erb
|
20
|
+
create app/assets/images
|
21
|
+
create app/assets/images/.keep
|
22
|
+
create app/controllers/concerns/.keep
|
23
|
+
create app/models/concerns/.keep
|
24
|
+
create bin
|
25
|
+
create bin/rails
|
26
|
+
create bin/rake
|
27
|
+
create bin/setup
|
28
|
+
create config
|
29
|
+
create config/routes.rb
|
30
|
+
create config/application.rb
|
31
|
+
create config/environment.rb
|
32
|
+
create config/cable.yml
|
33
|
+
create config/puma.rb
|
34
|
+
create config/storage.yml
|
35
|
+
create config/environments
|
36
|
+
create config/environments/development.rb
|
37
|
+
create config/environments/production.rb
|
38
|
+
create config/environments/test.rb
|
39
|
+
create config/initializers
|
40
|
+
create config/initializers/assets.rb
|
41
|
+
create config/initializers/content_security_policy.rb
|
42
|
+
create config/initializers/cors.rb
|
43
|
+
create config/initializers/filter_parameter_logging.rb
|
44
|
+
create config/initializers/inflections.rb
|
45
|
+
create config/initializers/new_framework_defaults_7_0.rb
|
46
|
+
create config/initializers/permissions_policy.rb
|
47
|
+
create config/locales
|
48
|
+
create config/locales/en.yml
|
49
|
+
create config/master.key
|
50
|
+
create config/boot.rb
|
51
|
+
create config/database.yml
|
52
|
+
create db
|
53
|
+
create db/seeds.rb
|
54
|
+
create lib
|
55
|
+
create lib/tasks
|
56
|
+
create lib/tasks/.keep
|
57
|
+
create lib/assets
|
58
|
+
create lib/assets/.keep
|
59
|
+
create log
|
60
|
+
create log/.keep
|
61
|
+
create public
|
62
|
+
create public/404.html
|
63
|
+
create public/422.html
|
64
|
+
create public/500.html
|
65
|
+
create public/apple-touch-icon-precomposed.png
|
66
|
+
create public/apple-touch-icon.png
|
67
|
+
create public/favicon.ico
|
68
|
+
create public/robots.txt
|
69
|
+
create tmp
|
70
|
+
create tmp/.keep
|
71
|
+
create tmp/pids
|
72
|
+
create tmp/pids/.keep
|
73
|
+
create tmp/cache
|
74
|
+
create tmp/cache/assets
|
75
|
+
create vendor
|
76
|
+
create vendor/.keep
|
77
|
+
create test/system
|
78
|
+
create test/system/.keep
|
79
|
+
create test/application_system_test_case.rb
|
80
|
+
create storage
|
81
|
+
create storage/.keep
|
82
|
+
create tmp/storage
|
83
|
+
create tmp/storage/.keep
|
84
|
+
remove config/initializers/cors.rb
|
85
|
+
remove config/initializers/new_framework_defaults_7_0.rb
|
86
|
+
finish template
|
@@ -0,0 +1,91 @@
|
|
1
|
+
create
|
2
|
+
create README.md
|
3
|
+
create Rakefile
|
4
|
+
create .ruby-version
|
5
|
+
create config.ru
|
6
|
+
create Gemfile
|
7
|
+
create app
|
8
|
+
create app/assets/config/manifest.js
|
9
|
+
create app/assets/stylesheets/application.css
|
10
|
+
create app/channels/application_cable/channel.rb
|
11
|
+
create app/channels/application_cable/connection.rb
|
12
|
+
create app/controllers/application_controller.rb
|
13
|
+
create app/helpers/application_helper.rb
|
14
|
+
create app/jobs/application_job.rb
|
15
|
+
create app/mailers/application_mailer.rb
|
16
|
+
create app/models/application_record.rb
|
17
|
+
create app/views/layouts/application.html.erb
|
18
|
+
create app/views/layouts/mailer.html.erb
|
19
|
+
create app/views/layouts/mailer.text.erb
|
20
|
+
create app/assets/images
|
21
|
+
create app/assets/images/.keep
|
22
|
+
create app/controllers/concerns/.keep
|
23
|
+
create app/models/concerns/.keep
|
24
|
+
create bin
|
25
|
+
create bin/rails
|
26
|
+
create bin/rake
|
27
|
+
create bin/setup
|
28
|
+
create config
|
29
|
+
create config/routes.rb
|
30
|
+
create config/application.rb
|
31
|
+
create config/environment.rb
|
32
|
+
create config/cable.yml
|
33
|
+
create config/puma.rb
|
34
|
+
create config/storage.yml
|
35
|
+
create config/environments
|
36
|
+
create config/environments/development.rb
|
37
|
+
create config/environments/production.rb
|
38
|
+
create config/environments/test.rb
|
39
|
+
create config/initializers
|
40
|
+
create config/initializers/assets.rb
|
41
|
+
create config/initializers/content_security_policy.rb
|
42
|
+
create config/initializers/cors.rb
|
43
|
+
create config/initializers/filter_parameter_logging.rb
|
44
|
+
create config/initializers/inflections.rb
|
45
|
+
create config/initializers/new_framework_defaults_7_0.rb
|
46
|
+
create config/initializers/permissions_policy.rb
|
47
|
+
create config/locales
|
48
|
+
create config/locales/en.yml
|
49
|
+
create config/master.key
|
50
|
+
create config/boot.rb
|
51
|
+
create config/database.yml
|
52
|
+
create db
|
53
|
+
create db/seeds.rb
|
54
|
+
create lib
|
55
|
+
create lib/tasks
|
56
|
+
create lib/tasks/.keep
|
57
|
+
create lib/assets
|
58
|
+
create lib/assets/.keep
|
59
|
+
create log
|
60
|
+
create log/.keep
|
61
|
+
create public
|
62
|
+
create public/404.html
|
63
|
+
create public/422.html
|
64
|
+
create public/500.html
|
65
|
+
create public/apple-touch-icon-precomposed.png
|
66
|
+
create public/apple-touch-icon.png
|
67
|
+
create public/favicon.ico
|
68
|
+
create public/robots.txt
|
69
|
+
create tmp
|
70
|
+
create tmp/.keep
|
71
|
+
create tmp/pids
|
72
|
+
create tmp/pids/.keep
|
73
|
+
create tmp/cache
|
74
|
+
create tmp/cache/assets
|
75
|
+
create vendor
|
76
|
+
create vendor/.keep
|
77
|
+
create test/system
|
78
|
+
create test/system/.keep
|
79
|
+
create test/application_system_test_case.rb
|
80
|
+
create storage
|
81
|
+
create storage/.keep
|
82
|
+
create tmp/storage
|
83
|
+
create tmp/storage/.keep
|
84
|
+
remove config/initializers/cors.rb
|
85
|
+
remove config/initializers/new_framework_defaults_7_0.rb
|
86
|
+
finish template
|
87
|
+
run bundle install
|
88
|
+
run bundle binstubs bundler
|
89
|
+
rails javascript:install:esbuild
|
90
|
+
rails turbo:install stimulus:install
|
91
|
+
rails css:install:bootstrap
|
@@ -4,6 +4,8 @@ module RailsAppGenerator
|
|
4
4
|
# Simple pass through mapper for options that do not yet have a mapper defined
|
5
5
|
class MapOptionString < BaseMapOption
|
6
6
|
def map(name, value)
|
7
|
+
return '' if value.nil? || value.empty?
|
8
|
+
|
7
9
|
value = value.to_s
|
8
10
|
value = "\"#{value}\"" if value.include?(' ')
|
9
11
|
"#{option_name(name)}=#{value}"
|