Browse Source

Merge pull request #16884 from abpframework/auto-merge/rel-7-3/2012

Merge branch dev with rel-7.3
pull/16885/head
Berkan Sasmaz 3 years ago
committed by GitHub
parent
commit
c9e3e31f79
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      docs/en/CLI.md
  2. 2
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/SwitchToNightlyCommand.cs
  3. 2
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/SwitchToPreviewCommand.cs
  4. 2
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/SwitchToStableCommand.cs
  5. 177
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/PackagePreviewSwitcher.cs

10
docs/en/CLI.md

@ -419,7 +419,7 @@ abp remove-proxy -t csharp --folder MyProxies/InnerFolder
### switch-to-preview
You can use this command to switch your project to latest preview version of the ABP framework.
You can use this command to switch your solution or project to latest preview version of the ABP framework.
Usage:
@ -429,12 +429,12 @@ abp switch-to-preview [options]
#### Options
* `--solution-directory` or `-sd`: Specifies the directory. The solution should be in that directory or in any of its sub directories. If not specified, default is the current directory.
* `--directory` or `-d`: Specifies the directory. The solution or project should be in that directory or in any of its sub directories. If not specified, default is the current directory.
### switch-to-nightly
You can use this command to switch your project to latest [nightly](Nightly-Builds.md) preview version of the ABP framework packages.
You can use this command to switch your solution or project to latest [nightly](Nightly-Builds.md) preview version of the ABP framework packages.
Usage:
@ -444,7 +444,7 @@ abp switch-to-nightly [options]
#### Options
* `--solution-directory` or `-sd`: Specifies the directory. The solution should be in that directory or in any of its sub directories. If not specified, default is the current directory.
* `--directory` or `-d`: Specifies the directory. The solution or project should be in that directory or in any of its sub directories. If not specified, default is the current directory.
### switch-to-stable
@ -457,7 +457,7 @@ abp switch-to-stable [options]
````
#### Options
* `--solution-directory` or `-sd`: Specifies the directory. The solution should be in that directory or in any of its sub directories. If not specified, default is the current directory.
* `--directory` or `-d`: Specifies the directory. The solution or project should be in that directory or in any of its sub directories. If not specified, default is the current directory.
### switch-to-local

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

@ -31,7 +31,7 @@ public class SwitchToNightlyCommand : IConsoleCommand, ITransientDependency
sb.AppendLine(" abp switch-to-nightly [options]");
sb.AppendLine("");
sb.AppendLine("Options:");
sb.AppendLine("-sd|--solution-directory");
sb.AppendLine("-d|--directory");
sb.AppendLine("");
sb.AppendLine("See the documentation for more info: https://docs.abp.io/en/abp/latest/CLI");

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

@ -31,7 +31,7 @@ public class SwitchToPreviewCommand : IConsoleCommand, ITransientDependency
sb.AppendLine(" abp switch-to-preview [options]");
sb.AppendLine("");
sb.AppendLine("Options:");
sb.AppendLine("-sd|--solution-directory");
sb.AppendLine("-d|--directory");
sb.AppendLine("");
sb.AppendLine("See the documentation for more info: https://docs.abp.io/en/abp/latest/CLI");

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

@ -31,7 +31,7 @@ public class SwitchToStableCommand : IConsoleCommand, ITransientDependency
sb.AppendLine(" abp switch-to-stable [options]");
sb.AppendLine("");
sb.AppendLine("Options:");
sb.AppendLine("-sd|--solution-directory");
sb.AppendLine("-d|--directory");
sb.AppendLine("");
sb.AppendLine("See the documentation for more info: https://docs.abp.io/en/abp/latest/CLI");

177
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/PackagePreviewSwitcher.cs

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Volo.Abp.Cli.Args;
@ -32,6 +33,37 @@ public class PackagePreviewSwitcher : ITransientDependency
{
var solutionPaths = GetSolutionPaths(commandLineArgs);
if (solutionPaths.Any())
{
await SwitchSolutionsToPreview(solutionPaths);
}
else
{
var projectPaths = GetProjectPaths(commandLineArgs);
await SwitchProjectsToPreview(projectPaths);
}
}
private async Task SwitchProjectsToPreview(List<string> projects)
{
foreach (var project in projects)
{
var folder = Path.GetDirectoryName(project);
await _nugetPackagesVersionUpdater.UpdateProjectAsync(
project,
includeReleaseCandidates: true);
await _npmPackagesUpdater.Update(
folder,
false,
true);
}
}
private async Task SwitchSolutionsToPreview(List<string> solutionPaths)
{
foreach (var solutionPath in solutionPaths)
{
var solutionFolder = Path.GetDirectoryName(solutionPath);
@ -56,69 +88,134 @@ public class PackagePreviewSwitcher : ITransientDependency
}
}
public async Task SwitchToNightlyPreview(CommandLineArgs commandLineArgs)
public async Task SwitchToStable(CommandLineArgs commandLineArgs)
{
var solutionPaths = GetSolutionPaths(commandLineArgs);
if (solutionPaths.Any())
{
await SwitchSolutionsToStable(solutionPaths);
}
else
{
var projectPaths = GetProjectPaths(commandLineArgs);
await SwitchProjectsToStable(projectPaths);
}
}
private async Task SwitchProjectsToStable(List<string> projects)
{
foreach (var project in projects)
{
var folder = Path.GetDirectoryName(project);
await _nugetPackagesVersionUpdater.UpdateProjectAsync(
project,
false,
false,
true);
await _npmPackagesUpdater.Update(
folder,
false,
false,
true);
}
}
private async Task SwitchSolutionsToStable(List<string> solutionPaths)
{
foreach (var solutionPath in solutionPaths)
{
var solutionFolder = Path.GetDirectoryName(solutionPath);
var solutionAngularFolder = GetSolutionAngularFolder(solutionFolder);
_packageSourceManager.Add(solutionFolder, "ABP Nightly", "https://www.myget.org/F/abp-nightly/api/v3/index.json");
_packageSourceManager.Remove(solutionFolder, "ABP Nightly");
if (solutionPath != null)
{
await _nugetPackagesVersionUpdater.UpdateSolutionAsync(
solutionPath,
true);
}
await _nugetPackagesVersionUpdater.UpdateSolutionAsync(
solutionPath,
false,
false,
true);
await _npmPackagesUpdater.Update(
solutionFolder,
false,
false,
true);
if (solutionAngularFolder != null)
{
await _npmPackagesUpdater.Update(
solutionAngularFolder,
false,
false,
true);
}
}
}
public async Task SwitchToStable(CommandLineArgs commandLineArgs)
public async Task SwitchToNightlyPreview(CommandLineArgs commandLineArgs)
{
var solutionPaths = GetSolutionPaths(commandLineArgs);
if (solutionPaths.Any())
{
await SwitchSolutionsToNightlyPreview(solutionPaths);
}
else
{
var projectPaths = GetProjectPaths(commandLineArgs);
await SwitchProjectsToNightlyPreview(projectPaths);
}
}
private async Task SwitchProjectsToNightlyPreview(List<string> projects)
{
foreach (var project in projects)
{
var folder = Path.GetDirectoryName(project);
_packageSourceManager.Add(FindSolutionFolder(project) ?? folder, "ABP Nightly",
"https://www.myget.org/F/abp-nightly/api/v3/index.json");
await _nugetPackagesVersionUpdater.UpdateSolutionAsync(
project,
true);
await _npmPackagesUpdater.Update(
folder,
true);
}
}
private async Task SwitchSolutionsToNightlyPreview(List<string> solutionPaths)
{
foreach (var solutionPath in solutionPaths)
{
var solutionFolder = Path.GetDirectoryName(solutionPath);
var solutionAngularFolder = GetSolutionAngularFolder(solutionFolder);
_packageSourceManager.Remove(solutionFolder, "ABP Nightly");
_packageSourceManager.Add(solutionFolder, "ABP Nightly",
"https://www.myget.org/F/abp-nightly/api/v3/index.json");
if (solutionPath != null)
{
await _nugetPackagesVersionUpdater.UpdateSolutionAsync(
solutionPath,
false,
false,
true);
}
await _npmPackagesUpdater.Update(
solutionFolder,
false,
false,
true);
if (solutionAngularFolder != null)
{
await _npmPackagesUpdater.Update(
solutionAngularFolder,
false,
false,
true);
}
}
@ -126,22 +223,18 @@ public class PackagePreviewSwitcher : ITransientDependency
private List<string> GetSolutionPaths(CommandLineArgs commandLineArgs)
{
var directory = commandLineArgs.Options.GetOrNull(Options.SolutionDirectory.Short, Options.SolutionDirectory.Long)
?? Directory.GetCurrentDirectory();
var solutionPaths = Directory.GetFiles(directory, "*.sln", SearchOption.AllDirectories);
if (!solutionPaths.Any())
{
Logger.LogWarning("No solution (.sln) found to change version.");
}
return Directory.GetFiles(GetDirectory(commandLineArgs), "*.sln", SearchOption.AllDirectories).ToList();
}
return solutionPaths.ToList();
private List<string> GetProjectPaths(CommandLineArgs commandLineArgs)
{
return Directory.GetFiles(GetDirectory(commandLineArgs), "*.csproj", SearchOption.AllDirectories).ToList();
}
private string GetSolutionFolder(CommandLineArgs commandLineArgs)
private string GetDirectory(CommandLineArgs commandLineArgs)
{
return commandLineArgs.Options.GetOrNull(Options.SolutionDirectory.Short, Options.SolutionDirectory.Long)
?? commandLineArgs.Options.GetOrNull(Options.Directory.Short, Options.Directory.Long)
?? Directory.GetCurrentDirectory();
}
@ -160,6 +253,31 @@ public class PackagePreviewSwitcher : ITransientDependency
}
return null;
}
[CanBeNull]
private string FindSolutionFolder(string projectFile)
{
var targetFolder = Path.GetDirectoryName(projectFile);
do
{
if (Directory.GetParent(targetFolder) != null)
{
targetFolder = Directory.GetParent(targetFolder).FullName;
}
else
{
return Path.GetDirectoryName(projectFile);
}
if (Directory.GetFiles(targetFolder, "*.sln", SearchOption.TopDirectoryOnly).Any())
{
break;
}
} while (targetFolder != null);
return targetFolder;
}
public static class Options
@ -169,5 +287,10 @@ public class PackagePreviewSwitcher : ITransientDependency
public const string Short = "sd";
public const string Long = "solution-directory";
}
public static class Directory
{
public const string Short = "d";
public const string Long = "directory";
}
}
}

Loading…
Cancel
Save