fixes #2387 and fix CLI command descriptions.

pull/2398/head
Alper Ebicoglu 6 years ago
parent def70c5fe0
commit bb38ffc28a

@ -69,7 +69,7 @@ namespace Volo.Abp.Cli
{
var assembly = typeof(CliService).Assembly;
var toolPath = GetToolPath(assembly);
var currentCliVersion = await GetCurrentCliVersion(toolPath, assembly);
var currentCliVersion = await GetCurrentCliVersion(assembly);
var updateChannel = GetUpdateChannel(currentCliVersion);
Logger.LogInformation($"Version {currentCliVersion} ({updateChannel} channel)");
@ -100,26 +100,25 @@ namespace Volo.Abp.Cli
return assembly.Location.Substring(0, assembly.Location.IndexOf(".store", StringComparison.Ordinal));
}
private async Task<SemanticVersion> GetCurrentCliVersion(string toolPath, Assembly assembly)
private static async Task<SemanticVersion> GetCurrentCliVersion(Assembly assembly)
{
SemanticVersion currentCliVersion = default;
if (!string.IsNullOrEmpty(toolPath))
var consoleOutput = new StringReader(CmdHelper.RunCmdAndGetOutput($"dotnet tool list -g"));
string line;
while ((line = await consoleOutput.ReadLineAsync()) != null)
{
var consoleOutput = new StringReader(CmdHelper.RunCmdAndGetOutput($"dotnet tool list --tool-path {toolPath}"));
string line;
while ((line = await consoleOutput.ReadLineAsync()) != null)
if (line.StartsWith("volo.abp.cli", StringComparison.InvariantCultureIgnoreCase))
{
if (line.StartsWith("Volo.Abp.Cli", StringComparison.InvariantCultureIgnoreCase))
{
var version = line.Split(new char[0], StringSplitOptions.RemoveEmptyEntries)[1];
var version = line.Split(new char[0], StringSplitOptions.RemoveEmptyEntries)[1];
SemanticVersion.TryParse(version, out currentCliVersion);
SemanticVersion.TryParse(version, out currentCliVersion);
break;
}
break;
}
}
if (currentCliVersion == null)
{
// If not a tool executable, fallback to assembly version and treat as dev without updates

@ -75,9 +75,8 @@ namespace Volo.Abp.Cli.Commands
public string GetShortDescription()
{
return "Adds a multi-package module to a solution by finding all packages of the module, " +
"finding related projects in the solution and adding each package to the" +
" corresponding project in the solution.";
return "Add a multi-package module to a solution by finding all packages of the module, " +
"finding related projects in the solution and adding each package to the corresponding project in the solution.";
}
protected virtual string GetSolutionFile(CommandLineArgs commandLineArgs)

@ -68,9 +68,7 @@ namespace Volo.Abp.Cli.Commands
public string GetShortDescription()
{
return "Adds a new ABP package to a project by adding related nuget package" +
" as a dependency to the project and adding [DependsOn(...)] attribute to" +
" the module class in the project.";
return "Add a new ABP package to a project by adding related NuGet package dependencies and [DependsOn(...)] attributes.";
}
protected virtual string GetProjectFile(CommandLineArgs commandLineArgs)

@ -143,7 +143,7 @@ namespace Volo.Abp.Cli.Commands
public string GetShortDescription()
{
return "Downloads the source code of the specified module.";
return "Download the source code of the specified module.";
}
public static class Options

@ -82,7 +82,7 @@ namespace Volo.Abp.Cli.Commands
public string GetShortDescription()
{
return string.Empty;
return "Show command line help. Write ` abp help <command> `";
}
}
}

@ -72,7 +72,7 @@ namespace Volo.Abp.Cli.Commands
public string GetShortDescription()
{
return string.Empty;
return "Sign in to " + CliUrls.AccountAbpIo + ".";
}
public static class Options

@ -31,7 +31,7 @@ namespace Volo.Abp.Cli.Commands
public string GetShortDescription()
{
return string.Empty;
return "Sign out from " + CliUrls.AccountAbpIo + ".";
}
}
}

@ -175,7 +175,7 @@ namespace Volo.Abp.Cli.Commands
public string GetShortDescription()
{
return "Generates a new solution based on the ABP startup templates.";
return "Generate a new solution based on the ABP startup templates.";
}
protected virtual DatabaseProvider GetDatabaseProvider(CommandLineArgs commandLineArgs)

@ -146,7 +146,7 @@ namespace Volo.Abp.Cli.Commands
public string GetShortDescription()
{
return "Utility commands to use Abp Suite tool. Installs, updates, removes or starts Suite.";
return "Install, update, remove or start ABP Suite. See https://commercial.abp.io/tools/suite.";
}
}
}

@ -131,8 +131,7 @@ namespace Volo.Abp.Cli.Commands
public string GetShortDescription()
{
return "Automatically updates all ABP related NuGet packages and NPM packages in a" +
" solution or project to the latest versions";
return "Update all ABP related NuGet packages and NPM packages in a solution or project to the latest version.";
}
public static class Options

@ -8,22 +8,36 @@ namespace Volo.Abp.Cli.Http
{
public class CliHttpClient : HttpClient
{
public static TimeSpan DefaultTimeout { get; set; } = TimeSpan.FromMinutes(1);
public CliHttpClient(TimeSpan? timeout = null) : base(new CliHttpClientHandler())
{
Timeout = timeout ?? TimeSpan.FromMinutes(1);
Timeout = timeout ?? DefaultTimeout;
AddAuthentication(this);
}
public CliHttpClient(bool setBearerToken) : base(new CliHttpClientHandler())
{
Timeout = DefaultTimeout;
if (setBearerToken)
{
AddAuthentication(this);
}
}
private static void AddAuthentication(HttpClient client)
{
if (File.Exists(CliPaths.AccessToken))
if (!File.Exists(CliPaths.AccessToken))
{
return;
}
var accessToken = File.ReadAllText(CliPaths.AccessToken, Encoding.UTF8);
if (!accessToken.IsNullOrEmpty())
{
var accessToken = File.ReadAllText(CliPaths.AccessToken, Encoding.UTF8);
if (!accessToken.IsNullOrEmpty())
{
client.SetBearerToken(accessToken);
}
client.SetBearerToken(accessToken);
}
}
}

@ -32,7 +32,7 @@ namespace Volo.Abp.Cli.NuGet
public async Task<SemanticVersion> GetLatestVersionOrNullAsync(string packageId, bool includePreviews = false, bool includeNightly = false)
{
using (var client = new CliHttpClient())
using (var client = new CliHttpClient(setBearerToken: false))
{
var url = includeNightly ?
$"https://www.myget.org/F/abp-nightly/api/v3/flatcontainer/{packageId.ToLowerInvariant()}/index.json" :

Loading…
Cancel
Save