diff --git a/docs/en/Nightly-Builds.md b/docs/en/Nightly-Builds.md index e7ebe0f33b..1a66af32e1 100644 --- a/docs/en/Nightly-Builds.md +++ b/docs/en/Nightly-Builds.md @@ -24,3 +24,18 @@ Now, you can install preview / nightly packages to your project from Nuget Brows 3. Search a package. You will see prereleases of the package formatted as `(VERSION)-preview(DATE)` (like *v0.16.0-preview20190401* in this sample). 4. You can click to the `Install` button to add package to your project. +## Install & Uninstall Preview NPM Packages + +The latest version of preview NPM packages can be installed by the running below command in the root folder of application: + +```bash +abp switch-to-preview +``` + +If you're using the ABP Framework preview packages, you can switch back to stable version using this command: + +```bash +abp switch-to-stable +``` + +See the [ABP CLI documentation](./CLI.md) for more information. \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliUrls.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliUrls.cs index 8c4c8c01f2..1ecc5b1631 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliUrls.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliUrls.cs @@ -3,19 +3,27 @@ public static class CliUrls { #if DEBUG - public const string WwwAbpIo = "https://localhost:44328/"; + public const string WwwAbpIo = WwwAbpIoDevelopment; - public const string AccountAbpIo = "https://localhost:44333/"; + public const string AccountAbpIo = AccountAbpIoDevelopment; - public const string NuGetRootPath = "https://localhost:44373/"; + public const string NuGetRootPath = NuGetRootPathDevelopment; #else - public const string WwwAbpIo = "https://abp.io/"; + public const string WwwAbpIo = WwwAbpIoProduction; - public const string AccountAbpIo = "https://account.abp.io/"; + public const string AccountAbpIo = AccountAbpIoProduction; - public const string NuGetRootPath = "https://nuget.abp.io/"; + public const string NuGetRootPath = NuGetRootPathProduction; #endif + public const string WwwAbpIoProduction = "https://abp.io/"; + public const string AccountAbpIoProduction = "https://account.abp.io/"; + public const string NuGetRootPathProduction = "https://nuget.abp.io/"; + + public const string WwwAbpIoDevelopment = "https://localhost:44328/"; + public const string AccountAbpIoDevelopment = "https://localhost:44333/"; + public const string NuGetRootPathDevelopment = "https://localhost:44373/"; + public static string GetNuGetServiceIndexUrl(string apiKey) { return $"{NuGetRootPath}{apiKey}/v3/index.json"; diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs index 0aa2587e20..2ded43fbf1 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Net.Http; +using System.Reflection; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -52,10 +53,15 @@ namespace Volo.Abp.Cli.ProjectBuilding string version = null, string templateSource = null) { - DirectoryHelper.CreateIfNotExists(CliPaths.TemplateCache); - - var latestVersion = await GetLatestSourceCodeVersionAsync(name, type); + + string latestVersion; + +#if DEBUG + latestVersion = await GetLatestSourceCodeVersionAsync(name, type, $"{CliUrls.WwwAbpIoProduction}api/download/{type}/get-version/"); +#else + latestVersion = await GetLatestSourceCodeVersionAsync(name, type); +#endif if (version == null) { if (latestVersion == null) @@ -64,7 +70,7 @@ namespace Volo.Abp.Cli.ProjectBuilding Logger.LogWarning(string.Empty); Logger.LogWarning("Find the following template in your cache directory: "); Logger.LogWarning("\t Template Name\tVersion"); - + var templateList = GetLocalTemplates(); foreach (var cacheFile in templateList) { @@ -74,12 +80,18 @@ namespace Volo.Abp.Cli.ProjectBuilding 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; - + string nugetVersion; + +#if DEBUG + nugetVersion = version; +#else + nugetVersion = (await GetTemplateNugetVersionAsync(name, type, version)) ?? version; +#endif + if (!string.IsNullOrWhiteSpace(templateSource) && !IsNetworkSource(templateSource)) { Logger.LogInformation("Using local " + type + ": " + name + ", version: " + version); @@ -87,6 +99,14 @@ namespace Volo.Abp.Cli.ProjectBuilding } var localCacheFile = Path.Combine(CliPaths.TemplateCache, name + "-" + version + ".zip"); + +#if DEBUG + if (File.Exists(localCacheFile)) + { + return new TemplateFile(File.ReadAllBytes(localCacheFile), version, latestVersion, nugetVersion); + } +#endif + if (Options.CacheTemplates && File.Exists(localCacheFile) && templateSource.IsNullOrWhiteSpace()) { Logger.LogInformation("Using cached " + type + ": " + name + ", version: " + version); @@ -111,12 +131,14 @@ namespace Volo.Abp.Cli.ProjectBuilding } return new TemplateFile(fileContent, version, latestVersion, nugetVersion); - } - private async Task GetLatestSourceCodeVersionAsync(string name, string type) + private async Task GetLatestSourceCodeVersionAsync(string name, string type, string url) { - var url = $"{CliUrls.WwwAbpIo}api/download/{type}/get-version/"; + if (url == null) + { + url = $"{CliUrls.WwwAbpIo}api/download/{type}/get-version/"; + } try { @@ -224,15 +246,15 @@ namespace Volo.Abp.Cli.ProjectBuilding private List<(string TemplateName, string Version)> GetLocalTemplates() { - var templateList = new List<(string TemplateName, string Version)>(); - + var templateList = new List<(string TemplateName, string Version)>(); + var stringBuilder = new StringBuilder(); foreach (var cacheFile in Directory.GetFiles(CliPaths.TemplateCache)) { stringBuilder.AppendLine(cacheFile); } - var matches = Regex.Matches(stringBuilder.ToString(),$"({AppTemplate.TemplateName}|{AppProTemplate.TemplateName}|{ModuleTemplate.TemplateName}|{ModuleProTemplate.TemplateName})-(.+).zip"); + var matches = Regex.Matches(stringBuilder.ToString(), $"({AppTemplate.TemplateName}|{AppProTemplate.TemplateName}|{ModuleTemplate.TemplateName}|{ModuleProTemplate.TemplateName})-(.+).zip"); foreach (Match match in matches) { templateList.Add((match.Groups[1].Value, match.Groups[2].Value)); diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs index 924fdaf2c9..e8ddc804c2 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateProjectBuilder.cs @@ -4,6 +4,7 @@ using Microsoft.Extensions.Options; using System; using System.Linq; using System.Threading.Tasks; +using Microsoft.Extensions.Configuration; using Volo.Abp.Cli.Commands; using Volo.Abp.Cli.Licensing; using Volo.Abp.Cli.ProjectBuilding.Analyticses; @@ -25,12 +26,15 @@ namespace Volo.Abp.Cli.ProjectBuilding protected IJsonSerializer JsonSerializer { get; } protected IApiKeyService ApiKeyService { get; } + private readonly IConfiguration _configuration; + public TemplateProjectBuilder(ISourceCodeStore sourceCodeStore, ITemplateInfoProvider templateInfoProvider, ICliAnalyticsCollect cliAnalyticsCollect, IOptions options, IJsonSerializer jsonSerializer, - IApiKeyService apiKeyService) + IApiKeyService apiKeyService, + IConfiguration configuration) { SourceCodeStore = sourceCodeStore; TemplateInfoProvider = templateInfoProvider; @@ -38,6 +42,7 @@ namespace Volo.Abp.Cli.ProjectBuilding Options = options.Value; JsonSerializer = jsonSerializer; ApiKeyService = apiKeyService; + _configuration = configuration; Logger = NullLogger.Instance; } @@ -55,7 +60,30 @@ namespace Volo.Abp.Cli.ProjectBuilding args.TemplateSource ); - var apiKeyResult = await ApiKeyService.GetApiKeyOrNullAsync(); + DeveloperApiKeyResult apiKeyResult = null; + +#if DEBUG + try + { + var apiKeyResultSection = _configuration.GetSection("apiKeyResult"); + if (apiKeyResultSection.Exists()) + { + apiKeyResult = apiKeyResultSection.Get(); //you can use user secrets + } + } + catch (Exception e) + { + Console.WriteLine(e); + } + + if (apiKeyResult == null) + { + apiKeyResult = await ApiKeyService.GetApiKeyOrNullAsync(); + } +#else + apiKeyResult = await ApiKeyService.GetApiKeyOrNullAsync(); +#endif + if (apiKeyResult != null) { if (apiKeyResult.ApiKey != null) diff --git a/framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj b/framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj index 2dd1772165..aec34db41a 100644 --- a/framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj +++ b/framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj @@ -1,5 +1,5 @@ + - @@ -9,6 +9,7 @@ true abp + 43599b00-4fa5-4b9f-a314-0757889b296b @@ -17,11 +18,12 @@ + + - - + \ No newline at end of file