еще правки

This commit is contained in:
gorbenko.pavel
2026-07-28 17:58:46 +05:00
parent b0280281fb
commit 9cb5080bf9
6 changed files with 66 additions and 17 deletions
+25 -7
View File
@@ -14,6 +14,24 @@ $ErrorActionPreference = "Stop"
# на современных Node (node-gyp 3.8 требует Python 2).
$SpfxVersion = "1.22.1"
# ---- Запись файлов ----
# ВАЖНО: "Set-Content -Encoding UTF8" в Windows PowerShell 5.1 пишет UTF-8 С BOM.
# Heft, tsc и node на BOM в .json/.js спотыкаются:
# Unexpected token '<U+FEFF>', "<U+FEFF>{ ..." is not valid JSON
# Поэтому все конфиги пишем строго UTF-8 без BOM.
function Write-Utf8NoBom {
param(
[Parameter(Mandatory = $true)][string]$Path,
[Parameter(Mandatory = $true)][string]$Content
)
$full = [System.IO.Path]::Combine((Get-Location).ProviderPath, $Path)
$dir = [System.IO.Path]::GetDirectoryName($full)
if ($dir -and -not (Test-Path $dir)) {
New-Item -ItemType Directory -Force -Path $dir | Out-Null
}
[System.IO.File]::WriteAllText($full, ($Content -replace "`r?`n", "`r`n"), (New-Object System.Text.UTF8Encoding($false)))
}
# ---- Цвета вывода ----
function Info { param($msg) Write-Host "[INFO] $msg" -ForegroundColor Cyan }
function Success { param($msg) Write-Host "[OK] $msg" -ForegroundColor Green }
@@ -152,7 +170,7 @@ $packageJson = @'
}
'@
$packageJson | Set-Content -Encoding UTF8 "package.json"
Write-Utf8NoBom "package.json" $packageJson
Success "package.json создан."
# ---------------------------------------------------------
@@ -237,7 +255,7 @@ $rigJson = @'
}
'@
$rigJson | Set-Content -Encoding UTF8 "config\rig.json"
Write-Utf8NoBom "config\rig.json" $rigJson
Success "config\rig.json создан."
# ---------------------------------------------------------
@@ -253,7 +271,7 @@ $sassJson = @'
}
'@
$sassJson | Set-Content -Encoding UTF8 "config\sass.json"
Write-Utf8NoBom "config\sass.json" $sassJson
Success "config\sass.json создан."
# ---------------------------------------------------------
@@ -272,7 +290,7 @@ $typescriptJson = @'
}
'@
$typescriptJson | Set-Content -Encoding UTF8 "config\typescript.json"
Write-Utf8NoBom "config\typescript.json" $typescriptJson
Success "config\typescript.json создан."
# ---------------------------------------------------------
@@ -287,7 +305,7 @@ if (-not (Test-Path "tsconfig.json")) {
}
'@
$tsConfig | Set-Content -Encoding UTF8 "tsconfig.json"
Write-Utf8NoBom "tsconfig.json" $tsConfig
Success "tsconfig.json создан."
} else {
Success "tsconfig.json уже существует, пропускаем."
@@ -308,7 +326,7 @@ module.exports = {
};
'@
$eslintConfig | Set-Content -Encoding UTF8 ".eslintrc.js"
Write-Utf8NoBom ".eslintrc.js" $eslintConfig
Success ".eslintrc.js создан."
} else {
Success ".eslintrc.js уже существует, пропускаем."
@@ -329,7 +347,7 @@ temp/
sharepoint/solution/
'@
$gitignore | Set-Content -Encoding UTF8 ".gitignore"
Write-Utf8NoBom ".gitignore" $gitignore
Success ".gitignore создан."
# ---------------------------------------------------------