Browse Source

Cli: GetSourceCommand & NewCommand --preview option

pull/4782/head
Yunus Emre Kalkan 6 years ago
parent
commit
a04a07a55d
  1. 1
      docs/en/CLI.md
  2. 2
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs
  3. 8
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GetSourceCommand.cs
  4. 12
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs
  5. 20
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs
  6. 5
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/ISourceCodeStore.cs
  7. 4
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/ModuleProjectBuilder.cs
  8. 4
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs

1
docs/en/CLI.md

@ -90,6 +90,7 @@ abp new Acme.BookStore
* **`console`**: [Console template](Startup-Templates/Console.md). * **`console`**: [Console template](Startup-Templates/Console.md).
* `--output-folder` or `-o`: Specifies the output folder. Default value is the current directory. * `--output-folder` or `-o`: Specifies the output folder. Default value is the current directory.
* `--version` or `-v`: Specifies the ABP & template version. It can be a [release tag](https://github.com/abpframework/abp/releases) or a [branch name](https://github.com/abpframework/abp/branches). Uses the latest release if not specified. Most of the times, you will want to use the latest version. * `--version` or `-v`: Specifies the ABP & template version. It can be a [release tag](https://github.com/abpframework/abp/releases) or a [branch name](https://github.com/abpframework/abp/branches). Uses the latest release if not specified. Most of the times, you will want to use the latest version.
* `--preview`: Use latest pre-release version (Only if `--version ` is not specified and there is at least one pre-release after latest stable version).
* `--template-source` or `-ts`: Specifies a custom template source to use to build the project. Local and network sources can be used(Like `D:\local-template` or `https://.../my-template-file.zip`). * `--template-source` or `-ts`: Specifies a custom template source to use to build the project. Local and network sources can be used(Like `D:\local-template` or `https://.../my-template-file.zip`).
* `--create-solution-folder` or `-csf`: Specifies if the project will be in a new folder in the output folder or directly the output folder. * `--create-solution-folder` or `-csf`: Specifies if the project will be in a new folder in the output folder or directly the output folder.
* `--connection-string` or `-cs`: Overwrites the default connection strings in all `appsettings.json` files. The default connection string is `Server=localhost;Database=MyProjectName;Trusted_Connection=True;MultipleActiveResultSets=true` for EF Core and it is configured to use the SQL Server. If you want to use the EF Core, but need to change the DBMS, you can change it as [described here](Entity-Framework-Core-Other-DBMS.md) (after creating the solution). * `--connection-string` or `-cs`: Overwrites the default connection strings in all `appsettings.json` files. The default connection string is `Server=localhost;Database=MyProjectName;Trusted_Connection=True;MultipleActiveResultSets=true` for EF Core and it is configured to use the SQL Server. If you want to use the EF Core, but need to change the DBMS, you can change it as [described here](Entity-Framework-Core-Other-DBMS.md) (after creating the solution).

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

@ -158,7 +158,7 @@ namespace Volo.Abp.Cli
return await NuGetService.GetLatestVersionOrNullAsync("Volo.Abp.Cli"); return await NuGetService.GetLatestVersionOrNullAsync("Volo.Abp.Cli");
case UpdateChannel.Prerelease: case UpdateChannel.Prerelease:
return await NuGetService.GetLatestVersionOrNullAsync("Volo.Abp.Cli", includePreviews: true); return await NuGetService.GetLatestVersionOrNullAsync("Volo.Abp.Cli", includeReleaseCandidates: true);
case UpdateChannel.Nightly: case UpdateChannel.Nightly:
return await NuGetService.GetLatestVersionOrNullAsync("Volo.Abp.Cli", includeNightly: true); return await NuGetService.GetLatestVersionOrNullAsync("Volo.Abp.Cli", includeNightly: true);

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

@ -61,7 +61,7 @@ namespace Volo.Abp.Cli.Commands
} }
commandLineArgs.Options.Add(CliConsts.Command, commandLineArgs.Command); commandLineArgs.Options.Add(CliConsts.Command, commandLineArgs.Command);
await _sourceCodeDownloadService.DownloadAsync( await _sourceCodeDownloadService.DownloadAsync(
commandLineArgs.Target, outputFolder, version, gitHubAbpLocalRepositoryPath, gitHubVoloLocalRepositoryPath, commandLineArgs.Options); commandLineArgs.Target, outputFolder, version, gitHubAbpLocalRepositoryPath, gitHubVoloLocalRepositoryPath, commandLineArgs.Options);
} }
@ -99,6 +99,7 @@ namespace Volo.Abp.Cli.Commands
sb.AppendLine(""); sb.AppendLine("");
sb.AppendLine("-o|--output-folder <output-folder> (default: current folder)"); sb.AppendLine("-o|--output-folder <output-folder> (default: current folder)");
sb.AppendLine("-v|--version <version> (default: latest version)"); sb.AppendLine("-v|--version <version> (default: latest version)");
sb.AppendLine("--preview (Use latest pre-release version if there is at least one pre-release after latest stable version)");
sb.AppendLine(""); sb.AppendLine("");
sb.AppendLine("Examples:"); sb.AppendLine("Examples:");
sb.AppendLine(""); sb.AppendLine("");
@ -138,6 +139,11 @@ namespace Volo.Abp.Cli.Commands
public const string Short = "v"; public const string Short = "v";
public const string Long = "version"; public const string Long = "version";
} }
public static class Preview
{
public const string Long = "preview";
}
} }
} }
} }

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

@ -62,6 +62,12 @@ namespace Volo.Abp.Cli.Commands
Logger.LogInformation("Tiered: yes"); Logger.LogInformation("Tiered: yes");
} }
var preview = commandLineArgs.Options.ContainsKey(Options.Preview.Long);
if (preview)
{
Logger.LogInformation("Preview: yes if any exist for next version.");
}
var databaseProvider = GetDatabaseProvider(commandLineArgs); var databaseProvider = GetDatabaseProvider(commandLineArgs);
if (databaseProvider != DatabaseProvider.NotSpecified) if (databaseProvider != DatabaseProvider.NotSpecified)
{ {
@ -218,6 +224,7 @@ namespace Volo.Abp.Cli.Commands
sb.AppendLine("-d|--database-provider <database-provider> (if supported by the template)"); sb.AppendLine("-d|--database-provider <database-provider> (if supported by the template)");
sb.AppendLine("-o|--output-folder <output-folder> (default: current folder)"); sb.AppendLine("-o|--output-folder <output-folder> (default: current folder)");
sb.AppendLine("-v|--version <version> (default: latest version)"); sb.AppendLine("-v|--version <version> (default: latest version)");
sb.AppendLine("--preview (Use latest pre-release version if there is at least one pre-release after latest stable version)");
sb.AppendLine("-ts|--template-source <template-source> (your local or network abp template source)"); sb.AppendLine("-ts|--template-source <template-source> (your local or network abp template source)");
sb.AppendLine("-csf|--create-solution-folder (default: true)"); sb.AppendLine("-csf|--create-solution-folder (default: true)");
sb.AppendLine("-cs|--connection-string <connection-string> (your database connection string)"); sb.AppendLine("-cs|--connection-string <connection-string> (your database connection string)");
@ -369,6 +376,11 @@ namespace Volo.Abp.Cli.Commands
{ {
public const string Long = "tiered"; public const string Long = "tiered";
} }
public static class Preview
{
public const string Long = "preview";
}
} }
} }
} }

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

@ -52,10 +52,11 @@ namespace Volo.Abp.Cli.ProjectBuilding
string name, string name,
string type, string type,
string version = null, string version = null,
string templateSource = null) string templateSource = null,
bool includePreReleases = false)
{ {
DirectoryHelper.CreateIfNotExists(CliPaths.TemplateCache); DirectoryHelper.CreateIfNotExists(CliPaths.TemplateCache);
var latestVersion = version ?? await GetLatestSourceCodeVersionAsync(name, type); var latestVersion = version ?? await GetLatestSourceCodeVersionAsync(name, type, null, includePreReleases);
if (version == null) if (version == null)
{ {
@ -110,7 +111,8 @@ namespace Volo.Abp.Cli.ProjectBuilding
Name = name, Name = name,
Type = type, Type = type,
TemplateSource = templateSource, TemplateSource = templateSource,
Version = version Version = version,
IncludePreReleases = includePreReleases
} }
); );
@ -122,7 +124,7 @@ namespace Volo.Abp.Cli.ProjectBuilding
return new TemplateFile(fileContent, version, latestVersion, nugetVersion); return new TemplateFile(fileContent, version, latestVersion, nugetVersion);
} }
private async Task<string> GetLatestSourceCodeVersionAsync(string name, string type, string url = null) private async Task<string> GetLatestSourceCodeVersionAsync(string name, string type, string url = null, bool includePreReleases = false)
{ {
if (url == null) if (url == null)
{ {
@ -137,7 +139,7 @@ namespace Volo.Abp.Cli.ProjectBuilding
url, url,
new StringContent( new StringContent(
JsonSerializer.Serialize( JsonSerializer.Serialize(
new GetLatestSourceCodeVersionDto { Name = name } new GetLatestSourceCodeVersionDto { Name = name, IncludePreReleases = includePreReleases }
), ),
Encoding.UTF8, Encoding.UTF8,
MimeTypes.Application.Json MimeTypes.Application.Json
@ -171,7 +173,7 @@ namespace Volo.Abp.Cli.ProjectBuilding
url, url,
new StringContent( new StringContent(
JsonSerializer.Serialize( JsonSerializer.Serialize(
new GetTemplateNugetVersionDto { Name = name, Version = version } new GetTemplateNugetVersionDto { Name = name, Version = version}
), ),
Encoding.UTF8, Encoding.UTF8,
MimeTypes.Application.Json MimeTypes.Application.Json
@ -260,11 +262,15 @@ namespace Volo.Abp.Cli.ProjectBuilding
public string Type { get; set; } public string Type { get; set; }
public string TemplateSource { get; set; } public string TemplateSource { get; set; }
public bool IncludePreReleases { get; set; }
} }
public class GetLatestSourceCodeVersionDto public class GetLatestSourceCodeVersionDto
{ {
public string Name { get; set; } public string Name { get; set; }
public bool IncludePreReleases { get; set; }
} }
public class GetTemplateNugetVersionDto public class GetTemplateNugetVersionDto
@ -272,6 +278,8 @@ namespace Volo.Abp.Cli.ProjectBuilding
public string Name { get; set; } public string Name { get; set; }
public string Version { get; set; } public string Version { get; set; }
public bool IncludePreReleases { get; set; }
} }
public class GetVersionResultDto public class GetVersionResultDto

5
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/ISourceCodeStore.cs

@ -9,7 +9,8 @@ namespace Volo.Abp.Cli.ProjectBuilding
string name, string name,
string type, string type,
[CanBeNull] string version = null, [CanBeNull] string version = null,
[CanBeNull] string templateSource = null [CanBeNull] string templateSource = null,
bool includePreReleases = false
); );
} }
} }

4
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/ModuleProjectBuilder.cs

@ -48,7 +48,9 @@ namespace Volo.Abp.Cli.ProjectBuilding
var templateFile = await SourceCodeStore.GetAsync( var templateFile = await SourceCodeStore.GetAsync(
args.TemplateName, args.TemplateName,
SourceCodeTypes.Module, SourceCodeTypes.Module,
args.Version args.Version,
null,
args.ExtraProperties.ContainsKey(GetSourceCommand.Options.Preview.Long)
); );
var apiKeyResult = await ApiKeyService.GetApiKeyOrNullAsync(); var apiKeyResult = await ApiKeyService.GetApiKeyOrNullAsync();

4
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs

@ -57,7 +57,8 @@ namespace Volo.Abp.Cli.ProjectBuilding
args.TemplateName, args.TemplateName,
SourceCodeTypes.Template, SourceCodeTypes.Template,
args.Version, args.Version,
args.TemplateSource args.TemplateSource,
args.ExtraProperties.ContainsKey(NewCommand.Options.Preview.Long)
); );
DeveloperApiKeyResult apiKeyResult = null; DeveloperApiKeyResult apiKeyResult = null;
@ -119,6 +120,7 @@ namespace Volo.Abp.Cli.ProjectBuilding
var options = args.ExtraProperties var options = args.ExtraProperties
.Where(x => !x.Key.Equals(CliConsts.Command, StringComparison.InvariantCultureIgnoreCase)) .Where(x => !x.Key.Equals(CliConsts.Command, StringComparison.InvariantCultureIgnoreCase))
.Where(x => !x.Key.Equals(NewCommand.Options.Tiered.Long, StringComparison.InvariantCultureIgnoreCase)) .Where(x => !x.Key.Equals(NewCommand.Options.Tiered.Long, StringComparison.InvariantCultureIgnoreCase))
.Where(x => !x.Key.Equals(NewCommand.Options.Preview.Long, StringComparison.InvariantCultureIgnoreCase))
.Where(x => !x.Key.Equals(NewCommand.Options.DatabaseProvider.Long, StringComparison.InvariantCultureIgnoreCase) && .Where(x => !x.Key.Equals(NewCommand.Options.DatabaseProvider.Long, StringComparison.InvariantCultureIgnoreCase) &&
!x.Key.Equals(NewCommand.Options.DatabaseProvider.Short, StringComparison.InvariantCultureIgnoreCase)) !x.Key.Equals(NewCommand.Options.DatabaseProvider.Short, StringComparison.InvariantCultureIgnoreCase))
.Where(x => !x.Key.Equals(NewCommand.Options.OutputFolder.Long, StringComparison.InvariantCultureIgnoreCase) && .Where(x => !x.Key.Equals(NewCommand.Options.OutputFolder.Long, StringComparison.InvariantCultureIgnoreCase) &&

Loading…
Cancel
Save