Browse Source

Cli: Switch-To commands update all available solutions in subfolders

pull/13051/head
Yunus Emre Kalkan 4 years ago
parent
commit
eb7f1961d4
  1. 134
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/PackagePreviewSwitcher.cs

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

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -29,114 +30,113 @@ public class PackagePreviewSwitcher : ITransientDependency
public async Task SwitchToPreview(CommandLineArgs commandLineArgs) public async Task SwitchToPreview(CommandLineArgs commandLineArgs)
{ {
var solutionPath = GetSolutionPath(commandLineArgs); var solutionPaths = GetSolutionPaths(commandLineArgs);
var solutionFolder = GetSolutionFolder(commandLineArgs);
var solutionAngularFolder = GetSolutionAngularFolder(solutionFolder);
await _nugetPackagesVersionUpdater.UpdateSolutionAsync( foreach (var solutionPath in solutionPaths)
solutionPath, {
includeReleaseCandidates: true); var solutionFolder = Path.GetDirectoryName(solutionPath);
var solutionAngularFolder = GetSolutionAngularFolder(solutionFolder);
await _npmPackagesUpdater.Update( await _nugetPackagesVersionUpdater.UpdateSolutionAsync(
solutionFolder, solutionPath,
false, includeReleaseCandidates: true);
true);
if (solutionAngularFolder != null)
{
await _npmPackagesUpdater.Update( await _npmPackagesUpdater.Update(
solutionAngularFolder, solutionFolder,
false, false,
true); true);
if (solutionAngularFolder != null)
{
await _npmPackagesUpdater.Update(
solutionAngularFolder,
false,
true);
}
} }
} }
public async Task SwitchToNightlyPreview(CommandLineArgs commandLineArgs) public async Task SwitchToNightlyPreview(CommandLineArgs commandLineArgs)
{ {
var solutionPath = GetSolutionPath(commandLineArgs); var solutionPaths = GetSolutionPaths(commandLineArgs);
var solutionFolder = GetSolutionFolder(commandLineArgs);
var solutionAngularFolder = GetSolutionAngularFolder(solutionFolder);
_packageSourceManager.Add(solutionFolder, "ABP Nightly", "https://www.myget.org/F/abp-nightly/api/v3/index.json");
if (solutionPath != null) foreach (var solutionPath in solutionPaths)
{ {
await _nugetPackagesVersionUpdater.UpdateSolutionAsync( var solutionFolder = Path.GetDirectoryName(solutionPath);
solutionPath, var solutionAngularFolder = GetSolutionAngularFolder(solutionFolder);
true);
}
await _npmPackagesUpdater.Update( _packageSourceManager.Add(solutionFolder, "ABP Nightly", "https://www.myget.org/F/abp-nightly/api/v3/index.json");
solutionFolder,
true); if (solutionPath != null)
{
await _nugetPackagesVersionUpdater.UpdateSolutionAsync(
solutionPath,
true);
}
if (solutionAngularFolder != null)
{
await _npmPackagesUpdater.Update( await _npmPackagesUpdater.Update(
solutionAngularFolder, solutionFolder,
true); true);
if (solutionAngularFolder != null)
{
await _npmPackagesUpdater.Update(
solutionAngularFolder,
true);
}
} }
} }
public async Task SwitchToStable(CommandLineArgs commandLineArgs) public async Task SwitchToStable(CommandLineArgs commandLineArgs)
{ {
var solutionPath = GetSolutionPath(commandLineArgs); var solutionPaths = GetSolutionPaths(commandLineArgs);
var solutionFolder = GetSolutionFolder(commandLineArgs);
var solutionAngularFolder = GetSolutionAngularFolder(solutionFolder);
_packageSourceManager.Remove(solutionFolder, "ABP Nightly"); foreach (var solutionPath in solutionPaths)
if (solutionPath != null)
{ {
await _nugetPackagesVersionUpdater.UpdateSolutionAsync( var solutionFolder = Path.GetDirectoryName(solutionPath);
solutionPath, var solutionAngularFolder = GetSolutionAngularFolder(solutionFolder);
false,
false,
true);
}
await _npmPackagesUpdater.Update( _packageSourceManager.Remove(solutionFolder, "ABP Nightly");
solutionFolder,
false, if (solutionPath != null)
false, {
true); await _nugetPackagesVersionUpdater.UpdateSolutionAsync(
solutionPath,
false,
false,
true);
}
if (solutionAngularFolder != null)
{
await _npmPackagesUpdater.Update( await _npmPackagesUpdater.Update(
solutionAngularFolder, solutionFolder,
false, false,
false, false,
true); true);
if (solutionAngularFolder != null)
{
await _npmPackagesUpdater.Update(
solutionAngularFolder,
false,
false,
true);
}
} }
} }
private string GetSolutionPath(CommandLineArgs commandLineArgs) private List<string> GetSolutionPaths(CommandLineArgs commandLineArgs)
{ {
var directory = commandLineArgs.Options.GetOrNull(Options.SolutionDirectory.Short, Options.SolutionDirectory.Long) var directory = commandLineArgs.Options.GetOrNull(Options.SolutionDirectory.Short, Options.SolutionDirectory.Long)
?? Directory.GetCurrentDirectory(); ?? Directory.GetCurrentDirectory();
var solutionPath = Directory.GetFiles(directory, "*.sln").FirstOrDefault(); var solutionPaths = Directory.GetFiles(directory, "*.sln", SearchOption.AllDirectories);
if (solutionPath == null) if (!solutionPaths.Any())
{ {
var subDirectories = Directory.GetDirectories(directory); Logger.LogWarning("No solution (.sln) found to change version.");
foreach (var subDirectory in subDirectories)
{
var slnInSubDirectory = Directory.GetFiles(subDirectory, "*.sln").FirstOrDefault();
if (slnInSubDirectory != null)
{
return Path.Combine(subDirectory, slnInSubDirectory);
}
}
Logger.LogWarning("There is no solution or more that one solution in current directory.");
return null;
} }
return solutionPath; return solutionPaths.ToList();
} }
private string GetSolutionFolder(CommandLineArgs commandLineArgs) private string GetSolutionFolder(CommandLineArgs commandLineArgs)

Loading…
Cancel
Save