thecore_generators 3.6.0 → 3.8.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: b52de470428f2cecb91388721b140a88d6cdb0a1e0ea7b3ce07b0b855e17fbaa
4
- data.tar.gz: 5a6147ac698f2820027e493bd8bdee96c13f39867dd50f6b472a495f5f01b829
3
+ metadata.gz: 43638f50febe1bf078edcf5e5490c33709065db0a522f2b14a659c9ae19954ab
4
+ data.tar.gz: 368b0b26a79a4a5be2ccc394e0dd4d64061efb1c66aa099d124432a1455e4230
5
5
  SHA512:
6
- metadata.gz: 52374b36988c76209702afb27c59e32ac95e05c53ca805914257264bb3eaae31ee06fa3329faae3a6da5c25742d31e136f470a22cf1897cdbd9a17caad010f97
7
- data.tar.gz: 75083924ea8bdc22bf39d5dbea930da5ec5eb37d736107b43037e235d40a4430b0ae963a24133b9789631135de83b51cdfb1afd82515c4d2f0c69ddb43bb30a2
6
+ metadata.gz: a0a7cb2fc271fe3f495ad2a4234ba338fc9e9b50f8309e2aefc593777d85fc8fa5b5146698f7000009a2da0552e1a89cd296e680a0003c99f6bca09e1b962e7e
7
+ data.tar.gz: 7495d392354b1f1834b8fba5117449f3b9383aa6df89f4bd637c9044bc7c3357f2136d316385b89057b2a851047887df7c49f94db5a7aa97641a91189ea05510
data/README.md CHANGED
@@ -22,6 +22,13 @@ transparently apply thecore's scaffolding conventions — no new command vocabul
22
22
  (check_practices + Root/Member Action generators) is complete** as of this release: `rails
23
23
  generate thecore:root_action`, `rails generate thecore:member_action`, and `rails
24
24
  thecore:check_practices` (Scaffold Files + Models + Actions, `--fix` included) all ship.
25
+ **Phase 3's App application template** (porting `createApp.js`) is complete as of this release —
26
+ both the core (`lib/templates/app_template.rb`: Rails app + Gemfile stack + vendor placeholders,
27
+ thecore_generators#17) and devcontainer/CI/CLAUDE.md asset fetching from the thecore repo's own
28
+ samples (thecore_generators#18) have shipped. The `thecore:atom` generator and a Collection
29
+ Action generator remain deferred to a future session (ADR 0005). See
30
+ [ADR 0005](https://github.com/gabrieletassoni/thecore/blob/release/3/docs/adr/0005-app-template-scoped-to-rails-new-m-assets-sourced-from-thecore-samples.md)
31
+ in the thecore repo for the full design.
25
32
 
26
33
  ### What `rails generate model`/`rails generate migration` do now
27
34
 
@@ -252,6 +259,54 @@ remain (so a violation this run can't fix, e.g. a `collection_action` companion,
252
259
  after `--fix`). The task exits non-zero whenever any violation remains, zero otherwise, so it's
253
260
  usable as a CI gate either with or without `--fix`.
254
261
 
262
+ ### Application Template (`rails new -m`) (thecore_generators#17/#18)
263
+
264
+ A Ruby port of `thecore_code_extension`'s `createApp.js`, as a genuine Rails application
265
+ template rather than a `thecore:*` generator — its entry point is `rails new -m`, not `rails
266
+ generate`:
267
+
268
+ ```bash
269
+ rails new myapp --database=postgresql --asset-pipeline=sprockets \
270
+ -m https://raw.githubusercontent.com/gabrieletassoni/thecore_generators/release/3/lib/templates/app_template.rb
271
+ ```
272
+
273
+ Run inside a devcontainer already created by the "Setup Devcontainer" VS Code command — a
274
+ bootstrap step this template doesn't invoke or modify itself (that command's own code is
275
+ untouched), even though the template's own devcontainer-asset fetch below does overwrite the
276
+ files that bootstrap step created, by design. See
277
+ [ADR 0005](https://github.com/gabrieletassoni/thecore/blob/release/3/docs/adr/0005-app-template-scoped-to-rails-new-m-assets-sourced-from-thecore-samples.md)
278
+ for the full design and why the two stay separate).
279
+
280
+ - **Core Gemfile stack, active** — `devise`, `cancancan`, `rails_admin`, `sassc-rails`,
281
+ `model_driven_api` (`~> 3.9`), `thecore_ui_rails_admin` (`~> 3.8` — both meeting ADR 0001's
282
+ `DefaultModuleRegistry` floor), `rails-erd` (`:development`). `thecore_generators` itself is
283
+ added too, `group: :development` — so the generated app can immediately use every
284
+ generator/task documented above without a manual Gemfile edit first.
285
+ - **The rest of the generic Thecore ecosystem, commented out** — `thecore_auth_commons`,
286
+ `thecore_settings`, `thecore_print_commons`, `thecore_background_jobs`, `thecore_ui_commons`,
287
+ `thecore_tcp_debug`, `thecore_download_documents`, `thecore_dataentry_commons`,
288
+ `thecore_connectors`, each with a one-line purpose comment — discoverable but off by default,
289
+ the same "commented but documented" philosophy ADR 0005 applies to the devcontainer's `gh`/
290
+ `glab` CLI mounts below.
291
+ - **`vendor/submodules/`/`vendor/external/`** — created empty (a `.keep` file each), not
292
+ pre-wired with any submodule or gem. Per ADR 0005 these are developer-convenience clone
293
+ locations, not template content.
294
+ - **Devcontainer/CI/CLAUDE.md**, fetched from the `thecore` repo's own `samples/` (single source
295
+ of truth, not duplicated here) and written unconditionally, overwriting whatever the bootstrap
296
+ "Setup Devcontainer" step created: `.devcontainer/*` (base image, plugin mounts, `gh`/`glab`
297
+ CLI config mounts commented out by default), `.gitlab-ci.yml` (build/test/lint/deploy, no
298
+ customer-specific paths), and `CLAUDE.md` (universal sections only, project-specific sections
299
+ left as TODO placeholders). The fetch location is one overridable point,
300
+ `ENV["THECORE_SAMPLES_SOURCE"]`, defaulting to the raw GitHub URL for `thecore`'s `samples/`
301
+ on `master` (`thecore`'s actual default branch).
302
+ - **The standard installer chain** (`devise:install`, `rails_admin:install`, `active_storage:
303
+ install`, `action_text:install`, `action_mailbox:install`, `cancan:ability`, `erd:install`,
304
+ each preceded by the necessary `bundle install`) is genuinely optional, gated behind an
305
+ interactive prompt (`yes?`, wrapped in `after_bundle` so it only ever runs once the gems
306
+ above are actually bundled) — a developer bootstrapping without network access can decline
307
+ and run these by hand later. There is no non-interactive/unattended flag for this in the
308
+ current version (tracked as a future improvement, not silently missing).
309
+
255
310
  ## Installation
256
311
 
257
312
  Add to your host app's or ATOM's `Gemfile`:
@@ -0,0 +1,220 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Thecore 3 Application Template — porting createApp.js's Gemfile/vendor-directory
4
+ # behavior (thecore_generators#17) plus devcontainer/CI/CLAUDE.md assets fetched from
5
+ # thecore's own samples/ (thecore_generators#18). See ADR 0005 in the thecore repo for
6
+ # the full design rationale behind both.
7
+ #
8
+ # Invoke via:
9
+ #
10
+ # rails new myapp --database=postgresql --asset-pipeline=sprockets \
11
+ # -m https://raw.githubusercontent.com/gabrieletassoni/thecore_generators/release/3/lib/templates/app_template.rb
12
+ #
13
+ # (or a local path to this file, e.g. while developing thecore_generators itself)
14
+
15
+ # --- Core Gemfile stack ------------------------------------------------------
16
+ # Always added, uncommented — every Thecore host app needs these (see thecore's own
17
+ # CLAUDE.md/GUIDE.md, "Standard Gem Stack").
18
+ gem "devise"
19
+ gem "cancancan"
20
+ gem "rails_admin"
21
+ # `rails_admin:install --asset=sprockets` (below) also unconditionally appends its own
22
+ # `gem 'sassc-rails'` line via its `configure_for_sprockets` step -- verified against
23
+ # the installed rails_admin 3.3.0 source, that step does nothing else. The resulting
24
+ # duplicate is harmless (empirically confirmed: `bundle lock` against two identical,
25
+ # unconstrained `gem` lines warns "lists the gem more than once" but resolves and
26
+ # exits 0) -- not worth a fragile post-install dedupe for a cosmetic Gemfile wart, and
27
+ # this declaration must stay regardless, since sassc-rails needs to be active even
28
+ # when the installer chain below is declined.
29
+ gem "sassc-rails"
30
+ # ADR 0001 (thecore repo) requires model_driven_api >= 3.9.0 / thecore_ui_rails_admin
31
+ # >= 3.8.0 for the DefaultModuleRegistry default-concern behavior this whole ecosystem
32
+ # now relies on -- matching the floor this gem's own Gemfile already pins to (see its
33
+ # comment), not an arbitrary choice.
34
+ gem "model_driven_api", "~> 3.9"
35
+ gem "thecore_ui_rails_admin", "~> 3.8"
36
+ gem "rails-erd", group: :development
37
+
38
+ # thecore_generators itself is dev-tooling only (it hooks `rails g model`/`migration`,
39
+ # see ADR 0002 in the thecore repo) — never a runtime dependency, so it goes in the
40
+ # :development group. A single-line `group:` option is equivalent to (and simpler
41
+ # than) createApp.js's manual `group :development do ... end` block insertion.
42
+ gem "thecore_generators", "~> 3.6", group: :development
43
+
44
+ # --- Optional ecosystem gems, discoverable but off by default ---------------
45
+ # Same "commented but documented" philosophy as the devcontainer's gh/glab CLI
46
+ # mounts (ADR 0005): each of these publishes to RubyGems.org (see thecore's own
47
+ # CLAUDE.md) but isn't needed by every app, so it starts commented out with a
48
+ # one-line description — uncomment only the ones this project actually needs.
49
+ append_to_file "Gemfile", <<~RUBY
50
+
51
+ # The rest of the generic Thecore ecosystem — uncomment only what you need.
52
+ # gem "thecore_auth_commons", "~> 3.0" # Role/permission/predicate models and authorization scaffolding
53
+ # gem "thecore_settings", "~> 3.0" # ThecoreSettings key/value configuration store
54
+ # gem "thecore_print_commons", "~> 3.0" # Shared PDF/print generation helpers
55
+ # gem "thecore_background_jobs", "~> 3.0" # Shared background job scheduling helpers
56
+ # gem "thecore_ui_commons", "~> 3.0" # Shared UI helpers/components for the admin frontend
57
+ # gem "thecore_tcp_debug", "~> 3.0" # TCP-level debugging/diagnostics support
58
+ # gem "thecore_download_documents", "~> 3.0" # Document download support
59
+ # gem "thecore_dataentry_commons", "~> 3.0" # Shared data-entry UI helpers
60
+ # gem "thecore_connectors" # Helpers for connecting to external systems/data sources
61
+ RUBY
62
+
63
+ # --- Developer-convenience placeholder directories --------------------------
64
+ # NOT template content (ADR 0005) — just known, git-trackable locations to clone
65
+ # auxiliary repos into during local development. Created empty; nothing is
66
+ # pre-wired, no submodule declarations, no Gemfile `path:` entries.
67
+ empty_directory "vendor/submodules"
68
+ create_file "vendor/submodules/.keep", <<~TEXT
69
+ Clone auxiliary Thecore ecosystem repos here during local development (e.g. an
70
+ ATOM you're developing against this app). Not consumed by any Gemfile entry
71
+ automatically — add a `path:` gem yourself if you want one of these clones
72
+ bundled from source instead of from RubyGems.org.
73
+ TEXT
74
+
75
+ empty_directory "vendor/external"
76
+ create_file "vendor/external/.keep", <<~TEXT
77
+ Clone read-only reference repos here during local development (framework docs,
78
+ sibling tooling repos you want open alongside this app). Not consumed by
79
+ anything automatically.
80
+ TEXT
81
+
82
+ # --- Devcontainer / CI / CLAUDE.md assets, from thecore's own samples -------
83
+ # Single source of truth (ADR 0005) — not duplicated inside this gem. The base
84
+ # location is resolved fresh inside `fetch_thecore_sample` on every call, through
85
+ # one overridable point: `ENV["THECORE_SAMPLES_SOURCE"]`, defaulting to the real
86
+ # raw GitHub URL for thecore's `samples/` directory on `master` (thecore's own
87
+ # default branch — double-checked directly against that repo, not assumed from
88
+ # this gem's own `release/3` naming convention, which doesn't apply there). An
89
+ # unset *or blank* env var falls back to the default (an explicit emptiness
90
+ # check, not `||` alone — `ENV["X"] || default` would treat `THECORE_SAMPLES_SOURCE=""`,
91
+ # a realistic shape for an optional env var in a compose file with no value set,
92
+ # as a real override and try to read a same-named file relative to whatever the
93
+ # current directory happens to be, instead of falling back). An http(s) value is
94
+ # fetched over the network via `get`; anything else is treated as a local
95
+ # directory and read directly — this gem's own offline test points it at a
96
+ # fixture instead.
97
+ #
98
+ # NOTE: this default URL only serves real content once `thecore`'s `master`
99
+ # carries the commits that added `samples/CLAUDE.md`/`samples/.gitlab-ci.yml`
100
+ # and brought `samples/devcontainer/` up to date (thecore#14/#15) — as of this
101
+ # gem's own 3.8.0 release those commits exist only in a local checkout, not
102
+ # pushed to `origin/master` yet. Until they're pushed, the default URL 404s for
103
+ # `.gitlab-ci.yml`/`CLAUDE.md`/the two devcontainer scripts and serves stale
104
+ # content for `devcontainer.json`/`docker-compose.yml`. This is an operational
105
+ # sequencing issue (push `thecore` before relying on the default in production),
106
+ # not a defect in this code — but it means `THECORE_SAMPLES_SOURCE` pointed at a
107
+ # local clone of `thecore` is the only way to exercise the real default content
108
+ # today.
109
+ #
110
+ # Every write below is unconditional (`force: true`, no interactive prompt).
111
+ # Of the six `.devcontainer/*` files, four (`devcontainer.json`,
112
+ # `docker-compose.yml`, `Dockerfile`, `create-db-user.sql`) are expected to
113
+ # already exist, written by the separate, prior "Setup Devcontainer" bootstrap
114
+ # step this template runs inside of (verified directly against that command's
115
+ # source, `thecore_code_extension/commands/setupDevContainer.js`) — replacing
116
+ # them is the whole point, not a conflict to ask about. The other two
117
+ # (`link-host-home.sh`/`check-plugins.sh`) are *not* written by that step at
118
+ # all — genuinely new files here, not overwrites — but `force: true` is harmless
119
+ # for a new file and keeps every write in this block uniform.
120
+ # `.gitlab-ci.yml`/`CLAUDE.md` don't exist yet in the documented flow either,
121
+ # but stay unconditional too so re-running this template later
122
+ # (`bin/rails app:template`) is a clean overwrite, not a prompt.
123
+ #
124
+ # A fetch failure (today: the 404s above; going forward: any network blip, or
125
+ # `thecore` reorganizing `samples/`) aborts the whole template with a clear,
126
+ # specific message instead of continuing into a silently half-scaffolded app
127
+ # (some `.devcontainer/*` files present, others not, no clear signal pointing
128
+ # back to the real cause) -- the same fail-fast philosophy thecore_generators#17
129
+ # already applies to `bundle_command`/`rails_command` failures in the installer
130
+ # chain below.
131
+ def fetch_thecore_sample(relative_path, destination)
132
+ source = ENV["THECORE_SAMPLES_SOURCE"]
133
+ source = "https://raw.githubusercontent.com/gabrieletassoni/thecore/master/samples" if source.nil? || source.empty?
134
+
135
+ if source.start_with?("http://", "https://")
136
+ get("#{source}/#{relative_path}", destination, force: true)
137
+ else
138
+ create_file(destination, File.read(File.join(source, relative_path)), force: true)
139
+ end
140
+ rescue StandardError => e
141
+ abort("Failed to fetch #{relative_path} from #{source} (#{e.class}: #{e.message}) " \
142
+ "-- aborting the app template. Set THECORE_SAMPLES_SOURCE to override the source.")
143
+ end
144
+
145
+ %w[devcontainer.json docker-compose.yml Dockerfile create-db-user.sql link-host-home.sh check-plugins.sh].each do |file|
146
+ fetch_thecore_sample("devcontainer/#{file}", ".devcontainer/#{file}")
147
+ end
148
+ # `get`/`create_file` only write content, never permissions — the executable bit
149
+ # has to be restored explicitly for the two scripts (`thecore/samples/devcontainer/`
150
+ # stores them executable, but that's lost the moment their bytes cross an HTTP
151
+ # fetch or a plain `File.read`).
152
+ chmod ".devcontainer/link-host-home.sh", 0o755
153
+ chmod ".devcontainer/check-plugins.sh", 0o755
154
+
155
+ fetch_thecore_sample(".gitlab-ci.yml", ".gitlab-ci.yml")
156
+ fetch_thecore_sample("CLAUDE.md", "CLAUDE.md")
157
+
158
+ # --- Standard installer chain ------------------------------------------------
159
+ # Needs the gems added above actually bundled and installable, i.e. real network
160
+ # access — genuinely optional (not a test-only escape hatch): a developer
161
+ # bootstrapping offline can say no here and run these steps by hand once they
162
+ # have connectivity. Wrapped in `after_bundle` (Rails' own template mechanism
163
+ # for "run this once the gems this template just added are actually bundled")
164
+ # so it runs after — never before — the gems above are installed.
165
+ if options[:asset_pipeline].to_s != "sprockets"
166
+ say_status :warning,
167
+ "this template assumes --asset-pipeline=sprockets (got #{options[:asset_pipeline].inspect}) " \
168
+ "-- rails_admin:install below is still configured for sprockets regardless, see the invocation " \
169
+ "documented in this gem's README.",
170
+ :yellow
171
+ end
172
+
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
+
178
+ after_bundle do
179
+ next unless run_setup_now
180
+
181
+ # `bundle_command`/`rails_command` never abort on failure by themselves (verified
182
+ # against railties' own source: `bundle_command` is a bare `system` call with no
183
+ # result check at all; `rails_command` only aborts when `abort_on_failure: true` is
184
+ # passed explicitly -- `generate` sets that internally, `rails_command` does not).
185
+ # createApp.js's own equivalent was one `&&`-joined shell command that failed the
186
+ # whole chain atomically on any step; matched here explicitly rather than silently
187
+ # limping on into later steps against a broken bundle/app.
188
+ abort("bundle install failed -- aborting the app template's installer chain") unless bundle_command("install")
189
+
190
+ generate "devise:install"
191
+
192
+ # The `_namespace` positional argument ("app") is RailsAdmin::InstallGenerator's own
193
+ # mount-path argument (not a placeholder/app-name) -- passing a non-blank value here
194
+ # is what makes it skip its interactive "Where do you want to mount rails_admin?"
195
+ # prompt (verified against its source), which nothing in this non-interactive chain
196
+ # could ever answer. The resulting namespace is irrelevant: `thecore_ui_rails_admin`
197
+ # already mounts `RailsAdmin::Engine` itself, in its own engine routes (see that
198
+ # gem's `config/routes.rb`) -- a second, active mount in *this* app's routes.rb would
199
+ # be a genuine duplicate route, not just cosmetic. `route(...)` below writes a
200
+ # commented placeholder line containing the exact substring
201
+ # (`"mount RailsAdmin::Engine"`) the installer checks for
202
+ # (`routes.rb.include?('mount RailsAdmin::Engine')`) *before* calling it, so it skips
203
+ # inserting an active one at all -- more robust than adding one and regex-stripping
204
+ # it back out afterward (a future RailsAdmin release reformatting its generated line
205
+ # would silently break a regex-based removal with no error raised anywhere).
206
+ route "# mount RailsAdmin::Engine -- already mounted by thecore_ui_rails_admin's own engine routes, see that gem's config/routes.rb"
207
+ generate "rails_admin:install", "app", "--asset=sprockets"
208
+
209
+ rails_command "active_storage:install", abort_on_failure: true
210
+ rails_command "action_text:install", abort_on_failure: true
211
+ # action_text:install (above) may add its own `image_processing` Gemfile dependency
212
+ # (verified against its source) -- this bundle is the one that actually picks that
213
+ # up; devise:install/rails_admin:install above added nothing new to bundle beyond
214
+ # what the first `bundle_command("install")` already covered, so no bundle call sits
215
+ # between them.
216
+ abort("bundle install failed -- aborting the app template's installer chain") unless bundle_command("install")
217
+ rails_command "action_mailbox:install", abort_on_failure: true
218
+ generate "cancan:ability"
219
+ generate "erd:install"
220
+ end
@@ -1,3 +1,3 @@
1
1
  module ThecoreGenerators
2
- VERSION = "3.6.0"
2
+ VERSION = "3.8.0"
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.6.0
4
+ version: 3.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni
@@ -56,6 +56,7 @@ files:
56
56
  - lib/generators/thecore/root_action/templates/action.scss.tt
57
57
  - lib/generators/thecore/workspace_context.rb
58
58
  - lib/tasks/thecore_generators_tasks.rake
59
+ - lib/templates/app_template.rb
59
60
  - lib/thecore_generators.rb
60
61
  - lib/thecore_generators/check_practices.rb
61
62
  - lib/thecore_generators/railtie.rb