From 24e22c25975b36f2245ed79333b48848d0b87f24 Mon Sep 17 00:00:00 2001 From: EngincanV Date: Thu, 5 Dec 2024 15:18:07 +0300 Subject: [PATCH 1/3] CLI: Update command should also update LeptonX Theme package versions --- .../VoloNugetPackagesVersionUpdater.cs | 31 ++++++++++++++++--- .../Version/PackageVersionCheckerService.cs | 30 +++++++++++++++--- 2 files changed, 52 insertions(+), 9 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/VoloNugetPackagesVersionUpdater.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/VoloNugetPackagesVersionUpdater.cs index 9f23645fb98..08bc6bbadee 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/VoloNugetPackagesVersionUpdater.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/VoloNugetPackagesVersionUpdater.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using NuGet.Versioning; using System.IO; using System.Linq; @@ -39,6 +40,7 @@ public async Task UpdateSolutionAsync(string solutionPath, bool includePreviews var latestVersionInfo = await _packageVersionCheckerService.GetLatestVersionOrNullAsync("Volo.Abp.Core", includeReleaseCandidates: includeReleaseCandidates); var latestReleaseCandidateVersionInfo = await _packageVersionCheckerService.GetLatestVersionOrNullAsync("Volo.Abp.Core", includeReleaseCandidates: true); var latestVersionFromMyGet = await GetLatestVersionFromMyGet("Volo.Abp.Core"); + var latestStableVersions = await _packageVersionCheckerService.GetLatestStableVersionsAsync(); async Task UpdateAsync(string filePath) { @@ -55,7 +57,8 @@ async Task UpdateAsync(string filePath) latestVersionInfo.Version, latestReleaseCandidateVersionInfo.Version, latestVersionFromMyGet, - version); + version, + latestStableVersions: latestStableVersions); fs.Seek(0, SeekOrigin.Begin); fs.SetLength(0); @@ -83,6 +86,7 @@ public async Task UpdateProjectAsync(string projectPath, bool includeNightlyPrev var latestVersionInfo = await _packageVersionCheckerService.GetLatestVersionOrNullAsync("Volo.Abp.Core"); var latestReleaseCandidateVersionInfo = await _packageVersionCheckerService.GetLatestVersionOrNullAsync("Volo.Abp.Core", includeReleaseCandidates: true); var latestVersionFromMyGet = await GetLatestVersionFromMyGet("Volo.Abp.Core"); + var latestStableVersions = await _packageVersionCheckerService.GetLatestStableVersionsAsync(); using (var fs = File.Open(projectPath, FileMode.Open, FileAccess.ReadWrite, FileShare.None)) { @@ -97,7 +101,8 @@ public async Task UpdateProjectAsync(string projectPath, bool includeNightlyPrev latestVersionInfo.Version, latestReleaseCandidateVersionInfo.Version, latestVersionFromMyGet, - version); + version, + latestStableVersions: latestStableVersions); fs.Seek(0, SeekOrigin.Begin); fs.SetLength(0); @@ -114,13 +119,20 @@ public async Task UpdateProjectAsync(string projectPath, bool includeNightlyPrev protected virtual async Task UpdateInternalAsync(string projectPath, bool includeNightlyPreviews = false, bool includeReleaseCandidates = false, bool switchToStable = false) { + var latestStableVersions = await _packageVersionCheckerService.GetLatestStableVersionsAsync(); + using (var fs = File.Open(projectPath, FileMode.Open, FileAccess.ReadWrite, FileShare.None)) { using (var sr = new StreamReader(fs, Encoding.Default, true)) { var fileContent = await sr.ReadToEndAsync(); - var updatedContent = await UpdateVoloPackagesAsync(fileContent, includeNightlyPreviews, includeReleaseCandidates, switchToStable); + var updatedContent = await UpdateVoloPackagesAsync( + fileContent, + includeNightlyPreviews, + includeReleaseCandidates, + switchToStable, + latestStableVersions: latestStableVersions); fs.Seek(0, SeekOrigin.Begin); fs.SetLength(0); @@ -153,7 +165,8 @@ private async Task UpdateVoloPackagesAsync(string content, SemanticVersion latestNugetVersion = null, SemanticVersion latestNugetReleaseCandidateVersion = null, string latestMyGetVersion = null, - string specifiedVersion = null) + string specifiedVersion = null, + List latestStableVersions = null) { string packageId = null; @@ -206,12 +219,20 @@ private async Task UpdateVoloPackagesAsync(string content, if (!specifiedVersion.IsNullOrWhiteSpace()) { - if (isLeptonXPackage || isStudioPackage) + var leptonXPackageVersion = latestStableVersions? + .FirstOrDefault(v => v.Version.Equals(specifiedVersion, StringComparison.InvariantCultureIgnoreCase))?.LeptonX?.Version; + + if ((isLeptonXPackage && string.IsNullOrWhiteSpace(leptonXPackageVersion)) || isStudioPackage) { Logger.LogWarning("Package: {PackageId} could not be updated. Please manually update the package version yourself to prevent version mismatches!", packageId); continue; } + if (isLeptonXPackage && !string.IsNullOrWhiteSpace(leptonXPackageVersion)) + { + specifiedVersion = leptonXPackageVersion; + } + if (await SpecifiedVersionExists(specifiedVersion, packageId)) { var specifiedSemanticVersion = SemanticVersion.Parse(specifiedVersion); diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Version/PackageVersionCheckerService.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Version/PackageVersionCheckerService.cs index d5764c1c0e8..316c53e01e6 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Version/PackageVersionCheckerService.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Version/PackageVersionCheckerService.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Net; using System.Threading.Tasks; +using JetBrains.Annotations; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Volo.Abp.Cli.Http; @@ -111,6 +112,11 @@ public async Task GetLatestStableVersionFromGithubAsync() ? new LatestVersionInfo(semanticVersion, latestStableVersionResult.Message) : null; } + + public async Task> GetLatestStableVersionsAsync() + { + return await GetLatestStableVersionsInternalAsync(); + } private static ConcurrentDictionary CommercialPackagesCache { get; } = new (); @@ -225,7 +231,7 @@ private async Task SetApiKeyResultAsync() _apiKeyResult ??= await _apiKeyService.GetApiKeyOrNullAsync(); } - private async Task GetLatestStableVersionOrNullAsync() + private async Task> GetLatestStableVersionsInternalAsync() { try { @@ -241,16 +247,24 @@ private async Task GetLatestStableVersionOrNullAsync( var content = await responseMessage.Content.ReadAsStringAsync(); var result = JsonSerializer.Deserialize>(content); - - return result.FirstOrDefault(x => x.Type.ToLowerInvariant() == "stable"); + return result.OrderBy(q => q.Type.ToLowerInvariant() == "stable").ThenBy(q => SemanticVersion.Parse(q.Version)).ToList(); } } catch { - return null; + return []; } } + private async Task GetLatestStableVersionOrNullAsync() + { + var latestStableVersionsResult = await GetLatestStableVersionsInternalAsync(); + + return latestStableVersionsResult.Count <= 0 + ? null + : latestStableVersionsResult.FirstOrDefault(); + } + public class NuGetSearchResultDto { public int TotalHits { get; set; } @@ -270,6 +284,11 @@ public class NuGetVersionResultDto public List Versions { get; set; } } + public class LeptonXThemeInfo + { + public string Version { get; set; } + } + public class LatestStableVersionResult { public string Version { get; set; } @@ -279,5 +298,8 @@ public class LatestStableVersionResult public string Type { get; set; } public string Message { get; set; } + + [CanBeNull] + public LeptonXThemeInfo LeptonX { get; set; } } } From 35d0ce0d652b503e344302e44d35d7c72f1bc5e4 Mon Sep 17 00:00:00 2001 From: EngincanV Date: Thu, 5 Dec 2024 15:21:43 +0300 Subject: [PATCH 2/3] Update latest-versions.json --- latest-versions.json | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/latest-versions.json b/latest-versions.json index 0eff05a8919..e2c60800a3d 100644 --- a/latest-versions.json +++ b/latest-versions.json @@ -1,8 +1,29 @@ [ + { + "version": "9.0.1", + "releaseDate": "", + "type": "stable", + "message": "", + "leptonx": { + "version": "4.0.1" + } + }, + { + "version": "9.0.0", + "releaseDate": "", + "type": "stable", + "message": "", + "leptonx": { + "version": "4.0.0" + } + }, { "version": "8.3.1", "releaseDate": "", "type": "stable", - "message": "" + "message": "", + "leptonx": { + "version": "3.3.1" + } } ] \ No newline at end of file From 3968c799f68b921115e6610a0672aa34af754d95 Mon Sep 17 00:00:00 2001 From: EngincanV Date: Thu, 5 Dec 2024 15:38:52 +0300 Subject: [PATCH 3/3] Update VoloNugetPackagesVersionUpdater.cs --- .../VoloNugetPackagesVersionUpdater.cs | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/VoloNugetPackagesVersionUpdater.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/VoloNugetPackagesVersionUpdater.cs index 08bc6bbadee..4ece393913b 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/VoloNugetPackagesVersionUpdater.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/VoloNugetPackagesVersionUpdater.cs @@ -228,28 +228,30 @@ private async Task UpdateVoloPackagesAsync(string content, continue; } - if (isLeptonXPackage && !string.IsNullOrWhiteSpace(leptonXPackageVersion)) + var isLeptonXPackageWithVersion = isLeptonXPackage && !string.IsNullOrWhiteSpace(leptonXPackageVersion); + + if (isLeptonXPackageWithVersion || await SpecifiedVersionExists(specifiedVersion, packageId)) { - specifiedVersion = leptonXPackageVersion; + TryUpdatingPackage(isLeptonXPackageWithVersion ? leptonXPackageVersion : specifiedVersion); } - - if (await SpecifiedVersionExists(specifiedVersion, packageId)) + else { - var specifiedSemanticVersion = SemanticVersion.Parse(specifiedVersion); + Logger.LogWarning("Package \"{PackageId}\" specified version v{SpecifiedVersion} does not exist!", packageId, specifiedVersion); + } + + void TryUpdatingPackage(string versionToUpdate) + { + var specifiedSemanticVersion = SemanticVersion.Parse(versionToUpdate); if (specifiedSemanticVersion > currentSemanticVersion) { - Logger.LogInformation("Updating package \"{PackageId}\" from v{CurrentVersion} to v{SpecifiedVersion}", packageId, currentVersion, specifiedVersion); - versionAttribute.Value = specifiedVersion; + Logger.LogInformation("Updating package \"{PackageId}\" from v{CurrentVersion} to v{SpecifiedVersion}", packageId, currentVersion, versionToUpdate); + versionAttribute.Value = versionToUpdate; } else { - Logger.LogWarning("Unable to update package \"{PackageId}\" version v{CurrentVersion} to v{SpecifiedVersion}", packageId, currentVersion, specifiedVersion); + Logger.LogWarning("Unable to update package \"{PackageId}\" version v{CurrentVersion} to v{SpecifiedVersion}", packageId, currentVersion, versionToUpdate); } } - else - { - Logger.LogWarning("Package \"{PackageId}\" specified version v{SpecifiedVersion} does not exist!", packageId, specifiedVersion); - } } else { @@ -273,7 +275,7 @@ private async Task UpdateVoloPackagesAsync(string content, } else { - latestVersion = latestMyGetVersion == null ? await GetLatestVersionFromMyGet(packageId) : latestMyGetVersion; + latestVersion = latestMyGetVersion ?? await GetLatestVersionFromMyGet(packageId); } if(latestVersion == null)