|
|
|
@ -2,11 +2,16 @@ using Microsoft.Extensions.Logging;
|
|
|
|
|
using Microsoft.Extensions.Logging.Abstractions;
|
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Volo.Abp.Cli.Http;
|
|
|
|
|
using Volo.Abp.Cli.ProjectBuilding.Templates.App;
|
|
|
|
|
using Volo.Abp.Cli.ProjectBuilding.Templates.MvcModule;
|
|
|
|
|
using Volo.Abp.DependencyInjection;
|
|
|
|
|
using Volo.Abp.Http;
|
|
|
|
|
using Volo.Abp.IO;
|
|
|
|
@ -48,16 +53,33 @@ namespace Volo.Abp.Cli.ProjectBuilding
|
|
|
|
|
string templateSource = null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
DirectoryHelper.CreateIfNotExists(CliPaths.TemplateCache);
|
|
|
|
|
|
|
|
|
|
var latestVersion = await GetLatestSourceCodeVersionAsync(name, type);
|
|
|
|
|
if (version == null)
|
|
|
|
|
{
|
|
|
|
|
if (latestVersion == null)
|
|
|
|
|
{
|
|
|
|
|
Logger.LogWarning("The remote service is currently unavailable, please specify the version.");
|
|
|
|
|
Logger.LogWarning(string.Empty);
|
|
|
|
|
Logger.LogWarning("Find the following template in your cache directory: ");
|
|
|
|
|
Logger.LogWarning("\t Template Name\tVersion");
|
|
|
|
|
|
|
|
|
|
var templateList = GetLocalTemplates();
|
|
|
|
|
foreach (var cacheFile in templateList)
|
|
|
|
|
{
|
|
|
|
|
Logger.LogWarning($"\t {cacheFile.TemplateName}\t\t{cacheFile.Version}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Logger.LogWarning(string.Empty);
|
|
|
|
|
throw new CliUsageException("Use command: abp new Acme.BookStore -v version");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
version = latestVersion;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var nugetVersion = (await GetTemplateNugetVersionAsync(name, type, version)) ?? version;
|
|
|
|
|
|
|
|
|
|
DirectoryHelper.CreateIfNotExists(CliPaths.TemplateCache);
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(templateSource) && !IsNetworkSource(templateSource))
|
|
|
|
|
{
|
|
|
|
|
Logger.LogInformation("Using local " + type + ": " + name + ", version: " + version);
|
|
|
|
@ -122,7 +144,7 @@ namespace Volo.Abp.Cli.ProjectBuilding
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Error occured while getting the latest version from {0} : {1}", url, ex.Message);
|
|
|
|
|
throw;
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -195,11 +217,30 @@ namespace Volo.Abp.Cli.ProjectBuilding
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static bool IsNetworkSource(string source)
|
|
|
|
|
private bool IsNetworkSource(string source)
|
|
|
|
|
{
|
|
|
|
|
return source.ToLower().StartsWith("http");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<(string TemplateName, string Version)> GetLocalTemplates()
|
|
|
|
|
{
|
|
|
|
|
var templateList = new List<(string TemplateName, string Version)>();
|
|
|
|
|
|
|
|
|
|
var stringBuilder = new StringBuilder();
|
|
|
|
|
foreach (var cacheFile in Directory.GetFiles(CliPaths.TemplateCache))
|
|
|
|
|
{
|
|
|
|
|
stringBuilder.AppendLine(cacheFile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var matches = Regex.Matches(stringBuilder.ToString(),$"({AppTemplate.TemplateName}|{AppProTemplate.TemplateName}|{ModuleTemplate.TemplateName}|{ModuleProTemplate.TemplateName})-(.+).zip");
|
|
|
|
|
foreach (Match match in matches)
|
|
|
|
|
{
|
|
|
|
|
templateList.Add((match.Groups[1].Value, match.Groups[2].Value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return templateList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class SourceCodeDownloadInputDto
|
|
|
|
|
{
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|