mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-09-01 07:50:50 +03:00
feat(db-repo): снять с модели рутину, которую видно по прогону каскада
Три места, где модель делала работу за навык. report требовал -OutputFile, хотя отчёт всё равно печатается в вывод: путь приходилось придумывать ради файла, который никто не читает. Теперь без параметра отчёт уходит во временный файл, а путь называется — сохранить осознанно по-прежнему можно. create и connect с явным путём хранилища теперь печатают готовый блок repository для .v8-project.json. Без записи в реестре реквизиты придётся передавать в каждом вызове, а update откажется работать вовсе — вспомнить об этом модель не может, а подставить готовое мы можем. Подсказка про -ForceReplaceCfg сразу называет и второй флаг: при переподключении платформа отвергает дважды подряд, сообщая о причинах по одной, и модель упиралась бы два раза. Проверено, что печатаемый блок — валидный JSON: строка из вывода разбирается парсером, путь читается обратно. В PS обратный слэш в строке замены -replace не спецсимвол, из-за чего слэши сперва удвоились дважды. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
8faa1f77c0
commit
ac20d95fea
@@ -8,7 +8,7 @@ powershell.exe -NoProfile -File "${CLAUDE_SKILL_DIR}/scripts/db-repo.ps1" -Comma
|
|||||||
|
|
||||||
| Параметр | Описание |
|
| Параметр | Описание |
|
||||||
|----------|----------|
|
|----------|----------|
|
||||||
| `-OutputFile <путь>` | Куда положить отчёт (обязателен) |
|
| `-OutputFile <путь>` | Куда положить отчёт. Без него — во временный файл, отчёт всё равно печатается |
|
||||||
| `-NBegin <номер>` | С какой версии. `-1` — только последняя |
|
| `-NBegin <номер>` | С какой версии. `-1` — только последняя |
|
||||||
| `-NEnd <номер>` | По какую версию |
|
| `-NEnd <номер>` | По какую версию |
|
||||||
| `-DateBegin` / `-DateEnd` | Границы по датам |
|
| `-DateBegin` / `-DateEnd` | Границы по датам |
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# db-repo v1.6 — 1C configuration repository operations
|
# db-repo v1.7 — 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 работу с хранилищем не поддерживает (нет такого режима).
|
||||||
<#
|
<#
|
||||||
@@ -977,6 +977,7 @@ function Write-RepoVerdict {
|
|||||||
if ($Log.Raw -match 'Конфигурация не пустая') {
|
if ($Log.Raw -match 'Конфигурация не пустая') {
|
||||||
Write-Host "[hint] в базе уже есть конфигурация. Замена её конфигурацией из хранилища —" -ForegroundColor Yellow
|
Write-Host "[hint] в базе уже есть конфигурация. Замена её конфигурацией из хранилища —" -ForegroundColor Yellow
|
||||||
Write-Host " -ForceReplaceCfg. Операция необратима: спросите подтверждение у пользователя." -ForegroundColor Yellow
|
Write-Host " -ForceReplaceCfg. Операция необратима: спросите подтверждение у пользователя." -ForegroundColor Yellow
|
||||||
|
Write-Host " Если база уже была подключена, понадобится ещё -ForceBindAlreadyBindedUser." -ForegroundColor Yellow
|
||||||
}
|
}
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
@@ -1066,7 +1067,10 @@ if ($WithChildren) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch ($cmd) {
|
switch ($cmd) {
|
||||||
'report' { if (-not $OutputFile) { Write-Host "Error: -OutputFile is required for report" -ForegroundColor Red; exit 1 } }
|
'report' {
|
||||||
|
# Отчёт печатается в вывод, поэтому путь нужен только если его хотят сохранить.
|
||||||
|
if (-not $OutputFile) { $OutputFile = Join-Path $env:TEMP "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 } }
|
||||||
'copy-users' { if (-not $SourcePath -or -not $SourceUser) { Write-Host "Error: -SourcePath and -SourceUser are required for copy-users" -ForegroundColor Red; exit 1 } }
|
'copy-users' { if (-not $SourcePath -or -not $SourceUser) { Write-Host "Error: -SourcePath and -SourceUser are required for copy-users" -ForegroundColor Red; exit 1 } }
|
||||||
@@ -1211,6 +1215,20 @@ try {
|
|||||||
Write-Host ($logLines -join [Environment]::NewLine)
|
Write-Host ($logLines -join [Environment]::NewLine)
|
||||||
Write-Host "--- End ---"
|
Write-Host "--- End ---"
|
||||||
}
|
}
|
||||||
|
# Реестр — не формальность: без repository реквизиты придётся передавать в каждом вызове,
|
||||||
|
# а update откажется работать вовсе. Модель об этом не вспомнит, поэтому даём готовый блок.
|
||||||
|
# Признак — что путь задали аргументом: значит в реестре его нет (или он другой).
|
||||||
|
if ($verdict -eq 0 -and @('create', 'connect') -contains $cmd -and $RepositoryPath) {
|
||||||
|
# В строке замены -replace обратный слэш не спецсимвол: два символа дают два слэша.
|
||||||
|
$jsonPath = $repo.Path -replace '\\', '\\'
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "[note] допишите хранилище в запись базы в .v8-project.json (см. /db-list):" -ForegroundColor Yellow
|
||||||
|
if ($Extension) {
|
||||||
|
Write-Host " `"extensions`": [ { `"name`": `"$Extension`", `"repository`": { `"path`": `"$jsonPath`", `"user`": `"$($repo.User)`", `"password`": `"<пароль>`" } } ]"
|
||||||
|
} else {
|
||||||
|
Write-Host " `"repository`": { `"path`": `"$jsonPath`", `"user`": `"$($repo.User)`", `"password`": `"<пароль>`" }"
|
||||||
|
}
|
||||||
|
}
|
||||||
Write-PlatformOutput $proc.Output
|
Write-PlatformOutput $proc.Output
|
||||||
exit $verdict
|
exit $verdict
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# db-repo v1.6 — 1C configuration repository operations
|
# db-repo v1.7 — 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С.
|
||||||
@@ -860,6 +860,7 @@ def write_repo_verdict(cmd, log, platform_exit, requested, report_format="", out
|
|||||||
if "Конфигурация не пустая" in (log.get("raw") or ""):
|
if "Конфигурация не пустая" in (log.get("raw") or ""):
|
||||||
print("[hint] в базе уже есть конфигурация. Замена её конфигурацией из хранилища —")
|
print("[hint] в базе уже есть конфигурация. Замена её конфигурацией из хранилища —")
|
||||||
print(" -ForceReplaceCfg. Операция необратима: спросите подтверждение у пользователя.")
|
print(" -ForceReplaceCfg. Операция необратима: спросите подтверждение у пользователя.")
|
||||||
|
print(" Если база уже была подключена, понадобится ещё -ForceBindAlreadyBindedUser.")
|
||||||
return 1
|
return 1
|
||||||
print("Команда '%s' выполнена." % cmd)
|
print("Команда '%s' выполнена." % cmd)
|
||||||
if cmd == "report" and report_format == "txt" and os.path.exists(output_file):
|
if cmd == "report" and report_format == "txt" and os.path.exists(output_file):
|
||||||
@@ -1000,8 +1001,8 @@ def main():
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if cmd == "report" and not args.OutputFile:
|
if cmd == "report" and not args.OutputFile:
|
||||||
print("Error: -OutputFile is required for report")
|
# Отчёт печатается в вывод, поэтому путь нужен только если его хотят сохранить.
|
||||||
sys.exit(1)
|
args.OutputFile = os.path.join(tempfile.gettempdir(), "db-repo-report.%s" % args.ReportFormat)
|
||||||
if cmd == "dump-cfg" and not args.OutputFile:
|
if cmd == "dump-cfg" and not args.OutputFile:
|
||||||
print("Error: -OutputFile (path to the .cf file) is required for dump-cfg")
|
print("Error: -OutputFile (path to the .cf file) is required for dump-cfg")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@@ -1167,6 +1168,19 @@ def main():
|
|||||||
log_lines = log_lines[-log_limit:]
|
log_lines = log_lines[-log_limit:]
|
||||||
print("\n".join(log_lines))
|
print("\n".join(log_lines))
|
||||||
print("--- End ---")
|
print("--- End ---")
|
||||||
|
# Реестр — не формальность: без repository реквизиты придётся передавать в каждом вызове,
|
||||||
|
# а update откажется работать вовсе. Модель об этом не вспомнит, поэтому даём готовый блок.
|
||||||
|
# Признак — что путь задали аргументом: значит в реестре его нет (или он другой).
|
||||||
|
if verdict == 0 and cmd in ("create", "connect") and args.RepositoryPath:
|
||||||
|
json_path = repo["path"].replace("\\", "\\\\")
|
||||||
|
print("")
|
||||||
|
print("[note] допишите хранилище в запись базы в .v8-project.json (см. /db-list):")
|
||||||
|
if args.Extension:
|
||||||
|
print(' "extensions": [ { "name": "%s", "repository": { "path": "%s", "user": "%s", '
|
||||||
|
'"password": "<пароль>" } } ]' % (args.Extension, json_path, repo["user"] or ""))
|
||||||
|
else:
|
||||||
|
print(' "repository": { "path": "%s", "user": "%s", "password": "<пароль>" }'
|
||||||
|
% (json_path, repo["user"] or ""))
|
||||||
print_platform_output(result)
|
print_platform_output(result)
|
||||||
sys.exit(verdict)
|
sys.exit(verdict)
|
||||||
finally:
|
finally:
|
||||||
|
|||||||
Reference in New Issue
Block a user