public async Task ExecuteAsync(CommandLineArgs commandLineArgs) { if (commandLineArgs.Target == null) { throw new CliUsageException( "Module name is missing!" + Environment.NewLine + Environment.NewLine + GetUsageInfo() ); } var newTemplate = commandLineArgs.Options.ContainsKey(Options.NewTemplate.Long); var template = commandLineArgs.Options.GetOrNull(Options.Template.Short, Options.Template.Long); var newProTemplate = !string.IsNullOrEmpty(template) && template == ModuleProTemplate.TemplateName; var withSourceCode = newTemplate || newProTemplate || commandLineArgs.Options.ContainsKey(Options.SourceCode.Long); var addSourceCodeToSolutionFile = withSourceCode && commandLineArgs.Options.ContainsKey("add-to-solution-file"); var skipDbMigrations = newTemplate || newProTemplate || commandLineArgs.Options.ContainsKey(Options.DbMigrations.Skip); var solutionFile = GetSolutionFile(commandLineArgs); var version = commandLineArgs.Options.GetOrNull(Options.Version.Short, Options.Version.Long); if (version == null) { version = SolutionPackageVersionFinder.Find(solutionFile); } var moduleInfo = await SolutionModuleAdder.AddAsync( solutionFile, commandLineArgs.Target, version, skipDbMigrations, withSourceCode, addSourceCodeToSolutionFile, newTemplate, newProTemplate ); _lastAddedModuleInfo = new AddModuleInfoOutput { DisplayName = moduleInfo.DisplayName, Name = moduleInfo.Name, DocumentationLinks = moduleInfo.DocumentationLinks, InstallationCompleteMessage = moduleInfo.InstallationCompleteMessage }; }
protected ProjectBuildArgs GetProjectBuildArgs(CommandLineArgs commandLineArgs, string template, string projectName) { var version = commandLineArgs.Options.GetOrNull(Options.Version.Short, Options.Version.Long); if (version != null) { Logger.LogInformation("Version: " + version); } var preview = commandLineArgs.Options.ContainsKey(Options.Preview.Long); if (preview) { Logger.LogInformation("Preview: yes"); } var pwa = commandLineArgs.Options.ContainsKey(Options.ProgressiveWebApp.Short); if (pwa) { Logger.LogInformation("Progressive Web App: yes"); } var databaseProvider = GetDatabaseProvider(commandLineArgs); if (databaseProvider != DatabaseProvider.NotSpecified) { Logger.LogInformation("Database provider: " + databaseProvider); } var connectionString = GetConnectionString(commandLineArgs); if (connectionString != null) { Logger.LogInformation("Connection string: " + connectionString); } var databaseManagementSystem = GetDatabaseManagementSystem(commandLineArgs); if (databaseManagementSystem != DatabaseManagementSystem.NotSpecified) { Logger.LogInformation("DBMS: " + databaseManagementSystem); } var uiFramework = GetUiFramework(commandLineArgs); if (uiFramework != UiFramework.NotSpecified) { Logger.LogInformation("UI Framework: " + uiFramework); } var theme = uiFramework == UiFramework.None ? (Theme?)null : GetTheme(commandLineArgs); if (theme.HasValue) { Logger.LogInformation("Theme: " + theme); } var publicWebSite = uiFramework != UiFramework.None && commandLineArgs.Options.ContainsKey(Options.PublicWebSite.Long); if (publicWebSite) { Logger.LogInformation("Public Web Site: yes"); } var mobileApp = GetMobilePreference(commandLineArgs); if (mobileApp != MobileApp.None) { Logger.LogInformation("Mobile App: " + mobileApp); } var gitHubAbpLocalRepositoryPath = commandLineArgs.Options.GetOrNull(Options.GitHubAbpLocalRepositoryPath.Long); if (gitHubAbpLocalRepositoryPath != null) { Logger.LogInformation("GitHub Abp Local Repository Path: " + gitHubAbpLocalRepositoryPath); } var gitHubVoloLocalRepositoryPath = commandLineArgs.Options.GetOrNull(Options.GitHubVoloLocalRepositoryPath.Long); if (gitHubVoloLocalRepositoryPath != null) { Logger.LogInformation("GitHub Volo Local Repository Path: " + gitHubVoloLocalRepositoryPath); } var templateSource = commandLineArgs.Options.GetOrNull(Options.TemplateSource.Short, Options.TemplateSource.Long); if (templateSource != null) { Logger.LogInformation("Template Source: " + templateSource); } var createSolutionFolder = GetCreateSolutionFolderPreference(commandLineArgs); var outputFolder = commandLineArgs.Options.GetOrNull(Options.OutputFolder.Short, Options.OutputFolder.Long); var outputFolderRoot = outputFolder != null?Path.GetFullPath(outputFolder) : Directory.GetCurrentDirectory(); SolutionName solutionName; if (MicroserviceServiceTemplateBase.IsMicroserviceServiceTemplate(template)) { var slnPath = commandLineArgs.Options.GetOrNull(Options.MainSolution.Short, Options.MainSolution.Long); if (slnPath == null) { 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(slnPath).RemovePostFix(".sln"); version ??= SolutionPackageVersionFinder.Find(slnPath); solutionName = SolutionName.Parse(microserviceSolutionName, projectName); outputFolder = MicroserviceServiceTemplateBase.CalculateTargetFolder(outputFolderRoot, solutionName.ProjectName); uiFramework = uiFramework == UiFramework.NotSpecified ? FindMicroserviceSolutionUiFramework(outputFolderRoot) : uiFramework; } else { solutionName = SolutionName.Parse(projectName); outputFolder = createSolutionFolder ? Path.Combine(outputFolderRoot, SolutionName.Parse(projectName).FullName) : outputFolderRoot; } IO.DirectoryHelper.CreateIfNotExists(outputFolder); Logger.LogInformation("Output folder: " + outputFolder); if (connectionString == null && databaseManagementSystem != DatabaseManagementSystem.NotSpecified && databaseManagementSystem != DatabaseManagementSystem.SQLServer) { connectionString = ConnectionStringProvider.GetByDbms(databaseManagementSystem, outputFolder); } commandLineArgs.Options.Add(CliConsts.Command, commandLineArgs.Command); return(new ProjectBuildArgs( solutionName, template, version, outputFolder, databaseProvider, databaseManagementSystem, uiFramework, mobileApp, publicWebSite, gitHubAbpLocalRepositoryPath, gitHubVoloLocalRepositoryPath, templateSource, commandLineArgs.Options, connectionString, pwa, theme )); }