12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/cli/commands/new_app/files/app.rb', line 12
def self.content(app_name)
snake_case_app_name = app_name.gsub(/([a-z])([A-Z])/, '\1_\2').downcase
" # typed: true\n # frozen_string_literal: true\n\n # First: check if all gems are installed correctly\n require \"bundler/setup\"\n\n # Second: load all gems\n # we have runtime/production (\"default\") and development gems (\"development\")\n Bundler.require(:default)\n Bundler.require(:development) if ENV[\"RACK_ENV\"] == \"development\"\n Bundler.require(:test) if ENV[\"RACK_ENV\"] == \"test\"\n\n # Third: load all initializers\n Dir[File.join(__dir__, \"config/initializers\", \"*.rb\")].each { require(_1) }\n\n # Fourth: load all application code\n APP_LOADER = Zeitwerk::Loader.new\n APP_LOADER.tag = File.basename(__FILE__, \".rb\")\n [\n \"/app\",\n \"/app/models\",\n \"/app/services\",\n ].each do |root_namespace|\n # a root namespace skips the auto-infered module for this folder\n # so we don't have to write e.g. `Models::` or `Services::`\n APP_LOADER.push_dir(\"\\\#{File.dirname(__FILE__)}\\\#{root_namespace}\")\n end\n APP_LOADER.setup\n\n # Fifth: load configs\n Dir[File.join(__dir__, \"config\", \"**\", \"*.rb\")].each do |cnf|\n next if cnf.split(\"/\").include?(\"initializers\")\n next if cnf.end_with?(\"puma.rb\") # Puma config uses DSL only available when loaded by Puma\n\n require(cnf)\n end\n\n class \#{app_name} < Kirei::App\n # Kirei configuration\n config.app_name = \"\#{snake_case_app_name}\"\n end\n\n APP_LOADER.eager_load\n RUBY\nend\n"
|