bankai 0.14.0 → 1.0.0

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: fe9b1776bfdff5af83481b22cec737cdb8195272b225596a5704768f54a2bf3f
4
- data.tar.gz: bff0047859348263752e86c09db55faa42da2f2956d887cfdf90fb4bbdc1c769
3
+ metadata.gz: 071eeba50ff152ec4a06b72062f9945424e379239ae02f900a02931c96b06d12
4
+ data.tar.gz: db429ae75b6ddf8b6eb0923b3c60117465a0caa03b845396e9f680b01e98dcf6
5
5
  SHA512:
6
- metadata.gz: c6b706b63a08723885ccc9a1ed219190bd023219970e1a464ee603c7c236485cc85e0962246b9130932f9ebb37b774861ed8c1ece28d2348b80d59879d1a71e9
7
- data.tar.gz: efd17a139f4a3a821a2861fb019fbad3f79b2720edca691ba81cb50425d1214fb487b36ec04cc9a3c69d811c5073b6adb14ea86d421c2f0112cae75f951ce120
6
+ metadata.gz: ce4d77ed36e3dba7d184a9c4c7edcca8a88ec1687aa9a3e209eeda4ca802a2a3cfa03a79ac34adc4f1a04bb5b45b0a5122dbf1ea3e33a6d994faeacebf22a483
7
+ data.tar.gz: 1efdf6257b89a00dee66362de7fb606d54a00723051e4f35ec61d29f859f06ff4938c9279c25d3293d0af81a70005d176ce2b777310d221c0aa350fe3d997201
@@ -14,7 +14,7 @@ jobs:
14
14
  fail-fast: false
15
15
  matrix:
16
16
  ruby-version: ['3.2', '3.3', '3.4', '4.0']
17
- rails-version: ['7.0', '7.1', '7.2', '8.1']
17
+ rails-version: ['8.0', '8.1']
18
18
 
19
19
  name: Ruby ${{ matrix.ruby-version }} / Rails ${{ matrix.rails-version }}
20
20
 
data/CHANGELOG.md ADDED
@@ -0,0 +1,89 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here.
4
+
5
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
6
+ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ Releases before 1.0.0 are not listed; see the [git tags](https://github.com/5xRuby/bankai/tags)
9
+ for that history.
10
+
11
+ ## [Unreleased]
12
+
13
+ ## [1.0.0] - 2026-09-09
14
+
15
+ The generated stack changed substantially and Rails 7 is no longer supported,
16
+ so this release is not backwards compatible with `0.14`.
17
+
18
+ ### Changed
19
+
20
+ - **Default database is now `sqlite3`** (was `postgresql`).
21
+ - **Solid Queue / Cache / Cable are installed by default** — `--skip-solid` now
22
+ defaults to `false`.
23
+ - **Falcon replaces Puma as the app server.** `puma` is filtered out of the
24
+ Gemfile, `config/puma.rb` is removed, and `bin/dev` runs
25
+ `falcon serve --bind http://localhost:3000 --count 1`.
26
+ - **Thruster is now installed by default** (`--skip-thruster` defaults to
27
+ `false`) and fronts Falcon in the Dockerfile, for HTTP/2, public asset
28
+ caching, X-Sendfile and compression. TLS stays off unless `TLS_DOMAIN` is set.
29
+ - **Generated projects use Minitest instead of RSpec.** The surrounding tooling
30
+ is unchanged: `factory_bot_rails`, `faker`, `shoulda-matchers`,
31
+ `database_rewinder`, `simplecov` and `simplecov-cobertura`. `shoulda-context`
32
+ is added so the `should` macro is available. Note that fixtures are not used:
33
+ DatabaseRewinder truncates every table, which conflicts with `fixtures :all`,
34
+ so `use_transactional_tests` is off and test data comes from factories.
35
+ - **`.rubocop.yml` inherits `rubocop-rails-omakase`** instead of carrying
36
+ bankai's own cop list, and is written with `force: true` to overwrite the one
37
+ Rails generates. `rubocop-rspec` is replaced by `rubocop-minitest`.
38
+ - `annotate` (unmaintained) is replaced by `annotaterb`.
39
+ - `.gitlab-ci.yml` runs `bin/rails test`, and only declares `services:` when
40
+ PostgreSQL or MySQL is actually in use.
41
+ - Scaffolded directories are now `test/factories`, `test/requests` and
42
+ `test/support/{matchers,mixins}`.
43
+ - Development dependencies were unpinned from ancient versions (`rake ~> 13`,
44
+ `rubocop ~> 1.90`, `simplecov ~> 0.22`) so `bundle exec` works on Ruby 4.0.
45
+
46
+ ### Removed
47
+
48
+ - **Rails 7 support.** The gem now requires `rails >= 8.0.0`; the CI matrix is
49
+ Ruby 3.2/3.3/3.4/4.0 x Rails 8.0/8.1. `falcon-rails` requires Rails >= 8.0,
50
+ so Rails 7 could only ever have run on a degraded path.
51
+ - The `--skip-rspec` option. Use `--skip-test` (default `false`) instead.
52
+ - The `RUBOCOP_VERSION` constant, now that RuboCop is not version-pinned in the
53
+ Gemfile template.
54
+ - Dead version branches: the `SUPPORTED_DATABASES` fallback chain, the
55
+ pre-Rails-6 `app_name` branch, and the `options.skip_yarn?` block in the
56
+ gitignore template.
57
+
58
+ ### Fixed
59
+
60
+ - `exe/bankai` computed its load path as `"#{dirname}../lib"`, missing a
61
+ separator, and appended rather than prepended it — so running it from a
62
+ checkout silently used the *installed* bankai gem, making local generator
63
+ changes untestable.
64
+ - `TargetRubyVersion: <%= RUBY_VERSION %>` in the RuboCop template produced
65
+ `4.0.6` on Ruby 4.0, which RuboCop rejects (it only accepts `major.minor`),
66
+ breaking RuboCop in every generated project.
67
+ - `templates/Gemfile.erb` replaces Rails' own Gemfile template wholesale, which
68
+ silently dropped everything Rails declares there (`solid_*`, `kamal`,
69
+ `rubocop-rails-omakase`). Those are now declared by bankai.
70
+ - Deprecated Bundler platform names (`%i[mingw mswin x64_mingw]`) are now
71
+ `%i[windows jruby]` / `%i[mri windows]`.
72
+ - The deprecated `SimpleCov.add_filter` call is now `SimpleCov.skip`.
73
+ - Rails' Dockerfile `CMD` is rewritten to run `falcon serve`. It shipped as
74
+ `bin/rails server`, which cannot start Falcon — falcon-rails deliberately does
75
+ not load Falcon during boot, so the Rackup handler is unavailable and
76
+ `rails server` fails with "Could not find a server gem" — meaning the
77
+ generated Dockerfile would not have booted at all. With `--no-skip-thruster`
78
+ the `CMD` becomes `./bin/thrust sh -c 'exec ... --bind http://0.0.0.0:$PORT'`,
79
+ so `$PORT` expands in the shell Thruster starts rather than in one wrapping it.
80
+ - `gem "thruster"` is declared in the Gemfile template, so `--no-skip-thruster`
81
+ actually installs it (same omission as `solid_*` and `kamal`).
82
+ - The generated Gemfile now pins `gem 'bankai', '~> <major>.<minor>'`. It was
83
+ unpinned, so running an unreleased `exe/bankai` without `--path` silently
84
+ bundled an older published bankai and ran *its* `bankai:*` sub-generators;
85
+ now `bundle install` fails instead. `--path` replaces the whole line, since a
86
+ path source and a version requirement cannot both be given.
87
+
88
+ [Unreleased]: https://github.com/5xRuby/bankai/compare/v1.0.0...HEAD
89
+ [1.0.0]: https://github.com/5xRuby/bankai/compare/v0.14.0...v1.0.0
data/CLAUDE.md CHANGED
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
4
4
 
5
5
  ## Project Overview
6
6
 
7
- Bankai is a Rails application template generator by 5xRuby (inspired by thoughtbot's Suspenders). It generates new Rails projects pre-configured with 5xRuby's standard tooling: RSpec, Rubocop, Overcommit, GitLab CI, and more.
7
+ Bankai is a Rails application template generator by 5xRuby (inspired by thoughtbot's Suspenders). It generates new Rails projects pre-configured with 5xRuby's standard tooling: Minitest, Rubocop, Overcommit, GitLab CI, and more.
8
8
 
9
9
  The CLI entry point is `exe/bankai`, which invokes `Bankai::Generator`.
10
10
 
@@ -50,14 +50,24 @@ ERB templates for generated project files (Gemfile, .rubocop.yml, .gitlab-ci.yml
50
50
 
51
51
  ## Key Options
52
52
 
53
- The generator accepts: `--database` (postgresql/mysql2/sqlite3, default: postgresql), `--capistrano`, `--skip-rspec`, `--skip-kamal` (default: true), `--skip-solid` (default: true), `--skip-thruster` (default: true), `--api`, `--path` (local gem path for testing).
53
+ The generator accepts: `--database` (postgresql/mysql2/sqlite3, default: sqlite3), `--capistrano`, `--skip-test`, `--skip-kamal` (default: true), `--skip-solid` (default: false), `--skip-thruster` (default: false), `--api`, `--path` (local gem path for testing).
54
54
 
55
55
  ## Rails Version Compatibility
56
56
 
57
- - Supports Rails 7.0 through 8.1+
58
- - Rails 8+ features (Kamal, Solid Queue/Cache/Cable, Thruster) are skipped by default
59
- - Rails 8+ auto-generates `.rubocop.yml`, so bankai skips its own rubocop config/autocorrect on Rails 8+
60
- - `inject_into_file` in sub-generators uses `Rails.application.configure do\n` as anchor (works across all Rails versions)
57
+ - Supports Rails 8.0 and 8.1 only (Rails 7 support was dropped: falcon-rails requires Rails >= 8.0)
58
+ - Defaults: sqlite3 + Solid Queue/Cache/Cable + falcon-rails as the app server
59
+ - Tests are Minitest (Rails' default), with factory_bot + faker for data and DatabaseRewinder
60
+ instead of transactional fixtures; `templates/test_helper.rb` replaces the one Rails generates
61
+ - Thruster is enabled by default and fronts Falcon; it is not Puma-specific (it proxies to
62
+ whatever command it wraps, passing the backend port via `$PORT`). Kamal stays skipped
63
+ - `Builder#rewrite_dockerfile_cmd` rewrites Rails' Dockerfile `CMD`, which uses
64
+ `bin/rails server`. That cannot run Falcon: falcon-rails deliberately avoids loading
65
+ Falcon during boot, so the Rackup handler is unavailable and `rails server` reports
66
+ "Could not find a server gem". Use `falcon serve` directly
67
+ - `templates/Gemfile.erb` replaces Rails' own Gemfile wholesale, so anything Rails declares in its Gemfile template (solid_*, kamal, rubocop-rails-omakase) must be repeated there
68
+ - `.rubocop.yml` inherits `rubocop-rails-omakase`; bankai writes it with `force: true` to overwrite the one Rails 8 generates
69
+ - Puma is filtered out of `gemfile_entries`; `Builder#remove_puma_config` deletes `config/puma.rb` and rewrites `bin/dev` to run `falcon serve`
70
+ - `inject_into_file` in sub-generators uses `Rails.application.configure do\n` as anchor
61
71
  - `Bundler.with_unbundled_env` wraps sub-generator invocations and `rails_command` to prevent Bundler env leakage
62
72
 
63
73
  ## Testing Locally
@@ -74,5 +84,5 @@ cd /tmp && bankai testapp --skip-rspec
74
84
 
75
85
  - All Ruby files use `# frozen_string_literal: true`
76
86
  - Version constants are in `lib/bankai/version.rb`
77
- - Required Ruby version: >= 3.2.0
87
+ - Required Ruby version: >= 3.2.0; CI matrix is Ruby 3.2/3.3/3.4/4.0 x Rails 8.0/8.1
78
88
  - Generated project README templates are in Traditional Chinese (zh-TW)
data/README.md CHANGED
@@ -20,20 +20,24 @@ bankai projectname
20
20
  ## Requirement
21
21
 
22
22
  * Ruby >= 3.2.0
23
- * `~> 0.13` required `rails >= 7.0` (tested up to Rails 8.1)
23
+ * `>= 1.0` requires `rails >= 8.0` (tested against Rails 8.0 and 8.1)
24
+ * `~> 0.13` required `rails >= 7.0`
24
25
  * `<= 0.12` required `rails >= 5.2`
25
26
 
27
+ See [CHANGELOG.md](CHANGELOG.md) for what changed in 1.0.
28
+
26
29
  ## Gemfile
27
30
 
28
31
  * [Oj](http://www.ohler.com/oj/)
32
+ * [Falcon](https://github.com/socketry/falcon-rails) - app server (replaces Puma)
29
33
 
30
34
  ### Development
31
35
 
32
36
  * [Brakeman](https://github.com/presidentbeef/brakeman)
33
37
  * [Bundler Audit](https://github.com/rubysec/bundler-audit)
34
- * [Rubocop](https://github.com/bbatsov/rubocop)
38
+ * [Rubocop](https://github.com/rubocop/rubocop) - inherits [rubocop-rails-omakase](https://github.com/rails/rubocop-rails-omakase)
35
39
  * [Rack Mini Profiler](https://github.com/MiniProfiler/rack-mini-profiler) - Enable with `RACK_MINI_PROFILER=1`
36
- * [Annotate](https://github.com/ctran/annotate_models)
40
+ * [AnnotateRb](https://github.com/drwl/annotaterb)
37
41
  * [Bullet](https://github.com/flyerhzm/bullet)
38
42
  * [Dotenv](https://github.com/bkeepers/dotenv)
39
43
  * [Letter Opener](https://github.com/ryanb/letter_opener)
@@ -42,11 +46,13 @@ bankai projectname
42
46
 
43
47
  ### Test
44
48
 
49
+ * [Minitest](https://guides.rubyonrails.org/testing.html) - Rails' built-in test framework
45
50
  * [Capybara](https://github.com/teamcapybara/capybara)
46
51
  * [Factory Bot](https://github.com/thoughtbot/factory_bot)
47
- * [Faker](https://github.com/stympy/faker)
48
- * [Rspec](https://github.com/rspec/rspec)
52
+ * [Faker](https://github.com/faker-ruby/faker)
53
+ * [Shoulda Context](https://github.com/thoughtbot/shoulda-context)
49
54
  * [Shoulda Matchers](https://github.com/thoughtbot/shoulda-matchers)
55
+ * [Database Rewinder](https://github.com/amatsuda/database_rewinder)
50
56
  * [Simplecov](https://github.com/colszowka/simplecov) - Enable with `COVERAGE=1`
51
57
 
52
58
  ## Others
@@ -62,12 +68,28 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
62
68
 
63
69
  ### Test Gem
64
70
 
65
- If you want to test the changes for generator is works well, you can add `--path` options to use your local version
71
+ To try your local changes, run `exe/bankai` straight out of the checkout and
72
+ point `--path` at that same checkout:
66
73
 
67
74
  ```
68
- bankai projectname --path=YOUR_LOCAL_GEM_PATH
75
+ cd /somewhere/else
76
+ ruby /path/to/bankai/exe/bankai projectname --path=/path/to/bankai
69
77
  ```
70
78
 
79
+ Both parts matter, and they do different things:
80
+
81
+ * which `exe/bankai` you run decides whose `lib/` and `templates/` generate the app
82
+ * `--path` decides which bankai the **generated app** bundles, and therefore
83
+ which version runs the `bankai:*` sub-generators (testing, ci, lint, ...)
84
+
85
+ Without `--path` the generated Gemfile asks for the released
86
+ `gem 'bankai', '~> <major>.<minor>'`, so an unreleased version fails at
87
+ `bundle install` rather than silently running an older gem's sub-generators.
88
+
89
+ Do not run this from inside the bankai repo, and do not set `BUNDLE_GEMFILE` —
90
+ the generated app's `bundle install` would then resolve against bankai's own
91
+ Gemfile.
92
+
71
93
  ## Contributing
72
94
 
73
95
  Bug reports and pull requests are welcome on GitHub at https://github.com/5xRuby/bankai. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
data/bankai.gemspec CHANGED
@@ -29,11 +29,11 @@ Gem::Specification.new do |spec|
29
29
 
30
30
  spec.add_development_dependency 'bundler-audit'
31
31
  spec.add_development_dependency 'overcommit'
32
- spec.add_development_dependency 'rake', '~> 12.0'
32
+ spec.add_development_dependency 'rake', '~> 13.0'
33
33
  spec.add_development_dependency 'rspec', '~> 3.0'
34
34
  spec.add_development_dependency 'rspec_junit_formatter'
35
- spec.add_development_dependency 'rubocop', '~> 1.8.1'
36
- spec.add_development_dependency 'simplecov', '~> 0.17.1'
35
+ spec.add_development_dependency 'rubocop', '~> 1.90'
36
+ spec.add_development_dependency 'simplecov', '~> 0.22'
37
37
 
38
38
  # TODO: Allow specify rails version
39
39
  spec.add_dependency 'rails', ">= #{Bankai::RAILS_VERSION}"
data/exe/bankai CHANGED
@@ -1,10 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'pathname'
5
-
6
- source_path = File.expand_path("#{Pathname.new(__FILE__).dirname}../lib")
7
- $LOAD_PATH << source_path
4
+ # Prepend, so running this file straight out of a checkout uses that checkout
5
+ # rather than whichever bankai gem happens to be installed.
6
+ $LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
8
7
 
9
8
  require 'bankai'
10
9
 
@@ -3,6 +3,15 @@
3
3
  module Bankai
4
4
  # :nodoc:
5
5
  class Builder < Rails::AppBuilder
6
+ # Thruster sets $PORT for its child, so the expansion has to happen in a
7
+ # shell that Thruster itself starts, not in one wrapping it.
8
+ DOCKERFILE_CMD_REPLACEMENTS = {
9
+ 'CMD ["./bin/thrust", "./bin/rails", "server"]' =>
10
+ 'CMD ["./bin/thrust", "sh", "-c", "exec bundle exec falcon serve --bind http://0.0.0.0:$PORT"]',
11
+ 'CMD ["./bin/rails", "server"]' =>
12
+ 'CMD ["bundle", "exec", "falcon", "serve", "--bind", "http://0.0.0.0:3000"]'
13
+ }.freeze
14
+
6
15
  def readme
7
16
  template 'README.md.erb', 'README.md'
8
17
  end
@@ -17,20 +26,44 @@ module Bankai
17
26
 
18
27
  def replace_gemfile(path)
19
28
  template 'Gemfile.erb', 'Gemfile', force: true do |content|
20
- if path
21
- content.gsub(/gem .bankai./) { |s| %(#{s}, path: "#{path}") }
22
- else
23
- content
29
+ next content unless path
30
+
31
+ # Replace the whole line: a path source and a version requirement
32
+ # cannot both be given.
33
+ content.sub(/^(\s*)gem 'bankai'.*$/) do
34
+ %(#{Regexp.last_match(1)}gem 'bankai', path: "#{path}")
24
35
  end
25
36
  end
26
37
  end
27
38
 
28
- def configure_puma_dev
39
+ def configure_dev_hosts
29
40
  application(nil, env: 'development') do
30
41
  "config.hosts << '.test'"
31
42
  end
32
43
  end
33
44
 
45
+ # Falcon replaces Puma as the app server.
46
+ def remove_puma_config
47
+ remove_file('config/puma.rb')
48
+ create_file('bin/dev', <<~SH, force: true)
49
+ #!/usr/bin/env sh
50
+ exec bundle exec falcon serve --bind http://localhost:3000 --count 1 "$@"
51
+ SH
52
+ chmod('bin/dev', 0o755)
53
+ rewrite_dockerfile_cmd
54
+ end
55
+
56
+ # Rails' Dockerfile boots the app with `bin/rails server`, which cannot run
57
+ # Falcon: falcon-rails deliberately avoids loading Falcon during boot, so
58
+ # the Rackup handler is unavailable. Run `falcon serve` directly instead.
59
+ def rewrite_dockerfile_cmd
60
+ return unless File.exist?("#{destination_root}/Dockerfile")
61
+
62
+ DOCKERFILE_CMD_REPLACEMENTS.each do |from, to|
63
+ gsub_file('Dockerfile', from, to, verbose: false)
64
+ end
65
+ end
66
+
34
67
  def configure_quiet_assets
35
68
  return if options[:api]
36
69
  return if options[:skip_asset_pipeline]
@@ -40,16 +73,11 @@ module Bankai
40
73
  end
41
74
  end
42
75
 
43
- # rubocop:disable Metrics/MethodLength
44
76
  def configure_generators
45
77
  application do
46
78
  <<-RUBY
47
79
  config.generators do |generate|
48
80
  generate.helper false
49
- generate.request_specs false
50
- generate.routing_specs false
51
- generate.test_framework :rspec
52
- generate.view_specs false
53
81
  end
54
82
  RUBY
55
83
  end
@@ -57,17 +85,14 @@ module Bankai
57
85
 
58
86
  def setup_default_directories
59
87
  [
60
- 'spec/lib',
61
- 'spec/controllers',
62
- 'spec/helpers',
63
- 'spec/support/matchers',
64
- 'spec/support/mixins',
65
- 'spec/support/shared_examples'
88
+ 'test/factories',
89
+ 'test/requests',
90
+ 'test/support/matchers',
91
+ 'test/support/mixins'
66
92
  ].each do |dir|
67
93
  empty_directory_with_keep_file dir
68
94
  end
69
95
  end
70
- # rubocop:enable Metrics/MethodLength
71
96
 
72
97
  def clear_seed_file
73
98
  File.write("#{destination_root}/db/seeds.rb", '')
@@ -9,34 +9,23 @@ module Bankai
9
9
  class Generator < Rails::Generators::AppGenerator
10
10
  hide!
11
11
 
12
- SUPPORTED_DATABASES = if defined?(Rails::Generators::Database::DATABASES)
13
- Rails::Generators::Database::DATABASES
14
- elsif defined?(DATABASES)
15
- DATABASES
16
- else
17
- %w[postgresql mysql2 sqlite3]
18
- end
19
-
20
- class_option :database, type: :string, aliases: '-d', default: 'postgresql',
12
+ class_option :database, type: :string, aliases: '-d', default: 'sqlite3',
21
13
  desc: 'Configure for selected database ' \
22
- "(options: #{SUPPORTED_DATABASES.join('/')})"
14
+ "(options: #{Rails::Generators::Database::DATABASES.join('/')})"
23
15
 
24
16
  class_option :capistrano, type: :boolean, default: false,
25
17
  desc: 'Use Capistrano'
26
18
 
27
- class_option :skip_test, type: :boolean, default: true,
19
+ class_option :skip_test, type: :boolean, default: false,
28
20
  desc: 'Skip test files'
29
21
 
30
- class_option :skip_rspec, type: :boolean, default: false,
31
- desc: 'Skip rspec files'
32
-
33
22
  class_option :skip_kamal, type: :boolean, default: true,
34
23
  desc: 'Skip Kamal setup'
35
24
 
36
- class_option :skip_solid, type: :boolean, default: true,
25
+ class_option :skip_solid, type: :boolean, default: false,
37
26
  desc: 'Skip Solid Queue/Cache/Cable setup'
38
27
 
39
- class_option :skip_thruster, type: :boolean, default: true,
28
+ class_option :skip_thruster, type: :boolean, default: false,
40
29
  desc: 'Skip Thruster setup'
41
30
 
42
31
  class_option :path, type: :string, default: nil,
@@ -52,6 +41,7 @@ module Bankai
52
41
  invoke :setup_development_environment
53
42
  invoke :configure_app
54
43
  invoke :setup_dotfiles
44
+ invoke :install_binstubs
55
45
  invoke :generate_default
56
46
  invoke :setup_default_directories
57
47
  end
@@ -64,7 +54,8 @@ module Bankai
64
54
  def setup_development_environment
65
55
  say 'Setting up the development environment'
66
56
  build :configure_quiet_assets
67
- build :configure_puma_dev
57
+ build :configure_dev_hosts
58
+ build :remove_puma_config
68
59
  build :configure_generators
69
60
  build :clear_seed_file
70
61
  # TODO: Add setup script
@@ -80,16 +71,19 @@ module Bankai
80
71
  build :copy_dotfiles
81
72
  end
82
73
 
83
- def generate_default
74
+ def install_binstubs
84
75
  run('bundle binstubs bundler')
76
+ end
77
+
78
+ def generate_default
85
79
  Bundler.with_original_env do
86
- generate('bankai:testing') unless options[:skip_rspec]
80
+ generate('bankai:testing') unless options[:skip_test]
87
81
  generate('bankai:ci', options.api? ? '--api' : '')
88
82
  generate('bankai:json')
89
83
  generate('bankai:db_optimizations')
90
84
  generate('bankai:mailer')
91
85
  generate('bankai:deploy') if options[:capistrano]
92
- generate('annotate:install')
86
+ generate('annotate_rb:install')
93
87
  generate('bankai:lint')
94
88
  end
95
89
  end
@@ -99,7 +93,7 @@ module Bankai
99
93
  end
100
94
 
101
95
  def depends_on_system_test?
102
- !(options[:skip_system_test] || options[:skip_rspec] || options[:api])
96
+ !(options[:skip_system_test] || options[:skip_test] || options[:api])
103
97
  end
104
98
 
105
99
  def self.banner
@@ -15,11 +15,7 @@ module Bankai
15
15
  private
16
16
 
17
17
  def app_name
18
- if Rails::VERSION::MAJOR >= 6
19
- Rails.app_class.module_parent_name.demodulize.underscore.dasherize
20
- else
21
- Rails.app_class.parent_name.demodulize.underscore.dasherize
22
- end
18
+ Rails.app_class.module_parent_name.demodulize.underscore.dasherize
23
19
  end
24
20
  end
25
21
  end
@@ -10,10 +10,9 @@ module Bankai
10
10
  template 'overcommit.yml.erb', '.overcommit.yml'
11
11
  end
12
12
 
13
+ # Overwrites the .rubocop.yml Rails 8 generates for itself.
13
14
  def configure_rubocop
14
- return if Rails::VERSION::MAJOR >= 8
15
-
16
- template 'rubocop.yml.erb', '.rubocop.yml'
15
+ template 'rubocop.yml.erb', '.rubocop.yml', force: true
17
16
  end
18
17
 
19
18
  def install_overcommit
@@ -21,14 +20,10 @@ module Bankai
21
20
  end
22
21
 
23
22
  def rubocop_autocorrect
24
- return if Rails::VERSION::MAJOR >= 8
25
-
26
- run 'bundle exec rubocop --auto-correct-all'
23
+ run 'bundle exec rubocop --autocorrect-all'
27
24
  end
28
25
 
29
26
  def rubocop_todo
30
- return if Rails::VERSION::MAJOR >= 8
31
-
32
27
  run 'bundle exec rubocop --auto-gen-config'
33
28
  end
34
29
  end
@@ -6,29 +6,20 @@ module Bankai
6
6
  module Generators
7
7
  # :nodoc:
8
8
  class TestingGenerator < Base
9
- def generate_rspec
10
- generate 'rspec:install'
9
+ def configure_minitest
10
+ template 'test_helper.rb', 'test/test_helper.rb', force: true
11
11
  end
12
12
 
13
- def configure_rspec
14
- remove_file 'spec/rails_helper.rb'
15
- remove_file 'spec/spec_helper.rb'
16
- copy_file 'rails_helper.rb', 'spec/rails_helper.rb'
17
- copy_file 'spec_helper.rb', 'spec/spec_helper.rb'
13
+ def provide_coverage_config
14
+ copy_file 'test/coverage.rb', 'test/support/coverage.rb'
18
15
  end
19
16
 
20
17
  def provide_shoulda_matchers_config
21
- copy_file(
22
- 'spec/shoulda_matchers.rb',
23
- 'spec/support/shoulda_matchers.rb'
24
- )
18
+ copy_file 'test/shoulda_matchers.rb', 'test/support/shoulda_matchers.rb'
25
19
  end
26
20
 
27
21
  def provide_database_rewinder_config
28
- copy_file(
29
- 'spec/database_rewinder.rb',
30
- 'spec/support/database_rewinder.rb'
31
- )
22
+ copy_file 'test/database_rewinder.rb', 'test/support/database_rewinder.rb'
32
23
  end
33
24
  end
34
25
  end
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bankai
4
- VERSION = '0.14.0'
5
- RAILS_VERSION = '7.0.0'
6
- RUBOCOP_VERSION = '1.24.1'
7
- CAPISTRANO_VERSION = '3.16.0'
4
+ VERSION = '1.0.0'
5
+ RAILS_VERSION = '8.0.0'
6
+ CAPISTRANO_VERSION = '3.19.2'
8
7
  end
@@ -3,7 +3,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
3
 
4
4
  ruby '<%= RUBY_VERSION -%>'
5
5
 
6
- <% gemfile_entries.each do |gemfile_entry| %>
6
+ <% gemfile_entries.reject { |entry| entry.name == 'puma' }.each do |gemfile_entry| %>
7
7
  <%= gemfile_entry %>
8
8
  <% end -%>
9
9
  <% unless options.minimal? -%>
@@ -15,22 +15,39 @@ ruby '<%= RUBY_VERSION -%>'
15
15
  # gem "bcrypt", "~> 3.1.7"
16
16
  <% end -%>
17
17
 
18
+ # Use Falcon as the app server [https://github.com/socketry/falcon-rails]
19
+ gem "falcon-rails"
20
+
18
21
  # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
19
- gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
22
+ gem "tzinfo-data", platforms: %i[ windows jruby ]
23
+ <% unless options.skip_solid? -%>
24
+
25
+ # Use the database-backed adapters for Rails.cache, Active Job, and Action Cable
26
+ gem "solid_cache"
27
+ gem "solid_queue"
28
+ <% unless options.skip_action_cable? -%>
29
+ gem "solid_cable"
30
+ <% end -%>
31
+ <% end -%>
32
+ <% unless options.skip_kamal? -%>
33
+
34
+ # Deploy this application anywhere as a Docker container [https://kamal-deploy.org]
35
+ gem "kamal", require: false
36
+ <% end -%>
37
+ <% unless options.skip_thruster? -%>
38
+
39
+ # Add HTTP asset caching/compression and X-Sendfile acceleration [https://github.com/basecamp/thruster/]
40
+ gem "thruster", require: false
41
+ <% end -%>
20
42
  <% if depend_on_bootsnap? -%>
21
43
 
22
44
  # Reduces boot times through caching; required in config/boot.rb
23
45
  gem "bootsnap", require: false
24
46
  <% end -%>
25
- <% unless (respond_to?(:skip_sprockets?) ? skip_sprockets? : true) || options.minimal? -%>
26
-
27
- # Use Sass to process CSS
28
- # gem "sassc-rails"
29
- <% end -%>
30
47
  <% unless skip_active_storage? -%>
31
48
 
32
49
  # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
33
- # gem "image_processing", "~> 1.2"
50
+ gem "image_processing", "~> 1.2"
34
51
  <% end -%>
35
52
  <%- if options.api? -%>
36
53
 
@@ -41,27 +58,24 @@ gem "bootsnap", require: false
41
58
 
42
59
  group :development, :test do
43
60
  # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
44
- gem "debug", platforms: %i[ mri mingw x64_mingw ]
61
+ gem "debug", platforms: %i[ mri windows ], require: "debug/prelude"
45
62
 
46
63
  gem 'brakeman', require: false
47
64
  gem 'bundler-audit', require: false
48
- gem 'rubocop', '~> <%= Bankai::RUBOCOP_VERSION %>', require: false
49
- gem 'rubocop-performance', require: false
50
- gem 'rubocop-rails', require: false
51
- gem 'rubocop-rspec', require: false
65
+ gem 'rubocop-rails-omakase', require: false
66
+ gem 'rubocop-minitest', require: false
52
67
 
53
- <%- unless options[:skip_rspec] -%>
68
+ <%- unless options[:skip_test] -%>
54
69
  gem 'database_rewinder'
55
70
  gem 'factory_bot_rails'
56
71
  gem 'faker'
57
- gem 'rspec', require: false
58
- gem 'rspec-rails', require: false
72
+ gem 'shoulda-context', require: false
59
73
  gem 'shoulda-matchers', require: false
60
74
  gem 'simplecov', require: false
61
75
  gem 'simplecov-cobertura', require: false
62
76
  <%- end -%>
63
77
 
64
- gem 'bankai'
78
+ gem 'bankai', '~> <%= Bankai::VERSION.split('.').first(2).join('.') %>'
65
79
  gem 'oj'
66
80
  end
67
81
  <% end -%>
@@ -75,9 +89,6 @@ group :development do
75
89
  # gem "rack-mini-profiler"
76
90
 
77
91
  <%- end -%>
78
- # Speed up commands on slow machines / big apps [https://github.com/rails/spring]
79
- # gem "spring"
80
-
81
92
  <% if options[:capistrano] -%>
82
93
  gem 'capistrano', '<%= Bankai::CAPISTRANO_VERSION %>'
83
94
  gem 'capistrano-bundler'
@@ -86,7 +97,7 @@ group :development do
86
97
  # gem 'capistrano-passenger'
87
98
  <% end -%>
88
99
 
89
- gem 'annotate'
100
+ gem 'annotaterb'
90
101
  gem 'bullet'
91
102
  gem 'dotenv-rails'
92
103
  gem 'letter_opener'
@@ -173,15 +173,21 @@ bundle exec rake db:migrate
173
173
  和 Rails 伺服器同時打開後,就可以看到正常的網站畫面
174
174
 
175
175
  <%- end -%>
176
- <%- unless options[:skip_rspec] -%>
176
+ <%- unless options[:skip_test] -%>
177
177
  ### 運行測試
178
178
 
179
- 這個專案使用 RSpec 進行測試,可以透過執行以下指令運行
179
+ 這個專案使用 Minitest 進行測試,可以透過執行以下指令運行
180
180
 
181
181
  ```bash
182
- bundle exec rspec
182
+ bin/rails test # 全部
183
+ bin/rails test test/models/user_test.rb
184
+ bin/rails test test/models/user_test.rb:42
185
+ COVERAGE=1 bin/rails test # 加上覆蓋率報告
183
186
  ```
184
187
 
188
+ 測試資料使用 factory_bot(factory 放在 `test/factories/`)與 faker,
189
+ 資料庫由 DatabaseRewinder 在每個 test 後清空,所以沒有使用 fixtures。
190
+
185
191
  <%- end -%>
186
192
  ### Ruby 語法檢查
187
193
 
@@ -11,6 +11,7 @@
11
11
  # Ignore the default SQLite database.
12
12
  /db/*.sqlite3
13
13
  /db/*.sqlite3-journal
14
+ /storage/*.sqlite3*
14
15
 
15
16
  <% end -%>
16
17
  # Ignore all logfiles and tempfiles.
@@ -31,21 +32,14 @@
31
32
  <% end -%>
32
33
  <% end -%>
33
34
 
34
- <% unless options.skip_yarn? -%>
35
- /node_modules
36
- yarn-debug.log*
37
- yarn-error.log*
38
- .yarn-integrity
39
-
40
- <% end -%>
41
35
  <% unless options.api? -%>
42
36
  /public/assets
43
37
  <% end -%>
44
38
  .byebug_history
45
39
 
46
- <% unless options[:skip_rspec] -%>
40
+ <% unless options[:skip_test] -%>
47
41
  /coverage/
48
- /spec/tmp
42
+ /test/tmp
49
43
  <% end -%>
50
44
 
51
45
  # Dotenv
@@ -74,10 +74,12 @@ bundler-leak:
74
74
  - if: $CI_MERGE_REQUEST_ID
75
75
  - if: $CI_PIPELINE_SOURCE == 'schedule'
76
76
 
77
- rspec:
77
+ minitest:
78
78
  extends: .common
79
79
  stage: test
80
+ <%- if pg? || mysql? -%>
80
81
  services:
82
+ <%- end -%>
81
83
  <%- if pg? -%>
82
84
  - postgres:16-alpine
83
85
  <%- end -%>
@@ -87,7 +89,7 @@ rspec:
87
89
  <%- end -%>
88
90
  script:
89
91
  - bundle exec rake db:migrate
90
- - bundle exec rspec
92
+ - bin/rails test
91
93
  rules:
92
94
  - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
93
95
  - if: $CI_MERGE_REQUEST_ID
@@ -1,28 +1,18 @@
1
- require:
1
+ inherit_gem:
2
+ rubocop-rails-omakase: rubocop.yml
3
+
4
+ plugins:
2
5
  - rubocop-performance
3
6
  - rubocop-rails
4
- - rubocop-rspec
7
+ - rubocop-minitest
5
8
 
6
9
  inherit_mode:
7
10
  merge:
8
11
  - Exclude
9
12
 
10
13
  AllCops:
11
- NewCops: enable
12
- TargetRubyVersion: <%= RUBY_VERSION %>
13
- DisplayCopNames: true
14
14
  SuggestExtensions: false
15
15
  Exclude:
16
- - vendor/ruby/**/*
16
+ - vendor/**/*
17
17
  - node_modules/**/*
18
- - .licenses/**/*
19
- Rails:
20
- Enabled: true
21
- Metrics/BlockLength:
22
- Exclude:
23
- - db/migrate/*
24
- - config/environments/*
25
- - lib/tasks/**/*
26
- - spec/**/*
27
- Style/Documentation:
28
- Enabled: false
18
+ - db/schema.rb
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ return unless ENV.fetch('COVERAGE', false) || ENV.fetch('CI', false)
4
+
5
+ require 'simplecov'
6
+ require 'simplecov-cobertura'
7
+
8
+ SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter if ENV.fetch('GITLAB_CI', false)
9
+ SimpleCov.refuse_coverage_drop
10
+
11
+ SimpleCov.start 'rails' do
12
+ skip 'vendor'
13
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ DatabaseRewinder.clean_all
4
+
5
+ module DatabaseRewinderCleanup
6
+ def after_teardown
7
+ super
8
+ DatabaseRewinder.clean
9
+ end
10
+ end
11
+
12
+ ActiveSupport::TestCase.include(DatabaseRewinderCleanup)
@@ -2,7 +2,7 @@
2
2
 
3
3
  Shoulda::Matchers.configure do |config|
4
4
  config.integrate do |with|
5
- with.test_framework :rspec
5
+ with.test_framework :minitest
6
6
  with.library :rails
7
7
  end
8
8
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Must be loaded before the application, so SimpleCov sees every file.
4
+ require_relative 'support/coverage'
5
+
6
+ ENV['RAILS_ENV'] ||= 'test'
7
+ require_relative '../config/environment'
8
+
9
+ abort('The Rails is running in production mode!') if Rails.env.production?
10
+
11
+ require 'rails/test_help'
12
+ require 'shoulda-context'
13
+ require 'shoulda/matchers'
14
+ require 'faker'
15
+
16
+ Dir[Rails.root.join('test/support/**/*.rb')].each { |f| require f }
17
+
18
+ module ActiveSupport
19
+ # :nodoc:
20
+ class TestCase
21
+ include FactoryBot::Syntax::Methods
22
+
23
+ # Test data comes from factories, so there are no fixtures to preserve and
24
+ # DatabaseRewinder does the cleaning instead of a wrapping transaction.
25
+ self.use_transactional_tests = false
26
+ end
27
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bankai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - 5xRuby
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '12.0'
47
+ version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '12.0'
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -86,42 +86,42 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.8.1
89
+ version: '1.90'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 1.8.1
96
+ version: '1.90'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: simplecov
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.17.1
103
+ version: '0.22'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.17.1
110
+ version: '0.22'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rails
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
116
116
  - !ruby/object:Gem::Version
117
- version: 7.0.0
117
+ version: 8.0.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: 7.0.0
124
+ version: 8.0.0
125
125
  description: The tool to generate Rails template for 5xRuby
126
126
  email:
127
127
  - hi@5xruby.tw
@@ -139,6 +139,7 @@ files:
139
139
  - ".rubocop.yml"
140
140
  - ".ruby-version"
141
141
  - ".travis.yml"
142
+ - CHANGELOG.md
142
143
  - CLAUDE.md
143
144
  - CODE_OF_CONDUCT.md
144
145
  - Gemfile
@@ -172,11 +173,11 @@ files:
172
173
  - templates/gitlab-ci.yml.erb
173
174
  - templates/overcommit.yml.erb
174
175
  - templates/rack_mini_profiler.rb
175
- - templates/rails_helper.rb
176
176
  - templates/rubocop.yml.erb
177
- - templates/spec/database_rewinder.rb
178
- - templates/spec/shoulda_matchers.rb
179
- - templates/spec_helper.rb
177
+ - templates/test/coverage.rb
178
+ - templates/test/database_rewinder.rb
179
+ - templates/test/shoulda_matchers.rb
180
+ - templates/test_helper.rb
180
181
  homepage: https://github.com/5xRuby/bankai
181
182
  licenses: []
182
183
  metadata: {}
@@ -194,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
195
  - !ruby/object:Gem::Version
195
196
  version: '0'
196
197
  requirements: []
197
- rubygems_version: 3.6.9
198
+ rubygems_version: 4.0.16
198
199
  specification_version: 4
199
200
  summary: The Rails template for 5xRuby
200
201
  test_files: []
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- ENV['RAILS_ENV'] ||= 'test'
5
- require File.expand_path('../config/environment', __dir__)
6
-
7
- abort('The Rails is running in production mode!') if Rails.env.production?
8
- require 'rspec/rails'
9
-
10
- require 'shoulda/matchers'
11
- require 'faker'
12
- require 'factory_bot'
13
-
14
- Dir[Rails.root.join('spec/support/**/*.rb')].sort.each { |f| require f }
15
-
16
- begin
17
- ActiveRecord::Migration.maintain_test_schema!
18
- rescue ActiveRecord::PendingMigrationError => e
19
- puts e.to_s.strip
20
- exit 1
21
- end
22
- RSpec.configure do |config|
23
- config.fixture_path = "#{::Rails.root}/spec/fixtures"
24
-
25
- config.use_transactional_fixtures = false
26
- config.infer_spec_type_from_file_location!
27
- config.filter_rails_from_backtrace!
28
-
29
- config.include FactoryBot::Syntax::Methods
30
- # config.include Devise::Test::IntegrationHelpers, type: :request
31
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.configure do |config|
4
- config.before(:suite) do
5
- DatabaseRewinder.clean_all
6
- end
7
-
8
- config.after do
9
- DatabaseRewinder.clean
10
- end
11
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if ENV.fetch('COVERAGE', false) || ENV.fetch('CI', false)
4
- require 'simplecov'
5
- require 'simplecov-cobertura'
6
-
7
- SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter if ENV.fetch('GITLAB_CI', false)
8
- SimpleCov.refuse_coverage_drop
9
-
10
- SimpleCov.start 'rails' do
11
- add_filter 'vendor'
12
- end
13
- end
14
-
15
- RSpec.configure do |config|
16
- config.expect_with :rspec do |expectations|
17
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
18
- end
19
-
20
- config.mock_with :rspec do |mocks|
21
- mocks.verify_partial_doubles = true
22
- end
23
-
24
- config.shared_context_metadata_behavior = :apply_to_host_groups
25
-
26
- config.expect_with :rspec do |c|
27
- c.syntax = :expect
28
- end
29
- end