thecore_generators 3.11.0 → 3.13.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: 753f6373a24773431ad2987bd84b7d8609f4a9bedb32dff5a59264bc37c68081
4
- data.tar.gz: bc6e8b3d5657bc82bebc1c1913a591e1b7bcb7545f8620d7b4b92704e4735558
3
+ metadata.gz: 82aaaedd48f043efdbc3f73c96a2dd28a59de2dede02d9be51c457a5ac2a8728
4
+ data.tar.gz: 6a9e1221628db11797320a882387bf0843cedea3861d3c338619271aa73d8c53
5
5
  SHA512:
6
- metadata.gz: f5f315cbe3496bca9a6f8ac33c1af880aba847704d1bda5f313dbfecae44cae8e2d66e6548a3e1eabd473921ec36bfddd0f96fae2dc7f509386a3f31059a53f3
7
- data.tar.gz: 435300740a43124c459e8688e3a3957693b0fd435e664ee07f52b824b30260d90b4a5d4c70e669157df65a5c1c52acd5a056c69fcf2af1d2ec6e59edf8e9030e
6
+ metadata.gz: a4781db70ca0658359f4ba768d34a9bce1433aadd1c87565b07a360dc4b57da7c1de98f4366b0b6a0dbaa3f753407433474259d8bcf086cd56366850a813b541
7
+ data.tar.gz: 0cbc37cc33e26a67f19d1c0a5dddd87595601c964eb5f2d6468ec839075ab8639082a82eb9e40691eaf5cc6496949519d1ba4aee62222e56e7125d5a0026c3bb
data/README.md CHANGED
@@ -391,9 +391,12 @@ for the full design and why the two stay separate).
391
391
  - **Devcontainer/CI/CLAUDE.md**, fetched from the `thecore` repo's own `samples/` (single source
392
392
  of truth, not duplicated here) and written unconditionally, overwriting whatever the bootstrap
393
393
  "Setup Devcontainer" step created: `.devcontainer/*` (base image, plugin mounts, `gh`/`glab`
394
- CLI config mounts commented out by default), `.gitlab-ci.yml` (build/test/lint/deploy, no
395
- customer-specific paths), and `CLAUDE.md` (universal sections only, project-specific sections
396
- left as TODO placeholders). The fetch location is one overridable point,
394
+ CLI config mounts commented out by default), **both** `.gitlab-ci.yml` and
395
+ `.github/workflows/ci.yml` (build/test/lint/deploy, no customer-specific paths — no hosting-
396
+ profile prompt, same git-hosting-agnostic reasoning ADR 0006 established for `thecore:atom`'s
397
+ own dual-CI generation, extended here by ADR 0007/thecore_generators#25), and `CLAUDE.md`
398
+ (universal sections only, project-specific sections left as TODO placeholders). The fetch
399
+ location is one overridable point,
397
400
  `ENV["THECORE_SAMPLES_SOURCE"]`, defaulting to the raw GitHub URL for `thecore`'s `samples/`
398
401
  on `master` (`thecore`'s actual default branch).
399
402
  - **The standard installer chain** (`devise:install`, `rails_admin:install`, `active_storage:
@@ -401,8 +404,16 @@ for the full design and why the two stay separate).
401
404
  each preceded by the necessary `bundle install`) is genuinely optional, gated behind an
402
405
  interactive prompt (`yes?`, wrapped in `after_bundle` so it only ever runs once the gems
403
406
  above are actually bundled) — a developer bootstrapping without network access can decline
404
- and run these by hand later. There is no non-interactive/unattended flag for this in the
405
- current version (tracked as a future improvement, not silently missing).
407
+ and run these by hand later.
408
+ - **Non-interactive/unattended mode**: set `THECORE_APP_TEMPLATE_NON_INTERACTIVE` (any non-blank
409
+ value) to bypass the installer-chain prompt above. When set, `THECORE_APP_TEMPLATE_RUN_INSTALLERS`
410
+ (`"true"` or `"false"`) is required — the template aborts with a clear message if it's missing
411
+ or unrecognized, rather than guessing. Example:
412
+ ```bash
413
+ THECORE_APP_TEMPLATE_NON_INTERACTIVE=1 THECORE_APP_TEMPLATE_RUN_INSTALLERS=true \
414
+ rails new myapp --database=postgresql --asset-pipeline=sprockets \
415
+ -m https://raw.githubusercontent.com/gabrieletassoni/thecore_generators/release/3/lib/templates/app_template.rb
416
+ ```
406
417
 
407
418
  ## Installation
408
419
 
@@ -422,17 +433,20 @@ git-based dependencies — see the Gemfile's comment — purely so
422
433
  `test/generators/thecore/model_generator_default_concern_behavior_test.rb` can prove the
423
434
  no-concern default actually works at runtime, not just that no file was written.
424
435
 
436
+ `test/dummy` runs on PostgreSQL only (never SQLite). Create its test database once, then run
437
+ the suite:
438
+
425
439
  ```bash
426
440
  bundle install
441
+ (cd test/dummy && RAILS_ENV=test bin/rails db:create)
427
442
  bundle exec rake test
428
443
  ```
429
444
 
430
- If your shell has `DATABASE_URL` set to a PostgreSQL URL (e.g. inside the Thecore
431
- devcontainer), unset it first — it overrides `test/dummy`'s own SQLite3 test config:
432
-
433
- ```bash
434
- env -u DATABASE_URL bundle exec rake test
435
- ```
445
+ Connection settings come from `PGHOST`/`PGPORT`/`PGUSER`/`PGPASSWORD` (defaults
446
+ `db`/`5432`/`postgres`/`postgres`). If `DATABASE_URL` is set to a PostgreSQL URL (e.g. inside the
447
+ Thecore devcontainer), `test/dummy/config/boot.rb` keeps its server/credentials but always
448
+ swaps the database name to `thecore_generators_<RAILS_ENV>`, so tests never touch the host
449
+ app's database — no need to unset it.
436
450
 
437
451
  `bundle exec rake` alone runs the same suite (`test` is the default Rake task).
438
452
 
@@ -37,7 +37,7 @@ module Thecore
37
37
  atom_name = atom_name.to_s.strip
38
38
  return resolve_named_atom(app_root, atom_name) unless atom_name.empty?
39
39
 
40
- resolve_cwd_atom(cwd)
40
+ resolve_cwd_atom(cwd, app_root)
41
41
  end
42
42
 
43
43
  # Walks up from `dir` until the immediate parent directory is
@@ -137,9 +137,21 @@ module Thecore
137
137
  "(expected a #{atom_name}.gemspec or #{atom_name.tr('-', '_')}.gemspec inside it)."
138
138
  end
139
139
 
140
- def resolve_cwd_atom(cwd)
140
+ # A cwd-detected ATOM only counts when it belongs to the app being
141
+ # generated into: it must be `app_root` itself (e.g. an engine's own
142
+ # bin/rails, whose destination_root is already the ATOM) or live
143
+ # inside it. For a real `rails generate` the app root is always an
144
+ # ancestor of cwd, so this never changes the normal outcome — but
145
+ # when `app_root` itself sits *inside* some `vendor/submodules/<x>/`
146
+ # tree (an ATOM's own test/dummy app, or a gem checked out as a
147
+ # submodule of a host app and running its own generator tests with
148
+ # a tmp destination_root), walking up from cwd would otherwise find
149
+ # that enclosing <x> and redirect every file *out of* app_root into
150
+ # it. See thecore_generators' CLAUDE.md, WorkspaceContext.
151
+ def resolve_cwd_atom(cwd, app_root)
141
152
  candidate = atom_root_of(cwd)
142
153
  return nil unless candidate
154
+ return nil unless within_app_root?(candidate, app_root)
143
155
 
144
156
  unless valid_atom_dir?(candidate)
145
157
  raise Thor::Error,
@@ -149,6 +161,13 @@ module Thecore
149
161
 
150
162
  candidate
151
163
  end
164
+
165
+ def within_app_root?(candidate, app_root)
166
+ return true if app_root.to_s.empty?
167
+
168
+ root = File.expand_path(app_root.to_s)
169
+ candidate == root || candidate.start_with?("#{root}/")
170
+ end
152
171
  end
153
172
  end
154
173
  end
@@ -153,6 +153,10 @@ chmod ".devcontainer/link-host-home.sh", 0o755
153
153
  chmod ".devcontainer/check-plugins.sh", 0o755
154
154
 
155
155
  fetch_thecore_sample(".gitlab-ci.yml", ".gitlab-ci.yml")
156
+ # thecore_generators#25 (ADR 0007): fetched unconditionally, alongside .gitlab-ci.yml above --
157
+ # no hosting-profile prompt, same reasoning ADR 0006 already established for thecore:atom's own
158
+ # dual-CI generation (git hosting is a generic, per-developer choice, not something to ask about).
159
+ fetch_thecore_sample(".github/workflows/ci.yml", ".github/workflows/ci.yml")
156
160
  fetch_thecore_sample("CLAUDE.md", "CLAUDE.md")
157
161
 
158
162
  # --- Standard installer chain ------------------------------------------------
@@ -170,10 +174,44 @@ if options[:asset_pipeline].to_s != "sprockets"
170
174
  :yellow
171
175
  end
172
176
 
173
- run_setup_now = yes?(
174
- "Run `bundle install` and the standard installer generators (devise, rails_admin, " \
175
- "active_storage, action_text, action_mailbox, cancan, erd) now? (y/n)"
176
- )
177
+ # thecore_generators#23: non-interactive mode, triggered ONLY by the explicit env var
178
+ # below -- deliberately NOT auto-detected from tty absence the way `thecore:atom`'s
179
+ # `TtyDetection`-based `effectively_non_interactive?` is (ADR 0006). That precedent
180
+ # works because `AtomGenerator` runs in-process inside its own test, where stubbing
181
+ # `$stdin.tty?`/`$stdout.tty?` (see `association_wiring_test.rb`) is meaningful. This
182
+ # template instead always runs as a genuine separate `rails new` subprocess (its own
183
+ # test seam spawns it via Open3), whose stdin is a pipe -- never a real tty -- even
184
+ # when the test is legitimately simulating interactive use by feeding an answer via
185
+ # `stdin_data`. Auto-triggering on tty absence would misfire on every such simulated-
186
+ # interactive test run; the explicit, deliberate opt-in below avoids that with no loss
187
+ # of real-world safety (an unattended CI run with neither var set still fails loudly
188
+ # below, just one env var short of `thecore:atom`'s own auto-detected equivalent).
189
+ non_interactive = !ENV["THECORE_APP_TEMPLATE_NON_INTERACTIVE"].to_s.strip.empty?
190
+
191
+ run_setup_now =
192
+ if non_interactive
193
+ run_installers_raw = ENV["THECORE_APP_TEMPLATE_RUN_INSTALLERS"]
194
+ if run_installers_raw.nil? || run_installers_raw.strip.empty?
195
+ abort(
196
+ "THECORE_APP_TEMPLATE_NON_INTERACTIVE is set but THECORE_APP_TEMPLATE_RUN_INSTALLERS " \
197
+ "is not -- set it to \"true\" or \"false\" to say whether the installer chain " \
198
+ "(devise/rails_admin/active_storage/action_text/action_mailbox/cancan/erd) should run."
199
+ )
200
+ end
201
+ normalized = run_installers_raw.strip.downcase
202
+ unless %w[true false].include?(normalized)
203
+ abort(
204
+ "THECORE_APP_TEMPLATE_RUN_INSTALLERS must be \"true\" or \"false\", got " \
205
+ "#{run_installers_raw.inspect}."
206
+ )
207
+ end
208
+ normalized == "true"
209
+ else
210
+ yes?(
211
+ "Run `bundle install` and the standard installer generators (devise, rails_admin, " \
212
+ "active_storage, action_text, action_mailbox, cancan, erd) now? (y/n)"
213
+ )
214
+ end
177
215
 
178
216
  after_bundle do
179
217
  next unless run_setup_now
@@ -1,3 +1,3 @@
1
1
  module ThecoreGenerators
2
- VERSION = "3.11.0"
2
+ VERSION = "3.13.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thecore_generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.0
4
+ version: 3.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni