Skip to content

feat: shelldocs dev + build — hot-reload watcher and static-site publisher - #8

Merged
Shewart merged 4 commits into
mainfrom
feat/cli-dev-build
Jul 17, 2026
Merged

feat: shelldocs dev + build — hot-reload watcher and static-site publisher#8
Shewart merged 4 commits into
mainfrom
feat/cli-dev-build

Conversation

@Shewart

@Shewart Shewart commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Fills in the two remaining CLI commands: shelldocs dev (thin wrapper around dotnet watch run with markdown in the watch set) and shelldocs build (dotnet publish -c Release + static-hosting post-processing for GH Pages / Cloudflare / S3). Both follow the InitCommand pattern — small orchestrator class per command, wired into Program.cs.

Last CLI feature branch before chore/release-0.1.0-alpha.

What's in it

src/ShellDocs.CLI/Commands/DevCommand.cs

  • Locates the .csproj in --dir (default cwd), errors cleanly if missing.
  • Spawns dotnet watch --project <csproj> --non-interactive run --urls http://localhost:<port> with inherited stdio so the user sees dotnet's output live.
  • Forwards Ctrl+C to the child process tree so shutdown is clean.
  • Returns the child's exit code.

src/ShellDocs.CLI/Commands/BuildCommand.cs

  • Runs dotnet publish -c Release -o obj/shelldocs-publish (scratch dir under the project's obj/).
  • Detects publish shape: if wwwroot/ exists inside the publish output → Blazor WASM (static site). If not → Blazor Server (whole publish dir is the payload, needs a .NET host).
  • Copies the appropriate source to --output, wiping the target first so stale files never linger between builds.
  • Two post-processing flags:
    • --base-href "/my-repo/" — rewrites <base href="..." /> in index.html (needed for GH Pages subpath deployments). Regex handles single-quote, double-quote, and no-quote variants; case-insensitive.
    • --spa-fallback — copies index.html → 404.html so GH Pages returns the SPA shell for unknown paths instead of a real 404 (standard client-routing trick).
  • Prints Spectre summary showing project, output path, kind (static vs server), and the applied post-processing steps.

src/ShellDocs.CLI/Program.cs — swaps both placeholder handlers for real dispatches. Adds --dir on both commands to match init. build gains --base-href and --spa-fallback options.

tests/ShellDocs.Tests/BuildCommandTests.cs — 7 unit tests covering the deterministic post-processing helpers (via reflection since they're internal). Doesn't shell out to dotnet publish — that's an integration surface I verified by hand.

  • RewriteBaseHref — 4 quote-variant cases all rewrite correctly
  • RewriteBaseHref leaves surrounding markup untouched
  • CopyDirectory recursively copies nested files preserving relative paths
  • CopyDirectory overwrites existing files in the destination

Full suite: 85 passing (was 78, +7).

Notes

  • dev doesn't add extra file globs to the watch set directly — dotnet-watch >= 8 already picks up razor + css + js. For markdown watching, the CLI relies on the consumer's csproj declaring <Watch Include="content/**/*.md" /> (something shelldocs init can add in a follow-up). MVP works fine because ShellDocs re-reads markdown files at render time.
  • build uses obj/shelldocs-publish as scratch rather than the default bin/Release/net10.0/publish so we don't collide with a user's own publish artifacts. Cleaned up after the copy either way.
  • Search index generation deferred — the roadmap item mentioned "search stub for now" but there's nothing to stub yet. Adding an empty search-index.json at build time would be dead weight until the runtime consumes it.

Test plan

  • dotnet build shelldocs.slnx — clean
  • dotnet test shelldocs.slnx — 85 passing
  • shelldocs dev --help and shelldocs build --help — options render, defaults correct

Shewart added 4 commits July 17, 2026 17:59
…hting the functionality of the `shelldocs dev` command for hot-reloading and navigation graph rebuilds.
@Shewart
Shewart merged commit ee4039b into main Jul 17, 2026
1 check passed
@Shewart
Shewart deleted the feat/cli-dev-build branch July 20, 2026 20:21
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