mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 10:39:47 +00:00
Added UpdateWebAssetsCommand
This commit is contained in:
parent
5d74df36a8
commit
2ce68cdca6
42
app/Build/Commands/UpdateWebAssetsCommand.cs
Normal file
42
app/Build/Commands/UpdateWebAssetsCommand.cs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// ReSharper disable ClassNeverInstantiated.Global
|
||||||
|
// ReSharper disable UnusedType.Global
|
||||||
|
// ReSharper disable UnusedMember.Global
|
||||||
|
|
||||||
|
namespace Build.Commands;
|
||||||
|
|
||||||
|
public sealed class UpdateWebAssetsCommand
|
||||||
|
{
|
||||||
|
[Command("update-web", Description = "Update web assets")]
|
||||||
|
public void UpdateWebAssets()
|
||||||
|
{
|
||||||
|
if(!Environment.IsWorkingDirectoryValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
var rid = Environment.GetRidsForCurrentOS().First();
|
||||||
|
var cwd = Environment.GetAIStudioDirectory();
|
||||||
|
var contentPath = Path.Join(cwd, "bin", "release", "net9.0", rid, "publish", "wwwroot", "_content");
|
||||||
|
var isMudBlazorDirectoryPresent = Directory.Exists(Path.Join(contentPath, "MudBlazor"));
|
||||||
|
if (!isMudBlazorDirectoryPresent)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"No web assets found for RID '{rid}'. Please publish the project first.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Directory.CreateDirectory(Path.Join(cwd, "wwwroot", "system"));
|
||||||
|
var sourcePaths = Directory.EnumerateFiles(contentPath, "*", SearchOption.AllDirectories);
|
||||||
|
var counter = 0;
|
||||||
|
foreach(var sourcePath in sourcePaths)
|
||||||
|
{
|
||||||
|
counter++;
|
||||||
|
var relativePath = Path.GetRelativePath(cwd, sourcePath);
|
||||||
|
var targetPath = Path.Join(cwd, "wwwroot", relativePath);
|
||||||
|
var targetDirectory = Path.GetDirectoryName(targetPath);
|
||||||
|
if (targetDirectory != null)
|
||||||
|
Directory.CreateDirectory(targetDirectory);
|
||||||
|
|
||||||
|
File.Copy(sourcePath, targetPath, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"{counter:###,###} web assets updated successfully.");
|
||||||
|
}
|
||||||
|
}
|
@ -4,4 +4,5 @@ var builder = CoconaApp.CreateBuilder();
|
|||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
app.AddCommands<CheckRidsCommand>();
|
app.AddCommands<CheckRidsCommand>();
|
||||||
app.AddCommands<UpdateMetadataCommands>();
|
app.AddCommands<UpdateMetadataCommands>();
|
||||||
|
app.AddCommands<UpdateWebAssetsCommand>();
|
||||||
app.Run();
|
app.Run();
|
Loading…
Reference in New Issue
Block a user