Browse Source

Merge pull request #17064 from abpframework/suite-option-for-target-solution

Cli: Option for ABP Suite to be opened with a target solution
pull/17066/head
Engincan VESKE 3 years ago
committed by GitHub
parent
commit
61fca45eef
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 36
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/SuiteCommand.cs

36
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/SuiteCommand.cs

@ -83,7 +83,7 @@ public class SuiteCommand : IConsoleCommand, ITransientDependency
case null: case null:
await InstallSuiteIfNotInstalledAsync(currentSuiteVersionAsString); await InstallSuiteIfNotInstalledAsync(currentSuiteVersionAsString);
_abpSuitePort = await _suiteAppSettingsService.GetSuitePortAsync(currentSuiteVersionAsString); _abpSuitePort = await _suiteAppSettingsService.GetSuitePortAsync(currentSuiteVersionAsString);
RunSuite(); RunSuite(commandLineArgs);
break; break;
case "generate": case "generate":
@ -418,7 +418,7 @@ public class SuiteCommand : IConsoleCommand, ITransientDependency
CmdHelper.RunCmd("dotnet tool uninstall " + SuitePackageName + " -g"); CmdHelper.RunCmd("dotnet tool uninstall " + SuitePackageName + " -g");
} }
private void RunSuite() private void RunSuite(CommandLineArgs commandLineArgs)
{ {
try try
{ {
@ -433,11 +433,16 @@ public class SuiteCommand : IConsoleCommand, ITransientDependency
{ {
Logger.LogWarning("Couldn't check ABP Suite installed status: " + ex.Message); Logger.LogWarning("Couldn't check ABP Suite installed status: " + ex.Message);
} }
var targetSolution = GetTargetSolutionOrNull(commandLineArgs);
var launchUrl = targetSolution == null?
$"http://localhost:{_abpSuitePort}":
$"http://localhost:{_abpSuitePort}/CrudPageGenerator/Create?targetSolution={targetSolution}";
if (IsSuiteAlreadyRunning()) if (IsSuiteAlreadyRunning())
{ {
Logger.LogInformation("Opening suite..."); Logger.LogInformation("Opening suite...");
CmdHelper.Open($"http://localhost:{_abpSuitePort}"); CmdHelper.Open(launchUrl);
return; return;
} }
@ -447,7 +452,28 @@ public class SuiteCommand : IConsoleCommand, ITransientDependency
return; return;
} }
CmdHelper.RunCmd("abp-suite"); if (targetSolution == null)
{
CmdHelper.RunCmd("abp-suite");
}
else
{
new Thread(OpenSuiteInBrowserWithLaunchUrl).Start();
CmdHelper.RunCmd("abp-suite --no-browser");
void OpenSuiteInBrowserWithLaunchUrl()
{
Thread.Sleep(2500); // needed for suite to be ready.
CmdHelper.Open(launchUrl);
}
}
}
private object GetTargetSolutionOrNull(CommandLineArgs commandLineArgs)
{
return commandLineArgs.Options.GetOrNull(Options.Crud.Solution.Short, Options.Crud.Solution.Long)
?? Directory.GetFiles(Directory.GetCurrentDirectory(), "*.sln", SearchOption.TopDirectoryOnly).FirstOrDefault();
} }
private Process StartSuite() private Process StartSuite()

Loading…
Cancel
Save