install.ps1: backup старого CursorRules, fix вызова init-cursor.
This commit is contained in:
+24
-9
@@ -3,18 +3,14 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Первая загрузка Rules и запуск init-cursor в текущем проекте.
|
Первая загрузка Rules и запуск init-cursor в текущем проекте.
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
Репозиторий приватный — irm .../raw/.../install.ps1 без логина вернёт 404.
|
|
||||||
Запускайте этот файл после clone или однострочник из README.
|
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
git clone --depth 1 ssh://git@git.kalinamall.ru:2222/PapaTramp/Rules.git $HOME\CursorRules
|
git clone --depth 1 ssh://git@git.kalinamall.ru:2222/PapaTramp/Rules.git $HOME\CursorRules
|
||||||
& $HOME\CursorRules\install.ps1
|
& $HOME\CursorRules\install.ps1
|
||||||
#>
|
#>
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param(
|
param(
|
||||||
[Parameter(ValueFromRemainingArguments = $true)]
|
[switch]$SkipGitRemotes,
|
||||||
[object[]]$InitCursorArgs
|
[switch]$Update
|
||||||
)
|
)
|
||||||
|
|
||||||
Set-StrictMode -Version Latest
|
Set-StrictMode -Version Latest
|
||||||
@@ -24,9 +20,17 @@ $rulesDest = Join-Path $HOME 'CursorRules'
|
|||||||
$httpsUrl = 'https://git.kalinamall.ru/PapaTramp/Rules.git'
|
$httpsUrl = 'https://git.kalinamall.ru/PapaTramp/Rules.git'
|
||||||
$sshUrl = 'ssh://git@git.kalinamall.ru:2222/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) {
|
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
|
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
|
Write-Host "[+] Cloned to $rulesDest" -ForegroundColor Green
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ensure-RulesClone
|
||||||
|
|
||||||
. (Join-Path $rulesDest 'init-cursor.ps1')
|
. (Join-Path $rulesDest 'init-cursor.ps1')
|
||||||
init-cursor @InitCursorArgs
|
|
||||||
|
if ($Update) {
|
||||||
|
init-cursor -Update -SkipGitRemotes:$SkipGitRemotes
|
||||||
|
}
|
||||||
|
elseif ($SkipGitRemotes) {
|
||||||
|
init-cursor -SkipGitRemotes
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
init-cursor
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user