This repository was archived by the owner on Oct 14, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathrun.ps1
More file actions
47 lines (45 loc) · 2.42 KB
/
Copy pathrun.ps1
File metadata and controls
47 lines (45 loc) · 2.42 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
param([string]$Project = (Get-Location).Path, [switch]$NoSetup)
$ErrorActionPreference = 'Stop'
Import-Module (Join-Path $PSHOME 'Modules\Microsoft.PowerShell.Management\Microsoft.PowerShell.Management.psd1')
$repository = $PSScriptRoot
$projectPath = (Resolve-Path -LiteralPath $Project).Path
function Write-Step([string]$Title, [scriptblock]$Action) {
Write-Host " ┌─ $Title " -ForegroundColor Cyan
& $Action
if ($LASTEXITCODE -ne 0) { throw "$Title failed (exit $LASTEXITCODE)." }
Write-Host ' └─ Complete' -ForegroundColor Green
Write-Host ''
}
Push-Location -LiteralPath $repository
try {
if (-not (Get-Command node -ErrorAction SilentlyContinue)) { throw 'Node.js 20 or newer is required.' }
if ([int]((& node --version).TrimStart('v').Split('.')[0]) -lt 20) { throw 'Node.js 20 or newer is required.' }
$pythonPath = Join-Path $repository '.venv\Scripts\python.exe'
if (-not $NoSetup) {
Write-Host ''
Write-Host ' ENVDOCTOR / CONSOLE SETUP' -ForegroundColor Cyan
Write-Host ' Preparing the local application environment' -ForegroundColor DarkGray
Write-Host ''
if (-not (Test-Path -LiteralPath $pythonPath)) {
$pythonCommand = Get-Command python -ErrorAction SilentlyContinue
if (-not $pythonCommand) { throw 'Python 3.11 or newer is required.' }
& $pythonCommand.Source -c 'import sys; sys.exit(0 if sys.version_info >= (3,11) else 1)'
if ($LASTEXITCODE -ne 0) { throw 'Python 3.11 or newer is required.' }
Write-Step 'Python virtual environment' { & $pythonCommand.Source -m venv (Join-Path $repository '.venv') }
}
Write-Step 'Diagnostic engine' { & $pythonPath -m pip install --disable-pip-version-check -e . }
Write-Step 'Console dependencies' { & npm.cmd ci --ignore-scripts --no-audit --no-fund }
Write-Step 'TypeScript console' { & npm.cmd run build }
}
if (-not (Test-Path -LiteralPath $pythonPath) -or -not (Test-Path -LiteralPath (Join-Path $repository 'dist\index.js'))) {
throw 'Application is not installed. Run again without -NoSetup.'
}
$env:ENVDOCTOR_PYTHON = $pythonPath
& node (Join-Path $repository 'dist\index.js') $projectPath
if ($LASTEXITCODE -ne 0) { throw "Console exited with status $LASTEXITCODE." }
} catch {
Write-Host " EnvDoctor: $($_.Exception.Message)" -ForegroundColor Red
exit 1
} finally {
Pop-Location
}