fix(db-*, epf-*): ошибка до запуска платформы не выдаётся за успех

Временный каталог брался из $env:TEMP, которой вне Windows нет. Join-Path
падал на привязке параметра внутри try/finally без catch: try прерывался,
finally отрабатывал, и скрипт выходил с кодом 0 — платформа не запускалась,
постусловие не проверялось (#106).

- временный каталог — [IO.Path]::GetTempPath() (на Windows тот же путь);
- верхнеуровневый trap { … exit 1 } в 15 скриптах db-*/epf-*, запускающих
  платформу: любая необработанная ошибка даёт код 1 и печатает место;
- уборка временного каталога в finally не падает на пустом пути;
- гард check-ps-portability.mjs держит оба правила.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-09-26 13:53:51 +03:00
co-authored by Claude Opus 5.5
parent 317dce6d9f
commit eb1796ef94
35 changed files with 233 additions and 79 deletions
@@ -1,4 +1,4 @@
# db-cfe-admin v1.1 — Configuration extensions in a 1C infobase: list, check, properties, delete # db-cfe-admin v1.2 — Configuration extensions in a 1C infobase: list, check, properties, delete
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
# NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется. # NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется.
<# <#
@@ -103,6 +103,11 @@ param(
[string[]]$AdditionalIbcmdArguments = @() [string[]]$AdditionalIbcmdArguments = @()
) )
# Необработанная ошибка (напр. привязка параметра) внутри try/finally без catch завершала
# скрипт с кодом 0 — ложный успех без запуска платформы. Любая такая ошибка — код 1.
# py-порт: необработанное исключение и так даёт код 1.
trap { Write-Host "Error: $($_.Exception.Message) ($($_.InvocationInfo.ScriptName):$($_.InvocationInfo.ScriptLineNumber))" -ForegroundColor Red; exit 1 }
$OutputEncoding = [System.Text.Encoding]::UTF8 $OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
@@ -663,7 +668,7 @@ function Invoke-Designer {
Write-Host "Error: 1C executable not found at $v8Exe" -ForegroundColor Red Write-Host "Error: 1C executable not found at $v8Exe" -ForegroundColor Red
exit 1 exit 1
} }
$tempDir = Join-Path $env:TEMP "db_cfe_admin_$(Get-Random)" $tempDir = Join-Path ([IO.Path]::GetTempPath()) "db_cfe_admin_$(Get-Random)"
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
try { try {
$arguments = @("DESIGNER") $arguments = @("DESIGNER")
@@ -694,7 +699,7 @@ function Invoke-Designer {
Output = $res.Output Output = $res.Output
} }
} finally { } finally {
if (Test-Path $tempDir) { Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue } if ($tempDir -and (Test-Path $tempDir)) { Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue }
} }
} }
@@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# db-cfe-admin v1.1 — Configuration extensions in a 1C infobase: list, check, properties, delete # db-cfe-admin v1.2 — Configuration extensions in a 1C infobase: list, check, properties, delete
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse import argparse
@@ -1,4 +1,4 @@
# db-create v1.15 — Create 1C information base # db-create v1.16 — Create 1C information base
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
# NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется. # NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется.
<# <#
@@ -76,6 +76,11 @@ param(
[string[]]$AdditionalIbcmdArguments = @() [string[]]$AdditionalIbcmdArguments = @()
) )
# Необработанная ошибка (напр. привязка параметра) внутри try/finally без catch завершала
# скрипт с кодом 0 — ложный успех без запуска платформы. Любая такая ошибка — код 1.
# py-порт: необработанное исключение и так даёт код 1.
trap { Write-Host "Error: $($_.Exception.Message) ($($_.InvocationInfo.ScriptName):$($_.InvocationInfo.ScriptLineNumber))" -ForegroundColor Red; exit 1 }
$OutputEncoding = [System.Text.Encoding]::UTF8 $OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
@@ -433,7 +438,7 @@ if ($UseTemplate -and -not (Test-Path $UseTemplate)) {
} }
# --- Temp dir --- # --- Temp dir ---
$tempDir = Join-Path $env:TEMP "db_create_$(Get-Random)" $tempDir = Join-Path ([IO.Path]::GetTempPath()) "db_create_$(Get-Random)"
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
try { try {
@@ -533,7 +538,7 @@ try {
exit $exitCode exit $exitCode
} finally { } finally {
if (Test-Path $tempDir) { if ($tempDir -and (Test-Path $tempDir)) {
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
} }
} }
@@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# db-create v1.15 — Create 1C information base # db-create v1.16 — Create 1C information base
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse import argparse
@@ -1,4 +1,4 @@
# db-dump-cf v1.17 — Dump 1C configuration to CF file # db-dump-cf v1.18 — Dump 1C configuration to CF file
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
# NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется. # NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется.
<# <#
@@ -85,6 +85,11 @@ param(
[string[]]$AdditionalIbcmdArguments = @() [string[]]$AdditionalIbcmdArguments = @()
) )
# Необработанная ошибка (напр. привязка параметра) внутри try/finally без catch завершала
# скрипт с кодом 0 — ложный успех без запуска платформы. Любая такая ошибка — код 1.
# py-порт: необработанное исключение и так даёт код 1.
trap { Write-Host "Error: $($_.Exception.Message) ($($_.InvocationInfo.ScriptName):$($_.InvocationInfo.ScriptLineNumber))" -ForegroundColor Red; exit 1 }
$OutputEncoding = [System.Text.Encoding]::UTF8 $OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
@@ -461,7 +466,7 @@ if ($outDir -and -not (Test-Path $outDir)) {
} }
# --- Temp dir --- # --- Temp dir ---
$tempDir = Join-Path $env:TEMP "db_dump_cf_$(Get-Random)" $tempDir = Join-Path ([IO.Path]::GetTempPath()) "db_dump_cf_$(Get-Random)"
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
try { try {
@@ -553,7 +558,7 @@ try {
exit $exitCode exit $exitCode
} finally { } finally {
if (Test-Path $tempDir) { if ($tempDir -and (Test-Path $tempDir)) {
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
} }
} }
@@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# db-dump-cf v1.17 — Dump 1C configuration to CF file # db-dump-cf v1.18 — Dump 1C configuration to CF file
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse import argparse
@@ -1,4 +1,4 @@
# db-dump-dt v1.16 — Dump 1C information base to DT file # db-dump-dt v1.17 — Dump 1C information base to DT file
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
# NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется. # NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется.
<# <#
@@ -69,6 +69,11 @@ param(
[string[]]$AdditionalIbcmdArguments = @() [string[]]$AdditionalIbcmdArguments = @()
) )
# Необработанная ошибка (напр. привязка параметра) внутри try/finally без catch завершала
# скрипт с кодом 0 — ложный успех без запуска платформы. Любая такая ошибка — код 1.
# py-порт: необработанное исключение и так даёт код 1.
trap { Write-Host "Error: $($_.Exception.Message) ($($_.InvocationInfo.ScriptName):$($_.InvocationInfo.ScriptLineNumber))" -ForegroundColor Red; exit 1 }
$OutputEncoding = [System.Text.Encoding]::UTF8 $OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
@@ -445,7 +450,7 @@ if ($outDir -and -not (Test-Path $outDir)) {
} }
# --- Temp dir --- # --- Temp dir ---
$tempDir = Join-Path $env:TEMP "db_dump_dt_$(Get-Random)" $tempDir = Join-Path ([IO.Path]::GetTempPath()) "db_dump_dt_$(Get-Random)"
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
try { try {
@@ -527,7 +532,7 @@ try {
exit $exitCode exit $exitCode
} finally { } finally {
if (Test-Path $tempDir) { if ($tempDir -and (Test-Path $tempDir)) {
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
} }
} }
@@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# db-dump-dt v1.16 — Dump 1C information base to DT file # db-dump-dt v1.17 — Dump 1C information base to DT file
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse import argparse
@@ -1,4 +1,4 @@
# db-dump-xml v1.23 — Dump 1C configuration to XML files # db-dump-xml v1.24 — Dump 1C configuration to XML files
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
# NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется. # NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется.
<# <#
@@ -122,6 +122,11 @@ param(
[string[]]$AdditionalIbcmdArguments = @() [string[]]$AdditionalIbcmdArguments = @()
) )
# Необработанная ошибка (напр. привязка параметра) внутри try/finally без catch завершала
# скрипт с кодом 0 — ложный успех без запуска платформы. Любая такая ошибка — код 1.
# py-порт: необработанное исключение и так даёт код 1.
trap { Write-Host "Error: $($_.Exception.Message) ($($_.InvocationInfo.ScriptName):$($_.InvocationInfo.ScriptLineNumber))" -ForegroundColor Red; exit 1 }
$OutputEncoding = [System.Text.Encoding]::UTF8 $OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
@@ -620,7 +625,7 @@ if (-not (Test-Path $ConfigDir)) {
} }
# --- Temp dir --- # --- Temp dir ---
$tempDir = Join-Path $env:TEMP "db_dump_xml_$(Get-Random)" $tempDir = Join-Path ([IO.Path]::GetTempPath()) "db_dump_xml_$(Get-Random)"
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
try { try {
@@ -782,7 +787,7 @@ try {
exit $exitCode exit $exitCode
} finally { } finally {
if (Test-Path $tempDir) { if ($tempDir -and (Test-Path $tempDir)) {
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
} }
} }
@@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# db-dump-xml v1.23 — Dump 1C configuration to XML files # db-dump-xml v1.24 — Dump 1C configuration to XML files
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse import argparse
@@ -1,4 +1,4 @@
# db-load-cf v1.19 — Load 1C configuration from CF file # db-load-cf v1.20 — Load 1C configuration from CF file
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
# NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется. # NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется.
<# <#
@@ -95,6 +95,11 @@ param(
[string[]]$AdditionalIbcmdArguments = @() [string[]]$AdditionalIbcmdArguments = @()
) )
# Необработанная ошибка (напр. привязка параметра) внутри try/finally без catch завершала
# скрипт с кодом 0 — ложный успех без запуска платформы. Любая такая ошибка — код 1.
# py-порт: необработанное исключение и так даёт код 1.
trap { Write-Host "Error: $($_.Exception.Message) ($($_.InvocationInfo.ScriptName):$($_.InvocationInfo.ScriptLineNumber))" -ForegroundColor Red; exit 1 }
$OutputEncoding = [System.Text.Encoding]::UTF8 $OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
@@ -472,7 +477,7 @@ function Invoke-ApplyCheck {
$exeLeaf = Split-Path $Exe -Leaf $exeLeaf = Split-Path $Exe -Leaf
$v8 = if ($exeLeaf -match '^ibcmd') { Join-Path $exeDir ("1cv8" + [System.IO.Path]::GetExtension($Exe)) } else { $Exe } $v8 = if ($exeLeaf -match '^ibcmd') { Join-Path $exeDir ("1cv8" + [System.IO.Path]::GetExtension($Exe)) } else { $Exe }
if (-not (Test-Path $v8)) { return @{ Skipped = $true; Reason = "1cv8 not found at $v8"; ExitCode = 0; Lines = @() } } if (-not (Test-Path $v8)) { return @{ Skipped = $true; Reason = "1cv8 not found at $v8"; ExitCode = 0; Lines = @() } }
$dir = Join-Path $env:TEMP "apply_check_$(Get-Random)" $dir = Join-Path ([IO.Path]::GetTempPath()) "apply_check_$(Get-Random)"
New-Item -ItemType Directory -Path $dir -Force | Out-Null New-Item -ItemType Directory -Path $dir -Force | Out-Null
try { try {
$a = @("DESIGNER") + $ConnArgs + @("/CheckCanApplyConfigurationExtensions") $a = @("DESIGNER") + $ConnArgs + @("/CheckCanApplyConfigurationExtensions")
@@ -488,7 +493,7 @@ function Invoke-ApplyCheck {
} }
return @{ Skipped = $false; Reason = ''; ExitCode = $res.ExitCode; Lines = $lines } return @{ Skipped = $false; Reason = ''; ExitCode = $res.ExitCode; Lines = $lines }
} finally { } finally {
if (Test-Path $dir) { Remove-Item -Path $dir -Recurse -Force -ErrorAction SilentlyContinue } if ($dir -and (Test-Path $dir)) { Remove-Item -Path $dir -Recurse -Force -ErrorAction SilentlyContinue }
} }
} }
@@ -548,7 +553,7 @@ if (-not (Test-Path $InputFile)) {
} }
# --- Temp dir --- # --- Temp dir ---
$tempDir = Join-Path $env:TEMP "db_load_cf_$(Get-Random)" $tempDir = Join-Path ([IO.Path]::GetTempPath()) "db_load_cf_$(Get-Random)"
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
try { try {
@@ -646,7 +651,7 @@ try {
exit $exitCode exit $exitCode
} finally { } finally {
if (Test-Path $tempDir) { if ($tempDir -and (Test-Path $tempDir)) {
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
} }
} }
@@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# db-load-cf v1.19 — Load 1C configuration from CF file # db-load-cf v1.20 — Load 1C configuration from CF file
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse import argparse
@@ -1,4 +1,4 @@
# db-load-dt v1.17 — Load 1C information base from DT file # db-load-dt v1.18 — Load 1C information base from DT file
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
# NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется. # NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется.
<# <#
@@ -82,6 +82,11 @@ param(
[string[]]$AdditionalIbcmdArguments = @() [string[]]$AdditionalIbcmdArguments = @()
) )
# Необработанная ошибка (напр. привязка параметра) внутри try/finally без catch завершала
# скрипт с кодом 0 — ложный успех без запуска платформы. Любая такая ошибка — код 1.
# py-порт: необработанное исключение и так даёт код 1.
trap { Write-Host "Error: $($_.Exception.Message) ($($_.InvocationInfo.ScriptName):$($_.InvocationInfo.ScriptLineNumber))" -ForegroundColor Red; exit 1 }
$OutputEncoding = [System.Text.Encoding]::UTF8 $OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
@@ -468,7 +473,7 @@ if (-not (Test-Path $InputFile)) {
} }
# --- Temp dir --- # --- Temp dir ---
$tempDir = Join-Path $env:TEMP "db_load_dt_$(Get-Random)" $tempDir = Join-Path ([IO.Path]::GetTempPath()) "db_load_dt_$(Get-Random)"
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
try { try {
@@ -544,7 +549,7 @@ try {
exit $exitCode exit $exitCode
} finally { } finally {
if (Test-Path $tempDir) { if ($tempDir -and (Test-Path $tempDir)) {
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
} }
} }
@@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# db-load-dt v1.17 — Load 1C information base from DT file # db-load-dt v1.18 — Load 1C information base from DT file
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse import argparse
@@ -1,4 +1,4 @@
# db-load-git v1.29 — Load Git changes into 1C database # db-load-git v1.30 — Load Git changes into 1C database
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
# NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется. # NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется.
<# <#
@@ -136,6 +136,11 @@ param(
[string[]]$AdditionalIbcmdArguments = @() [string[]]$AdditionalIbcmdArguments = @()
) )
# Необработанная ошибка (напр. привязка параметра) внутри try/finally без catch завершала
# скрипт с кодом 0 — ложный успех без запуска платформы. Любая такая ошибка — код 1.
# py-порт: необработанное исключение и так даёт код 1.
trap { Write-Host "Error: $($_.Exception.Message) ($($_.InvocationInfo.ScriptName):$($_.InvocationInfo.ScriptLineNumber))" -ForegroundColor Red; exit 1 }
$OutputEncoding = [System.Text.Encoding]::UTF8 $OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
@@ -664,7 +669,7 @@ function Invoke-ApplyCheck {
$exeLeaf = Split-Path $Exe -Leaf $exeLeaf = Split-Path $Exe -Leaf
$v8 = if ($exeLeaf -match '^ibcmd') { Join-Path $exeDir ("1cv8" + [System.IO.Path]::GetExtension($Exe)) } else { $Exe } $v8 = if ($exeLeaf -match '^ibcmd') { Join-Path $exeDir ("1cv8" + [System.IO.Path]::GetExtension($Exe)) } else { $Exe }
if (-not (Test-Path $v8)) { return @{ Skipped = $true; Reason = "1cv8 not found at $v8"; ExitCode = 0; Lines = @() } } if (-not (Test-Path $v8)) { return @{ Skipped = $true; Reason = "1cv8 not found at $v8"; ExitCode = 0; Lines = @() } }
$dir = Join-Path $env:TEMP "apply_check_$(Get-Random)" $dir = Join-Path ([IO.Path]::GetTempPath()) "apply_check_$(Get-Random)"
New-Item -ItemType Directory -Path $dir -Force | Out-Null New-Item -ItemType Directory -Path $dir -Force | Out-Null
try { try {
$a = @("DESIGNER") + $ConnArgs + @("/CheckCanApplyConfigurationExtensions") $a = @("DESIGNER") + $ConnArgs + @("/CheckCanApplyConfigurationExtensions")
@@ -680,7 +685,7 @@ function Invoke-ApplyCheck {
} }
return @{ Skipped = $false; Reason = ''; ExitCode = $res.ExitCode; Lines = $lines } return @{ Skipped = $false; Reason = ''; ExitCode = $res.ExitCode; Lines = $lines }
} finally { } finally {
if (Test-Path $dir) { Remove-Item -Path $dir -Recurse -Force -ErrorAction SilentlyContinue } if ($dir -and (Test-Path $dir)) { Remove-Item -Path $dir -Recurse -Force -ErrorAction SilentlyContinue }
} }
} }
@@ -911,7 +916,7 @@ if ($DryRun) {
} }
# --- Temp dir --- # --- Temp dir ---
$tempDir = Join-Path $env:TEMP "db_load_git_$(Get-Random)" $tempDir = Join-Path ([IO.Path]::GetTempPath()) "db_load_git_$(Get-Random)"
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
try { try {
@@ -1060,7 +1065,7 @@ try {
exit $exitCode exit $exitCode
} finally { } finally {
if (Test-Path $tempDir) { if ($tempDir -and (Test-Path $tempDir)) {
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
} }
} }
@@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# db-load-git v1.29 — Load Git changes into 1C database # db-load-git v1.30 — Load Git changes into 1C database
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse import argparse
@@ -1,4 +1,4 @@
# db-load-xml v1.31 — Load 1C configuration from XML files # db-load-xml v1.32 — Load 1C configuration from XML files
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
# NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется. # NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется.
<# <#
@@ -132,6 +132,11 @@ param(
[string[]]$AdditionalIbcmdArguments = @() [string[]]$AdditionalIbcmdArguments = @()
) )
# Необработанная ошибка (напр. привязка параметра) внутри try/finally без catch завершала
# скрипт с кодом 0 — ложный успех без запуска платформы. Любая такая ошибка — код 1.
# py-порт: необработанное исключение и так даёт код 1.
trap { Write-Host "Error: $($_.Exception.Message) ($($_.InvocationInfo.ScriptName):$($_.InvocationInfo.ScriptLineNumber))" -ForegroundColor Red; exit 1 }
$OutputEncoding = [System.Text.Encoding]::UTF8 $OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
@@ -627,7 +632,7 @@ function Invoke-ApplyCheck {
$exeLeaf = Split-Path $Exe -Leaf $exeLeaf = Split-Path $Exe -Leaf
$v8 = if ($exeLeaf -match '^ibcmd') { Join-Path $exeDir ("1cv8" + [System.IO.Path]::GetExtension($Exe)) } else { $Exe } $v8 = if ($exeLeaf -match '^ibcmd') { Join-Path $exeDir ("1cv8" + [System.IO.Path]::GetExtension($Exe)) } else { $Exe }
if (-not (Test-Path $v8)) { return @{ Skipped = $true; Reason = "1cv8 not found at $v8"; ExitCode = 0; Lines = @() } } if (-not (Test-Path $v8)) { return @{ Skipped = $true; Reason = "1cv8 not found at $v8"; ExitCode = 0; Lines = @() } }
$dir = Join-Path $env:TEMP "apply_check_$(Get-Random)" $dir = Join-Path ([IO.Path]::GetTempPath()) "apply_check_$(Get-Random)"
New-Item -ItemType Directory -Path $dir -Force | Out-Null New-Item -ItemType Directory -Path $dir -Force | Out-Null
try { try {
$a = @("DESIGNER") + $ConnArgs + @("/CheckCanApplyConfigurationExtensions") $a = @("DESIGNER") + $ConnArgs + @("/CheckCanApplyConfigurationExtensions")
@@ -643,7 +648,7 @@ function Invoke-ApplyCheck {
} }
return @{ Skipped = $false; Reason = ''; ExitCode = $res.ExitCode; Lines = $lines } return @{ Skipped = $false; Reason = ''; ExitCode = $res.ExitCode; Lines = $lines }
} finally { } finally {
if (Test-Path $dir) { Remove-Item -Path $dir -Recurse -Force -ErrorAction SilentlyContinue } if ($dir -and (Test-Path $dir)) { Remove-Item -Path $dir -Recurse -Force -ErrorAction SilentlyContinue }
} }
} }
@@ -726,7 +731,7 @@ if ($Mode -eq "Partial" -and $AllExtensions) {
} }
# --- Temp dir --- # --- Temp dir ---
$tempDir = Join-Path $env:TEMP "db_load_xml_$(Get-Random)" $tempDir = Join-Path ([IO.Path]::GetTempPath()) "db_load_xml_$(Get-Random)"
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
try { try {
@@ -940,7 +945,7 @@ try {
exit $exitCode exit $exitCode
} finally { } finally {
if (Test-Path $tempDir) { if ($tempDir -and (Test-Path $tempDir)) {
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
} }
} }
@@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# db-load-xml v1.31 — Load 1C configuration from XML files # db-load-xml v1.32 — Load 1C configuration from XML files
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse import argparse
+11 -6
View File
@@ -1,4 +1,4 @@
# db-repo v1.16 — 1C configuration repository operations # db-repo v1.17 — 1C configuration repository operations
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
# NB: движок только 1cv8 — ibcmd работу с хранилищем не поддерживает (нет такого режима). # NB: движок только 1cv8 — ibcmd работу с хранилищем не поддерживает (нет такого режима).
<# <#
@@ -176,6 +176,11 @@ param(
[string[]]$AdditionalV8Arguments = @() [string[]]$AdditionalV8Arguments = @()
) )
# Необработанная ошибка (напр. привязка параметра) внутри try/finally без catch завершала
# скрипт с кодом 0 — ложный успех без запуска платформы. Любая такая ошибка — код 1.
# py-порт: необработанное исключение и так даёт код 1.
trap { Write-Host "Error: $($_.Exception.Message) ($($_.InvocationInfo.ScriptName):$($_.InvocationInfo.ScriptLineNumber))" -ForegroundColor Red; exit 1 }
$OutputEncoding = [System.Text.Encoding]::UTF8 $OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
function Protect-Secrets { function Protect-Secrets {
@@ -749,7 +754,7 @@ function Write-ReceivedWarning {
$owners = Get-OwnerObjects $Received $owners = Get-OwnerObjects $Received
$hasRoot = @($Received | Where-Object { ($_ -split '\.').Count -eq 1 }).Count -gt 0 $hasRoot = @($Received | Where-Object { ($_ -split '\.').Count -eq 1 }).Count -gt 0
if ($owners.Count -gt 0) { if ($owners.Count -gt 0) {
$listPath = Join-Path $env:TEMP "db-repo-received.txt" $listPath = Join-Path ([IO.Path]::GetTempPath()) "db-repo-received.txt"
$utf8Bom = New-Object System.Text.UTF8Encoding($true) $utf8Bom = New-Object System.Text.UTF8Encoding($true)
[System.IO.File]::WriteAllLines($listPath, $owners, $utf8Bom) [System.IO.File]::WriteAllLines($listPath, $owners, $utf8Bom)
Write-Host "Исходники в проекте устарели по этим объектам. Перевыгрузите их ПЕРЕД правкой," -ForegroundColor Yellow Write-Host "Исходники в проекте устарели по этим объектам. Перевыгрузите их ПЕРЕД правкой," -ForegroundColor Yellow
@@ -838,7 +843,7 @@ $script:ListLimit = 20
function Save-ObjectList { function Save-ObjectList {
param([string[]]$Names, [string]$Key) param([string[]]$Names, [string]$Key)
if (-not $Key) { $Key = 'objects' } if (-not $Key) { $Key = 'objects' }
$path = Join-Path $env:TEMP "db-repo-$Key.txt" $path = Join-Path ([IO.Path]::GetTempPath()) "db-repo-$Key.txt"
$utf8Bom = New-Object System.Text.UTF8Encoding($true) $utf8Bom = New-Object System.Text.UTF8Encoding($true)
[System.IO.File]::WriteAllLines($path, $Names, $utf8Bom) [System.IO.File]::WriteAllLines($path, $Names, $utf8Bom)
return $path return $path
@@ -1097,7 +1102,7 @@ if ($WithChildren) {
switch ($cmd) { switch ($cmd) {
'report' { 'report' {
# Отчёт печатается в вывод, поэтому путь нужен только если его хотят сохранить. # Отчёт печатается в вывод, поэтому путь нужен только если его хотят сохранить.
if (-not $OutputFile) { $OutputFile = Join-Path $env:TEMP "db-repo-report.$ReportFormat" } if (-not $OutputFile) { $OutputFile = Join-Path ([IO.Path]::GetTempPath()) "db-repo-report.$ReportFormat" }
} }
'dump-cfg' { if (-not $OutputFile) { Write-Host "Error: -OutputFile (path to the .cf file) is required for dump-cfg" -ForegroundColor Red; exit 1 } } 'dump-cfg' { if (-not $OutputFile) { Write-Host "Error: -OutputFile (path to the .cf file) is required for dump-cfg" -ForegroundColor Red; exit 1 } }
'add-user' { if (-not $NewUser -or -not $Rights) { Write-Host "Error: -NewUser and -Rights are required for add-user" -ForegroundColor Red; exit 1 } } 'add-user' { if (-not $NewUser -or -not $Rights) { Write-Host "Error: -NewUser and -Rights are required for add-user" -ForegroundColor Red; exit 1 } }
@@ -1107,7 +1112,7 @@ switch ($cmd) {
$extraArgs = @(Resolve-ExtraArgs $AdditionalV8Arguments @{}) $extraArgs = @(Resolve-ExtraArgs $AdditionalV8Arguments @{})
$tempDir = Join-Path $env:TEMP "db_repo_$(Get-Random)" $tempDir = Join-Path ([IO.Path]::GetTempPath()) "db_repo_$(Get-Random)"
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
try { try {
@@ -1275,7 +1280,7 @@ try {
exit $verdict exit $verdict
} finally { } finally {
if (Test-Path $tempDir) { if ($tempDir -and (Test-Path $tempDir)) {
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
} }
} }
+1 -1
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# db-repo v1.16 — 1C configuration repository operations # db-repo v1.17 — 1C configuration repository operations
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
# NB: движок только 1cv8 — ibcmd работу с хранилищем не поддерживает (нет такого режима). # NB: движок только 1cv8 — ibcmd работу с хранилищем не поддерживает (нет такого режима).
"""Работа с хранилищем конфигурации 1С. """Работа с хранилищем конфигурации 1С.
+6 -1
View File
@@ -1,4 +1,4 @@
# db-run v1.11 — Launch 1C:Enterprise # db-run v1.12 — Launch 1C:Enterprise
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
# NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется. # NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется.
<# <#
@@ -88,6 +88,11 @@ param(
[string[]]$AdditionalIbcmdArguments = @() [string[]]$AdditionalIbcmdArguments = @()
) )
# Необработанная ошибка (напр. привязка параметра) внутри try/finally без catch завершала
# скрипт с кодом 0 — ложный успех без запуска платформы. Любая такая ошибка — код 1.
# py-порт: необработанное исключение и так даёт код 1.
trap { Write-Host "Error: $($_.Exception.Message) ($($_.InvocationInfo.ScriptName):$($_.InvocationInfo.ScriptLineNumber))" -ForegroundColor Red; exit 1 }
$OutputEncoding = [System.Text.Encoding]::UTF8 $OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
+1 -1
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# db-run v1.11 — Launch 1C:Enterprise # db-run v1.12 — Launch 1C:Enterprise
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse import argparse
+10 -5
View File
@@ -1,4 +1,4 @@
# db-update v1.21 — Update 1C database configuration # db-update v1.22 — Update 1C database configuration
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
# NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется. # NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется.
<# <#
@@ -119,6 +119,11 @@ param(
[string[]]$AdditionalIbcmdArguments = @() [string[]]$AdditionalIbcmdArguments = @()
) )
# Необработанная ошибка (напр. привязка параметра) внутри try/finally без catch завершала
# скрипт с кодом 0 — ложный успех без запуска платформы. Любая такая ошибка — код 1.
# py-порт: необработанное исключение и так даёт код 1.
trap { Write-Host "Error: $($_.Exception.Message) ($($_.InvocationInfo.ScriptName):$($_.InvocationInfo.ScriptLineNumber))" -ForegroundColor Red; exit 1 }
if ($Dynamic) { $Dynamic = if (@('on', 'yes', '+') -contains $Dynamic.ToLower()) { '+' } else { '-' } } if ($Dynamic) { $Dynamic = if (@('on', 'yes', '+') -contains $Dynamic.ToLower()) { '+' } else { '-' } }
$OutputEncoding = [System.Text.Encoding]::UTF8 $OutputEncoding = [System.Text.Encoding]::UTF8
@@ -577,7 +582,7 @@ function Invoke-ApplyCheck {
$exeLeaf = Split-Path $Exe -Leaf $exeLeaf = Split-Path $Exe -Leaf
$v8 = if ($exeLeaf -match '^ibcmd') { Join-Path $exeDir ("1cv8" + [System.IO.Path]::GetExtension($Exe)) } else { $Exe } $v8 = if ($exeLeaf -match '^ibcmd') { Join-Path $exeDir ("1cv8" + [System.IO.Path]::GetExtension($Exe)) } else { $Exe }
if (-not (Test-Path $v8)) { return @{ Skipped = $true; Reason = "1cv8 not found at $v8"; ExitCode = 0; Lines = @() } } if (-not (Test-Path $v8)) { return @{ Skipped = $true; Reason = "1cv8 not found at $v8"; ExitCode = 0; Lines = @() } }
$dir = Join-Path $env:TEMP "apply_check_$(Get-Random)" $dir = Join-Path ([IO.Path]::GetTempPath()) "apply_check_$(Get-Random)"
New-Item -ItemType Directory -Path $dir -Force | Out-Null New-Item -ItemType Directory -Path $dir -Force | Out-Null
try { try {
$a = @("DESIGNER") + $ConnArgs + @("/CheckCanApplyConfigurationExtensions") $a = @("DESIGNER") + $ConnArgs + @("/CheckCanApplyConfigurationExtensions")
@@ -593,7 +598,7 @@ function Invoke-ApplyCheck {
} }
return @{ Skipped = $false; Reason = ''; ExitCode = $res.ExitCode; Lines = $lines } return @{ Skipped = $false; Reason = ''; ExitCode = $res.ExitCode; Lines = $lines }
} finally { } finally {
if (Test-Path $dir) { Remove-Item -Path $dir -Recurse -Force -ErrorAction SilentlyContinue } if ($dir -and (Test-Path $dir)) { Remove-Item -Path $dir -Recurse -Force -ErrorAction SilentlyContinue }
} }
} }
@@ -647,7 +652,7 @@ if ($engine -eq "ibcmd") {
} }
# --- Temp dir --- # --- Temp dir ---
$tempDir = Join-Path $env:TEMP "db_update_$(Get-Random)" $tempDir = Join-Path ([IO.Path]::GetTempPath()) "db_update_$(Get-Random)"
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
try { try {
@@ -773,7 +778,7 @@ try {
exit $exitCode exit $exitCode
} finally { } finally {
if (Test-Path $tempDir) { if ($tempDir -and (Test-Path $tempDir)) {
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
} }
} }
@@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# db-update v1.21 — Update 1C database configuration # db-update v1.22 — Update 1C database configuration
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse import argparse
+12 -7
View File
@@ -1,4 +1,4 @@
# epf-build v1.20 — Build external data processor or report (EPF/ERF) from XML sources # epf-build v1.21 — Build external data processor or report (EPF/ERF) from XML sources
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
# NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется. # NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется.
<# <#
@@ -95,6 +95,11 @@ param(
[string[]]$AdditionalIbcmdArguments = @() [string[]]$AdditionalIbcmdArguments = @()
) )
# Необработанная ошибка (напр. привязка параметра) внутри try/finally без catch завершала
# скрипт с кодом 0 — ложный успех без запуска платформы. Любая такая ошибка — код 1.
# py-порт: необработанное исключение и так даёт код 1.
trap { Write-Host "Error: $($_.Exception.Message) ($($_.InvocationInfo.ScriptName):$($_.InvocationInfo.ScriptLineNumber))" -ForegroundColor Red; exit 1 }
$OutputEncoding = [System.Text.Encoding]::UTF8 $OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
@@ -517,7 +522,7 @@ function Invoke-SourceCheck {
Write-Host "[note] source check skipped: 1cv8 not found at $v8" -ForegroundColor Yellow Write-Host "[note] source check skipped: 1cv8 not found at $v8" -ForegroundColor Yellow
return $false return $false
} }
$dir = Join-Path $env:TEMP "epf_check_$(Get-Random)" $dir = Join-Path ([IO.Path]::GetTempPath()) "epf_check_$(Get-Random)"
New-Item -ItemType Directory -Path $dir -Force | Out-Null New-Item -ItemType Directory -Path $dir -Force | Out-Null
try { try {
$outFile = Join-Path $dir "check_log.txt" $outFile = Join-Path $dir "check_log.txt"
@@ -550,7 +555,7 @@ function Invoke-SourceCheck {
} }
return $true return $true
} finally { } finally {
if (Test-Path $dir) { Remove-Item -Path $dir -Recurse -Force -ErrorAction SilentlyContinue } if ($dir -and (Test-Path $dir)) { Remove-Item -Path $dir -Recurse -Force -ErrorAction SilentlyContinue }
} }
} }
@@ -652,7 +657,7 @@ $autoCreatedBase = $null
$checkBase = $null $checkBase = $null
$checkBasePath = $null $checkBasePath = $null
if (-not $InfoBasePath -and (-not $InfoBaseServer -or -not $InfoBaseRef)) { if (-not $InfoBasePath -and (-not $InfoBaseServer -or -not $InfoBaseRef)) {
$autoBasePath = Join-Path $env:TEMP "epf_stub_db_$(Get-Random)" $autoBasePath = Join-Path ([IO.Path]::GetTempPath()) "epf_stub_db_$(Get-Random)"
Write-Host "No database specified. Creating temporary stub database..." Write-Host "No database specified. Creating temporary stub database..."
if ((New-StubBase $autoBasePath -Embed:($checkList.Count -gt 0)) -ne 0) { if ((New-StubBase $autoBasePath -Embed:($checkList.Count -gt 0)) -ne 0) {
# С внедрённой обработкой база падает прежде всего из-за самих исходников # С внедрённой обработкой база падает прежде всего из-за самих исходников
@@ -671,7 +676,7 @@ if (-not $InfoBasePath -and (-not $InfoBaseServer -or -not $InfoBaseRef)) {
} elseif ($checkList.Count -gt 0) { } elseif ($checkList.Count -gt 0) {
# Базу указали снаружи: класть проверяемую обработку в чужую конфигурацию нельзя, поэтому под # Базу указали снаружи: класть проверяемую обработку в чужую конфигурацию нельзя, поэтому под
# проверку поднимается своя временная база, а сборка идёт на указанной. # проверку поднимается своя временная база, а сборка идёт на указанной.
$checkBase = Join-Path $env:TEMP "epf_check_db_$(Get-Random)" $checkBase = Join-Path ([IO.Path]::GetTempPath()) "epf_check_db_$(Get-Random)"
Write-Host "Creating temporary database for the source check..." Write-Host "Creating temporary database for the source check..."
if ((New-StubBase $checkBase -Embed) -ne 0) { if ((New-StubBase $checkBase -Embed) -ne 0) {
Write-Host "Error: платформа не приняла исходники при подготовке проверки — сборка отменена" -ForegroundColor Red Write-Host "Error: платформа не приняла исходники при подготовке проверки — сборка отменена" -ForegroundColor Red
@@ -706,7 +711,7 @@ if ($outDir -and -not (Test-Path $outDir)) {
} }
# --- Temp dir --- # --- Temp dir ---
$tempDir = Join-Path $env:TEMP "epf_build_$(Get-Random)" $tempDir = Join-Path ([IO.Path]::GetTempPath()) "epf_build_$(Get-Random)"
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
try { try {
@@ -786,7 +791,7 @@ try {
exit $exitCode exit $exitCode
} finally { } finally {
if (Test-Path $tempDir) { if ($tempDir -and (Test-Path $tempDir)) {
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
} }
if ($autoCreatedBase -and (Test-Path $autoCreatedBase)) { if ($autoCreatedBase -and (Test-Path $autoCreatedBase)) {
@@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# epf-build v1.20 — Build external data processor or report (EPF/ERF) from XML sources # epf-build v1.21 — Build external data processor or report (EPF/ERF) from XML sources
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse import argparse
@@ -1,4 +1,4 @@
# stub-db-create v1.12 — Create temp 1C infobase with metadata stubs for EPF/ERF build # stub-db-create v1.13 — Create temp 1C infobase with metadata stubs for EPF/ERF build
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
param( param(
[Parameter(Mandatory)] [Parameter(Mandatory)]
@@ -22,6 +22,11 @@ param(
[string[]]$AdditionalIbcmdArguments = @() [string[]]$AdditionalIbcmdArguments = @()
) )
# Необработанная ошибка (напр. привязка параметра) внутри try/finally без catch завершала
# скрипт с кодом 0 — ложный успех без запуска платформы. Любая такая ошибка — код 1.
# py-порт: необработанное исключение и так даёт код 1.
trap { Write-Host "Error: $($_.Exception.Message) ($($_.InvocationInfo.ScriptName):$($_.InvocationInfo.ScriptLineNumber))" -ForegroundColor Red; exit 1 }
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
@@ -422,7 +427,7 @@ $needCfg = $hasRefTypes -or $embedRequested -or $commonModules.Count -gt 0
# --- 2. Determine TempBasePath --- # --- 2. Determine TempBasePath ---
if (-not $TempBasePath) { if (-not $TempBasePath) {
$TempBasePath = Join-Path $env:TEMP "epf_stub_db_$(Get-Random)" $TempBasePath = Join-Path ([IO.Path]::GetTempPath()) "epf_stub_db_$(Get-Random)"
} }
# --- 3. If registers need a registrator, add stub document --- # --- 3. If registers need a registrator, add stub document ---
@@ -1751,7 +1756,7 @@ function Format-ArgToken {
$extraArgString = -join ($extraArgs | ForEach-Object { Format-ArgToken $_ }) $extraArgString = -join ($extraArgs | ForEach-Object { Format-ArgToken $_ })
if ($stubEngine -eq "ibcmd") { if ($stubEngine -eq "ibcmd") {
Write-Host "Creating infobase (ibcmd): $TempBasePath" Write-Host "Creating infobase (ibcmd): $TempBasePath"
$ibData = Join-Path $env:TEMP "stub_data_$(Get-Random)" $ibData = Join-Path ([IO.Path]::GetTempPath()) "stub_data_$(Get-Random)"
New-Item -ItemType Directory -Path $ibData -Force | Out-Null New-Item -ItemType Directory -Path $ibData -Force | Out-Null
$ibArgs = @("infobase", "create", "--db-path=$TempBasePath", "--create-database") $ibArgs = @("infobase", "create", "--db-path=$TempBasePath", "--create-database")
if ($needCfg) { $ibArgs += "--import=$(Join-Path $TempBasePath 'cfg')", "--apply", "--force" } if ($needCfg) { $ibArgs += "--import=$(Join-Path $TempBasePath 'cfg')", "--apply", "--force" }
@@ -1787,7 +1792,7 @@ if ($needCfg) {
$cfgDir = Join-Path $TempBasePath "cfg" $cfgDir = Join-Path $TempBasePath "cfg"
# LoadConfigFromFiles # LoadConfigFromFiles
Write-Host "Loading configuration from files..." Write-Host "Loading configuration from files..."
$loadLog = Join-Path $env:TEMP "stub_load_log.txt" $loadLog = Join-Path ([IO.Path]::GetTempPath()) "stub_load_log.txt"
$loadArgs = "DESIGNER /F`"$TempBasePath`" /LoadConfigFromFiles `"$cfgDir`" /Out `"$loadLog`" /DisableStartupDialogs" + $extraArgString $loadArgs = "DESIGNER /F`"$TempBasePath`" /LoadConfigFromFiles `"$cfgDir`" /Out `"$loadLog`" /DisableStartupDialogs" + $extraArgString
$proc = Invoke-PlatformProcess $V8Path @($loadArgs) -PreQuoted $proc = Invoke-PlatformProcess $V8Path @($loadArgs) -PreQuoted
if ($proc.ExitCode -ne 0) { if ($proc.ExitCode -ne 0) {
@@ -1799,7 +1804,7 @@ if ($needCfg) {
# UpdateDBCfg # UpdateDBCfg
Write-Host "Updating database configuration..." Write-Host "Updating database configuration..."
$updateLog = Join-Path $env:TEMP "stub_update_log.txt" $updateLog = Join-Path ([IO.Path]::GetTempPath()) "stub_update_log.txt"
$updateArgs = "DESIGNER /F`"$TempBasePath`" /UpdateDBCfg /Out `"$updateLog`" /DisableStartupDialogs" + $extraArgString $updateArgs = "DESIGNER /F`"$TempBasePath`" /UpdateDBCfg /Out `"$updateLog`" /DisableStartupDialogs" + $extraArgString
$proc = Invoke-PlatformProcess $V8Path @($updateArgs) -PreQuoted $proc = Invoke-PlatformProcess $V8Path @($updateArgs) -PreQuoted
if ($proc.ExitCode -ne 0) { if ($proc.ExitCode -ne 0) {
@@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# stub-db-create v1.12 — Create temp 1C infobase with metadata stubs for EPF/ERF build # stub-db-create v1.13 — Create temp 1C infobase with metadata stubs for EPF/ERF build
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse import argparse
+8 -3
View File
@@ -1,4 +1,4 @@
# epf-dump v1.16 — Dump external data processor or report (EPF/ERF) to XML sources # epf-dump v1.17 — Dump external data processor or report (EPF/ERF) to XML sources
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
# NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется. # NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется.
<# <#
@@ -86,6 +86,11 @@ param(
[string[]]$AdditionalIbcmdArguments = @() [string[]]$AdditionalIbcmdArguments = @()
) )
# Необработанная ошибка (напр. привязка параметра) внутри try/finally без catch завершала
# скрипт с кодом 0 — ложный успех без запуска платформы. Любая такая ошибка — код 1.
# py-порт: необработанное исключение и так даёт код 1.
trap { Write-Host "Error: $($_.Exception.Message) ($($_.InvocationInfo.ScriptName):$($_.InvocationInfo.ScriptLineNumber))" -ForegroundColor Red; exit 1 }
$OutputEncoding = [System.Text.Encoding]::UTF8 $OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
@@ -474,7 +479,7 @@ if (-not (Test-Path $OutputDir)) {
} }
# --- Temp dir --- # --- Temp dir ---
$tempDir = Join-Path $env:TEMP "epf_dump_$(Get-Random)" $tempDir = Join-Path ([IO.Path]::GetTempPath()) "epf_dump_$(Get-Random)"
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
try { try {
@@ -554,7 +559,7 @@ try {
exit $exitCode exit $exitCode
} finally { } finally {
if (Test-Path $tempDir) { if ($tempDir -and (Test-Path $tempDir)) {
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
} }
} }
+1 -1
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# epf-dump v1.16 — Dump external data processor or report (EPF/ERF) to XML sources # epf-dump v1.17 — Dump external data processor or report (EPF/ERF) to XML sources
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse import argparse
@@ -1,4 +1,4 @@
# web-publish v1.10 — Publish 1C infobase via Apache (+_version_dir/_version_key: общий эталон db-семейства) # web-publish v1.11 — Publish 1C infobase via Apache (+_version_dir/_version_key: общий эталон db-семейства)
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
<# <#
.SYNOPSIS .SYNOPSIS
@@ -205,8 +205,8 @@ if (-not (Test-Path $httpdExe)) {
} }
Write-Host "Apache не найден. Скачиваю..." -ForegroundColor Cyan Write-Host "Apache не найден. Скачиваю..." -ForegroundColor Cyan
$tmpZip = Join-Path $env:TEMP "apache24.zip" $tmpZip = Join-Path ([IO.Path]::GetTempPath()) "apache24.zip"
$tmpDir = Join-Path $env:TEMP "apache24_extract" $tmpDir = Join-Path ([IO.Path]::GetTempPath()) "apache24_extract"
try { try {
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
@@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# web-publish v1.10 — Publish 1C infobase via Apache (+_version_dir/_version_key: общий эталон db-семейства) # web-publish v1.11 — Publish 1C infobase via Apache (+_version_dir/_version_key: общий эталон db-семейства)
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
""" """
+11
View File
@@ -115,6 +115,7 @@ node tests/skills/check-inline-drift.mjs --list # реестр: семья →
| `check-agent-portability.mjs` | исходники навыков не привязаны к конкретному AI-агенту: единственная разрешённая форма — плейсхолдер `${CLAUDE_SKILL_DIR}/`, который разворачивает `scripts/switch.py` | | `check-agent-portability.mjs` | исходники навыков не привязаны к конкретному AI-агенту: единственная разрешённая форма — плейсхолдер `${CLAUDE_SKILL_DIR}/`, который разворачивает `scripts/switch.py` |
| `check-error-streams.mjs` | сообщения об ошибках идут в один и тот же поток в обоих портах навыка (соответствие из `docs/python-porting-guide.md`) | | `check-error-streams.mjs` | сообщения об ошибках идут в один и тот же поток в обоих портах навыка (соответствие из `docs/python-porting-guide.md`) |
| `check-nonascii-fs.mjs` | `fsutil`: удаление и копирование держат не-ASCII пути (кириллический `%TEMP%`, кириллические имена объектов 1С), обе копии модуля не разошлись | | `check-nonascii-fs.mjs` | `fsutil`: удаление и копирование держат не-ASCII пути (кириллический `%TEMP%`, кириллические имена объектов 1С), обе копии модуля не разошлись |
| `check-ps-portability.mjs` | `.ps1` навыков не читают `$env:TEMP`/`$env:TMP`; скрипты `db-*`/`epf-*`, запускающие платформу, держат верхнеуровневый `trap { … exit 1 }` |
`check-inline-drift.mjs` держит реестр семей внутри себя: у каждой семьи перечислены варианты, у `check-inline-drift.mjs` держит реестр семей внутри себя: у каждой семьи перечислены варианты, у
варианта — навык-эталон и список копий. Отклоняющийся вариант обязан иметь обоснование (`why`), варианта — навык-эталон и список копий. Отклоняющийся вариант обязан иметь обоснование (`why`),
@@ -159,6 +160,16 @@ node tests/skills/check-inline-drift.mjs --list # реестр: семья →
[nafs]: https://github.com/nodejs/node/issues/61067 [nafs]: https://github.com/nodejs/node/issues/61067
`check-ps-portability.mjs` держит два следствия issue #106. Вне Windows `$env:TEMP` равна `$null`,
и `Join-Path $env:TEMP …` падает на привязке параметра. Внутри `try { } finally { }` без `catch`
такая ошибка прерывает `try`, отрабатывает `finally` — и скрипт выходит с **кодом 0**: платформа
не запускалась, постусловие не проверялось, навык «успешен». Поэтому временный каталог берётся
через `[IO.Path]::GetTempPath()`, а скрипты `db-*`/`epf-*`, запускающие платформу, ставят после
`param(...)` верхнеуровневый `trap { … exit 1 }` — он ловит и ошибки вне `try`, внутренние `catch`
сохраняют приоритет, `finally` отрабатывает. Кейсом это не проверить: libuv на Windows возвращает
`TEMP` в окружение дочернего процесса, даже если раннер его убрал, а пустое значение ломает
`GetTempPath()` иначе, чем отсутствие переменной.
`check-format-versions.mjs` держит границы проверенного диапазона версий формата выгрузки. Раньше `check-format-versions.mjs` держит границы проверенного диапазона версий формата выгрузки. Раньше
допустимый список версий был независимым литералом в каждом валидаторе, и сверять его было не с допустимый список версий был независимым литералом в каждом валидаторе, и сверять его было не с
чем: волна 2.21 прошла по четырём валидаторам и молча обошла пятый — `form-validate` остался на чем: волна 2.21 прошла по четырём валидаторам и молча обошла пятый — `form-validate` остался на
+1
View File
@@ -23,6 +23,7 @@ const GUARDS = [
['check-agent-portability.mjs', 'исходники навыков: без привязки к конкретному AI-агенту'], ['check-agent-portability.mjs', 'исходники навыков: без привязки к конкретному AI-агенту'],
['check-error-streams.mjs', 'сообщения об ошибках: один и тот же поток в обоих портах'], ['check-error-streams.mjs', 'сообщения об ошибках: один и тот же поток в обоих портах'],
['check-nonascii-fs.mjs', 'fsutil: удаление и копирование держат не-ASCII пути, копии не разошлись'], ['check-nonascii-fs.mjs', 'fsutil: удаление и копирование держат не-ASCII пути, копии не разошлись'],
['check-ps-portability.mjs', '.ps1: без $env:TEMP, необработанная ошибка у db-*/epf-* даёт код 1'],
]; ];
let failed = 0; let failed = 0;
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env node
// Инвариант: PS-скрипты навыков не опираются на окружение, которое есть только в Windows, а
// скрипты, запускающие платформу, не могут завершиться с кодом 0 из-за необработанной ошибки.
//
// Issue #106: вне Windows `$env:TEMP` равна $null. `Join-Path $env:TEMP …` внутри
// `try { } finally { }` без catch — ошибка привязки параметра прерывает try, отрабатывает
// finally, и скрипт выходит с кодом 0: платформа не запускалась, постусловие не проверялось.
// db-create/db-dump-*/db-load-xml рапортовали «успех», ничего не сделав.
//
// Два правила:
// 1. `$env:TEMP` / `$env:TMP` в .ps1 навыков запрещены — временный каталог берётся через
// [IO.Path]::GetTempPath() (на Windows тот же путь, вне Windows — TMPDIR или /tmp).
// 2. .ps1 в db-*/epf-*, запускающий платформу (Invoke-PlatformProcess / Start-Process),
// держит верхнеуровневый `trap { … exit 1 }`: любая необработанная ошибка — код 1.
// Рантайм-кейсом это не поймать: после правила 1 штатного способа уронить скрипт нет.
//
// Почему гард, а не кейс с урезанным окружением: libuv на Windows возвращает TEMP в окружение
// дочернего процесса, даже если его убрали (обязательная переменная), — «TEMP нет» из Node на
// Windows не выразить.
//
// Запуск: node tests/skills/check-ps-portability.mjs
import { readFileSync, readdirSync, existsSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { dirname, join } from 'node:path';
const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..', '..');
const SKILLS = join(ROOT, '.claude', 'skills');
const errors = [];
let checked = 0;
let trapped = 0;
for (const skill of readdirSync(SKILLS)) {
const dir = join(SKILLS, skill, 'scripts');
if (!existsSync(dir)) continue;
for (const file of readdirSync(dir)) {
if (!file.endsWith('.ps1')) continue;
checked++;
const lines = readFileSync(join(dir, file), 'utf8').replace(/^/, '').split(/\r?\n/);
const code = lines.map((l, i) => ({ l, n: i + 1 })).filter(({ l }) => !l.trimStart().startsWith('#'));
for (const { l, n } of code) {
if (/\$env:(TEMP|TMP)\b/i.test(l)) {
errors.push(`${skill}/${file}:${n}: $env:TEMP/$env:TMP есть только в Windows — `
+ `используйте [IO.Path]::GetTempPath()`);
}
}
if (!/^(db|epf)-/.test(skill)) continue;
const runsPlatform = code.some(({ l }) => /Invoke-PlatformProcess|Start-Process/.test(l));
if (!runsPlatform) continue;
trapped++;
if (!code.some(({ l }) => /^trap \{.*\bexit 1\b/.test(l))) {
errors.push(`${skill}/${file}: запускает платформу, но нет верхнеуровневого `
+ '`trap { … exit 1 }` — необработанная ошибка внутри try/finally даст код 0');
}
}
}
console.log(`Проверено .ps1: ${checked}; из них запускают платформу (db-*/epf-*): ${trapped}`);
if (errors.length === 0) {
console.log('OK — без Windows-only окружения, необработанная ошибка даёт код 1.');
process.exit(0);
}
console.log(`\n${errors.length} НАРУШЕНИЙ:`);
for (const e of errors) console.log(` [ERROR] ${e}`);
process.exit(1);