/// <summary> /// Writes End of slugBuilder Summary info. /// </summary> internal virtual void WriteSummary(ExecutionPlan plan, bool isInteractive, CISession ciSession) { Console.WriteLine(); Misc.WriteFinalHeader(plan.PlanStatus, ciSession); // Build dictionary of each Build Stage in order, assigning a letter to each stage. The letter will allow user to see detailed info // about the stage. Dictionary <char, BuildStage> stageInfo = new Dictionary <char, BuildStage>(); char letter = 'A'; foreach (BuildStage buildStage in plan.Plan) { stageInfo.Add(letter, buildStage); letter++; } bool continueLooping = true; while (continueLooping) { // Print info for non interactive sessions if (!isInteractive) { if (Logger.OutputSink.SevereMessages.Count > 0) { CISession.OutputSink.WriteNormal(""); WriteSevereMessages(); WriteStageStats(plan, stageInfo); } } else { CISession.OutputSink.WriteNormal(""); WriteStageStats(plan, stageInfo); CISession.OutputSink.WriteNormal(""); } // Write Version info if successful build if (plan.WasSuccessful) { CISession.OutputSink.WriteSuccess($"Build succeeded on {DateTime.Now.ToString(CultureInfo.CurrentCulture)}"); Console.WriteLine(); Console.WriteLine("Version Built was: ", Color.Yellow); Console.WriteLine(" Semantic Version: " + ciSession.VersionInfo.SemVersionAsString, Color.Yellow); Console.WriteLine(" Assembly Version: " + ciSession.VersionInfo.AssemblyVersion, Color.Yellow); Console.WriteLine(" File Version: " + ciSession.VersionInfo.FileVersion, Color.Yellow); Console.WriteLine(" Info Version: " + ciSession.VersionInfo.InformationalVersion, Color.Yellow); } else { CISession.OutputSink.WriteError($"Build failed on {DateTime.Now.ToString(CultureInfo.CurrentCulture)}"); } // Exit if non-interactive as rest is user prompting and responding if (!isInteractive) { return; } Console.WriteLine("Press (x) to exit, (1) to display git history (9) to view detailed error information OR"); Console.WriteLine(" Press letter from above build stage to see detailed output of that build stage."); ConsoleKeyInfo keyInfo = Console.ReadKey(); if (keyInfo.Key == ConsoleKey.X) { return; } // Detailed error info if (keyInfo.Key == ConsoleKey.D9) { CISession.OutputSink.WriteNormal(""); WriteSevereMessages(); } // Git history if (keyInfo.Key == ConsoleKey.D1) { ciSession.GitProcessor.PrintGitHistory(); Console.WriteLine("Press [space] key to return to menu", Color.Yellow); while (Console.ReadKey().Key != ConsoleKey.Spacebar) { } } // Check to see if letter is in StageInfo Dictionary. char keyPress = keyInfo.KeyChar; if (keyPress > 96) { keyPress = (char)(keyPress - 32); } // Display detailed info about a specific stage... if (stageInfo.ContainsKey(keyPress)) { // Display detailed info BuildStage stage = stageInfo [keyPress]; Console.WriteLine(); Misc.WriteSubHeader(stage.Name, new List <string>() { "Detailed Output" }); Color lineColor = Color.WhiteSmoke; foreach (LineOutColored output in stage.StageOutput) { output.WriteToConsole(); } Console.WriteLine(); Console.WriteLine("Press [space] key to return to menu", Color.Yellow); while (Console.ReadKey().Key != ConsoleKey.Spacebar) { } } } }
/// <summary> /// Displays the Main Menu for SLUGCI /// </summary> /// <param name="ciSession"></param> /// <param name="slugCi"></param> /// <returns></returns> private static bool Menu(CISession ciSession, SlugCI slugCi) { bool keepLooping = true; // Get some variables that are expensive to get, just once. string versionAlpha = ciSession.GitProcessor.GetMostRecentVersionTagOfBranch("alpha").ToString(); string versionBeta = ciSession.GitProcessor.GetMostRecentVersionTagOfBranch("beta").ToString(); string versionMain = ciSession.GitBranches[ciSession.GitProcessor.MainBranchName].LatestSemVersionOnBranch.ToString(); while (keepLooping) { Console.WriteLine(Environment.NewLine); Color lineColor = Color.WhiteSmoke; // Display Git Info / Versions of project string versionPreReleaseName = "alpha"; // Get most recent Version Tag for the desired branch type Misc.WriteSubHeader("Git Project Information"); Console.WriteLine(" {0,-25} | {1,-34}", "Current Branch", ciSession.GitProcessor.CurrentBranch); Console.WriteLine(" {0,-25} | {1,-20}", "Main Branch Name", ciSession.GitProcessor.MainBranchName); Console.WriteLine(" {0,-25} | {1,-20}", "Main Branch Version #", versionMain); Console.WriteLine(" {0,-25} | {1,-20}", "Alpha Branch Version #", versionAlpha); Console.WriteLine(" {0,-25} | {1,-20}", "Beta Branch Version #", versionBeta); Misc.WriteMainHeader("SlugCI Interactive Menu", new List <string>() { ciSession.Solution.Name }); Console.WriteLine(" {0,-30} | {1,-35}", "Target Deploy:", ciSession.PublishTarget.ToString(), lineColor); Console.WriteLine(" {0,-30} | {1,-35}", "Compile Config:", ciSession.CompileConfig, lineColor); // Menu Item Console.WriteLine(" (I) Information about Project", Color.Yellow); // Menu Item Console.WriteLine(" (G) Display Git Command History", lineColor); // Menu Item string ver = ""; if (ciSession.ManuallySetVersion != null) { ver = ciSession.ManuallySetVersion.ToString(); } lineColor = ver != string.Empty ? Color.Yellow : Color.WhiteSmoke; Console.WriteLine(" (V) Manually Set the next version [ " + ver + " ]", lineColor); Console.WriteLine(" (9) Show Next Version #", Color.WhiteSmoke); Console.WriteLine(); // Menu Item Console.WriteLine(" (C) Cleanup Git Repo"); // Menu Item if (ciSession.SkipNuget) { lineColor = Color.Yellow; } else { lineColor = Color.WhiteSmoke; } Console.WriteLine(" (S) Skip Nuget Publish [ " + ciSession.SkipNuget + " ]", lineColor); // Menu Item if (ciSession.SkipAngularBuild) { lineColor = Color.Yellow; } else { lineColor = Color.WhiteSmoke; } Console.WriteLine(" (A) Skip Angular Build & Publish [ " + ciSession.SkipAngularBuild + " ]", lineColor); // Menu Item if (ciSession.SkipTests) { lineColor = Color.Yellow; } else { lineColor = Color.WhiteSmoke; } Console.WriteLine(" (T) Skip All Test Runs [ " + ciSession.SkipTests + " ]", lineColor); // Menu Item if (ciSession.FailedUnitTestsOkay) { lineColor = Color.Yellow; } else { lineColor = Color.WhiteSmoke; } Console.WriteLine(" (U) Failed Unit Tests are okay - continue building: {0}", ciSession.FailedUnitTestsOkay, lineColor); // Menu Item if (ciSession.GitProcessor.AreUncommitedChangesOnLocalBranch) { lineColor = Color.Red; Console.WriteLine(" (R) Refresh Git (You have uncommitted changes on branch). Commit and then issue this command", lineColor); } // Last line of Menu Console.Write(" (X) Exit", Color.Red); Console.WriteLine(); // Set Valid Keys List <ConsoleKey> validKeys = new List <ConsoleKey>() { ConsoleKey.A, ConsoleKey.I, ConsoleKey.C, ConsoleKey.G, ConsoleKey.V, ConsoleKey.R, ConsoleKey.S, ConsoleKey.T, ConsoleKey.U, ConsoleKey.X, ConsoleKey.D9, ConsoleKey.Enter, }; ConsoleKey answer = PromptAndGetResponse(ConsoleKey.Enter, validKeys, "Press Enter to start the Build Process OR Select an Item"); if (answer == ConsoleKey.I) { slugCi.DisplayInfo(); } else if (answer == ConsoleKey.Enter && !ciSession.GitProcessor.AreUncommitedChangesOnLocalBranch) { return(true); } else if (answer == ConsoleKey.V) { ManualVersionPrompts(ciSession, slugCi); } else if (answer == ConsoleKey.S) { ciSession.SkipNuget = !ciSession.SkipNuget; } else if (answer == ConsoleKey.A) { ciSession.SkipAngularBuild = !ciSession.SkipAngularBuild; } else if (answer == ConsoleKey.X) { return(false); } else if (answer == ConsoleKey.R) { ciSession.GitProcessor.RefreshUncommittedChanges(); } else if (answer == ConsoleKey.T) { ciSession.SkipTests = true; } else if (answer == ConsoleKey.U) { ciSession.FailedUnitTestsOkay = true; } else if (answer == ConsoleKey.G) { ciSession.GitProcessor.PrintGitHistory(); Console.WriteLine("Press [space] key to return to menu", Color.Yellow); while (Console.ReadKey().Key != ConsoleKey.Spacebar) { } } else if (answer == ConsoleKey.D9) { BuildStage_CalcVersion calcVersion = new BuildStage_CalcVersion(ciSession); calcVersion.Execute(); Console.WriteLine("{0}{0}", Environment.NewLine); Console.WriteLine("Next version will be: ", Color.DarkCyan); Console.WriteLine(" Assembly Version: {0}", ciSession.VersionInfo.AssemblyVersion); Console.WriteLine(" File Version: {0}", ciSession.VersionInfo.FileVersion); Console.WriteLine(" Informational Version: {0}", ciSession.VersionInfo.InformationalVersion); Console.WriteLine(" SemVersion: {0}", ciSession.VersionInfo.SemVersionAsString); Console.WriteLine(" NPM Version: {0}", ciSession.VersionInfo.NPMVersion); Console.WriteLine("{0}{0}Press any key to return to menu", Environment.NewLine); Console.ReadKey(); Console.Clear(); } else if (answer == ConsoleKey.C) { BuildStage_GitCleanup gitCleanup = new BuildStage_GitCleanup(ciSession); if (!gitCleanup.Execute()) { Console.WriteLine("Git Cleanup Failed."); } else { Console.WriteLine("Git Cleanup Success!"); } Console.WriteLine("Press any key to continue"); Console.ReadKey(); } Console.Clear(); } return(true); }