protected override async Task <int> OnExecuteAsync(CommandLineApplication app) { if (TemplateName.IndexOf('/') <= 0 || TemplateName.EndsWith('/')) { Console.WriteLine("Invalid TemplateName!Please Enter As Format aspnetboilerplate/[email protected] "); } if (!Mpa && string.IsNullOrWhiteSpace(SpaType)) { SpaType = Prompt.GetString(SpaTypeDesc, defaultValue: "vue"); SpaType = SpaType.ToLower(); if ("vue,ng,react".IndexOf(SpaType) == -1) { SpaType = "vue"; } } Console.WriteLine($"TemplateName\t:{TemplateName}"); Console.WriteLine($"PlaceHolder\t:{PlaceHolder}"); Console.WriteLine($"ProjectName\t:{ProjectName}"); Console.WriteLine($"MPA\t\t:{Mpa}"); Console.WriteLine($"SpaType\t\t:{SpaType}"); Console.WriteLine($"RenameBackup\t:{RenameBackup}"); //set project folder var projectFolder = Path.Combine(Directory.GetCurrentDirectory(), ProjectName); if (!Directory.Exists(projectFolder)) { Directory.CreateDirectory(projectFolder); } //Fetch Template Zip Console.WriteLine($"Fetching Project Template From Github.com/{TemplateName}..."); var filePath = Path.Combine(projectFolder, $"{ProjectName}.zip"); var tNames = TemplateName.Split(new char[] { '/', '@' }); var userName = string.Empty; var repoName = string.Empty; var tagName = "latest"; if (tNames.Length > 1) { userName = tNames[0]; repoName = tNames[1]; } if (tNames.Length > 2) { tagName = tNames[2]; } await FetchTemplateZipFile(userName, repoName, tagName, filePath); //Extract Zip File Console.WriteLine($"Extracting Project Template Zip:{filePath}..."); Console.WriteLine($"Extracting To:{projectFolder}..."); ExtractZipFile(filePath, projectFolder, repoName); //Folders To Rename Console.WriteLine("Cleaning Sub Dirs in Project Template Folder..."); var excludeFolders = new List <string> { "./vue", "./angular", "./reactjs" }; if (!Mpa) { excludeFolders.Add($"./aspnet-core/src/{PlaceHolder}.Web.Mvc"); //TODO@personball remove web.mvc entry in vs solution file(sln). switch (SpaType.ToLower()) { case "ng": excludeFolders.Remove("./angular"); break; case "react": excludeFolders.Remove("./reactjs"); break; case "vue": default: excludeFolders.Remove("./vue"); break; } } //Delete ExcludeFolders foreach (var excludeFolder in excludeFolders) { var directoryToDel = Path.Combine(projectFolder, excludeFolder); if (Directory.Exists(directoryToDel)) { Console.WriteLine($"ExcludeFolders Delete:{directoryToDel}"); Directory.Delete(directoryToDel, true); } } //Rename Folder var companyNamePlaceHolder = PlaceHolder.Split('.')[0]; var projectNamePlaceHolder = PlaceHolder.Split('.')[1]; var newNames = ProjectName.Split('.'); var newCompanyName = string.Empty; var newProjectName = ProjectName; if (newNames.Length > 1) { newCompanyName = newNames[0]; newProjectName = newNames[1]; } Console.WriteLine($"Renaming {PlaceHolder} to {newCompanyName}{(newNames.Length > 1 ? "." : "")}{newProjectName}..."); var slnRenamer = new SolutionRenamer(projectFolder, companyNamePlaceHolder, projectNamePlaceHolder, newCompanyName, newProjectName) { CreateBackup = RenameBackup }; slnRenamer.Run(); //Delete Template Zip if (File.Exists(filePath)) { File.Delete(filePath); } Console.WriteLine("Init Completed!"); return(1); }
public void NormalizeHtml() { //Make sure there is a full html document defined this.htmlDoc = NormalizeHtmlExtracted(HtmlDoc, TemplateName.EndsWith("Plain")); }