roblox-ts-template/scripts/setup.ps1

74 lines
2.7 KiB
PowerShell

#Requires -Version 5.1
[CmdletBinding()]
param(
[switch]$DryRun,
[switch]$SkipChecks
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
$projectRoot = Split-Path -Parent $PSScriptRoot
function Invoke-Tool {
param([string]$Name, [string[]]$Arguments)
Write-Host "> $Name $($Arguments -join ' ')"
if ($DryRun) { return }
& $Name @Arguments
if ($LASTEXITCODE -ne 0) {
throw "$Name a echoue (code $LASTEXITCODE). Corriger l'erreur puis relancer le script."
}
}
function Update-SessionPath {
$machinePath = [Environment]::GetEnvironmentVariable('Path', 'Machine')
$userPath = [Environment]::GetEnvironmentVariable('Path', 'User')
$env:Path = "$machinePath;$userPath;$env:Path;$env:USERPROFILE\.rokit\bin"
}
function Install-Package {
param([string]$Id)
if (-not $DryRun) {
& winget list --id $Id --exact --source winget --accept-source-agreements --disable-interactivity
if ($LASTEXITCODE -eq 0) {
Write-Host "$Id est deja installe."
return
}
# APP_NOT_INSTALLED: other errors must not be mistaken for a missing package.
if ($LASTEXITCODE -ne -1978335212) {
throw "Impossible de verifier $Id avec winget (code $LASTEXITCODE)."
}
}
Invoke-Tool 'winget' @('install', '--id', $Id, '--exact', '--source', 'winget', '--silent', '--accept-package-agreements', '--accept-source-agreements', '--disable-interactivity')
if (-not $DryRun) { Update-SessionPath }
}
Push-Location $projectRoot
try {
if (-not $DryRun -and -not (Get-Command winget -ErrorAction SilentlyContinue)) {
throw "Installer App Installer (winget) depuis le Microsoft Store, puis relancer ce script."
}
foreach ($package in @('Git.Git', 'jdx.mise', 'Rojo.Rokit', 'Roblox.RobloxStudio', 'BlenderFoundation.Blender')) {
Install-Package $package
}
Invoke-Tool 'mise' @('trust', 'mise.toml')
Invoke-Tool 'mise' @('install')
Invoke-Tool 'rokit' @('install')
Invoke-Tool 'mise' @('exec', '--', 'pnpm', 'install', '--frozen-lockfile')
if (-not $SkipChecks) {
Invoke-Tool 'mise' @('exec', '--', 'pnpm', 'check')
Invoke-Tool 'mise' @('exec', '--', 'pnpm', 'build')
}
if ($DryRun) {
Write-Host 'Apercu termine : aucune installation effectuee.'
} else {
Write-Host 'Installation terminee. Rouvrir le terminal et les clients MCP.'
Write-Host 'Pour les commandes pnpm/uvx, utiliser mise exec -- <commande> ou activer mise dans le shell.'
Write-Host 'Activer le MCP dans Studio et installer/activer l extension MCP officielle dans Blender (voir README).'
}
} finally {
Pop-Location
}