mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-20 17:40:59 +03:00
feat(validate): brief output by default, -Detailed for verbose
All 10 validation skills (meta, epf, skd, cf, cfe, form, mxl, role, subsystem, interface) now output a single summary line on success: === Validation OK: Type.Name (N checks) === Errors/warnings always shown. Full per-check [OK] output behind -Detailed flag. Removed all N/A check lines. Unified role-validate output format. Trimmed SKILL.md files from 42-119 to 51-67 lines. Version bumps: meta-validate v1.2, all others v1.1. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
93e4130ff2
commit
422e397381
@@ -1,9 +1,11 @@
|
||||
# meta-validate v1.1 — Validate 1C metadata object structure
|
||||
# meta-validate v1.2 — Validate 1C metadata object structure
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$ObjectPath,
|
||||
|
||||
[switch]$Detailed,
|
||||
|
||||
[int]$MaxErrors = 30,
|
||||
|
||||
[string]$OutFile
|
||||
@@ -19,7 +21,7 @@ if ($pathList.Count -gt 1) {
|
||||
$batchOk = 0
|
||||
$batchFail = 0
|
||||
foreach ($singlePath in $pathList) {
|
||||
$callArgs = @{ ObjectPath = $singlePath; MaxErrors = $MaxErrors }
|
||||
$callArgs = @{ ObjectPath = $singlePath; MaxErrors = $MaxErrors; Verbose = $Detailed }
|
||||
if ($OutFile) {
|
||||
$baseName = [System.IO.Path]::GetFileNameWithoutExtension($OutFile)
|
||||
$ext = [System.IO.Path]::GetExtension($OutFile)
|
||||
@@ -96,6 +98,7 @@ for ($depth = 0; $depth -lt 4; $depth++) {
|
||||
|
||||
$script:errors = 0
|
||||
$script:warnings = 0
|
||||
$script:okCount = 0
|
||||
$script:stopped = $false
|
||||
$script:output = New-Object System.Text.StringBuilder 8192
|
||||
|
||||
@@ -106,7 +109,8 @@ function Out-Line {
|
||||
|
||||
function Report-OK {
|
||||
param([string]$msg)
|
||||
Out-Line "[OK] $msg"
|
||||
$script:okCount++
|
||||
if ($Detailed) { Out-Line "[OK] $msg" }
|
||||
}
|
||||
|
||||
function Report-Error {
|
||||
@@ -125,10 +129,14 @@ function Report-Warn {
|
||||
}
|
||||
|
||||
$finalize = {
|
||||
Out-Line ""
|
||||
Out-Line "=== Result: $($script:errors) errors, $($script:warnings) warnings ==="
|
||||
|
||||
$result = $script:output.ToString()
|
||||
$checks = $script:okCount + $script:errors + $script:warnings
|
||||
if ($script:errors -eq 0 -and $script:warnings -eq 0 -and -not $Detailed) {
|
||||
$result = "=== Validation OK: $mdType.$objName ($checks checks) ==="
|
||||
} else {
|
||||
Out-Line ""
|
||||
Out-Line "=== Result: $($script:errors) errors, $($script:warnings) warnings ($checks checks) ==="
|
||||
$result = $script:output.ToString()
|
||||
}
|
||||
Write-Host $result
|
||||
|
||||
if ($OutFile) {
|
||||
@@ -449,8 +457,6 @@ if ($typesWithoutInternalInfo -contains $mdType) {
|
||||
Report-OK "2. InternalInfo: $($genTypes.Count) GeneratedType ($catList)"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Report-OK "2. InternalInfo: N/A for $mdType"
|
||||
}
|
||||
|
||||
if ($script:stopped) { & $finalize; exit 1 }
|
||||
@@ -569,8 +575,6 @@ if ($typesWithStdAttrs -contains $mdType) {
|
||||
Report-OK "5. StandardAttributes: $($stdAttrs.Count) entries"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Report-OK "5. StandardAttributes: N/A for $mdType"
|
||||
}
|
||||
|
||||
if ($script:stopped) { & $finalize; exit 1 }
|
||||
@@ -690,8 +694,6 @@ if ($childObjNode) {
|
||||
} elseif ($check7Count -eq 0) {
|
||||
Report-OK "7. Child elements: none to check"
|
||||
}
|
||||
} else {
|
||||
Report-OK "7. Child elements: N/A (no ChildObjects)"
|
||||
}
|
||||
|
||||
if ($script:stopped) { & $finalize; exit 1 }
|
||||
@@ -725,8 +727,6 @@ if ($childObjNode) {
|
||||
if ($check7bOk) {
|
||||
Report-OK "7b. Reserved attribute names: no conflicts"
|
||||
}
|
||||
} else {
|
||||
Report-OK "7b. Reserved attribute names: N/A"
|
||||
}
|
||||
|
||||
if ($script:stopped) { & $finalize; exit 1 }
|
||||
@@ -814,8 +814,6 @@ if ($childObjNode) {
|
||||
if ($check8Ok) {
|
||||
Report-OK "8. Name uniqueness: all names unique"
|
||||
}
|
||||
} else {
|
||||
Report-OK "8. Name uniqueness: N/A"
|
||||
}
|
||||
|
||||
if ($script:stopped) { & $finalize; exit 1 }
|
||||
@@ -901,8 +899,6 @@ if ($childObjNode) {
|
||||
} else {
|
||||
Report-OK "9. TabularSections: none present"
|
||||
}
|
||||
} else {
|
||||
Report-OK "9. TabularSections: N/A"
|
||||
}
|
||||
|
||||
if ($script:stopped) { & $finalize; exit 1 }
|
||||
@@ -1160,8 +1156,6 @@ if ($mdType -eq "HTTPService" -and $childObjNode) {
|
||||
if ($check11Ok) {
|
||||
Report-OK "11. WebService: $($operations.Count) operation(s), $paramCount parameter(s)"
|
||||
}
|
||||
} else {
|
||||
Report-OK "11. HTTPService/WebService: N/A"
|
||||
}
|
||||
|
||||
if ($script:stopped) { & $finalize; exit 1 }
|
||||
@@ -1181,8 +1175,6 @@ if ($propsNode -and $forbiddenProperties.ContainsKey($mdType)) {
|
||||
if ($check12Ok) {
|
||||
Report-OK "12. Forbidden properties: none found"
|
||||
}
|
||||
} else {
|
||||
Report-OK "12. Forbidden properties: N/A"
|
||||
}
|
||||
|
||||
if ($script:stopped) { & $finalize; exit 1 }
|
||||
@@ -1245,8 +1237,6 @@ if ($propsNode -and $mdType -in @("EventSubscription","ScheduledJob") -and $scri
|
||||
if ($check13Ok) {
|
||||
Report-OK "13. Method reference: $propLabel = '$methodRef'"
|
||||
}
|
||||
} else {
|
||||
Report-OK "13. Method reference: N/A"
|
||||
}
|
||||
|
||||
if ($script:stopped) { & $finalize; exit 1 }
|
||||
@@ -1283,8 +1273,6 @@ if ($mdType -eq "DocumentJournal" -and $childObjNode) {
|
||||
} elseif ($colCount -eq 0) {
|
||||
Report-OK "14. DocumentJournal Columns: none"
|
||||
}
|
||||
} else {
|
||||
Report-OK "14. DocumentJournal Columns: N/A"
|
||||
}
|
||||
|
||||
# --- Final output ---
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# meta-validate v1.1 — Validate 1C metadata object structure (Python port)
|
||||
# meta-validate v1.2 — Validate 1C metadata object structure (Python port)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import os
|
||||
@@ -15,10 +15,12 @@ sys.stderr.reconfigure(encoding="utf-8")
|
||||
|
||||
parser = argparse.ArgumentParser(allow_abbrev=False)
|
||||
parser.add_argument("-ObjectPath", required=True)
|
||||
parser.add_argument("-Detailed", action="store_true")
|
||||
parser.add_argument("-MaxErrors", type=int, default=30)
|
||||
parser.add_argument("-OutFile", default="")
|
||||
args = parser.parse_args()
|
||||
|
||||
detailed = args.Detailed
|
||||
max_errors = args.MaxErrors
|
||||
out_file = args.OutFile
|
||||
|
||||
@@ -30,6 +32,8 @@ if len(path_list) > 1:
|
||||
batch_fail = 0
|
||||
for single_path in path_list:
|
||||
cmd = [sys.executable, __file__, "-ObjectPath", single_path, "-MaxErrors", str(max_errors)]
|
||||
if detailed:
|
||||
cmd.append("-Detailed")
|
||||
if out_file:
|
||||
base, ext = os.path.splitext(out_file)
|
||||
obj_leaf = os.path.splitext(os.path.basename(single_path))[0]
|
||||
@@ -98,6 +102,7 @@ for _ in range(4):
|
||||
|
||||
errors = 0
|
||||
warnings = 0
|
||||
ok_count = 0
|
||||
stopped = False
|
||||
output_lines = []
|
||||
|
||||
@@ -107,7 +112,10 @@ def out_line(msg):
|
||||
|
||||
|
||||
def report_ok(msg):
|
||||
out_line(f"[OK] {msg}")
|
||||
global ok_count
|
||||
ok_count += 1
|
||||
if detailed:
|
||||
out_line(f"[OK] {msg}")
|
||||
|
||||
|
||||
def report_error(msg):
|
||||
@@ -125,9 +133,13 @@ def report_warn(msg):
|
||||
|
||||
|
||||
def finalize():
|
||||
out_line("")
|
||||
out_line(f"=== Result: {errors} errors, {warnings} warnings ===")
|
||||
result = "\n".join(output_lines)
|
||||
checks = ok_count + errors + warnings
|
||||
if errors == 0 and warnings == 0 and not detailed:
|
||||
result = f"=== Validation OK: {md_type}.{obj_name} ({checks} checks) ==="
|
||||
else:
|
||||
out_line("")
|
||||
out_line(f"=== Result: {errors} errors, {warnings} warnings ({checks} checks) ===")
|
||||
result = "\n".join(output_lines)
|
||||
print(result)
|
||||
if out_file:
|
||||
with open(out_file, "w", encoding="utf-8-sig") as f:
|
||||
@@ -453,8 +465,6 @@ elif md_type in generated_type_categories:
|
||||
if check2_ok:
|
||||
cat_list = ", ".join(sorted(found_categories))
|
||||
report_ok(f"2. InternalInfo: {len(gen_types)} GeneratedType ({cat_list})")
|
||||
else:
|
||||
report_ok(f"2. InternalInfo: N/A for {md_type}")
|
||||
|
||||
if stopped:
|
||||
finalize()
|
||||
@@ -560,8 +570,6 @@ if md_type in types_with_std_attrs:
|
||||
|
||||
if check5_ok:
|
||||
report_ok(f"5. StandardAttributes: {len(std_attrs)} entries")
|
||||
else:
|
||||
report_ok(f"5. StandardAttributes: N/A for {md_type}")
|
||||
|
||||
if stopped:
|
||||
finalize()
|
||||
@@ -663,8 +671,6 @@ if child_obj_node is not None:
|
||||
report_ok(f"7. Child elements: {check7_count} items checked (UUID, Name, Type)")
|
||||
elif check7_count == 0:
|
||||
report_ok("7. Child elements: none to check")
|
||||
else:
|
||||
report_ok("7. Child elements: N/A (no ChildObjects)")
|
||||
|
||||
if stopped:
|
||||
finalize()
|
||||
@@ -694,8 +700,6 @@ if child_obj_node is not None:
|
||||
check7b_ok = False
|
||||
if check7b_ok:
|
||||
report_ok("7b. Reserved attribute names: no conflicts")
|
||||
else:
|
||||
report_ok("7b. Reserved attribute names: N/A")
|
||||
|
||||
if stopped:
|
||||
finalize()
|
||||
@@ -776,8 +780,6 @@ if child_obj_node is not None:
|
||||
|
||||
if check8_ok:
|
||||
report_ok("8. Name uniqueness: all names unique")
|
||||
else:
|
||||
report_ok("8. Name uniqueness: N/A")
|
||||
|
||||
if stopped:
|
||||
finalize()
|
||||
@@ -854,8 +856,6 @@ if child_obj_node is not None:
|
||||
report_ok(f"9. TabularSections: {ts_count} sections, structure valid")
|
||||
else:
|
||||
report_ok("9. TabularSections: none present")
|
||||
else:
|
||||
report_ok("9. TabularSections: N/A")
|
||||
|
||||
if stopped:
|
||||
finalize()
|
||||
@@ -1083,8 +1083,6 @@ elif md_type == "WebService" and child_obj_node is not None:
|
||||
|
||||
if check11_ok:
|
||||
report_ok(f"11. WebService: {len(operations)} operation(s), {param_count} parameter(s)")
|
||||
else:
|
||||
report_ok("11. HTTPService/WebService: N/A")
|
||||
|
||||
if stopped:
|
||||
finalize()
|
||||
@@ -1102,8 +1100,6 @@ if props_node is not None and md_type in forbidden_properties:
|
||||
check12_ok = False
|
||||
if check12_ok:
|
||||
report_ok("12. Forbidden properties: none found")
|
||||
else:
|
||||
report_ok("12. Forbidden properties: N/A")
|
||||
|
||||
if stopped:
|
||||
finalize()
|
||||
@@ -1161,8 +1157,6 @@ if props_node is not None and md_type in ("EventSubscription", "ScheduledJob") a
|
||||
|
||||
if check13_ok:
|
||||
report_ok(f"13. Method reference: {prop_label} = '{method_ref}'")
|
||||
else:
|
||||
report_ok("13. Method reference: N/A")
|
||||
|
||||
if stopped:
|
||||
finalize()
|
||||
@@ -1197,8 +1191,6 @@ if md_type == "DocumentJournal" and child_obj_node is not None:
|
||||
report_ok(f"14. DocumentJournal Columns: {col_count} column(s), all have References")
|
||||
elif col_count == 0:
|
||||
report_ok("14. DocumentJournal Columns: none")
|
||||
else:
|
||||
report_ok("14. DocumentJournal Columns: N/A")
|
||||
|
||||
# ── Final output ──────────────────────────────────────────────
|
||||
|
||||
|
||||
Reference in New Issue
Block a user