thecore_generators 3.13.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 +4 -4
- data/README.md +9 -6
- data/lib/generators/thecore/workspace_context.rb +21 -2
- data/lib/thecore_generators/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 82aaaedd48f043efdbc3f73c96a2dd28a59de2dede02d9be51c457a5ac2a8728
|
|
4
|
+
data.tar.gz: 6a9e1221628db11797320a882387bf0843cedea3861d3c338619271aa73d8c53
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a4781db70ca0658359f4ba768d34a9bce1433aadd1c87565b07a360dc4b57da7c1de98f4366b0b6a0dbaa3f753407433474259d8bcf086cd56366850a813b541
|
|
7
|
+
data.tar.gz: 0cbc37cc33e26a67f19d1c0a5dddd87595601c964eb5f2d6468ec839075ab8639082a82eb9e40691eaf5cc6496949519d1ba4aee62222e56e7125d5a0026c3bb
|
data/README.md
CHANGED
|
@@ -433,17 +433,20 @@ git-based dependencies — see the Gemfile's comment — purely so
|
|
|
433
433
|
`test/generators/thecore/model_generator_default_concern_behavior_test.rb` can prove the
|
|
434
434
|
no-concern default actually works at runtime, not just that no file was written.
|
|
435
435
|
|
|
436
|
+
`test/dummy` runs on PostgreSQL only (never SQLite). Create its test database once, then run
|
|
437
|
+
the suite:
|
|
438
|
+
|
|
436
439
|
```bash
|
|
437
440
|
bundle install
|
|
441
|
+
(cd test/dummy && RAILS_ENV=test bin/rails db:create)
|
|
438
442
|
bundle exec rake test
|
|
439
443
|
```
|
|
440
444
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
```
|
|
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.
|
|
447
450
|
|
|
448
451
|
`bundle exec rake` alone runs the same suite (`test` is the default Rake task).
|
|
449
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
|
-
|
|
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
|