diff --git a/.claude/skills/epf-build/scripts/epf-build.ps1 b/.claude/skills/epf-build/scripts/epf-build.ps1 index d099615d..7a021132 100644 --- a/.claude/skills/epf-build/scripts/epf-build.ps1 +++ b/.claude/skills/epf-build/scripts/epf-build.ps1 @@ -1,4 +1,4 @@ -# epf-build v1.0 — Build external data processor or report (EPF/ERF) from XML sources +# epf-build v1.1 — Build external data processor or report (EPF/ERF) from XML sources # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills <# .SYNOPSIS @@ -70,15 +70,40 @@ $OutputEncoding = [System.Text.Encoding]::UTF8 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 # --- Resolve V8Path --- +function Find-ProjectV8Path { + $dir = (Get-Location).Path + while ($dir) { + $pf = Join-Path $dir ".v8-project.json" + if (Test-Path $pf) { + try { + $j = Get-Content $pf -Raw -Encoding UTF8 | ConvertFrom-Json + if ($j.v8path) { return [string]$j.v8path } + } catch {} + return $null + } + $parent = Split-Path $dir -Parent + if (-not $parent -or $parent -eq $dir) { break } + $dir = $parent + } + return $null +} + if (-not $V8Path) { - $found = Get-ChildItem "C:\Program Files\1cv8\*\bin\1cv8.exe" -ErrorAction SilentlyContinue | Sort-Object FullName -Descending | Select-Object -First 1 + $V8Path = Find-ProjectV8Path +} +if (-not $V8Path) { + $found = Get-ChildItem @("C:\Program Files\1cv8\*\bin\1cv8.exe", "C:\Program Files (x86)\1cv8\*\bin\1cv8.exe") -ErrorAction SilentlyContinue | + Sort-Object { try { [version]$_.Directory.Parent.Name } catch { [version]"0.0" } } -Descending | + Select-Object -First 1 if ($found) { $V8Path = $found.FullName + Write-Host "Auto-selected platform $($found.Directory.Parent.Name): $V8Path" -ForegroundColor Yellow } else { Write-Host "Error: 1cv8.exe not found. Specify -V8Path" -ForegroundColor Red exit 1 } -} elseif (Test-Path $V8Path -PathType Container) { +} +if (Test-Path $V8Path -PathType Container) { $V8Path = Join-Path $V8Path "1cv8.exe" } diff --git a/.claude/skills/epf-build/scripts/epf-build.py b/.claude/skills/epf-build/scripts/epf-build.py index c4ff7d11..0447d32d 100644 --- a/.claude/skills/epf-build/scripts/epf-build.py +++ b/.claude/skills/epf-build/scripts/epf-build.py @@ -1,34 +1,67 @@ #!/usr/bin/env python3 -# epf-build v1.0 — Build external data processor or report (EPF/ERF) from XML sources +# epf-build v1.1 — Build external data processor or report (EPF/ERF) from XML sources # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills import argparse import glob +import json import os import random +import re import shutil import subprocess import sys import tempfile +def _find_project_v8path(): + """Walk up from CWD to find .v8-project.json and read its v8path.""" + d = os.getcwd() + while True: + pf = os.path.join(d, ".v8-project.json") + if os.path.isfile(pf): + try: + with open(pf, encoding="utf-8-sig") as f: + data = json.load(f) + v = data.get("v8path") + if v: + return v + except Exception: + pass + return None + parent = os.path.dirname(d) + if parent == d: + return None + d = parent + + +def _version_key(p): + """Numeric sort key from version dir name (.../1cv8//bin/1cv8.exe).""" + ver = os.path.basename(os.path.dirname(os.path.dirname(p))) + return [int(x) for x in re.findall(r"\d+", ver)] + + def resolve_v8path(v8path): """Resolve path to 1cv8.exe.""" if not v8path: - candidates = glob.glob(r"C:\Program Files\1cv8\*\bin\1cv8.exe") + v8path = _find_project_v8path() + if not v8path: + candidates = ( + glob.glob(r"C:\Program Files\1cv8\*\bin\1cv8.exe") + + glob.glob(r"C:\Program Files (x86)\1cv8\*\bin\1cv8.exe") + ) if candidates: - candidates.sort() - return candidates[-1] + v8path = max(candidates, key=_version_key) + ver = os.path.basename(os.path.dirname(os.path.dirname(v8path))) + print(f"Auto-selected platform {ver}: {v8path}") else: print("Error: 1cv8.exe not found. Specify -V8Path", file=sys.stderr) sys.exit(1) - elif os.path.isdir(v8path): + if os.path.isdir(v8path): v8path = os.path.join(v8path, "1cv8.exe") - if not os.path.isfile(v8path): print(f"Error: 1cv8.exe not found at {v8path}", file=sys.stderr) sys.exit(1) - return v8path diff --git a/.claude/skills/epf-dump/scripts/epf-dump.ps1 b/.claude/skills/epf-dump/scripts/epf-dump.ps1 index a15a5e2f..631a3619 100644 --- a/.claude/skills/epf-dump/scripts/epf-dump.ps1 +++ b/.claude/skills/epf-dump/scripts/epf-dump.ps1 @@ -1,4 +1,4 @@ -# epf-dump v1.0 — Dump external data processor or report (EPF/ERF) to XML sources +# epf-dump v1.1 — Dump external data processor or report (EPF/ERF) to XML sources # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills <# .SYNOPSIS @@ -77,15 +77,40 @@ $OutputEncoding = [System.Text.Encoding]::UTF8 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 # --- Resolve V8Path --- +function Find-ProjectV8Path { + $dir = (Get-Location).Path + while ($dir) { + $pf = Join-Path $dir ".v8-project.json" + if (Test-Path $pf) { + try { + $j = Get-Content $pf -Raw -Encoding UTF8 | ConvertFrom-Json + if ($j.v8path) { return [string]$j.v8path } + } catch {} + return $null + } + $parent = Split-Path $dir -Parent + if (-not $parent -or $parent -eq $dir) { break } + $dir = $parent + } + return $null +} + if (-not $V8Path) { - $found = Get-ChildItem "C:\Program Files\1cv8\*\bin\1cv8.exe" -ErrorAction SilentlyContinue | Sort-Object FullName -Descending | Select-Object -First 1 + $V8Path = Find-ProjectV8Path +} +if (-not $V8Path) { + $found = Get-ChildItem @("C:\Program Files\1cv8\*\bin\1cv8.exe", "C:\Program Files (x86)\1cv8\*\bin\1cv8.exe") -ErrorAction SilentlyContinue | + Sort-Object { try { [version]$_.Directory.Parent.Name } catch { [version]"0.0" } } -Descending | + Select-Object -First 1 if ($found) { $V8Path = $found.FullName + Write-Host "Auto-selected platform $($found.Directory.Parent.Name): $V8Path" -ForegroundColor Yellow } else { Write-Host "Error: 1cv8.exe not found. Specify -V8Path" -ForegroundColor Red exit 1 } -} elseif (Test-Path $V8Path -PathType Container) { +} +if (Test-Path $V8Path -PathType Container) { $V8Path = Join-Path $V8Path "1cv8.exe" } diff --git a/.claude/skills/epf-dump/scripts/epf-dump.py b/.claude/skills/epf-dump/scripts/epf-dump.py index ab1c8ea0..efc0e1a4 100644 --- a/.claude/skills/epf-dump/scripts/epf-dump.py +++ b/.claude/skills/epf-dump/scripts/epf-dump.py @@ -1,34 +1,67 @@ #!/usr/bin/env python3 -# epf-dump v1.0 — Dump external data processor or report (EPF/ERF) to XML sources +# epf-dump v1.1 — Dump external data processor or report (EPF/ERF) to XML sources # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills import argparse import glob +import json import os import random +import re import shutil import subprocess import sys import tempfile +def _find_project_v8path(): + """Walk up from CWD to find .v8-project.json and read its v8path.""" + d = os.getcwd() + while True: + pf = os.path.join(d, ".v8-project.json") + if os.path.isfile(pf): + try: + with open(pf, encoding="utf-8-sig") as f: + data = json.load(f) + v = data.get("v8path") + if v: + return v + except Exception: + pass + return None + parent = os.path.dirname(d) + if parent == d: + return None + d = parent + + +def _version_key(p): + """Numeric sort key from version dir name (.../1cv8//bin/1cv8.exe).""" + ver = os.path.basename(os.path.dirname(os.path.dirname(p))) + return [int(x) for x in re.findall(r"\d+", ver)] + + def resolve_v8path(v8path): """Resolve path to 1cv8.exe.""" if not v8path: - candidates = glob.glob(r"C:\Program Files\1cv8\*\bin\1cv8.exe") + v8path = _find_project_v8path() + if not v8path: + candidates = ( + glob.glob(r"C:\Program Files\1cv8\*\bin\1cv8.exe") + + glob.glob(r"C:\Program Files (x86)\1cv8\*\bin\1cv8.exe") + ) if candidates: - candidates.sort() - return candidates[-1] + v8path = max(candidates, key=_version_key) + ver = os.path.basename(os.path.dirname(os.path.dirname(v8path))) + print(f"Auto-selected platform {ver}: {v8path}") else: print("Error: 1cv8.exe not found. Specify -V8Path", file=sys.stderr) sys.exit(1) - elif os.path.isdir(v8path): + if os.path.isdir(v8path): v8path = os.path.join(v8path, "1cv8.exe") - if not os.path.isfile(v8path): print(f"Error: 1cv8.exe not found at {v8path}", file=sys.stderr) sys.exit(1) - return v8path diff --git a/.claude/skills/web-publish/scripts/web-publish.ps1 b/.claude/skills/web-publish/scripts/web-publish.ps1 index 9a918d28..46fc1997 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.2 — Publish 1C infobase via Apache +# web-publish v1.3 — Publish 1C infobase via Apache # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills <# .SYNOPSIS @@ -87,10 +87,34 @@ $OutputEncoding = [System.Text.Encoding]::UTF8 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 # --- Resolve V8Path --- +function Find-ProjectV8Path { + $dir = (Get-Location).Path + while ($dir) { + $pf = Join-Path $dir ".v8-project.json" + if (Test-Path $pf) { + try { + $j = Get-Content $pf -Raw -Encoding UTF8 | ConvertFrom-Json + if ($j.v8path) { return [string]$j.v8path } + } catch {} + return $null + } + $parent = Split-Path $dir -Parent + if (-not $parent -or $parent -eq $dir) { break } + $dir = $parent + } + return $null +} + if (-not $V8Path) { - $found = Get-ChildItem "C:\Program Files\1cv8\*\bin\1cv8.exe" -ErrorAction SilentlyContinue | Sort-Object FullName -Descending | Select-Object -First 1 + $V8Path = Find-ProjectV8Path +} +if (-not $V8Path) { + $found = Get-ChildItem @("C:\Program Files\1cv8\*\bin\1cv8.exe", "C:\Program Files (x86)\1cv8\*\bin\1cv8.exe") -ErrorAction SilentlyContinue | + Sort-Object { try { [version]$_.Directory.Parent.Name } catch { [version]"0.0" } } -Descending | + Select-Object -First 1 if ($found) { $V8Path = Split-Path $found.FullName -Parent + Write-Host "Auto-selected platform $($found.Directory.Parent.Name): $V8Path" -ForegroundColor Yellow } else { Write-Host "Error: платформа 1С не найдена. Укажите -V8Path" -ForegroundColor Red exit 1 diff --git a/.claude/skills/web-publish/scripts/web-publish.py b/.claude/skills/web-publish/scripts/web-publish.py index 2bf30105..56bd2232 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.2 — Publish 1C infobase via Apache +# web-publish v1.3 — Publish 1C infobase via Apache # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills """ @@ -11,6 +11,7 @@ import argparse import glob +import json import os import re import shutil @@ -24,6 +25,33 @@ import zipfile import psutil +def _find_project_v8path(): + """Walk up from CWD to find .v8-project.json and read its v8path.""" + d = os.getcwd() + while True: + pf = os.path.join(d, ".v8-project.json") + if os.path.isfile(pf): + try: + with open(pf, encoding="utf-8-sig") as f: + data = json.load(f) + v = data.get("v8path") + if v: + return v + except Exception: + pass + return None + parent = os.path.dirname(d) + if parent == d: + return None + d = parent + + +def _version_key(p): + """Numeric sort key from version dir name (.../1cv8//bin/1cv8.exe).""" + ver = os.path.basename(os.path.dirname(os.path.dirname(p))) + return [int(x) for x in re.findall(r"\d+", ver)] + + def get_our_httpd(httpd_exe_norm): """Filter httpd processes by our ApachePath.""" result = [] @@ -78,10 +106,17 @@ def main(): # --- Resolve V8Path --- v8_path = args.V8Path if not v8_path: - candidates = glob.glob(r'C:\Program Files\1cv8\*\bin\1cv8.exe') - candidates.sort(reverse=True) + v8_path = _find_project_v8path() + if not v8_path: + candidates = ( + glob.glob(r'C:\Program Files\1cv8\*\bin\1cv8.exe') + + glob.glob(r'C:\Program Files (x86)\1cv8\*\bin\1cv8.exe') + ) if candidates: - v8_path = os.path.dirname(candidates[0]) + best = max(candidates, key=_version_key) + v8_path = os.path.dirname(best) + ver = os.path.basename(os.path.dirname(v8_path)) + print(f'Auto-selected platform {ver}: {v8_path}') else: print('Error: платформа 1С не найдена. Укажите -V8Path', file=sys.stderr) sys.exit(1)