From 8d5fd75ce84486e88048444e529f33f491a9593f Mon Sep 17 00:00:00 2001 From: Pier-Paolo Mammi Date: Thu, 21 May 2026 16:35:19 +0200 Subject: [PATCH] add batch script to call extract-elx tool --- extract-elx-internals.bat | 18 ++++++++ scripts/extract-elx-internals.ps1 | 77 +++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 extract-elx-internals.bat create mode 100644 scripts/extract-elx-internals.ps1 diff --git a/extract-elx-internals.bat b/extract-elx-internals.bat new file mode 100644 index 0000000..de39e6d --- /dev/null +++ b/extract-elx-internals.bat @@ -0,0 +1,18 @@ +@echo off +echo %cmdcmdline% | findstr /i /c:"%~nx0" >NUL && set iscommandline=1 +echo %PSModulePath% | findstr "%USERPROFILE%" >NUL && set ispowershell=1 +cd /D "%~dp0" + +echo. + +@REM IF %* == "" echo "Module tag not specified." +@REM #set /p "ModuleTag=Insert module tag: " +@REM ) ELSE ( +@REM #set "ModuleTag=%*" +@REM ) + +@powershell -NoProfile -ExecutionPolicy Bypass -Command .\scripts\extract-elx-internals.ps1 -ModuleTag %* + +echo. + +IF DEFINED iscommandline IF NOT DEFINED ispowershell pause diff --git a/scripts/extract-elx-internals.ps1 b/scripts/extract-elx-internals.ps1 new file mode 100644 index 0000000..f5347f7 --- /dev/null +++ b/scripts/extract-elx-internals.ps1 @@ -0,0 +1,77 @@ +# If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { +# #"No Administrative rights, it will display a popup window asking user for Admin rights" +# $arguments = "-NoProfile -ExecutionPolicy Bypass -Command & '" + $myinvocation.mycommand.definition + "'" +# Start-Process "$psHome\powershell.exe" -Verb runAs -ArgumentList $arguments #-WindowStyle Hidden +# break +# } + +# # Set execution policy remotesigned machine wide +# try { +# Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -Force -ErrorAction SilentlyContinue -WarningAction SilentlyContinue -InformationAction SilentlyContinue +# } +# catch { +# # Suppress +# } + +# # Load Environment Setup Module +# $envSetupModulePath = $(Join-Path $PSScriptRoot "EnvironmentSetup.psm1") +# if (-not (Test-Path $envSetupModulePath)) { +# Write-Warning "Environment Setup Module file '$($envSetupModulePath)' not found!" +# Write-Host +# exit 1 +# } +# Import-Module -Force $envSetupModulePath + +[CmdletBinding()] +param( + [Parameter(Mandatory=$false)][string]$ModuleTag +) + +Write-Host "Extracting ELX internals for module tag $ModuleTag..." -ForegroundColor Cyan +Write-Host "Switching to ELX Tools directory..." -ForegroundColor DarkGray + +$extractElxToolsScriptPath = Join-Path $PSScriptRoot "../tools/extract-elx/" +Push-Location -StackName ElxTools $extractElxToolsScriptPath + +Write-Host "Identifying module file..." -ForegroundColor DarkGray + +$modulesSrcPath = Join-Path $PSScriptRoot "../src/$($ModuleTag)" +$moduleFile = Get-childitem -Path $modulesSrcPath -Filter "*.elx" -ErrorAction Stop | Select-Object -First 1 +if (-not $moduleFile) { + Write-Error "No .elx file found in '$modulesSrcPath'." + exit 1 +} + +Write-Host "Module file found: $moduleFile" -ForegroundColor Gray +Write-Host "Installing Node.js dependencies for the ELX Tools..." -ForegroundColor DarkGray + +# Install Node.js dependencies for the ELX Tools +& npm install +if ($LASTEXITCODE -ne 0) { + Write-Error "npm install failed with exit code $LASTEXITCODE." + exit 1 +} + +Write-Host "Node.js dependencies installed successfully!" -ForegroundColor DarkGray +Write-Host "Executing ELX extraction..." -ForegroundColor DarkGray + +& node "extract-elx.js" $moduleFile.FullName --clean +if ($LASTEXITCODE -ne 0) { + Write-Error "ELX extraction failed with exit code $LASTEXITCODE." + exit 1 +} + +Write-Host "ELX extraction completed successfully!" -ForegroundColor DarkGray + +Pop-Location -StackName ElxTools + +Write-Host "ELX internals extracted successfully!" -ForegroundColor Cyan + +# do { +# Write-Host "To complete the intallations you need to restart your computer" -ForegroundColor Cyan +# Write-Host "do you want to restart? [Y/n]" -ForegroundColor Cyan +# $key = ([console]::ReadKey()).Key.ToString().ToUpper() +# if ($key -eq 'Y') { +# Restart-Computer +# } +# } while ($key -ne 'N' -and $key -ne 'Y')