1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-07 21:58:06 -05:00

Check before installing Excubo.WebCompiler (#341)

Checks if it's installed and its version before trying to install/update it. Current behaviour reinstalls the tool on each rebuild. Reduces build time from 53s to 17s in testing.
This commit is contained in:
Amos 2024-08-19 00:43:45 +01:00 committed by GitHub
parent 2f03d4dc82
commit f4876bf910
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 50 additions and 3 deletions

View File

@ -16,9 +16,35 @@ if (-not (Test-Path "$SolutionDir/WebfrontCore/wwwroot/lib/open-iconic/font/css/
(Get-Content "$SolutionDir/WebfrontCore/wwwroot/lib/open-iconic/font/css/open-iconic-bootstrap-override.scss") -replace '../fonts/', '/font/' | Set-Content "$SolutionDir/WebfrontCore/wwwroot/lib/open-iconic/font/css/open-iconic-bootstrap-override.scss" (Get-Content "$SolutionDir/WebfrontCore/wwwroot/lib/open-iconic/font/css/open-iconic-bootstrap-override.scss") -replace '../fonts/', '/font/' | Set-Content "$SolutionDir/WebfrontCore/wwwroot/lib/open-iconic/font/css/open-iconic-bootstrap-override.scss"
} }
Write-Output "checking for Excubo.WebCompiler..."
$toolExists = dotnet tool list -g | Where-Object { $_ -match "Excubo.WebCompiler" }
if ($toolExists) {
$installedVersion = ($toolExists | Select-String -Pattern "Excubo.WebCompiler\s+(\d+\.\d+\.\d+)" -AllMatches).Matches.Groups[1].Value
$latestVersion = (Invoke-WebRequest -Uri "https://api.nuget.org/v3-flatcontainer/excubo.webcompiler/index.json" | ConvertFrom-Json).versions | Select-Object -Last 1
Write-Output "installed version: $installedVersion"
Write-Output "latest version: $latestVersion"
if ([version]$latestVersion -gt [version]$installedVersion) {
Write-Output "updating Excubo.WebCompiler to version $latestVersion..."
try {
dotnet tool update Excubo.WebCompiler --global
}
catch {
Write-Output "failed to update Excubo.WebCompiler. Using existing version."
}
} else {
Write-Output "Excubo.WebCompiler is already up-to-date."
}
} else {
Write-Output "installing Excubo.WebCompiler..."
dotnet tool install Excubo.WebCompiler --global
}
Write-Output "compiling scss files" Write-Output "compiling scss files"
dotnet tool install Excubo.WebCompiler --global
webcompiler -r "$SolutionDir/WebfrontCore/wwwroot/css/src" -o WebfrontCore/wwwroot/css/ -m disable -z disable webcompiler -r "$SolutionDir/WebfrontCore/wwwroot/css/src" -o WebfrontCore/wwwroot/css/ -m disable -z disable
webcompiler "$SolutionDir/WebfrontCore/wwwroot/lib/open-iconic/font/css/open-iconic-bootstrap-override.scss" -o "$SolutionDir/WebfrontCore/wwwroot/css/" -m disable -z disable webcompiler "$SolutionDir/WebfrontCore/wwwroot/lib/open-iconic/font/css/open-iconic-bootstrap-override.scss" -o "$SolutionDir/WebfrontCore/wwwroot/css/" -m disable -z disable

View File

@ -20,9 +20,30 @@ if [ ! -f "$SolutionDir/WebfrontCore/wwwroot/lib/open-iconic/font/css/open-iconi
sed -i 's#../fonts/#/font/#g' "$SolutionDir/WebfrontCore/wwwroot/lib/open-iconic/font/css/open-iconic-bootstrap-override.scss" sed -i 's#../fonts/#/font/#g' "$SolutionDir/WebfrontCore/wwwroot/lib/open-iconic/font/css/open-iconic-bootstrap-override.scss"
fi fi
echo compiling scss files echo "checking for Excubo.WebCompiler..."
toolExists=$(dotnet tool list -g | grep "Excubo.WebCompiler")
if [[ ! -z "$toolExists" ]]; then
installedVersion=$(echo "$toolExists" | grep -oE "Excubo.WebCompiler\s+(\d+\.\d+\.\d+)" | grep -oE "\d+\.\d+\.\d+")
latestVersion=$(curl -s "https://api.nuget.org/v3-flatcontainer/excubo.webcompiler/index.json" | jq -r '.versions | last')
echo "installed version: $installedVersion"
echo "latest version: $latestVersion"
if [[ "$latestVersion" != "$installedVersion" && "$(printf '%s\n%s' "$installedVersion" "$latestVersion" | sort -V | head -n 1)" == "$installedVersion" ]]; then
echo "updating Excubo.WebCompiler to version $latestVersion..."
dotnet tool update Excubo.WebCompiler --global || echo "failed to update Excubo.WebCompiler. Using existing version."
else
echo "Excubo.WebCompiler is already up-to-date."
fi
else
echo "installing Excubo.WebCompiler..."
dotnet tool install Excubo.WebCompiler --global dotnet tool install Excubo.WebCompiler --global
fi
echo "compiling scss files"
webcompiler -r "$SolutionDir/WebfrontCore/wwwroot/css/src" -o "$SolutionDir/WebfrontCore/wwwroot/css/" -m disable -z disable webcompiler -r "$SolutionDir/WebfrontCore/wwwroot/css/src" -o "$SolutionDir/WebfrontCore/wwwroot/css/" -m disable -z disable
webcompiler "$SolutionDir/WebfrontCore/wwwroot/lib/open-iconic/font/css/open-iconic-bootstrap-override.scss" -o "$SolutionDir/WebfrontCore/wwwroot/css/" -m disable -z disable webcompiler "$SolutionDir/WebfrontCore/wwwroot/lib/open-iconic/font/css/open-iconic-bootstrap-override.scss" -o "$SolutionDir/WebfrontCore/wwwroot/css/" -m disable -z disable