39 lines
2.0 KiB
PowerShell
39 lines
2.0 KiB
PowerShell
[CmdletBinding()]
|
|
param()
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$source = $PSScriptRoot
|
|
$target = Join-Path $env:APPDATA "Zed"
|
|
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
|
|
$backup = Join-Path $target "backups\portable-install-$timestamp"
|
|
$utf8 = New-Object System.Text.UTF8Encoding($false)
|
|
|
|
New-Item -ItemType Directory -Force -Path $target, $backup, (Join-Path $target "scripts") | Out-Null
|
|
|
|
foreach ($name in @("settings.json", "keymap.json", "tasks.json")) {
|
|
$existing = Join-Path $target $name
|
|
if (Test-Path -LiteralPath $existing) {
|
|
Copy-Item -LiteralPath $existing -Destination (Join-Path $backup $name)
|
|
}
|
|
}
|
|
|
|
Copy-Item -LiteralPath (Join-Path $source "settings.json") -Destination (Join-Path $target "settings.json") -Force
|
|
Copy-Item -LiteralPath (Join-Path $source "keymap.json") -Destination (Join-Path $target "keymap.json") -Force
|
|
Copy-Item -LiteralPath (Join-Path $source "scripts\toggle-file-scan-exclusions.mjs") -Destination (Join-Path $target "scripts\toggle-file-scan-exclusions.mjs") -Force
|
|
Copy-Item -LiteralPath (Join-Path $source "scripts\file-exclusions.json") -Destination (Join-Path $target "scripts\file-exclusions.json") -Force
|
|
Copy-Item -LiteralPath (Join-Path $source "scripts\zed-settings-sync.mjs") -Destination (Join-Path $target "scripts\zed-settings-sync.mjs") -Force
|
|
$syncConfig = Join-Path $target "scripts\settings-sync.json"
|
|
if (-not (Test-Path -LiteralPath $syncConfig)) {
|
|
Copy-Item -LiteralPath (Join-Path $source "scripts\settings-sync.json") -Destination $syncConfig
|
|
}
|
|
|
|
$toggleScriptPath = (Join-Path $target "scripts\toggle-file-scan-exclusions.mjs").Replace("\", "/")
|
|
$syncScriptPath = (Join-Path $target "scripts\zed-settings-sync.mjs").Replace("\", "/")
|
|
$tasks = [IO.File]::ReadAllText((Join-Path $source "tasks.json"))
|
|
$tasks = $tasks.Replace("__TOGGLE_SCRIPT__", $toggleScriptPath)
|
|
$tasks = $tasks.Replace("__SYNC_SCRIPT__", $syncScriptPath)
|
|
[IO.File]::WriteAllText((Join-Path $target "tasks.json"), $tasks, $utf8)
|
|
|
|
Write-Host "Installed Zed configuration to $target"
|
|
Write-Host "Previous configuration backed up to $backup"
|