# Veci CLI — instalador para Windows (PowerShell). Sin permisos de administrador. # # irm https://ia.vecipp.com/install.ps1 | iex # # Si no tienes Node.js 20+, se instala uno propio en %LOCALAPPDATA%\Veci\node (no toca el del sistema). # Variables opcionales: $env:VECI_VERSION='1.2.3' · $env:VECI_SIN_OPCIONALES='1' · $env:VECI_BASE (pruebas). & { $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 $Base = if ($env:VECI_BASE) { $env:VECI_BASE } else { 'https://ia.vecipp.com' } $Datos = Join-Path $env:LOCALAPPDATA 'Veci' $NodeDir = Join-Path $Datos 'node' function Say([string]$m) { Write-Host ([char]0x273B + ' Veci ') -ForegroundColor Blue -NoNewline; Write-Host $m } function NodeOk { try { return [int]((& node --version).TrimStart('v').Split('.')[0]) -ge 20 } catch { return $false } } function AlPath([string]$dir) { $usuario = [Environment]::GetEnvironmentVariable('Path', 'User') if (-not (($usuario -split ';') -contains $dir)) { [Environment]::SetEnvironmentVariable('Path', ($(if ($usuario) { "$usuario;$dir" } else { $dir })), 'User') } if (-not (($env:Path -split ';') -contains $dir)) { $env:Path = "$dir;$env:Path" } } # el Node.js propio de la instalación de antes sirve igual: se usa mientras no haya uno nuevo $Viejo = Join-Path (Join-Path $env:LOCALAPPDATA 'Vecipp') 'node' if (Test-Path (Join-Path $NodeDir 'node.exe')) { AlPath $NodeDir } elseif (Test-Path (Join-Path $Viejo 'node.exe')) { AlPath $Viejo } if (-not (NodeOk)) { $arq = if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { 'arm64' } else { 'x64' } Say 'Instalando Node.js 22 para tu usuario…' $tmp = Join-Path ([IO.Path]::GetTempPath()) ('veci-' + [guid]::NewGuid()) New-Item -ItemType Directory -Path $tmp | Out-Null $sumas = (Invoke-WebRequest -UseBasicParsing 'https://nodejs.org/dist/latest-v22.x/SHASUMS256.txt').Content if ($sumas -is [byte[]]) { $sumas = [Text.Encoding]::UTF8.GetString($sumas) } $linea = ($sumas -split "`n") | Where-Object { $_ -match "node-v[0-9.]+-win-$arq\.zip$" } | Select-Object -First 1 if (-not $linea) { throw "No encontré Node.js para win-$arq." } $esperado, $archivo = ($linea.Trim() -split '\s+') $zip = Join-Path $tmp $archivo Invoke-WebRequest -UseBasicParsing "https://nodejs.org/dist/latest-v22.x/$archivo" -OutFile $zip if ((Get-FileHash $zip -Algorithm SHA256).Hash -ne $esperado.ToUpper()) { throw 'La descarga de Node.js no coincide con su suma SHA-256.' } Expand-Archive $zip -DestinationPath $tmp if (Test-Path $NodeDir) { Remove-Item $NodeDir -Recurse -Force } New-Item -ItemType Directory -Path $Datos -Force | Out-Null Move-Item (Join-Path $tmp ([IO.Path]::GetFileNameWithoutExtension($archivo))) $NodeDir Remove-Item $tmp -Recurse -Force AlPath $NodeDir if (-not (NodeOk)) { throw 'Node.js no quedó disponible.' } } Say 'Descargando Veci CLI…' $versiones = Invoke-RestMethod -UseBasicParsing "$Base/descargas/versiones.json" $lista = @($versiones.cli) $v = if ($env:VECI_VERSION) { $lista | Where-Object { $_.version -eq $env:VECI_VERSION } | Select-Object -First 1 } else { $lista[0] } if (-not $v) { throw $(if ($env:VECI_VERSION) { "No existe la versión $env:VECI_VERSION." } else { 'No hay versiones publicadas.' }) } $tmp = Join-Path ([IO.Path]::GetTempPath()) ('veci-' + [guid]::NewGuid()) New-Item -ItemType Directory -Path $tmp | Out-Null $tgz = Join-Path $tmp $v.archivo Invoke-WebRequest -UseBasicParsing "$Base/descargas/cli/$($v.archivo)" -OutFile $tgz if ((Get-FileHash $tgz -Algorithm SHA256).Hash -ne $v.sha256.ToUpper()) { throw 'El paquete no coincide con su SHA-256.' } Say 'Instalando…' # npm.cmd y no npm: con la política de ejecución por defecto, PowerShell bloquea npm.ps1. $env:npm_config_update_notifier = 'false' $npmArgs = @('install', '--global', '--no-fund', '--no-audit', '--loglevel=error') if ($env:VECI_SIN_OPCIONALES) { $npmArgs += '--omit=optional' } & npm.cmd @npmArgs $tgz | Out-Null if ($LASTEXITCODE -ne 0) { throw "npm install falló (código $LASTEXITCODE)." } Remove-Item $tmp -Recurse -Force # Igual que con npm.ps1: si PowerShell no deja correr scripts, veci.ps1 se bloquearía y veci.cmd no. $prefijo = (& npm.cmd prefix --global).Trim() if ((Get-ExecutionPolicy) -in @('Restricted', 'AllSigned', 'Undefined')) { Remove-Item (Join-Path $prefijo 'veci.ps1') -ErrorAction SilentlyContinue } AlPath $prefijo # el paquete de antes (con otro nombre) se va: sus comandos ya no deben abrir una versión vieja & npm.cmd uninstall --global vecipp-cli --loglevel=error 2>$null | Out-Null $version = (& (Join-Path $prefijo 'veci.cmd') --version) Say "Listo: Veci CLI $version. Abre una terminal nueva y escribe veci para empezar." }