feat: shelldocs init - scaffold ShellDocs into a Blazor project - #7
Merged
Conversation
…s with ShellDocs scaffolding and package references
…emplates and setup instructions
…e `shelldocs init` command functionality for Blazor WASM projects
…Blazor project scaffolding and idempotency
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
Implements the first real CLI command:
shelldocs init. Detects a Blazor project in the target directory, addsShellDocs.Components+ShellDocs.Tokenspackage references, drops incontent/docs/starter markdown + a routedDocsPage.razor, and writes aSHELLDOCS_SETUP.mdwith copy-paste snippets forProgram.csandApp.razor. Idempotent — every write is skip-if-present.What's in it
src/ShellDocs.Templates/ScaffoldTemplates.cs— raw-string constants for everything the CLI emits:introduction.md,meta.json,DocsPage.razor, and a parameterisedSHELLDOCS_SETUP.md(takessiteName+githubRepo). Zero I/O beyond the string constants — the templates ARE the payload.src/ShellDocs.CLI/Commands/InitCommand.cs— the orchestrator:.csprojin--dir(default cwd), errors cleanly if missing.Microsoft.NET.Sdk.Web/Microsoft.NET.Sdk.Razor/Microsoft.NET.Sdk.BlazorWebAssemblySDK, or anAspNetCore.Componentspackage reference). Errors if not.ShellDocs.Components+ShellDocs.Tokenspackage refs — inserts into an existing<ItemGroup>that already holdsPackageReferences if possible, else appends a new<ItemGroup>before</Project>. Regex-guarded so it never duplicates.content/docs/exists, writesintroduction.md+meta.jsonif missing.Components/Pages(modern Blazor Web App), falls back toPages(classic Server / WASM). CreatesComponents/Pagesif neither exists. WritesDocsPage.razorif missing.SHELLDOCS_SETUP.mdat the project root with the exactProgram.csandApp.razorsnippets to paste. Deliberately doesn't patch those files directly — users'Program.cses have auth, custom middleware, etc. we can't safely rewrite around.--yesis passed (which also silently accepts non-TTY stdin).src/ShellDocs.CLI/Program.cs— swaps the placeholder init handler forInitCommand.Run(dir, yes, theme). Added a--diroption (defaults to cwd).tests/ShellDocs.Tests/InitCommandTests.cs— 7 integration tests. Each spins up a temp dir with a minimal Blazor csproj, invokesInitCommand.Runvia reflection, and asserts the outcome. Covers:Pages/whenComponents/Pages/doesn't exist andPages/doesTest project now
ProjectReferencesShellDocs.CLIfor reflection access. Full suite: 78 passing (was 71, +7).Smoke test (verified locally)