thecore_generators 3.14.0 → 3.15.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: c96cf53c100408b84dad8704e8008fc6ca860d8b99fc0e4c4da605b702a0bdd0
4
- data.tar.gz: 4b2b88048110f0ecc45b780ee7f92eada4235bfbbb4fa89322366bb38adee079
3
+ metadata.gz: b5cb7e253b11bc9757eba5e303f23e0bb745b97f6657fd215b84363d9ba5c977
4
+ data.tar.gz: eea84a0e751f4e0956dc767a206201fb77e53c6aaea97c23ccbb434914ea0b26
5
5
  SHA512:
6
- metadata.gz: e7ec0f8d41dc5f67a0f2a9fab4ed436d49ac2877c1686861403ce2f00e5ea7f8b1bf9794f6cb63d0ef0a9d0855b27d8e6285f0d70eaa034bf7c50312cfbd81ba
7
- data.tar.gz: 63ebaace602a89a384c7b340559269d3d5a4eb5bfb20b7c538180817312229e2ffcdd94d30915180417dc18a4fb38297878408fd9431621ff1adbbb7365bf77b
6
+ metadata.gz: '039f78b814cb50398c6072c84f1bf4bfcf44e22251b3e650d74443ea9af1ddd2e2ac945847c3fb3928a2b2a76a33be04a7e364f715e52e7c7d0053c66c5a6628'
7
+ data.tar.gz: 8a11eaf74c07b59e5d6285b03752d94f44d89a8ef3695442e4feb2cec32e5f6e2a7bea351737355790f0a02a93e52ee07b1fda8f41c8b4b831ebd063a68580e0
data/README.md CHANGED
@@ -253,7 +253,8 @@ with `--non-interactive`) for the same five fields `createATOM.js` always has, t
253
253
  (below).
254
254
  - Asks (`yes?`-style, default yes; `--skip-api-admin-deps` in non-interactive mode) whether to
255
255
  add `model_driven_api`/`thecore_ui_rails_admin` as dependencies — at this gem's own ADR 0001
256
- floor (`~> 3.9`/`~> 3.8`), not `createATOM.js`'s stale `~> 3.1`/`~> 3.2`. Declining adds
256
+ floor (`~> 3.8` for `thecore_ui_rails_admin`) and at `model_driven_api ~> 3.13, >= 3.13.2`
257
+ (older ones fail on Rails 8.1), not `createATOM.js`'s stale `~> 3.1`/`~> 3.2`. Declining adds
257
258
  neither; the Scaffold Files/directories below are created either way.
258
259
  - Creates the same Scaffold Files/directories `createATOM.js` always has: `db/migrate`, the
259
260
  API/RailsAdmin concern directories, `config/initializers`, `config/locales`,
@@ -263,12 +264,14 @@ with `--non-interactive`) for the same five fields `createATOM.js` always has, t
263
264
  content `createATOM.js` already produces.
264
265
  - Generates **both** `.github/workflows/gempush.yml` and `.gitlab-ci.yml` unconditionally — no
265
266
  hosting-profile prompt (see ADR 0006 for why: which git host a developer pushes to is a
266
- per-developer choice this ecosystem already treats as generic). `gempush.yml`'s two
267
- long-standing bugs are fixed here (a broken `awk` pipeline computing the version string; a
268
- `version_exists` check referenced in `if:` conditions but never actually set, so the
269
- tag/publish steps have never run for any ATOM generated this way). Both publish like the real
270
- ATOMs (thecore_devcontainer#14): `gempush.yml` only on pushes to `release/3`; `.gitlab-ci.yml`'s
271
- `build_gem` only when `lib/*/version.rb` changes, plus GitLab's SAST and Secret Detection
267
+ per-developer choice this ecosystem already treats as generic). Both publish like the real
268
+ ATOMs (thecore_devcontainer#14), and only after a green test suite (#26): `gempush.yml` runs a
269
+ `test` job on PostgreSQL 15 on every push and pull request on `release/3` and a `publish` job
270
+ (`needs: test`, pushes only) that pushes the gem, tags the version and attaches the JUnit report
271
+ to its GitHub release; `.gitlab-ci.yml` runs `test_gem` on PostgreSQL 15 on every branch push,
272
+ and `build_gem` (`needs: [test_gem]`) only when `lib/*/version.rb` changes, keeping the JUnit
273
+ report. `test/support/junit_report.rb` (minitest-reporters, on when `JUNIT_REPORT_DIR` is set)
274
+ writes that report. Plus GitLab's SAST and Secret Detection
272
275
  templates and a `security-summary` job running `script/security_summary.rb`, which is fetched
273
276
  from `thecore`'s samples with its test (`test/script/security_summary_test.rb`).
274
277
  - `--gem-host=HOST` (default `rubygems.org`) names the gem server: the gemspec's
@@ -276,8 +279,10 @@ with `--non-interactive`) for the same five fields `createATOM.js` always has, t
276
279
  pushes there (`GITLAB_GEM_REPO_TARGET`), and so does `gempush.yml` (`gem push --host
277
280
  https://HOST`, with the API key in the GitHub repository secret `GEMS_REPO_CREDENTIALS`). With
278
281
  the default the variable is left out, so the image's `gem-compile.sh` pushes to RubyGems, and
279
- `gempush.yml` pushes to RubyGems with the `RUBYGEMS_AUTH_TOKEN` secret. The gemspec requires `rails ~> 7.2`, the Rails of
280
- Thecore 3 hosts.
282
+ `gempush.yml` pushes to RubyGems with the `RUBYGEMS_AUTH_TOKEN` secret. The gemspec requires
283
+ `rails >= 7.2, < 8.2`: Thecore 3 hosts run Rails 7.2 or 8.1 (dual support). On Rails 8 the dummy
284
+ app also gets `ApplicationCable::Connection`/`Channel`, which `rails plugin new` no longer
285
+ writes and `thecore_backend_commons` extends at boot.
281
286
  - Rewrites the gemspec's authors/email/homepage/summary/description/metadata fields via targeted
282
287
  in-memory substitutions (not `createATOM.js`'s own blind full-file line rewrite, which —
283
288
  verified directly against a current `rails plugin new --full` gemspec — silently drops the
@@ -380,10 +385,18 @@ template rather than a `thecore:*` generator — its entry point is `rails new -
380
385
  generate`:
381
386
 
382
387
  ```bash
383
- rails new myapp --database=postgresql --asset-pipeline=sprockets \
388
+ rails _8.1.4.1_ new myapp --database=postgresql \
384
389
  -m https://raw.githubusercontent.com/gabrieletassoni/thecore_generators/release/3/lib/templates/app_template.rb
385
390
  ```
386
391
 
392
+ New apps start on Rails 8.1. Rails 8's `rails new` only generates Propshaft (there is no
393
+ `--asset-pipeline=sprockets` any more); the template switches the app to Sprockets, which
394
+ RailsAdmin 3 and the Thecore UI need, writes `app/assets/config/manifest.js` and links
395
+ `"application"` in the layout (Propshaft's `:app` doesn't exist in Sprockets). With Rails 7.2's
396
+ `rails new`, keep passing `--asset-pipeline=sprockets`. Rails 8's other defaults (Solid
397
+ Cache/Queue/Cable, Kamal, Thruster) are left as `rails new` writes them; the pilot's production
398
+ shape is Sidekiq + Redis and one database; the update path that adopts them is #27.
399
+
387
400
  Run inside a devcontainer already created by the "Setup Devcontainer" VS Code command — a
388
401
  bootstrap step this template doesn't invoke or modify itself (that command's own code is
389
402
  untouched), even though the template's own devcontainer-asset fetch below does overwrite the
@@ -392,14 +405,19 @@ files that bootstrap step created, by design. See
392
405
  for the full design and why the two stay separate).
393
406
 
394
407
  - **Core Gemfile stack, active** — `devise`, `cancancan`, `rails_admin`, `sassc-rails`,
395
- `model_driven_api` (`>= 3.13.1`), `thecore_ui_rails_admin` (`>= 3.8.7`), `rails-erd`
408
+ `model_driven_api` (`>= 3.13.2`), `thecore_ui_rails_admin` (`>= 3.8.7`), `rails-erd`
396
409
  (`:development`). `thecore_generators` itself is added too, `group: :development` — so the
397
410
  generated app can immediately use every generator/task documented above without a manual
398
411
  Gemfile edit first.
399
- - **Security floors and pins** — `thecore_backend_commons >= 3.10` and `thecore_auth_commons >=
400
- 3.6.3` (transitive, listed for their floor), `rails >= 7.2.4`, `puma >= 7.2.1`, and the pins
401
- `redis < 6` (Action Cable 7.2) and `connection_pool ~> 2.4` (Sidekiq 7). Each carries its reason
402
- in a Gemfile comment.
412
+ - **Security floors and pins** — `thecore_backend_commons ~> 3.11` and `thecore_auth_commons >=
413
+ 3.6.3` (transitive, listed for their floor), `rails ~> 8.1.4, >= 8.1.4.1` (never 8.2, which the
414
+ 3.x ATOMs don't support), `puma >= 7.2.1`, and the pins `redis < 6` (the pilot's line) and
415
+ `connection_pool ~> 2.4` (Sidekiq 7). Each carries its reason in a Gemfile comment.
416
+ - **What the Thecore engines need before the app can boot** — `config/initializers/00_devise_orm.rb`
417
+ (Devise's ActiveRecord hook: the engines load `User` at boot), the pilot's empty
418
+ `app/models/ability.rb` (permissions come from thecore_auth_commons) and
419
+ `app/channels/application_cable/{connection,channel}.rb` (Rails 8 no longer generates them),
420
+ written whether or not the installer chain runs.
403
421
  - **The rest of the generic Thecore ecosystem, commented out** — `thecore_print_commons`,
404
422
  `thecore_tcp_debug`, `thecore_download_documents`, `thecore_dataentry_commons`, each with a
405
423
  one-line purpose comment — discoverable but off by default, the same "commented but documented"
@@ -428,11 +446,12 @@ for the full design and why the two stay separate).
428
446
  - **Test-database rule** — the generated `test/test_helper.rb` replaces whatever database
429
447
  `DATABASE_URL` names with `<app>_test` before the app boots. The devcontainer's `DATABASE_URL`
430
448
  points at development, so running tests never touches development data.
431
- - **No root `Dockerfile`** — the `Dockerfile` and `bin/docker-entrypoint` that `rails new` 7.2
449
+ - **No root `Dockerfile`** — the `Dockerfile` and `bin/docker-entrypoint` that `rails new`
432
450
  generates are removed, so the Thecore build script (`app-compile.sh` in `thecore_devcontainer`)
433
451
  builds the app with the Thecore Dockerfile instead of Rails' own. `.dockerignore` is kept.
434
452
  - **The standard installer chain** (`devise:install`, `rails_admin:install`, `active_storage:
435
- install`, `action_text:install`, `action_mailbox:install`, `cancan:ability`, `erd:install`,
453
+ install`, `action_text:install`, `action_mailbox:install`, `erd:install`; `devise:install`
454
+ with `--orm=active_record`, since this gem is the app's generator ORM;
436
455
  each preceded by the necessary `bundle install`) is genuinely optional, gated behind an
437
456
  interactive prompt (`yes?`, wrapped in `after_bundle` so it only ever runs once the gems
438
457
  above are actually bundled) — a developer bootstrapping without network access can decline
@@ -443,7 +462,7 @@ for the full design and why the two stay separate).
443
462
  or unrecognized, rather than guessing. Example:
444
463
  ```bash
445
464
  THECORE_APP_TEMPLATE_NON_INTERACTIVE=1 THECORE_APP_TEMPLATE_RUN_INSTALLERS=true \
446
- rails new myapp --database=postgresql --asset-pipeline=sprockets \
465
+ rails _8.1.4.1_ new myapp --database=postgresql \
447
466
  -m https://raw.githubusercontent.com/gabrieletassoni/thecore_generators/release/3/lib/templates/app_template.rb
448
467
  ```
449
468
 
@@ -69,12 +69,15 @@ module Thecore
69
69
 
70
70
  # This gem's own ADR 0001 floor (matching the App template's already-corrected
71
71
  # versions) — not createATOM.js's stale "~> 3.1"/"~> 3.2".
72
- MODEL_DRIVEN_API_VERSION = "~> 3.9"
72
+ # model_driven_api 3.13.2: older ones raise FrozenError rendering JSON with `include:` on
73
+ # Rails 8.1 (the App template's floor too).
74
+ MODEL_DRIVEN_API_REQUIREMENTS = ["~> 3.13", ">= 3.13.2"].freeze
73
75
  THECORE_UI_RAILS_ADMIN_VERSION = "~> 3.8"
74
76
  MINITEST_VERSION = "~> 5.25"
75
- # Thecore 3 hosts run Rails 7.2. The ATOM commits no lockfile, so without this its own bundle
76
- # (with --skip-api-admin-deps nothing else holds Rails back) resolves the newest Rails.
77
- RAILS_VERSION = "~> 7.2"
77
+ # Thecore 3 hosts run Rails 7.2 or 8.1 (dual support, ADR 0033 in mytask-imas, Odoo #6091).
78
+ # The ATOM commits no lockfile, so without the upper bound its own bundle (with
79
+ # --skip-api-admin-deps nothing else holds Rails back) would resolve an unsupported 8.2.
80
+ RAILS_REQUIREMENTS = [">= 7.2", "< 8.2"].freeze
78
81
  GEM_HOST_PATTERN = /\A[a-z0-9]([a-z0-9.-]*[a-z0-9])?(:\d+)?\z/i
79
82
 
80
83
  # Faithful port of templates/createATOM/after_initialize.rb /
@@ -98,45 +101,119 @@ module Thecore
98
101
  # )
99
102
  RUBY
100
103
 
101
- # Faithful port of createATOM.js's addCICDFiles gempush.yml, with its two
102
- # long-standing bugs fixed (thecore_generators#20 acceptance criteria): the awk
103
- # pipeline computing the version string had a stray, unmatched `)` instead of a
104
- # closing `}'`; and `version_exists` was referenced in two steps' `if:`
105
- # conditions but never actually set anywhere (the "check" step only ever did
106
- # `echo $?`), so those two steps have never run for any ATOM generated this way.
107
- # Fixed here by actually writing `version_exists` to $GITHUB_ENV based on
108
- # whether a git tag for the computed version already exists - kept as an
109
- # `env.*`-style if: condition (not switched to `steps.*.outputs.*`) to stay as
110
- # close to the original's structure as the fix allows.
111
- GEMPUSH_YML_CONTENT = <<~YAML
112
- name: Ruby Gem
104
+ # The base ATOMs' gempush.yml (thecore_generators#26, Odoo #6088 in mytask-imas): every push
105
+ # and pull request on release/3 runs the test suite on PostgreSQL 15 (never SQLite), and a
106
+ # push publishes only after it is green (`needs: test`). The publish job pushes the gem
107
+ # first and tags it after, so a failed push leaves no tag and re-running the workflow
108
+ # retries it; `version_exists` (from the version's tag) skips a version already published.
109
+ # The JUnit report of the green run is attached to the version's GitHub release, the
110
+ # published version's test evidence. The publish step itself (#gempush_yml) depends on
111
+ # --gem-host. Started from createATOM.js's addCICDFiles, whose two bugs (an unmatched `)`
112
+ # in the version awk, `version_exists` never set) thecore_generators#20 fixed.
113
+ GEMPUSH_TEST_AND_CHECK = <<~YAML
114
+ name: Test and publish
115
+
113
116
  on:
114
117
  push:
115
- branches:
116
- - release/3
118
+ branches: [ release/3 ]
119
+ pull_request:
120
+ branches: [ release/3 ]
121
+
117
122
  jobs:
118
- build:
119
- name: Build + Publish
123
+ test:
124
+ name: Test suite
125
+ runs-on: ubuntu-latest
126
+
127
+ services:
128
+ postgres:
129
+ image: postgres:15-bookworm
130
+ env:
131
+ POSTGRES_PASSWORD: postgres
132
+ ports:
133
+ - 5432:5432
134
+ options: >-
135
+ --health-cmd pg_isready
136
+ --health-interval 5s
137
+ --health-timeout 5s
138
+ --health-retries 10
139
+
140
+ # test/dummy/config/database.yml reads PGHOST/PGPORT/PGUSER/PGPASSWORD.
141
+ env:
142
+ PGHOST: localhost
143
+ PGPORT: 5432
144
+ PGUSER: postgres
145
+ PGPASSWORD: postgres
146
+ RAILS_ENV: test
147
+ CI: true
148
+ JUNIT_REPORT_DIR: ${{ github.workspace }}/tmp/junit
149
+
150
+ steps:
151
+ - uses: actions/checkout@v4
152
+ - uses: ruby/setup-ruby@v1
153
+ with:
154
+ ruby-version: '3.3'
155
+ bundler-cache: true
156
+ - name: Create the test database
157
+ run: bin/rails db:create
158
+ - name: Run the test suite
159
+ run: bin/rails test
160
+ - name: Keep the JUnit report
161
+ if: always()
162
+ uses: actions/upload-artifact@v4
163
+ with:
164
+ name: junit
165
+ path: tmp/junit/
166
+ if-no-files-found: error
167
+
168
+ publish:
169
+ name: Publish + Tag
170
+ needs: test
171
+ if: github.event_name == 'push'
120
172
  runs-on: ubuntu-latest
173
+ permissions:
174
+ contents: write # push the version tag and create its release
121
175
  steps:
122
- - uses: actions/checkout@v3
176
+ - uses: actions/checkout@v4
177
+ with:
178
+ fetch-depth: 0
123
179
  - name: Check if version already exists
124
180
  run: |
125
- version=$(grep -oP 'VERSION = "\\K[^"]+' lib/*/version.rb | awk -F'.' '{print $1"."$2"."$3}')
126
- git fetch --unshallow --tags
127
- if git rev-parse "$version" >/dev/null 2>&1; then
181
+ version=$(grep -oP 'VERSION = "\\K[^"]+' lib/*/version.rb)
182
+ echo "version=$version" >> "$GITHUB_ENV"
183
+ if git rev-parse -q --verify "refs/tags/$version" >/dev/null; then
128
184
  echo "version_exists=true" >> "$GITHUB_ENV"
129
185
  else
130
186
  echo "version_exists=false" >> "$GITHUB_ENV"
131
187
  fi
132
- - name: Set git tag
188
+ - uses: ruby/setup-ruby@v1
133
189
  if: env.version_exists == 'false'
134
- run: |
135
- git config --local user.email "noreply@alchemic.it"
136
- git config --local user.name "AlchemicIT"
137
- version=$(grep -oP 'VERSION = "\\K[^"]+' lib/*/version.rb | awk -F'.' '{print $1"."$2"."$3}')
138
- git tag -a $version -m "Version $version"
139
- git push --tags
190
+ with:
191
+ ruby-version: '3.3'
192
+ - name: Get the JUnit report
193
+ if: env.version_exists == 'false'
194
+ uses: actions/download-artifact@v4
195
+ with:
196
+ name: junit
197
+ path: junit
198
+ YAML
199
+
200
+ GEMPUSH_TAG_AND_RELEASE = <<~YAML
201
+ - name: Set git tag
202
+ if: env.version_exists == 'false'
203
+ run: |
204
+ git config --local user.email "noreply@alchemic.it"
205
+ git config --local user.name "AlchemicIT"
206
+ git tag -a "$version" -m "Version $version"
207
+ git push origin "refs/tags/$version"
208
+ - name: Create the release with the JUnit report
209
+ if: env.version_exists == 'false'
210
+ env:
211
+ GH_TOKEN: ${{ github.token }}
212
+ run: |
213
+ gem_name=$(basename *.gemspec .gemspec)
214
+ for f in junit/*.xml; do mv "$f" "junit/$gem_name-$version-$(basename "$f")"; done
215
+ gh release create "$version" --verify-tag --title "$version" \\
216
+ --notes "Test suite green on PostgreSQL 15 (Ruby 3.3). JUnit report attached." junit/*.xml
140
217
  YAML
141
218
 
142
219
  GEMPUSH_RUBYGEMS_STEP = <<~YAML
@@ -169,12 +246,27 @@ module Thecore
169
246
  YAML
170
247
 
171
248
  GITLAB_CI_HEADER = <<~YAML
172
- # Publish: build_gem builds and pushes the gem only when lib/*/version.rb changes (see
173
- # CLAUDE.md). Security: SAST and Secret Detection report only; security-summary lists their
249
+ # Test: test_gem runs the suite on PostgreSQL 15 on every branch push, with a JUnit report.
250
+ # Publish: build_gem builds and pushes the gem only when lib/*/version.rb changes and only
251
+ # after a green test_gem (see CLAUDE.md). Security: SAST and Secret Detection report only; security-summary lists their
174
252
  # findings and turns orange when there are any. CVEs in the dependencies are checked by the
175
253
  # host app's bundler-audit, since this gem commits no Gemfile.lock.
176
254
  YAML
177
255
 
256
+ # Same file as the base ATOMs' test/support/junit_report.rb (Odoo #6088 in mytask-imas).
257
+ JUNIT_REPORT_CONTENT = <<~RUBY
258
+ # JUnit XML report for CI, kept with every published version as its test evidence.
259
+ # Off unless JUNIT_REPORT_DIR is set, so a local run keeps the normal Rails output.
260
+ if ENV["JUNIT_REPORT_DIR"].present?
261
+ require "minitest/reporters"
262
+ Minitest::Reporters.use!([
263
+ Minitest::Reporters::DefaultReporter.new,
264
+ Minitest::Reporters::JUnitReporter.new(ENV["JUNIT_REPORT_DIR"], true, single_file: true)
265
+ ])
266
+ end
267
+ RUBY
268
+ MINITEST_REPORTERS_VERSION = "~> 1.8"
269
+
178
270
  DUMMY_ABILITY_CONTENT = <<~RUBY
179
271
  # The host app's Ability, which the Thecore engines reference. Permissions come from
180
272
  # thecore_auth_commons' Role/Permission system, so this stays empty, as in a host app.
@@ -193,6 +285,24 @@ module Thecore
193
285
  end
194
286
  RUBY
195
287
 
288
+ # Rails 8 stopped generating app/channels/application_cable (7.2 still did), but
289
+ # thecore_backend_commons includes its cable authentication into
290
+ # ApplicationCable::Connection at boot and its channels subclass ApplicationCable::Channel:
291
+ # without these the dummy app raises NameError before any test runs.
292
+ DUMMY_CABLE_CONNECTION_CONTENT = <<~RUBY
293
+ module ApplicationCable
294
+ class Connection < ActionCable::Connection::Base
295
+ end
296
+ end
297
+ RUBY
298
+
299
+ DUMMY_CABLE_CHANNEL_CONTENT = <<~RUBY
300
+ module ApplicationCable
301
+ class Channel < ActionCable::Channel::Base
302
+ end
303
+ end
304
+ RUBY
305
+
196
306
  SCAFFOLD_DIRECTORIES = %w[
197
307
  db/migrate
198
308
  app/models/concerns/api
@@ -347,15 +457,20 @@ module Thecore
347
457
  end
348
458
 
349
459
  # The host-app pieces the Thecore engines expect, which a `rails plugin new` dummy lacks:
350
- # an `Ability` class (the App template gets it from `cancan:ability`) and Devise's ORM hook
460
+ # an `Ability` class (the App template writes the pilot's empty one), Devise's ORM hook
351
461
  # (`devise:install`), without which thecore_auth_commons' `User` hits `undefined method
352
- # devise` at boot. Same files as the pilot ATOM's (mytask) dummy. Only with the API/Admin
462
+ # devise` at boot, and ApplicationCable's base classes, which Rails 8 no longer generates
463
+ # (`skip: true` keeps the ones a Rails 7.2 dummy already has). Same files as the pilot ATOM's (mytask) dummy. Only with the API/Admin
353
464
  # dependencies: without them neither CanCan nor Devise is in the bundle.
354
465
  def configure_dummy_host_app
355
466
  return unless @include_api_admin_deps
356
467
 
357
468
  create_file File.join(atom_root, "test/dummy/app/models/ability.rb"), DUMMY_ABILITY_CONTENT
358
469
  create_file File.join(atom_root, "test/dummy/config/initializers/devise.rb"), DUMMY_DEVISE_CONTENT
470
+ create_file File.join(atom_root, "test/dummy/app/channels/application_cable/connection.rb"),
471
+ DUMMY_CABLE_CONNECTION_CONTENT, skip: true
472
+ create_file File.join(atom_root, "test/dummy/app/channels/application_cable/channel.rb"),
473
+ DUMMY_CABLE_CHANNEL_CONTENT, skip: true
359
474
  end
360
475
 
361
476
  # #create_file already `mkdir_p`s its own parent directory, so a separate
@@ -402,6 +517,14 @@ module Thecore
402
517
  create_file File.join(atom_root, ".gitlab-ci.yml"), GITLAB_CI_HEADER + gitlab_ci.to_yaml.delete_prefix("---\n")
403
518
  end
404
519
 
520
+ # The JUnit report both CIs keep, loaded by the test helper right after the dummy app boots.
521
+ def create_junit_report
522
+ create_file File.join(atom_root, "test/support/junit_report.rb"), JUNIT_REPORT_CONTENT
523
+ inject_into_file File.join(atom_root, "test/test_helper.rb"),
524
+ "require_relative \"support/junit_report\"\n",
525
+ after: %r{^require "rails/test_help"\n}
526
+ end
527
+
405
528
  def fetch_security_summary
406
529
  %w[script/security_summary.rb test/script/security_summary_test.rb].each do |file|
407
530
  Thecore::Generators::SampleFetcher.fetch_thecore_sample(
@@ -422,7 +545,9 @@ module Thecore
422
545
  # in the ATOM's lockfile-less bundle does (the --skip-api-admin-deps variant even floats
423
546
  # to the newest Rails, where 5.x works too: checked on Rails 8.1).
424
547
  gemfile_addition << "gem 'minitest', '#{MINITEST_VERSION}'\n"
425
- gemfile_addition << "gem 'model_driven_api', '#{MODEL_DRIVEN_API_VERSION}'\n" \
548
+ # The CI's JUnit report (test/support/junit_report.rb).
549
+ gemfile_addition << "gem 'minitest-reporters', '#{MINITEST_REPORTERS_VERSION}'\n"
550
+ gemfile_addition << "gem 'model_driven_api', #{MODEL_DRIVEN_API_REQUIREMENTS.map { |r| "'#{r}'" }.join(", ")}\n" \
426
551
  "gem 'thecore_ui_rails_admin', '#{THECORE_UI_RAILS_ADMIN_VERSION}'\n" if @include_api_admin_deps
427
552
  append_to_file gemfile_path, gemfile_addition
428
553
 
@@ -453,7 +578,7 @@ module Thecore
453
578
  content = content.sub(/^(\s*spec\.add_dependency\s+["']rails["'].*)$/) do
454
579
  next Regexp.last_match(1) unless @include_api_admin_deps
455
580
 
456
- "#{Regexp.last_match(1)}\n spec.add_dependency \"model_driven_api\", \"#{MODEL_DRIVEN_API_VERSION}\"\n" \
581
+ "#{Regexp.last_match(1)}\n spec.add_dependency \"model_driven_api\", #{MODEL_DRIVEN_API_REQUIREMENTS.map(&:inspect).join(", ")}\n" \
457
582
  " spec.add_dependency \"thecore_ui_rails_admin\", \"#{THECORE_UI_RAILS_ADMIN_VERSION}\""
458
583
  end
459
584
  content = content.sub(/^\s*spec\.authors\s*=.*$/, " spec.authors = [#{@author.to_s.inspect}]")
@@ -461,7 +586,7 @@ module Thecore
461
586
  content = content.sub(/^\s*spec\.homepage\s*=.*$/, " spec.homepage = #{@url.to_s.inspect}")
462
587
  content = content.sub(/^\s*spec\.summary\s*=.*$/, " spec.summary = #{@summary.to_s.inspect}")
463
588
  content = content.sub(/^\s*spec\.description\s*=.*$/, " spec.description = #{@description.to_s.inspect}")
464
- content = content.sub(/^(\s*spec\.add_dependency\s+["']rails["']).*$/) { "#{Regexp.last_match(1)}, #{RAILS_VERSION.inspect}" }
589
+ content = content.sub(/^(\s*spec\.add_dependency\s+["']rails["']).*$/) { "#{Regexp.last_match(1)}, #{RAILS_REQUIREMENTS.map(&:inspect).join(", ")}" }
465
590
  content = content.sub(/^\s*spec\.metadata\["allowed_push_host"\]\s*=.*$/,
466
591
  " spec.metadata[\"allowed_push_host\"] = \"https://#{gem_host}\"")
467
592
  content = content.sub(/^\s*spec\.metadata\["source_code_uri"\]\s*=.*$/,
@@ -579,6 +704,32 @@ module Thecore
579
704
  "image" => "gabrieletassoni/vscode-devcontainers-thecore:3",
580
705
  "variables" => variables,
581
706
  "stages" => %w[test build],
707
+ # thecore_generators#26 (mytask's own CI): the dummy app on PostgreSQL 15 (never
708
+ # SQLite) on every branch push; build_gem needs it, so a red test never publishes.
709
+ "test_gem" => {
710
+ "stage" => "test",
711
+ "rules" => [
712
+ { "if" => "$CI_COMMIT_TAG", "when" => "never" },
713
+ { "if" => "$CI_COMMIT_BRANCH" },
714
+ ],
715
+ "services" => [{ "name" => "postgres:15-bookworm", "alias" => "db" }],
716
+ "variables" => {
717
+ "POSTGRES_PASSWORD" => "postgres", # Throwaway service container, gone with the job.
718
+ "PGHOST" => "db",
719
+ "PGUSER" => "postgres",
720
+ "PGPASSWORD" => "postgres",
721
+ "RAILS_ENV" => "test",
722
+ "CI" => "true",
723
+ "JUNIT_REPORT_DIR" => "$CI_PROJECT_DIR/tmp/junit",
724
+ },
725
+ "script" => ["bundle install --quiet", "bin/rails db:create", "bin/rails test"],
726
+ "artifacts" => {
727
+ "when" => "always",
728
+ "expire_in" => "30 days",
729
+ "paths" => ["tmp/junit/"],
730
+ "reports" => { "junit" => "tmp/junit/*.xml" },
731
+ },
732
+ },
582
733
  "build_gem" => {
583
734
  "rules" => [
584
735
  { "if" => "$CI_COMMIT_TAG", "when" => "never" },
@@ -586,7 +737,15 @@ module Thecore
586
737
  { "when" => "never" },
587
738
  ],
588
739
  "stage" => "build",
740
+ "needs" => ["test_gem"], # also downloads test_gem's tmp/junit/
589
741
  "script" => ["/usr/bin/gem-compile.sh"],
742
+ # The published version's test evidence: the JUnit report of the green run that
743
+ # gated it, kept in the pipeline of the commit that changed version.rb.
744
+ "artifacts" => {
745
+ "name" => "junit-$CI_PROJECT_NAME-$CI_COMMIT_SHORT_SHA",
746
+ "expire_in" => "never",
747
+ "paths" => ["tmp/junit/"],
748
+ },
590
749
  },
591
750
  "include" => [
592
751
  { "template" => "Jobs/SAST.gitlab-ci.yml" },
@@ -625,7 +784,7 @@ module Thecore
625
784
  def gempush_yml
626
785
  step = rubygems_host? ? GEMPUSH_RUBYGEMS_STEP : format(GEMPUSH_PRIVATE_HOST_STEP, host: gem_host, url: "https://#{gem_host}")
627
786
  # The step is a heredoc of its own: indent it to the steps list's level.
628
- GEMPUSH_YML_CONTENT + step.gsub(/^/, " ")
787
+ GEMPUSH_TEST_AND_CHECK + (step + GEMPUSH_TAG_AND_RELEASE).gsub(/^/, " ")
629
788
  end
630
789
 
631
790
  def rubygems_host?
@@ -33,33 +33,37 @@ gem "sassc-rails"
33
33
  # a `bundle update --conservative` from an old lock can't stay below it. ADR 0001
34
34
  # (thecore repo) only needed model_driven_api >= 3.9.0 / thecore_ui_rails_admin >= 3.8.0
35
35
  # (DefaultModuleRegistry); the floors below are higher.
36
- # - model_driven_api 3.13.1: the generic API no longer instantiates the class named by
37
- # the request path (any JWT could run `Tempfile.new` through `GET /api/v2/tempfiles`).
36
+ # - model_driven_api 3.13.2: JSON with `include:` works on Rails 8.1 (older ones raise
37
+ # FrozenError there). Since 3.13.1 the generic API no longer instantiates the class named
38
+ # by the request path (any JWT could run `Tempfile.new` through `GET /api/v2/tempfiles`).
38
39
  # - thecore_ui_rails_admin 3.8.7: RailsAdmin's User create form answered 500 under
39
40
  # Devise 5, which thecore_auth_commons 3.6.3 requires.
40
- gem "model_driven_api", "~> 3.13", ">= 3.13.1"
41
+ gem "model_driven_api", "~> 3.13", ">= 3.13.2"
41
42
  gem "thecore_ui_rails_admin", "~> 3.8", ">= 3.8.7"
42
43
  # Both already arrive as dependencies of the two gems above; listed only for their floors.
43
- # - thecore_backend_commons 3.10.0: no job is retried by default and only the latest
44
+ # - thecore_backend_commons 3.11.0: the first that resolves on Rails 8.1 (rails-i18n 8).
45
+ # Since 3.10.0 no job is retried by default and only the latest
44
46
  # failed job is kept (sidekiq-failures set capped at 1), so failing jobs can't fill
45
47
  # Redis; THECORE_JOB_RETRIES / THECORE_FAILED_JOBS_KEPT change both per installation.
46
48
  # It also carries 3.9.1's ActionCable JWT verification and 3.9.0's roo 3 (rubyzip
47
49
  # >= 3.4, CVE-2026-85396).
48
50
  # - thecore_auth_commons 3.6.3: OAuth login takes the identity only from OmniAuth's
49
51
  # verified data, never from request params (3.6.2: no fixed initial admin password).
50
- gem "thecore_backend_commons", "~> 3.10"
52
+ gem "thecore_backend_commons", "~> 3.11"
51
53
  gem "thecore_auth_commons", "~> 3.6", ">= 3.6.3"
52
54
  # `rails new` already declares rails and puma: their lines are rewritten, since a second
53
55
  # `gem` line with a different requirement is a Bundler error.
54
- # - rails 7.2.4: carries the 7.2.3.1/7.2.3.2 security fixes.
56
+ # - rails 8.1.4.1: new apps start on Rails 8.1 (ADR 0033 in mytask-imas, Odoo #6091), the
57
+ # first release with the 2026-11-04 security fixes. `~> 8.1.4` keeps it below 8.2,
58
+ # which the 3.x ATOMs don't support.
55
59
  # - puma 7.2.1: fixes the PROXY protocol v1 CVE-2026-47736/47737.
56
- gsub_file "Gemfile", /^gem ["']rails["'].*$/, 'gem "rails", "~> 7.2", ">= 7.2.4"'
60
+ gsub_file "Gemfile", /^gem ["']rails["'].*$/, 'gem "rails", "~> 8.1.4", ">= 8.1.4.1"'
57
61
  gsub_file "Gemfile", /^gem ["']puma["'].*$/, 'gem "puma", ">= 7.2.1"'
58
62
  # Pins still needed (checked against rubygems.org on 2026-11-09):
59
- # - redis < 6: Action Cable 7.2's Redis adapter (production's cable.yml) requires
60
- # `redis >= 4, < 6` when it loads. redis-namespace (via thecore_background_jobs) only
61
- # asks for `>= 4`, so a fresh resolve takes redis 6.0.0 and production crashes at boot
62
- # with a Gem::LoadError.
63
+ # - redis < 6: the line the pilot runs. Action Cable 7.2's Redis adapter (production's
64
+ # cable.yml) refused redis 6 at load; 8.1's accepts `< 7`, but redis 6 is untried with
65
+ # redis-namespace and Sidekiq 7 (via thecore_background_jobs), which only ask for
66
+ # `>= 4`. Lift it once the pilot runs on redis 6.
63
67
  # - connection_pool ~> 2.4: connection_pool 3 changed TimedStack#pop and breaks Sidekiq
64
68
  # 7's scheduler thread. Sidekiq 7.3.10 caps it below 3 itself, but 7.3.9 and earlier
65
69
  # don't, and Bundler can still pick that pair: a fresh resolve of this gem's own dev
@@ -116,7 +120,7 @@ create_file "vendor/external/.keep", <<~TEXT
116
120
  TEXT
117
121
 
118
122
  # --- No root Dockerfile ------------------------------------------------------
119
- # `rails new` (7.2) writes a Kamal-style root `Dockerfile` plus the
123
+ # `rails new` writes a Kamal-style root `Dockerfile` plus the
120
124
  # `bin/docker-entrypoint` it runs. The Thecore build script (`app-compile.sh` in
121
125
  # thecore_devcontainer) prefers a root `Dockerfile` whenever one exists, so keeping
122
126
  # Rails' one would make CI build the app with it instead of the Thecore Dockerfile
@@ -127,6 +131,58 @@ TEXT
127
131
  remove_file "Dockerfile"
128
132
  remove_file "bin/docker-entrypoint"
129
133
 
134
+ # The files below repeat what `thecore:atom` writes into an ATOM's dummy app (atom_generator.rb):
135
+ # this template runs standalone through `rails new -m <URL>` and can't require this gem's code.
136
+
137
+ # --- Devise's ORM hook, before anything boots the app ------------------------
138
+ # thecore_backend_commons and thecore_auth_commons load `User` while the app boots, and `User`
139
+ # calls `devise`, which only exists once "devise/orm/active_record" is required. Devise's own
140
+ # initializer requires it, but `devise:install` (below) has to boot the app to write it, and so
141
+ # do Rails' own `importmap:install` and any later `bin/rails` command: without this file every
142
+ # one of them fails with "undefined method `devise' for class User". Kept after the install
143
+ # too; requiring the hook a second time from config/initializers/devise.rb is a no-op.
144
+ create_file "config/initializers/00_devise_orm.rb", <<~RUBY, skip: true
145
+ # Loads Devise's ActiveRecord hook before the Thecore engines load `User` at boot.
146
+ require "devise/orm/active_record"
147
+ RUBY
148
+
149
+ # --- The app's Ability, before anything boots the app -------------------------
150
+ # thecore_auth_commons references `Ability` while the app boots, so `cancan:ability` (which
151
+ # boots it to run) could never write it. The pilot's (mytask-imas) Ability, written directly:
152
+ # permissions come from thecore_auth_commons' Role/Permission system, never from rules here.
153
+ create_file "app/models/ability.rb", <<~RUBY, skip: true
154
+ # frozen_string_literal: true
155
+
156
+ # CanCanCan ability class. Permissions in this application are managed through
157
+ # the Role / Permission / Predicate system provided by thecore_auth_commons,
158
+ # which populates abilities at runtime via its own hooks. This class is
159
+ # intentionally left empty — adding rules here would bypass that system.
160
+ class Ability
161
+ include CanCan::Ability
162
+
163
+ def initialize(user); end
164
+ end
165
+ RUBY
166
+
167
+ # --- Action Cable base classes ----------------------------------------------
168
+ # Rails 8 no longer generates app/channels/application_cable (7.2 did), but
169
+ # thecore_backend_commons includes its JWT cable authentication into
170
+ # ApplicationCable::Connection at boot and its channels subclass
171
+ # ApplicationCable::Channel: without them the app raises NameError when it starts.
172
+ # `skip: true` keeps the ones an older `rails new` already wrote.
173
+ create_file "app/channels/application_cable/connection.rb", <<~RUBY, skip: true
174
+ module ApplicationCable
175
+ class Connection < ActionCable::Connection::Base
176
+ end
177
+ end
178
+ RUBY
179
+ create_file "app/channels/application_cable/channel.rb", <<~RUBY, skip: true
180
+ module ApplicationCable
181
+ class Channel < ActionCable::Channel::Base
182
+ end
183
+ end
184
+ RUBY
185
+
130
186
  # --- Devcontainer / CI / CLAUDE.md assets, from thecore's own samples -------
131
187
  # Single source of truth (ADR 0005) — not duplicated inside this gem. The base
132
188
  # location is resolved fresh inside `fetch_thecore_sample` on every call, through
@@ -249,7 +305,24 @@ end
249
305
  # have connectivity. Wrapped in `after_bundle` (Rails' own template mechanism
250
306
  # for "run this once the gems this template just added are actually bundled")
251
307
  # so it runs after — never before — the gems above are installed.
252
- if options[:asset_pipeline].to_s != "sprockets"
308
+ # Rails 8's `rails new` only generates Propshaft (`--asset-pipeline=sprockets` is gone), but
309
+ # RailsAdmin 3 and the Thecore UI ATOMs run on Sprockets, as the pilot does: swap the gem and
310
+ # write the manifest Sprockets requires at boot (the one `rails new` 7.2 generated). The
311
+ # layout's `stylesheet_link_tag :app` is Propshaft's "every stylesheet" name: Sprockets looks
312
+ # for an app.css that doesn't exist, so every page with the layout raised AssetNotFound.
313
+ if File.read(File.join(destination_root, "Gemfile")).match?(/^gem ["']propshaft["']/)
314
+ gsub_file "Gemfile", /^gem ["']propshaft["'].*$/, 'gem "sprockets-rails"'
315
+ layout = "app/views/layouts/application.html.erb"
316
+ if File.exist?(File.join(destination_root, layout))
317
+ gsub_file layout, /stylesheet_link_tag :app\b/, 'stylesheet_link_tag "application"'
318
+ end
319
+ create_file "app/assets/config/manifest.js", <<~JS, skip: true
320
+ //= link_tree ../images
321
+ //= link_directory ../stylesheets .css
322
+ //= link_tree ../../javascript .js
323
+ //= link_tree ../../../vendor/javascript .js
324
+ JS
325
+ elsif options[:asset_pipeline].to_s != "sprockets"
253
326
  say_status :warning,
254
327
  "this template assumes --asset-pipeline=sprockets (got #{options[:asset_pipeline].inspect}) " \
255
328
  "-- rails_admin:install below is still configured for sprockets regardless, see the invocation " \
@@ -308,7 +381,9 @@ after_bundle do
308
381
  # limping on into later steps against a broken bundle/app.
309
382
  abort("bundle install failed -- aborting the app template's installer chain") unless bundle_command("install")
310
383
 
311
- generate "devise:install"
384
+ # `--orm=active_record`: this gem registers itself as the app's generator ORM (`:thecore`,
385
+ # ADR 0002), and devise:install writes `require "devise/orm/<that ORM>"`, which doesn't exist.
386
+ generate "devise:install", "--orm=active_record"
312
387
 
313
388
  # The `_namespace` positional argument ("app") is RailsAdmin::InstallGenerator's own
314
389
  # mount-path argument (not a placeholder/app-name) -- passing a non-blank value here
@@ -336,6 +411,6 @@ after_bundle do
336
411
  # between them.
337
412
  abort("bundle install failed -- aborting the app template's installer chain") unless bundle_command("install")
338
413
  rails_command "action_mailbox:install", abort_on_failure: true
339
- generate "cancan:ability"
414
+ # No `cancan:ability`: app/models/ability.rb is written above, before anything boots.
340
415
  generate "erd:install"
341
416
  end
@@ -1,3 +1,3 @@
1
1
  module ThecoreGenerators
2
- VERSION = "3.14.0"
2
+ VERSION = "3.15.0"
3
3
  end
metadata CHANGED
@@ -1,28 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thecore_generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.14.0
4
+ version: 3.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-11-24 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: railties
14
15
  requirement: !ruby/object:Gem::Requirement
15
16
  requirements:
16
- - - "~>"
17
+ - - ">="
17
18
  - !ruby/object:Gem::Version
18
19
  version: '7.2'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '8.2'
19
23
  type: :runtime
20
24
  prerelease: false
21
25
  version_requirements: !ruby/object:Gem::Requirement
22
26
  requirements:
23
- - - "~>"
27
+ - - ">="
24
28
  - !ruby/object:Gem::Version
25
29
  version: '7.2'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '8.2'
26
33
  description: Hooks Rails' own generator commands (model, migration) and adds thecore:*-namespaced
27
34
  generators plus a check_practices rake task, replacing scaffolding logic previously
28
35
  duplicated in the Thecore VS Code extension. See docs/adr/0002-thecore-generators-gem-and-generator-hook-mechanism.md
@@ -79,6 +86,7 @@ metadata:
79
86
  homepage_uri: https://github.com/gabrieletassoni/thecore_generators
80
87
  source_code_uri: https://github.com/gabrieletassoni/thecore_generators
81
88
  changelog_uri: https://github.com/gabrieletassoni/thecore_generators/blob/release/3/CHANGELOG.md
89
+ post_install_message:
82
90
  rdoc_options: []
83
91
  require_paths:
84
92
  - lib
@@ -93,7 +101,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
101
  - !ruby/object:Gem::Version
94
102
  version: '0'
95
103
  requirements: []
96
- rubygems_version: 3.6.9
104
+ rubygems_version: 3.5.22
105
+ signing_key:
97
106
  specification_version: 4
98
107
  summary: Rails-native generators for the Thecore 3 scaffolding framework.
99
108
  test_files: []