omg-railties 8.0.0.alpha3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (351) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +171 -0
  3. data/MIT-LICENSE +20 -0
  4. data/RDOC_MAIN.md +99 -0
  5. data/README.rdoc +39 -0
  6. data/exe/rails +10 -0
  7. data/lib/minitest/rails_plugin.rb +140 -0
  8. data/lib/rails/all.rb +21 -0
  9. data/lib/rails/api/generator.rb +38 -0
  10. data/lib/rails/api/task.rb +235 -0
  11. data/lib/rails/app_loader.rb +77 -0
  12. data/lib/rails/application/bootstrap.rb +118 -0
  13. data/lib/rails/application/configuration.rb +659 -0
  14. data/lib/rails/application/default_middleware_stack.rb +140 -0
  15. data/lib/rails/application/dummy_config.rb +19 -0
  16. data/lib/rails/application/finisher.rb +238 -0
  17. data/lib/rails/application/routes_reloader.rb +79 -0
  18. data/lib/rails/application.rb +658 -0
  19. data/lib/rails/application_controller.rb +28 -0
  20. data/lib/rails/autoloaders/inflector.rb +21 -0
  21. data/lib/rails/autoloaders.rb +48 -0
  22. data/lib/rails/backtrace_cleaner.rb +42 -0
  23. data/lib/rails/cli.rb +21 -0
  24. data/lib/rails/code_statistics.rb +159 -0
  25. data/lib/rails/code_statistics_calculator.rb +99 -0
  26. data/lib/rails/command/actions.rb +52 -0
  27. data/lib/rails/command/base.rb +185 -0
  28. data/lib/rails/command/behavior.rb +84 -0
  29. data/lib/rails/command/environment_argument.rb +56 -0
  30. data/lib/rails/command/helpers/editor.rb +40 -0
  31. data/lib/rails/command.rb +172 -0
  32. data/lib/rails/commands/about/about_command.rb +14 -0
  33. data/lib/rails/commands/app/update_command.rb +94 -0
  34. data/lib/rails/commands/application/application_command.rb +33 -0
  35. data/lib/rails/commands/boot/boot_command.rb +14 -0
  36. data/lib/rails/commands/console/console_command.rb +91 -0
  37. data/lib/rails/commands/console/irb_console.rb +136 -0
  38. data/lib/rails/commands/credentials/USAGE +73 -0
  39. data/lib/rails/commands/credentials/credentials_command/diffing.rb +53 -0
  40. data/lib/rails/commands/credentials/credentials_command.rb +139 -0
  41. data/lib/rails/commands/db/system/change/change_command.rb +26 -0
  42. data/lib/rails/commands/dbconsole/dbconsole_command.rb +88 -0
  43. data/lib/rails/commands/destroy/destroy_command.rb +29 -0
  44. data/lib/rails/commands/dev/dev_command.rb +14 -0
  45. data/lib/rails/commands/devcontainer/devcontainer_command.rb +39 -0
  46. data/lib/rails/commands/encrypted/USAGE +23 -0
  47. data/lib/rails/commands/encrypted/encrypted_command.rb +98 -0
  48. data/lib/rails/commands/gem_help/USAGE +16 -0
  49. data/lib/rails/commands/gem_help/gem_help_command.rb +13 -0
  50. data/lib/rails/commands/generate/generate_command.rb +30 -0
  51. data/lib/rails/commands/help/USAGE +17 -0
  52. data/lib/rails/commands/help/help_command.rb +34 -0
  53. data/lib/rails/commands/initializers/initializers_command.rb +20 -0
  54. data/lib/rails/commands/middleware/middleware_command.rb +17 -0
  55. data/lib/rails/commands/new/new_command.rb +21 -0
  56. data/lib/rails/commands/notes/notes_command.rb +30 -0
  57. data/lib/rails/commands/plugin/plugin_command.rb +47 -0
  58. data/lib/rails/commands/rake/rake_command.rb +55 -0
  59. data/lib/rails/commands/restart/restart_command.rb +14 -0
  60. data/lib/rails/commands/routes/routes_command.rb +49 -0
  61. data/lib/rails/commands/runner/USAGE +22 -0
  62. data/lib/rails/commands/runner/runner_command.rb +81 -0
  63. data/lib/rails/commands/secret/secret_command.rb +13 -0
  64. data/lib/rails/commands/server/server_command.rb +290 -0
  65. data/lib/rails/commands/stats/stats_command.rb +19 -0
  66. data/lib/rails/commands/test/USAGE +14 -0
  67. data/lib/rails/commands/test/test_command.rb +81 -0
  68. data/lib/rails/commands/unused_routes/unused_routes_command.rb +75 -0
  69. data/lib/rails/commands/version/version_command.rb +12 -0
  70. data/lib/rails/commands.rb +18 -0
  71. data/lib/rails/configuration.rb +170 -0
  72. data/lib/rails/console/app.rb +8 -0
  73. data/lib/rails/console/helpers.rb +8 -0
  74. data/lib/rails/console/methods.rb +23 -0
  75. data/lib/rails/deprecator.rb +7 -0
  76. data/lib/rails/dev_caching.rb +44 -0
  77. data/lib/rails/engine/commands.rb +9 -0
  78. data/lib/rails/engine/configuration.rb +138 -0
  79. data/lib/rails/engine/lazy_route_set.rb +109 -0
  80. data/lib/rails/engine/railties.rb +23 -0
  81. data/lib/rails/engine/updater.rb +21 -0
  82. data/lib/rails/engine.rb +760 -0
  83. data/lib/rails/gem_version.rb +17 -0
  84. data/lib/rails/generators/actions/create_migration.rb +75 -0
  85. data/lib/rails/generators/actions.rb +528 -0
  86. data/lib/rails/generators/active_model.rb +94 -0
  87. data/lib/rails/generators/app_base.rb +806 -0
  88. data/lib/rails/generators/app_name.rb +39 -0
  89. data/lib/rails/generators/base.rb +432 -0
  90. data/lib/rails/generators/database.rb +287 -0
  91. data/lib/rails/generators/erb/authentication/authentication_generator.rb +15 -0
  92. data/lib/rails/generators/erb/authentication/templates/views/passwords/edit.html.erb +9 -0
  93. data/lib/rails/generators/erb/authentication/templates/views/passwords/new.html.erb +8 -0
  94. data/lib/rails/generators/erb/authentication/templates/views/sessions/new.html.erb +11 -0
  95. data/lib/rails/generators/erb/controller/controller_generator.rb +24 -0
  96. data/lib/rails/generators/erb/controller/templates/view.html.erb.tt +2 -0
  97. data/lib/rails/generators/erb/mailer/mailer_generator.rb +41 -0
  98. data/lib/rails/generators/erb/mailer/templates/layout.html.erb.tt +13 -0
  99. data/lib/rails/generators/erb/mailer/templates/layout.text.erb.tt +1 -0
  100. data/lib/rails/generators/erb/mailer/templates/view.html.erb.tt +5 -0
  101. data/lib/rails/generators/erb/mailer/templates/view.text.erb.tt +3 -0
  102. data/lib/rails/generators/erb/scaffold/scaffold_generator.rb +34 -0
  103. data/lib/rails/generators/erb/scaffold/templates/_form.html.erb.tt +37 -0
  104. data/lib/rails/generators/erb/scaffold/templates/edit.html.erb.tt +12 -0
  105. data/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt +16 -0
  106. data/lib/rails/generators/erb/scaffold/templates/new.html.erb.tt +11 -0
  107. data/lib/rails/generators/erb/scaffold/templates/partial.html.erb.tt +17 -0
  108. data/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt +10 -0
  109. data/lib/rails/generators/erb.rb +26 -0
  110. data/lib/rails/generators/generated_attribute.rb +274 -0
  111. data/lib/rails/generators/migration.rb +71 -0
  112. data/lib/rails/generators/model_helpers.rb +62 -0
  113. data/lib/rails/generators/named_base.rb +227 -0
  114. data/lib/rails/generators/rails/app/USAGE +31 -0
  115. data/lib/rails/generators/rails/app/app_generator.rb +678 -0
  116. data/lib/rails/generators/rails/app/templates/Dockerfile.tt +119 -0
  117. data/lib/rails/generators/rails/app/templates/Gemfile.tt +83 -0
  118. data/lib/rails/generators/rails/app/templates/README.md.tt +24 -0
  119. data/lib/rails/generators/rails/app/templates/Rakefile.tt +6 -0
  120. data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css.tt +15 -0
  121. data/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt +6 -0
  122. data/lib/rails/generators/rails/app/templates/app/helpers/application_helper.rb.tt +2 -0
  123. data/lib/rails/generators/rails/app/templates/app/jobs/application_job.rb.tt +7 -0
  124. data/lib/rails/generators/rails/app/templates/app/mailers/application_mailer.rb.tt +4 -0
  125. data/lib/rails/generators/rails/app/templates/app/models/application_record.rb.tt +3 -0
  126. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +33 -0
  127. data/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.html.erb.tt +13 -0
  128. data/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.text.erb.tt +1 -0
  129. data/lib/rails/generators/rails/app/templates/app/views/pwa/manifest.json.erb.tt +22 -0
  130. data/lib/rails/generators/rails/app/templates/app/views/pwa/service-worker.js +26 -0
  131. data/lib/rails/generators/rails/app/templates/bin/brakeman.tt +6 -0
  132. data/lib/rails/generators/rails/app/templates/bin/dev.tt +1 -0
  133. data/lib/rails/generators/rails/app/templates/bin/rails.tt +3 -0
  134. data/lib/rails/generators/rails/app/templates/bin/rake.tt +3 -0
  135. data/lib/rails/generators/rails/app/templates/bin/rubocop.tt +7 -0
  136. data/lib/rails/generators/rails/app/templates/bin/setup.tt +45 -0
  137. data/lib/rails/generators/rails/app/templates/bin/thrust.tt +4 -0
  138. data/lib/rails/generators/rails/app/templates/config/application.rb.tt +42 -0
  139. data/lib/rails/generators/rails/app/templates/config/boot.rb.tt +6 -0
  140. data/lib/rails/generators/rails/app/templates/config/cable.yml.tt +10 -0
  141. data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +82 -0
  142. data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +114 -0
  143. data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +72 -0
  144. data/lib/rails/generators/rails/app/templates/config/databases/trilogy.yml.tt +82 -0
  145. data/lib/rails/generators/rails/app/templates/config/deploy.yml.tt +107 -0
  146. data/lib/rails/generators/rails/app/templates/config/environment.rb.tt +5 -0
  147. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +89 -0
  148. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +125 -0
  149. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +62 -0
  150. data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +7 -0
  151. data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +25 -0
  152. data/lib/rails/generators/rails/app/templates/config/initializers/cors.rb.tt +16 -0
  153. data/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt +8 -0
  154. data/lib/rails/generators/rails/app/templates/config/initializers/inflections.rb.tt +16 -0
  155. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_8_0.rb.tt +25 -0
  156. data/lib/rails/generators/rails/app/templates/config/locales/en.yml +31 -0
  157. data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +43 -0
  158. data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +16 -0
  159. data/lib/rails/generators/rails/app/templates/config/storage.yml.tt +34 -0
  160. data/lib/rails/generators/rails/app/templates/config.ru.tt +6 -0
  161. data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +9 -0
  162. data/lib/rails/generators/rails/app/templates/docker-entrypoint.tt +16 -0
  163. data/lib/rails/generators/rails/app/templates/dockerignore.tt +56 -0
  164. data/lib/rails/generators/rails/app/templates/env.erb.tt +5 -0
  165. data/lib/rails/generators/rails/app/templates/gitattributes.tt +9 -0
  166. data/lib/rails/generators/rails/app/templates/github/ci.yml.tt +138 -0
  167. data/lib/rails/generators/rails/app/templates/github/dependabot.yml +12 -0
  168. data/lib/rails/generators/rails/app/templates/gitignore.tt +38 -0
  169. data/lib/rails/generators/rails/app/templates/node-version.tt +1 -0
  170. data/lib/rails/generators/rails/app/templates/public/400.html +67 -0
  171. data/lib/rails/generators/rails/app/templates/public/404.html +67 -0
  172. data/lib/rails/generators/rails/app/templates/public/406-unsupported-browser.html +66 -0
  173. data/lib/rails/generators/rails/app/templates/public/422.html +67 -0
  174. data/lib/rails/generators/rails/app/templates/public/500.html +66 -0
  175. data/lib/rails/generators/rails/app/templates/public/icon.png +0 -0
  176. data/lib/rails/generators/rails/app/templates/public/icon.svg +3 -0
  177. data/lib/rails/generators/rails/app/templates/public/robots.txt +1 -0
  178. data/lib/rails/generators/rails/app/templates/rubocop.yml.tt +8 -0
  179. data/lib/rails/generators/rails/app/templates/ruby-version.tt +1 -0
  180. data/lib/rails/generators/rails/app/templates/test/application_system_test_case.rb.tt +5 -0
  181. data/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt +21 -0
  182. data/lib/rails/generators/rails/application_record/application_record_generator.rb +13 -0
  183. data/lib/rails/generators/rails/authentication/USAGE +6 -0
  184. data/lib/rails/generators/rails/authentication/authentication_generator.rb +54 -0
  185. data/lib/rails/generators/rails/authentication/templates/controllers/concerns/authentication.rb +55 -0
  186. data/lib/rails/generators/rails/authentication/templates/controllers/passwords_controller.rb +33 -0
  187. data/lib/rails/generators/rails/authentication/templates/controllers/sessions_controller.rb +21 -0
  188. data/lib/rails/generators/rails/authentication/templates/mailers/passwords_mailer.rb +6 -0
  189. data/lib/rails/generators/rails/authentication/templates/models/current.rb +4 -0
  190. data/lib/rails/generators/rails/authentication/templates/models/session.rb +3 -0
  191. data/lib/rails/generators/rails/authentication/templates/models/user.rb +6 -0
  192. data/lib/rails/generators/rails/authentication/templates/test/mailers/previews/passwords_mailer_preview.rb +7 -0
  193. data/lib/rails/generators/rails/authentication/templates/views/passwords_mailer/reset.html.erb +4 -0
  194. data/lib/rails/generators/rails/authentication/templates/views/passwords_mailer/reset.text.erb +2 -0
  195. data/lib/rails/generators/rails/benchmark/USAGE +19 -0
  196. data/lib/rails/generators/rails/benchmark/benchmark_generator.rb +30 -0
  197. data/lib/rails/generators/rails/benchmark/templates/benchmark.rb.tt +15 -0
  198. data/lib/rails/generators/rails/controller/USAGE +26 -0
  199. data/lib/rails/generators/rails/controller/controller_generator.rb +42 -0
  200. data/lib/rails/generators/rails/controller/templates/controller.rb.tt +9 -0
  201. data/lib/rails/generators/rails/credentials/credentials_generator.rb +61 -0
  202. data/lib/rails/generators/rails/credentials/templates/credentials.yml.tt +12 -0
  203. data/lib/rails/generators/rails/db/system/change/change_generator.rb +206 -0
  204. data/lib/rails/generators/rails/devcontainer/devcontainer_generator.rb +168 -0
  205. data/lib/rails/generators/rails/devcontainer/templates/devcontainer/Dockerfile.tt +3 -0
  206. data/lib/rails/generators/rails/devcontainer/templates/devcontainer/compose.yaml.tt +47 -0
  207. data/lib/rails/generators/rails/devcontainer/templates/devcontainer/devcontainer.json.tt +37 -0
  208. data/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb +31 -0
  209. data/lib/rails/generators/rails/encryption_key_file/encryption_key_file_generator.rb +57 -0
  210. data/lib/rails/generators/rails/generator/USAGE +13 -0
  211. data/lib/rails/generators/rails/generator/generator_generator.rb +27 -0
  212. data/lib/rails/generators/rails/generator/templates/%file_name%_generator.rb.tt +3 -0
  213. data/lib/rails/generators/rails/generator/templates/USAGE.tt +8 -0
  214. data/lib/rails/generators/rails/generator/templates/templates/.empty_directory +0 -0
  215. data/lib/rails/generators/rails/helper/USAGE +12 -0
  216. data/lib/rails/generators/rails/helper/helper_generator.rb +20 -0
  217. data/lib/rails/generators/rails/helper/templates/helper.rb.tt +4 -0
  218. data/lib/rails/generators/rails/integration_test/USAGE +10 -0
  219. data/lib/rails/generators/rails/integration_test/integration_test_generator.rb +9 -0
  220. data/lib/rails/generators/rails/master_key/master_key_generator.rb +53 -0
  221. data/lib/rails/generators/rails/migration/USAGE +45 -0
  222. data/lib/rails/generators/rails/migration/migration_generator.rb +14 -0
  223. data/lib/rails/generators/rails/model/model_generator.rb +18 -0
  224. data/lib/rails/generators/rails/plugin/USAGE +21 -0
  225. data/lib/rails/generators/rails/plugin/plugin_generator.rb +499 -0
  226. data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +28 -0
  227. data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +23 -0
  228. data/lib/rails/generators/rails/plugin/templates/MIT-LICENSE.tt +20 -0
  229. data/lib/rails/generators/rails/plugin/templates/README.md.tt +28 -0
  230. data/lib/rails/generators/rails/plugin/templates/Rakefile.tt +14 -0
  231. data/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +5 -0
  232. data/lib/rails/generators/rails/plugin/templates/app/helpers/%namespaced_name%/application_helper.rb.tt +5 -0
  233. data/lib/rails/generators/rails/plugin/templates/app/jobs/%namespaced_name%/application_job.rb.tt +5 -0
  234. data/lib/rails/generators/rails/plugin/templates/app/mailers/%namespaced_name%/application_mailer.rb.tt +7 -0
  235. data/lib/rails/generators/rails/plugin/templates/app/models/%namespaced_name%/application_record.rb.tt +6 -0
  236. data/lib/rails/generators/rails/plugin/templates/app/views/layouts/%namespaced_name%/application.html.erb.tt +17 -0
  237. data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +15 -0
  238. data/lib/rails/generators/rails/plugin/templates/bin/rubocop.tt +7 -0
  239. data/lib/rails/generators/rails/plugin/templates/bin/test.tt +4 -0
  240. data/lib/rails/generators/rails/plugin/templates/config/routes.rb.tt +6 -0
  241. data/lib/rails/generators/rails/plugin/templates/github/ci.yml.tt +103 -0
  242. data/lib/rails/generators/rails/plugin/templates/github/dependabot.yml +12 -0
  243. data/lib/rails/generators/rails/plugin/templates/gitignore.tt +14 -0
  244. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb.tt +7 -0
  245. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/railtie.rb.tt +5 -0
  246. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/version.rb.tt +1 -0
  247. data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%.rb.tt +8 -0
  248. data/lib/rails/generators/rails/plugin/templates/lib/tasks/%namespaced_name%_tasks.rake.tt +4 -0
  249. data/lib/rails/generators/rails/plugin/templates/rails/boot.rb.tt +5 -0
  250. data/lib/rails/generators/rails/plugin/templates/rails/routes.rb.tt +3 -0
  251. data/lib/rails/generators/rails/plugin/templates/rails/stylesheets.css +15 -0
  252. data/lib/rails/generators/rails/plugin/templates/rubocop.yml.tt +8 -0
  253. data/lib/rails/generators/rails/plugin/templates/test/%namespaced_name%_test.rb.tt +7 -0
  254. data/lib/rails/generators/rails/plugin/templates/test/application_system_test_case.rb.tt +5 -0
  255. data/lib/rails/generators/rails/plugin/templates/test/integration/navigation_test.rb.tt +7 -0
  256. data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +21 -0
  257. data/lib/rails/generators/rails/resource/USAGE +23 -0
  258. data/lib/rails/generators/rails/resource/resource_generator.rb +27 -0
  259. data/lib/rails/generators/rails/resource_route/resource_route_generator.rb +23 -0
  260. data/lib/rails/generators/rails/scaffold/USAGE +41 -0
  261. data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +18 -0
  262. data/lib/rails/generators/rails/scaffold_controller/USAGE +19 -0
  263. data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +56 -0
  264. data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb.tt +57 -0
  265. data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt +64 -0
  266. data/lib/rails/generators/rails/script/USAGE +18 -0
  267. data/lib/rails/generators/rails/script/script_generator.rb +18 -0
  268. data/lib/rails/generators/rails/script/templates/script.rb.tt +3 -0
  269. data/lib/rails/generators/rails/system_test/USAGE +10 -0
  270. data/lib/rails/generators/rails/system_test/system_test_generator.rb +9 -0
  271. data/lib/rails/generators/rails/task/USAGE +9 -0
  272. data/lib/rails/generators/rails/task/task_generator.rb +13 -0
  273. data/lib/rails/generators/rails/task/templates/task.rb.tt +8 -0
  274. data/lib/rails/generators/resource_helpers.rb +82 -0
  275. data/lib/rails/generators/test_case.rb +37 -0
  276. data/lib/rails/generators/test_unit/controller/controller_generator.rb +19 -0
  277. data/lib/rails/generators/test_unit/controller/templates/functional_test.rb.tt +23 -0
  278. data/lib/rails/generators/test_unit/generator/generator_generator.rb +27 -0
  279. data/lib/rails/generators/test_unit/generator/templates/generator_test.rb.tt +16 -0
  280. data/lib/rails/generators/test_unit/helper/helper_generator.rb +11 -0
  281. data/lib/rails/generators/test_unit/integration/integration_generator.rb +20 -0
  282. data/lib/rails/generators/test_unit/integration/templates/integration_test.rb.tt +9 -0
  283. data/lib/rails/generators/test_unit/job/job_generator.rb +20 -0
  284. data/lib/rails/generators/test_unit/job/templates/unit_test.rb.tt +9 -0
  285. data/lib/rails/generators/test_unit/mailer/mailer_generator.rb +28 -0
  286. data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb.tt +23 -0
  287. data/lib/rails/generators/test_unit/mailer/templates/preview.rb.tt +14 -0
  288. data/lib/rails/generators/test_unit/model/model_generator.rb +37 -0
  289. data/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt +29 -0
  290. data/lib/rails/generators/test_unit/model/templates/unit_test.rb.tt +9 -0
  291. data/lib/rails/generators/test_unit/plugin/plugin_generator.rb +15 -0
  292. data/lib/rails/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +7 -0
  293. data/lib/rails/generators/test_unit/plugin/templates/test_helper.rb +2 -0
  294. data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +82 -0
  295. data/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb.tt +44 -0
  296. data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt +54 -0
  297. data/lib/rails/generators/test_unit/scaffold/templates/system_test.rb.tt +57 -0
  298. data/lib/rails/generators/test_unit/system/system_generator.rb +24 -0
  299. data/lib/rails/generators/test_unit/system/templates/application_system_test_case.rb.tt +5 -0
  300. data/lib/rails/generators/test_unit/system/templates/system_test.rb.tt +9 -0
  301. data/lib/rails/generators/test_unit.rb +10 -0
  302. data/lib/rails/generators/testing/assertions.rb +147 -0
  303. data/lib/rails/generators/testing/behavior.rb +116 -0
  304. data/lib/rails/generators/testing/setup_and_teardown.rb +20 -0
  305. data/lib/rails/generators.rb +327 -0
  306. data/lib/rails/health_controller.rb +55 -0
  307. data/lib/rails/info.rb +105 -0
  308. data/lib/rails/info_controller.rb +71 -0
  309. data/lib/rails/initializable.rb +95 -0
  310. data/lib/rails/mailers_controller.rb +122 -0
  311. data/lib/rails/paths.rb +246 -0
  312. data/lib/rails/plugin/test.rb +9 -0
  313. data/lib/rails/pwa_controller.rb +15 -0
  314. data/lib/rails/rack/logger.rb +88 -0
  315. data/lib/rails/rack/silence_request.rb +33 -0
  316. data/lib/rails/rack.rb +8 -0
  317. data/lib/rails/rackup/server.rb +15 -0
  318. data/lib/rails/railtie/configurable.rb +36 -0
  319. data/lib/rails/railtie/configuration.rb +114 -0
  320. data/lib/rails/railtie.rb +302 -0
  321. data/lib/rails/source_annotation_extractor.rb +214 -0
  322. data/lib/rails/tasks/engine.rake +85 -0
  323. data/lib/rails/tasks/framework.rake +34 -0
  324. data/lib/rails/tasks/log.rake +41 -0
  325. data/lib/rails/tasks/misc.rake +68 -0
  326. data/lib/rails/tasks/statistics.rake +23 -0
  327. data/lib/rails/tasks/tmp.rake +51 -0
  328. data/lib/rails/tasks/yarn.rake +29 -0
  329. data/lib/rails/tasks/zeitwerk.rake +41 -0
  330. data/lib/rails/tasks.rb +17 -0
  331. data/lib/rails/templates/layouts/application.html.erb +51 -0
  332. data/lib/rails/templates/rails/info/notes.html.erb +65 -0
  333. data/lib/rails/templates/rails/info/properties.html.erb +1 -0
  334. data/lib/rails/templates/rails/info/routes.html.erb +9 -0
  335. data/lib/rails/templates/rails/mailers/email.html.erb +201 -0
  336. data/lib/rails/templates/rails/mailers/index.html.erb +15 -0
  337. data/lib/rails/templates/rails/mailers/mailer.html.erb +12 -0
  338. data/lib/rails/templates/rails/welcome/index.html.erb +93 -0
  339. data/lib/rails/test_help.rb +47 -0
  340. data/lib/rails/test_unit/line_filtering.rb +13 -0
  341. data/lib/rails/test_unit/railtie.rb +25 -0
  342. data/lib/rails/test_unit/reporter.rb +121 -0
  343. data/lib/rails/test_unit/runner.rb +209 -0
  344. data/lib/rails/test_unit/test_parser.rb +133 -0
  345. data/lib/rails/test_unit/testing.rake +39 -0
  346. data/lib/rails/testing/maintain_test_schema.rb +16 -0
  347. data/lib/rails/version.rb +10 -0
  348. data/lib/rails/welcome_controller.rb +11 -0
  349. data/lib/rails/zeitwerk_checker.rb +15 -0
  350. data/lib/rails.rb +130 -0
  351. metadata +518 -0
@@ -0,0 +1,136 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "irb/helper_method"
4
+ require "irb/command"
5
+
6
+ module Rails
7
+ class Console
8
+ class RailsHelperBase < IRB::HelperMethod::Base
9
+ include ConsoleMethods
10
+ end
11
+
12
+ class ControllerHelper < RailsHelperBase
13
+ description "Gets helper methods available to ApplicationController."
14
+
15
+ # This method assumes an +ApplicationController+ exists, and that it extends ActionController::Base.
16
+ def execute
17
+ ApplicationController.helpers
18
+ end
19
+ end
20
+
21
+ class ControllerInstance < RailsHelperBase
22
+ description "Gets a new instance of ApplicationController."
23
+
24
+ # This method assumes an +ApplicationController+ exists, and that it extends ActionController::Base.
25
+ def execute
26
+ @controller ||= ApplicationController.new
27
+ end
28
+ end
29
+
30
+ class NewSession < RailsHelperBase
31
+ description "[Deprecated] Please use `app(true)` instead."
32
+
33
+ def execute(*)
34
+ app = Rails.application
35
+ session = ActionDispatch::Integration::Session.new(app)
36
+
37
+ # This makes app.url_for and app.foo_path available in the console
38
+ session.extend(app.routes.url_helpers)
39
+ session.extend(app.routes.mounted_helpers)
40
+
41
+ session
42
+ end
43
+ end
44
+
45
+ class AppInstance < NewSession
46
+ description "Creates a new ActionDispatch::Integration::Session and memoizes it. Use `app(true)` to create a new instance."
47
+
48
+ def execute(create = false)
49
+ @app_integration_instance = nil if create
50
+ @app_integration_instance ||= super
51
+ end
52
+ end
53
+
54
+ class Reloader < IRB::Command::Base
55
+ include ConsoleMethods
56
+
57
+ category "Rails console"
58
+ description "Reloads the Rails application."
59
+
60
+ def execute(*)
61
+ puts "Reloading..."
62
+ Rails.application.reloader.reload!
63
+ end
64
+ end
65
+
66
+ IRB::HelperMethod.register(:helper, ControllerHelper)
67
+ IRB::HelperMethod.register(:controller, ControllerInstance)
68
+ IRB::HelperMethod.register(:new_session, NewSession)
69
+ IRB::HelperMethod.register(:app, AppInstance)
70
+ IRB::Command.register(:reload!, Reloader)
71
+
72
+ class IRBConsole
73
+ def initialize(app)
74
+ @app = app
75
+
76
+ require "irb"
77
+ require "irb/completion"
78
+ end
79
+
80
+ def name
81
+ "IRB"
82
+ end
83
+
84
+ def start
85
+ IRB.setup(nil)
86
+
87
+ if !Rails.env.local? && !ENV.key?("IRB_USE_AUTOCOMPLETE")
88
+ IRB.conf[:USE_AUTOCOMPLETE] = false
89
+ end
90
+
91
+ env = colorized_env
92
+ prompt_prefix = "%N(#{env})"
93
+ IRB.conf[:IRB_NAME] = @app.name
94
+
95
+ IRB.conf[:PROMPT][:RAILS_PROMPT] = {
96
+ PROMPT_I: "#{prompt_prefix}> ",
97
+ PROMPT_S: "#{prompt_prefix}%l ",
98
+ PROMPT_C: "#{prompt_prefix}* ",
99
+ RETURN: "=> %s\n"
100
+ }
101
+
102
+ if current_filter = IRB.conf[:BACKTRACE_FILTER]
103
+ IRB.conf[:BACKTRACE_FILTER] = -> (backtrace) do
104
+ backtrace = current_filter.call(backtrace)
105
+ Rails.backtrace_cleaner.filter(backtrace)
106
+ end
107
+ else
108
+ IRB.conf[:BACKTRACE_FILTER] = -> (backtrace) do
109
+ Rails.backtrace_cleaner.filter(backtrace)
110
+ end
111
+ end
112
+
113
+ # Because some users/libs use Rails::ConsoleMethods to extend Rails console,
114
+ # we still include it for backward compatibility.
115
+ IRB::ExtendCommandBundle.include ConsoleMethods
116
+
117
+ # Respect user's choice of prompt mode.
118
+ IRB.conf[:PROMPT_MODE] = :RAILS_PROMPT if IRB.conf[:PROMPT_MODE] == :DEFAULT
119
+ IRB::Irb.new.run(IRB.conf)
120
+ end
121
+
122
+ def colorized_env
123
+ case Rails.env
124
+ when "development"
125
+ IRB::Color.colorize("dev", [:BLUE])
126
+ when "test"
127
+ IRB::Color.colorize("test", [:BLUE])
128
+ when "production"
129
+ IRB::Color.colorize("prod", [:RED])
130
+ else
131
+ Rails.env
132
+ end
133
+ end
134
+ end
135
+ end
136
+ end
@@ -0,0 +1,73 @@
1
+ Description:
2
+ The Rails `credentials` commands provide access to encrypted credentials,
3
+ so you can safely store access tokens, database passwords, and the like
4
+ safely inside the app without relying on a mess of ENVs.
5
+
6
+ This also allows for atomic deploys: no need to coordinate key changes
7
+ to get everything working as the keys are shipped with the code.
8
+
9
+ Setup:
10
+ Applications after Rails 5.2 automatically have a basic credentials file generated
11
+ that just contains the secret_key_base used by MessageVerifiers/MessageEncryptors, like the ones
12
+ signing and encrypting cookies.
13
+
14
+ For applications created prior to Rails 5.2, we'll automatically generate a new
15
+ credentials file in `config/credentials.yml.enc` the first time you run `<%= executable(:edit) %>`.
16
+ If you didn't have a master key saved in `config/master.key`, that'll be created too.
17
+
18
+ Don't lose this master key! Put it in a password manager your team can access.
19
+ Should you lose it no one, including you, will be able to access any encrypted
20
+ credentials.
21
+
22
+ Don't commit the key! Add `config/master.key` to your source control's
23
+ ignore file. If you use Git, Rails handles this for you.
24
+
25
+ Rails also looks for the master key in `ENV["RAILS_MASTER_KEY"]`, in case that
26
+ is easier to manage. You could set `RAILS_MASTER_KEY` in a deployment
27
+ configuration, or you could prepend it to your server's start command like so:
28
+
29
+ RAILS_MASTER_KEY="very-secret-and-secure" bin/rails server
30
+
31
+ If `ENV["RAILS_MASTER_KEY"]` is present, it takes precedence over
32
+ `config/master.key`.
33
+
34
+ Set up Git to Diff Credentials:
35
+ Rails provides `<%= executable(:diff) %> --enroll` to instruct Git to call
36
+ `<%= executable(:diff) %>` when `git diff` is run on a credentials file.
37
+
38
+ Running the command enrolls the project such that all credentials files use the
39
+ "rails_credentials" diff driver in .gitattributes.
40
+
41
+ Additionally, since Git requires the driver itself to be set up in a config file
42
+ that isn't tracked, Rails automatically ensures it's configured when running
43
+ `<%= executable(:edit) %>`.
44
+
45
+ Otherwise each co-worker would have to run enable manually, including on each new
46
+ repo clone.
47
+
48
+ To disenroll from this feature, run `<%= executable(:diff) %> --disenroll`.
49
+
50
+ Editing Credentials:
51
+ `<%= executable(:edit) %>` will open a temporary file in `$VISUAL` or `$EDITOR`
52
+ with the decrypted contents to edit the encrypted credentials.
53
+
54
+ When the temporary file is next saved the contents are encrypted and written to
55
+ `config/credentials.yml.enc` while the file itself is destroyed to prevent credentials
56
+ from leaking.
57
+
58
+ Environment Specific Credentials:
59
+ The `credentials` command supports passing an `--environment` option to create an
60
+ environment specific override. That override will take precedence over the
61
+ global `config/credentials.yml.enc` file when running in that environment. So:
62
+
63
+ <%= executable(:edit) %> --environment development
64
+
65
+ will create `config/credentials/development.yml.enc` with the corresponding
66
+ encryption key in `config/credentials/development.key` if the credentials file
67
+ doesn't exist.
68
+
69
+ In addition to that, the default credentials lookup paths can be overridden through
70
+ `config.credentials.content_path` and `config.credentials.key_path`.
71
+
72
+ Just as with `config/master.key`, `ENV["RAILS_MASTER_KEY"]` takes precedence
73
+ over any environment specific or specially configured key files.
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rails::Command::CredentialsCommand::Diffing # :nodoc:
4
+ GITATTRIBUTES_ENTRY = <<~END
5
+ config/credentials/*.yml.enc diff=rails_credentials
6
+ config/credentials.yml.enc diff=rails_credentials
7
+ END
8
+
9
+ def enroll_project_in_credentials_diffing
10
+ if enrolled_in_credentials_diffing?
11
+ say "Project is already enrolled in credentials file diffing."
12
+ else
13
+ gitattributes.write(GITATTRIBUTES_ENTRY, mode: "a")
14
+
15
+ say "Enrolled project in credentials file diffing!"
16
+ say ""
17
+ say "Rails will configure the Git diff driver for credentials when running `#{executable(:edit)}`. See `#{executable(:help)}` for more information."
18
+ end
19
+ end
20
+
21
+ def disenroll_project_from_credentials_diffing
22
+ if enrolled_in_credentials_diffing?
23
+ gitattributes.write(gitattributes.read.gsub(GITATTRIBUTES_ENTRY, ""))
24
+ gitattributes.delete if gitattributes.empty?
25
+
26
+ say "Disenrolled project from credentials file diffing!"
27
+ else
28
+ say "Project is not enrolled in credentials file diffing."
29
+ end
30
+ end
31
+
32
+ def ensure_diffing_driver_is_configured
33
+ configure_diffing_driver if enrolled_in_credentials_diffing? && !diffing_driver_configured?
34
+ end
35
+
36
+ private
37
+ def enrolled_in_credentials_diffing?
38
+ gitattributes.file? && gitattributes.read.include?(GITATTRIBUTES_ENTRY)
39
+ end
40
+
41
+ def diffing_driver_configured?
42
+ system "git config --get diff.rails_credentials.textconv", out: File::NULL
43
+ end
44
+
45
+ def configure_diffing_driver
46
+ system "git config diff.rails_credentials.textconv '#{executable(:diff)}'"
47
+ say "Configured Git diff driver for credentials."
48
+ end
49
+
50
+ def gitattributes
51
+ @gitattributes ||= (Rails::Command.root || Pathname.pwd).join(".gitattributes")
52
+ end
53
+ end
@@ -0,0 +1,139 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+ require "active_support"
5
+ require "rails/command/helpers/editor"
6
+ require "rails/command/environment_argument"
7
+
8
+ module Rails
9
+ module Command
10
+ class CredentialsCommand < Rails::Command::Base # :nodoc:
11
+ include Helpers::Editor
12
+ include EnvironmentArgument
13
+
14
+ require_relative "credentials_command/diffing"
15
+ include Diffing
16
+
17
+ desc "edit", "Open the decrypted credentials in `$VISUAL` or `$EDITOR` for editing"
18
+ def edit
19
+ load_environment_config!
20
+ load_generators
21
+
22
+ if environment_specified?
23
+ @content_path = "config/credentials/#{environment}.yml.enc" unless config.overridden?(:content_path)
24
+ @key_path = "config/credentials/#{environment}.key" unless config.overridden?(:key_path)
25
+ end
26
+
27
+ ensure_encryption_key_has_been_added
28
+ ensure_credentials_have_been_added
29
+ ensure_diffing_driver_is_configured
30
+
31
+ change_credentials_in_system_editor
32
+ end
33
+
34
+ desc "show", "Show the decrypted credentials"
35
+ def show
36
+ load_environment_config!
37
+
38
+ say credentials.read.presence || missing_credentials_message
39
+ end
40
+
41
+ desc "diff", "Enroll/disenroll in decrypted diffs of credentials using git"
42
+ option :enroll, type: :boolean, default: false,
43
+ desc: "Enroll project in credentials file diffing with `git diff`"
44
+ option :disenroll, type: :boolean, default: false,
45
+ desc: "Disenroll project from credentials file diffing"
46
+ def diff(content_path = nil)
47
+ if @content_path = content_path
48
+ self.environment = extract_environment_from_path(content_path)
49
+ load_environment_config!
50
+
51
+ say credentials.read.presence || credentials.content_path.read
52
+ else
53
+ disenroll_project_from_credentials_diffing if options[:disenroll]
54
+ enroll_project_in_credentials_diffing if options[:enroll]
55
+ end
56
+ rescue ActiveSupport::MessageEncryptor::InvalidMessage
57
+ say credentials.content_path.read
58
+ end
59
+
60
+ private
61
+ def config
62
+ Rails.application.config.credentials
63
+ end
64
+
65
+ def content_path
66
+ @content_path ||= relative_path(config.content_path)
67
+ end
68
+
69
+ def key_path
70
+ @key_path ||= relative_path(config.key_path)
71
+ end
72
+
73
+ def credentials
74
+ @credentials ||= Rails.application.encrypted(content_path, key_path: key_path)
75
+ end
76
+
77
+ def ensure_encryption_key_has_been_added
78
+ return if credentials.key?
79
+
80
+ require "rails/generators/rails/encryption_key_file/encryption_key_file_generator"
81
+
82
+ encryption_key_file_generator = Rails::Generators::EncryptionKeyFileGenerator.new
83
+ encryption_key_file_generator.add_key_file(key_path)
84
+ encryption_key_file_generator.ignore_key_file(key_path)
85
+ end
86
+
87
+ def ensure_credentials_have_been_added
88
+ require "rails/generators/rails/credentials/credentials_generator"
89
+
90
+ Rails::Generators::CredentialsGenerator.new(
91
+ [content_path, key_path],
92
+ skip_secret_key_base: environment_specified? && %w[development test].include?(environment),
93
+ quiet: true
94
+ ).invoke_all
95
+ end
96
+
97
+ def change_credentials_in_system_editor
98
+ using_system_editor do
99
+ say "Editing #{content_path}..."
100
+ credentials.change { |tmp_path| system_editor(tmp_path) }
101
+ say "File encrypted and saved."
102
+ warn_if_credentials_are_invalid
103
+ end
104
+ rescue ActiveSupport::EncryptedFile::MissingKeyError => error
105
+ say error.message
106
+ rescue ActiveSupport::MessageEncryptor::InvalidMessage
107
+ say "Couldn't decrypt #{content_path}. Perhaps you passed the wrong key?"
108
+ end
109
+
110
+ def warn_if_credentials_are_invalid
111
+ credentials.validate!
112
+ rescue ActiveSupport::EncryptedConfiguration::InvalidContentError => error
113
+ say "WARNING: #{error.message}", :red
114
+ say ""
115
+ say "Your application will not be able to load '#{content_path}' until the error has been fixed.", :red
116
+ end
117
+
118
+ def missing_credentials_message
119
+ if !credentials.key?
120
+ "Missing '#{key_path}' to decrypt credentials. See `#{executable(:help)}`."
121
+ else
122
+ "File '#{content_path}' does not exist. Use `#{executable(:edit)}` to change that."
123
+ end
124
+ end
125
+
126
+ def relative_path(path)
127
+ Rails.root.join(path).relative_path_from(Rails.root).to_s
128
+ end
129
+
130
+ def extract_environment_from_path(path)
131
+ available_environments.find { |env| path.end_with?("#{env}.yml.enc") } || extract_custom_environment(path)
132
+ end
133
+
134
+ def extract_custom_environment(path)
135
+ path =~ %r{config/credentials/(.+)\.yml\.enc} && $1
136
+ end
137
+ end
138
+ end
139
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators"
4
+ require "rails/generators/rails/db/system/change/change_generator"
5
+
6
+ module Rails
7
+ module Command
8
+ module Db
9
+ module System
10
+ class ChangeCommand < Base # :nodoc:
11
+ class_option :to, desc: "The database system to switch to."
12
+
13
+ def initialize(positional_args, option_args, *)
14
+ @argv = positional_args + option_args
15
+ super
16
+ end
17
+
18
+ desc "change", "Change `config/database.yml` and your database gem to the target database"
19
+ def perform(*)
20
+ Rails::Generators::Db::System::ChangeGenerator.start(@argv)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/core_ext/string/filters"
4
+ require "rails/command/environment_argument"
5
+
6
+ module Rails
7
+ class DBConsole
8
+ def self.start(*args)
9
+ new(*args).start
10
+ end
11
+
12
+ def initialize(options = {})
13
+ @options = options
14
+ @options[:environment] ||= Rails::Command.environment
15
+ end
16
+
17
+ def start
18
+ adapter_class.dbconsole(db_config, @options)
19
+ rescue NotImplementedError, ActiveRecord::AdapterNotFound, LoadError => error
20
+ abort error.message
21
+ end
22
+
23
+ def db_config
24
+ @db_config ||= begin
25
+ # If the user provided a database, use that. Otherwise find
26
+ # the first config in the database.yml
27
+ config = if database
28
+ @db_config = configurations.configs_for(env_name: environment, name: database, include_hidden: true)
29
+ else
30
+ @db_config = configurations.find_db_config(environment)
31
+ end
32
+
33
+ unless config
34
+ missing_db = database ? "'#{database}' database is not" : "No databases are"
35
+ raise ActiveRecord::AdapterNotSpecified,
36
+ "#{missing_db} configured for '#{environment}'. Available configuration: #{configurations.inspect}"
37
+ end
38
+
39
+ config.validate!
40
+ config
41
+ end
42
+ end
43
+
44
+ def database
45
+ @options[:database]
46
+ end
47
+
48
+ def environment
49
+ @options[:environment]
50
+ end
51
+
52
+ private
53
+ def adapter_class
54
+ ActiveRecord::ConnectionAdapters.resolve(db_config.adapter)
55
+ rescue LoadError
56
+ ActiveRecord::ConnectionAdapters::AbstractAdapter
57
+ end
58
+
59
+ def configurations # :doc:
60
+ require APP_PATH
61
+ ActiveRecord::Base.configurations = Rails.application.config.database_configuration
62
+ ActiveRecord::Base.configurations
63
+ end
64
+ end
65
+
66
+ module Command
67
+ class DbconsoleCommand < Base # :nodoc:
68
+ include EnvironmentArgument
69
+
70
+ class_option :include_password, aliases: "-p", type: :boolean,
71
+ desc: "Automatically provide the password from database.yml"
72
+
73
+ class_option :mode, enum: %w( html list line column ), type: :string,
74
+ desc: "Automatically put the sqlite3 database in the specified mode"
75
+
76
+ class_option :header, type: :boolean
77
+
78
+ class_option :database, aliases: "--db", type: :string,
79
+ desc: "Specify the database to use."
80
+
81
+ desc "dbconsole", "Start a console for the database specified in config/database.yml"
82
+ def perform
83
+ boot_application!
84
+ Rails::DBConsole.start(options)
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators"
4
+
5
+ module Rails
6
+ module Command
7
+ class DestroyCommand < Base # :nodoc:
8
+ no_commands do
9
+ def help
10
+ boot_application!
11
+ load_generators
12
+
13
+ Rails::Generators.help self.class.command_name
14
+ end
15
+ end
16
+
17
+ desc "destroy GENERATOR", "Remove code generated by `bin/rails generate`"
18
+ def perform(*)
19
+ generator = args.shift
20
+ return help unless generator
21
+
22
+ boot_application!
23
+ load_generators
24
+
25
+ Rails::Generators.invoke generator, args, behavior: :revoke, destination_root: Rails::Command.root
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/dev_caching"
4
+
5
+ module Rails
6
+ module Command
7
+ class DevCommand < Base # :nodoc:
8
+ desc "cache", "Toggle Action Controller development mode caching on/off"
9
+ def cache
10
+ Rails::DevCaching.enable_by_file
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators"
4
+ require "rails/generators/rails/devcontainer/devcontainer_generator"
5
+
6
+ module Rails
7
+ module Command
8
+ class DevcontainerCommand < Base # :nodoc:
9
+ desc "devcontainer", "Generate a Dev Container setup based on current application configuration"
10
+ def perform(*)
11
+ boot_application!
12
+
13
+ say "Generating Dev Container with the following options:"
14
+ devcontainer_options.each do |option, value|
15
+ say "#{option}: #{value}"
16
+ end
17
+
18
+ Rails::Generators::DevcontainerGenerator.new([], devcontainer_options).invoke_all
19
+ end
20
+
21
+ private
22
+ def devcontainer_options
23
+ @devcontainer_options ||= {
24
+ app_name: Rails.application.railtie_name.chomp("_application"),
25
+ database: !!defined?(ActiveRecord) && database,
26
+ active_storage: !!defined?(ActiveStorage),
27
+ redis: !!((defined?(ActionCable) && !defined?(SolidCable)) || (defined?(ActiveJob) && !defined?(SolidQueue))),
28
+ system_test: File.exist?("test/application_system_test_case.rb"),
29
+ node: File.exist?(".node-version"),
30
+ }
31
+ end
32
+
33
+ def database
34
+ adapter = ActiveRecord::Base.connection_db_config.adapter
35
+ adapter == "mysql2" ? "mysql" : adapter
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,23 @@
1
+ Description:
2
+ The Rails `encrypted` commands provide access to encrypted files or configurations.
3
+ See the `Rails.application.encrypted` documentation for using them in your app.
4
+
5
+ Encryption Keys:
6
+ By default, Rails looks for the encryption key in `ENV["RAILS_MASTER_KEY"]` or
7
+ `config/master.key`, but that lookup can be overridden with `--key`:
8
+
9
+ <%= executable(:edit) %> config/encrypted_file.yml.enc --key config/encrypted_file.key
10
+
11
+ Don't commit the key! Add it to your source control's ignore file. If you use
12
+ Git, Rails handles this for you.
13
+
14
+ Examples:
15
+ To edit or create an encrypted file use:
16
+
17
+ <%= executable(:edit) %> config/encrypted_file.yml.enc
18
+
19
+ This opens a temporary file in `$VISUAL` or `$EDITOR` with the decrypted contents for editing.
20
+
21
+ To print the decrypted contents of an encrypted file use:
22
+
23
+ <%= executable(:show) %> config/encrypted_file.yml.enc