kaze 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7ab421b0a7d20dbb30c5b0aaf56162163b146eda38f71a29be7a828aa1625b9
4
- data.tar.gz: 992e0ec2554ad5b93feb3e88780e774333af09a047bc633cf59d4371e158c4ef
3
+ metadata.gz: ab4d236e7d08529caaafe2924edaab3a90cb9742fe5dcf916cb6e188bf453d38
4
+ data.tar.gz: 57eb011f2173bf00a346195b91d0620777f173be7acf22d97b97cf94b803e6bf
5
5
  SHA512:
6
- metadata.gz: 464c2bea1cbd7454d506daae0e0ea93860c03522a3c5d3a33008677452412668590cea894890c2467a0c2f624c1ca4acc50c7fa2e156354a8a4a9971924a7674
7
- data.tar.gz: 9ab0ae727a1b18b1d5bdfb0c8b346d7e86a94338094b758fef7791a38cd91ed47d5be3c7c9e9807ed3d0f156ad7ef4c0e5c1156923b8303b005a24a2eb2f6ef6
6
+ metadata.gz: af68391e4cce4dace60eb32e614b55c6ea4fe3fc6cd52f7a1c3ff614a4e9b2b5c295d31dada55c57f001ddb850f5cdfc4251c337de4176425162532f941343c2
7
+ data.tar.gz: 0611eeedb28e33537e0d09f85dfdbb1010caad5ef3409ca9bd84ee7b1fddf69197343ffa416c2ca003ddd496849e606bdb76632cf0f909d0dd023dd86a9fecf1
data/CHANGELOG.md CHANGED
@@ -6,6 +6,22 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [2.2.1] - 2026-10-27
10
+
11
+ ### Added
12
+
13
+ - The install now says what to do next: `Run bin/rails db:prepare to apply the migrations Kaze installed.` A new application reaches its migrations through `bin/setup`, but an upgrade has no such step, so 2.2.0 handed existing applications the two factor settings page and login challenge while their database still had none of the columns behind them. The `## Upgrading` section of the README says it too.
14
+
15
+ ### Fixed
16
+
17
+ - `kaze install` and `kaze upgrade` no longer empty files. `replace_in_file` wrote the result of `String#gsub!` back to disk, and the bang form returns `nil` when it matched nothing — so `File.write` truncated the file to nothing. Every call site passes a pattern that can legitimately be absent, either because an earlier install already applied it or because the application edited it out, and each of those was a file silently destroyed. It is `gsub` now, which returns the string unchanged when it matches nothing.
18
+
19
+ Two files were reachable this way. An application's own migrations were emptied on the **first** upgrade: the rewrite that stamps the Rails version into Kaze's migrations walked the whole of `db/migrate`, and the pattern it uses only fits the ones Kaze ships, since a generated migration already carries its `[8.1]` suffix. `rails db:migrate` did not complain, because the version was already recorded and Rails never read the file again — the loss surfaced later, as `NameError: uninitialized constant` on a rollback, or as a schema that could no longer be rebuilt from its migrations. This dates from 2024-07-01 and has been in every release since; it took an application with a migration of its own to show, which is why neither the test suite nor the 1.4.0 upgrade test caught it. The rewrite is now scoped to the files Kaze copied.
20
+
21
+ `config/environments/test.rb` was emptied on the **second** upgrade, and on any upgrade of an application already on 2.2.0. `enable_test_cache_store` rewrites `:null_store` to `:memory_store`, so a second run found nothing to match and truncated the file; the suite then came apart with 15 failures and 31 errors. That one was introduced in 2.2.0, a few hours before this fix.
22
+
23
+ - `install_migrations` no longer crashes if `bin/rails version` prints something unexpected, for the same reason: it called `gsub!` on the output and then `split` on the result.
24
+
9
25
  ## [2.2.0] - 2026-10-27
10
26
 
11
27
  ### Added
@@ -261,7 +277,8 @@ Together these take a freshly scaffolded Inertia application from seven npm advi
261
277
 
262
278
  Releases before 1.0.0 are not catalogued here. See the [tags](https://github.com/cuonggt/kaze/tags) for their history.
263
279
 
264
- [Unreleased]: https://github.com/cuonggt/kaze/compare/v2.2.0...HEAD
280
+ [Unreleased]: https://github.com/cuonggt/kaze/compare/v2.2.1...HEAD
281
+ [2.2.1]: https://github.com/cuonggt/kaze/compare/v2.2.0...v2.2.1
265
282
  [2.2.0]: https://github.com/cuonggt/kaze/compare/v2.1.1...v2.2.0
266
283
  [2.1.1]: https://github.com/cuonggt/kaze/compare/v2.1.0...v2.1.1
267
284
  [2.1.0]: https://github.com/cuonggt/kaze/compare/v2.0.1...v2.1.0
data/README.md CHANGED
@@ -126,4 +126,12 @@ kaze upgrade react
126
126
 
127
127
  It lists the files an earlier Kaze installed that this version no longer ships, waits for you to agree, removes them, and then runs the normal install. Only files Kaze itself shipped are ever listed — anything you added alongside them is untouched, and a directory is removed only once it is empty. Pass `--dry-run` to see the list and stop, or `--force` to skip the prompt in a script.
128
128
 
129
+ An upgrade can bring migrations with it, so run them afterwards:
130
+
131
+ ```
132
+ bin/rails db:prepare
133
+ ```
134
+
135
+ Upgrading to 2.2 in particular adds the columns two factor authentication needs. Until they are applied, the settings page and the login challenge are reading columns the database does not have.
136
+
129
137
  Upgrading from 1.x to 2.x matters on the React stack in particular: `tsc` typechecks every file under `app/javascript`, so the old `Pages/Profile/Edit.tsx` fails the build until it is gone.
@@ -74,12 +74,17 @@ class Kaze::Commands::App::BaseStack
74
74
 
75
75
  def install_migrations
76
76
  stdin, _ = Open3.capture3("#{Dir.pwd}/bin/rails version")
77
- versions = stdin.gsub!('Rails ', '').split('.')
77
+ versions = stdin.gsub('Rails ', '').split('.')
78
78
  railsVersion = [ versions[0], versions[1] ].join('.')
79
79
 
80
80
  ensure_directory_exists("#{Dir.pwd}/db/migrate")
81
+
82
+ # Only the migrations Kaze ships get the version written into them. The
83
+ # application's own already carry one, and are none of our business.
84
+ migrations = Dir.children("#{stubs_path}/default/db/migrate")
85
+
81
86
  FileUtils.copy_entry("#{stubs_path}/default/db/migrate", "#{Dir.pwd}/db/migrate")
82
- Dir.children("#{Dir.pwd}/db/migrate").each { |file| replace_in_file(/ActiveRecord::Migration$/, "ActiveRecord::Migration[#{railsVersion}]", "#{Dir.pwd}/db/migrate/#{file}") }
87
+ migrations.each { |file| replace_in_file(/ActiveRecord::Migration$/, "ActiveRecord::Migration[#{railsVersion}]", "#{Dir.pwd}/db/migrate/#{file}") }
83
88
  end
84
89
 
85
90
  # Rate limiting counts attempts in the cache, and a generated application uses
@@ -108,8 +113,23 @@ class Kaze::Commands::App::BaseStack
108
113
  FileUtils.mkdir_p(path) unless File.directory?(path)
109
114
  end
110
115
 
116
+ # Kaze ships migrations, and an install that adds one leaves the application
117
+ # holding code for columns the database does not have yet. A new application
118
+ # reaches them through `bin/setup`, but an upgrade of an existing one has no
119
+ # such step, so say it here where the person is already looking.
120
+ def say_installed_successfully
121
+ say ''
122
+ say 'Kaze scaffolding installed successfully.', :green
123
+ say ''
124
+ say 'Run `bin/rails db:prepare` to apply the migrations Kaze installed.', :yellow
125
+ end
126
+
127
+ # NOTE: `gsub`, not `gsub!`. The bang form returns nil when it matched
128
+ # nothing, and writing that back truncates the file to nothing -- so a
129
+ # pattern that had already been applied, or that an application had edited
130
+ # out, silently emptied the file instead of leaving it alone.
111
131
  def replace_in_file(search, replace, path)
112
- File.write(path, File.read(path).gsub!(search, replace))
132
+ File.write(path, File.read(path).gsub(search, replace))
113
133
  end
114
134
 
115
135
  def run_command(command)
@@ -79,8 +79,7 @@ class Kaze::Commands::App::HotwireStack < Kaze::Commands::App::BaseStack
79
79
  FileUtils.copy_file("#{stubs_path}/default/Procfile.dev", "#{Dir.pwd}/Procfile.dev")
80
80
  return unless run_command("#{Dir.pwd}/bin/rails tailwindcss:build").success?
81
81
 
82
- say ''
83
- say 'Kaze scaffolding installed successfully.', :green
82
+ say_installed_successfully
84
83
 
85
84
  true
86
85
  end
@@ -108,8 +108,7 @@ class Kaze::Commands::App::InertiaReactStack < Kaze::Commands::App::BaseStack
108
108
 
109
109
  return unless node_dependencies_installed
110
110
 
111
- say ''
112
- say 'Kaze scaffolding installed successfully.', :green
111
+ say_installed_successfully
113
112
 
114
113
  true
115
114
  end
@@ -109,8 +109,7 @@ class Kaze::Commands::App::InertiaVueStack < Kaze::Commands::App::BaseStack
109
109
 
110
110
  return unless node_dependencies_installed
111
111
 
112
- say ''
113
- say 'Kaze scaffolding installed successfully.', :green
112
+ say_installed_successfully
114
113
 
115
114
  true
116
115
  end
data/lib/kaze/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kaze
2
- VERSION = '2.2.0'
2
+ VERSION = '2.2.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kaze
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cuong Giang