refactor(meta-validate,web-publish): свести format_rank и db-обвязку к эталонам

format_rank в meta-validate отличался только именем параметра, _version_key в
web-publish инлайнил каталог версии вместо общего _version_dir (и знал только
Windows-раскладку .../bin/exe). Обе копии приведены к эталону db-create/
meta-compile; для Windows-навыка web-publish поведение не меняется.

В реестр добавлены семьи _version_dir и _find_project_v8path.

Экстрактор PS1 в гарде и сканере научен видеть вложенные определения: db-load-git
объявляет Find-ProjectV8Path внутри if, и поиск по `function` с нулевой позиции
считал функцию отсутствующей. Конец тела теперь ищется по закрывающей скобке на
отступе самого слова function.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-08-08 21:13:50 +03:00
co-authored by Claude Opus 5
parent 974ca3aac9
commit fadda6a287
5 changed files with 45 additions and 20 deletions
@@ -1,4 +1,4 @@
# meta-validate v1.15 — Validate 1C metadata object structure (+ReuseSessions: Use)
# meta-validate v1.16 — Validate 1C metadata object structure (+format_rank: свести к общему эталону)
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
param(
[Parameter(Mandatory)]
@@ -1509,8 +1509,8 @@ $versionedProps = @{
"UseInInterfaceCompatibilityMode" = "2.21" # использование общей формы в режиме совместимости интерфейса
}
# Версия формата как число: "2.20" → 220. Строковое сравнение неверно ("2.9" > "2.17").
function Get-FormatRank([string]$v) {
if ($v -match '^(\d+)\.(\d+)$') { return [int]$Matches[1] * 100 + [int]$Matches[2] }
function Get-FormatRank([string]$ver) {
if ($ver -match '^(\d+)\.(\d+)$') { return [int]$Matches[1] * 100 + [int]$Matches[2] }
return 0
}
$fileRank = Get-FormatRank $version
@@ -1,4 +1,4 @@
# meta-validate v1.15 — Validate 1C metadata object structure (Python port) (+ReuseSessions: Use)
# meta-validate v1.16 — Validate 1C metadata object structure (Python port) (+format_rank: свести к общему эталону)
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse
import os
@@ -1412,9 +1412,9 @@ versioned_props = {
}
def format_rank(v):
""""2.20" → 220. Строковое сравнение неверно ("2.9" > "2.17")."""
m = re.match(r'^(\d+)\.(\d+)$', v or '')
def format_rank(ver):
""""2.20" → 220, "2.9" → 209. Строковое сравнение неверно ("2.9" > "2.17")."""
m = re.match(r'^(\d+)\.(\d+)$', ver or '')
return int(m.group(1)) * 100 + int(m.group(2)) if m else 0
@@ -1,4 +1,4 @@
# web-publish v1.5 — Publish 1C infobase via Apache
# web-publish v1.6 — Publish 1C infobase via Apache (+_version_dir/_version_key: общий эталон db-семейства)
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
<#
.SYNOPSIS
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# web-publish v1.5 — Publish 1C infobase via Apache
# web-publish v1.6 — Publish 1C infobase via Apache (+_version_dir/_version_key: общий эталон db-семейства)
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
"""
@@ -46,10 +46,17 @@ def _find_project_v8path():
d = parent
def _version_dir(p):
"""Version dir for both Windows (.../1cv8/<ver>/bin/1cv8.exe) and *nix (.../1cv8/<ver>/1cv8)."""
parent = os.path.dirname(p)
if os.path.basename(parent).lower() == "bin":
parent = os.path.dirname(parent)
return os.path.basename(parent)
def _version_key(p):
"""Numeric sort key from version dir name (.../1cv8/<ver>/bin/1cv8.exe)."""
ver = os.path.basename(os.path.dirname(os.path.dirname(p)))
return [int(x) for x in re.findall(r"\d+", ver)]
"""Numeric sort key from version dir name."""
return [int(x) for x in re.findall(r"\d+", _version_dir(p))]
def get_our_httpd(httpd_exe_norm):
+26 -8
View File
@@ -104,10 +104,10 @@ const FAMILIES = [
name: 'format_rank', py: 'format_rank', ps1: 'Get-FormatRank',
variants: [
{ id: 'base', authority: 'meta-compile',
consumers: ['cfe-borrow', 'cfe-init', 'form-add', 'form-compile', 'mxl-compile', 'role-compile',
'subsystem-compile', 'subsystem-edit', 'template-add', 'xdto-compile'],
consumers: ['cfe-borrow', 'cfe-init', 'form-add', 'form-compile', 'meta-validate',
'mxl-compile', 'role-compile', 'subsystem-compile', 'subsystem-edit', 'template-add',
'xdto-compile'],
consumersPy: ['epf-init', 'erf-init'] },
{ id: 'meta-validate-own', authority: 'meta-validate', consumers: [] },
],
},
@@ -200,8 +200,23 @@ const FAMILIES = [
variants: [
{ id: 'base', authority: 'db-create',
consumers: ['db-dump-cf', 'db-dump-dt', 'db-dump-xml', 'db-load-cf', 'db-load-dt', 'db-load-git',
'db-load-xml', 'db-run', 'db-update', 'epf-build', 'epf-dump'] },
{ id: 'web-publish-own', authority: 'web-publish', consumers: [] },
'db-load-xml', 'db-run', 'db-update', 'epf-build', 'epf-dump', 'web-publish'] },
],
},
{
name: 'platform: version_dir', py: '_version_dir', ps1: null,
variants: [
{ id: 'base', authority: 'db-create',
consumers: ['db-dump-cf', 'db-dump-dt', 'db-dump-xml', 'db-load-cf', 'db-load-dt', 'db-load-git',
'db-load-xml', 'db-run', 'db-update', 'epf-build', 'epf-dump', 'web-publish'] },
],
},
{
name: 'platform: find_project_v8path', py: '_find_project_v8path', ps1: 'Find-ProjectV8Path',
variants: [
{ id: 'base', authority: 'db-create',
consumers: ['db-dump-cf', 'db-dump-dt', 'db-dump-xml', 'db-load-cf', 'db-load-dt', 'db-load-git',
'db-load-xml', 'db-run', 'db-update', 'epf-build', 'epf-dump', 'web-publish'] },
],
},
@@ -251,15 +266,18 @@ function extractPs1(text) {
const lines = text.split('\n');
const out = new Map();
for (let i = 0; i < lines.length; i++) {
const m = /^function\s+([A-Za-z][\w-]*)/.exec(lines[i]);
// Определение может быть вложенным (db-load-git объявляет Find-ProjectV8Path внутри if),
// поэтому конец ищем по закрывающей скобке НА ТОМ ЖЕ отступе, что и слово function.
const m = /^(\s*)function\s+([A-Za-z][\w-]*)/.exec(lines[i]);
if (!m) continue;
const closing = m[1] + '}';
const body = [lines[i]];
let j = i + 1;
for (; j < lines.length; j++) {
body.push(lines[j]);
if (lines[j].replace(/\s+$/, '') === '}') break;
if (lines[j].replace(/\s+$/, '') === closing) break;
}
out.set(m[1], body);
if (!out.has(m[2])) out.set(m[2], body);
i = j;
}
return out;