forked from jenkinsci/uipath-automation-package-plugin
-
Notifications
You must be signed in to change notification settings - Fork 3
/
GenerateHelpFiles.ps1
63 lines (52 loc) · 2.57 KB
/
GenerateHelpFiles.ps1
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
$OpenDivTag='<div>'
$CloseDivTag='</div>'
$OpenHrefTag='<a href ="'
$CloseHrefTag='" target = "_blank">here</a>.'
$UrlRegex = "https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)"
$ResourcesRelativePath = "src\\main\\resources\\com\\uipath\\uipathpackage\\"
$FolderName = "help"
$ActivitiesFolders = @{"ExternalAppAuthenticationEntry" = "entries\\authentication\\ExternalAppAuthenticationEntry";
"TokenAuthenticationEntry" = "entries\\authentication\\TokenAuthenticationEntry";
"DynamicallyEntry" = "entries\\job\\DynamicallyEntry";
"RobotEntry" = "entries\\job\\RobotEntry";
"TestProjectEntry" = "entries\\testExecutionTarget\\TestProjectEntry";
"TestSetEntry" = "entries\\testExecutionTarget\\TestSetEntry";
"UiPathAssets" = "UiPathAssets";
"UiPathDeploy" = "UiPathDeploy";
"UiPathPack" = "UiPathPack";
"UiPathRunJob" = "UiPathRunJob";
"UiPathTest" = "UiPathTest"}
$Languages = @("", "_de", "_es", "_es-MX", "_fr", "_ja", "_ko", "_pt", "_pt-BR", "_ru", "_tr", "_zh-CN")
# Set content of a file using FilePath and Value
function CreateFileWithContent {
param (
$FilePath,
$Value
)
$hasUrl = $Value -match $UrlRegex
if ($hasUrl -eq $true){
$match = $matches[0]
$Value = $Value.Replace($match, "$OpenHrefTag$match$CloseHrefTag")
}
$TemplateValue = $OpenDivTag + $Value + $CloseDivTag
Set-Content -Path $FilePath -Value $TemplateValue -Force
}
# Create the html help files for jelly interfaces
function CreateHelpFiles {
# Iterate through help.properties files to create help.html files for each language
foreach ($language in $Languages) {
$content = Get-Content $ResourcesRelativePath\help$language.properties -Force
$formattedLanguage = $language -replace "-", "_"
foreach ($line in $content) {
# Get the key-value pairs and create a html file for each entry in the properties file
$model, $key = $line.Split('=')[0].Split('.')
$value = $line.Split('=')[1]
$subfolder = $ActivitiesFolders[$model]
$FileName = "$FolderName-$key$formattedLanguage.html"
$FilePath = ".\\$ResourcesRelativePath$subfolder\\$Filename"
Write-Host "Created resource file: $FilePath"
CreateFileWithContent -FilePath $FilePath -Value $value
}
}
}
CreateHelpFiles