-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.ps1
More file actions
73 lines (63 loc) · 2.63 KB
/
setup.ps1
File metadata and controls
73 lines (63 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# cc-settings bootstrap for Windows — PowerShell mirror of setup.sh.
# All install logic lives in src\setup.ts. This file exists to:
# 1. Handle `iwr ... | iex` by cloning the repo if not already on disk.
# 2. Ensure Bun is installed.
# 3. exec `bun "$Repo\src\setup.ts" --source="$Repo" @Args`.
#
# Flags (forwarded to src\setup.ts):
# --rollback[=TS] restore newest backup (or a timestamp match)
# --dry-run print planned actions only
# --interactive prompt on settings.json conflicts (also: $env:CC_INTERACTIVE=1)
# --ts-hooks install with TS hook paths (also: $env:CC_USE_TS_HOOKS=1)
# --help, -h
$ErrorActionPreference = "Stop"
$RepoUrl = "https://github.com/darkroomengineering/cc-settings.git"
# --- Resolve repo dir --------------------------------------------------------
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
if (-not $ScriptDir -or -not (Test-Path $ScriptDir)) {
# Invoked via `iwr ... | iex` — clone into a temp dir.
$Clone = Join-Path $env:TEMP ("cc-settings-" + [System.Guid]::NewGuid().ToString("N"))
Write-Host "Fetching cc-settings..."
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
Write-Error "git is required for remote install. Install git or clone manually: git clone $RepoUrl"
exit 1
}
git clone --depth 1 $RepoUrl $Clone | Out-Null
& (Join-Path $Clone "setup.ps1") @Args
exit $LASTEXITCODE
}
# --- Ensure Bun --------------------------------------------------------------
function Ensure-Bun {
if (Get-Command bun -ErrorAction SilentlyContinue) { return }
Write-Host "Bun not found - installing via https://bun.sh/install..."
try {
Invoke-RestMethod bun.sh/install.ps1 | Invoke-Expression
}
catch {
Write-Error "Bun install failed. Install manually: https://bun.sh/docs/installation"
exit 1
}
# The installer adds ~/.bun/bin to PATH for future shells; add it now too.
$BunBin = Join-Path $HOME ".bun\bin"
if (Test-Path $BunBin) {
$env:PATH = "$BunBin;$env:PATH"
}
if (-not (Get-Command bun -ErrorAction SilentlyContinue)) {
Write-Error "bun install completed but 'bun' is not on PATH. Re-run from a new shell."
exit 1
}
}
Ensure-Bun
# --- Delegate to src\setup.ts ------------------------------------------------
Push-Location $ScriptDir
try {
# Idempotent dep install for the TS side.
bun install --frozen-lockfile 2>$null
if ($LASTEXITCODE -ne 0) { bun install 2>$null }
$SetupTs = Join-Path $ScriptDir "src\setup.ts"
bun $SetupTs "--source=$ScriptDir" @Args
exit $LASTEXITCODE
}
finally {
Pop-Location
}