diff --git a/.cheese/scripts/i18n.cs b/.cheese/scripts/i18n.cs new file mode 100644 index 0000000..cf1a83f --- /dev/null +++ b/.cheese/scripts/i18n.cs @@ -0,0 +1,46 @@ +ο»Ώusing System.Diagnostics; +using Common.BasicHelper.Core.Shell; +using Common.BasicHelper.Utils.Extensions; +using Spectre.Console; + +var utilsToLaunch = AnsiConsole.Prompt( + new MultiSelectionPrompt() + .Title("Which [green]i18n utils[/] are to be launched ?") + .NotRequired() + .PageSize(10) + .MoreChoicesText("[grey](Move up and down to reveal more utils)[/]") + .InstructionsText("[grey](Press [blue][/] to toggle a i18n util, [green][/] to accept)[/]") + .AddChoices( + new[] { + "KitX Dashboard (XamlMLE)" + } + ) + ); + +var baseDir = PathHelper.Instance.BaseSlnDir; + +foreach (var util in utilsToLaunch) +{ + AnsiConsole.MarkupLine($"@ Launching {util}"); + + switch (util) + { + case "KitX Dashboard (XamlMLE)": + var xamlMleDir = $"{baseDir}/KitX SDK/Reference/XamlMultiLanguageEditor".GetFullPath(); + var scriptPath = $"{xamlMleDir}/run.ps1".GetFullPath(); + + var args = new StringBuilder() + .Append($" -WorkingDirectory \"{xamlMleDir}\"") + .Append($" -Command \"& '{scriptPath}'\"") + .ToString() + ; + + Console.WriteLine(args); + + var result = "pwsh".ExecuteAsCommand(args: args, findInPath: true); + + Console.WriteLine(result); + + break; + } +} diff --git a/.cheese/scripts/publish.cs b/.cheese/scripts/publish.cs index 4345091..027e51b 100644 --- a/.cheese/scripts/publish.cs +++ b/.cheese/scripts/publish.cs @@ -7,7 +7,8 @@ AnsiConsole.Write( new FigletText("KitX Publisher") .Centered() - .Color(Color.Blue)); + .Color(Color.Blue) +); PathHelper.Instance.AssertInSlnDirectory(out _); @@ -42,111 +43,111 @@ const string prompt = "[white]>>>[/]"; -AnsiConsole.Progress() - .Columns(new ProgressColumn[] +AnsiConsole + .Progress() + .Columns( + new ProgressColumn[] { new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn(), - // new RemainingTimeColumn(), new SpinnerColumn(), - }) - .Start(ctx => - { - var genTask = ctx.AddTask("[green]Publishing[/]"); - var packTask = ctx.AddTask("[blue]Packing[/]"); - - { - AnsiConsole.Write(new Rule($"[blue]Begin Generating[/]")); - - AnsiConsole.MarkupLine($"{prompt} Found {files.Length} profiles"); - AnsiConsole.Markup($"{prompt} Generating logs at: \"{Path.GetRelativePath(baseDir, log)}\""); - AnsiConsole.WriteLine(); - - packTask.IsIndeterminate = true; + } + ) + .Start(ctx => + { + var genTask = ctx.AddTask("[green]Publishing[/]"); + var packTask = ctx.AddTask("[blue]Packing[/]"); - foreach (var item in files) - { - var index = executingThreadIndex++; - var filename = Path.GetFileName(item); - const string cmd = "dotnet"; - var arg = $"publish \"{(path + "/KitX.Dashboard.csproj").GetFullPath()}\" \"/p:PublishProfile={item}\""; - - AnsiConsole.MarkupLine($"{prompt} πŸ“„ [white]{filename}[/]: [gray]{cmd} {arg}[/]"); + { + AnsiConsole.Write(new Rule($"[blue]Begin Generating[/]")); - var process = new Process(); - var psi = new ProcessStartInfo() - { - FileName = cmd, - Arguments = arg, - UseShellExecute = false, - CreateNoWindow = true, - RedirectStandardOutput = true, - RedirectStandardError = true - }; - process.StartInfo = psi; - process.Start(); + AnsiConsole.MarkupLine($"{prompt} Found {files.Length} profiles"); + AnsiConsole.Markup($"{prompt} Generating logs at: \"{Path.GetRelativePath(baseDir, log)}\""); + AnsiConsole.WriteLine(); - while (!process.StandardOutput.EndOfStream) - { - var line = process.StandardOutput.ReadLine(); + packTask.IsIndeterminate = true; - File.AppendAllText(log, Environment.NewLine + line); - } + foreach (var item in files) + { + var index = executingThreadIndex++; + var filename = Path.GetFileName(item); + const string cmd = "dotnet"; + var arg = $"publish \"{(path + "/KitX.Dashboard.csproj").GetFullPath()}\" \"/p:PublishProfile={item}\""; - // Thread.Sleep(700); + AnsiConsole.MarkupLine($"{prompt} πŸ“„ [white]{filename}[/]: [gray]{cmd} {arg}[/]"); - process.WaitForExit(); + var process = new Process(); + var psi = new ProcessStartInfo() + { + FileName = cmd, + Arguments = arg, + UseShellExecute = false, + CreateNoWindow = true, + RedirectStandardOutput = true, + RedirectStandardError = true + }; + process.StartInfo = psi; + process.Start(); + + while (!process.StandardOutput.EndOfStream) + { + var line = process.StandardOutput.ReadLine(); - ++finishedThreads; + File.AppendAllText(log, Environment.NewLine + line); + } - genTask.Increment((1.0 / files.Length) * 100); + process.WaitForExit(); - AnsiConsole.MarkupLine($"{prompt} Finished task_{index}, still {files.Length - finishedThreads} tasks waiting"); + ++finishedThreads; - AnsiConsole.Write(new Rule($"[red]Finished task-{index}[/]")); - } + genTask.Increment((1.0 / files.Length) * 100); - AnsiConsole.MarkupLine($"{prompt} All tasks done."); + AnsiConsole.MarkupLine($"{prompt} Finished task_{index}, still {files.Length - finishedThreads} tasks waiting"); - genTask.StopTask(); + AnsiConsole.Write(new Rule($"[red]Finished task-{index}[/]")); } - { - AnsiConsole.MarkupLine($"{prompt} Begin packing."); + AnsiConsole.MarkupLine($"{prompt} All tasks done."); - packTask.IsIndeterminate = false; + genTask.StopTask(); + } - var ignoredDirectories = JsonSerializer.Deserialize>(File.ReadAllText(packIgnore)); + { + AnsiConsole.MarkupLine($"{prompt} Begin packing."); - var folders = new DirectoryInfo(publishDir).GetDirectories().ToList(); + packTask.IsIndeterminate = false; - folders.RemoveAll(f => ignoredDirectories.Contains(f.Name)); + var ignoredDirectories = JsonSerializer.Deserialize>(File.ReadAllText(packIgnore)); - foreach (var folder in folders) - { - var name = folder.Name; - var zipFileName = $"{publishDir}/{name}.zip"; + var folders = new DirectoryInfo(publishDir).GetDirectories().ToList(); - AnsiConsole.MarkupLine($"{prompt} Packing πŸ“‚ [yellow]{name}[/]"); + folders.RemoveAll(f => ignoredDirectories.Contains(f.Name)); - if (File.Exists(zipFileName)) - File.Delete(zipFileName); + foreach (var folder in folders) + { + var name = folder.Name; + var zipFileName = $"{publishDir}/{name}.zip"; - ZipFile.CreateFromDirectory( - folder.FullName, - zipFileName, - CompressionLevel.SmallestSize, - true - ); + AnsiConsole.MarkupLine($"{prompt} Packing πŸ“‚ [yellow]{name}[/]"); - AnsiConsole.MarkupLine($" Packed to {Path.GetRelativePath(baseDir, zipFileName)}"); + if (File.Exists(zipFileName)) + File.Delete(zipFileName); - packTask.Increment((1.0 / folders.Count) * 100); - } + ZipFile.CreateFromDirectory( + folder.FullName, + zipFileName, + CompressionLevel.SmallestSize, + true + ); - AnsiConsole.MarkupLine($"{prompt} Packing done."); + AnsiConsole.MarkupLine($" Packed to {Path.GetRelativePath(baseDir, zipFileName)}"); - packTask.StopTask(); + packTask.Increment((1.0 / folders.Count) * 100); } - }); + + AnsiConsole.MarkupLine($"{prompt} Packing done."); + + packTask.StopTask(); + } + });