Skip to content

feat: stamp component source with docs-page signature#77

Merged
starc007 merged 1 commit into
mainfrom
feat/code-signature
Jun 28, 2026
Merged

feat: stamp component source with docs-page signature#77
starc007 merged 1 commit into
mainfrom
feat/code-signature

Conversation

@starc007

Copy link
Copy Markdown
Owner

What

Adds a one-line provenance comment to component source — both when copied from the docs and when installed via the registry — so the origin travels with the code:

"use client";
// beui.dev/components/motion/tabs
import ...

Plus centralizes the site domain behind an env var.

Signature

  • lib/signature.ts
    • withSignature(content, path, pageUrl) — inserts the banner after any use client/use server directive, else at the top. Picks // vs /* */ by extension. No-ops non-code files (json, etc.).
    • pageUrlFor(category, slug) — the docs page URL.
  • Applied to the component's own source files only (not shared util/lib deps):
    • InstallbuildEntry + buildShadcnItem in lib/registry-server.ts
    • Copy — source tab on the component page (ExampleBlock + DefaultTabs). Usage/preview tabs unchanged, matching what installs ship.

Domain from env

  • lib/site.tsSITE_URL = NEXT_PUBLIC_SITE_URL ?? "https://beui.dev" (trailing slash stripped).
  • Reused in registry-server, robots, sitemap, and layout metadataBase (previously hardcoded https://beui.dev in each).
  • NEXT_PUBLIC_SITE_URL is optional; the fallback keeps prod working. Set it for non-prod envs to self-reference.

Verification

  • bun run typecheck clean
  • bun run check:registry validates 35 components
  • bun run lint clean (one pre-existing warning in install-command.tsx, unrelated)

Add a one-line provenance comment to component source on copy and on
registry install so the origin travels with the code.

- lib/signature.ts: withSignature inserts `// <domain>/components/<cat>/<slug>`
  after any use client/use server directive; picks // or /* */ by extension;
  no-ops non-code files
- lib/site.ts: SITE_URL from NEXT_PUBLIC_SITE_URL with beui.dev fallback;
  reused across registry-server, robots, sitemap and layout metadataBase
- registry-server: signs the component's own files only (not shared deps)
- component page: signs the source tab so copied code matches installs
@starc007 starc007 merged commit 17721ea into main Jun 28, 2026
2 checks passed
@starc007 starc007 deleted the feat/code-signature branch June 28, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant