test
This commit is contained in:
@@ -1593,6 +1593,9 @@ def main() -> int:
|
||||
ps1_text = r"""Param([Parameter(ValueFromRemainingArguments=$true)] $args)
|
||||
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$repo = (Resolve-Path (Join-Path $scriptDir "..")).Path
|
||||
$venv = Join-Path $repo '.venv'
|
||||
$py = Join-Path $venv 'Scripts\python.exe'
|
||||
$requirements = Join-Path $repo 'scripts\requirements.txt'
|
||||
|
||||
# Automatically check for updates if this is a git repository
|
||||
if (Test-Path (Join-Path $repo ".git")) {
|
||||
@@ -1608,7 +1611,17 @@ if (Test-Path (Join-Path $repo ".git")) {
|
||||
if (-not $skip) {
|
||||
Write-Host "Checking for updates..." -ForegroundColor Gray
|
||||
$update = git -C "$repo" pull --ff-only 2>&1
|
||||
if ($update -like "*Updating*" -or $update -like "*Fast-forward*") {
|
||||
$repoUpdated = ($update -like "*Updating*" -or $update -like "*Fast-forward*")
|
||||
|
||||
if (-not $env:MM_NO_DEP_UPDATE -and (Test-Path $py) -and (Test-Path $requirements)) {
|
||||
Write-Host "Checking Python module updates..." -ForegroundColor Gray
|
||||
& $py -m pip install --disable-pip-version-check --upgrade -r $requirements *> $null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "Warning: dependency update failed; continuing startup." -ForegroundColor Yellow
|
||||
}
|
||||
}
|
||||
|
||||
if ($repoUpdated) {
|
||||
Clear-Host
|
||||
Write-Host "Medeia-Macina has been updated. Please restart the application to apply changes." -ForegroundColor Cyan
|
||||
exit 0
|
||||
@@ -1619,8 +1632,6 @@ if (Test-Path (Join-Path $repo ".git")) {
|
||||
} catch {}
|
||||
}
|
||||
|
||||
$venv = Join-Path $repo '.venv'
|
||||
$py = Join-Path $venv 'Scripts\python.exe'
|
||||
if (Test-Path $py) {
|
||||
& $py -m scripts.cli_entry @args; exit $LASTEXITCODE
|
||||
}
|
||||
@@ -1665,6 +1676,10 @@ if (Test-Path (Join-Path $repo 'CLI.py')) {
|
||||
"@echo off\n"
|
||||
"setlocal enabledelayedexpansion\n"
|
||||
f'set "REPO={repo_bat_str}"\n'
|
||||
"set \"VENV=!REPO!\\.venv\"\n"
|
||||
"set \"PY=!VENV!\\Scripts\\python.exe\"\n"
|
||||
"set \"ENTRY=!REPO!\\scripts\\cli_entry.py\"\n"
|
||||
"set \"REQ=!REPO!\\scripts\\requirements.txt\"\n"
|
||||
"\n"
|
||||
":: Automatically check for updates if this is a git repository\n"
|
||||
"if not defined MM_NO_UPDATE (\n"
|
||||
@@ -1680,7 +1695,15 @@ if (Test-Path (Join-Path $repo 'CLI.py')) {
|
||||
" if \"!AUTO_UPDATE!\" == \"true\" (\n"
|
||||
" echo Checking for updates...\n"
|
||||
" git -C \"!REPO!\" pull --ff-only | findstr /i /c:\"Updating\" /c:\"Fast-forward\" >nul 2>&1\n"
|
||||
" if !errorlevel! == 0 (\n"
|
||||
" set \"REPO_UPDATED=false\"\n"
|
||||
" if !errorlevel! == 0 set \"REPO_UPDATED=true\"\n"
|
||||
" if not defined MM_NO_DEP_UPDATE (\n"
|
||||
" if exist \"!PY!\" if exist \"!REQ!\" (\n"
|
||||
" echo Checking Python module updates...\n"
|
||||
" \"!PY!\" -m pip install --disable-pip-version-check --upgrade -r \"!REQ!\" >nul 2>&1\n"
|
||||
" )\n"
|
||||
" )\n"
|
||||
" if \"!REPO_UPDATED!\" == \"true\" (\n"
|
||||
" cls\n"
|
||||
" echo Medeia-Macina has been updated. Please restart the application to apply changes.\n"
|
||||
" exit /b 0\n"
|
||||
@@ -1690,9 +1713,6 @@ if (Test-Path (Join-Path $repo 'CLI.py')) {
|
||||
" )\n"
|
||||
")\n"
|
||||
"\n"
|
||||
"set \"VENV=!REPO!\\.venv\"\n"
|
||||
"set \"PY=!VENV!\\Scripts\\python.exe\"\n"
|
||||
"set \"ENTRY=!REPO!\\scripts\\cli_entry.py\"\n"
|
||||
"if exist \"!PY!\" (\n"
|
||||
" \"!PY!\" \"!ENTRY!\" %*\n"
|
||||
" exit /b !ERRORLEVEL!\n"
|
||||
@@ -1869,7 +1889,21 @@ if (Test-Path (Join-Path $repo 'CLI.py')) {
|
||||
' if [ "$AUTO_UPDATE" = "true" ]; then\n'
|
||||
' echo "Checking for updates..."\n'
|
||||
' UPDATE_OUT=$(git -C "$REPO" pull --ff-only 2>&1)\n'
|
||||
' REPO_UPDATED="false"\n'
|
||||
' if echo "$UPDATE_OUT" | grep -qiE \'Updating|Fast-forward\'; then\n'
|
||||
' REPO_UPDATED="true"\n'
|
||||
' fi\n'
|
||||
' MM_PY=""\n'
|
||||
' if [ -x "$VENV/bin/python3" ]; then\n'
|
||||
' MM_PY="$VENV/bin/python3"\n'
|
||||
' elif [ -x "$VENV/bin/python" ]; then\n'
|
||||
' MM_PY="$VENV/bin/python"\n'
|
||||
' fi\n'
|
||||
' if [ -z "${MM_NO_DEP_UPDATE:-}" ] && [ -n "$MM_PY" ] && [ -f "$REPO/scripts/requirements.txt" ]; then\n'
|
||||
' echo "Checking Python module updates..."\n'
|
||||
' "$MM_PY" -m pip install --disable-pip-version-check --upgrade -r "$REPO/scripts/requirements.txt" >/dev/null 2>&1 || true\n'
|
||||
' fi\n'
|
||||
' if [ "$REPO_UPDATED" = "true" ]; then\n'
|
||||
' clear\n'
|
||||
' echo "Medeia-Macina has been updated. Please restart the application to apply changes."\n'
|
||||
' exit 0\n'
|
||||
|
||||
Reference in New Issue
Block a user