Skip to content

Commit

Permalink
feat: update to bit 8.7.4 #43 (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmoradi authored Jan 23, 2024
1 parent 62a77ea commit ebc571f
Show file tree
Hide file tree
Showing 37 changed files with 382 additions and 98 deletions.
77 changes: 25 additions & 52 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ permissions:
jobs:

build_api_blazor:
name: build api + blazor
name: build api + blazor web
runs-on: ubuntu-22.04

steps:
Expand Down Expand Up @@ -132,7 +132,7 @@ jobs:

- name: Checkout source code
uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
Expand All @@ -145,24 +145,37 @@ jobs:
- name: Update appsettings.json api server address
uses: microsoft/variable-substitution@v1
with:
files: 'src/Client/Bit.TemplatePlayground.Client.Core/appsettings.json'
files: 'src\Client\Bit.TemplatePlayground.Client.Core\appsettings.json'
env:
ApiServerAddress: ${{ env.API_SERVER_ADDRESS }}

- name: Install maui
run: cd src && dotnet workload install maui
WindowsUpdateSettings.FilesUrl: https://windows-bit.templateplayground.bitplatform.dev

- name: Generate CSS/JS files
run: dotnet build src/Client/Bit.TemplatePlayground.Client.Core/Bit.TemplatePlayground.Client.Core.csproj -t:BeforeBuildTasks --no-restore

- name: Build exe
run: dotnet build src/Client/Bit.TemplatePlayground.Client.Maui/Bit.TemplatePlayground.Client.Maui.csproj -c Release -p:WindowsPackageType=None -p:SelfContained=true -p:WindowsAppSDKSelfContained=true -p:GenerateAppxPackageOnBuild=false -p:RuntimeIdentifier=win10-x86 -p:UseRidGraph=true -f net8.0-windows10.0.19041.0
run: dotnet build src\Client\Bit.TemplatePlayground.Client.Core\Bit.TemplatePlayground.Client.Core.csproj -t:BeforeBuildTasks --no-restore

- name: Publish
run: |
cd src\Client\Bit.TemplatePlayground.Client.Windows\
dotnet publish Bit.TemplatePlayground.Client.Windows.csproj -c Release -o .\bin\publish-arm64 -r win-arm64
ren .\bin\publish-arm64\Bit.TemplatePlayground.Client.Windows.exe Bit.TemplatePlayground.Client.Windows-arm64.exe
dotnet publish Bit.TemplatePlayground.Client.Windows.csproj -c Release -o .\bin\publish-x86 -r win-x86
ren .\bin\publish-x86\Bit.TemplatePlayground.Client.Windows.exe Bit.TemplatePlayground.Client.Windows-x86.exe
dotnet publish Bit.TemplatePlayground.Client.Windows.csproj -c Release -o .\bin\publish-x64 -r win-x64
ren .\bin\publish-x64\Bit.TemplatePlayground.Client.Windows.exe Bit.TemplatePlayground.Client.Windows-x64.exe
dotnet publish Bit.TemplatePlayground.Client.Windows.csproj -c Release -o .\bin\publish
del .\bin\publish\Bit.TemplatePlayground.Client.Windows.exe
echo D | xcopy .\bin\publish-arm64 .\publish-result /s /e /h
echo A | xcopy .\bin\publish-x86 .\publish-result /s /e /h
echo A | xcopy .\bin\publish-x64 .\publish-result /s /e /h
echo A | xcopy .\bin\publish .\publish-result /s /e /h
dotnet tool restore
dotnet vpk pack -u Bit.TemplatePlayground.Client.Windows -v "${{ vars.APPLICATION_DISPLAY_VERSION }}" -p .\publish-result -e Bit.TemplatePlayground.Client.Windows-x64.exe -r win-x64 --framework net8.0.1-x64-desktop,webview2 --icon .\wwwroot\favicon.ico --packTitle 'Bit.TemplatePlayground'
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: win-exe-bundle
path: src/Client/Bit.TemplatePlayground.Client.Maui/bin/release/net8.0-windows10.0.19041.0/win10-x86
path: src\Client\Bit.TemplatePlayground.Client.Windows\Releases

build_blazor_hybrid_android:
name: build blazor hybrid (android)
Expand Down Expand Up @@ -216,49 +229,9 @@ jobs:
with:
name: android-bundle
path: src/Client/Bit.TemplatePlayground.Client.Maui/bin/Release/net8.0-android/*-Signed.*

build_blazor_hybrid_maccatalyst:
name: build blazor hybrid (maccatalyst)
runs-on: macos-13

steps:

- name: Checkout source code
uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
global-json-file: global.json

- uses: actions/setup-node@v3
with:
node-version: 18

- name: Update appsettings.json api server address
uses: microsoft/variable-substitution@v1
with:
files: 'src/Client/Bit.TemplatePlayground.Client.Core/appsettings.json'
env:
ApiServerAddress: ${{ env.API_SERVER_ADDRESS }}

- name: Install maui
run: cd src && dotnet workload install maui

- name: Generate CSS/JS files
run: dotnet build src/Client/Bit.TemplatePlayground.Client.Core/Bit.TemplatePlayground.Client.Core.csproj -t:BeforeBuildTasks --no-restore

- name: Build pkg
run: dotnet build src/Client/Bit.TemplatePlayground.Client.Maui/Bit.TemplatePlayground.Client.Maui.csproj -c Release -p:CreatePackage=true -f net8.0-maccatalyst

- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: mac-pkg-bundle
path: src/Client/Bit.TemplatePlayground.Client.Maui/bin/release/net8.0-maccatalyst/*.pkg

build_blazor_hybrid_iOS:
name: build blazor hybrid (iOS)
name: build blazor hybrid (iOS-macOS)
runs-on: macos-13

steps:
Expand Down
7 changes: 7 additions & 0 deletions Bit.TemplatePlayground.sln
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
.github\workflows\ci.yml = .github\workflows\ci.yml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bit.TemplatePlayground.Client.Windows", "src\Client\Bit.TemplatePlayground.Client.Windows\Bit.TemplatePlayground.Client.Windows.csproj", "{E3CB3C34-F5DE-4A96-B552-7D52BCAD1E1F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -65,6 +67,10 @@ Global
{22816913-64D5-4AE8-9B34-6F188B71FAD1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{22816913-64D5-4AE8-9B34-6F188B71FAD1}.Release|Any CPU.Build.0 = Release|Any CPU
{22816913-64D5-4AE8-9B34-6F188B71FAD1}.Release|Any CPU.Deploy.0 = Release|Any CPU
{E3CB3C34-F5DE-4A96-B552-7D52BCAD1E1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E3CB3C34-F5DE-4A96-B552-7D52BCAD1E1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E3CB3C34-F5DE-4A96-B552-7D52BCAD1E1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E3CB3C34-F5DE-4A96-B552-7D52BCAD1E1F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -75,6 +81,7 @@ Global
{22816913-64D5-4AE8-9B34-6F188B71FAD1} = {248D8229-BABD-4F0A-A9C6-0417B464507B}
{3E577755-186F-4E63-8153-B8DE890015C9} = {5CF43F76-BB71-4B5B-B4DF-1C753E042A8F}
{2347E3B2-FDDE-427E-A0AE-E4DCD47C2989} = {3E577755-186F-4E63-8153-B8DE890015C9}
{E3CB3C34-F5DE-4A96-B552-7D52BCAD1E1F} = {248D8229-BABD-4F0A-A9C6-0417B464507B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572}
Expand Down
6 changes: 3 additions & 3 deletions Clean.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
:: The commands in this script are specifically designed for Windows.

:: Deletes CSS, JS, and source map files that are not tracked in Git.
powershell -Command "[string]$trackedFiles = git ls-files; Get-ChildItem -Include *.css,*.min.css,*.js,*.min.js,*.map -Recurse | ForEach-Object { if ($trackedFiles -NotMatch $_.Name) { Remove-Item -Recurse -Path $_ -Confirm:$false -Force }}"
powershell -Command "[string]$trackedFiles = git ls-files; Get-ChildItem -Force -Include *.css,*.min.css,*.js,*.min.js,*.map -Recurse | ForEach-Object { if ($trackedFiles -NotMatch $_.Name) { Remove-Item -Recurse -Path $_ -Confirm:$false -Force }}"

:: Runs the dotnet clean command for each .csproj file.
powershell -Command "Get-ChildItem -Include *.csproj -Recurse | ForEach-Object { dotnet clean $_.FullName }"
powershell -Command "Get-ChildItem -Force -Include *.csproj -Recurse | ForEach-Object { dotnet clean $_.FullName }"

:: Deletes the specified files and folders.
powershell -Command "Get-ChildItem -Include *.csproj.user,Resources.designer.cs,bin,obj,node_modules,Packages,TestResults,AppPackages,.meteor -Recurse | ForEach-Object { Remove-Item -Recurse -Path $_ -Confirm:$false -Force }"
powershell -Command "Get-ChildItem -Force -Include *.csproj.user,Resources.designer.cs,bin,obj,node_modules,Packages,TestResults,AppPackages,.meteor -Recurse | ForEach-Object { Remove-Item -Recurse -Path $_ -Confirm:$false -Force }"
FOR /d /r . %%d IN (.vs) DO @IF EXIST "%%d" rd /s /q "%%d"

:: Deletes empty directories.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Done!

This sample project gets created by the following command:
```bash
dotnet new install Bit.Boilerplate && dotnet new bit-bp --name Bit.TemplatePlayground --database sqlite --sample admin
dotnet new install Bit.Boilerplate && dotnet new bit-bp --name Bit.TemplatePlayground --database sqlite --sample admin --windows
```

Note: In order to view sign-up's `confirmation email`, read [Email settings docs](https://bitplatform.dev/templates/settings).
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pulumi.AzureNative" Version="2.24.0" />
<PackageReference Include="Pulumi.AzureNative" Version="2.26.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

<ItemGroup>
<PackageReference Include="Magick.NET-Q16-AnyCPU" Version="13.5.0" />
<PackageReference Include="Bit.CodeAnalyzers" Version="8.7.2">
<PackageReference Include="Bit.CodeAnalyzers" Version="8.7.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Bit.SourceGenerators" Version="8.7.2">
<PackageReference Include="Bit.SourceGenerators" Version="8.7.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -20,7 +20,7 @@
<PackageReference Include="Microsoft.AspNetCore.DataProtection.EntityFrameworkCore" Version="8.0.1" />

<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.OData" Version="8.2.3" />
<PackageReference Include="Microsoft.AspNetCore.OData" Version="8.2.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down Expand Up @@ -89,7 +89,7 @@
<PropertyGroup>
<RuntimeIdentifiers>linux-x64</RuntimeIdentifiers>
<EnableSdkContainerDebugging>True</EnableSdkContainerDebugging>
<UserSecretsId>AC87AA5B-4B37-4E52-8468-2D5DF24AF256</UserSecretsId>
<UserSecretsId>21D250BE-CAF7-44E4-8DAC-AFA502B0E2F2</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,20 @@ public static void AddBlazor(this IServiceCollection services, IConfiguration co
services.AddClientWebServices();
}

public static void AddIdentity(this IServiceCollection services, IConfiguration configuration)
public static void AddIdentity(this IServiceCollection services, IConfiguration configuration, IWebHostEnvironment hostEnv)
{
var appSettings = configuration.GetSection(nameof(AppSettings)).Get<AppSettings>()!;
var settings = appSettings.IdentitySettings;

var certificatePath = Path.Combine(Directory.GetCurrentDirectory(), "IdentityCertificate.pfx");
var certificate = new X509Certificate2(certificatePath, appSettings.IdentitySettings.IdentityCertificatePassword, OperatingSystem.IsWindows() ? X509KeyStorageFlags.EphemeralKeySet : X509KeyStorageFlags.DefaultKeySet);

bool isTestCertificate = certificate.Thumbprint is "55140A8C935AB5202949071E5781E6946CD60606"; // The default test certificate is still in use
if (isTestCertificate && hostEnv.IsDevelopment() is false)
{
throw new InvalidOperationException(@"The default test certificate is still in use. Please replace it with a new one by running the 'dotnet dev-certs https --export-path IdentityCertificate.pfx --password P@ssw0rdP@ssw0rd' command (or your preferred method for generating PFX files) in the server project's folder.");
}

services.AddDataProtection()
.PersistKeysToDbContext<AppDbContext>()
.ProtectKeysWithCertificate(certificate);
Expand Down
Binary file modified src/Bit.TemplatePlayground.Server/IdentityCertificate.pfx
Binary file not shown.
2 changes: 1 addition & 1 deletion src/Bit.TemplatePlayground.Server/Startup/Services.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static void Add(IServiceCollection services, IWebHostEnvironment env, ICo

services.AddSwaggerGen();

services.AddIdentity(configuration);
services.AddIdentity(configuration, env);

services.AddHealthChecks(env, configuration);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"AppSettings": {

}
"DetailedErrors": true
}
10 changes: 5 additions & 5 deletions src/Bit.TemplatePlayground.Server/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"IdentitySettings": {
"Issuer": "Bit.TemplatePlayground",
"Audience": "Bit.TemplatePlayground",
"IdentityCertificatePassword": "P@ssw0rdP@ssw0rd",
"BearerTokenExpiration": "0.01:00:00", //Format: D.HH:mm:ss
"RefreshTokenExpiration": "14.00:00:00", //Format: D.HH:mm:ss
"IdentityCertificatePassword": "P@ssw0rdP@ssw0rd", // It can also be configured using: dotnet user-secrets set "AppSettings:IdentitySettings:IdentityCertificatePassword" "P@ssw0rdP@ssw0rd"
"BearerTokenExpiration": "0.01:00:00", // Format: D.HH:mm:ss
"RefreshTokenExpiration": "14.00:00:00", // Format: D.HH:mm:ss
"PasswordRequireDigit": "false",
"PasswordRequiredLength": "6",
"PasswordRequireNonAlphanumeric": "false",
"PasswordRequireUppercase": "false",
"PasswordRequireLowercase": "false",
"RequireUniqueEmail": "true",
"ConfirmationEmailResendDelay": "0.00:02:00", //Format: D.HH:mm:ss
"ResetPasswordEmailResendDelay": "0.00:02:00" //Format: D.HH:mm:ss
"ConfirmationEmailResendDelay": "0.00:02:00", // Format: D.HH:mm:ss
"ResetPasswordEmailResendDelay": "0.00:02:00" // Format: D.HH:mm:ss
},
"EmailSettings": {
"Host": "LocalFolder", // Local folder means storing emails as .eml file in bin/Debug/net8.0/sent-emails folder (Recommended for testing purposes only) instead of sending them using smtp server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bit.CodeAnalyzers" Version="8.7.2">
<PackageReference Include="Bit.CodeAnalyzers" Version="8.7.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Bit.SourceGenerators" Version="8.7.2">
<PackageReference Include="Bit.SourceGenerators" Version="8.7.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
<Content Remove="appsettings*.json" />
<EmbeddedResource Include="appsettings*.json" />

<PackageReference Include="Bit.Butil" Version="8.7.2" />
<PackageReference Include="Bit.BlazorUI" Version="8.7.2" />
<PackageReference Include="Bit.BlazorUI.Icons" Version="8.7.2" />
<PackageReference Include="Bit.BlazorUI.Assets" Version="8.7.2" />
<PackageReference Include="Bit.BlazorUI.Extras" Version="8.7.2" />
<PackageReference Include="Bit.CodeAnalyzers" Version="8.7.2">
<PackageReference Include="Bit.Butil" Version="8.7.4" />
<PackageReference Include="Bit.BlazorUI" Version="8.7.4" />
<PackageReference Include="Bit.BlazorUI.Icons" Version="8.7.4" />
<PackageReference Include="Bit.BlazorUI.Assets" Version="8.7.4" />
<PackageReference Include="Bit.BlazorUI.Extras" Version="8.7.4" />
<PackageReference Include="Bit.CodeAnalyzers" Version="8.7.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Bit.SourceGenerators" Version="8.7.2">
<PackageReference Include="Bit.SourceGenerators" Version="8.7.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ protected override async Task OnInitAsync()
{
AuthenticationManager.AuthenticationStateChanged += VerifyUserIsAuthenticatedOrNot;

isUserAuthenticated = await PrerenderStateService.GetValue($"{nameof(Header)}-isUserAuthenticated", async () => (await AuthenticationStateTask).User.IsAuthenticated());
isUserAuthenticated = await PrerenderStateService.GetValue(async () => (await AuthenticationStateTask).User.IsAuthenticated());

await base.OnInitAsync();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected override async Task OnInitializedAsync()
{
authManager.AuthenticationStateChanged += VerifyUserIsAuthenticatedOrNot;

isUserAuthenticated = await prerenderStateService.GetValue($"{nameof(MainLayout)}-isUserAuthenticated", async () => (await AuthenticationStateTask).User.IsAuthenticated());
isUserAuthenticated = await prerenderStateService.GetValue(async () => (await AuthenticationStateTask).User.IsAuthenticated());

await base.OnInitializedAsync();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ protected override async Task OnInitAsync()
await InvokeAsync(StateHasChanged);
});

user = (await HttpClient.GetFromJsonAsync("api/User/GetCurrentUser", AppJsonContext.Default.UserDto, CurrentCancellationToken))!;
user = (await PrerenderStateService.GetValue(() => HttpClient.GetFromJsonAsync("api/User/GetCurrentUser", AppJsonContext.Default.UserDto, CurrentCancellationToken)))!;

var access_token = await PrerenderStateService.GetValue(AuthTokenProvider.GetAccessTokenAsync);
var access_token = await PrerenderStateService.GetValue(() => AuthTokenProvider.GetAccessTokenAsync());
profileImageUrlBase = $"{Configuration.GetApiServerAddress()}api/Attachment/GetProfileImage?access_token={access_token}&file=";

SetProfileImageUrl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected override async Task OnInitAsync()
{
await LoadEditProfileData();

var access_token = await PrerenderStateService.GetValue(AuthTokenProvider.GetAccessTokenAsync);
var access_token = await PrerenderStateService.GetValue(() => AuthTokenProvider.GetAccessTokenAsync());

profileImageUploadUrl = $"{Configuration.GetApiServerAddress()}api/Attachment/UploadProfileImage?access_token={access_token}";
profileImageUrl = $"{Configuration.GetApiServerAddress()}api/Attachment/GetProfileImage?access_token={access_token}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
"Microsoft": "Warning"
}
},
"ApiServerAddress": "http://localhost:5030/" // You can also use relative urls such as / for Blazor Server and WebAssembly
"ApiServerAddress": "http://localhost:5030/", // You can also use relative urls such as / for Blazor Server and WebAssembly
"WindowsUpdateSettings": {
"FilesUrl": null,
"AutoReload": true
}
}
Loading

0 comments on commit ebc571f

Please sign in to comment.