Browse Source

Cli: Don't allow company name in ms-service generation

pull/13049/head
Yunus Emre Kalkan 4 years ago
parent
commit
17e3cebd49
  1. 38
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs
  2. 2
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/SolutionName.cs

38
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs

@ -129,18 +129,38 @@ public abstract class ProjectCreationCommandBase
SolutionName solutionName; SolutionName solutionName;
if (MicroserviceServiceTemplateBase.IsMicroserviceServiceTemplate(template)) if (MicroserviceServiceTemplateBase.IsMicroserviceServiceTemplate(template))
{ {
var slnFile = Directory.GetFiles(outputFolderRoot, "*.sln").FirstOrDefault(); var slnPath = commandLineArgs.Options.GetOrNull(Options.MainSolution.Short, Options.MainSolution.Long);
if (slnFile == null) if (slnPath == null)
{ {
throw new CliUsageException("This command should be run inside a folder that contains a microservice solution!"); slnPath = Directory.GetFiles(outputFolderRoot, "*.sln").FirstOrDefault();
}
else if (slnPath.EndsWith(".sln"))
{
Directory.SetCurrentDirectory(Path.GetDirectoryName(slnPath));
outputFolderRoot = Path.GetDirectoryName(slnPath);
}
else if (!Directory.Exists(slnPath))
{
slnPath = null;
}
else
{
Directory.SetCurrentDirectory(slnPath);
outputFolderRoot = slnPath;
slnPath = Directory.GetFiles(outputFolderRoot, "*.sln").FirstOrDefault();
}
if (slnPath == null)
{
throw new CliUsageException($"This command should be run inside a folder that contains a microservice solution! Or use -{Options.MainSolution.Short} parameter.");
} }
var microserviceSolutionName = Path.GetFileName(slnFile).RemovePostFix(".sln"); var microserviceSolutionName = Path.GetFileName(slnPath).RemovePostFix(".sln");
version ??= SolutionPackageVersionFinder.Find(slnFile); version ??= SolutionPackageVersionFinder.Find(slnPath);
solutionName = SolutionName.Parse(microserviceSolutionName, projectName); solutionName = SolutionName.Parse(microserviceSolutionName, projectName);
outputFolder = MicroserviceServiceTemplateBase.CalculateTargetFolder(outputFolderRoot, projectName); outputFolder = MicroserviceServiceTemplateBase.CalculateTargetFolder(outputFolderRoot, solutionName.ProjectName);
uiFramework = uiFramework == UiFramework.NotSpecified ? FindMicroserviceSolutionUiFramework(outputFolderRoot) : uiFramework; uiFramework = uiFramework == UiFramework.NotSpecified ? FindMicroserviceSolutionUiFramework(outputFolderRoot) : uiFramework;
} }
else else
@ -512,5 +532,11 @@ public abstract class ProjectCreationCommandBase
{ {
public const string Short = "pwa"; public const string Short = "pwa";
} }
public static class MainSolution
{
public const string Short = "ms";
public const string Long = "main-solution";
}
} }
} }

2
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/SolutionName.cs

@ -19,6 +19,8 @@ public class SolutionName
public static SolutionName Parse(string fullName, string microserviceName) public static SolutionName Parse(string fullName, string microserviceName)
{ {
microserviceName = microserviceName.Replace(".", string.Empty);
return new SolutionName(fullName + "." + microserviceName, fullName, microserviceName); return new SolutionName(fullName + "." + microserviceName, fullName, microserviceName);
} }

Loading…
Cancel
Save