forked from langchain-ai/open-swe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-typescript.ps1
More file actions
133 lines (106 loc) Β· 5.19 KB
/
setup-typescript.ps1
File metadata and controls
133 lines (106 loc) Β· 5.19 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# TypeScript Upgrade and Installation Script for OpenSWE-Source
# Run this script in PowerShell
Write-Host "π TypeScript Setup for OpenSWE-Source" -ForegroundColor Cyan
Write-Host "=====================================" -ForegroundColor Cyan
$projectPath = "d:\local git 2025\cue-verse-beginnings\local main v1 - pre branch merge completion\Priv-cue-staging\ai-stack\openswe-source"
Set-Location $projectPath
Write-Host "π Working directory: $projectPath" -ForegroundColor Yellow
# Function to check if running as administrator
function Test-Administrator {
$currentUser = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object Security.Principal.WindowsPrincipal($currentUser)
return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
# Method selection
Write-Host "`nπ§ Choose installation method:" -ForegroundColor Green
Write-Host "1. Enable Corepack + Yarn 3.5.1 (Recommended)" -ForegroundColor White
Write-Host "2. Use NPM (Alternative)" -ForegroundColor White
Write-Host "3. Use Global Yarn 1.x (Fallback)" -ForegroundColor White
$choice = Read-Host "Enter your choice (1-3)"
switch ($choice) {
"1" {
Write-Host "`nπ Checking administrator privileges..." -ForegroundColor Yellow
if (-not (Test-Administrator)) {
Write-Host "β Administrator privileges required for corepack enable" -ForegroundColor Red
Write-Host "Please restart PowerShell as Administrator and run:" -ForegroundColor Yellow
Write-Host "corepack enable" -ForegroundColor Cyan
Write-Host "Then run this script again." -ForegroundColor Yellow
Read-Host "Press Enter to exit"
exit 1
}
Write-Host "β
Running as Administrator" -ForegroundColor Green
Write-Host "π§ Enabling corepack..." -ForegroundColor Yellow
try {
corepack enable
Write-Host "β
Corepack enabled successfully" -ForegroundColor Green
Write-Host "π¦ Installing dependencies with Yarn 3.5.1..." -ForegroundColor Yellow
yarn install
Write-Host "π¨ Building project..." -ForegroundColor Yellow
yarn build
Write-Host "β
TypeScript setup complete!" -ForegroundColor Green
}
catch {
Write-Host "β Error with corepack setup: $_" -ForegroundColor Red
Write-Host "Falling back to NPM method..." -ForegroundColor Yellow
& $MyInvocation.MyCommand.Path "2"
}
}
"2" {
Write-Host "`nπ¦ Using NPM installation method..." -ForegroundColor Yellow
# Remove yarn-specific files if they exist
if (Test-Path "yarn.lock") {
Write-Host "ποΈ Removing yarn.lock..." -ForegroundColor Yellow
Remove-Item "yarn.lock" -Force
}
Write-Host "π₯ Installing dependencies with NPM..." -ForegroundColor Yellow
npm install --legacy-peer-deps
Write-Host "π¨ Building project..." -ForegroundColor Yellow
npm run build
Write-Host "β
TypeScript setup complete with NPM!" -ForegroundColor Green
}
"3" {
Write-Host "`nπ¦ Using global Yarn 1.x..." -ForegroundColor Yellow
# Check if yarn is installed globally
try {
$yarnVersion = yarn --version
Write-Host "π Global Yarn version: $yarnVersion" -ForegroundColor Yellow
}
catch {
Write-Host "β Yarn not found. Installing globally..." -ForegroundColor Red
npm install -g yarn
}
Write-Host "π₯ Installing dependencies with global Yarn..." -ForegroundColor Yellow
yarn install
Write-Host "π¨ Building project..." -ForegroundColor Yellow
yarn build
Write-Host "β
TypeScript setup complete with Yarn!" -ForegroundColor Green
}
default {
Write-Host "β Invalid choice. Please run the script again." -ForegroundColor Red
exit 1
}
}
# Verify installation
Write-Host "`nπ Verifying TypeScript installation..." -ForegroundColor Yellow
try {
if ($choice -eq "2") {
$tsVersion = npx tsc --version
} else {
$tsVersion = yarn tsc --version
}
Write-Host "β
TypeScript version: $tsVersion" -ForegroundColor Green
}
catch {
Write-Host "β οΈ Could not verify TypeScript installation" -ForegroundColor Yellow
}
Write-Host "`nπ Setup complete! Your OpenSWE-Source project now has:" -ForegroundColor Green
Write-Host " β’ TypeScript 5.9.2 (latest stable)" -ForegroundColor White
Write-Host " β’ Modern ES2021+ configuration" -ForegroundColor White
Write-Host " β’ Strict type checking enabled" -ForegroundColor White
Write-Host " β’ All packages updated" -ForegroundColor White
Write-Host "`nπ Next steps:" -ForegroundColor Cyan
Write-Host " β’ Run development server: yarn dev" -ForegroundColor White
Write-Host " β’ Type check: yarn lint" -ForegroundColor White
Write-Host " β’ Format code: yarn format" -ForegroundColor White
Write-Host " β’ Run tests: yarn test" -ForegroundColor White
Read-Host "`nPress Enter to exit"