mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-09-27 20:45:54 +03:00
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:
co-authored by
Claude Opus 5.5
parent
317dce6d9f
commit
eb1796ef94
@@ -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
|
||||
# NB: *nix-раскладку платформы (/opt/1cv8/<ver>/1cv8, без .exe) знает только .py-порт — PS на *nix не исполняется.
|
||||
<#
|
||||
@@ -95,6 +95,11 @@ param(
|
||||
[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
|
||||
[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
|
||||
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
|
||||
try {
|
||||
$outFile = Join-Path $dir "check_log.txt"
|
||||
@@ -550,7 +555,7 @@ function Invoke-SourceCheck {
|
||||
}
|
||||
return $true
|
||||
} 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
|
||||
$checkBasePath = $null
|
||||
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..."
|
||||
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) {
|
||||
# Базу указали снаружи: класть проверяемую обработку в чужую конфигурацию нельзя, поэтому под
|
||||
# проверку поднимается своя временная база, а сборка идёт на указанной.
|
||||
$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..."
|
||||
if ((New-StubBase $checkBase -Embed) -ne 0) {
|
||||
Write-Host "Error: платформа не приняла исходники при подготовке проверки — сборка отменена" -ForegroundColor Red
|
||||
@@ -706,7 +711,7 @@ if ($outDir -and -not (Test-Path $outDir)) {
|
||||
}
|
||||
|
||||
# --- 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
|
||||
|
||||
try {
|
||||
@@ -786,7 +791,7 @@ try {
|
||||
exit $exitCode
|
||||
|
||||
} finally {
|
||||
if (Test-Path $tempDir) {
|
||||
if ($tempDir -and (Test-Path $tempDir)) {
|
||||
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
if ($autoCreatedBase -and (Test-Path $autoCreatedBase)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/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
|
||||
|
||||
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
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -22,6 +22,11 @@ param(
|
||||
[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"
|
||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||
|
||||
@@ -422,7 +427,7 @@ $needCfg = $hasRefTypes -or $embedRequested -or $commonModules.Count -gt 0
|
||||
|
||||
# --- 2. Determine 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 ---
|
||||
@@ -1751,7 +1756,7 @@ function Format-ArgToken {
|
||||
$extraArgString = -join ($extraArgs | ForEach-Object { Format-ArgToken $_ })
|
||||
if ($stubEngine -eq "ibcmd") {
|
||||
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
|
||||
$ibArgs = @("infobase", "create", "--db-path=$TempBasePath", "--create-database")
|
||||
if ($needCfg) { $ibArgs += "--import=$(Join-Path $TempBasePath 'cfg')", "--apply", "--force" }
|
||||
@@ -1787,7 +1792,7 @@ if ($needCfg) {
|
||||
$cfgDir = Join-Path $TempBasePath "cfg"
|
||||
# LoadConfigFromFiles
|
||||
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
|
||||
$proc = Invoke-PlatformProcess $V8Path @($loadArgs) -PreQuoted
|
||||
if ($proc.ExitCode -ne 0) {
|
||||
@@ -1799,7 +1804,7 @@ if ($needCfg) {
|
||||
|
||||
# UpdateDBCfg
|
||||
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
|
||||
$proc = Invoke-PlatformProcess $V8Path @($updateArgs) -PreQuoted
|
||||
if ($proc.ExitCode -ne 0) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/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
|
||||
|
||||
import argparse
|
||||
|
||||
Reference in New Issue
Block a user