Skip to content

Commit 64d756a

Browse files
committed
[Improvement] Docs: abort symlink sync on duplicate controller basenames
Address cubic review on #493: - `ruby_ui:sync_controller_symlinks` now detects two gem controllers sharing a basename before creating any link and aborts listing the offenders. The docs controllers directory is flat, so the second symlink would silently clobber the first and one component would ship the wrong JS. - Fix the missing `rake` prefix on `stimulus:manifest:update` in the ruby-ui-stimulus skill.
1 parent af7d6ef commit 64d756a

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

.claude/skills/ruby-ui-stimulus/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Building or changing a Stimulus-backed component:
4444
- `docs/app/javascript/controllers/ruby_ui/<component>_controller.js` is a
4545
symlink to the gem file above, not a copy. For a brand-new controller, run
4646
`bin/rails ruby_ui:sync_controller_symlinks` in `docs/` first to create the
47-
symlink, then `stimulus:manifest:update` to register it.
47+
symlink, then `rake stimulus:manifest:update` to register it.
4848
- New JS packages go in `gem/package.json` **and** per-component in
4949
`gem/lib/generators/ruby_ui/dependencies.yml`.
5050
5. **Update docs & tests** in the same PR: `<component>_docs.rb` and

docs/lib/tasks/ruby_ui.rake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ namespace :ruby_ui do
1515
abort "No *_controller.js files found under #{gem_root} - is the gem/ checkout present?"
1616
end
1717

18+
# The docs controllers directory is flat, so two gem controllers sharing a
19+
# basename cannot both be represented - the second symlink would silently
20+
# clobber the first and one component would ship the wrong JS.
21+
collisions = controller_files.group_by { |p| File.basename(p) }.select { |_, paths| paths.size > 1 }
22+
unless collisions.empty?
23+
details = collisions.map { |basename, paths| " #{basename}: #{paths.join(", ")}" }.join("\n")
24+
abort "Duplicate controller basenames found under #{gem_root} - rename one of them:\n#{details}"
25+
end
26+
1827
controller_files.each do |gem_path|
1928
gem_path = Pathname.new(gem_path)
2029
link_path = controllers_dir.join(gem_path.basename)

0 commit comments

Comments
 (0)