Skip to content

Commit

Permalink
add Create-a-Blazor-App.topic
Browse files Browse the repository at this point in the history
  • Loading branch information
phmatray committed Feb 21, 2024
1 parent 712cd3e commit 4a885cf
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 16 deletions.
4 changes: 4 additions & 0 deletions docs/site/Writerside/redirection-rules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@
<accepts>page.html</accepts>
</rule>
-->
<rule id="3afb57b1">
<description>Created after removal of "Tutorials" from MasterCommander</description>
<accepts>Tutorials.html</accepts>
</rule>
</rules>
98 changes: 98 additions & 0 deletions docs/site/Writerside/topics/Create-a-Blazor-App.topic
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic SYSTEM "https://resources.jetbrains.com/writerside/1.0/xhtml-entities.dtd">
<topic xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/topic.v2.xsd"
id="Create-a-Blazor-App" title="Create a Blazor App with MasterCommander">

<title>[WIP] Create a Blazor App with MasterCommander</title>

<chapter id="Overview" title="Overview">
<p>Creating a Blazor app is an exciting and engaging experience. With the help of MasterCommander's <code>InitializeBlazorAppAsync</code> method, you can streamline the process and get started even faster. This documentation outlines how to use this method to create a new Blazor app and configure it for development.</p>
</chapter>

<chapter id="Prerequisites" title="Prerequisites">
<p>Before you begin, ensure you have the following installed:</p>
<list type="decimal">
<li>.NET 8 SDK or later</li>
<li>Git command line tool</li>
<li>Visual Studio Code or another code editor</li>
<li>A modern web browser (Chrome, Firefox, Edge, etc.)</li>
</list>
</chapter>

<chapter id="Process-Description" title="Step-by-Step Process">
<p>The <code>InitializeBlazorAppAsync</code> method automates the creation of a new Blazor app, configures it within a solution, and prepares it for development. It simplifies several steps into a single asynchronous operation, improving developer productivity.</p>
</chapter>

<chapter id="Sequence-Diagram" title="Sequence Diagram">
<p>The following sequence diagram illustrates the process executed by the <code>InitializeBlazorAppAsync</code> method:</p>
<code-block lang="plantuml">
@startuml
actor Developer
participant "MasterCommander API" as API
participant "Git CLI" as Git
participant "Dotnet CLI" as Dotnet
participant "FileSystem" as FS

Developer -> API: Initialize Blazor App Async
API -> FS : Set Working Directory
API -> API: Display Startup Message Async
API -> Git: git init Async
Git -> API: Repo Initialized
API -> Dotnet: dotnet new gitignore Async
API -> Dotnet: dotnet new editorconfig Async
API -> Dotnet: dotnet new nugetconfig Async
API -> Dotnet: dotnet new globaljson\n(SdkVersion = "8.0.101") Async
API -> Dotnet: dotnet new blazorwebassembly\n(OutputName = "BlazorAppDemo") Async
API -> Dotnet: dotnet sln\n(OutputName = "BlazorAppDemo") Async
API -> Dotnet: dotnet sln add "BlazorAppDemo.csproj" Async
API -> Git: git add "*" Async
API -> Git: git commit "Initial commit" Async
API -> Dotnet: dotnet build Async
API -> Dotnet: dotnet build\n(Configuration = "Release") Async
API -> Dotnet: dotnet run\n(Project = "BlazorAppDemo.csproj", Configuration = "Release") Async
API -> FS: Open Browser

note right of API: Asynchronous operations are denoted\nby "Async" for clarity.
note right of API: Open Browser step matches the C# method's action.
@enduml
</code-block>
<p>This diagram provides a visual representation of the interactions between the developer, MasterCommander API, and other components during Blazor app initialization.</p>
</chapter>

<chapter id="Example-Implementation" title="Example Implementation">
<p>The following C# code snippet shows a practical implementation of the <code>InitializeBlazorAppAsync</code> method:</p>
<code-block lang="c#">
public async Task InitializeBlazorAppAsync()
{
SetWorkingDirectory();

console.WriteStartupMessage();

await git.InitAsync();

await dotnet.NewAsync(new DotnetNewGitignoreOptions());
await dotnet.NewAsync(new DotnetNewEditorConfigOptions());
await dotnet.NewAsync(new DotnetNewNuGetConfigOptions());
await dotnet.NewAsync(new DotnetNewGlobalJsonOptions { SdkVersion = SdkVersion });
await dotnet.NewAsync(new DotnetNewBlazorWebAssemblyOptions { OutputName = BlazorAppName });
await dotnet.NewAsync(new DotnetNewSolutionOptions { OutputName = BlazorAppName });
await dotnet.SlnAddAsync(BlazorAppCsproj);

await git.AddAsync("*");
await git.CommitAsync("Initial commit");

await dotnet.BuildAsync();
await dotnet.BuildAsync(new DotnetBuildOptions { Configuration = "Release" });
await dotnet.RunAsync(new DotnetRunOptions { Project = BlazorAppCsproj, Configuration = "Release" });

OpenBrowser();
}
</code-block>
</chapter>

<chapter id="Conclusion-and-Next-Steps" title="Conclusion and Next Steps">
<p>By following the steps outlined in this documentation, you have successfully created a Blazor app using an efficient and streamlined process. Explore further by adding more features to your app or integrating it with other services. Don't forget to check out the <a href="https://docs.microsoft.com/en-us/aspnet/core/blazor/?view=aspnetcore-8.0">official Blazor documentation</a> for more information and best practices.</p>
</chapter>

</topic>
12 changes: 0 additions & 12 deletions docs/site/Writerside/topics/Tutorials.topic

This file was deleted.

7 changes: 3 additions & 4 deletions docs/site/Writerside/web.tree
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
start-page="MasterCommander.topic">

<toc-element topic="MasterCommander.topic">
<toc-element topic="Installing-MasterCommander.topic"/>
<toc-element topic="Overview.topic"/>
</toc-element>
<toc-element topic="Tutorials.topic">
<toc-element topic="Installing-MasterCommander.topic"/>
<toc-element topic="FAQ.topic"/>
</toc-element>
<toc-element topic="How-Tos.topic">
<toc-element topic="Create-a-NET-Console-Project.topic"/>
<toc-element topic="Create-a-Blazor-App.topic"/>
</toc-element>
<toc-element topic="Reference.topic">
<toc-element topic="CliCommandException.ExitCode.topic"/>
</toc-element>
<toc-element topic="FAQ.topic"/>
</instance-profile>

0 comments on commit 4a885cf

Please sign in to comment.