Skip to content

Commit

Permalink
📝 Chore(Submodules): Sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Dynesshely committed Jun 21, 2024
1 parent 26eceee commit 2654a0a
Show file tree
Hide file tree
Showing 7 changed files with 191 additions and 6 deletions.
185 changes: 185 additions & 0 deletions .cheese/publishers/general.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
using System.Diagnostics;
using System.IO.Compression;
using Cheese.Options;
using Cheese.Utils.Cheese;
using Common.BasicHelper.Utils.Extensions;

namespace Cheese.Utils.Publisher;

public class Publisher
{
private static Publisher? _instance;

public static Publisher Instance => _instance ??= new();

internal static List<int> AvailableColors =
[
1,
2,
3,
5,
9,
10,
11,
13
];

public void Execute(PublishOptions options)
{
Console.WriteLine("Running Cheese Publisher");

if (PathHelper.Instance.BaseSlnDir is null)
{
Console.WriteLine("! You're not in KitX repo.");
return;
}

var baseDir = PathHelper.Instance.BaseSlnDir;

var publishDir = $"{baseDir}/KitX Publish".GetFullPath();

if (Directory.Exists(publishDir) && !options.SkipGenerating)
foreach (var dir in new DirectoryInfo(publishDir).GetDirectories())
Directory.Delete(dir.FullName, true);

var path = $"{baseDir}/KitX Clients/KitX Dashboard/KitX Dashboard/".GetFullPath();
const string pro = "Properties/";
const string pub = "PublishProfiles/";
var abPubPath = $"{path}{pro}{pub}".GetFullPath();
var files = Directory.GetFiles(
abPubPath,
"*.pubxml",
SearchOption.AllDirectories
);

var finishedThreads = 0;
var executingThreadIndex = 0;

var updateFinishedThreadsLock = new object();
var singleThreadUpdateLock = new object();

var random = new Random();

var threadOutputColors = new Dictionary<int, ConsoleColor>();
var usedColorsCount = 0;
var defaultColor = Console.ForegroundColor;

var tasks = new List<Action>();

foreach (var item in files)
{
var index = executingThreadIndex++;
var color = GetRandomColor();
threadOutputColors.Add(index, color);
var filename = Path.GetFileName(item);

tasks.Add(() =>
{
const string cmd = "dotnet";
var arg = $"publish \"{(path + "/KitX.Dashboard.csproj").GetFullPath()}\" \"/p:PublishProfile={item}\"";
lock (singleThreadUpdateLock)
{
Print(
$"""
>>> On task_{index}:
Task file: {filename}
Executing: {cmd} {arg}
Output:
"""
);
}
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();
Console.WriteLine($" {line}");
}
process.WaitForExit();
lock (updateFinishedThreadsLock)
{
++finishedThreads;
Print($">>> Finished task_{index}, still {files.Length - finishedThreads} tasks running.");
}
});

Print($">>> New task: task_{index}\t-> {filename}");

continue;

void Print(string msg)
{
Console.ForegroundColor = threadOutputColors[index];
Console.WriteLine(msg);
Console.ForegroundColor = defaultColor;
}
}

if (!options.SkipGenerating)
foreach (var task in tasks)
task.Invoke();

if (!options.SkipGenerating)
while (finishedThreads != files.Length)
{
}

Console.WriteLine($">>> All tasks done.");

if (options.SkipPacking) return;

Console.WriteLine(">>> Begin packing.");

var folders = new DirectoryInfo(publishDir).GetDirectories();

foreach (var folder in folders)
{
var name = folder.Name;
var zipFileName = $"{publishDir}/{name}.zip";

Console.WriteLine($">>> Packing {name}");

if (File.Exists(zipFileName))
File.Delete(zipFileName);

ZipFile.CreateFromDirectory(
folder.FullName,
zipFileName,
CompressionLevel.SmallestSize,
true
);
}

Console.WriteLine(">>> Packing done.");

return;

ConsoleColor GetRandomColor()
{
var cc = AvailableColors[GetRandomIndex(AvailableColors.Count)];
if (usedColorsCount < AvailableColors.Count)
{
while (threadOutputColors.Values.ToList().Contains((ConsoleColor)cc))
cc = AvailableColors[GetRandomIndex(AvailableColors.Count)];
}
++usedColorsCount;
return (ConsoleColor)cc;
}

int GetRandomIndex(int max) => random.Next(0, max);
}
}
2 changes: 1 addition & 1 deletion KitX Clients/KitX Installer
Submodule KitX Installer updated 34 files
+922 −194 KitX_Installer_Egui/Cargo.lock
+6 −6 KitX_Installer_Egui/Cargo.toml
+21 −13 KitX_Installer_Egui/assets/7z/README.md
+4 −0 KitX_Installer_Egui/rustfmt.toml
+3 −7 KitX_Installer_Egui/src/app_info.rs
+1 −3 KitX_Installer_Egui/src/data/data_fetcher.rs
+4 −4 KitX_Installer_Egui/src/data/download_config.rs
+6 −10 KitX_Installer_Egui/src/data/install_config.rs
+7 −0 KitX_Installer_Egui/src/macros.rs
+13 −16 KitX_Installer_Egui/src/main.rs
+1 −1 KitX_Installer_Egui/src/platforms/linux/linux_installer.rs
+1 −1 KitX_Installer_Egui/src/platforms/macos/mac_installer.rs
+27 −73 KitX_Installer_Egui/src/platforms/windows/reg_helper.rs
+1 −9 KitX_Installer_Egui/src/platforms/windows/shortcut_helper.rs
+26 −125 KitX_Installer_Egui/src/platforms/windows/win_installer.rs
+4 −10 KitX_Installer_Egui/src/platforms/windows/win_uninstaller.rs
+3 −5 KitX_Installer_Egui/src/utils/arguments_processor.rs
+1 −7 KitX_Installer_Egui/src/utils/zip_file_manager.rs
+50 −816 KitX_Installer_Egui/src/views/application.rs
+5 −14 KitX_Installer_Egui/src/views/font_helper.rs
+250 −0 KitX_Installer_Egui/src/views/layout.rs
+3 −0 KitX_Installer_Egui/src/views/mod.rs
+43 −0 KitX_Installer_Egui/src/views/native_helper.rs
+7 −0 KitX_Installer_Egui/src/views/pages/mod.rs
+23 −0 KitX_Installer_Egui/src/views/pages/page_finish.rs
+64 −0 KitX_Installer_Egui/src/views/pages/page_installation.rs
+122 −0 KitX_Installer_Egui/src/views/pages/page_installation_config.rs
+32 −0 KitX_Installer_Egui/src/views/pages/page_introduce.rs
+55 −0 KitX_Installer_Egui/src/views/pages/page_license.rs
+34 −0 KitX_Installer_Egui/src/views/pages/page_select_language.rs
+60 −0 KitX_Installer_Egui/src/views/pages/page_uninstallation.rs
+1 −1 KitX_Installer_Egui/src/views/translations.rs
+4 −4 KitX_Installer_Egui_Patcher/src/main.rs
+5 −5 README.md
2 changes: 1 addition & 1 deletion KitX Clients/KitX Website
Submodule KitX Website updated 25 files
+46 −28 KitX Website Flutter/kitx_website/analysis_options.yaml
+1 −1 KitX Website Flutter/kitx_website/build.ps1
+0 −3 KitX Website Flutter/kitx_website/build.sh
+33 −6 KitX Website Flutter/kitx_website/deploy.ps1
+0 −9 KitX Website Flutter/kitx_website/deploy.sh
+6 −7 KitX Website Flutter/kitx_website/lib/main.dart
+6 −6 KitX Website Flutter/kitx_website/lib/pages/controls/controls_helper.dart
+215 −194 KitX Website Flutter/kitx_website/lib/pages/controls/download_list.dart
+6 −6 KitX Website Flutter/kitx_website/lib/pages/controls/drawer.dart
+8 −17 KitX Website Flutter/kitx_website/lib/pages/controls/home_page_actions.dart
+2 −2 KitX Website Flutter/kitx_website/lib/pages/docs_page.dart
+6 −8 KitX Website Flutter/kitx_website/lib/pages/home_page.dart
+14 −20 KitX Website Flutter/kitx_website/lib/pages/navigation_page.dart
+2 −1 KitX Website Flutter/kitx_website/lib/pages/plugins_page.dart
+2 −1 KitX Website Flutter/kitx_website/lib/pages/settings_page.dart
+8 −9 KitX Website Flutter/kitx_website/lib/utils/global.dart
+10 −5 KitX Website Flutter/kitx_website/lib/utils/open_link.dart
+27 −0 KitX Website Flutter/kitx_website/lib/utils/translation/en_us.dart
+11 −0 KitX Website Flutter/kitx_website/lib/utils/translation/translations.dart
+27 −0 KitX Website Flutter/kitx_website/lib/utils/translation/zh_cn.dart
+0 −54 KitX Website Flutter/kitx_website/lib/utils/translations.dart
+1 −0 KitX Website Flutter/kitx_website/optimize.ps1
+0 −4 KitX Website Flutter/kitx_website/optimize.sh
+14 −16 KitX Website Flutter/kitx_website/pubspec.yaml
+7 −1 KitX Website.code-workspace

0 comments on commit 2654a0a

Please sign in to comment.