mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-09-19 16:35:52 +03:00
refactor(skd-compile,skd-edit,form-compile,role-*): одно правило поиска @файла
Чтение текста из файла жило тремя копиями под именем Resolve-QueryValue и вне реестра гарда, а role-* завели четвёртое правило — только от рабочего каталога. Теперь функция одна на пять навыков: Resolve-TextFromFile / resolve_text_from_file, заведена семья в check-inline-drift, эталон — skd-edit. Правило поиска общее: абсолютный путь как есть, относительный — рядом с DSL (у edit-навыков — рядом с редактируемым объектом), затем в текущем каталоге, не нашли — ошибка со списком проверенных мест. Имя без "query": в ролях из файла приходит условие RLS, а не запрос. Текст ошибки приведён к языку остальных сообщений. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FGkXwoXTuafcu1SXMsauFq
This commit is contained in:
co-authored by
Claude Opus 5
parent
121c9c8ad3
commit
d425833709
@@ -1,4 +1,4 @@
|
||||
# skd-compile v1.121 — Compile 1C DCS from JSON (+write_xml_file/write_utf8_bom: общий эталон записи)
|
||||
# skd-compile v1.122 — Compile 1C DCS from JSON (+write_xml_file/write_utf8_bom: общий эталон записи)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
[CmdletBinding(PositionalBinding=$false)]
|
||||
param(
|
||||
@@ -305,7 +305,7 @@ function Esc-XmlText {
|
||||
return $s.Replace('&','&').Replace('<','<').Replace('>','>')
|
||||
}
|
||||
|
||||
function Resolve-QueryValue {
|
||||
function Resolve-TextFromFile {
|
||||
param([string]$val, [string]$baseDir)
|
||||
if (-not $val.StartsWith("@")) { return $val }
|
||||
$filePath = $val.Substring(1)
|
||||
@@ -322,7 +322,7 @@ function Resolve-QueryValue {
|
||||
return (Get-Content -Raw -Encoding UTF8 $c).TrimEnd()
|
||||
}
|
||||
}
|
||||
Write-Error "Query file not found: $filePath (searched: $($candidates -join ', '))"
|
||||
Write-Error "Файл значения не найден: $filePath (искали: $($candidates -join ', '))"
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -1341,7 +1341,7 @@ function Emit-DataSet {
|
||||
|
||||
# Type-specific content
|
||||
if ($dsType -eq "DataSetQuery") {
|
||||
$queryText = Resolve-QueryValue "$($ds.query)" $script:queryBaseDir
|
||||
$queryText = Resolve-TextFromFile "$($ds.query)" $script:queryBaseDir
|
||||
X "$indent`t<query>$(Esc-XmlText $queryText)</query>"
|
||||
if ($ds.autoFillFields -eq $false) {
|
||||
X "$indent`t<autoFillFields>false</autoFillFields>"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# skd-compile v1.121 — Compile 1C DCS from JSON (+write_xml_file/write_utf8_bom: общий эталон записи)
|
||||
# skd-compile v1.122 — Compile 1C DCS from JSON (+write_xml_file/write_utf8_bom: общий эталон записи)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import json
|
||||
@@ -321,7 +321,7 @@ def fmt_dec(v):
|
||||
return str(int(v)) if v == int(v) else str(v)
|
||||
|
||||
|
||||
def resolve_query_value(val, base_dir):
|
||||
def resolve_text_from_file(val, base_dir):
|
||||
if not val.startswith("@"):
|
||||
return val
|
||||
file_path = val[1:]
|
||||
@@ -336,7 +336,7 @@ def resolve_query_value(val, base_dir):
|
||||
if os.path.exists(c):
|
||||
with open(c, 'r', encoding='utf-8-sig') as f:
|
||||
return f.read().rstrip()
|
||||
print(f"Query file not found: {file_path} (searched: {', '.join(candidates)})", file=sys.stderr)
|
||||
print(f"Файл значения не найден: {file_path} (искали: {', '.join(candidates)})", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
@@ -1190,7 +1190,7 @@ def emit_data_set(lines, ds, indent, default_source, tag_name='dataSet'):
|
||||
|
||||
# Type-specific content
|
||||
if ds_type == 'DataSetQuery':
|
||||
query_text = resolve_query_value(str(ds.get("query", "")), query_base_dir)
|
||||
query_text = resolve_text_from_file(str(ds.get("query", "")), query_base_dir)
|
||||
lines.append(f'{indent}\t<query>{esc_xml_text(query_text)}</query>')
|
||||
if ds.get('autoFillFields') is False:
|
||||
lines.append(f'{indent}\t<autoFillFields>false</autoFillFields>')
|
||||
|
||||
Reference in New Issue
Block a user