-
-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add blazor wasm standalone demo (#9506) #9507
base: develop
Are you sure you want to change the base?
Conversation
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe pull request introduces several enhancements across the project's infrastructure and configuration. A new GitHub Actions workflow job is added for deploying a Blazor WebAssembly standalone application to Azure Static Web Apps. The README.md is updated with more detailed information about the bitplatform toolkit and its tools. The service worker script has been modified to adjust asset exclusions, and the server-side configuration now includes more flexible CORS (Cross-Origin Resource Sharing) settings. These changes primarily focus on improving deployment processes, documentation, and configuration flexibility. Changes
Sequence DiagramsequenceDiagram
participant GHA as GitHub Actions
participant Build as Build Process
participant Azure as Azure Static Web Apps
GHA->>Build: Trigger Blazor WASM build
Build->>Build: Set up .NET environment
Build->>Build: Publish project
Build->>Azure: Deploy application
Azure-->>Build: Deployment confirmation
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (2)
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/ServerApiSettings.cs (1)
163-166
: Add XML documentation for the new CORS configuration.The new CORS configuration classes lack documentation explaining their purpose and usage.
Add documentation:
+/// <summary> +/// Configuration options for Cross-Origin Resource Sharing (CORS). +/// </summary> public class CorsOptions { + /// <summary> + /// Array of allowed origin URLs that may access the API. + /// </summary> public string[] AllowedOrigins { get; set; } = []; }.github/workflows/admin-sample.cd.yml (1)
77-114
: Fix YAML formatting issuesThere are several formatting inconsistencies in the file:
- Remove trailing spaces (lines 77, 80, 92, 94, 108, 111, 114)
- Fix spacing after colon (line 110)
🧰 Tools
🪛 yamllint (1.35.1)
[error] 77-77: trailing spaces
(trailing-spaces)
[error] 80-80: trailing spaces
(trailing-spaces)
[error] 92-92: trailing spaces
(trailing-spaces)
[error] 94-94: trailing spaces
(trailing-spaces)
[error] 108-108: trailing spaces
(trailing-spaces)
[warning] 110-110: too many spaces after colon
(colons)
[error] 111-111: trailing spaces
(trailing-spaces)
[error] 114-114: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
.github/workflows/admin-sample.cd.yml
(1 hunks)README.md
(1 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Web/wwwroot/service-worker.published.js
(1 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Program.Services.cs
(1 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/ServerApiSettings.cs
(2 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/admin-sample.cd.yml
[error] 77-77: trailing spaces
(trailing-spaces)
[error] 80-80: trailing spaces
(trailing-spaces)
[error] 92-92: trailing spaces
(trailing-spaces)
[error] 94-94: trailing spaces
(trailing-spaces)
[error] 108-108: trailing spaces
(trailing-spaces)
[warning] 110-110: too many spaces after colon
(colons)
[error] 111-111: trailing spaces
(trailing-spaces)
[error] 114-114: trailing spaces
(trailing-spaces)
🔇 Additional comments (2)
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Web/wwwroot/service-worker.published.js (1)
30-30
: LGTM: PDF.js worker exclusion is consistent with main file.
The addition of pdfjs-4.7.76-worker.js
to the exclusion list is consistent with the existing exclusion of the main PDF.js file. This ensures proper dynamic loading of PDF.js components.
Let's verify the PDF.js file versions are consistent:
✅ Verification successful
Based on the search results, I can verify that:
-
The PDF.js files exist in the codebase at consistent versions:
- src/BlazorUI/Bit.BlazorUI.Extras/wwwroot/pdf.js/pdfjs-4.7.76.js
- src/BlazorUI/Bit.BlazorUI.Extras/wwwroot/pdf.js/pdfjs-4.7.76-worker.js
-
The service worker exclusion list correctly includes both files:
- /pdfjs-4.7.76.js$/
- /pdfjs-4.7.76-worker.js$/
LGTM: PDF.js worker exclusion matches main file version (4.7.76)
The service worker configuration properly excludes both the main PDF.js file and its worker script with matching version numbers (4.7.76), ensuring consistent dynamic loading behavior.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify PDF.js files exist and have matching versions
rg -g "*.js" "pdfjs-4\.7\.76"
Length of output: 31
Script:
#!/bin/bash
# Let's try a broader search for PDF.js related files and patterns
rg -g "*.js" "pdfjs-" -A 2
Length of output: 66095
Script:
#!/bin/bash
# Search for any PDF.js related files in the codebase
fd "pdfjs"
Length of output: 145
Script:
#!/bin/bash
# Check service worker configuration for PDF related exclusions
rg -g "*.js" "pdf.*worker" -A 2
Length of output: 65963
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Program.Services.cs (1)
127-135
: LGTM! Well-implemented CORS configuration
The changes enhance CORS configuration flexibility by:
- Supporting configurable allowed origins through settings
- Maintaining existing security checks
- Using case-insensitive comparisons for origin validation
public CorsOptions? Cors { get; set; } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add validation for CORS configuration.
The new Cors property lacks validation in the Validate method. Consider adding validation to ensure AllowedOrigins is properly configured when CORS is enabled.
Add this to the Validate method:
if (ForwardedHeaders is not null)
{
Validator.TryValidateObject(ForwardedHeaders, new ValidationContext(ForwardedHeaders), validationResults, true);
}
+if (Cors is not null)
+{
+ if (Cors.AllowedOrigins.Length == 0)
+ {
+ validationResults.Add(new ValidationResult("AllowedOrigins must not be empty when CORS is configured.", new[] { nameof(Cors) }));
+ }
+ Validator.TryValidateObject(Cors, new ValidationContext(Cors), validationResults, true);
+}
Committable suggestion skipped: line range outside the PR's diff.
README.md
Outdated
5. [adminpanel.bitplatform.dev](https://adminpanel.bitplatform.dev): .NET 9 PWA with Blazor WebAssembly | ||
5. [adminpanel.bitplatform.dev](https://adminpanel.bitplatform.dev): .NET 9 PWA with Blazor WebAssembly | ||
6. [adminpanel.bitplatform.cc](https://adminpanel.bitplatform.cc): .NET 9 PWA with Blazor WebAssembly Standalone (Free Azure static web app) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove duplicate entries for adminpanel.bitplatform.dev.
There are three identical entries for the admin panel URL, which appears to be a documentation error.
Keep only one entry and fix the numbering:
4. [todo.bitplatform.dev](https://todo.bitplatform.dev): .NET 8 Pre-rendered PWA with Blazor WebAssembly
-5. [adminpanel.bitplatform.dev](https://adminpanel.bitplatform.dev): .NET 9 PWA with Blazor WebAssembly
-5. [adminpanel.bitplatform.dev](https://adminpanel.bitplatform.dev): .NET 9 PWA with Blazor WebAssembly
-6. [adminpanel.bitplatform.cc](https://adminpanel.bitplatform.cc): .NET 9 PWA with Blazor WebAssembly Standalone (Free Azure static web app)
+5. [adminpanel.bitplatform.cc](https://adminpanel.bitplatform.cc): .NET 9 PWA with Blazor WebAssembly Standalone (Free Azure static web app)
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
5. [adminpanel.bitplatform.dev](https://adminpanel.bitplatform.dev): .NET 9 PWA with Blazor WebAssembly | |
5. [adminpanel.bitplatform.dev](https://adminpanel.bitplatform.dev): .NET 9 PWA with Blazor WebAssembly | |
6. [adminpanel.bitplatform.cc](https://adminpanel.bitplatform.cc): .NET 9 PWA with Blazor WebAssembly Standalone (Free Azure static web app) | |
4. [todo.bitplatform.dev](https://todo.bitplatform.dev): .NET 8 Pre-rendered PWA with Blazor WebAssembly | |
5. [adminpanel.bitplatform.cc](https://adminpanel.bitplatform.cc): .NET 9 PWA with Blazor WebAssembly Standalone (Free Azure static web app) |
cd src/Templates/Boilerplate && dotnet build -c Release | ||
dotnet pack -c Release -o . -p:ReleaseVersion=0.0.0 -p:PackageVersion=0.0.0 | ||
dotnet new install Bit.Boilerplate.0.0.0.nupkg | ||
cd ../../../ && dotnet new bit-bp --name AdminPanel --database PostgreSQL --sample Admin --appInsights --sentry --serverUrl https://adminpanel.bitplatform.cc --filesStorage AzureBlobStorage --notification --captcha reCaptcha --signalR --framework net9.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use environment variable for server URL instead of hardcoding
The server URL is hardcoded to "https://adminpanel.bitplatform.cc" while other jobs use the ${{ env.SERVER_ADDRESS }}
environment variable.
Apply this diff to maintain consistency:
- cd ../../../ && dotnet new bit-bp --name AdminPanel --database PostgreSQL --sample Admin --appInsights --sentry --serverUrl https://adminpanel.bitplatform.cc --filesStorage AzureBlobStorage --notification --captcha reCaptcha --signalR --framework net9.0
+ cd ../../../ && dotnet new bit-bp --name AdminPanel --database PostgreSQL --sample Admin --appInsights --sentry --serverUrl ${{ env.SERVER_ADDRESS }} --filesStorage AzureBlobStorage --notification --captcha reCaptcha --signalR --framework net9.0
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
cd ../../../ && dotnet new bit-bp --name AdminPanel --database PostgreSQL --sample Admin --appInsights --sentry --serverUrl https://adminpanel.bitplatform.cc --filesStorage AzureBlobStorage --notification --captcha reCaptcha --signalR --framework net9.0 | |
cd ../../../ && dotnet new bit-bp --name AdminPanel --database PostgreSQL --sample Admin --appInsights --sentry --serverUrl ${{ env.SERVER_ADDRESS }} --filesStorage AzureBlobStorage --notification --captcha reCaptcha --signalR --framework net9.0 |
deploy_blazor_wasm_standalone: | ||
name: build blazor wasm standalone | ||
runs-on: ubuntu-24.04 | ||
|
||
steps: | ||
|
||
- name: Checkout source code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
global-json-file: src/global.json | ||
|
||
- name: Create project from Boilerplate | ||
run: | | ||
cd src/Templates/Boilerplate && dotnet build -c Release | ||
dotnet pack -c Release -o . -p:ReleaseVersion=0.0.0 -p:PackageVersion=0.0.0 | ||
dotnet new install Bit.Boilerplate.0.0.0.nupkg | ||
cd ../../../ && dotnet new bit-bp --name AdminPanel --database PostgreSQL --sample Admin --appInsights --sentry --serverUrl https://adminpanel.bitplatform.cc --filesStorage AzureBlobStorage --notification --captcha reCaptcha --signalR --framework net9.0 | ||
|
||
- name: Update core appsettings.json | ||
uses: devops-actions/variable-substitution@v1.2 | ||
with: | ||
files: 'AdminPanel/src/Shared/appsettings.json, AdminPanel/src/Client/AdminPanel.Client.Core/appsettings.json, AdminPanel/src/Client/AdminPanel.Client.Web/appsettings.json, AdminPanel/src/Client/AdminPanel.Client.Web/appsettings.Production.json' | ||
env: | ||
WebAppRender.BlazorMode: BlazorWebAssembly | ||
ServerAddress: ${{ env.SERVER_ADDRESS }} | ||
Logging.Sentry.Dsn: ${{ secrets.ADMINPANEL_SENTRY_DSN }} | ||
GoogleRecaptchaSiteKey: ${{ secrets.GOOGLE_RECAPTCHA_SITE_KEY }} | ||
AdsPushVapid.PublicKey: ${{ secrets.ADMINPANEL_PUBLIC_VAPIDKEY }} | ||
ApplicationInsights.ConnectionString: ${{ secrets.APPLICATION_INSIGHTS_CONNECTION_STRING }} | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 22 | ||
|
||
- name: Install wasm | ||
run: cd src && dotnet workload install wasm-tools | ||
|
||
- name: Generate CSS/JS files | ||
run: dotnet build AdminPanel/src/Client/AdminPanel.Client.Core/AdminPanel.Client.Core.csproj -t:BeforeBuildTasks -p:Version="${{ vars.APPLICATION_DISPLAY_VERSION}}" --no-restore -c Release | ||
|
||
- name: Publish | ||
run: dotnet publish AdminPanel/src/Client/AdminPanel.Client.Web/AdminPanel.Client.Web.csproj -c Release -p:PwaEnabled=true -o ${{env.DOTNET_ROOT}}/client -p:Version="${{ vars.APPLICATION_DISPLAY_VERSION}}" | ||
|
||
- name: Upload to asw | ||
run: | | ||
npm install -g @azure/static-web-apps-cli | ||
swa deploy --deployment-token ${{ secrets.ADMINPANEL_ASW_TOKEN }} --env production --app-location ${{env.DOTNET_ROOT}}/client/wwwroot | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider adding environment configuration for production deployment
The job deploys directly to production without an environment configuration, unlike the deploy_api_blazor
job which has proper environment settings.
Add environment configuration to ensure proper deployment control:
deploy_blazor_wasm_standalone:
name: build blazor wasm standalone
runs-on: ubuntu-24.04
+ environment:
+ name: 'production'
+ url: https://adminpanel-wasm.bitplatform.dev
steps:
# ... existing steps ...
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
deploy_blazor_wasm_standalone: | |
name: build blazor wasm standalone | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
global-json-file: src/global.json | |
- name: Create project from Boilerplate | |
run: | | |
cd src/Templates/Boilerplate && dotnet build -c Release | |
dotnet pack -c Release -o . -p:ReleaseVersion=0.0.0 -p:PackageVersion=0.0.0 | |
dotnet new install Bit.Boilerplate.0.0.0.nupkg | |
cd ../../../ && dotnet new bit-bp --name AdminPanel --database PostgreSQL --sample Admin --appInsights --sentry --serverUrl https://adminpanel.bitplatform.cc --filesStorage AzureBlobStorage --notification --captcha reCaptcha --signalR --framework net9.0 | |
- name: Update core appsettings.json | |
uses: devops-actions/variable-substitution@v1.2 | |
with: | |
files: 'AdminPanel/src/Shared/appsettings.json, AdminPanel/src/Client/AdminPanel.Client.Core/appsettings.json, AdminPanel/src/Client/AdminPanel.Client.Web/appsettings.json, AdminPanel/src/Client/AdminPanel.Client.Web/appsettings.Production.json' | |
env: | |
WebAppRender.BlazorMode: BlazorWebAssembly | |
ServerAddress: ${{ env.SERVER_ADDRESS }} | |
Logging.Sentry.Dsn: ${{ secrets.ADMINPANEL_SENTRY_DSN }} | |
GoogleRecaptchaSiteKey: ${{ secrets.GOOGLE_RECAPTCHA_SITE_KEY }} | |
AdsPushVapid.PublicKey: ${{ secrets.ADMINPANEL_PUBLIC_VAPIDKEY }} | |
ApplicationInsights.ConnectionString: ${{ secrets.APPLICATION_INSIGHTS_CONNECTION_STRING }} | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
- name: Install wasm | |
run: cd src && dotnet workload install wasm-tools | |
- name: Generate CSS/JS files | |
run: dotnet build AdminPanel/src/Client/AdminPanel.Client.Core/AdminPanel.Client.Core.csproj -t:BeforeBuildTasks -p:Version="${{ vars.APPLICATION_DISPLAY_VERSION}}" --no-restore -c Release | |
- name: Publish | |
run: dotnet publish AdminPanel/src/Client/AdminPanel.Client.Web/AdminPanel.Client.Web.csproj -c Release -p:PwaEnabled=true -o ${{env.DOTNET_ROOT}}/client -p:Version="${{ vars.APPLICATION_DISPLAY_VERSION}}" | |
- name: Upload to asw | |
run: | | |
npm install -g @azure/static-web-apps-cli | |
swa deploy --deployment-token ${{ secrets.ADMINPANEL_ASW_TOKEN }} --env production --app-location ${{env.DOTNET_ROOT}}/client/wwwroot | |
deploy_blazor_wasm_standalone: | |
name: build blazor wasm standalone | |
runs-on: ubuntu-24.04 | |
environment: | |
name: 'production' | |
url: https://adminpanel-wasm.bitplatform.dev | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
global-json-file: src/global.json | |
- name: Create project from Boilerplate | |
run: | | |
cd src/Templates/Boilerplate && dotnet build -c Release | |
dotnet pack -c Release -o . -p:ReleaseVersion=0.0.0 -p:PackageVersion=0.0.0 | |
dotnet new install Bit.Boilerplate.0.0.0.nupkg | |
cd ../../../ && dotnet new bit-bp --name AdminPanel --database PostgreSQL --sample Admin --appInsights --sentry --serverUrl https://adminpanel.bitplatform.cc --filesStorage AzureBlobStorage --notification --captcha reCaptcha --signalR --framework net9.0 | |
- name: Update core appsettings.json | |
uses: devops-actions/variable-substitution@v1.2 | |
with: | |
files: 'AdminPanel/src/Shared/appsettings.json, AdminPanel/src/Client/AdminPanel.Client.Core/appsettings.json, AdminPanel/src/Client/AdminPanel.Client.Web/appsettings.json, AdminPanel/src/Client/AdminPanel.Client.Web/appsettings.Production.json' | |
env: | |
WebAppRender.BlazorMode: BlazorWebAssembly | |
ServerAddress: ${{ env.SERVER_ADDRESS }} | |
Logging.Sentry.Dsn: ${{ secrets.ADMINPANEL_SENTRY_DSN }} | |
GoogleRecaptchaSiteKey: ${{ secrets.GOOGLE_RECAPTCHA_SITE_KEY }} | |
AdsPushVapid.PublicKey: ${{ secrets.ADMINPANEL_PUBLIC_VAPIDKEY }} | |
ApplicationInsights.ConnectionString: ${{ secrets.APPLICATION_INSIGHTS_CONNECTION_STRING }} | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
- name: Install wasm | |
run: cd src && dotnet workload install wasm-tools | |
- name: Generate CSS/JS files | |
run: dotnet build AdminPanel/src/Client/AdminPanel.Client.Core/AdminPanel.Client.Core.csproj -t:BeforeBuildTasks -p:Version="${{ vars.APPLICATION_DISPLAY_VERSION}}" --no-restore -c Release | |
- name: Publish | |
run: dotnet publish AdminPanel/src/Client/AdminPanel.Client.Web/AdminPanel.Client.Web.csproj -c Release -p:PwaEnabled=true -o ${{env.DOTNET_ROOT}}/client -p:Version="${{ vars.APPLICATION_DISPLAY_VERSION}}" | |
- name: Upload to asw | |
run: | | |
npm install -g @azure/static-web-apps-cli | |
swa deploy --deployment-token ${{ secrets.ADMINPANEL_ASW_TOKEN }} --env production --app-location ${{env.DOTNET_ROOT}}/client/wwwroot |
🧰 Tools
🪛 yamllint (1.35.1)
[error] 77-77: trailing spaces
(trailing-spaces)
[error] 80-80: trailing spaces
(trailing-spaces)
[error] 92-92: trailing spaces
(trailing-spaces)
[error] 94-94: trailing spaces
(trailing-spaces)
[error] 108-108: trailing spaces
(trailing-spaces)
[warning] 110-110: too many spaces after colon
(colons)
[error] 111-111: trailing spaces
(trailing-spaces)
[error] 114-114: trailing spaces
(trailing-spaces)
closes #9506
Summary by CodeRabbit
New Features
Documentation
Bug Fixes