|
|
@ -12,6 +12,7 @@ using System.Text.Json; |
|
|
using System.Text.RegularExpressions; |
|
|
using System.Text.RegularExpressions; |
|
|
using System.Threading; |
|
|
using System.Threading; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
|
|
|
using NuGet.Versioning; |
|
|
using Volo.Abp.Cli.GitHub; |
|
|
using Volo.Abp.Cli.GitHub; |
|
|
using Volo.Abp.Cli.Http; |
|
|
using Volo.Abp.Cli.Http; |
|
|
using Volo.Abp.Cli.ProjectBuilding.Templates.App; |
|
|
using Volo.Abp.Cli.ProjectBuilding.Templates.App; |
|
|
@ -19,6 +20,7 @@ using Volo.Abp.Cli.ProjectBuilding.Templates.Console; |
|
|
using Volo.Abp.Cli.ProjectBuilding.Templates.Maui; |
|
|
using Volo.Abp.Cli.ProjectBuilding.Templates.Maui; |
|
|
using Volo.Abp.Cli.ProjectBuilding.Templates.MvcModule; |
|
|
using Volo.Abp.Cli.ProjectBuilding.Templates.MvcModule; |
|
|
using Volo.Abp.Cli.ProjectBuilding.Templates.Wpf; |
|
|
using Volo.Abp.Cli.ProjectBuilding.Templates.Wpf; |
|
|
|
|
|
using Volo.Abp.Cli.Version; |
|
|
using Volo.Abp.DependencyInjection; |
|
|
using Volo.Abp.DependencyInjection; |
|
|
using Volo.Abp.Http; |
|
|
using Volo.Abp.Http; |
|
|
using Volo.Abp.IO; |
|
|
using Volo.Abp.IO; |
|
|
@ -37,18 +39,21 @@ public class AbpIoSourceCodeStore : ISourceCodeStore, ITransientDependency |
|
|
protected ICancellationTokenProvider CancellationTokenProvider { get; } |
|
|
protected ICancellationTokenProvider CancellationTokenProvider { get; } |
|
|
|
|
|
|
|
|
private readonly CliHttpClientFactory _cliHttpClientFactory; |
|
|
private readonly CliHttpClientFactory _cliHttpClientFactory; |
|
|
|
|
|
protected CliVersionService CliVersionService { get; } |
|
|
|
|
|
|
|
|
public AbpIoSourceCodeStore( |
|
|
public AbpIoSourceCodeStore( |
|
|
IOptions<AbpCliOptions> options, |
|
|
IOptions<AbpCliOptions> options, |
|
|
IJsonSerializer jsonSerializer, |
|
|
IJsonSerializer jsonSerializer, |
|
|
IRemoteServiceExceptionHandler remoteServiceExceptionHandler, |
|
|
IRemoteServiceExceptionHandler remoteServiceExceptionHandler, |
|
|
ICancellationTokenProvider cancellationTokenProvider, |
|
|
ICancellationTokenProvider cancellationTokenProvider, |
|
|
CliHttpClientFactory cliHttpClientFactory) |
|
|
CliHttpClientFactory cliHttpClientFactory, |
|
|
|
|
|
CliVersionService cliVersionService) |
|
|
{ |
|
|
{ |
|
|
JsonSerializer = jsonSerializer; |
|
|
JsonSerializer = jsonSerializer; |
|
|
RemoteServiceExceptionHandler = remoteServiceExceptionHandler; |
|
|
RemoteServiceExceptionHandler = remoteServiceExceptionHandler; |
|
|
CancellationTokenProvider = cancellationTokenProvider; |
|
|
CancellationTokenProvider = cancellationTokenProvider; |
|
|
_cliHttpClientFactory = cliHttpClientFactory; |
|
|
_cliHttpClientFactory = cliHttpClientFactory; |
|
|
|
|
|
CliVersionService = cliVersionService; |
|
|
Options = options.Value; |
|
|
Options = options.Value; |
|
|
|
|
|
|
|
|
Logger = NullLogger<AbpIoSourceCodeStore>.Instance; |
|
|
Logger = NullLogger<AbpIoSourceCodeStore>.Instance; |
|
|
@ -63,8 +68,8 @@ public class AbpIoSourceCodeStore : ISourceCodeStore, ITransientDependency |
|
|
bool skipCache = false) |
|
|
bool skipCache = false) |
|
|
{ |
|
|
{ |
|
|
DirectoryHelper.CreateIfNotExists(CliPaths.TemplateCache); |
|
|
DirectoryHelper.CreateIfNotExists(CliPaths.TemplateCache); |
|
|
|
|
|
var userSpecifiedVersion = version != null; |
|
|
var latestVersion = version ?? await GetLatestSourceCodeVersionAsync(name, type, null, includePreReleases); |
|
|
var latestVersion = version ?? await GetLatestSourceCodeVersionAsync(name, type, null, includePreReleases); |
|
|
|
|
|
|
|
|
if (version == null) |
|
|
if (version == null) |
|
|
{ |
|
|
{ |
|
|
if (latestVersion == null) |
|
|
if (latestVersion == null) |
|
|
@ -86,14 +91,68 @@ public class AbpIoSourceCodeStore : ISourceCodeStore, ITransientDependency |
|
|
|
|
|
|
|
|
version = latestVersion; |
|
|
version = latestVersion; |
|
|
} |
|
|
} |
|
|
else |
|
|
|
|
|
|
|
|
var currentCliVersion = await CliVersionService.GetCurrentCliVersionAsync(); |
|
|
|
|
|
var templateVersion = SemanticVersion.Parse(version); |
|
|
|
|
|
|
|
|
|
|
|
var outputWarning = false; |
|
|
|
|
|
if (currentCliVersion.Major != templateVersion.Major || currentCliVersion.Minor != templateVersion.Minor) |
|
|
|
|
|
{ |
|
|
|
|
|
// major and minor version are different
|
|
|
|
|
|
outputWarning = true; |
|
|
|
|
|
} |
|
|
|
|
|
else if (currentCliVersion.Major == templateVersion.Major && |
|
|
|
|
|
currentCliVersion.Minor == templateVersion.Minor && |
|
|
|
|
|
currentCliVersion.Patch < templateVersion.Patch) |
|
|
{ |
|
|
{ |
|
|
if (!await IsVersionExists(name, version)) |
|
|
// major and minor version are same but patch version is lower
|
|
|
|
|
|
outputWarning = true; |
|
|
|
|
|
} |
|
|
|
|
|
else if(currentCliVersion.Major == templateVersion.Major && |
|
|
|
|
|
currentCliVersion.Minor == templateVersion.Minor && |
|
|
|
|
|
currentCliVersion.Patch == templateVersion.Patch && |
|
|
|
|
|
currentCliVersion.IsPrerelease && templateVersion.IsPrerelease) |
|
|
|
|
|
{ |
|
|
|
|
|
// major and minor and patch version are same but prerelease version may be lower
|
|
|
|
|
|
var cliRcVersion = currentCliVersion.ReleaseLabels.LastOrDefault(); |
|
|
|
|
|
var templateRcVersion = templateVersion.ReleaseLabels.LastOrDefault(); |
|
|
|
|
|
if (cliRcVersion != null && templateRcVersion != null) |
|
|
{ |
|
|
{ |
|
|
throw new Exception("There is no version found with given version: " + version); |
|
|
if (int.TryParse(cliRcVersion, out var cliRcVersionNumber) && int.TryParse(templateRcVersion, out var templateRcVersionNumber)) |
|
|
|
|
|
{ |
|
|
|
|
|
if (cliRcVersionNumber < templateRcVersionNumber) |
|
|
|
|
|
{ |
|
|
|
|
|
outputWarning = true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (outputWarning) |
|
|
|
|
|
{ |
|
|
|
|
|
version = currentCliVersion.ToString(); |
|
|
|
|
|
Logger.LogWarning(userSpecifiedVersion |
|
|
|
|
|
? $"The specified template version ({templateVersion}) is different than the CLI version ({currentCliVersion}). This may cause compatibility issues." |
|
|
|
|
|
: $"The latest template version ({templateVersion}) is different than the CLI version ({currentCliVersion}). This may cause compatibility issues."); |
|
|
|
|
|
Logger.LogWarning("Please upgrade/downgrade the CLI version to the template version."); |
|
|
|
|
|
Logger.LogWarning($"> dotnet tool uninstall -g volo.abp.cli"); |
|
|
|
|
|
Logger.LogWarning(!templateVersion.IsPrerelease |
|
|
|
|
|
? $"> dotnet tool install -g volo.abp.cli --version \"{templateVersion.Major}.{templateVersion.Minor}.*\"" |
|
|
|
|
|
: $"> dotnet tool install -g volo.abp.cli --version {templateVersion}"); |
|
|
|
|
|
|
|
|
|
|
|
if (!userSpecifiedVersion) |
|
|
|
|
|
{ |
|
|
|
|
|
version = currentCliVersion.ToString(); |
|
|
|
|
|
Logger.LogWarning($"We have changed the template version as the cli version."); |
|
|
|
|
|
Logger.LogWarning($"New version: {version}"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!await IsVersionExists(name, version)) |
|
|
|
|
|
{ |
|
|
|
|
|
throw new Exception("There is no version found with given version: " + version); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var nugetVersion = (await GetTemplateNugetVersionAsync(name, type, version)) ?? version; |
|
|
var nugetVersion = (await GetTemplateNugetVersionAsync(name, type, version)) ?? version; |
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(templateSource) && !IsNetworkSource(templateSource)) |
|
|
if (!string.IsNullOrWhiteSpace(templateSource) && !IsNetworkSource(templateSource)) |
|
|
|