Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d300f8110a |
No files matched your search
+2
-1
@@ -3,4 +3,5 @@
|
|||||||
# IMPORTANT #2: Surround values with quotes if they contain spaces or special characters!
|
# IMPORTANT #2: Surround values with quotes if they contain spaces or special characters!
|
||||||
ELIXFORMS_USERNAME=
|
ELIXFORMS_USERNAME=
|
||||||
ELIXFORMS_PASSWORD=
|
ELIXFORMS_PASSWORD=
|
||||||
ELIXFORMS_MODULE_TAG=
|
ELIXFORMS_MODULE=
|
||||||
|
ELIXFORMS_AJSRV=
|
||||||
@@ -4,21 +4,22 @@ echo %cmdcmdline% | findstr /i /c:"%~nx0" >NUL && set iscommandline=1
|
|||||||
echo %PSModulePath% | findstr /i /c:"%USERPROFILE%" >NUL && set ispowershell=1
|
echo %PSModulePath% | findstr /i /c:"%USERPROFILE%" >NUL && set ispowershell=1
|
||||||
cd /D "%~dp0"
|
cd /D "%~dp0"
|
||||||
|
|
||||||
SET UserModuleTag=
|
SET UserModuleId=
|
||||||
|
SET ModuleTag=
|
||||||
IF "%~1"=="" (
|
IF "%~1"=="" (
|
||||||
echo Module tag not specified.
|
echo Module ID not specified.
|
||||||
set /p UserModuleTag=Insert module tag:
|
set /p UserModuleId=Insert module ID:
|
||||||
IF "!UserModuleTag!"=="" (
|
IF "!UserModuleId!"=="" (
|
||||||
echo Module tag is required to extract internals!
|
echo Module ID is required to extract internals!
|
||||||
exit /b 1
|
exit /b 1
|
||||||
) ELSE (
|
) ELSE (
|
||||||
set ModuleTag=!UserModuleTag!
|
set ModuleId=!UserModuleId!
|
||||||
)
|
)
|
||||||
) ELSE (
|
) ELSE (
|
||||||
set ModuleTag=%~1
|
set ModuleId=%~1
|
||||||
)
|
)
|
||||||
|
|
||||||
call export-elx.bat "!ModuleTag!" && call extract-elx-internals.bat "!ModuleTag!"
|
call export-elx.bat "!ModuleId!" && call extract-elx-internals-last-updated.bat
|
||||||
|
|
||||||
IF DEFINED iscommandline IF NOT DEFINED ispowershell pause
|
IF DEFINED iscommandline IF NOT DEFINED ispowershell pause
|
||||||
ENDLOCAL
|
ENDLOCAL
|
||||||
+1
-1
@@ -18,7 +18,7 @@ IF "%~1"=="" (
|
|||||||
set ModuleTag=%~1
|
set ModuleTag=%~1
|
||||||
)
|
)
|
||||||
|
|
||||||
@pwsh -NoProfile -ExecutionPolicy Bypass -Command .\scripts\export-elx.ps1 -ModuleTag %ModuleTag%
|
@pwsh -NoProfile -ExecutionPolicy Bypass -Command .\scripts\export-elx.ps1 -Module %ModuleTag%
|
||||||
|
|
||||||
IF DEFINED iscommandline IF NOT DEFINED ispowershell pause
|
IF DEFINED iscommandline IF NOT DEFINED ispowershell pause
|
||||||
ENDLOCAL
|
ENDLOCAL
|
||||||
@@ -53,17 +53,17 @@ function Save-ElxInternals {
|
|||||||
|
|
||||||
function New-EnvFileContent {
|
function New-EnvFileContent {
|
||||||
param(
|
param(
|
||||||
[ValidateNotNullOrEmpty()][Parameter(Mandatory)][string]$ModuleTag
|
[ValidateNotNullOrEmpty()][Parameter(Mandatory)][string]$Module
|
||||||
)
|
)
|
||||||
|
|
||||||
$envValues = Get-EnvironmentFromFile -ModuleTag $ModuleTag
|
$envValues = Get-EnvironmentFromFile -Module $Module
|
||||||
|
|
||||||
$out = ($envValues.Keys | ForEach-Object { "$_='$($envValues[$_])'" }) -join "`n"
|
$out = ($envValues.Keys | ForEach-Object { "$_='$($envValues[$_])'" }) -join "`n"
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-EnvironmentFromFile {
|
function Get-EnvironmentFromFile {
|
||||||
param(
|
param(
|
||||||
[ValidateNotNullOrEmpty()][Parameter(Mandatory)][string]$ModuleTag
|
[ValidateNotNullOrEmpty()][Parameter(Mandatory)][string]$Module
|
||||||
)
|
)
|
||||||
|
|
||||||
$envFileScriptPath = Join-Path $PSScriptRoot "../"
|
$envFileScriptPath = Join-Path $PSScriptRoot "../"
|
||||||
@@ -87,15 +87,15 @@ function Get-EnvironmentFromFile {
|
|||||||
$value = $parts[1].Trim().Trim("'").Trim('"')
|
$value = $parts[1].Trim().Trim("'").Trim('"')
|
||||||
$envValues[$name] = $value
|
$envValues[$name] = $value
|
||||||
}
|
}
|
||||||
if ($name -eq 'ELIXFORMS_MODULE_TAG') {
|
if ($name -eq 'ELIXFORMS_MODULE') {
|
||||||
$envValues[$name] = $ModuleTag
|
$envValues[$name] = $Module
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$envValues
|
$envValues
|
||||||
}
|
}
|
||||||
|
|
||||||
function Export-ElxModule {
|
function Export-ElxModuleSelenium {
|
||||||
param(
|
param(
|
||||||
[ValidateNotNullOrEmpty()][Parameter(Mandatory)][string]$ModuleTag,
|
[ValidateNotNullOrEmpty()][Parameter(Mandatory)][string]$ModuleTag,
|
||||||
[ValidateScript({ Test-Path $_ })][Parameter(Mandatory)]$ModulePath
|
[ValidateScript({ Test-Path $_ })][Parameter(Mandatory)]$ModulePath
|
||||||
@@ -118,7 +118,7 @@ function Export-ElxModule {
|
|||||||
Write-Error "npm is not installed or not found in PATH. Please install Node.js and npm, then try again."
|
Write-Error "npm is not installed or not found in PATH. Please install Node.js and npm, then try again."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
Start-Process pwsh -ArgumentList "$NpmPath run export" -Environment (Get-EnvironmentFromFile -ModuleTag $ModuleTag) -NoNewWindow -Wait -PassThru | Out-Null
|
Start-Process pwsh -ArgumentList "$NpmPath run export" -Environment (Get-EnvironmentFromFile -Module $ModuleTag) -NoNewWindow -Wait -PassThru | Out-Null
|
||||||
|
|
||||||
if ($LASTEXITCODE -and ($LASTEXITCODE -ne 0)) {
|
if ($LASTEXITCODE -and ($LASTEXITCODE -ne 0)) {
|
||||||
Write-Error "Module export for '$ModuleTag' failed with exit code $LASTEXITCODE."
|
Write-Error "Module export for '$ModuleTag' failed with exit code $LASTEXITCODE."
|
||||||
@@ -149,6 +149,92 @@ function Export-ElxModule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Export-ElxModuleManual {
|
||||||
|
param(
|
||||||
|
[ValidateNotNullOrEmpty()][Parameter(Mandatory)][string]$ModuleId,
|
||||||
|
[ValidateScript({ Test-Path $_ })][Parameter(Mandatory)]$ModulePath
|
||||||
|
)
|
||||||
|
|
||||||
|
if (-not $Quiet) {
|
||||||
|
Write-Host "Checking authentication environment variable..."
|
||||||
|
}
|
||||||
|
|
||||||
|
$CurrentEnvironment = Get-EnvironmentFromFile -Module $ModuleId
|
||||||
|
|
||||||
|
if (-not ($CurrentEnvironment["ELIXFORMS_AJSRV"])) {
|
||||||
|
Write-Error "Required environment variable 'ELIXFORMS_AJSRV' is missing. Please ensure .env file is correctly configured."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (-not $Quiet) {
|
||||||
|
Write-Host "Switching to manual export directory..."
|
||||||
|
}
|
||||||
|
|
||||||
|
$manualExportPath = Join-Path $PSScriptRoot "../tools/manual-export/downloads"
|
||||||
|
if (-not (Test-Path -Path $manualExportPath)) {
|
||||||
|
New-Item -ItemType Directory -Path $manualExportPath -Force | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
Push-Location -StackName ManualExport $manualExportPath
|
||||||
|
|
||||||
|
if (-not $Quiet) {
|
||||||
|
Write-Host "Executing module export for Module ID '$ModuleId'..."
|
||||||
|
}
|
||||||
|
|
||||||
|
$Response = Invoke-WebRequest `
|
||||||
|
-Headers @{ "Cookie" = "AJSRV=$($CurrentEnvironment['ELIXFORMS_AJSRV'])" } `
|
||||||
|
"https://console-unipr.elixforms.it/AJSRV/ELIXFORMS/moduleExport?MODULE_ID=$($ModuleId)&exportProtocol=true"
|
||||||
|
|
||||||
|
if (-not $Response.StatusCode -eq 200) {
|
||||||
|
Write-Error "Module export for '$ModuleId' failed with status code $($Response.StatusCode)."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
$ModuleXml = New-Object xml
|
||||||
|
$ModuleXml.LoadXml(($Response.Content | ConvertFrom-Json | Select-Object -ExpandProperty module))
|
||||||
|
$ModuleTag = ((Select-Xml -Xml $ModuleXml -XPath "/EXT[@title='RWE2 - Modulo']/SECTION[1]/COL0001").Node.InnerText).Trim()
|
||||||
|
|
||||||
|
if (-not $ModuleTag) {
|
||||||
|
Write-Error "Failed to extract module tag from the exported XML."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $Quiet) {
|
||||||
|
Write-Host "Module ID '$ModuleId' corresponds to Module Tag '$ModuleTag'."
|
||||||
|
}
|
||||||
|
|
||||||
|
$Response.Content | Out-File -FilePath (Join-Path $manualExportPath "elxforms_$($ModuleId).elx") -Encoding UTF8
|
||||||
|
|
||||||
|
if (-not $Quiet) {
|
||||||
|
Write-Host "Module export for '$ModuleId' completed successfully!" -ForegroundColor Green
|
||||||
|
Write-Host "Switching back to original directory..."
|
||||||
|
}
|
||||||
|
|
||||||
|
$latestDownloadedFile = Get-ChildItem -Path $manualExportPath -Filter "*.elx" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
|
||||||
|
if (-not $latestDownloadedFile) {
|
||||||
|
Write-Error "No .elx file found in manual export directory '$manualExportPath'."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
$DestinationFolder = Join-Path -Path $ModulePath -ChildPath $ModuleTag
|
||||||
|
if (-not (Test-Path -Path $DestinationFolder)) {
|
||||||
|
New-Item -ItemType Directory -Path $DestinationFolder -Force | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $Quiet) {
|
||||||
|
Write-Host "Moving exported module file '$($latestDownloadedFile.Name)' to destination '$DestinationFolder'..."
|
||||||
|
}
|
||||||
|
|
||||||
|
Move-Item -Path $latestDownloadedFile.FullName -Destination (Join-Path $DestinationFolder $latestDownloadedFile.Name) -Force
|
||||||
|
|
||||||
|
$ModuleTag
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
Pop-Location -StackName ManualExport
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function Convert-UrlToElixAutocompleteFormat {
|
function Convert-UrlToElixAutocompleteFormat {
|
||||||
param (
|
param (
|
||||||
[Parameter(Mandatory)][ValidateNotNullOrEmpty()][uri]$AbsoluteUrl
|
[Parameter(Mandatory)][ValidateNotNullOrEmpty()][uri]$AbsoluteUrl
|
||||||
@@ -194,5 +280,6 @@ 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
|
Export-ModuleMember -Function Export-ElxModuleManual
|
||||||
|
Export-ModuleMember -Function Export-ElxModuleSelenium
|
||||||
Export-ModuleMember -Function New-EnvFileContent
|
Export-ModuleMember -Function New-EnvFileContent
|
||||||
+10
-8
@@ -1,6 +1,6 @@
|
|||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory)][ValidateNotNullOrEmpty()][string]$ModuleTag
|
[Parameter(Mandatory)][ValidateNotNullOrEmpty()][string]$ModuleId
|
||||||
)
|
)
|
||||||
|
|
||||||
$psVersion = $PSVersionTable.PSVersion
|
$psVersion = $PSVersionTable.PSVersion
|
||||||
@@ -10,19 +10,21 @@ if ($psVersion.Major -lt 7 -or ($psVersion.Major -eq 7 -and $psVersion.Minor -lt
|
|||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Checking module folder existence..."
|
Write-Host "Checking module folder existence..."
|
||||||
$modulesSrcPath = Join-Path $PSScriptRoot "../src/$ModuleTag"
|
$modulesSrcPath = Join-Path $PSScriptRoot "../src"
|
||||||
if (-not (Test-Path -Path $modulesSrcPath)) {
|
if (-not (Test-Path -Path $modulesSrcPath)) {
|
||||||
Write-Host "Module folder not found. Creating folder for module tag '$ModuleTag'..." -ForegroundColor Yellow
|
Write-Host "Module folder not found. Creating folder for module '$ModuleId'..." -ForegroundColor Yellow
|
||||||
New-Item -ItemType Directory -Path $modulesSrcPath -Force | Out-Null
|
New-Item -ItemType Directory -Path $modulesSrcPath -Force | Out-Null
|
||||||
}
|
}
|
||||||
$modulesSrcPath = Join-Path -Resolve $PSScriptRoot "../src/$ModuleTag"
|
$modulesSrcPath = Join-Path -Resolve $PSScriptRoot "../src"
|
||||||
|
|
||||||
Write-Host "Module tag '$ModuleTag' will be exported to '$modulesSrcPath'"
|
Write-Host "Module '$ModuleId' will be exported to '$modulesSrcPath' in its own folder"
|
||||||
|
|
||||||
Import-Module $(Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Definition) "elx-tools-module.psm1") -Force
|
Import-Module $(Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Definition) "elx-tools-module.psm1") -Force
|
||||||
|
|
||||||
Write-Host "Exporting module tag '$ModuleTag' from elixForms..."
|
Write-Host "Exporting module '$ModuleId' from elixForms..."
|
||||||
|
|
||||||
Export-ElxModule -ModuleTag $ModuleTag -ModulePath $modulesSrcPath
|
$ModuleTag = (Export-ElxModuleManual -ModuleId $ModuleId -ModulePath $modulesSrcPath)
|
||||||
|
|
||||||
Write-Host "Module tag '$ModuleTag' exported successfully!" -ForegroundColor Green
|
Write-Host "Module '$ModuleId' exported successfully!" -ForegroundColor Green
|
||||||
|
|
||||||
|
Return $ModuleTag
|
||||||
Reference in new issue
Block a user