Browse Source

fixes #2387 and fix CLI command descriptions.

pull/2398/head
Alper Ebicoglu 7 years ago
parent
commit
bb38ffc28a
  1. 23
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs
  2. 5
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddModuleCommand.cs
  3. 4
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddPackageCommand.cs
  4. 2
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GetSourceCommand.cs
  5. 2
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/HelpCommand.cs
  6. 2
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/LoginCommand.cs
  7. 2
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/LogoutCommand.cs
  8. 2
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs
  9. 2
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/SuiteCommand.cs
  10. 3
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/UpdateCommand.cs
  11. 28
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Http/CliHttpClient.cs
  12. 2
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/NuGet/NuGetService.cs

23
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs

@ -69,7 +69,7 @@ namespace Volo.Abp.Cli
{ {
var assembly = typeof(CliService).Assembly; var assembly = typeof(CliService).Assembly;
var toolPath = GetToolPath(assembly); var toolPath = GetToolPath(assembly);
var currentCliVersion = await GetCurrentCliVersion(toolPath, assembly); var currentCliVersion = await GetCurrentCliVersion(assembly);
var updateChannel = GetUpdateChannel(currentCliVersion); var updateChannel = GetUpdateChannel(currentCliVersion);
Logger.LogInformation($"Version {currentCliVersion} ({updateChannel} channel)"); 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)); 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; 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}")); if (line.StartsWith("volo.abp.cli", StringComparison.InvariantCultureIgnoreCase))
string line;
while ((line = await consoleOutput.ReadLineAsync()) != null)
{ {
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 (currentCliVersion == null)
{ {
// If not a tool executable, fallback to assembly version and treat as dev without updates // If not a tool executable, fallback to assembly version and treat as dev without updates

5
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddModuleCommand.cs

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

4
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddPackageCommand.cs

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

2
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GetSourceCommand.cs

@ -143,7 +143,7 @@ namespace Volo.Abp.Cli.Commands
public string GetShortDescription() 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 public static class Options

2
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/HelpCommand.cs

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

2
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/LoginCommand.cs

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

2
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/LogoutCommand.cs

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

2
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs

@ -175,7 +175,7 @@ namespace Volo.Abp.Cli.Commands
public string GetShortDescription() 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) protected virtual DatabaseProvider GetDatabaseProvider(CommandLineArgs commandLineArgs)

2
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/SuiteCommand.cs

@ -146,7 +146,7 @@ namespace Volo.Abp.Cli.Commands
public string GetShortDescription() 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.";
} }
} }
} }

3
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/UpdateCommand.cs

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

28
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Http/CliHttpClient.cs

@ -8,22 +8,36 @@ namespace Volo.Abp.Cli.Http
{ {
public class CliHttpClient : HttpClient public class CliHttpClient : HttpClient
{ {
public static TimeSpan DefaultTimeout { get; set; } = TimeSpan.FromMinutes(1);
public CliHttpClient(TimeSpan? timeout = null) : base(new CliHttpClientHandler()) public CliHttpClient(TimeSpan? timeout = null) : base(new CliHttpClientHandler())
{ {
Timeout = timeout ?? TimeSpan.FromMinutes(1); Timeout = timeout ?? DefaultTimeout;
AddAuthentication(this); AddAuthentication(this);
} }
public CliHttpClient(bool setBearerToken) : base(new CliHttpClientHandler())
{
Timeout = DefaultTimeout;
if (setBearerToken)
{
AddAuthentication(this);
}
}
private static void AddAuthentication(HttpClient client) 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); client.SetBearerToken(accessToken);
if (!accessToken.IsNullOrEmpty())
{
client.SetBearerToken(accessToken);
}
} }
} }
} }

2
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/NuGet/NuGetService.cs

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

Loading…
Cancel
Save