From d574320849793e124cbc9665df8603a0e84385dd Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Wed, 1 Apr 2026 18:38:42 +0300 Subject: [PATCH] fix(web-publish): auto-detect Apache download URL from apachelounge.com Replace hardcoded Apache zip URL with dynamic parsing of the Apache Lounge download page. Finds the latest Win64 build automatically, so the script won't break when new versions are published. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../web-publish/scripts/web-publish.ps1 | 27 +++++++++++++++-- .../skills/web-publish/scripts/web-publish.py | 29 +++++++++++++++++-- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/.claude/skills/web-publish/scripts/web-publish.ps1 b/.claude/skills/web-publish/scripts/web-publish.ps1 index 19e048fe..9a918d28 100644 --- a/.claude/skills/web-publish/scripts/web-publish.ps1 +++ b/.claude/skills/web-publish/scripts/web-publish.ps1 @@ -1,4 +1,4 @@ -# web-publish v1.1 — Publish 1C infobase via Apache +# web-publish v1.2 — Publish 1C infobase via Apache # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills <# .SYNOPSIS @@ -137,14 +137,35 @@ if (-not (Test-Path $httpdExe)) { } Write-Host "Apache не найден. Скачиваю..." -ForegroundColor Cyan - $zipUrl = "https://www.apachelounge.com/download/VS18/binaries/httpd-2.4.66-260131-Win64-VS18.zip" $tmpZip = Join-Path $env:TEMP "apache24.zip" $tmpDir = Join-Path $env:TEMP "apache24_extract" try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - # WebClient works better than Invoke-WebRequest in PS 5.1 (handles redirects) $wc = New-Object System.Net.WebClient + + # Parse Apache Lounge download page for latest Win64 zip URL + $downloadPage = "https://www.apachelounge.com/download/" + Write-Host "Определяю актуальную версию с $downloadPage ..." + $html = $wc.DownloadString($downloadPage) + # Links are typically relative (/download/...), try that first + $match = [regex]::Match($html, '(?i)href="(/download/[^"]*?httpd-[^"]*?Win64[^"]*?\.zip)"') + if (-not $match.Success) { + $match = [regex]::Match($html, '(?i)href="(https://[^"]*?httpd-[^"]*?Win64[^"]*?\.zip)"') + } + + if ($match.Success) { + $zipUrl = $match.Groups[1].Value + if ($zipUrl.StartsWith('/')) { + $zipUrl = "https://www.apachelounge.com$zipUrl" + } + Write-Host "Найдено: $zipUrl" -ForegroundColor Green + } else { + Write-Host "Не удалось определить ссылку автоматически." -ForegroundColor Yellow + Write-Host "Скачайте вручную: $downloadPage" -ForegroundColor Yellow + exit 1 + } + $wc.DownloadFile($zipUrl, $tmpZip) } catch { Write-Host "Error: не удалось скачать Apache: $_" -ForegroundColor Red diff --git a/.claude/skills/web-publish/scripts/web-publish.py b/.claude/skills/web-publish/scripts/web-publish.py index c6e09922..2bf30105 100644 --- a/.claude/skills/web-publish/scripts/web-publish.py +++ b/.claude/skills/web-publish/scripts/web-publish.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# web-publish v1.1 — Publish 1C infobase via Apache +# web-publish v1.2 — Publish 1C infobase via Apache # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills """ @@ -125,12 +125,37 @@ def main(): sys.exit(1) print('Apache не найден. Скачиваю...') - zip_url = 'https://www.apachelounge.com/download/VS18/binaries/httpd-2.4.66-260131-Win64-VS18.zip' tmp_zip = os.path.join(tempfile.gettempdir(), 'apache24.zip') tmp_dir = os.path.join(tempfile.gettempdir(), 'apache24_extract') try: + # Parse Apache Lounge download page for latest Win64 zip URL + download_page = 'https://www.apachelounge.com/download/' + print(f'Определяю актуальную версию с {download_page} ...') + req = urllib.request.Request(download_page, headers={ + 'User-Agent': 'Mozilla/5.0', + }) + with urllib.request.urlopen(req, timeout=30) as resp: + html = resp.read().decode('utf-8', errors='replace') + + # Links are typically relative (/download/...), try that first + m = re.search(r'(?i)href="(/download/[^"]*?httpd-[^"]*?Win64[^"]*?\.zip)"', html) + if not m: + m = re.search(r'(?i)href="(https://[^"]*?httpd-[^"]*?Win64[^"]*?\.zip)"', html) + + if m: + zip_url = m.group(1) + if zip_url.startswith('/'): + zip_url = f'https://www.apachelounge.com{zip_url}' + print(f'Найдено: {zip_url}') + else: + print('Не удалось определить ссылку автоматически.', file=sys.stderr) + print(f'Скачайте вручную: {download_page}') + sys.exit(1) + urllib.request.urlretrieve(zip_url, tmp_zip) + except SystemExit: + raise except Exception as e: print(f'Error: не удалось скачать Apache: {e}', file=sys.stderr) print('Скачайте вручную: https://www.apachelounge.com/download/')