mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-09-06 02:00:54 +03:00
fix(17 навыков): самозакрывающийся тег без пробела и UTF-8 в декларации (#57)
.NET XmlWriter пишет `<a />`, а Конфигуратор — `<a/>`. Поскольку Save переписывает файл целиком, meta-edit при добавлении одного реквизита переводил в пробельную форму все пустые теги документа. Дефект только у PS-порта: lxml (45 из 49 py-портов) уже пишет плотно, то есть порты расходились побайтово. Канон измерен, а не предположен: чистая выгрузка пустой ИБ на Windows и macOS плюс сплошной скан 8 выгрузок в cfsrc — 476 943 XML, 21 294 119 самозакрывающихся тегов, пробельных 0. Форма не зависит от ОС, версии платформы (8.3.20-8.5) и наличия атрибутов. Правило уже было реализовано в skd-edit — оттуда и взято. Замена безопасна доказуемо: .NET экранирует `>` как `>` и в тексте, и в атрибутах, поэтому ` />` после Save — только конец тега. Лазейки (CDATA, комментарии) в 1С-метаданных не встречаются — 0 из 476 943 файлов; гард на них всё равно стоит. Одиннадцать скриптов писали прямо в FileStream без пост-обработки — переведены на MemoryStream, что заодно чинит `encoding="utf-8"` строчными (335 файлов в снэпшотах). В cfe-borrow правится и сборка Form.xml: куски берутся из OuterXml, а он спацовывает так же, как XmlWriter. Дрейф снэпшотов: 12 838 строк тегов + 335 деклараций, содержательных изменений ноль. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
ccd860ae89
commit
39cf8e49cf
@@ -1,4 +1,4 @@
|
||||
# cf-edit v1.11 — Edit 1C configuration root (Configuration.xml)
|
||||
# cf-edit v1.12 — Edit 1C configuration root (Configuration.xml)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)][Alias('Path')][string]$ConfigPath,
|
||||
@@ -982,6 +982,9 @@ $memStream.Close()
|
||||
$text = [System.Text.Encoding]::UTF8.GetString($bytes)
|
||||
if ($text.Length -gt 0 -and $text[0] -eq [char]0xFEFF) { $text = $text.Substring(1) }
|
||||
$text = $text.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||
# Пустой элемент: XmlWriter пишет `<a />`, Конфигуратор — `<a/>`. Гард на CDATA/комментарии:
|
||||
# только там `>` не экранируется, и ` />` может быть содержимым, а не концом тега.
|
||||
if ($text -notmatch '<!\[CDATA\[|<!--') { $text = [regex]::Replace($text, '(?<=\S) />', '/>') }
|
||||
|
||||
$utf8Bom = New-Object System.Text.UTF8Encoding($true)
|
||||
[System.IO.File]::WriteAllText($resolvedPath, $text, $utf8Bom)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# cf-edit v1.11 — Edit 1C configuration root (Configuration.xml)
|
||||
# cf-edit v1.12 — Edit 1C configuration root (Configuration.xml)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
|
||||
import argparse
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# cfe-borrow v1.11 — Borrow objects from configuration into extension (CFE)
|
||||
# cfe-borrow v1.12 — Borrow objects from configuration into extension (CFE)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)][string]$ExtensionPath,
|
||||
@@ -917,7 +917,12 @@ function Borrow-Form {
|
||||
New-Item -ItemType Directory -Path $formXmlDir -Force | Out-Null
|
||||
}
|
||||
$formXmlFile = Join-Path $formXmlDir "Form.xml"
|
||||
[System.IO.File]::WriteAllText($formXmlFile, $formXmlSb.ToString(), $enc)
|
||||
# Куски формы берутся из OuterXml исходного документа, а он — как и XmlWriter —
|
||||
# отдаёт `<a />`; Конфигуратор пишет `<a/>`. Гард на CDATA/комментарии: только там
|
||||
# `>` не экранируется, и ` />` может быть содержимым, а не концом тега.
|
||||
$formXmlText = $formXmlSb.ToString()
|
||||
if ($formXmlText -notmatch '<!\[CDATA\[|<!--') { $formXmlText = [regex]::Replace($formXmlText, '(?<=\S) />', '/>') }
|
||||
[System.IO.File]::WriteAllText($formXmlFile, $formXmlText, $enc)
|
||||
Info " Created: $formXmlFile"
|
||||
|
||||
# 6. Create empty Module.bsl — but NEVER overwrite an existing one (re-borrow must
|
||||
@@ -1023,6 +1028,9 @@ function Register-FormInObject {
|
||||
$text2 = [System.Text.Encoding]::UTF8.GetString($bytes2)
|
||||
if ($text2.Length -gt 0 -and $text2[0] -eq [char]0xFEFF) { $text2 = $text2.Substring(1) }
|
||||
$text2 = $text2.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||
# Пустой элемент: XmlWriter пишет `<a />`, Конфигуратор — `<a/>`. Гард на CDATA/комментарии:
|
||||
# только там `>` не экранируется, и ` />` может быть содержимым, а не концом тега.
|
||||
if ($text2 -notmatch '<!\[CDATA\[|<!--') { $text2 = [regex]::Replace($text2, '(?<=\S) />', '/>') }
|
||||
|
||||
$utf8Bom2 = New-Object System.Text.UTF8Encoding($true)
|
||||
[System.IO.File]::WriteAllText($objFile, $text2, $utf8Bom2)
|
||||
@@ -1413,6 +1421,10 @@ function Merge-AttributesIntoObject {
|
||||
# Insert attributes before </ChildObjects>
|
||||
$text3 = $text3 -replace '</ChildObjects>', "${allAttrXml}`r`n`t`t</ChildObjects>"
|
||||
|
||||
# Пустой элемент: XmlWriter пишет `<a />`, Конфигуратор — `<a/>`. После вставки реквизитов,
|
||||
# чтобы накрыть и их. Гард на CDATA/комментарии: только там ` />` может быть содержимым.
|
||||
if ($text3 -notmatch '<!\[CDATA\[|<!--') { $text3 = [regex]::Replace($text3, '(?<=\S) />', '/>') }
|
||||
|
||||
$utf8Bom3 = New-Object System.Text.UTF8Encoding($true)
|
||||
[System.IO.File]::WriteAllText($objFile, $text3, $utf8Bom3)
|
||||
Info " Merged $added attribute(s) into: $objFile"
|
||||
@@ -1877,6 +1889,9 @@ $memStream.Close()
|
||||
$text = [System.Text.Encoding]::UTF8.GetString($bytes)
|
||||
if ($text.Length -gt 0 -and $text[0] -eq [char]0xFEFF) { $text = $text.Substring(1) }
|
||||
$text = $text.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||
# Пустой элемент: XmlWriter пишет `<a />`, Конфигуратор — `<a/>`. Гард на CDATA/комментарии:
|
||||
# только там `>` не экранируется, и ` />` может быть содержимым, а не концом тега.
|
||||
if ($text -notmatch '<!\[CDATA\[|<!--') { $text = [regex]::Replace($text, '(?<=\S) />', '/>') }
|
||||
|
||||
$utf8Bom = New-Object System.Text.UTF8Encoding($true)
|
||||
[System.IO.File]::WriteAllText($extResolvedPath, $text, $utf8Bom)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# cfe-borrow v1.11 — Borrow objects from configuration into extension (CFE)
|
||||
# cfe-borrow v1.12 — Borrow objects from configuration into extension (CFE)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
|
||||
import argparse
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# form-add v1.12 — Add managed form to 1C config object
|
||||
# form-add v1.13 — Add managed form to 1C config object
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -586,11 +586,20 @@ $settings = New-Object System.Xml.XmlWriterSettings
|
||||
$settings.Encoding = $encBom
|
||||
$settings.Indent = $false
|
||||
|
||||
$stream = New-Object System.IO.FileStream($objectXmlFull.Path, [System.IO.FileMode]::Create)
|
||||
$writer = [System.Xml.XmlWriter]::Create($stream, $settings)
|
||||
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки — XmlWriter
|
||||
# отдаёт `encoding="utf-8"` и `<a />`, Конфигуратор пишет `encoding="UTF-8"` и `<a/>`.
|
||||
$memStream = New-Object System.IO.MemoryStream
|
||||
$writer = [System.Xml.XmlWriter]::Create($memStream, $settings)
|
||||
$xmlDoc.Save($writer)
|
||||
$writer.Close()
|
||||
$stream.Close()
|
||||
$writer.Flush(); $writer.Close()
|
||||
|
||||
$xmlText = [System.Text.Encoding]::UTF8.GetString($memStream.ToArray())
|
||||
$memStream.Close()
|
||||
if ($xmlText.Length -gt 0 -and $xmlText[0] -eq [char]0xFEFF) { $xmlText = $xmlText.Substring(1) }
|
||||
$xmlText = $xmlText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||
# Гард на CDATA/комментарии: только там `>` не экранируется, и ` />` может быть содержимым.
|
||||
if ($xmlText -notmatch '<!\[CDATA\[|<!--') { $xmlText = [regex]::Replace($xmlText, '(?<=\S) />', '/>') }
|
||||
[System.IO.File]::WriteAllText($objectXmlFull.Path, $xmlText, $encBom)
|
||||
|
||||
# --- Фаза 5: Вывод ---
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# form-add v1.12 — Add managed form to 1C config object
|
||||
# form-add v1.13 — Add managed form to 1C config object
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
|
||||
import argparse
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# form-compile v1.176 — Compile 1C managed form from JSON or object metadata
|
||||
# form-compile v1.177 — Compile 1C managed form from JSON or object metadata
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$JsonPath,
|
||||
@@ -6677,11 +6677,20 @@ if ($formsLeaf -eq 'Forms') {
|
||||
$regSettings = New-Object System.Xml.XmlWriterSettings
|
||||
$regSettings.Encoding = $regEnc
|
||||
$regSettings.Indent = $false
|
||||
$regStream = New-Object System.IO.FileStream($objectXmlPath, [System.IO.FileMode]::Create)
|
||||
$regWriter = [System.Xml.XmlWriter]::Create($regStream, $regSettings)
|
||||
# Через MemoryStream: нужен шаг пост-обработки строки — XmlWriter отдаёт
|
||||
# `encoding="utf-8"` и `<a />`, Конфигуратор пишет `encoding="UTF-8"` и `<a/>`.
|
||||
$regMem = New-Object System.IO.MemoryStream
|
||||
$regWriter = [System.Xml.XmlWriter]::Create($regMem, $regSettings)
|
||||
$objDoc.Save($regWriter)
|
||||
$regWriter.Close()
|
||||
$regStream.Close()
|
||||
$regWriter.Flush(); $regWriter.Close()
|
||||
|
||||
$regText = [System.Text.Encoding]::UTF8.GetString($regMem.ToArray())
|
||||
$regMem.Close()
|
||||
if ($regText.Length -gt 0 -and $regText[0] -eq [char]0xFEFF) { $regText = $regText.Substring(1) }
|
||||
$regText = $regText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||
# Гард на CDATA/комментарии: только там ` />` может быть содержимым.
|
||||
if ($regText -notmatch '<!\[CDATA\[|<!--') { $regText = [regex]::Replace($regText, '(?<=\S) />', '/>') }
|
||||
[System.IO.File]::WriteAllText($objectXmlPath, $regText, $regEnc)
|
||||
|
||||
Write-Host " Registered: <Form>$formName</Form> in $objectName.xml"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# form-compile v1.176 — Compile 1C managed form from JSON or object metadata
|
||||
# form-compile v1.177 — Compile 1C managed form from JSON or object metadata
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import copy
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# form-remove v1.4 — Remove form from 1C object
|
||||
# form-remove v1.5 — Remove form from 1C object
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -84,10 +84,19 @@ $settings = New-Object System.Xml.XmlWriterSettings
|
||||
$settings.Encoding = $encBom
|
||||
$settings.Indent = $false
|
||||
|
||||
$stream = New-Object System.IO.FileStream($rootXmlFull.Path, [System.IO.FileMode]::Create)
|
||||
$writer = [System.Xml.XmlWriter]::Create($stream, $settings)
|
||||
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки — XmlWriter
|
||||
# отдаёт `encoding="utf-8"` и `<a />`, Конфигуратор пишет `encoding="UTF-8"` и `<a/>`.
|
||||
$memStream = New-Object System.IO.MemoryStream
|
||||
$writer = [System.Xml.XmlWriter]::Create($memStream, $settings)
|
||||
$xmlDoc.Save($writer)
|
||||
$writer.Close()
|
||||
$stream.Close()
|
||||
$writer.Flush(); $writer.Close()
|
||||
|
||||
$xmlText = [System.Text.Encoding]::UTF8.GetString($memStream.ToArray())
|
||||
$memStream.Close()
|
||||
if ($xmlText.Length -gt 0 -and $xmlText[0] -eq [char]0xFEFF) { $xmlText = $xmlText.Substring(1) }
|
||||
$xmlText = $xmlText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||
# Гард на CDATA/комментарии: только там `>` не экранируется, и ` />` может быть содержимым.
|
||||
if ($xmlText -notmatch '<!\[CDATA\[|<!--') { $xmlText = [regex]::Replace($xmlText, '(?<=\S) />', '/>') }
|
||||
[System.IO.File]::WriteAllText($rootXmlFull.Path, $xmlText, $encBom)
|
||||
|
||||
Write-Host "[OK] Форма $FormName удалена из $rootXmlPath"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# remove-form v1.4 — Remove form from 1C object
|
||||
# remove-form v1.5 — Remove form from 1C object
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
|
||||
import argparse
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# help-add v1.9 — Add built-in help to 1C object
|
||||
# help-add v1.10 — Add built-in help to 1C object
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -255,11 +255,20 @@ if (Test-Path $formsDir) {
|
||||
$settings = New-Object System.Xml.XmlWriterSettings
|
||||
$settings.Encoding = $encBom
|
||||
$settings.Indent = $false
|
||||
$stream = New-Object System.IO.FileStream($formMeta.FullName, [System.IO.FileMode]::Create)
|
||||
$writer = [System.Xml.XmlWriter]::Create($stream, $settings)
|
||||
# Через MemoryStream: нужен шаг пост-обработки строки — XmlWriter отдаёт
|
||||
# `encoding="utf-8"` и `<a />`, Конфигуратор пишет `encoding="UTF-8"` и `<a/>`.
|
||||
$memStream = New-Object System.IO.MemoryStream
|
||||
$writer = [System.Xml.XmlWriter]::Create($memStream, $settings)
|
||||
$xmlDoc.Save($writer)
|
||||
$writer.Close()
|
||||
$stream.Close()
|
||||
$writer.Flush(); $writer.Close()
|
||||
|
||||
$xmlText = [System.Text.Encoding]::UTF8.GetString($memStream.ToArray())
|
||||
$memStream.Close()
|
||||
if ($xmlText.Length -gt 0 -and $xmlText[0] -eq [char]0xFEFF) { $xmlText = $xmlText.Substring(1) }
|
||||
$xmlText = $xmlText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||
# Гард на CDATA/комментарии: только там ` />` может быть содержимым.
|
||||
if ($xmlText -notmatch '<!\[CDATA\[|<!--') { $xmlText = [regex]::Replace($xmlText, '(?<=\S) />', '/>') }
|
||||
[System.IO.File]::WriteAllText($formMeta.FullName, $xmlText, $encBom)
|
||||
|
||||
Write-Host " IncludeHelpInContents добавлен: $($formMeta.Name)"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# add-help v1.9 — Add built-in help to 1C object
|
||||
# add-help v1.10 — Add built-in help to 1C object
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
|
||||
import argparse
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# interface-edit v1.9 — Edit 1C CommandInterface.xml
|
||||
# interface-edit v1.10 — Edit 1C CommandInterface.xml
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)][Alias('Path')][string]$CIPath,
|
||||
@@ -674,6 +674,9 @@ $memStream.Close()
|
||||
$text = [System.Text.Encoding]::UTF8.GetString($bytes)
|
||||
if ($text.Length -gt 0 -and $text[0] -eq [char]0xFEFF) { $text = $text.Substring(1) }
|
||||
$text = $text.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||
# Пустой элемент: XmlWriter пишет `<a />`, Конфигуратор — `<a/>`. Гард на CDATA/комментарии:
|
||||
# только там `>` не экранируется, и ` />` может быть содержимым, а не концом тега.
|
||||
if ($text -notmatch '<!\[CDATA\[|<!--') { $text = [regex]::Replace($text, '(?<=\S) />', '/>') }
|
||||
|
||||
$utf8Bom = New-Object System.Text.UTF8Encoding($true)
|
||||
[System.IO.File]::WriteAllText($resolvedPath, $text, $utf8Bom)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# interface-edit v1.9 — Edit 1C CommandInterface.xml
|
||||
# interface-edit v1.10 — Edit 1C CommandInterface.xml
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
|
||||
import argparse
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# meta-compile v1.76 — Compile 1C metadata object from JSON
|
||||
# meta-compile v1.77 — Compile 1C metadata object from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -4990,15 +4990,25 @@ if (Test-Path $configXmlPath) {
|
||||
}
|
||||
}
|
||||
|
||||
# Save
|
||||
# Save. Пишем через MemoryStream, а не прямо в файл: нужен шаг пост-обработки
|
||||
# строки — XmlWriter отдаёт `encoding="utf-8"` и `<a />`, Конфигуратор пишет
|
||||
# `encoding="UTF-8"` и `<a/>`.
|
||||
$cfgSettings = New-Object System.Xml.XmlWriterSettings
|
||||
$cfgSettings.Encoding = New-Object System.Text.UTF8Encoding($true)
|
||||
$cfgSettings.Indent = $false
|
||||
$stream = New-Object System.IO.FileStream($configXmlPath, [System.IO.FileMode]::Create)
|
||||
$writer = [System.Xml.XmlWriter]::Create($stream, $cfgSettings)
|
||||
$memStream = New-Object System.IO.MemoryStream
|
||||
$writer = [System.Xml.XmlWriter]::Create($memStream, $cfgSettings)
|
||||
$configDoc.Save($writer)
|
||||
$writer.Close()
|
||||
$stream.Close()
|
||||
$writer.Flush(); $writer.Close()
|
||||
|
||||
$cfgText = [System.Text.Encoding]::UTF8.GetString($memStream.ToArray())
|
||||
$memStream.Close()
|
||||
if ($cfgText.Length -gt 0 -and $cfgText[0] -eq [char]0xFEFF) { $cfgText = $cfgText.Substring(1) }
|
||||
$cfgText = $cfgText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||
# Гард на CDATA/комментарии: только там `>` не экранируется, и ` />` может
|
||||
# быть содержимым, а не концом тега.
|
||||
if ($cfgText -notmatch '<!\[CDATA\[|<!--') { $cfgText = [regex]::Replace($cfgText, '(?<=\S) />', '/>') }
|
||||
[System.IO.File]::WriteAllText($configXmlPath, $cfgText, (New-Object System.Text.UTF8Encoding($true)))
|
||||
|
||||
$regResult = "added"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# meta-compile v1.76 — Compile 1C metadata object from JSON
|
||||
# meta-compile v1.77 — Compile 1C metadata object from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
|
||||
import argparse
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# meta-edit v1.24 — Edit existing 1C metadata object XML
|
||||
# meta-edit v1.25 — Edit existing 1C metadata object XML
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$DefinitionFile,
|
||||
@@ -3208,6 +3208,9 @@ if ($text.Length -gt 0 -and $text[0] -eq [char]0xFEFF) {
|
||||
$text = $text.Substring(1)
|
||||
}
|
||||
$text = $text.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||
# Пустой элемент: XmlWriter пишет `<a />`, Конфигуратор — `<a/>`. Гард на CDATA/комментарии:
|
||||
# только там `>` не экранируется, и ` />` может быть содержимым, а не концом тега.
|
||||
if ($text -notmatch '<!\[CDATA\[|<!--') { $text = [regex]::Replace($text, '(?<=\S) />', '/>') }
|
||||
|
||||
# Write with BOM
|
||||
$utf8Bom = New-Object System.Text.UTF8Encoding($true)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# meta-edit v1.24 — Edit existing 1C metadata object XML
|
||||
# meta-edit v1.25 — Edit existing 1C metadata object XML
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
|
||||
import argparse
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# meta-remove v1.5 — Remove metadata object from 1C configuration dump
|
||||
# meta-remove v1.6 — Remove metadata object from 1C configuration dump
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -493,9 +493,24 @@ if (-not $cfgNode) {
|
||||
# Save Configuration.xml
|
||||
if ($actions -gt 0 -and -not $DryRun) {
|
||||
$enc = New-Object System.Text.UTF8Encoding $true
|
||||
$sw = New-Object System.IO.StreamWriter($configXml, $false, $enc)
|
||||
$xmlDoc.Save($sw)
|
||||
$sw.Close()
|
||||
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки —
|
||||
# XmlWriter отдаёт `encoding="utf-8"` и `<a />`, Конфигуратор пишет
|
||||
# `encoding="UTF-8"` и `<a/>`.
|
||||
$settings = New-Object System.Xml.XmlWriterSettings
|
||||
$settings.Encoding = $enc
|
||||
$settings.Indent = $false
|
||||
$memStream = New-Object System.IO.MemoryStream
|
||||
$writer = [System.Xml.XmlWriter]::Create($memStream, $settings)
|
||||
$xmlDoc.Save($writer)
|
||||
$writer.Flush(); $writer.Close()
|
||||
|
||||
$xmlText = [System.Text.Encoding]::UTF8.GetString($memStream.ToArray())
|
||||
$memStream.Close()
|
||||
if ($xmlText.Length -gt 0 -and $xmlText[0] -eq [char]0xFEFF) { $xmlText = $xmlText.Substring(1) }
|
||||
$xmlText = $xmlText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||
# Гард на CDATA/комментарии: только там ` />` может быть содержимым.
|
||||
if ($xmlText -notmatch '<!\[CDATA\[|<!--') { $xmlText = [regex]::Replace($xmlText, '(?<=\S) />', '/>') }
|
||||
[System.IO.File]::WriteAllText($configXml, $xmlText, $enc)
|
||||
Write-Host "[OK] Configuration.xml saved"
|
||||
}
|
||||
}
|
||||
@@ -559,9 +574,23 @@ function Remove-FromSubsystems {
|
||||
|
||||
if ($modified -and -not $DryRun) {
|
||||
$enc = New-Object System.Text.UTF8Encoding $true
|
||||
$sw = New-Object System.IO.StreamWriter($xmlFile.FullName, $false, $enc)
|
||||
$ssDoc.Save($sw)
|
||||
$sw.Close()
|
||||
# Через MemoryStream: нужен шаг пост-обработки строки — XmlWriter отдаёт
|
||||
# `encoding="utf-8"` и `<a />`, Конфигуратор пишет `encoding="UTF-8"` и `<a/>`.
|
||||
$settings = New-Object System.Xml.XmlWriterSettings
|
||||
$settings.Encoding = $enc
|
||||
$settings.Indent = $false
|
||||
$memStream = New-Object System.IO.MemoryStream
|
||||
$writer = [System.Xml.XmlWriter]::Create($memStream, $settings)
|
||||
$ssDoc.Save($writer)
|
||||
$writer.Flush(); $writer.Close()
|
||||
|
||||
$xmlText = [System.Text.Encoding]::UTF8.GetString($memStream.ToArray())
|
||||
$memStream.Close()
|
||||
if ($xmlText.Length -gt 0 -and $xmlText[0] -eq [char]0xFEFF) { $xmlText = $xmlText.Substring(1) }
|
||||
$xmlText = $xmlText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||
# Гард на CDATA/комментарии: только там ` />` может быть содержимым.
|
||||
if ($xmlText -notmatch '<!\[CDATA\[|<!--') { $xmlText = [regex]::Replace($xmlText, '(?<=\S) />', '/>') }
|
||||
[System.IO.File]::WriteAllText($xmlFile.FullName, $xmlText, $enc)
|
||||
}
|
||||
|
||||
# Recurse into child subsystems
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# meta-remove v1.5 — Remove metadata object from 1C configuration dump
|
||||
# meta-remove v1.6 — Remove metadata object from 1C configuration dump
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
|
||||
import argparse
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# role-compile v1.10 — Compile 1C role from JSON
|
||||
# role-compile v1.11 — Compile 1C role from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -856,11 +856,21 @@ if (Test-Path $configXmlPath) {
|
||||
$cfgSettings = New-Object System.Xml.XmlWriterSettings
|
||||
$cfgSettings.Encoding = New-Object System.Text.UTF8Encoding($true)
|
||||
$cfgSettings.Indent = $false
|
||||
$stream = New-Object System.IO.FileStream($configXmlPath, [System.IO.FileMode]::Create)
|
||||
$writer = [System.Xml.XmlWriter]::Create($stream, $cfgSettings)
|
||||
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки —
|
||||
# XmlWriter отдаёт `encoding="utf-8"` и `<a />`, Конфигуратор пишет
|
||||
# `encoding="UTF-8"` и `<a/>`.
|
||||
$memStream = New-Object System.IO.MemoryStream
|
||||
$writer = [System.Xml.XmlWriter]::Create($memStream, $cfgSettings)
|
||||
$configDoc.Save($writer)
|
||||
$writer.Close()
|
||||
$stream.Close()
|
||||
$writer.Flush(); $writer.Close()
|
||||
|
||||
$cfgText = [System.Text.Encoding]::UTF8.GetString($memStream.ToArray())
|
||||
$memStream.Close()
|
||||
if ($cfgText.Length -gt 0 -and $cfgText[0] -eq [char]0xFEFF) { $cfgText = $cfgText.Substring(1) }
|
||||
$cfgText = $cfgText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||
# Гард на CDATA/комментарии: только там ` />` может быть содержимым.
|
||||
if ($cfgText -notmatch '<!\[CDATA\[|<!--') { $cfgText = [regex]::Replace($cfgText, '(?<=\S) />', '/>') }
|
||||
[System.IO.File]::WriteAllText($configXmlPath, $cfgText, (New-Object System.Text.UTF8Encoding($true)))
|
||||
|
||||
$regResult = "added"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# role-compile v1.10 — Compile 1C role from JSON
|
||||
# role-compile v1.11 — Compile 1C role from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import json
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# subsystem-compile v1.11 — Create 1C subsystem from JSON definition
|
||||
# subsystem-compile v1.12 — Create 1C subsystem from JSON definition
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$DefinitionFile,
|
||||
@@ -657,6 +657,9 @@ if ($parentXmlPath -and (Test-Path $parentXmlPath)) {
|
||||
$text = [System.Text.Encoding]::UTF8.GetString($bytes)
|
||||
if ($text.Length -gt 0 -and $text[0] -eq [char]0xFEFF) { $text = $text.Substring(1) }
|
||||
$text = $text.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||
# Пустой элемент: XmlWriter пишет `<a />`, Конфигуратор — `<a/>`. Гард на CDATA/комментарии:
|
||||
# только там `>` не экранируется, и ` />` может быть содержимым, а не концом тега.
|
||||
if ($text -notmatch '<!\[CDATA\[|<!--') { $text = [regex]::Replace($text, '(?<=\S) />', '/>') }
|
||||
[System.IO.File]::WriteAllText($parentXmlPath, $text, $utf8Bom)
|
||||
|
||||
Write-Host "[OK] Registered in: $parentXmlPath"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# subsystem-compile v1.11 — Create 1C subsystem from JSON definition
|
||||
# subsystem-compile v1.12 — Create 1C subsystem from JSON definition
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import json
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# subsystem-edit v1.8 — Edit existing 1C subsystem XML
|
||||
# subsystem-edit v1.9 — Edit existing 1C subsystem XML
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)][Alias('Path')][string]$SubsystemPath,
|
||||
@@ -655,6 +655,9 @@ $memStream.Close()
|
||||
$text = [System.Text.Encoding]::UTF8.GetString($bytes)
|
||||
if ($text.Length -gt 0 -and $text[0] -eq [char]0xFEFF) { $text = $text.Substring(1) }
|
||||
$text = $text.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||
# Пустой элемент: XmlWriter пишет `<a />`, Конфигуратор — `<a/>`. Гард на CDATA/комментарии:
|
||||
# только там `>` не экранируется, и ` />` может быть содержимым, а не концом тега.
|
||||
if ($text -notmatch '<!\[CDATA\[|<!--') { $text = [regex]::Replace($text, '(?<=\S) />', '/>') }
|
||||
|
||||
$utf8Bom = New-Object System.Text.UTF8Encoding($true)
|
||||
[System.IO.File]::WriteAllText($resolvedPath, $text, $utf8Bom)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# subsystem-edit v1.8 — Edit existing 1C subsystem XML
|
||||
# subsystem-edit v1.9 — Edit existing 1C subsystem XML
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
|
||||
import argparse
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# template-add v1.11 — Add template to 1C object
|
||||
# template-add v1.12 — Add template to 1C object
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -392,11 +392,20 @@ $settings = New-Object System.Xml.XmlWriterSettings
|
||||
$settings.Encoding = $encBom
|
||||
$settings.Indent = $false
|
||||
|
||||
$stream = New-Object System.IO.FileStream($rootXmlFull.Path, [System.IO.FileMode]::Create)
|
||||
$writer = [System.Xml.XmlWriter]::Create($stream, $settings)
|
||||
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки — XmlWriter
|
||||
# отдаёт `encoding="utf-8"` и `<a />`, Конфигуратор пишет `encoding="UTF-8"` и `<a/>`.
|
||||
$memStream = New-Object System.IO.MemoryStream
|
||||
$writer = [System.Xml.XmlWriter]::Create($memStream, $settings)
|
||||
$xmlDoc.Save($writer)
|
||||
$writer.Close()
|
||||
$stream.Close()
|
||||
$writer.Flush(); $writer.Close()
|
||||
|
||||
$xmlText = [System.Text.Encoding]::UTF8.GetString($memStream.ToArray())
|
||||
$memStream.Close()
|
||||
if ($xmlText.Length -gt 0 -and $xmlText[0] -eq [char]0xFEFF) { $xmlText = $xmlText.Substring(1) }
|
||||
$xmlText = $xmlText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||
# Гард на CDATA/комментарии: только там `>` не экранируется, и ` />` может быть содержимым.
|
||||
if ($xmlText -notmatch '<!\[CDATA\[|<!--') { $xmlText = [regex]::Replace($xmlText, '(?<=\S) />', '/>') }
|
||||
[System.IO.File]::WriteAllText($rootXmlFull.Path, $xmlText, $encBom)
|
||||
|
||||
Write-Host "[OK] Создан макет: $TemplateName ($TemplateType)"
|
||||
if ($alreadyRegistered) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# add-template v1.11 — Add template to 1C object
|
||||
# add-template v1.12 — Add template to 1C object
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
|
||||
import argparse
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# template-remove v1.3 — Remove template from 1C object
|
||||
# template-remove v1.4 — Remove template from 1C object
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -81,10 +81,19 @@ $settings = New-Object System.Xml.XmlWriterSettings
|
||||
$settings.Encoding = $encBom
|
||||
$settings.Indent = $false
|
||||
|
||||
$stream = New-Object System.IO.FileStream($rootXmlFull.Path, [System.IO.FileMode]::Create)
|
||||
$writer = [System.Xml.XmlWriter]::Create($stream, $settings)
|
||||
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки — XmlWriter
|
||||
# отдаёт `encoding="utf-8"` и `<a />`, Конфигуратор пишет `encoding="UTF-8"` и `<a/>`.
|
||||
$memStream = New-Object System.IO.MemoryStream
|
||||
$writer = [System.Xml.XmlWriter]::Create($memStream, $settings)
|
||||
$xmlDoc.Save($writer)
|
||||
$writer.Close()
|
||||
$stream.Close()
|
||||
$writer.Flush(); $writer.Close()
|
||||
|
||||
$xmlText = [System.Text.Encoding]::UTF8.GetString($memStream.ToArray())
|
||||
$memStream.Close()
|
||||
if ($xmlText.Length -gt 0 -and $xmlText[0] -eq [char]0xFEFF) { $xmlText = $xmlText.Substring(1) }
|
||||
$xmlText = $xmlText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||
# Гард на CDATA/комментарии: только там `>` не экранируется, и ` />` может быть содержимым.
|
||||
if ($xmlText -notmatch '<!\[CDATA\[|<!--') { $xmlText = [regex]::Replace($xmlText, '(?<=\S) />', '/>') }
|
||||
[System.IO.File]::WriteAllText($rootXmlFull.Path, $xmlText, $encBom)
|
||||
|
||||
Write-Host "[OK] Макет $TemplateName удалён из $rootXmlPath"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# remove-template v1.3 — Remove template from 1C object
|
||||
# remove-template v1.4 — Remove template from 1C object
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
|
||||
import argparse
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# xdto-compile v1.2 — Build a 1C XDTO package from an XML Schema (XSD)
|
||||
# xdto-compile v1.3 — Build a 1C XDTO package from an XML Schema (XSD)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory=$true, ParameterSetName='File')]
|
||||
@@ -948,11 +948,21 @@ if (Test-Path $configXmlPath) {
|
||||
$cfgSettings = New-Object System.Xml.XmlWriterSettings
|
||||
$cfgSettings.Encoding = New-Object System.Text.UTF8Encoding($true)
|
||||
$cfgSettings.Indent = $false
|
||||
$stream = New-Object System.IO.FileStream($configXmlPath, [System.IO.FileMode]::Create)
|
||||
$writer = [System.Xml.XmlWriter]::Create($stream, $cfgSettings)
|
||||
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки —
|
||||
# XmlWriter отдаёт `encoding="utf-8"` и `<a />`, Конфигуратор пишет
|
||||
# `encoding="UTF-8"` и `<a/>`.
|
||||
$memStream = New-Object System.IO.MemoryStream
|
||||
$writer = [System.Xml.XmlWriter]::Create($memStream, $cfgSettings)
|
||||
$configDoc.Save($writer)
|
||||
$writer.Close()
|
||||
$stream.Close()
|
||||
$writer.Flush(); $writer.Close()
|
||||
|
||||
$cfgText = [System.Text.Encoding]::UTF8.GetString($memStream.ToArray())
|
||||
$memStream.Close()
|
||||
if ($cfgText.Length -gt 0 -and $cfgText[0] -eq [char]0xFEFF) { $cfgText = $cfgText.Substring(1) }
|
||||
$cfgText = $cfgText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||
# Гард на CDATA/комментарии: только там ` />` может быть содержимым.
|
||||
if ($cfgText -notmatch '<!\[CDATA\[|<!--') { $cfgText = [regex]::Replace($cfgText, '(?<=\S) />', '/>') }
|
||||
[System.IO.File]::WriteAllText($configXmlPath, $cfgText, (New-Object System.Text.UTF8Encoding($true)))
|
||||
$regResult = "added"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# xdto-compile v1.2 — Build a 1C XDTO package from an XML Schema (XSD) (Python port)
|
||||
# xdto-compile v1.3 — Build a 1C XDTO package from an XML Schema (XSD) (Python port)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import json
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# xdto-edit v1.0 — Point edits of a 1C XDTO package
|
||||
# xdto-edit v1.1 — Point edits of a 1C XDTO package
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory=$true)]
|
||||
@@ -221,10 +221,21 @@ function Edit-Metadata([string]$field, [string]$newValue) {
|
||||
$settings = New-Object System.Xml.XmlWriterSettings
|
||||
$settings.Encoding = $encBom
|
||||
$settings.Indent = $false
|
||||
$stream = New-Object System.IO.FileStream($mdFile, [System.IO.FileMode]::Create)
|
||||
$writer = [System.Xml.XmlWriter]::Create($stream, $settings)
|
||||
# Через MemoryStream, а не прямо в файл: нужен шаг пост-обработки строки —
|
||||
# XmlWriter отдаёт `encoding="utf-8"` и `<a />`, Конфигуратор пишет
|
||||
# `encoding="UTF-8"` и `<a/>`.
|
||||
$memStream = New-Object System.IO.MemoryStream
|
||||
$writer = [System.Xml.XmlWriter]::Create($memStream, $settings)
|
||||
$doc.Save($writer)
|
||||
$writer.Close(); $stream.Close()
|
||||
$writer.Flush(); $writer.Close()
|
||||
|
||||
$mdText = [System.Text.Encoding]::UTF8.GetString($memStream.ToArray())
|
||||
$memStream.Close()
|
||||
if ($mdText.Length -gt 0 -and $mdText[0] -eq [char]0xFEFF) { $mdText = $mdText.Substring(1) }
|
||||
$mdText = $mdText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||
# Гард на CDATA/комментарии: только там ` />` может быть содержимым.
|
||||
if ($mdText -notmatch '<!\[CDATA\[|<!--') { $mdText = [regex]::Replace($mdText, '(?<=\S) />', '/>') }
|
||||
[System.IO.File]::WriteAllText($mdFile, $mdText, $encBom)
|
||||
}
|
||||
|
||||
function Rename-Package([string]$newName) {
|
||||
@@ -252,9 +263,18 @@ function Rename-Package([string]$newName) {
|
||||
if ($found) {
|
||||
$s = New-Object System.Xml.XmlWriterSettings
|
||||
$s.Encoding = $encBom; $s.Indent = $false
|
||||
$st = New-Object System.IO.FileStream($configXml, [System.IO.FileMode]::Create)
|
||||
$w = [System.Xml.XmlWriter]::Create($st, $s)
|
||||
$cfg.Save($w); $w.Close(); $st.Close()
|
||||
# Через MemoryStream: нужен шаг пост-обработки строки — XmlWriter отдаёт
|
||||
# `encoding="utf-8"` и `<a />`, Конфигуратор пишет `encoding="UTF-8"` и `<a/>`.
|
||||
$mem = New-Object System.IO.MemoryStream
|
||||
$w = [System.Xml.XmlWriter]::Create($mem, $s)
|
||||
$cfg.Save($w); $w.Flush(); $w.Close()
|
||||
$cfgText = [System.Text.Encoding]::UTF8.GetString($mem.ToArray())
|
||||
$mem.Close()
|
||||
if ($cfgText.Length -gt 0 -and $cfgText[0] -eq [char]0xFEFF) { $cfgText = $cfgText.Substring(1) }
|
||||
$cfgText = $cfgText.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||
# Гард на CDATA/комментарии: только там ` />` может быть содержимым.
|
||||
if ($cfgText -notmatch '<!\[CDATA\[|<!--') { $cfgText = [regex]::Replace($cfgText, '(?<=\S) />', '/>') }
|
||||
[System.IO.File]::WriteAllText($configXml, $cfgText, $encBom)
|
||||
Write-Host " Configuration.xml: <XDTOPackage> переименован в $newName"
|
||||
} else {
|
||||
Write-Warning "В Configuration.xml не найдена запись <XDTOPackage>$pkgName</XDTOPackage> — зарегистрируйте пакет вручную"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# xdto-edit v1.0 — Point edits of a 1C XDTO package (Python port)
|
||||
# xdto-edit v1.1 — Point edits of a 1C XDTO package (Python port)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import json
|
||||
|
||||
Reference in New Issue
Block a user