Cli: GetSourceCommand & NewCommand --preview option

pull/4782/head
Yunus Emre Kalkan 5 years ago
parent 31c992fe17
commit a04a07a55d

@ -90,6 +90,7 @@ abp new Acme.BookStore
* **`console`**: [Console template](Startup-Templates/Console.md).
* `--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.
* `--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`).
* `--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).

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

@ -61,7 +61,7 @@ namespace Volo.Abp.Cli.Commands
}
commandLineArgs.Options.Add(CliConsts.Command, commandLineArgs.Command);
await _sourceCodeDownloadService.DownloadAsync(
commandLineArgs.Target, outputFolder, version, gitHubAbpLocalRepositoryPath, gitHubVoloLocalRepositoryPath, commandLineArgs.Options);
}
@ -99,6 +99,7 @@ namespace Volo.Abp.Cli.Commands
sb.AppendLine("");
sb.AppendLine("-o|--output-folder <output-folder> (default: current folder)");
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("Examples:");
sb.AppendLine("");
@ -138,6 +139,11 @@ namespace Volo.Abp.Cli.Commands
public const string Short = "v";
public const string Long = "version";
}
public static class Preview
{
public const string Long = "preview";
}
}
}
}

@ -62,6 +62,12 @@ namespace Volo.Abp.Cli.Commands
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);
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("-o|--output-folder <output-folder> (default: current folder)");
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("-csf|--create-solution-folder (default: true)");
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 static class Preview
{
public const string Long = "preview";
}
}
}
}

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

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

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

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

Loading…
Cancel
Save