Compare commits

...
6 Commits
Author SHA1 Message Date
amacocianandGitHub c64830c5b6 #123 #113 #105 Build Templates Improvements (#124) 2023-01-21 21:35:16 +00:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
561c7cf7b1 Bump microsoft/setup-msbuild from 1.0.1 to 1.1.3 (#111)
Bumps [microsoft/setup-msbuild](https://github.com/microsoft/setup-msbuild) from 1.0.1 to 1.1.3.
- [Release notes](https://github.com/microsoft/setup-msbuild/releases)
- [Changelog](https://github.com/microsoft/setup-msbuild/blob/master/building-release.md)
- [Commits](https://github.com/microsoft/setup-msbuild/compare/v1.0.1...v1.1.3)

---
updated-dependencies:
- dependency-name: microsoft/setup-msbuild
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-09 15:22:44 +01:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2c6862de41 Bump coverlet.collector from 3.1.2 to 3.2.0 (#112)
Bumps [coverlet.collector](https://github.com/coverlet-coverage/coverlet) from 3.1.2 to 3.2.0.
- [Release notes](https://github.com/coverlet-coverage/coverlet/releases)
- [Commits](https://github.com/coverlet-coverage/coverlet/commits/v3.2.0)

---
updated-dependencies:
- dependency-name: coverlet.collector
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-09 15:10:18 +01:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
69842cbadf Bump Microsoft.NET.Test.Sdk from 17.4.0-preview-20221003-03 to 17.4.0 (#116)
Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.4.0-preview-20221003-03 to 17.4.0.
- [Release notes](https://github.com/microsoft/vstest/releases)
- [Commits](https://github.com/microsoft/vstest/compare/v17.4.0-preview-20221003-03...v17.4.0)

---
updated-dependencies:
- dependency-name: Microsoft.NET.Test.Sdk
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-09 14:24:26 +01:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
c7327e7bb2 Bump Microsoft.NET.Test.Sdk (#108)
Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.4.0-preview-20220726-02 to 17.4.0-preview-20221003-03.
- [Release notes](https://github.com/microsoft/vstest/releases)
- [Commits](https://github.com/microsoft/vstest/compare/v17.4.0-preview-20220726-02...v17.4.0-preview-20221003-03)

---
updated-dependencies:
- dependency-name: Microsoft.NET.Test.Sdk
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-11 10:18:44 +00:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
de33ed7fc4 Bump actions/setup-dotnet from 2 to 3 (#107)
Bumps [actions/setup-dotnet](https://github.com/actions/setup-dotnet) from 2 to 3.
- [Release notes](https://github.com/actions/setup-dotnet/releases)
- [Commits](https://github.com/actions/setup-dotnet/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/setup-dotnet
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-11 10:09:29 +00:00
11 changed files with 91 additions and 48 deletions
+2 -2
View File
@@ -53,12 +53,12 @@ jobs:
echo "${{ env.Changelog }}"
- name: Install .NET Core
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.x'
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v1.0.1
uses: microsoft/setup-msbuild@v1.1.3
- name: Setup project secrets
run: |
+2 -2
View File
@@ -36,12 +36,12 @@ jobs:
fetch-depth: 0
- name: Install .NET Core
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.x'
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v1.0.1
uses: microsoft/setup-msbuild@v1.1.3
- name: Execute Unit Tests
run: dotnet test $env:Test_Project_Path
+1 -1
View File
@@ -57,7 +57,7 @@ jobs:
# If this step fails, then you should remove it and run the build manually (see below)
- name: Install .NET Core
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.x'
+6 -6
View File
@@ -6,12 +6,12 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0-preview-20220726-02" />
<PackageReference Include="Moq" Version="4.18.2" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="coverlet.collector" Version="3.1.2" />
<PackageReference Include="FluentAssertions" Version="6.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
<PackageReference Include="coverlet.collector" Version="3.2.0" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
</ItemGroup>
+7 -7
View File
@@ -11,7 +11,7 @@
<LangVersion>preview</LangVersion>
<ApplicationIcon>Daybreak.ico</ApplicationIcon>
<IncludePackageReferencesDuringMarkupCompilation>true</IncludePackageReferencesDuringMarkupCompilation>
<Version>0.9.7.2</Version>
<Version>0.9.7.3</Version>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<UserSecretsId>cfb2a489-db80-448d-a969-80270f314c46</UserSecretsId>
</PropertyGroup>
@@ -35,14 +35,14 @@
</Target>
<ItemGroup>
<PackageReference Include="LiteDB" Version="5.0.12" />
<PackageReference Include="LiteDB" Version="5.0.15" />
<PackageReference Include="Microsoft.CorrelationVector" Version="1.0.42" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.2" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1370.28" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1518.46" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="NReco.Logging.File" Version="1.1.5" />
<PackageReference Include="securifybv.ShellLink" Version="0.1.0" />
<PackageReference Include="Slim" Version="1.9.2" />
+8
View File
@@ -0,0 +1,8 @@
namespace Daybreak.Models;
public sealed class SynchronizationBuild
{
public string Name { get; set; }
public string TemplateCode { get; set; }
public bool Changed { get; set; }
}
@@ -44,7 +44,6 @@ namespace Daybreak.Services.BuildTemplates
var emptyBuild = new Build();
var name = Guid.NewGuid().ToString();
var entry = new BuildEntry { Build = emptyBuild, Name = name, PreviousName = string.Empty };
this.SaveBuild(entry);
return entry;
}
@@ -52,19 +51,24 @@ namespace Daybreak.Services.BuildTemplates
{
var emptyBuild = new Build();
var entry = new BuildEntry { Build = emptyBuild, Name = name, PreviousName = string.Empty };
this.SaveBuild(entry);
return entry;
}
public void SaveBuild(BuildEntry buildEntry)
{
var encodedBuild = this.EncodeTemplate(buildEntry.Build);
if (string.IsNullOrWhiteSpace(buildEntry.PreviousName))
var newPath = Path.Combine(BuildsPath, $"{buildEntry.Name}.txt");
if (string.IsNullOrWhiteSpace(buildEntry.PreviousName) is false)
{
File.Delete($"{BuildsPath}\\{buildEntry.PreviousName}.txt");
var oldPath = Path.GetFullPath(Path.Combine(BuildsPath, $"{buildEntry.PreviousName}.txt"));
if (File.Exists(oldPath))
{
File.Delete(oldPath);
}
}
File.WriteAllText($"{BuildsPath}\\{buildEntry.Name}.txt", encodedBuild);
Directory.CreateDirectory(Path.GetDirectoryName(newPath));
File.WriteAllText(newPath, encodedBuild);
}
public void RemoveBuild(BuildEntry buildEntry)
@@ -82,12 +86,13 @@ namespace Daybreak.Services.BuildTemplates
public async Task<Result<BuildEntry, Exception>> GetBuild(string name)
{
if (File.Exists($"{BuildsPath}/{name}.txt") is false)
var path = Path.Combine(BuildsPath, $"{name}.txt");
if (File.Exists(path) is false)
{
return new InvalidOperationException("Unable to find build file");
}
var content = await File.ReadAllTextAsync($"{BuildsPath}/{name}.txt");
var content = await File.ReadAllTextAsync(path);
if (this.TryDecodeTemplate(content, out var build) is false)
{
return new InvalidOperationException("Unable to parse build file");
@@ -98,7 +103,7 @@ namespace Daybreak.Services.BuildTemplates
public void ClearBuilds()
{
foreach(var file in Directory.GetFiles(BuildsPath))
foreach(var file in Directory.GetFiles(BuildsPath, "*.txt", SearchOption.AllDirectories))
{
File.Delete(file);
}
@@ -106,7 +111,12 @@ namespace Daybreak.Services.BuildTemplates
public async IAsyncEnumerable<BuildEntry> GetBuilds()
{
foreach (var file in Directory.GetFiles(BuildsPath))
if (Directory.Exists(BuildsPath) is false)
{
yield break;
}
foreach (var file in Directory.GetFiles(BuildsPath, "*.txt", SearchOption.AllDirectories))
{
var maybeBuild = this.DecodeTemplateInner(await File.ReadAllTextAsync(file));
var build = maybeBuild.Switch(
@@ -119,7 +129,7 @@ namespace Daybreak.Services.BuildTemplates
if (build is not null)
{
yield return new BuildEntry { Build = build, Name = Path.GetFileNameWithoutExtension(file), PreviousName = Path.GetFileNameWithoutExtension(file) };
yield return new BuildEntry { Build = build, Name = Path.GetRelativePath(BuildsPath, file).Replace(".txt", string.Empty), PreviousName = Path.GetRelativePath(BuildsPath, file).Replace(".txt", string.Empty) };
}
}
}
+1 -1
View File
@@ -20,7 +20,7 @@ namespace Daybreak.Views
/// </summary>
public partial class BuildTemplateView : UserControl
{
private const string DisallowedChars = "\r\n\\/.";
private const string DisallowedChars = "\r\n/.";
private bool supressDecode = false;
+1 -1
View File
@@ -36,7 +36,7 @@ namespace Daybreak.Views
private async void LoadBuilds()
{
this.buildEntries = await this.buildTemplateManager.GetBuilds().ToListAsync();
this.BuildEntries.ClearAnd().AddRange(this.buildEntries);
this.BuildEntries.ClearAnd().AddRange(this.buildEntries.OrderBy(b => b.Name));
}
private void ListView_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
@@ -14,6 +14,7 @@
<UserControl.Resources>
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" TriggerValue="False"></converters:BooleanToVisibilityConverter>
<converters:BooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter" TriggerValue="True"></converters:BooleanToVisibilityConverter>
<BooleanToVisibilityConverter x:Key="BaseBooleanToVisibilityConverter"></BooleanToVisibilityConverter>
</UserControl.Resources>
<Grid
Background="#A0202020">
@@ -96,9 +97,12 @@
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Rectangle Fill="LawnGreen"
Opacity="0.2"
Visibility="{Binding Changed, Converter={StaticResource BooleanToVisibilityConverter}}"></Rectangle>
<TextBlock FontSize="14"
Foreground="White"
Text="{Binding Build.Name}"
Text="{Binding Name}"
HorizontalAlignment="Left"></TextBlock>
<TextBlock FontSize="14"
Foreground="White"
@@ -134,13 +138,16 @@
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Rectangle Fill="Red"
Visibility="{Binding Changed, Converter={StaticResource BooleanToVisibilityConverter}}"
Opacity="0.2"></Rectangle>
<TextBlock FontSize="14"
Foreground="White"
Text="{Binding TemplateCode}"
HorizontalAlignment="Left"></TextBlock>
<TextBlock FontSize="14"
Foreground="White"
Text="{Binding FileName}"
Text="{Binding Name}"
HorizontalAlignment="Right"></TextBlock>
</Grid>
</DataTemplate>
@@ -27,8 +27,8 @@ public partial class BuildsSynchronizationView : UserControl
private readonly IViewManager viewManager;
private readonly ILogger<BuildsSynchronizationView> logger;
public ObservableCollection<BuildFile> RemoteBuildEntries { get; } = new();
public ObservableCollection<BuildWithTemplateCode> LocalBuildEntries { get; } = new();
public ObservableCollection<SynchronizationBuild> RemoteBuildEntries { get; } = new();
public ObservableCollection<SynchronizationBuild> LocalBuildEntries { get; } = new();
[GenerateDependencyProperty(InitialValue = true)]
private bool buttonsEnabled;
@@ -37,9 +37,9 @@ public partial class BuildsSynchronizationView : UserControl
[GenerateDependencyProperty]
private string lastUploadDate;
[GenerateDependencyProperty]
private BuildFile selectedRemoteBuild;
private SynchronizationBuild selectedRemoteBuild;
[GenerateDependencyProperty]
private BuildWithTemplateCode selectedLocalBuild;
private SynchronizationBuild selectedLocalBuild;
[GenerateDependencyProperty]
private bool showLoading;
[GenerateDependencyProperty]
@@ -78,18 +78,28 @@ public partial class BuildsSynchronizationView : UserControl
private async Task PopulateBuilds()
{
var getBuildsResponse = await this.graphClient.RetrieveBuildsList();
if (getBuildsResponse.TryExtractSuccess(out var builds) is false)
if (getBuildsResponse.TryExtractSuccess(out var remoteBuildFiles) is false)
{
builds = new List<BuildFile>();
remoteBuildFiles = new List<BuildFile>();
}
this.RemoteBuildEntries.ClearAnd().AddRange(builds);
var localBuilds = await this.buildTemplateManager.GetBuilds().ToListAsync();
this.LocalBuildEntries.ClearAnd().AddRange(localBuilds.Select(build => new BuildWithTemplateCode { Build = build, TemplateCode = this.buildTemplateManager.EncodeTemplate(build.Build) }));
var localBuildFiles = await this.buildTemplateManager.GetBuilds().ToListAsync();
if (this.LocalBuildEntries.Count == this.RemoteBuildEntries.Count &&
this.LocalBuildEntries.Select(b => b.Build.Name).Except(this.RemoteBuildEntries.Select(b => b.FileName)).None() &&
this.LocalBuildEntries.Select(b => b.TemplateCode).Except(this.RemoteBuildEntries.Select(b => b.TemplateCode)).None())
var remoteBuilds = remoteBuildFiles.Select(buildFile => new SynchronizationBuild { Name = buildFile.FileName, TemplateCode = buildFile.TemplateCode })
.ToList();
var localBuilds = localBuildFiles.Select(build => new SynchronizationBuild { Name = build.Name, TemplateCode = this.buildTemplateManager.EncodeTemplate(build.Build) })
.ToList();
var changedLocalBuilds = localBuilds.Where(
localBuild => remoteBuilds.None(remoteBuild => localBuild.Name + localBuild.TemplateCode == remoteBuild.Name + remoteBuild.TemplateCode))
.ToList();
var changedRemoteBuilds = remoteBuilds.Where(
remoteBuild => localBuilds.None(localBuild => localBuild.Name + localBuild.TemplateCode == remoteBuild.Name + remoteBuild.TemplateCode))
.ToList();
if (localBuilds.Any() &&
changedLocalBuilds.None() &&
changedRemoteBuilds.None())
{
this.Synchronized = true;
}
@@ -97,6 +107,14 @@ public partial class BuildsSynchronizationView : UserControl
{
this.Synchronized = false;
}
foreach(var build in changedLocalBuilds.Concat(changedRemoteBuilds))
{
build.Changed = true;
}
this.RemoteBuildEntries.ClearAnd().AddRange(remoteBuilds);
this.LocalBuildEntries.ClearAnd().AddRange(localBuilds);
}
private void BackButton_Clicked(object sender, EventArgs e)
@@ -107,14 +125,14 @@ public partial class BuildsSynchronizationView : UserControl
private async void UploadButton_Clicked(object sender, EventArgs e)
{
// TODO: Handle failures to upload
if (this.SelectedLocalBuild is not BuildWithTemplateCode buildWithTemplateCode)
if (this.SelectedLocalBuild is not SynchronizationBuild build)
{
return;
}
this.ButtonsEnabled = false;
this.ShowLoading = true;
await this.graphClient.UploadBuild(buildWithTemplateCode.Build.Name);
await this.graphClient.UploadBuild(build.Name);
await this.PopulateBuilds();
this.ButtonsEnabled = true;
this.ShowLoading = false;
@@ -122,14 +140,14 @@ public partial class BuildsSynchronizationView : UserControl
private async void DownloadButton_Clicked(object sender, EventArgs e)
{
if (this.SelectedRemoteBuild is not BuildFile buildFile)
if (this.SelectedRemoteBuild is not SynchronizationBuild build)
{
return;
}
this.ButtonsEnabled = false;
this.ShowLoading = true;
await this.graphClient.DownloadBuild(buildFile.FileName);
await this.graphClient.DownloadBuild(build.Name);
await this.PopulateBuilds();
this.ButtonsEnabled = true;
this.ShowLoading = false;