kaze 0.10.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27a8de2c9dc1c9297b72ca20e60fc00582579e39cf1372ad019d6ab18c28942f
4
- data.tar.gz: fadd95b9700cc5409c2cffcaae03ba3ad68cc79b8331b6a9e27612a47d6e5ce7
3
+ metadata.gz: c65dc7f1acffb3ae6d361fbd4f1172fb46b857611dc0cc96b9229219869a3576
4
+ data.tar.gz: 5fa72ea32080be5c77a451bbc9cf24d6e8ff1c83af914c0b97004086cfd76e14
5
5
  SHA512:
6
- metadata.gz: a5bd8c23395b302a93fa836e33c10da76de5681d563f84c1f16ff70317583aa3470e05d03cdfd726257c0ece38ef20c8d72ffe0974e0cbdb14d93a7688a1686c
7
- data.tar.gz: 70cd7f58402805e19197e0c9f161ebde8891e5696eafdec0c96dc3017c52fe6f966068329c77f3f55a3e989cc983050694d91a68097502691fed80e4ea4084c0
6
+ metadata.gz: 51c93d3f462be29745003941d34a1d8d42da5ff6ab8127c59ae4fc9c3ab001cf23094cc5f298262b63d661507bb5e79d93657fce24ea1fd1c82d8de7d7e5ac7f
7
+ data.tar.gz: 3abcbcda1957bf7415d10fc5c142183ca0227925843b6a1aeebd9c5a158fc5eeed0b855963c60cd785ce4201ac13dcbc169d27cdfe6d3dd12d9b41798d0e7931
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Cuong Giang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -2,29 +2,41 @@
2
2
 
3
3
  # Kaze
4
4
 
5
- Heavily inspired by [Laravel Breeze](https://github.com/laravel/breeze), this gem offers authentication and application starter kits to give you a head start building your new Rails application. These kits automatically scaffold your application with the routes, controllers, and views you need to register and authenticate your application's users.
5
+ Heavily inspired by [Laravel Breeze](https://github.com/laravel/breeze), this gem offers authentication and application starter kits to give you a head start building your new [Rails](https://rubyonrails.org) application. These kits automatically scaffold your application with the routes, controllers, and views you need to register and authenticate your application's users.
6
6
 
7
- [Kaze](https://github.com/gtkvn/kaze) is a minimal, simple implementation of all of Rails's authentication features, including login, registration, password reset. In addition, Kaze includes a simple "profile" page where the user may update their name, email address, and password.
7
+ [Kaze](https://github.com/gtkvn/kaze) is a opinionated minimal, simple implementation of all authentication features that a modern web application should have, including login, registration, password reset, email verification. In addition, Kaze includes a simple "profile" page where the user may update their name, email address, and password.
8
8
 
9
9
  Kaze provides scaffolding options based on [Hotwire](https://hotwired.dev) or [Inertia](https://inertiajs.com), with the choice of using Vue or React for the Inertia-based scaffolding.
10
10
 
11
11
  ## Installation
12
12
 
13
- First, you should create a new Rails application, configure your database, and run your database migrations.
13
+ Before creating your first project powered by Kaze, make sure that your local machine has Ruby installed. Ruby can be installed in minutes via [mise](https://mise.jdx.dev).
14
14
 
15
- You may install Kaze globally with:
15
+ ```
16
+ mise use -g ruby@3.3
17
+ ```
18
+
19
+ After you have installed Ruby, you may install `rails` and `kaze` gems globally:
16
20
 
17
21
  ```
22
+ gem install rails
18
23
  gem install kaze
19
24
  ```
20
25
 
21
- Once Kaze is installed, you may scaffold your application using one of the Kaze "stacks" discussed in the documentation below.
26
+ Then, you may create a new Rails application:
27
+
28
+ ```
29
+ rails new kaze-example-app
30
+ cd kaze-example-app
31
+ ```
32
+
33
+ Once the project has been created, you may scaffold your application using one of the Kaze "stacks" discussed in the documentation below.
22
34
 
23
- ## Kaze & Hotwire
35
+ ## Kaze and Hotwire
24
36
 
25
37
  The default Kaze "stack" is the Hotwire stack. Hotwire is a powerful way to building dynamic, reactive, front-end UIs primarily using Ruby and ERB templates without using much JavaScript by sending HTML instead of JSON over the wire.
26
38
 
27
- The Hotwire stack may be installed by invoking the `install` command with no other additional arguments inside your app directory.
39
+ The Hotwire stack may be installed by invoking the `kaze install` command with no other additional arguments inside your app directory. This command publishes the authentication, views, routes, controllers, and other resources to your application.
28
40
 
29
41
  ```
30
42
  kaze install
@@ -37,13 +49,13 @@ bin/setup
37
49
  bin/dev
38
50
  ```
39
51
 
40
- Next, you may navigate to your application's `/login` or `/register` URLs in your web browser.
52
+ Next, you may navigate to your application's `/login` or `/register` URLs in your web browser. All of Kaze's routes are defined within the `config/routes.rb` file.
41
53
 
42
- ## Kaze & React / Vue
54
+ ## Kaze and React / Vue
43
55
 
44
56
  Kaze offers React and Vue scaffolding via an Inertia frontend implementation. Inertia allows you to build modern, single-page React and Vue applications using classic server-side routing and controllers.
45
57
 
46
- Inertia lets you enjoy the frontend power of React and Vue combined with the incredible backend productivity of Rails and lightning-fast Vite compilation. To use an Inertia stack, specify `react` or `vue` as your desired stack when executing the `install` command inside your app directory:
58
+ Inertia lets you enjoy the frontend power of React and Vue combined with the incredible backend productivity of Rails and lightning-fast Vite compilation. To use an Inertia stack, specify `react` or `vue` as your desired stack when executing the `kaze install` command:
47
59
 
48
60
  ```
49
61
  kaze install react
@@ -60,4 +72,4 @@ bin/setup
60
72
  bin/dev
61
73
  ```
62
74
 
63
- Next, you may navigate to your application's `/login` or `/register` URLs in your web browser.
75
+ Next, you may navigate to your application's `/login` or `/register` URLs in your web browser. All of Kaze's routes are defined within the `config/routes.rb` file.
@@ -11,17 +11,11 @@ class Kaze::Commands::InstallCommand < Thor
11
11
  def install(stack = 'hotwire')
12
12
  return say 'Kaze must be run in a new Rails application.', :red unless File.exist?("#{Dir.pwd}/bin/rails")
13
13
 
14
- if stack == 'hotwire'
15
- return install_hotwire_stack
16
- end
14
+ return install_hotwire_stack if stack == 'hotwire'
17
15
 
18
- if stack == 'react'
19
- return install_inertia_react_stack
20
- end
16
+ return install_inertia_react_stack if stack == 'react'
21
17
 
22
- if stack == 'vue'
23
- return install_inertia_vue_stack
24
- end
18
+ return install_inertia_vue_stack if stack == 'vue'
25
19
 
26
20
  say 'Invalid stack. Supported stacks are [hotwire], [react], [vue].', :red
27
21
  end
@@ -53,14 +47,14 @@ class Kaze::Commands::InstallCommand < Thor
53
47
  end
54
48
 
55
49
  def install_migrations
56
- ensure_directory_exists("#{Dir.pwd}/db/migrate")
57
- FileUtils.copy_entry("#{File.dirname(__FILE__)}/../../../stubs/default/db/migrate", "#{Dir.pwd}/db/migrate")
58
50
  stdin, _ = Open3.capture3("#{Dir.pwd}/bin/rails version")
59
51
  versions = stdin.gsub!('Rails ', '').split('.')
60
52
  railsVersion = [ versions[0], versions[1] ].join('.')
53
+
54
+ ensure_directory_exists("#{Dir.pwd}/db/migrate")
55
+ FileUtils.copy_entry("#{File.dirname(__FILE__)}/../../../stubs/default/db/migrate", "#{Dir.pwd}/db/migrate")
61
56
  Dir.children("#{Dir.pwd}/db/migrate").each do |file|
62
- path = "#{Dir.pwd}/db/migrate/#{file}"
63
- File.write(path, File.read(path).gsub!(/ActiveRecord::Migration$/, "ActiveRecord::Migration[#{railsVersion}]"))
57
+ replace_in_file(/ActiveRecord::Migration$/, "ActiveRecord::Migration[#{railsVersion}]", "#{Dir.pwd}/db/migrate/#{file}")
64
58
  end
65
59
  end
66
60
 
@@ -76,15 +70,19 @@ class Kaze::Commands::InstallCommand < Thor
76
70
  FileUtils.mkdir_p(path) unless File.directory?(path)
77
71
  end
78
72
 
73
+ def replace_in_file(search, replace, path)
74
+ File.write(path, File.read(path).gsub!(search, replace))
75
+ end
76
+
79
77
  def run_command(command)
80
78
  Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|
81
79
  stdout_thread = Thread.new do
82
- while (line = stdout.gets) do
80
+ while line = stdout.gets do
83
81
  say line
84
82
  end
85
83
  end
86
84
  stderr_thread = Thread.new do
87
- while (line = stderr.gets) do
85
+ while line = stderr.gets do
88
86
  say line, :red
89
87
  end
90
88
  end
@@ -60,7 +60,7 @@ module Kaze::Commands::InstallsInertiaStacks
60
60
  FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/default/bin/dev", "#{Dir.pwd}/bin/dev")
61
61
  FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/inertia-common/bin/vite", "#{Dir.pwd}/bin/vite")
62
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: bundle exec rake js:routes:typescript && bin/vite dev\n")
63
+ File.write("#{Dir.pwd}/Procfile.dev", "#{File.read("#{Dir.pwd}/Procfile.dev")}\nvite: bin/vite dev\n")
64
64
  run_command("#{Dir.pwd}/bin/rails generate js_routes:middleware")
65
65
  run_command("#{Dir.pwd}/bin/rails tailwindcss:build")
66
66
 
@@ -140,7 +140,7 @@ module Kaze::Commands::InstallsInertiaStacks
140
140
  FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/default/bin/dev", "#{Dir.pwd}/bin/dev")
141
141
  FileUtils.copy_file("#{File.dirname(__FILE__)}/../../../stubs/inertia-common/bin/vite", "#{Dir.pwd}/bin/vite")
142
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: bundle exec rake js:routes:typescript && bin/vite dev\n")
143
+ File.write("#{Dir.pwd}/Procfile.dev", "#{File.read("#{Dir.pwd}/Procfile.dev")}\nvite: bin/vite dev\n")
144
144
  run_command("#{Dir.pwd}/bin/rails generate js_routes:middleware")
145
145
  run_command("#{Dir.pwd}/bin/rails tailwindcss:build")
146
146
 
data/lib/kaze/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kaze
2
- VERSION = '0.10.0'
2
+ VERSION = '0.12.0'
3
3
  end
@@ -1,6 +1,4 @@
1
1
  module MustVerifyEmail
2
- extend ActiveSupport::Concern
3
-
4
2
  def has_verified_email?
5
3
  !email_verified_at.nil?
6
4
  end
@@ -1,11 +1,11 @@
1
1
  class CreateUsers < ActiveRecord::Migration
2
2
  def self.up
3
3
  create_table :users do |table|
4
- table.string :name
5
- table.string :email
6
- table.timestamp :email_verified_at, null: true
7
- table.string :password_digest
8
- table.string :remember_token, null: true
4
+ table.string :name, null: false
5
+ table.string :email, null: false
6
+ table.timestamp :email_verified_at
7
+ table.string :password_digest, null: false
8
+ table.string :remember_token
9
9
  table.timestamps
10
10
  end
11
11
  end
@@ -8,7 +8,7 @@ class ModalComponent < ViewComponent::Base
8
8
  lg: 'sm:max-w-lg',
9
9
  xl: 'sm:max-w-xl',
10
10
  '2xl': 'sm:max-w-2xl'
11
- }[attributes[:max_width] || '2xl']
11
+ }[(attributes[:max_width] || '2xl').to_sym]
12
12
  @attributes = attributes.without(:name, :show, :max_width)
13
13
  end
14
14
  end
@@ -22,7 +22,7 @@ class ProfileController < ApplicationController
22
22
  def destroy
23
23
  @delete_user_form = DeleteUserForm.new(params.permit(:password))
24
24
 
25
- return render partial: 'profile/partials/delete_user_form', status: :unprocessable_entity if @delete_user_form.invalid?
25
+ return render turbo_stream: turbo_stream.replace('confirm_user_deletion_modal', partial: 'profile/partials/confirm_user_deletion_modal'), status: :unprocessable_entity if @delete_user_form.invalid?
26
26
 
27
27
  user = Current.auth.user
28
28
 
@@ -0,0 +1,25 @@
1
+ <div id="confirm_user_deletion_modal">
2
+ <%= render(ModalComponent.new({ name: "confirm-user-deletion", show: @delete_user_form.error_messages.has_key?(:password), focusable: true })) do %>
3
+ <%= form_with model: @delete_user_form, url: profile_destroy_path, method: "delete", class: "p-6" do %>
4
+ <h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
5
+ Are you sure you want to delete your account?
6
+ </h2>
7
+ <p class="mt-1 text-sm text-gray-600 dark:text-gray-400">
8
+ Once your account is deleted, all of its resources and data will be permanently deleted. Please enter your password to confirm you would like to permanently delete your account.
9
+ </p>
10
+ <div class="mt-6">
11
+ <%= render(InputLabelComponent.new({ for: "password", value: "Password", class: "sr-only" })) %>
12
+ <%= render(TextInputComponent.new({ id: "password", class: "mt-1 block w-3/4", type: "password", name: "password", placeholder: "Password" })) %>
13
+ <%= render(InputErrorComponent.new({ class: "mt-2", message: @delete_user_form.error_messages[:password] })) %>
14
+ </div>
15
+ <div class="mt-6 flex justify-end">
16
+ <%= render(SecondaryButtonComponent.new({ "x-on:click": "$dispatch('close')" })) do %>
17
+ Cancel
18
+ <% end %>
19
+ <%= render(DangerButtonComponent.new({ class: "ms-3" })) do %>
20
+ Delete Account
21
+ <% end %>
22
+ </div>
23
+ <% end %>
24
+ <% end %>
25
+ </div>
@@ -10,29 +10,5 @@
10
10
  <%= render(DangerButtonComponent.new({"x-data": "", "x-on:click.prevent": "$dispatch('open-modal', 'confirm-user-deletion')"})) do %>
11
11
  Delete Account
12
12
  <% end %>
13
- <%= render(ModalComponent.new({ name: "confirm-user-deletion", show: @delete_user_form.error_messages.has_key?(:password), focusable: true })) do %>
14
- <turbo-frame id="delete_user_form">
15
- <%= form_with model: @delete_user_form, url: profile_destroy_path, method: "delete", class: "p-6" do %>
16
- <h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
17
- Are you sure you want to delete your account?
18
- </h2>
19
- <p class="mt-1 text-sm text-gray-600 dark:text-gray-400">
20
- Once your account is deleted, all of its resources and data will be permanently deleted. Please enter your password to confirm you would like to permanently delete your account.
21
- </p>
22
- <div class="mt-6">
23
- <%= render(InputLabelComponent.new({ for: "password", value: "Password", class: "sr-only" })) %>
24
- <%= render(TextInputComponent.new({ id: "password", class: "mt-1 block w-3/4", type: "password", name: "password", placeholder: "Password" })) %>
25
- <%= render(InputErrorComponent.new({ class: "mt-2", message: @delete_user_form.error_messages[:password] })) %>
26
- </div>
27
- <div class="mt-6 flex justify-end">
28
- <%= render(SecondaryButtonComponent.new({ "x-on:click": "$dispatch('close')" })) do %>
29
- Cancel
30
- <% end %>
31
- <%= render(DangerButtonComponent.new({ class: "ms-3" })) do %>
32
- Delete Account
33
- <% end %>
34
- </div>
35
- <% end %>
36
- </turbo-frame>
37
- <% end %>
13
+ <%= render 'profile/partials/confirm_user_deletion_modal' %>
38
14
  </section>
@@ -3,7 +3,6 @@
3
3
  <head>
4
4
  <meta charset="utf-8">
5
5
  <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <meta name="turbo-visit-control" content="reload">
7
6
  <title><%= content_for(:title) || "Rails" %></title>
8
7
  <%= csrf_meta_tags %>
9
8
  <%= csp_meta_tag %>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kaze
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cuong Giang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-19 00:00:00.000000000 Z
11
+ date: 2024-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.2'
19
+ version: '1.3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.2'
26
+ version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: zeitwerk
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.5'
33
+ version: '2.6'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.5'
40
+ version: '2.6'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: railties
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -60,6 +60,7 @@ executables:
60
60
  extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
+ - LICENSE.md
63
64
  - README.md
64
65
  - bin/kaze
65
66
  - lib/kaze.rb
@@ -150,6 +151,7 @@ files:
150
151
  - stubs/hotwire/app/views/layouts/application.html.erb
151
152
  - stubs/hotwire/app/views/layouts/guest.html.erb
152
153
  - stubs/hotwire/app/views/profile/edit.html.erb
154
+ - stubs/hotwire/app/views/profile/partials/_confirm_user_deletion_modal.html.erb
153
155
  - stubs/hotwire/app/views/profile/partials/_delete_user_form.html.erb
154
156
  - stubs/hotwire/app/views/profile/partials/_update_password_form.html.erb
155
157
  - stubs/hotwire/app/views/profile/partials/_update_profile_information_form.html.erb
@@ -260,7 +262,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
260
262
  requirements:
261
263
  - - ">="
262
264
  - !ruby/object:Gem::Version
263
- version: '0'
265
+ version: 3.1.0
264
266
  required_rubygems_version: !ruby/object:Gem::Requirement
265
267
  requirements:
266
268
  - - ">="
@@ -270,5 +272,6 @@ requirements: []
270
272
  rubygems_version: 3.5.9
271
273
  signing_key:
272
274
  specification_version: 4
273
- summary: Minimal Rails authentication scaffolding with Hotwire, Vue, or React + Tailwind.
275
+ summary: Opinionated minimal Rails authentication scaffolding with Hotwire, React,
276
+ or Vue + Tailwind.
274
277
  test_files: []