add very crude scripts to export modules with selenium
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
@echo off
|
||||||
|
SETLOCAL EnableDelayedExpansion
|
||||||
|
echo %cmdcmdline% | findstr /i /c:"%~nx0" >NUL && set iscommandline=1
|
||||||
|
echo %PSModulePath% | findstr /i /c:"%USERPROFILE%" >NUL && set ispowershell=1
|
||||||
|
cd /D "%~dp0"
|
||||||
|
|
||||||
|
SET UserModuleTag=
|
||||||
|
IF "%~1"=="" (
|
||||||
|
echo Module tag not specified.
|
||||||
|
set /p UserModuleTag=Insert module tag:
|
||||||
|
IF "!UserModuleTag!"=="" (
|
||||||
|
echo Module tag is required to extract internals!
|
||||||
|
exit /b 1
|
||||||
|
) ELSE (
|
||||||
|
echo Using module tag: !UserModuleTag!
|
||||||
|
set ModuleTag=!UserModuleTag!
|
||||||
|
)
|
||||||
|
) ELSE (
|
||||||
|
echo Using module tag: %~1
|
||||||
|
set ModuleTag=%~1
|
||||||
|
)
|
||||||
|
|
||||||
|
@powershell -NoProfile -ExecutionPolicy Bypass -Command .\scripts\export-elx.ps1 -ModuleTag %ModuleTag%
|
||||||
|
|
||||||
|
IF DEFINED iscommandline IF NOT DEFINED ispowershell pause
|
||||||
|
ENDLOCAL
|
||||||
@@ -7,7 +7,7 @@ $uri = [System.Uri]$AbsoluteUrl
|
|||||||
|
|
||||||
Write-Host "Converting URL '$uri' to elixForms WS call format..."
|
Write-Host "Converting URL '$uri' to elixForms WS call format..."
|
||||||
|
|
||||||
Import-Module $(Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Definition) "extract-elx-module.psm1") -Force
|
Import-Module $(Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Definition) "elx-tools-module.psm1") -Force
|
||||||
|
|
||||||
$convertedUrl = Convert-UrlToElixAutocompleteFormat -AbsoluteUrl $uri
|
$convertedUrl = Convert-UrlToElixAutocompleteFormat -AbsoluteUrl $uri
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,79 @@ function Save-ElxInternals {
|
|||||||
Pop-Location -StackName ElxTools
|
Pop-Location -StackName ElxTools
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function New-EnvFileContent {
|
||||||
|
param(
|
||||||
|
[ValidateNotNullOrEmpty()][Parameter(Mandatory)][string]$ModuleTag
|
||||||
|
)
|
||||||
|
|
||||||
|
$envFileScriptPath = Join-Path $PSScriptRoot "../"
|
||||||
|
# Load existing .env if present
|
||||||
|
$envPath = Join-Path $envFileScriptPath '.env'
|
||||||
|
|
||||||
|
if (-not (Test-Path $envPath)) {
|
||||||
|
Write-Error "No existing .env file found!"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
$envValues = @{}
|
||||||
|
$envLines = Get-Content -Raw -Path $envPath -ErrorAction Stop
|
||||||
|
Write-Host $envLines
|
||||||
|
foreach ($line in $envLines -split "`n") {
|
||||||
|
$l = $line.Trim()
|
||||||
|
if ($l -eq '' -or $l.StartsWith('#') -or $l.StartsWith(';')) { continue }
|
||||||
|
if ($l -match '=') {
|
||||||
|
$parts = $l -split '=', 2
|
||||||
|
$name = $parts[0].Trim()
|
||||||
|
$value = $parts[1].Trim().Trim("'").Trim('"')
|
||||||
|
$envValues[$name] = $value
|
||||||
|
}
|
||||||
|
if ($name -eq 'ELIXFORMS_MODULE_TAG') {
|
||||||
|
$envValues[$name] = $ModuleTag
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$out = foreach ($name in $settingNames) { "$name='$($envValues[$name])'" }
|
||||||
|
$out -join "`n"
|
||||||
|
}
|
||||||
|
|
||||||
|
function Export-ElxModule {
|
||||||
|
param(
|
||||||
|
[ValidateNotNullOrEmpty()][Parameter(Mandatory)][string]$ModuleTag,
|
||||||
|
[ValidateScript({ Test-Path $_ })][Parameter(Mandatory)]$ModulePath
|
||||||
|
)
|
||||||
|
|
||||||
|
if (-not $Quiet) {
|
||||||
|
Write-Host "Switching to Selenium directory..."
|
||||||
|
}
|
||||||
|
|
||||||
|
$seleniumToolsScriptPath = Join-Path $PSScriptRoot "../tools/selenium/"
|
||||||
|
Push-Location -StackName Selenium $seleniumToolsScriptPath
|
||||||
|
|
||||||
|
if (-not $Quiet) {
|
||||||
|
Write-Host "Executing module export for '$ModuleTag'..."
|
||||||
|
}
|
||||||
|
|
||||||
|
#HACK: il tool prende in ingresso un env file
|
||||||
|
$tmpEnvFile = [System.IO.Path]::GetTempFileName()
|
||||||
|
|
||||||
|
New-EnvFileContent -ModuleTag $ModuleTag | Set-Content -LiteralPath $tmpEnvFile -Encoding UTF8
|
||||||
|
|
||||||
|
& npx env-cmd --file "$tmpEnvFile" -- npm run export
|
||||||
|
|
||||||
|
Remove-Item -LiteralPath $tmpEnvFile -Force -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
Write-Error "Module export for '$ModuleTag' failed with exit code $LASTEXITCODE."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $Quiet) {
|
||||||
|
Write-Host "Module export for '$ModuleTag' completed successfully!" -ForegroundColor Green
|
||||||
|
Write-Host "Switching back to original directory..."
|
||||||
|
}
|
||||||
|
|
||||||
|
Pop-Location -StackName Selenium
|
||||||
|
}
|
||||||
|
|
||||||
function Convert-UrlToElixAutocompleteFormat {
|
function Convert-UrlToElixAutocompleteFormat {
|
||||||
param (
|
param (
|
||||||
[Parameter(Mandatory)][ValidateNotNullOrEmpty()][uri]$AbsoluteUrl
|
[Parameter(Mandatory)][ValidateNotNullOrEmpty()][uri]$AbsoluteUrl
|
||||||
@@ -95,4 +168,5 @@ function Convert-UrlToElixAutocompleteFormat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Export-ModuleMember -Function Convert-UrlToElixAutocompleteFormat
|
Export-ModuleMember -Function Convert-UrlToElixAutocompleteFormat
|
||||||
Export-ModuleMember -Function Save-ElxInternals
|
Export-ModuleMember -Function Save-ElxInternals
|
||||||
|
Export-ModuleMember -Function Export-ElxModule
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
[CmdletBinding()]
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory)][ValidateNotNullOrEmpty()][string]$ModuleTag
|
||||||
|
)
|
||||||
|
|
||||||
|
Write-Host "Checking module folder existence..."
|
||||||
|
$modulesSrcPath = Join-Path -Resolve $PSScriptRoot "../src/$ModuleTag"
|
||||||
|
if (-not (Test-Path -Path "$modulesSrcPath")) {
|
||||||
|
Write-Host "Module folder not found. Creating folder for module tag '$ModuleTag'..." -ForegroundColor Yellow
|
||||||
|
New-Item -ItemType Directory -Path "$modulesSrcPath" -Force | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Exporting module tag '$ModuleTag' from elixForms..."
|
||||||
|
|
||||||
|
Import-Module $(Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Definition) "elx-tools-module.psm1") -Force
|
||||||
|
|
||||||
|
Export-ElxModule -ModuleTag $ModuleTag -ModulePath "$modulesSrcPath"
|
||||||
|
|
||||||
|
Write-Host "Module tag '$ModuleTag' exported successfully!" -ForegroundColor Green
|
||||||
@@ -10,7 +10,7 @@ Write-Host "Found module files:" -ForegroundColor Cyan
|
|||||||
$moduleFiles | ForEach-Object { Write-Host " - $($_.FullName)" -ForegroundColor Cyan }
|
$moduleFiles | ForEach-Object { Write-Host " - $($_.FullName)" -ForegroundColor Cyan }
|
||||||
Write-Host "Extracting ELX internals for each module..."
|
Write-Host "Extracting ELX internals for each module..."
|
||||||
|
|
||||||
Import-Module $(Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Definition) "extract-elx-module.psm1") -Force
|
Import-Module $(Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Definition) "elx-tools-module.psm1") -Force
|
||||||
|
|
||||||
$moduleFiles | ForEach-Object {
|
$moduleFiles | ForEach-Object {
|
||||||
Save-ElxInternals -ModulePath $_.FullName
|
Save-ElxInternals -ModulePath $_.FullName
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ if (-not $moduleFile) {
|
|||||||
Write-Host "Latest updated module file found: '$($moduleFile.FullName)'" -ForegroundColor Cyan
|
Write-Host "Latest updated module file found: '$($moduleFile.FullName)'" -ForegroundColor Cyan
|
||||||
Write-Host "Extracting ELX internals for module tag '$($moduleFile.FullName)'..."
|
Write-Host "Extracting ELX internals for module tag '$($moduleFile.FullName)'..."
|
||||||
|
|
||||||
Import-Module $(Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Definition) "extract-elx-module.psm1") -Force
|
Import-Module $(Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Definition) "elx-tools-module.psm1") -Force
|
||||||
|
|
||||||
Save-ElxInternals -ModulePath $moduleFile.FullName
|
Save-ElxInternals -ModulePath $moduleFile.FullName
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ if (-not $moduleFile) {
|
|||||||
Write-Host "Module file found: '$($moduleFile.FullName)'" -ForegroundColor Cyan
|
Write-Host "Module file found: '$($moduleFile.FullName)'" -ForegroundColor Cyan
|
||||||
Write-Host "Extracting ELX internals for module tag '$($moduleFile.FullName)'..."
|
Write-Host "Extracting ELX internals for module tag '$($moduleFile.FullName)'..."
|
||||||
|
|
||||||
Import-Module $(Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Definition) "extract-elx-module.psm1") -Force
|
Import-Module $(Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Definition) "elx-tools-module.psm1") -Force
|
||||||
|
|
||||||
Save-ElxInternals -ModulePath $moduleFile.FullName
|
Save-ElxInternals -ModulePath $moduleFile.FullName
|
||||||
|
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ function Initialize-EnvironmentSettings {
|
|||||||
Write-Host "Settings preparation complete"
|
Write-Host "Settings preparation complete"
|
||||||
}
|
}
|
||||||
|
|
||||||
function Initialize-NodeTools {
|
function Initialize-ExtractElxTools {
|
||||||
Write-Host "Installing Node.js dependencies for the ELX Tools..."
|
Write-Host "Installing Node.js dependencies for the ELX Tools..." -ForegroundColor Cyan
|
||||||
|
|
||||||
$extractElxToolsScriptPath = Join-Path $PSScriptRoot "../tools/extract-elx/"
|
$extractElxToolsScriptPath = Join-Path $PSScriptRoot "../tools/extract-elx/"
|
||||||
|
|
||||||
@@ -82,6 +82,44 @@ function Initialize-NodeTools {
|
|||||||
Write-Host "Node.js dependencies installed successfully!"
|
Write-Host "Node.js dependencies installed successfully!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Initialize-PlaywrightTools {
|
||||||
|
Write-Host "Installing Node.js dependencies for Playwright..." -ForegroundColor Cyan
|
||||||
|
|
||||||
|
$playwrightScriptPath = Join-Path $PSScriptRoot "../tools/playwright/"
|
||||||
|
|
||||||
|
Push-Location -StackName Playwright $playwrightScriptPath
|
||||||
|
|
||||||
|
# Install Node.js dependencies for Playwright
|
||||||
|
& npm install
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
Write-Error "npm install failed with exit code $LASTEXITCODE."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Pop-Location -StackName Playwright
|
||||||
|
|
||||||
|
Write-Host "Node.js dependencies installed successfully!"
|
||||||
|
}
|
||||||
|
|
||||||
|
function Initialize-SeleniumTools {
|
||||||
|
Write-Host "Installing Node.js dependencies for Selenium..." -ForegroundColor Cyan
|
||||||
|
|
||||||
|
$seleniumScriptPath = Join-Path $PSScriptRoot "../tools/selenium/"
|
||||||
|
|
||||||
|
Push-Location -StackName Selenium $seleniumScriptPath
|
||||||
|
|
||||||
|
# Install Node.js dependencies for Selenium
|
||||||
|
& npm install
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
Write-Error "npm install failed with exit code $LASTEXITCODE."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Pop-Location -StackName Selenium
|
||||||
|
|
||||||
|
Write-Host "Node.js dependencies installed successfully!"
|
||||||
|
}
|
||||||
|
|
||||||
# If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
|
# 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"
|
# #"No Administrative rights, it will display a popup window asking user for Admin rights"
|
||||||
# $arguments = "-NoProfile -ExecutionPolicy Bypass -Command & '" + $myinvocation.mycommand.definition + "'"
|
# $arguments = "-NoProfile -ExecutionPolicy Bypass -Command & '" + $myinvocation.mycommand.definition + "'"
|
||||||
@@ -113,7 +151,15 @@ Initialize-EnvironmentSettings
|
|||||||
|
|
||||||
Write-Host
|
Write-Host
|
||||||
|
|
||||||
Initialize-NodeTools
|
Initialize-ExtractElxTools
|
||||||
|
|
||||||
|
Write-Host
|
||||||
|
|
||||||
|
Initialize-PlaywrightTools
|
||||||
|
|
||||||
|
Write-Host
|
||||||
|
|
||||||
|
Initialize-SeleniumTools
|
||||||
|
|
||||||
Write-Host
|
Write-Host
|
||||||
Write-Host "Environment preparation complete!" -ForegroundColor Green
|
Write-Host "Environment preparation complete!" -ForegroundColor Green
|
||||||
|
|||||||
Generated
+4
-4
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "playwright",
|
"name": "playwright-export-module",
|
||||||
"version": "1.0.0",
|
"version": "0.0.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "playwright",
|
"name": "playwright-export-module",
|
||||||
"version": "1.0.0",
|
"version": "0.0.1",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dotenv": "^17.4.2"
|
"dotenv": "^17.4.2"
|
||||||
|
|||||||
Reference in New Issue
Block a user