# cf-init v1.2 — Create empty 1C configuration scaffold # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [Parameter(Mandatory)] [string]$Name, [string]$Synonym = $Name, [string]$OutputDir = "src", [string]$Version, [string]$Vendor, [string]$CompatibilityMode = "Version8_3_24" ) $ErrorActionPreference = "Stop" [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 # --- Resolve output dir --- if (-not [System.IO.Path]::IsPathRooted($OutputDir)) { $OutputDir = Join-Path (Get-Location).Path $OutputDir } # --- Check existing --- $cfgFile = Join-Path $OutputDir "Configuration.xml" if (Test-Path $cfgFile) { Write-Error "Configuration.xml already exists: $cfgFile" exit 1 } # --- Generate UUIDs --- $uuidCfg = [guid]::NewGuid().ToString() $uuidLang = [guid]::NewGuid().ToString() # 7 ContainedObject ObjectIds $co1 = [guid]::NewGuid().ToString() $co2 = [guid]::NewGuid().ToString() $co3 = [guid]::NewGuid().ToString() $co4 = [guid]::NewGuid().ToString() $co5 = [guid]::NewGuid().ToString() $co6 = [guid]::NewGuid().ToString() $co7 = [guid]::NewGuid().ToString() # --- Mobile functionalities --- $mobileFuncs = @( @("Biometrics","true"), @("Location","false"), @("BackgroundLocation","false"), @("BluetoothPrinters","false"), @("WiFiPrinters","false"), @("Contacts","false"), @("Calendars","false"), @("PushNotifications","false"), @("LocalNotifications","false"), @("InAppPurchases","false"), @("PersonalComputerFileExchange","false"), @("Ads","false"), @("NumberDialing","false"), @("CallProcessing","false"), @("CallLog","false"), @("AutoSendSMS","false"), @("ReceiveSMS","false"), @("SMSLog","false"), @("Camera","false"), @("Microphone","false"), @("MusicLibrary","false"), @("PictureAndVideoLibraries","false"), @("AudioPlaybackAndVibration","false"), @("BackgroundAudioPlaybackAndVibration","false"), @("InstallPackages","false"), @("OSBackup","true"), @("ApplicationUsageStatistics","false"), @("BarcodeScanning","false"), @("BackgroundAudioRecording","false"), @("AllFilesAccess","false"), @("Videoconferences","false"), @("NFC","false"), @("DocumentScanning","false"), @("SpeechToText","false"), @("Geofences","false"), @("IncomingShareRequests","false"), @("AllIncomingShareRequestsTypesProcessing","false") ) $mobileXml = "" foreach ($mf in $mobileFuncs) { $mobileXml += "`r`n`t`t`t`t`r`n`t`t`t`t`t$($mf[0])`r`n`t`t`t`t`t$($mf[1])`r`n`t`t`t`t" } # --- Synonym XML --- $synonymXml = "" if ($Synonym) { $synonymXml = "`r`n`t`t`t`t`r`n`t`t`t`t`tru`r`n`t`t`t`t`t$([System.Security.SecurityElement]::Escape($Synonym))`r`n`t`t`t`t`r`n`t`t`t" } # --- Optional properties --- $vendorXml = if ($Vendor) { [System.Security.SecurityElement]::Escape($Vendor) } else { "" } $versionXml = if ($Version) { [System.Security.SecurityElement]::Escape($Version) } else { "" } # --- Configuration.xml --- $cfgXml = @" 9cd510cd-abfc-11d4-9434-004095e12fc7 $co1 9fcd25a0-4822-11d4-9414-008048da11f9 $co2 e3687481-0a87-462c-a166-9f34594f9bba $co3 9de14907-ec23-4a07-96f0-85521cb6b53b $co4 51f2d5d8-ea4d-4064-8892-82951750031e $co5 e68182ea-4237-4383-967f-90c1e3370bc7 $co6 fb282519-d103-4dd3-bc12-cb271d631dfc $co7 $([System.Security.SecurityElement]::Escape($Name)) $synonymXml $CompatibilityMode ManagedApplication PlatformApplication Russian $vendorXml $versionXml false false false $mobileXml Normal Language.Русский Managed NotAutoFree DontUse DontUse TaxiEnableVersion8_2 DontUse $CompatibilityMode Русский "@ # --- Languages/Русский.xml --- $langXml = @" Русский ru Русский ru "@ # --- Ext/ClientApplicationInterface.xml (default ERP-style panel layout) --- # Open panel on top, Sections panel on left; Functions/Favorites/History declared # via panelDef but not placed by default. Without this file the web client renders # section icons without labels (icon-only mode). $openPanelInst = [guid]::NewGuid().ToString() $sectionsPanelInst = [guid]::NewGuid().ToString() $caiXml = @" cbab57f2-a0f3-4f0a-89ea-4cb19570ab75 b553047f-c9aa-4157-978d-448ecad24248 "@ # --- Create directories --- if (-not (Test-Path $OutputDir)) { New-Item -ItemType Directory -Path $OutputDir -Force | Out-Null } $langDir = Join-Path $OutputDir "Languages" if (-not (Test-Path $langDir)) { New-Item -ItemType Directory -Path $langDir -Force | Out-Null } $extDir = Join-Path $OutputDir "Ext" if (-not (Test-Path $extDir)) { New-Item -ItemType Directory -Path $extDir -Force | Out-Null } # --- Write files with UTF-8 BOM --- $enc = New-Object System.Text.UTF8Encoding($true) [System.IO.File]::WriteAllText($cfgFile, $cfgXml, $enc) $langFile = Join-Path $langDir "Русский.xml" [System.IO.File]::WriteAllText($langFile, $langXml, $enc) $caiFile = Join-Path $extDir "ClientApplicationInterface.xml" [System.IO.File]::WriteAllText($caiFile, $caiXml, $enc) # --- Output --- Write-Host "[OK] Создана конфигурация: $Name" Write-Host " Каталог: $OutputDir" Write-Host " Configuration.xml: $cfgFile" Write-Host " Languages: $langFile" Write-Host " Ext/CAI: $caiFile"