feat: shelldocs dev + build — hot-reload watcher and static-site publisher - #8
Merged
Conversation
…ocs projects with dotnet
…uild command functionality
…hting the functionality of the `shelldocs dev` command for hot-reloading and navigation graph rebuilds.
…eBaseHref and CopyDirectory methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fills in the two remaining CLI commands:
shelldocs dev(thin wrapper arounddotnet watch runwith markdown in the watch set) andshelldocs build(dotnet publish -c Release+ static-hosting post-processing for GH Pages / Cloudflare / S3). Both follow theInitCommandpattern — small orchestrator class per command, wired intoProgram.cs.Last CLI feature branch before
chore/release-0.1.0-alpha.What's in it
src/ShellDocs.CLI/Commands/DevCommand.cs--dir(default cwd), errors cleanly if missing.dotnet watch --project <csproj> --non-interactive run --urls http://localhost:<port>with inherited stdio so the user sees dotnet's output live.Ctrl+Cto the child process tree so shutdown is clean.src/ShellDocs.CLI/Commands/BuildCommand.csdotnet publish -c Release -o obj/shelldocs-publish(scratch dir under the project'sobj/).wwwroot/exists inside the publish output → Blazor WASM (static site). If not → Blazor Server (whole publish dir is the payload, needs a .NET host).--output, wiping the target first so stale files never linger between builds.--base-href "/my-repo/"— rewrites<base href="..." />inindex.html(needed for GH Pages subpath deployments). Regex handles single-quote, double-quote, and no-quote variants; case-insensitive.--spa-fallback— copiesindex.html → 404.htmlso GH Pages returns the SPA shell for unknown paths instead of a real 404 (standard client-routing trick).src/ShellDocs.CLI/Program.cs— swaps both placeholder handlers for real dispatches. Adds--diron both commands to matchinit.buildgains--base-hrefand--spa-fallbackoptions.tests/ShellDocs.Tests/BuildCommandTests.cs— 7 unit tests covering the deterministic post-processing helpers (via reflection since they're internal). Doesn't shell out todotnet publish— that's an integration surface I verified by hand.RewriteBaseHref— 4 quote-variant cases all rewrite correctlyRewriteBaseHrefleaves surrounding markup untouchedCopyDirectoryrecursively copies nested files preserving relative pathsCopyDirectoryoverwrites existing files in the destinationFull suite: 85 passing (was 78, +7).
Notes
devdoesn'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" />(somethingshelldocs initcan add in a follow-up). MVP works fine because ShellDocs re-reads markdown files at render time.buildusesobj/shelldocs-publishas scratch rather than the defaultbin/Release/net10.0/publishso we don't collide with a user's own publish artifacts. Cleaned up after the copy either way.search-index.jsonat build time would be dead weight until the runtime consumes it.Test plan
dotnet build shelldocs.slnx— cleandotnet test shelldocs.slnx— 85 passingshelldocs dev --helpandshelldocs build --help— options render, defaults correct