Browse Source

Output cache template info, ignore CLI analysis exceptions

pull/3338/head
liangshiwei 7 years ago
parent
commit
1ba052cba5
  1. 24
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs
  2. 3
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Analyticses/CliAnalyticsCollect.cs

24
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs

@ -3,6 +3,7 @@ using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using System; using System;
using System.IO; using System.IO;
using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -48,17 +49,30 @@ namespace Volo.Abp.Cli.ProjectBuilding
string templateSource = null) string templateSource = null)
{ {
DirectoryHelper.CreateIfNotExists(CliPaths.TemplateCache);
var latestVersion = await GetLatestSourceCodeVersionAsync(name, type); var latestVersion = await GetLatestSourceCodeVersionAsync(name, type);
if (version == null) if (version == null)
{ {
version = latestVersion ?? throw new CliUsageException( if (latestVersion == null)
"The remote service is currently unavailable, please specify the version (like abp new Acme.BookStore -v 2.3.0(Make sure you have a template cache locally))!"); {
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: ");
foreach (var cacheFile in Directory.GetFiles(CliPaths.TemplateCache))
{
Logger.LogWarning($" {cacheFile}");
}
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; var nugetVersion = (await GetTemplateNugetVersionAsync(name, type, version)) ?? version;
DirectoryHelper.CreateIfNotExists(CliPaths.TemplateCache);
if (!string.IsNullOrWhiteSpace(templateSource) && !IsNetworkSource(templateSource)) if (!string.IsNullOrWhiteSpace(templateSource) && !IsNetworkSource(templateSource))
{ {
Logger.LogInformation("Using local " + type + ": " + name + ", version: " + version); Logger.LogInformation("Using local " + type + ": " + name + ", version: " + version);

3
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Analyticses/CliAnalyticsCollect.cs

@ -61,9 +61,8 @@ namespace Volo.Abp.Cli.ProjectBuilding.Analyticses
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine("Error occured while cli analytics from {0} : {1}", url, ex.Message); // ignored
} }
} }
} }
} }
Loading…
Cancel
Save