Skip to content

Commit 180dca8

Browse files
authored
Merge pull request #292 from Crequency/dev=main
[Pull Request] Daily merge
2 parents 36f8d85 + 619b1a2 commit 180dca8

19 files changed

+567
-277
lines changed

.cheese/KitX.Cheese.csproj

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
<PropertyGroup>
10+
<NoWarn>CS8802</NoWarn>
11+
<NoWarn>CS0246</NoWarn>
12+
<NoWarn>CS0103</NoWarn>
13+
<NoWarn>CS0136</NoWarn>
14+
</PropertyGroup>
15+
16+
</Project>

.cheese/references.cs

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
return new List<ReferenceItem>()
2+
{
3+
new ReferenceItem
4+
{
5+
Name = "Common.Activity",
6+
Location = "Reference/Common.Activity",
7+
Url = "[email protected]:Crequency/Common.Activity.git",
8+
Branch = "dev=main",
9+
RemoteBranch = "origin/dev=main",
10+
Type = ReferenceType.GitRepo,
11+
},
12+
new ReferenceItem
13+
{
14+
Name = "Common.Algorithm",
15+
Location = "Reference/Common.Algorithm",
16+
Url = "[email protected]:Crequency/Common.Algorithm.git",
17+
Branch = "dev=main",
18+
RemoteBranch = "origin/dev=main",
19+
Type = ReferenceType.GitRepo,
20+
},
21+
new ReferenceItem
22+
{
23+
Name = "Common.BasicHelper",
24+
Location = "Reference/Common.BasicHelper",
25+
Url = "[email protected]:Crequency/Common.BasicHelper.git",
26+
Branch = "dev=main",
27+
RemoteBranch = "origin/dev=main",
28+
Type = ReferenceType.GitRepo,
29+
},
30+
new ReferenceItem
31+
{
32+
Name = "Common.Update",
33+
Location = "Reference/Common.Update",
34+
Url = "[email protected]:Crequency/Common.Update.git",
35+
Branch = "dev=main",
36+
RemoteBranch = "origin/dev=main",
37+
Type = ReferenceType.GitRepo,
38+
},
39+
new ReferenceItem
40+
{
41+
Name = "Csharpell",
42+
Location = "Reference/Csharpell",
43+
Url = "[email protected]:Dynesshely/Csharpell.git",
44+
Branch = "dev=main",
45+
RemoteBranch = "origin/dev=main",
46+
Type = ReferenceType.GitRepo,
47+
},
48+
new ReferenceItem
49+
{
50+
Name = "XamlMultiLanguageEditor",
51+
Location = "KitX SDK/Reference/XamlMultiLanguageEditor",
52+
Url = "[email protected]:Dynesshely/XamlMultiLanguageEditor.git",
53+
Branch = "dev=main",
54+
RemoteBranch = "origin/dev=main",
55+
Type = ReferenceType.GitRepo,
56+
InSubmodule = true,
57+
},
58+
};

.cheese/references.json

-56
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
using System.IO;
3+
using System.Threading;
4+
5+
while (true)
6+
{
7+
if (Directory.Exists("Config"))
8+
Directory.Delete("Config", true);
9+
10+
Thread.Sleep(5000);
11+
}

.cheese/scripts/i18n.cs

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using System.Diagnostics;
2+
using Common.BasicHelper.Core.Shell;
3+
using Common.BasicHelper.Utils.Extensions;
4+
using Spectre.Console;
5+
6+
var utilsToLaunch = AnsiConsole.Prompt(
7+
new MultiSelectionPrompt<string>()
8+
.Title("Which [green]i18n utils[/] are to be launched ?")
9+
.NotRequired()
10+
.PageSize(10)
11+
.MoreChoicesText("[grey](Move up and down to reveal more utils)[/]")
12+
.InstructionsText("[grey](Press [blue]<space>[/] to toggle a i18n util, [green]<enter>[/] to accept)[/]")
13+
.AddChoices(
14+
new[] {
15+
"KitX Dashboard (XamlMLE)"
16+
}
17+
)
18+
);
19+
20+
var baseDir = PathHelper.Instance.BaseSlnDir;
21+
22+
foreach (var util in utilsToLaunch)
23+
{
24+
AnsiConsole.MarkupLine($"@ Launching {util}");
25+
26+
switch (util)
27+
{
28+
case "KitX Dashboard (XamlMLE)":
29+
var xamlMleDir = $"{baseDir}/KitX SDK/Reference/XamlMultiLanguageEditor".GetFullPath();
30+
var scriptPath = $"{xamlMleDir}/run.ps1".GetFullPath();
31+
32+
var args = new StringBuilder()
33+
.Append($" -WorkingDirectory \"{xamlMleDir}\"")
34+
.Append($" -Command \"& '{scriptPath}'\"")
35+
.ToString()
36+
;
37+
38+
Console.WriteLine(args);
39+
40+
var result = "pwsh".ExecuteAsCommand(args: args, findInPath: true);
41+
42+
Console.WriteLine(result);
43+
44+
break;
45+
}
46+
}

.cheese/scripts/publish.cs

+163
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
using System.Diagnostics;
2+
using System.IO.Compression;
3+
using System.Text.Json;
4+
using Common.BasicHelper.Utils.Extensions;
5+
using Spectre.Console;
6+
7+
AnsiConsole.Write(new FigletText("KitX Publisher").Centered().Color(Color.Blue));
8+
9+
PathHelper.Instance.AssertInSlnDirectory(out _);
10+
11+
var baseDir = PathHelper.Instance.BaseSlnDir;
12+
13+
var publishDir = $"{baseDir}/KitX Publish".GetFullPath();
14+
15+
if (Directory.Exists(publishDir))
16+
foreach (var dir in new DirectoryInfo(publishDir).GetDirectories())
17+
Directory.Delete(dir.FullName, true);
18+
19+
const string pro = "Properties/";
20+
const string pub = "PublishProfiles/";
21+
22+
var path = $"{baseDir}/KitX Clients/KitX Dashboard/KitX Dashboard/".GetFullPath();
23+
var abPubPath = $"{path}{pro}{pub}".GetFullPath();
24+
var files = Directory.GetFiles(abPubPath, "*.pubxml", SearchOption.AllDirectories);
25+
26+
var logsDir = $"{publishDir}/logs".GetFullPath();
27+
var log = $"{logsDir}/log-{DateTime.Now:yyyy-MM-dd-HH-mm-ss}.log".GetFullPath();
28+
if (!Directory.Exists(logsDir))
29+
Directory.CreateDirectory(logsDir);
30+
31+
var packIgnore = $"{publishDir}/.packignore".GetFullPath();
32+
var packIgnoreExists = File.Exists(packIgnore);
33+
34+
var finishedThreads = 0;
35+
var executingThreadIndex = 0;
36+
37+
const string prompt = "[white]>>>[/]";
38+
39+
AnsiConsole
40+
.Progress()
41+
.Columns(
42+
new ProgressColumn[]
43+
{
44+
new TaskDescriptionColumn(),
45+
new ProgressBarColumn(),
46+
new PercentageColumn(),
47+
new SpinnerColumn(),
48+
}
49+
)
50+
.Start(ctx =>
51+
{
52+
var genTask = ctx.AddTask("[green]Publishing[/]");
53+
var packTask = ctx.AddTask("[blue]Packing[/]");
54+
55+
{
56+
AnsiConsole.Write(new Rule($"[blue]Begin Generating[/]"));
57+
58+
AnsiConsole.MarkupLine($"{prompt} Found {files.Length} profiles");
59+
AnsiConsole.Markup(
60+
$"{prompt} Generating logs at: \"{Path.GetRelativePath(baseDir, log)}\""
61+
);
62+
AnsiConsole.WriteLine();
63+
64+
packTask.IsIndeterminate = true;
65+
66+
foreach (var item in files)
67+
{
68+
var index = executingThreadIndex++;
69+
var filename = Path.GetFileName(item);
70+
const string cmd = "dotnet";
71+
var arg = new StringBuilder()
72+
.Append("publish ")
73+
.Append($"\"{(path + "/KitX.Dashboard.csproj").GetFullPath()}\" ")
74+
.Append($"\"/p:PublishProfile={item}\"")
75+
.ToString();
76+
77+
AnsiConsole.MarkupLine($"{prompt} 📄 [white]{filename}[/]: [gray]{cmd} {arg}[/]");
78+
79+
var process = new Process();
80+
var psi = new ProcessStartInfo()
81+
{
82+
FileName = cmd,
83+
Arguments = arg,
84+
UseShellExecute = false,
85+
CreateNoWindow = true,
86+
RedirectStandardOutput = true,
87+
RedirectStandardError = true,
88+
};
89+
process.StartInfo = psi;
90+
process.Start();
91+
92+
while (!process.StandardOutput.EndOfStream)
93+
{
94+
var line = process.StandardOutput.ReadLine();
95+
96+
File.AppendAllText(log, Environment.NewLine + line);
97+
}
98+
99+
process.WaitForExit();
100+
101+
++finishedThreads;
102+
103+
genTask.Increment((1.0 / files.Length) * 100);
104+
105+
AnsiConsole.MarkupLine(
106+
$"{prompt} Finished task_{index}, still {files.Length - finishedThreads} tasks waiting"
107+
);
108+
109+
AnsiConsole.Write(new Rule($"[red]Finished task-{index}[/]"));
110+
}
111+
112+
AnsiConsole.MarkupLine($"{prompt} All tasks done.");
113+
114+
genTask.StopTask();
115+
}
116+
117+
{
118+
AnsiConsole.MarkupLine($"{prompt} Begin packing.");
119+
120+
if (packIgnoreExists)
121+
AnsiConsole.MarkupLine(
122+
$"{prompt} `.packignore` not exists, all folder will be packed."
123+
);
124+
125+
packTask.IsIndeterminate = false;
126+
127+
var ignoredDirectories = packIgnoreExists
128+
? JsonSerializer.Deserialize<List<string>>(File.ReadAllText(packIgnore))
129+
: new List<string>();
130+
131+
var folders = new DirectoryInfo(publishDir).GetDirectories().ToList();
132+
133+
folders.RemoveAll(f => ignoredDirectories.Contains(f.Name));
134+
135+
foreach (var folder in folders)
136+
{
137+
var name = folder.Name;
138+
var zipFileName = $"{publishDir}/{name}.zip";
139+
140+
AnsiConsole.MarkupLine($"{prompt} Packing 📂 [yellow]{name}[/]");
141+
142+
if (File.Exists(zipFileName))
143+
File.Delete(zipFileName);
144+
145+
ZipFile.CreateFromDirectory(
146+
folder.FullName,
147+
zipFileName,
148+
CompressionLevel.SmallestSize,
149+
true
150+
);
151+
152+
AnsiConsole.MarkupLine(
153+
$" Packed to {Path.GetRelativePath(baseDir, zipFileName)}"
154+
);
155+
156+
packTask.Increment((1.0 / folders.Count) * 100);
157+
}
158+
159+
AnsiConsole.MarkupLine($"{prompt} Packing done.");
160+
161+
packTask.StopTask();
162+
}
163+
});

.csharpierrc.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
printWidth: 140
2+
useTabs: false
3+
tabWidth: 4
4+
endOfLine: auto

0 commit comments

Comments
 (0)