Skip to content

Commit

Permalink
Merge branch 'rel-6.0' of https://github.com/abpframework/abp into re…
Browse files Browse the repository at this point in the history
…l-6.0
  • Loading branch information
voloagent committed Sep 27, 2022
2 parents fe8bfd4 + d999d67 commit 6e9c719
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using Newtonsoft.Json;

namespace Volo.Abp.Cli.GitHub;

[JsonObject]
[Serializable]
public class GithubRelease
{
[JsonProperty("id")]
public int Id { get; set; }

[JsonProperty("name")]
public string Name { get; set; }

[JsonProperty("prerelease")]
public bool IsPrerelease { get; set; }

[JsonProperty("published_at")]
public DateTime PublishTime { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
using System.Net.Http;
using System.Reflection;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Cli.GitHub;
using Volo.Abp.Cli.Http;
using Volo.Abp.Cli.ProjectBuilding.Templates.App;
using Volo.Abp.Cli.ProjectBuilding.Templates.Console;
Expand Down Expand Up @@ -85,7 +87,7 @@ public async Task<TemplateFile> GetAsync(
}
else
{
if (!await IsVersionExists(version))
if (!await IsVersionExists(name, version))
{
throw new Exception("There is no version found with given version: " + version);
}
Expand Down Expand Up @@ -201,7 +203,7 @@ private async Task<string> GetTemplateNugetVersionAsync(string name, string type
}
}

private async Task<bool> IsVersionExists(string version)
private async Task<bool> IsVersionExists(string templateName, string version)
{
var url = $"{CliUrls.WwwAbpIo}api/download/versions?includePreReleases=true";

Expand All @@ -214,15 +216,15 @@ private async Task<bool> IsVersionExists(string version)
{
await RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(response);
var result = await response.Content.ReadAsStringAsync();
var versions = JsonSerializer.Deserialize<List<GithubRelease>>(result);
var versions = JsonSerializer.Deserialize<GithubReleaseVersions>(result);

return versions.Any(v => v.Name == version);
return templateName.Contains("LeptonX") ?
versions.LeptonXVersions.Any(v => v.Name == version) :
versions.FrameworkAndCommercialVersions.Any(v => v.Name == version);
}
}
catch (Exception ex)
catch (Exception)
{
Logger.LogWarning($"Error occured while getting the versions from {url} : {ex.Message}");
// The remote service is currently unavailable, try to work offline.
return true;
}
}
Expand Down Expand Up @@ -324,14 +326,10 @@ public class GetVersionResultDto
public string Version { get; set; }
}

public class GithubRelease
public class GithubReleaseVersions
{
public int Id { get; set; }

public string Name { get; set; }

public bool IsPrerelease { get; set; }

public DateTime PublishTime { get; set; }
public List<GithubRelease> FrameworkAndCommercialVersions { get; set; }

public List<GithubRelease> LeptonXVersions { get; set; }
}
}
}

0 comments on commit 6e9c719

Please sign in to comment.