kaze 0.4.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/lib/kaze/commands/install_command.rb +25 -13
  3. data/lib/kaze/commands/installs_hotwire_stack.rb +11 -8
  4. data/lib/kaze/commands/installs_inertia_stacks.rb +34 -24
  5. data/lib/kaze/commands/version_command.rb +6 -0
  6. data/lib/kaze/version.rb +1 -1
  7. data/lib/kaze.rb +1 -3
  8. data/stubs/default/app/forms/auth/login_form.rb +2 -8
  9. data/stubs/default/app/forms/auth/new_password_form.rb +1 -1
  10. data/stubs/default/app/forms/update_profile_information_form.rb +1 -1
  11. data/stubs/default/app/mailers/application_mailer.rb +4 -4
  12. data/stubs/default/app/mailers/user_mailer.rb +1 -1
  13. data/stubs/default/app/models/auth.rb +57 -0
  14. data/stubs/default/app/models/current.rb +1 -1
  15. data/stubs/default/app/validators/current_password_validator.rb +1 -1
  16. data/stubs/default/app/validators/email_validator.rb +1 -1
  17. data/stubs/default/app/validators/lowercase_validator.rb +2 -2
  18. data/stubs/default/app/views/layouts/mailer.html.erb +367 -372
  19. data/stubs/default/app/views/layouts/mailer.text.erb +1 -4
  20. data/stubs/default/app/views/user_mailer/reset_password.html.erb +21 -26
  21. data/stubs/default/config/routes.rb +16 -16
  22. data/stubs/default/db/migrate/20240101000001_create_delayed_jobs.rb +1 -1
  23. data/stubs/default/test/factories/users.rb +7 -0
  24. data/stubs/default/test/integration/auth/authentication_test.rb +43 -0
  25. data/stubs/default/test/integration/auth/password_reset_test.rb +41 -0
  26. data/stubs/default/test/integration/auth/registration_test.rb +21 -0
  27. data/stubs/default/test/integration/password_update_test.rb +28 -0
  28. data/stubs/default/test/integration/profile_test.rb +51 -0
  29. data/stubs/default/test/test_helper.rb +38 -0
  30. data/stubs/hotwire/app/components/danger_button_component.rb +1 -1
  31. data/stubs/hotwire/app/components/dropdown_component.html.erb +17 -18
  32. data/stubs/hotwire/app/components/dropdown_component.rb +7 -7
  33. data/stubs/hotwire/app/components/modal_component.html.erb +55 -59
  34. data/stubs/hotwire/app/components/modal_component.rb +6 -6
  35. data/stubs/hotwire/app/components/primary_button_component.rb +1 -1
  36. data/stubs/hotwire/app/components/secondary_button_component.rb +1 -1
  37. data/stubs/hotwire/app/controllers/application_controller.rb +1 -0
  38. data/stubs/hotwire/app/controllers/auth/authenticated_session_controller.rb +12 -9
  39. data/stubs/hotwire/app/controllers/auth/new_password_controller.rb +7 -5
  40. data/stubs/hotwire/app/controllers/auth/password_reset_link_controller.rb +7 -5
  41. data/stubs/hotwire/app/controllers/auth/registered_user_controller.rb +7 -5
  42. data/stubs/hotwire/app/controllers/concerns/authenticate.rb +5 -20
  43. data/stubs/hotwire/app/controllers/concerns/redirect_if_authenticated.rb +19 -0
  44. data/stubs/hotwire/app/controllers/concerns/set_current_auth.rb +9 -0
  45. data/stubs/hotwire/app/controllers/password_controller.rb +3 -3
  46. data/stubs/hotwire/app/controllers/profile_controller.rb +11 -9
  47. data/stubs/hotwire/app/controllers/welcome_controller.rb +1 -1
  48. data/stubs/hotwire/app/javascript/application.js +3 -3
  49. data/stubs/hotwire/app/views/auth/forgot_password.html.erb +12 -17
  50. data/stubs/hotwire/app/views/auth/login.html.erb +0 -9
  51. data/stubs/hotwire/app/views/auth/register.html.erb +0 -13
  52. data/stubs/hotwire/app/views/auth/reset_password.html.erb +0 -7
  53. data/stubs/hotwire/app/views/dashboard/index.html.erb +9 -10
  54. data/stubs/hotwire/app/views/layouts/_navigation.html.erb +77 -87
  55. data/stubs/hotwire/app/views/layouts/application.html.erb +0 -9
  56. data/stubs/hotwire/app/views/layouts/guest.html.erb +0 -6
  57. data/stubs/hotwire/app/views/profile/edit.html.erb +19 -22
  58. data/stubs/hotwire/app/views/profile/partials/_delete_user_form.html.erb +32 -42
  59. data/stubs/hotwire/app/views/profile/partials/_update_password_form.html.erb +42 -55
  60. data/stubs/hotwire/app/views/profile/partials/_update_profile_information_form.html.erb +36 -46
  61. data/stubs/hotwire/app/views/welcome/index.html.erb +34 -46
  62. data/stubs/hotwire/config/importmap.rb +3 -3
  63. data/stubs/hotwire/config/tailwind.config.js +2 -2
  64. data/stubs/inertia-common/app/controllers/application_controller.rb +1 -0
  65. data/stubs/inertia-common/app/controllers/auth/authenticated_session_controller.rb +11 -8
  66. data/stubs/inertia-common/app/controllers/auth/new_password_controller.rb +5 -3
  67. data/stubs/inertia-common/app/controllers/auth/password_reset_link_controller.rb +5 -3
  68. data/stubs/inertia-common/app/controllers/auth/registered_user_controller.rb +5 -3
  69. data/stubs/inertia-common/app/controllers/concerns/authenticate.rb +5 -20
  70. data/stubs/inertia-common/app/controllers/concerns/handle_inertia_requests.rb +1 -1
  71. data/stubs/inertia-common/app/controllers/concerns/redirect_if_authenticated.rb +19 -0
  72. data/stubs/inertia-common/app/controllers/concerns/set_current_auth.rb +9 -0
  73. data/stubs/inertia-common/app/controllers/concerns/verify_csrf_token.rb +4 -4
  74. data/stubs/inertia-common/app/controllers/dashboard_controller.rb +1 -1
  75. data/stubs/inertia-common/app/controllers/password_controller.rb +1 -1
  76. data/stubs/inertia-common/app/controllers/profile_controller.rb +7 -5
  77. data/stubs/inertia-common/app/controllers/welcome_controller.rb +2 -2
  78. data/stubs/inertia-common/bin/vite +6 -6
  79. data/stubs/inertia-common/test/integration/password_update_test.rb +28 -0
  80. data/stubs/inertia-common/test/integration/profile_test.rb +51 -0
  81. data/stubs/inertia-react-ts/app/javascript/Components/ApplicationLogo.tsx +13 -9
  82. data/stubs/inertia-react-ts/app/javascript/Components/Checkbox.tsx +15 -12
  83. data/stubs/inertia-react-ts/app/javascript/Components/DangerButton.tsx +20 -15
  84. data/stubs/inertia-react-ts/app/javascript/Components/Dropdown.tsx +119 -87
  85. data/stubs/inertia-react-ts/app/javascript/Components/InputError.tsx +14 -7
  86. data/stubs/inertia-react-ts/app/javascript/Components/InputLabel.tsx +18 -7
  87. data/stubs/inertia-react-ts/app/javascript/Components/Modal.tsx +60 -60
  88. data/stubs/inertia-react-ts/app/javascript/Components/NavLink.tsx +21 -16
  89. data/stubs/inertia-react-ts/app/javascript/Components/PrimaryButton.tsx +20 -15
  90. data/stubs/inertia-react-ts/app/javascript/Components/ResponsiveNavLink.tsx +19 -14
  91. data/stubs/inertia-react-ts/app/javascript/Components/SecondaryButton.tsx +22 -16
  92. data/stubs/inertia-react-ts/app/javascript/Components/TextInput.tsx +35 -24
  93. data/stubs/inertia-react-ts/app/javascript/Layouts/AuthenticatedLayout.tsx +157 -117
  94. data/stubs/inertia-react-ts/app/javascript/Layouts/GuestLayout.tsx +15 -15
  95. data/stubs/inertia-react-ts/app/javascript/Pages/Auth/ForgotPassword.tsx +52 -49
  96. data/stubs/inertia-react-ts/app/javascript/Pages/Auth/Login.tsx +90 -82
  97. data/stubs/inertia-react-ts/app/javascript/Pages/Auth/Register.tsx +118 -115
  98. data/stubs/inertia-react-ts/app/javascript/Pages/Auth/ResetPassword.tsx +63 -60
  99. data/stubs/inertia-react-ts/app/javascript/Pages/Dashboard.tsx +23 -17
  100. data/stubs/inertia-react-ts/app/javascript/Pages/Profile/Edit.tsx +31 -27
  101. data/stubs/inertia-react-ts/app/javascript/Pages/Profile/Partials/DeleteUserForm.tsx +109 -99
  102. data/stubs/inertia-react-ts/app/javascript/Pages/Profile/Partials/UpdatePasswordForm.tsx +121 -113
  103. data/stubs/inertia-react-ts/app/javascript/Pages/Profile/Partials/UpdateProfileInformationForm.tsx +76 -69
  104. data/stubs/inertia-react-ts/app/javascript/Pages/Welcome.tsx +87 -63
  105. data/stubs/inertia-react-ts/app/javascript/entrypoints/application.tsx +32 -25
  106. data/stubs/inertia-react-ts/app/views/layouts/application.html.erb +0 -4
  107. data/stubs/inertia-react-ts/config/tailwind.config.js +2 -2
  108. data/stubs/inertia-react-ts/vite.config.ts +2 -5
  109. data/stubs/inertia-vue-ts/app/javascript/Components/ApplicationLogo.vue +10 -6
  110. data/stubs/inertia-vue-ts/app/javascript/Components/Checkbox.vue +18 -18
  111. data/stubs/inertia-vue-ts/app/javascript/Components/DangerButton.vue +5 -5
  112. data/stubs/inertia-vue-ts/app/javascript/Components/Dropdown.vue +60 -57
  113. data/stubs/inertia-vue-ts/app/javascript/Components/DropdownLink.vue +9 -9
  114. data/stubs/inertia-vue-ts/app/javascript/Components/InputError.vue +7 -7
  115. data/stubs/inertia-vue-ts/app/javascript/Components/InputLabel.vue +6 -6
  116. data/stubs/inertia-vue-ts/app/javascript/Components/Modal.vue +84 -74
  117. data/stubs/inertia-vue-ts/app/javascript/Components/NavLink.vue +12 -12
  118. data/stubs/inertia-vue-ts/app/javascript/Components/PrimaryButton.vue +5 -5
  119. data/stubs/inertia-vue-ts/app/javascript/Components/ResponsiveNavLink.vue +12 -12
  120. data/stubs/inertia-vue-ts/app/javascript/Components/SecondaryButton.vue +13 -13
  121. data/stubs/inertia-vue-ts/app/javascript/Components/TextInput.vue +13 -13
  122. data/stubs/inertia-vue-ts/app/javascript/Layouts/AuthenticatedLayout.vue +168 -136
  123. data/stubs/inertia-vue-ts/app/javascript/Layouts/GuestLayout.vue +15 -13
  124. data/stubs/inertia-vue-ts/app/javascript/Pages/Auth/ForgotPassword.vue +56 -49
  125. data/stubs/inertia-vue-ts/app/javascript/Pages/Auth/Login.vue +78 -72
  126. data/stubs/inertia-vue-ts/app/javascript/Pages/Auth/Register.vue +101 -97
  127. data/stubs/inertia-vue-ts/app/javascript/Pages/Auth/ResetPassword.vue +71 -68
  128. data/stubs/inertia-vue-ts/app/javascript/Pages/Dashboard.vue +22 -14
  129. data/stubs/inertia-vue-ts/app/javascript/Pages/Profile/Edit.vue +34 -30
  130. data/stubs/inertia-vue-ts/app/javascript/Pages/Profile/Partials/DeleteUserForm.vue +87 -83
  131. data/stubs/inertia-vue-ts/app/javascript/Pages/Profile/Partials/UpdatePasswordForm.vue +105 -98
  132. data/stubs/inertia-vue-ts/app/javascript/Pages/Profile/Partials/UpdateProfileInformationForm.vue +69 -59
  133. data/stubs/inertia-vue-ts/app/javascript/Pages/Welcome.vue +74 -47
  134. data/stubs/inertia-vue-ts/app/views/layouts/application.html.erb +0 -4
  135. data/stubs/inertia-vue-ts/config/tailwind.config.js +2 -2
  136. data/stubs/inertia-vue-ts/vite.config.ts +2 -5
  137. metadata +19 -6
  138. data/stubs/hotwire/bin/vite +0 -27
  139. data/stubs/inertia-common/Procfile.dev +0 -3
  140. /data/stubs/{hotwire → default}/Procfile.dev +0 -0
  141. /data/stubs/hotwire/app/javascript/{alpinejs.js → alpinejs.stub} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2c180c5d3390cc6b2013e98ce172091691001be25971dfc2f2f28fe7022eaf1
4
- data.tar.gz: ddc60156cf90ab2827ea0907e0f7d68e6bc4c760963ad271809b80132b0a7884
3
+ metadata.gz: 57126b1b287c8bf01b88c9baaae1a139d4791fe50e575262ec483ef8ad58e6e1
4
+ data.tar.gz: 254ed015dfcab378aae5ef24b69c90819fc88f46b4e3557811f7a3b50c3a5bd8
5
5
  SHA512:
6
- metadata.gz: 7a47cce2a4bd167ac9f57ac2c367794f61f7354e3400619112abd2482d59a1341ccbe1bbd6881f61104404f4b7a87c59600fe1889abbd5577ab8f12d22308ef6
7
- data.tar.gz: 0f885b972c32e66757b2412481b8cce0aacc03fd7512bebbc41e007bc4e715afec41afc36c946fe05e462a5c26256cfbe47955ce61e66508df9467be82ddab77
6
+ metadata.gz: ee1afd04c5c57655b90e2f43d93730e9abc9cfc2989dba0b5c9e8684c041628ca80c7aeb496c5c8cae3a26e71c1ec21af2de6e7404fe60290f8b5a8eac2639cd
7
+ data.tar.gz: c4fdc51d36d33cfa6a346a10ef933f7b2cdffeb08958ca6aac5b42cf3e5ac335245892ef1662a881ddd33ce0dc9b74dfd019b6b07683dc8ec82474b28c8e6174
@@ -1,27 +1,27 @@
1
- require "bundler"
2
- require "fileutils"
3
- require "open3"
4
- require "thor"
1
+ require 'bundler'
2
+ require 'fileutils'
3
+ require 'open3'
4
+ require 'thor'
5
5
 
6
6
  class Kaze::Commands::InstallCommand < Thor
7
7
  include Kaze::Commands::InstallsHotwireStack
8
8
  include Kaze::Commands::InstallsInertiaStacks
9
9
 
10
- desc "install [STACK]", "Install the Kaze controllers and resources. Supported stacks: hotwire, react, vue."
11
- def install(stack = "hotwire")
12
- if stack == "hotwire"
10
+ desc 'install [STACK]', 'Install the Kaze controllers and resources. Supported stacks: hotwire, react, vue.'
11
+ def install(stack = 'hotwire')
12
+ if stack == 'hotwire'
13
13
  return install_hotwire_stack
14
14
  end
15
15
 
16
- if stack == "react"
16
+ if stack == 'react'
17
17
  return install_inertia_react_stack
18
18
  end
19
19
 
20
- if stack == "vue"
20
+ if stack == 'vue'
21
21
  return install_inertia_vue_stack
22
22
  end
23
23
 
24
- say "Invalid stack. Supported stacks are [hotwire], [react], [vue].", :red
24
+ say 'Invalid stack. Supported stacks are [hotwire], [react], [vue].', :red
25
25
  end
26
26
 
27
27
  private
@@ -53,9 +53,21 @@ class Kaze::Commands::InstallCommand < Thor
53
53
  def install_migrations
54
54
  ensure_directory_exists("#{Dir.pwd}/db/migrate")
55
55
  FileUtils.copy_entry("#{File.dirname(__FILE__)}/../../../stubs/default/db/migrate", "#{Dir.pwd}/db/migrate")
56
- stdin, _ = Open3.capture3("rails version")
57
- versions = stdin.gsub!("Rails ", "").split(".")
58
- Open3.capture3('grep -rl ActiveRecord::Migration$ db | xargs sed -i "" "s/ActiveRecord::Migration/ActiveRecord::Migration[' + [ versions[0], versions[1] ].join(".") + ']/g"')
56
+ stdin, _ = Open3.capture3('rails version')
57
+ versions = stdin.gsub!('Rails ', '').split('.')
58
+ railsVersion = [ versions[0], versions[1] ].join('.')
59
+ Dir.children("#{Dir.pwd}/db/migrate").each do |file|
60
+ path = "#{Dir.pwd}/db/migrate/#{file}"
61
+ File.write(path, File.read(path).gsub!(/ActiveRecord::Migration$/, "ActiveRecord::Migration[#{railsVersion}]"))
62
+ end
63
+ end
64
+
65
+ def install_tests
66
+ ensure_directory_exists("#{Dir.pwd}/test/factories")
67
+ ensure_directory_exists("#{Dir.pwd}/test/integration")
68
+ FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/default/test/test_helper.rb", "#{Dir.pwd}/test/test_helper.rb")
69
+ FileUtils.copy_entry("#{File.dirname(__FILE__)}/../../../stubs/default/test/factories", "#{Dir.pwd}/test/factories")
70
+ FileUtils.copy_entry("#{File.dirname(__FILE__)}/../../../stubs/default/test/integration", "#{Dir.pwd}/test/integration")
59
71
  end
60
72
 
61
73
  def ensure_directory_exists(path)
@@ -3,9 +3,10 @@ module Kaze::Commands::InstallsHotwireStack
3
3
 
4
4
  def install_hotwire_stack
5
5
  # Gems...
6
- return unless remove_gems([ "sprockets-rails" ])
7
- return unless install_gems([ "propshaft", "view_component", "tailwindcss-rails", "turbo-rails", "dotenv", "bcrypt" ])
8
- return unless install_gems([ "hotwire-livereload" ], "development")
6
+ return unless remove_gems([ 'sprockets-rails', 'stimulus-rails' ])
7
+ return unless install_gems([ 'propshaft', 'view_component', 'tailwindcss-rails', 'turbo-rails', 'dotenv', 'bcrypt' ])
8
+ return unless install_gems([ 'hotwire-livereload' ], 'development')
9
+ return unless install_gems([ 'factory_bot_rails', 'faker' ], 'development, test')
9
10
 
10
11
  # Controllers...
11
12
  FileUtils.copy_entry("#{File.dirname(__FILE__)}/../../../stubs/hotwire/app/controllers", "#{Dir.pwd}/app/controllers")
@@ -37,10 +38,12 @@ module Kaze::Commands::InstallsHotwireStack
37
38
  ensure_directory_exists("#{Dir.pwd}/app/components")
38
39
  FileUtils.copy_entry("#{File.dirname(__FILE__)}/../../../stubs/hotwire/app/components", "#{Dir.pwd}/app/components")
39
40
  ensure_directory_exists("#{Dir.pwd}/app/javascript")
40
- FileUtils.copy_entry("#{File.dirname(__FILE__)}/../../../stubs/hotwire/app/javascript", "#{Dir.pwd}/app/javascript")
41
+ FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/hotwire/app/javascript/application.js", "#{Dir.pwd}/app/javascript/application.js")
42
+ FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/hotwire/app/javascript/alpinejs.stub", "#{Dir.pwd}/app/javascript/alpinejs.js")
41
43
  FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/hotwire/config/importmap.rb", "#{Dir.pwd}/config/importmap.rb")
42
44
 
43
45
  # Tests...
46
+ install_tests
44
47
 
45
48
  # Routes...
46
49
  FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/default/config/routes.rb", "#{Dir.pwd}/config/routes.rb")
@@ -53,10 +56,10 @@ module Kaze::Commands::InstallsHotwireStack
53
56
  FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/default/app/assets/stylesheets/application.tailwind.css", "#{Dir.pwd}/app/assets/stylesheets/application.tailwind.css")
54
57
  FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/hotwire/config/tailwind.config.js", "#{Dir.pwd}/config/tailwind.config.js")
55
58
  FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/default/bin/dev", "#{Dir.pwd}/bin/dev")
56
- FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/hotwire/Procfile.dev", "#{Dir.pwd}/Procfile.dev")
57
- run_command("rails tailwindcss:build")
59
+ FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/default/Procfile.dev", "#{Dir.pwd}/Procfile.dev")
60
+ run_command('rails tailwindcss:build')
58
61
 
59
- say ""
60
- say "Kaze scaffolding installed successfully.", :green
62
+ say ''
63
+ say 'Kaze scaffolding installed successfully.', :green
61
64
  end
62
65
  end
@@ -3,8 +3,9 @@ module Kaze::Commands::InstallsInertiaStacks
3
3
 
4
4
  def install_inertia_react_stack
5
5
  # Gems...
6
- return unless remove_gems([ "sprockets-rails" ])
7
- return unless install_gems([ "propshaft", "tailwindcss-rails", "inertia_rails", "vite_rails", "dotenv", "bcrypt", "js-routes" ])
6
+ return unless remove_gems([ 'sprockets-rails', 'turbo-rails', 'stimulus-rails' ])
7
+ return unless install_gems([ 'propshaft', 'tailwindcss-rails', 'inertia_rails', 'vite_rails', 'dotenv', 'bcrypt', 'js-routes' ])
8
+ return unless install_gems([ 'factory_bot_rails', 'faker' ], 'development, test')
8
9
 
9
10
  # NPM Packages...
10
11
  FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/inertia-react-ts/package.json", "#{Dir.pwd}/package.json")
@@ -40,6 +41,8 @@ module Kaze::Commands::InstallsInertiaStacks
40
41
  FileUtils.copy_entry("#{File.dirname(__FILE__)}/../../../stubs/inertia-react-ts/app/javascript", "#{Dir.pwd}/app/javascript")
41
42
 
42
43
  # Tests...
44
+ install_tests
45
+ FileUtils.copy_entry("#{File.dirname(__FILE__)}/../../../stubs/inertia-common/test/integration", "#{Dir.pwd}/test/integration")
43
46
 
44
47
  # Routes...
45
48
  FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/default/config/routes.rb", "#{Dir.pwd}/config/routes.rb")
@@ -56,30 +59,33 @@ module Kaze::Commands::InstallsInertiaStacks
56
59
  FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/inertia-react-ts/vite.config.ts", "#{Dir.pwd}/vite.config.ts")
57
60
  FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/default/bin/dev", "#{Dir.pwd}/bin/dev")
58
61
  FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/inertia-common/bin/vite", "#{Dir.pwd}/bin/vite")
59
- FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/inertia-common/Procfile.dev", "#{Dir.pwd}/Procfile.dev")
60
- run_command("rails generate js_routes:middleware")
62
+ FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/default/Procfile.dev", "#{Dir.pwd}/Procfile.dev")
63
+ File.write("#{Dir.pwd}/Procfile.dev", "#{File.read("#{Dir.pwd}/Procfile.dev")}\nvite: bin/vite dev\n")
64
+ run_command('rails generate js_routes:middleware')
65
+ run_command('rails tailwindcss:build')
61
66
 
62
- say ""
63
- say "Installing and building Node dependencies.", :magenta
67
+ say ''
68
+ say 'Installing and building Node dependencies.', :magenta
64
69
 
65
70
  if File.exist?("#{Dir.pwd}/pnpm-lock.yaml")
66
- run_commands([ "pnpm install", "pnpm run build" ])
71
+ run_commands([ 'pnpm install', 'pnpm run build' ])
67
72
  elsif File.exist?("#{Dir.pwd}/yarn.lock")
68
- run_commands([ "yarn install", "yarn build" ])
73
+ run_commands([ 'yarn install', 'yarn build' ])
69
74
  elsif File.exist?("#{Dir.pwd}/bun.lockb")
70
- run_commands([ "bun install", "bun run build" ])
75
+ run_commands([ 'bun install', 'bun run build' ])
71
76
  else
72
- run_commands([ "npm install", "npm run build" ])
77
+ run_commands([ 'npm install', 'npm run build' ])
73
78
  end
74
79
 
75
- say ""
76
- say "Kaze scaffolding installed successfully.", :green
80
+ say ''
81
+ say 'Kaze scaffolding installed successfully.', :green
77
82
  end
78
83
 
79
84
  def install_inertia_vue_stack
80
85
  # Gems...
81
- return unless remove_gems([ "sprockets-rails" ])
82
- return unless install_gems([ "propshaft", "tailwindcss-rails", "inertia_rails", "vite_rails", "dotenv", "bcrypt", "js-routes" ])
86
+ return unless remove_gems([ 'sprockets-rails', 'turbo-rails', 'stimulus-rails' ])
87
+ return unless install_gems([ 'propshaft', 'tailwindcss-rails', 'inertia_rails', 'vite_rails', 'dotenv', 'bcrypt', 'js-routes' ])
88
+ return unless install_gems([ 'factory_bot_rails', 'faker' ], 'development, test')
83
89
 
84
90
  # NPM Packages...
85
91
  FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/inertia-vue-ts/package.json", "#{Dir.pwd}/package.json")
@@ -115,6 +121,8 @@ module Kaze::Commands::InstallsInertiaStacks
115
121
  FileUtils.copy_entry("#{File.dirname(__FILE__)}/../../../stubs/inertia-vue-ts/app/javascript", "#{Dir.pwd}/app/javascript")
116
122
 
117
123
  # Tests...
124
+ install_tests
125
+ FileUtils.copy_entry("#{File.dirname(__FILE__)}/../../../stubs/inertia-common/test/integration", "#{Dir.pwd}/test/integration")
118
126
 
119
127
  # Routes...
120
128
  FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/default/config/routes.rb", "#{Dir.pwd}/config/routes.rb")
@@ -131,23 +139,25 @@ module Kaze::Commands::InstallsInertiaStacks
131
139
  FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/inertia-vue-ts/vite.config.ts", "#{Dir.pwd}/vite.config.ts")
132
140
  FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/default/bin/dev", "#{Dir.pwd}/bin/dev")
133
141
  FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/inertia-common/bin/vite", "#{Dir.pwd}/bin/vite")
134
- FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/inertia-common/Procfile.dev", "#{Dir.pwd}/Procfile.dev")
135
- run_command("rails generate js_routes:middleware")
142
+ FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/default/Procfile.dev", "#{Dir.pwd}/Procfile.dev")
143
+ File.write("#{Dir.pwd}/Procfile.dev", "#{File.read("#{Dir.pwd}/Procfile.dev")}\nvite: bin/vite dev\n")
144
+ run_command('rails generate js_routes:middleware')
145
+ run_command('rails tailwindcss:build')
136
146
 
137
- say ""
138
- say "Installing and building Node dependencies.", :magenta
147
+ say ''
148
+ say 'Installing and building Node dependencies.', :magenta
139
149
 
140
150
  if File.exist?("#{Dir.pwd}/pnpm-lock.yaml")
141
- run_commands([ "pnpm install", "pnpm run build" ])
151
+ run_commands([ 'pnpm install', 'pnpm run build' ])
142
152
  elsif File.exist?("#{Dir.pwd}/yarn.lock")
143
- run_commands([ "yarn install", "yarn build" ])
153
+ run_commands([ 'yarn install', 'yarn build' ])
144
154
  elsif File.exist?("#{Dir.pwd}/bun.lockb")
145
- run_commands([ "bun install", "bun run build" ])
155
+ run_commands([ 'bun install', 'bun run build' ])
146
156
  else
147
- run_commands([ "npm install", "npm run build" ])
157
+ run_commands([ 'npm install', 'npm run build' ])
148
158
  end
149
159
 
150
- say ""
151
- say "Kaze scaffolding installed successfully.", :green
160
+ say ''
161
+ say 'Kaze scaffolding installed successfully.', :green
152
162
  end
153
163
  end
@@ -0,0 +1,6 @@
1
+ class Kaze::Commands::VersionCommand < Thor
2
+ desc 'version', 'Show Kaze version'
3
+ def version
4
+ puts Kaze::VERSION
5
+ end
6
+ end
data/lib/kaze/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kaze
2
- VERSION = "0.4.0"
2
+ VERSION = '0.6.0'
3
3
  end
data/lib/kaze.rb CHANGED
@@ -1,9 +1,7 @@
1
1
  module Kaze
2
2
  end
3
3
 
4
- require "active_support"
5
- require "zeitwerk"
4
+ require 'zeitwerk'
6
5
 
7
6
  loader = Zeitwerk::Loader.for_gem
8
7
  loader.setup
9
- loader.eager_load # We need all commands loaded.
@@ -5,14 +5,8 @@ class Auth::LoginForm < ApplicationForm
5
5
  validates :password, presence: true
6
6
 
7
7
  def authenticate
8
- return nil if invalid?
8
+ return if invalid?
9
9
 
10
- user = User.authenticate_by(email: email, password: password)
11
-
12
- return user if user.present?
13
-
14
- errors.add(:email, message: "These credentials do not match our records.")
15
-
16
- nil
10
+ errors.add(:email, message: 'These credentials do not match our records.') unless Current.auth.attempt(email: email, password: password)
17
11
  end
18
12
  end
@@ -10,7 +10,7 @@ class Auth::NewPasswordForm < ApplicationForm
10
10
  user = User.find_by_token_for(:password_reset, token)
11
11
 
12
12
  if user.nil?
13
- errors.add(:password, message: "This password reset token is invalid.")
13
+ errors.add(:password, message: 'This password reset token is invalid.')
14
14
  return false
15
15
  end
16
16
 
@@ -2,5 +2,5 @@ class UpdateProfileInformationForm < ApplicationForm
2
2
  attr_accessor :name, :email
3
3
 
4
4
  validates :name, presence: true
5
- validates :email, presence: true, lowercase: true, email: true, uniqueness: { model: User, attribute: :email, conditions: -> { where.not(id: Current.user.id) } }
5
+ validates :email, presence: true, lowercase: true, email: true, uniqueness: { model: User, attribute: :email, conditions: -> { where.not(id: Current.auth.user.id) } }
6
6
  end
@@ -1,11 +1,11 @@
1
1
  class ApplicationMailer < ActionMailer::Base
2
2
  default from: email_address_with_name(
3
- ENV.fetch("MAIL_FROM_ADDRESS", "hello@example.com"),
4
- ENV.fetch("MAIL_FROM_NAME", "Example")
3
+ ENV.fetch('MAIL_FROM_ADDRESS', 'hello@example.com'),
4
+ ENV.fetch('MAIL_FROM_NAME', 'Example')
5
5
  )
6
- layout "mailer"
6
+ layout 'mailer'
7
7
 
8
8
  def default_url_options
9
- { host: ENV.fetch("APP_URL", "http://localhost") }
9
+ { host: ENV.fetch('APP_URL', 'http://localhost') }
10
10
  end
11
11
  end
@@ -2,7 +2,7 @@ class UserMailer < ApplicationMailer
2
2
  def reset_password
3
3
  mail(
4
4
  to: params[:user].email,
5
- subject: "Reset Password Notification"
5
+ subject: 'Reset Password Notification'
6
6
  )
7
7
  end
8
8
  end
@@ -0,0 +1,57 @@
1
+ class Auth
2
+ attr_reader :name, :session, :user
3
+
4
+ def initialize(name, session)
5
+ @name = name
6
+ @session = session
7
+ end
8
+
9
+ def get_user
10
+ return @user unless @user.nil?
11
+
12
+ id = @session[get_name]
13
+
14
+ @user = User.find_by(id: id) unless id.nil?
15
+
16
+ @user
17
+ end
18
+
19
+ def get_name
20
+ "login_#{@name}_#{Digest::SHA1.hexdigest(self.class.name)}"
21
+ end
22
+
23
+ def check?
24
+ not get_user.nil?
25
+ end
26
+
27
+ def attempt(credentials = {})
28
+ user = User.authenticate_by(credentials)
29
+
30
+ return false if user.nil?
31
+
32
+ login user
33
+
34
+ true
35
+ end
36
+
37
+ def login(user)
38
+ update_session user.id
39
+
40
+ set_user user
41
+ end
42
+
43
+ def set_user(user)
44
+ @user = user
45
+ end
46
+
47
+ def logout
48
+ @session[get_name] = nil
49
+ @user = nil
50
+ end
51
+
52
+ private
53
+
54
+ def update_session(id)
55
+ @session[get_name] = id
56
+ end
57
+ end
@@ -1,3 +1,3 @@
1
1
  class Current < ActiveSupport::CurrentAttributes
2
- attribute :user
2
+ attribute :auth
3
3
  end
@@ -1,5 +1,5 @@
1
1
  class CurrentPasswordValidator < ActiveModel::EachValidator
2
2
  def validate_each(record, attribute, value)
3
- record.errors.add attribute, "The password is incorrect." unless Current.user&.authenticate(value)
3
+ record.errors.add attribute, 'The password is incorrect.' unless Current.auth.user&.authenticate(value)
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  class EmailValidator < ActiveModel::EachValidator
2
2
  def validate_each(record, attribute, value)
3
3
  unless URI::MailTo::EMAIL_REGEXP.match?(value)
4
- record.errors.add attribute, (options[:message] || "is not an email")
4
+ record.errors.add attribute, (options[:message] || 'is not an email')
5
5
  end
6
6
  end
7
7
  end
@@ -1,6 +1,6 @@
1
1
  class LowercaseValidator < ActiveModel::EachValidator
2
2
  def validate_each(record, attribute, value)
3
- value = "" if value.nil?
4
- record.errors.add attribute, (options[:message] || "must be lowercase") unless value == value.downcase
3
+ value = '' if value.nil?
4
+ record.errors.add attribute, (options[:message] || 'must be lowercase') unless value == value.downcase
5
5
  end
6
6
  end