mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-02-10 20:49:06 +00:00
Defined subcommands, e.g., to automate the fix for #27
This commit is contained in:
parent
79b9e1c26a
commit
21911a68ed
@ -1,42 +1,57 @@
|
|||||||
#!/usr/bin/env nu
|
#!/usr/bin/env nu
|
||||||
|
|
||||||
build
|
def main [] {}
|
||||||
|
|
||||||
def build [] {
|
def are_assets_exist [rid: string]: string -> bool {
|
||||||
|
$"bin/release/net8.0/($rid)/publish/wwwroot/_content/MudBlazor/MudBlazor.min.css" | path exists
|
||||||
|
}
|
||||||
|
|
||||||
|
def "main fix_web_assets" []: nothing -> nothing {
|
||||||
|
|
||||||
|
# Get the matching RIDs for the current OS:
|
||||||
|
let rids = get_rids
|
||||||
|
|
||||||
|
# We chose the first RID to copy the assets from:
|
||||||
|
let rid = $rids.0
|
||||||
|
|
||||||
|
if (are_assets_exist $rid) == false {
|
||||||
|
print $"Web assets do not exist for ($rid). Please build the project first."
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
# Ensure, that the dist directory exists:
|
||||||
|
mkdir wwwroot/system
|
||||||
|
|
||||||
|
# Copy the web assets from the first RID to the source project:
|
||||||
|
let source_path: glob = $"bin/release/net8.0/($rid)/publish/wwwroot/_content/*"
|
||||||
|
cp --recursive --force --update $source_path wwwroot/system/
|
||||||
|
}
|
||||||
|
|
||||||
|
def "main publish" []: nothing -> nothing {
|
||||||
|
|
||||||
# Ensure, that the dist directory exists:
|
# Ensure, that the dist directory exists:
|
||||||
mkdir bin/dist
|
mkdir bin/dist
|
||||||
|
|
||||||
# Define the list of RIDs to build for, cf. https://learn.microsoft.com/en-us/dotnet/core/rid-catalog:
|
|
||||||
let rids = ["win-x64", "win-arm64", "linux-x64", "linux-arm64", "osx-arm64", "osx-x64"]
|
|
||||||
|
|
||||||
# Get the current OS:
|
# Get the matching RIDs for the current OS:
|
||||||
let current_os = (sys).host.name | str downcase
|
let rids = get_rids
|
||||||
let current_os_dotnet = match $current_os {
|
|
||||||
"windows" => "win-",
|
if ($rids | length) == 0 {
|
||||||
"linux" => "linux-",
|
print "No RIDs to build for."
|
||||||
"darwin" => "osx-",
|
return
|
||||||
|
|
||||||
_ => {
|
|
||||||
print $"Unsupported OS: ($current_os)"
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let current_os = get_os
|
||||||
let published_filename_dotnet = match $current_os {
|
let published_filename_dotnet = match $current_os {
|
||||||
"windows" => "mindworkAIStudio.exe",
|
"windows" => "mindworkAIStudio.exe",
|
||||||
_ => "mindworkAIStudio"
|
_ => "mindworkAIStudio"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Filter the RIDs to build for the current OS:
|
|
||||||
let rids = $rids | where $it =~ $current_os_dotnet
|
|
||||||
|
|
||||||
# Build for each RID:
|
# Build for each RID:
|
||||||
for rid in $rids {
|
for rid in $rids {
|
||||||
print "=============================="
|
print "=============================="
|
||||||
print $"Start building for ($rid)..."
|
print $"Start building for ($rid)..."
|
||||||
|
|
||||||
^dotnet publish -c release -r $rid
|
^dotnet publish --configuration release --runtime $rid
|
||||||
|
|
||||||
let final_filename = match $rid {
|
let final_filename = match $rid {
|
||||||
"win-x64" => "mindworkAIStudio-x86_64-pc-windows-msvc.exe",
|
"win-x64" => "mindworkAIStudio-x86_64-pc-windows-msvc.exe",
|
||||||
@ -67,4 +82,32 @@ def build [] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
print "=============================="
|
print "=============================="
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_rids []: nothing -> list {
|
||||||
|
# Define the list of RIDs to build for, cf. https://learn.microsoft.com/en-us/dotnet/core/rid-catalog:
|
||||||
|
let rids = ["win-x64", "win-arm64", "linux-x64", "linux-arm64", "osx-arm64", "osx-x64"]
|
||||||
|
|
||||||
|
# Get the current OS:
|
||||||
|
let current_os = get_os
|
||||||
|
let current_os_dotnet = match $current_os {
|
||||||
|
"windows" => "win-",
|
||||||
|
"linux" => "linux-",
|
||||||
|
"darwin" => "osx-",
|
||||||
|
|
||||||
|
_ => {
|
||||||
|
print $"Unsupported OS: ($current_os)"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Filter the RIDs to build for the current OS:
|
||||||
|
let rids = $rids | where $it =~ $current_os_dotnet
|
||||||
|
|
||||||
|
# Return the list of RIDs to build for:
|
||||||
|
$rids
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_os []: nothing -> string {
|
||||||
|
(sys).host.name | str downcase
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user