Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check before installing Excubo.WebCompiler #341

Merged
merged 1 commit into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion Application/BuildScripts/PreBuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

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"

dotnet tool install Excubo.WebCompiler --global
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

Expand Down
25 changes: 23 additions & 2 deletions Application/BuildScripts/PreBuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
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
fi

echo "compiling scss files"

dotnet tool install Excubo.WebCompiler --global
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

Expand Down
Loading