fix(cli): docs command generates fallback URLs when registry has no m…#1782
fix(cli): docs command generates fallback URLs when registry has no m…#1782imlargo wants to merge 5 commits intounovue:devfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI Command
participant Registry as Registry Metadata
participant Docs as Docs Host (SHADCN_VUE_URL)
CLI->>Registry: read item.meta?.links[base]
alt links exist
CLI->>CLI: use metaLinks.docs
else links missing/empty
CLI->>Docs: construct fallback URL {SHADCN_VUE_URL}/docs/components/{component}
CLI->>CLI: log debug (include base) and include fallback link
end
CLI->>CLI: add component to results
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/cli/src/commands/docs.ts (1)
65-67: Fallback URL ignoresbaseand doesn't validate existence.The fallback hard-codes
/docs/components/${component}regardless of the resolvedbase. This is acceptable today since onlyrekaships (per the comment on line 29-30), but if additional bases are introduced later the fallback will silently emit links that don't reflect the selected base. Also note that the generated URL is not verified against the docs site, so users may be pointed to a 404 when a component lacks a dedicated docs page. Consider either namespacing the fallback bybasewhen multi-base support lands, or logging a debug/info note that the link is a best-effort fallback.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/docs.ts` around lines 65 - 67, The fallback link assignment for links currently hard-codes `${SHADCN_VUE_URL}/docs/components/${component}` and ignores the selected base; update the fallback to incorporate the resolved base (use the existing base variable) e.g. `${SHADCN_VUE_URL}/${base}/docs/components/${component}` (or otherwise namespace by base) when metaLinks is empty, and add a lightweight existence check (HEAD/GET) against the constructed URL or emit a debug/info log stating the URL is a best-effort fallback if the check fails; update the code that computes links (the metaLinks/links branch) and use existing logging utilities to report when the fallback is used or when the URL resolves to 404.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/cli/src/commands/docs.ts`:
- Around line 65-67: The fallback link assignment for links currently hard-codes
`${SHADCN_VUE_URL}/docs/components/${component}` and ignores the selected base;
update the fallback to incorporate the resolved base (use the existing base
variable) e.g. `${SHADCN_VUE_URL}/${base}/docs/components/${component}` (or
otherwise namespace by base) when metaLinks is empty, and add a lightweight
existence check (HEAD/GET) against the constructed URL or emit a debug/info log
stating the URL is a best-effort fallback if the check fails; update the code
that computes links (the metaLinks/links branch) and use existing logging
utilities to report when the fallback is used or when the URL resolves to 404.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 81ce645c-85f2-41b0-abd9-cb8d0c9e2403
📒 Files selected for processing (1)
packages/cli/src/commands/docs.ts
…used Agent-Logs-Url: https://github.com/imlargo/shadcn-vue/sessions/84958647-5953-486a-95da-026ffc97efe0 Co-authored-by: imlargo <134282467+imlargo@users.noreply.github.com>
…nment fix(docs): incorporate base in fallback URL and add debug log
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/cli/src/commands/docs.ts (1)
71-73: Considerlogger.warninstead oflogger.debugfor the fallback notice.Since the fallback is best-effort and may point to a non-existent page, users running the command at default log level will see a link without any indication it was synthesized. A
warn(or at leastinfo) would make the degraded behavior visible;debugeffectively hides it unless the user opts in.Proposed change
- logger.debug( + logger.warn( `No registry links found for ${highlighter.info(component)} (base: ${highlighter.info(base)}). Using best-effort fallback: ${fallbackUrl}`, )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/docs.ts` around lines 71 - 73, The log currently uses logger.debug when falling back to a synthesized registry link in the docs command (see the logger.debug call that references highlighter.info(component), highlighter.info(base) and fallbackUrl); change this to logger.warn (or logger.info) so the fallback is visible at default log levels, and update the message to clearly indicate the link is a best-effort/synthesized fallback (e.g., include the word "fallback" or "synthesized" in the message) while keeping the same context variables (component, base, fallbackUrl).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/cli/src/commands/docs.ts`:
- Around line 70-74: The fallback URL built in the docs command includes an
extra `${base}/` path segment causing 404s; update the construction of
fallbackUrl (used where SHADCN_VUE_URL is combined, referenced along with
logger.debug and assigned into links) to omit the `${base}/` segment so it
becomes SHADCN_VUE_URL + "/docs/components/" + component, and keep the existing
debug message and assignment to links = { docs: fallbackUrl } intact.
---
Nitpick comments:
In `@packages/cli/src/commands/docs.ts`:
- Around line 71-73: The log currently uses logger.debug when falling back to a
synthesized registry link in the docs command (see the logger.debug call that
references highlighter.info(component), highlighter.info(base) and fallbackUrl);
change this to logger.warn (or logger.info) so the fallback is visible at
default log levels, and update the message to clearly indicate the link is a
best-effort/synthesized fallback (e.g., include the word "fallback" or
"synthesized" in the message) while keeping the same context variables
(component, base, fallbackUrl).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: aa59e47a-8f19-4f67-8e08-c31beea8eaea
📒 Files selected for processing (1)
packages/cli/src/commands/docs.ts
The fallback URL was constructed as `${SHADCN_VUE_URL}/${base}/docs/components/${component}`
which produced URLs like `https://shadcn-vue.com/reka/docs/components/button`,
causing 404s. The correct URL pattern (matching all other docs links in the
codebase) is `https://shadcn-vue.com/docs/components/{component}`.
Agent-Logs-Url: https://github.com/imlargo/shadcn-vue/sessions/94840a9e-97bf-4ae1-8d83-0c93e3f07445
…uction fix(cli): remove extra base path segment from docs fallback URL
…eta.links
Agent-Logs-Url: https://github.com/imlargo/shadcn-vue/sessions/2ca0afaa-c518-4e5c-a1fe-1147f5797092
🔗 Linked issue
❓ Type of change
📚 Description
📸 Screenshots (if appropriate)
📝 Checklist
Summary by CodeRabbit