kaze 0.4.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kaze/commands/install_command.rb +25 -13
- data/lib/kaze/commands/installs_hotwire_stack.rb +11 -8
- data/lib/kaze/commands/installs_inertia_stacks.rb +34 -24
- data/lib/kaze/commands/version_command.rb +6 -0
- data/lib/kaze/version.rb +1 -1
- data/lib/kaze.rb +1 -3
- data/stubs/default/app/forms/auth/login_form.rb +2 -8
- data/stubs/default/app/forms/auth/new_password_form.rb +1 -1
- data/stubs/default/app/forms/update_profile_information_form.rb +1 -1
- data/stubs/default/app/mailers/application_mailer.rb +4 -4
- data/stubs/default/app/mailers/user_mailer.rb +1 -1
- data/stubs/default/app/models/auth.rb +57 -0
- data/stubs/default/app/models/current.rb +1 -1
- data/stubs/default/app/validators/current_password_validator.rb +1 -1
- data/stubs/default/app/validators/email_validator.rb +1 -1
- data/stubs/default/app/validators/lowercase_validator.rb +2 -2
- data/stubs/default/app/views/layouts/mailer.html.erb +367 -372
- data/stubs/default/app/views/layouts/mailer.text.erb +1 -4
- data/stubs/default/app/views/user_mailer/reset_password.html.erb +21 -26
- data/stubs/default/config/routes.rb +16 -16
- data/stubs/default/db/migrate/20240101000001_create_delayed_jobs.rb +1 -1
- data/stubs/default/test/factories/users.rb +7 -0
- data/stubs/default/test/integration/auth/authentication_test.rb +43 -0
- data/stubs/default/test/integration/auth/password_reset_test.rb +41 -0
- data/stubs/default/test/integration/auth/registration_test.rb +21 -0
- data/stubs/default/test/integration/password_update_test.rb +28 -0
- data/stubs/default/test/integration/profile_test.rb +51 -0
- data/stubs/default/test/test_helper.rb +38 -0
- data/stubs/hotwire/app/components/danger_button_component.rb +1 -1
- data/stubs/hotwire/app/components/dropdown_component.html.erb +17 -18
- data/stubs/hotwire/app/components/dropdown_component.rb +7 -7
- data/stubs/hotwire/app/components/modal_component.html.erb +55 -59
- data/stubs/hotwire/app/components/modal_component.rb +6 -6
- data/stubs/hotwire/app/components/primary_button_component.rb +1 -1
- data/stubs/hotwire/app/components/secondary_button_component.rb +1 -1
- data/stubs/hotwire/app/controllers/application_controller.rb +1 -0
- data/stubs/hotwire/app/controllers/auth/authenticated_session_controller.rb +12 -9
- data/stubs/hotwire/app/controllers/auth/new_password_controller.rb +7 -5
- data/stubs/hotwire/app/controllers/auth/password_reset_link_controller.rb +7 -5
- data/stubs/hotwire/app/controllers/auth/registered_user_controller.rb +7 -5
- data/stubs/hotwire/app/controllers/concerns/authenticate.rb +5 -20
- data/stubs/hotwire/app/controllers/concerns/redirect_if_authenticated.rb +19 -0
- data/stubs/hotwire/app/controllers/concerns/set_current_auth.rb +9 -0
- data/stubs/hotwire/app/controllers/password_controller.rb +3 -3
- data/stubs/hotwire/app/controllers/profile_controller.rb +11 -9
- data/stubs/hotwire/app/controllers/welcome_controller.rb +1 -1
- data/stubs/hotwire/app/javascript/application.js +3 -3
- data/stubs/hotwire/app/views/auth/forgot_password.html.erb +12 -17
- data/stubs/hotwire/app/views/auth/login.html.erb +0 -9
- data/stubs/hotwire/app/views/auth/register.html.erb +0 -13
- data/stubs/hotwire/app/views/auth/reset_password.html.erb +0 -7
- data/stubs/hotwire/app/views/dashboard/index.html.erb +9 -10
- data/stubs/hotwire/app/views/layouts/_navigation.html.erb +77 -87
- data/stubs/hotwire/app/views/layouts/application.html.erb +0 -9
- data/stubs/hotwire/app/views/layouts/guest.html.erb +0 -6
- data/stubs/hotwire/app/views/profile/edit.html.erb +19 -22
- data/stubs/hotwire/app/views/profile/partials/_delete_user_form.html.erb +32 -42
- data/stubs/hotwire/app/views/profile/partials/_update_password_form.html.erb +42 -55
- data/stubs/hotwire/app/views/profile/partials/_update_profile_information_form.html.erb +36 -46
- data/stubs/hotwire/app/views/welcome/index.html.erb +34 -46
- data/stubs/hotwire/config/importmap.rb +3 -3
- data/stubs/hotwire/config/tailwind.config.js +2 -2
- data/stubs/inertia-common/app/controllers/application_controller.rb +1 -0
- data/stubs/inertia-common/app/controllers/auth/authenticated_session_controller.rb +11 -8
- data/stubs/inertia-common/app/controllers/auth/new_password_controller.rb +5 -3
- data/stubs/inertia-common/app/controllers/auth/password_reset_link_controller.rb +5 -3
- data/stubs/inertia-common/app/controllers/auth/registered_user_controller.rb +5 -3
- data/stubs/inertia-common/app/controllers/concerns/authenticate.rb +5 -20
- data/stubs/inertia-common/app/controllers/concerns/handle_inertia_requests.rb +1 -1
- data/stubs/inertia-common/app/controllers/concerns/redirect_if_authenticated.rb +19 -0
- data/stubs/inertia-common/app/controllers/concerns/set_current_auth.rb +9 -0
- data/stubs/inertia-common/app/controllers/concerns/verify_csrf_token.rb +4 -4
- data/stubs/inertia-common/app/controllers/dashboard_controller.rb +1 -1
- data/stubs/inertia-common/app/controllers/password_controller.rb +1 -1
- data/stubs/inertia-common/app/controllers/profile_controller.rb +7 -5
- data/stubs/inertia-common/app/controllers/welcome_controller.rb +2 -2
- data/stubs/inertia-common/bin/vite +6 -6
- data/stubs/inertia-common/test/integration/password_update_test.rb +28 -0
- data/stubs/inertia-common/test/integration/profile_test.rb +51 -0
- data/stubs/inertia-react-ts/app/javascript/Components/ApplicationLogo.tsx +13 -9
- data/stubs/inertia-react-ts/app/javascript/Components/Checkbox.tsx +15 -12
- data/stubs/inertia-react-ts/app/javascript/Components/DangerButton.tsx +20 -15
- data/stubs/inertia-react-ts/app/javascript/Components/Dropdown.tsx +119 -87
- data/stubs/inertia-react-ts/app/javascript/Components/InputError.tsx +14 -7
- data/stubs/inertia-react-ts/app/javascript/Components/InputLabel.tsx +18 -7
- data/stubs/inertia-react-ts/app/javascript/Components/Modal.tsx +60 -60
- data/stubs/inertia-react-ts/app/javascript/Components/NavLink.tsx +21 -16
- data/stubs/inertia-react-ts/app/javascript/Components/PrimaryButton.tsx +20 -15
- data/stubs/inertia-react-ts/app/javascript/Components/ResponsiveNavLink.tsx +19 -14
- data/stubs/inertia-react-ts/app/javascript/Components/SecondaryButton.tsx +22 -16
- data/stubs/inertia-react-ts/app/javascript/Components/TextInput.tsx +35 -24
- data/stubs/inertia-react-ts/app/javascript/Layouts/AuthenticatedLayout.tsx +157 -117
- data/stubs/inertia-react-ts/app/javascript/Layouts/GuestLayout.tsx +15 -15
- data/stubs/inertia-react-ts/app/javascript/Pages/Auth/ForgotPassword.tsx +52 -49
- data/stubs/inertia-react-ts/app/javascript/Pages/Auth/Login.tsx +90 -82
- data/stubs/inertia-react-ts/app/javascript/Pages/Auth/Register.tsx +118 -115
- data/stubs/inertia-react-ts/app/javascript/Pages/Auth/ResetPassword.tsx +63 -60
- data/stubs/inertia-react-ts/app/javascript/Pages/Dashboard.tsx +23 -17
- data/stubs/inertia-react-ts/app/javascript/Pages/Profile/Edit.tsx +31 -27
- data/stubs/inertia-react-ts/app/javascript/Pages/Profile/Partials/DeleteUserForm.tsx +109 -99
- data/stubs/inertia-react-ts/app/javascript/Pages/Profile/Partials/UpdatePasswordForm.tsx +121 -113
- data/stubs/inertia-react-ts/app/javascript/Pages/Profile/Partials/UpdateProfileInformationForm.tsx +76 -69
- data/stubs/inertia-react-ts/app/javascript/Pages/Welcome.tsx +87 -63
- data/stubs/inertia-react-ts/app/javascript/entrypoints/application.tsx +32 -25
- data/stubs/inertia-react-ts/app/views/layouts/application.html.erb +0 -4
- data/stubs/inertia-react-ts/config/tailwind.config.js +2 -2
- data/stubs/inertia-react-ts/vite.config.ts +2 -5
- data/stubs/inertia-vue-ts/app/javascript/Components/ApplicationLogo.vue +10 -6
- data/stubs/inertia-vue-ts/app/javascript/Components/Checkbox.vue +18 -18
- data/stubs/inertia-vue-ts/app/javascript/Components/DangerButton.vue +5 -5
- data/stubs/inertia-vue-ts/app/javascript/Components/Dropdown.vue +60 -57
- data/stubs/inertia-vue-ts/app/javascript/Components/DropdownLink.vue +9 -9
- data/stubs/inertia-vue-ts/app/javascript/Components/InputError.vue +7 -7
- data/stubs/inertia-vue-ts/app/javascript/Components/InputLabel.vue +6 -6
- data/stubs/inertia-vue-ts/app/javascript/Components/Modal.vue +84 -74
- data/stubs/inertia-vue-ts/app/javascript/Components/NavLink.vue +12 -12
- data/stubs/inertia-vue-ts/app/javascript/Components/PrimaryButton.vue +5 -5
- data/stubs/inertia-vue-ts/app/javascript/Components/ResponsiveNavLink.vue +12 -12
- data/stubs/inertia-vue-ts/app/javascript/Components/SecondaryButton.vue +13 -13
- data/stubs/inertia-vue-ts/app/javascript/Components/TextInput.vue +13 -13
- data/stubs/inertia-vue-ts/app/javascript/Layouts/AuthenticatedLayout.vue +168 -136
- data/stubs/inertia-vue-ts/app/javascript/Layouts/GuestLayout.vue +15 -13
- data/stubs/inertia-vue-ts/app/javascript/Pages/Auth/ForgotPassword.vue +56 -49
- data/stubs/inertia-vue-ts/app/javascript/Pages/Auth/Login.vue +78 -72
- data/stubs/inertia-vue-ts/app/javascript/Pages/Auth/Register.vue +101 -97
- data/stubs/inertia-vue-ts/app/javascript/Pages/Auth/ResetPassword.vue +71 -68
- data/stubs/inertia-vue-ts/app/javascript/Pages/Dashboard.vue +22 -14
- data/stubs/inertia-vue-ts/app/javascript/Pages/Profile/Edit.vue +34 -30
- data/stubs/inertia-vue-ts/app/javascript/Pages/Profile/Partials/DeleteUserForm.vue +87 -83
- data/stubs/inertia-vue-ts/app/javascript/Pages/Profile/Partials/UpdatePasswordForm.vue +105 -98
- data/stubs/inertia-vue-ts/app/javascript/Pages/Profile/Partials/UpdateProfileInformationForm.vue +69 -59
- data/stubs/inertia-vue-ts/app/javascript/Pages/Welcome.vue +74 -47
- data/stubs/inertia-vue-ts/app/views/layouts/application.html.erb +0 -4
- data/stubs/inertia-vue-ts/config/tailwind.config.js +2 -2
- data/stubs/inertia-vue-ts/vite.config.ts +2 -5
- metadata +19 -6
- data/stubs/hotwire/bin/vite +0 -27
- data/stubs/inertia-common/Procfile.dev +0 -3
- /data/stubs/{hotwire → default}/Procfile.dev +0 -0
- /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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57126b1b287c8bf01b88c9baaae1a139d4791fe50e575262ec483ef8ad58e6e1
|
4
|
+
data.tar.gz: 254ed015dfcab378aae5ef24b69c90819fc88f46b4e3557811f7a3b50c3a5bd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee1afd04c5c57655b90e2f43d93730e9abc9cfc2989dba0b5c9e8684c041628ca80c7aeb496c5c8cae3a26e71c1ec21af2de6e7404fe60290f8b5a8eac2639cd
|
7
|
+
data.tar.gz: c4fdc51d36d33cfa6a346a10ef933f7b2cdffeb08958ca6aac5b42cf3e5ac335245892ef1662a881ddd33ce0dc9b74dfd019b6b07683dc8ec82474b28c8e6174
|
@@ -1,27 +1,27 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
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
|
11
|
-
def install(stack =
|
12
|
-
if stack ==
|
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 ==
|
16
|
+
if stack == 'react'
|
17
17
|
return install_inertia_react_stack
|
18
18
|
end
|
19
19
|
|
20
|
-
if stack ==
|
20
|
+
if stack == 'vue'
|
21
21
|
return install_inertia_vue_stack
|
22
22
|
end
|
23
23
|
|
24
|
-
say
|
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(
|
57
|
-
versions = stdin.gsub!(
|
58
|
-
|
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([
|
7
|
-
return unless install_gems([
|
8
|
-
return unless install_gems([
|
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.
|
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/
|
57
|
-
run_command(
|
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
|
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([
|
7
|
-
return unless install_gems([
|
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/
|
60
|
-
|
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
|
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([
|
71
|
+
run_commands([ 'pnpm install', 'pnpm run build' ])
|
67
72
|
elsif File.exist?("#{Dir.pwd}/yarn.lock")
|
68
|
-
run_commands([
|
73
|
+
run_commands([ 'yarn install', 'yarn build' ])
|
69
74
|
elsif File.exist?("#{Dir.pwd}/bun.lockb")
|
70
|
-
run_commands([
|
75
|
+
run_commands([ 'bun install', 'bun run build' ])
|
71
76
|
else
|
72
|
-
run_commands([
|
77
|
+
run_commands([ 'npm install', 'npm run build' ])
|
73
78
|
end
|
74
79
|
|
75
|
-
say
|
76
|
-
say
|
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([
|
82
|
-
return unless install_gems([
|
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/
|
135
|
-
|
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
|
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([
|
151
|
+
run_commands([ 'pnpm install', 'pnpm run build' ])
|
142
152
|
elsif File.exist?("#{Dir.pwd}/yarn.lock")
|
143
|
-
run_commands([
|
153
|
+
run_commands([ 'yarn install', 'yarn build' ])
|
144
154
|
elsif File.exist?("#{Dir.pwd}/bun.lockb")
|
145
|
-
run_commands([
|
155
|
+
run_commands([ 'bun install', 'bun run build' ])
|
146
156
|
else
|
147
|
-
run_commands([
|
157
|
+
run_commands([ 'npm install', 'npm run build' ])
|
148
158
|
end
|
149
159
|
|
150
|
-
say
|
151
|
-
say
|
160
|
+
say ''
|
161
|
+
say 'Kaze scaffolding installed successfully.', :green
|
152
162
|
end
|
153
163
|
end
|
data/lib/kaze/version.rb
CHANGED
data/lib/kaze.rb
CHANGED
@@ -5,14 +5,8 @@ class Auth::LoginForm < ApplicationForm
|
|
5
5
|
validates :password, presence: true
|
6
6
|
|
7
7
|
def authenticate
|
8
|
-
return
|
8
|
+
return if invalid?
|
9
9
|
|
10
|
-
|
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:
|
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(
|
4
|
-
ENV.fetch(
|
3
|
+
ENV.fetch('MAIL_FROM_ADDRESS', 'hello@example.com'),
|
4
|
+
ENV.fetch('MAIL_FROM_NAME', 'Example')
|
5
5
|
)
|
6
|
-
layout
|
6
|
+
layout 'mailer'
|
7
7
|
|
8
8
|
def default_url_options
|
9
|
-
{ host: ENV.fetch(
|
9
|
+
{ host: ENV.fetch('APP_URL', 'http://localhost') }
|
10
10
|
end
|
11
11
|
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,5 +1,5 @@
|
|
1
1
|
class CurrentPasswordValidator < ActiveModel::EachValidator
|
2
2
|
def validate_each(record, attribute, value)
|
3
|
-
record.errors.add attribute,
|
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] ||
|
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 =
|
4
|
-
record.errors.add attribute, (options[:message] ||
|
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
|