From 25f4d5972e9b0d4ce326e9c8e2af5f41d7a436a2 Mon Sep 17 00:00:00 2001 From: PTah Date: Fri, 19 Jun 2026 23:33:53 +1000 Subject: [PATCH] =?UTF-8?q?install.ps1:=20backup=20=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D1=80=D0=BE=D0=B3=D0=BE=20CursorRules,=20fix=20=D0=B2=D1=8B?= =?UTF-8?q?=D0=B7=D0=BE=D0=B2=D0=B0=20init-cursor.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.ps1 | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/install.ps1 b/install.ps1 index 47bf2ad..c501196 100644 --- a/install.ps1 +++ b/install.ps1 @@ -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 +}