Skip to content

feat(appkit-docs): sync via shallow git clone at build time#58

Open
pkosiec wants to merge 6 commits intomainfrom
pkosiec/appkit-docs-sync
Open

feat(appkit-docs): sync via shallow git clone at build time#58
pkosiec wants to merge 6 commits intomainfrom
pkosiec/appkit-docs-sync

Conversation

@pkosiec
Copy link
Copy Markdown
Member

@pkosiec pkosiec commented Apr 23, 2026

Summary

Replace committed AppKit docs, examples, and compiled styles with build-time sync from the appkit repo.

How it works

scripts/sync-appkit-docs.mjs runs automatically via prebuild/prestart hooks on first build or dev start:

  1. Shallow-clones appkit main (sparse checkout) into a temp dir
  2. Copies docs to docs/appkit/latest/, examples to src/components/doc-examples/, compiles styles to static/appkit-preview/latest/
  3. Skips on subsequent runs if all outputs exist; npm run sync:appkit-docs to force re-sync

All generated paths are gitignored. Override clone source via APPKIT_REMOTE / APPKIT_BRANCH env vars.

The script and sidebar are ready for doc versioning — when appkit ships versioned_docs/, they'll be picked up automatically as version-*/ channels alongside latest.

Other changes

  • .prettierrc to pin 2-space indent (Prettier 3.8 defaults to tabs for JSON)
  • Explicit sync step added to CI workflow

Design note

Live <DocExample> previews are tied to the single installed @databricks/appkit-ui package, since npm supports only one version at a time. When multiple doc versions ship, older versions will show code blocks only — no live preview.

Known limitations

  • @databricks/appkit-ui version is pinned manually. Docs and examples sync from appkit main, but the npm package used for live component rendering is pinned in package.json. These can drift. Once @databricks/appkit-ui is allowlisted on the npm proxy, the sync script should auto-update the dep to match the cloned version.

Test plan

  • Delete generated dirs, npm run build — syncs and builds
  • npm run build again — skips, no network call
  • npm run sync:appkit-docs — force re-sync works
  • Sidebar shows "latest", .source-ref has SHA + date

Screenshot

Screenshot 2026-04-24 at 12 12 51

pkosiec added 4 commits April 24, 2026 10:56
Replace the manual tarball-based AppKit docs sync with a shallow git
clone of the main branch that runs automatically as a prebuild step.
Docs are now generated at build time instead of being committed to git.

Key changes:
- Rewrite sync-appkit-docs.mjs to clone from main with sparse checkout
- Output docs to docs/appkit/latest/ (instead of v0/)
- Skip with informational log when docs already exist locally
- Support future Docusaurus versioned_docs if AppKit adopts versioning
- Add prebuild/prestart lifecycle hooks for automatic sync
- Update sidebar to discover latest/ and version-* directories
- Add generated paths to .gitignore and .prettierignore
- Add explicit sync step to CI workflow

Co-authored-by: Isaac
…nvention

- Update DocExample styles href from v0 to latest
- Rewrite getAppKitChannelOptions to deduplicate by channel path segment
- Hide VERSION dropdown when only one channel exists (> 1 check)

Co-authored-by: Isaac
- Fix stale error message referencing removed `v0` argument in DocExample
- Harden isAlreadySynced() to check all 3 outputs (docs, examples, styles)
- Wrap temp directory in try/finally so it's cleaned up on failure
- Change fail() to throw so cleanup runs before exit
- Add 2-minute timeout to spawned git commands
- Remove unnecessary appKitItems alias in sidebars

Co-authored-by: Isaac
Prettier 3.8 changed the default for JSON to tabs. Pin useTabs: false
and tabWidth: 2 to maintain consistent formatting across the repo.

Co-authored-by: Isaac
@pkosiec pkosiec force-pushed the pkosiec/appkit-docs-sync branch from 403810e to 11b85e7 Compare April 24, 2026 09:12
Allow overriding the appkit git remote URL and branch via environment
variables. Defaults remain unchanged (github.com/databricks/appkit, main).

This enables CI pipelines in the appkit repo to validate that docs
changes on a PR branch don't break the devhub build, and supports
forks where the remote URL differs.

Co-authored-by: Isaac
- Validate APPKIT_BRANCH and APPKIT_REMOTE before passing to git clone
  to prevent flag injection (e.g. --upload-pack=/bin/sh).
- Replace SIGTERM-only checks with generic signal check in run() and
  runCapture() to catch SIGKILL, SIGSEGV, etc.

Co-authored-by: Isaac
@pkosiec pkosiec marked this pull request as ready for review April 24, 2026 11:37
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