mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-21 02:41:06 +03:00
fix(epf-dump): require database connection, remove auto-create empty base
Dump in an empty database irreversibly loses reference types (CatalogRef, DocumentRef, etc.) — they get converted to xs:string. Instead of silently creating an empty temp database, the script now exits with an error explaining that a real database is required. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
f01f9d6ae8
commit
3097811dde
@@ -33,7 +33,7 @@ allowed-tools:
|
|||||||
3. Если указал базу по имени — ищи по id / alias / name в `.v8-project.json`
|
3. Если указал базу по имени — ищи по id / alias / name в `.v8-project.json`
|
||||||
4. Если не указал — сопоставь текущую ветку Git с `databases[].branches`
|
4. Если не указал — сопоставь текущую ветку Git с `databases[].branches`
|
||||||
5. Если ветка не совпала — используй `default`
|
5. Если ветка не совпала — используй `default`
|
||||||
6. Если `.v8-project.json` нет или база не найдена — не указывай параметры подключения: скрипт автоматически создаст временную пустую базу. **Важно:** в пустой базе ссылочные типы (CatalogRef, DocumentRef и т.д.) сбрасываются в строки. Для сохранения типов нужна реальная база с конфигурацией. Предупреди пользователя об этом.
|
6. Если `.v8-project.json` нет или база не найдена — **сообщи пользователю об ошибке**. Для dump база обязательна: в пустой базе ссылочные типы (CatalogRef, DocumentRef и т.д.) безвозвратно сбрасываются в строки. Предложи указать базу или зарегистрировать через `/db-list add`.
|
||||||
|
|
||||||
Если `v8path` не задан — автоопределение: `Get-ChildItem "C:\Program Files\1cv8\*\bin\1cv8.exe" | Sort -Desc | Select -First 1`
|
Если `v8path` не задан — автоопределение: `Get-ChildItem "C:\Program Files\1cv8\*\bin\1cv8.exe" | Sort -Desc | Select -First 1`
|
||||||
Если использованная база не зарегистрирована — после выполнения предложи добавить через `/db-list add`.
|
Если использованная база не зарегистрирована — после выполнения предложи добавить через `/db-list add`.
|
||||||
@@ -58,7 +58,7 @@ powershell.exe -NoProfile -File .claude/skills/epf-dump/scripts/epf-dump.ps1 <п
|
|||||||
| `-OutputDir <путь>` | да | Каталог для выгрузки исходников |
|
| `-OutputDir <путь>` | да | Каталог для выгрузки исходников |
|
||||||
| `-Format <формат>` | нет | `Hierarchical` (по умолч.) / `Plain` |
|
| `-Format <формат>` | нет | `Hierarchical` (по умолч.) / `Plain` |
|
||||||
|
|
||||||
> `*` — опционально. Если не указано — автоматически создаётся временная пустая база. Ссылочные типы при этом сбрасываются в строки
|
> `*` — обязательно хотя бы одно подключение. Без базы скрипт завершится с ошибкой (dump в пустой базе безвозвратно теряет ссылочные типы)
|
||||||
|
|
||||||
## Коды возврата
|
## Коды возврата
|
||||||
|
|
||||||
|
|||||||
@@ -94,20 +94,11 @@ if (-not (Test-Path $V8Path)) {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- Auto-create empty database if no connection specified ---
|
# --- Validate database connection ---
|
||||||
$autoCreatedBase = $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_dump_db_$(Get-Random)"
|
Write-Host "Error: database connection required. Specify -InfoBasePath or -InfoBaseServer/-InfoBaseRef" -ForegroundColor Red
|
||||||
Write-Host "No database specified. Creating temporary empty database..."
|
Write-Host "Dump in an empty database loses reference types (CatalogRef, DocumentRef, etc.) irreversibly." -ForegroundColor Yellow
|
||||||
Write-Host "WARNING: Reference types (CatalogRef, DocumentRef, etc.) will be lost - converted to strings. Use a real database to preserve types." -ForegroundColor Yellow
|
exit 1
|
||||||
$createArgs = "CREATEINFOBASE File=`"$autoBasePath`" /DisableStartupDialogs"
|
|
||||||
$createProc = Start-Process -FilePath $V8Path -ArgumentList $createArgs -NoNewWindow -Wait -PassThru
|
|
||||||
if ($createProc.ExitCode -ne 0) {
|
|
||||||
Write-Host "Error: failed to create temporary database" -ForegroundColor Red
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
$InfoBasePath = $autoBasePath
|
|
||||||
$autoCreatedBase = $autoBasePath
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- Validate input file ---
|
# --- Validate input file ---
|
||||||
@@ -173,7 +164,4 @@ try {
|
|||||||
if (Test-Path $tempDir) {
|
if (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)) {
|
|
||||||
Remove-Item -Path $autoCreatedBase -Recurse -Force -ErrorAction SilentlyContinue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,21 +58,11 @@ def main():
|
|||||||
# --- Resolve V8Path ---
|
# --- Resolve V8Path ---
|
||||||
v8path = resolve_v8path(args.V8Path)
|
v8path = resolve_v8path(args.V8Path)
|
||||||
|
|
||||||
# --- Auto-create empty database if no connection specified ---
|
# --- Validate database connection ---
|
||||||
auto_created_base = None
|
|
||||||
if not args.InfoBasePath and (not args.InfoBaseServer or not args.InfoBaseRef):
|
if not args.InfoBasePath and (not args.InfoBaseServer or not args.InfoBaseRef):
|
||||||
auto_base_path = os.path.join(tempfile.gettempdir(), f"epf_dump_db_{random.randint(0, 999999)}")
|
print("Error: database connection required. Specify -InfoBasePath or -InfoBaseServer/-InfoBaseRef", file=sys.stderr)
|
||||||
print("No database specified. Creating temporary empty database...")
|
print("Dump in an empty database loses reference types (CatalogRef, DocumentRef, etc.) irreversibly.")
|
||||||
print("WARNING: Reference types (CatalogRef, DocumentRef, etc.) will be lost - converted to strings. Use a real database to preserve types.")
|
sys.exit(1)
|
||||||
result = subprocess.run(
|
|
||||||
[v8path, "CREATEINFOBASE", f'File={auto_base_path}', "/DisableStartupDialogs"],
|
|
||||||
capture_output=True, text=True,
|
|
||||||
)
|
|
||||||
if result.returncode != 0:
|
|
||||||
print("Error: failed to create temporary database", file=sys.stderr)
|
|
||||||
sys.exit(1)
|
|
||||||
args.InfoBasePath = auto_base_path
|
|
||||||
auto_created_base = auto_base_path
|
|
||||||
|
|
||||||
# --- Validate input file ---
|
# --- Validate input file ---
|
||||||
if not os.path.isfile(args.InputFile):
|
if not os.path.isfile(args.InputFile):
|
||||||
@@ -140,8 +130,6 @@ def main():
|
|||||||
finally:
|
finally:
|
||||||
if os.path.exists(temp_dir):
|
if os.path.exists(temp_dir):
|
||||||
shutil.rmtree(temp_dir, ignore_errors=True)
|
shutil.rmtree(temp_dir, ignore_errors=True)
|
||||||
if auto_created_base and os.path.exists(auto_created_base):
|
|
||||||
shutil.rmtree(auto_created_base, ignore_errors=True)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ allowed-tools:
|
|||||||
3. Если указал базу по имени — ищи по id / alias / name в `.v8-project.json`
|
3. Если указал базу по имени — ищи по id / alias / name в `.v8-project.json`
|
||||||
4. Если не указал — сопоставь текущую ветку Git с `databases[].branches`
|
4. Если не указал — сопоставь текущую ветку Git с `databases[].branches`
|
||||||
5. Если ветка не совпала — используй `default`
|
5. Если ветка не совпала — используй `default`
|
||||||
6. Если `.v8-project.json` нет или база не найдена — не указывай параметры подключения: скрипт автоматически создаст временную пустую базу. **Важно:** в пустой базе ссылочные типы (CatalogRef, DocumentRef и т.д.) сбрасываются в строки. Для сохранения типов нужна реальная база с конфигурацией. Предупреди пользователя об этом.
|
6. Если `.v8-project.json` нет или база не найдена — **сообщи пользователю об ошибке**. Для dump база обязательна: в пустой базе ссылочные типы (CatalogRef, DocumentRef и т.д.) безвозвратно сбрасываются в строки. Предложи указать базу или зарегистрировать через `/db-list add`.
|
||||||
|
|
||||||
Если `v8path` не задан — автоопределение: `Get-ChildItem "C:\Program Files\1cv8\*\bin\1cv8.exe" | Sort -Desc | Select -First 1`
|
Если `v8path` не задан — автоопределение: `Get-ChildItem "C:\Program Files\1cv8\*\bin\1cv8.exe" | Sort -Desc | Select -First 1`
|
||||||
Если использованная база не зарегистрирована — после выполнения предложи добавить через `/db-list add`.
|
Если использованная база не зарегистрирована — после выполнения предложи добавить через `/db-list add`.
|
||||||
@@ -60,7 +60,7 @@ powershell.exe -NoProfile -File .claude/skills/epf-dump/scripts/epf-dump.ps1 <п
|
|||||||
| `-OutputDir <путь>` | да | Каталог для выгрузки исходников |
|
| `-OutputDir <путь>` | да | Каталог для выгрузки исходников |
|
||||||
| `-Format <формат>` | нет | `Hierarchical` (по умолч.) / `Plain` |
|
| `-Format <формат>` | нет | `Hierarchical` (по умолч.) / `Plain` |
|
||||||
|
|
||||||
> `*` — опционально. Если не указано — автоматически создаётся временная пустая база
|
> `*` — обязательно хотя бы одно подключение. Без базы скрипт завершится с ошибкой (dump в пустой базе безвозвратно теряет ссылочные типы)
|
||||||
|
|
||||||
## Коды возврата
|
## Коды возврата
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user