install.ps1: backup старого CursorRules, fix вызова init-cursor.

This commit is contained in:
2026-06-19 23:33:53 +10:00
parent 12dd597360
commit 25f4d5972e
+24 -9
View File
@@ -3,18 +3,14 @@
.SYNOPSIS
Первая загрузка Rules и запуск init-cursor в текущем проекте.
.DESCRIPTION
Репозиторий приватный — irm .../raw/.../install.ps1 без логина вернёт 404.
Запускайте этот файл после clone или однострочник из README.
.EXAMPLE
git clone --depth 1 ssh://git@git.kalinamall.ru:2222/PapaTramp/Rules.git $HOME\CursorRules
& $HOME\CursorRules\install.ps1
#>
[CmdletBinding()]
param(
[Parameter(ValueFromRemainingArguments = $true)]
[object[]]$InitCursorArgs
[switch]$SkipGitRemotes,
[switch]$Update
)
Set-StrictMode -Version Latest
@@ -24,9 +20,17 @@ $rulesDest = Join-Path $HOME 'CursorRules'
$httpsUrl = 'https://git.kalinamall.ru/PapaTramp/Rules.git'
$sshUrl = 'ssh://git@git.kalinamall.ru:2222/PapaTramp/Rules.git'
if (-not (Test-Path (Join-Path $rulesDest '.git'))) {
function Ensure-RulesClone {
if (Test-Path (Join-Path $rulesDest '.git')) {
Write-Host '[*] Updating CursorRules...' -ForegroundColor Cyan
git -C $rulesDest pull --ff-only
return
}
if (Test-Path -LiteralPath $rulesDest) {
throw "Path exists and is not a git repo: $rulesDest"
$backup = "${rulesDest}.bak-$(Get-Date -Format 'yyyyMMdd-HHmmss')"
Write-Host "[!] Replacing non-git folder: $rulesDest -> $backup" -ForegroundColor Yellow
Move-Item -LiteralPath $rulesDest -Destination $backup
}
Write-Host '[*] Cloning Rules via SSH...' -ForegroundColor Cyan
@@ -41,5 +45,16 @@ if (-not (Test-Path (Join-Path $rulesDest '.git'))) {
Write-Host "[+] Cloned to $rulesDest" -ForegroundColor Green
}
Ensure-RulesClone
. (Join-Path $rulesDest 'init-cursor.ps1')
init-cursor @InitCursorArgs
if ($Update) {
init-cursor -Update -SkipGitRemotes:$SkipGitRemotes
}
elseif ($SkipGitRemotes) {
init-cursor -SkipGitRemotes
}
else {
init-cursor
}