-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap-robotframework.ps1
92 lines (74 loc) · 2.97 KB
/
bootstrap-robotframework.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
param (
[string]$Proxy
)
# Define the local path to save the installer
$defRFInstallerPath= "C:\RF-Bootstrap"
$defRepo= "PhilippLemke/robotframework-bootstrap"
$gitSnap= "$defRFInstallerPath\git-snap"
function Download-Repo {
param (
[string]$tmp_folder,
[string]$repo,
[string]$Proxy
)
# Define the URL based on the $repo argument
$url = "https://github.com/$repo/archive/refs/heads/master.zip"
# Construct the output file path
$outputFilePath = Join-Path -Path $tmp_folder -ChildPath "$($repo.Split('/')[-1]).zip"
# Download bootstrap git content as zip-file and extract it to tmp
if ($Proxy) {
Write-Output "Download via Proxy: $Proxy"
Invoke-WebRequest -Uri $url -OutFile $outputFilePath -Proxy $Proxy -ProxyUseDefaultCredentials
} else {
Write-Output "No Proxy configured, download directly."
Invoke-WebRequest -Uri $url -OutFile $outputFilePath
}
Expand-Archive -Path $outputFilePath -DestinationPath $tmp_folder -Force
}
# Define your bootstrap directory structure here
$directoryStructure = @{
$defRFInstallerPath = @(
"salt-app",
"salt-var",
"git-snap",
"pkgs/blobs",
"pkgs/pip"
)
}
# Function to create directories from the structure
function Create-Directories {
param (
[Parameter(Mandatory = $true)]
[System.Collections.Hashtable]$structure
)
foreach ($root in $structure.Keys) {
foreach ($path in $structure[$root]) {
$fullPath = Join-Path -Path $root -ChildPath $path
if (-not (Test-Path -Path $fullPath)) {
Write-Output "Creating directory: $fullPath"
New-Item -Path $fullPath -ItemType Directory | Out-Null
}
else {
Write-Output "Directory already exists: $fullPath"
}
}
}
}
# Call the function to create the directory structure
Create-Directories -structure $directoryStructure
# Define source and destination paths
$sourcePath = "C:\Program Files\Salt Project\Salt"
$destinationPath = $defRFInstallerPath + "\salt-app"
# Check if the source directory exists
if (Test-Path -Path $sourcePath) {
# Copy the entire contents of the source directory to the destination, including subfolders
Copy-Item -Path "$sourcePath\*" -Destination $destinationPath -Recurse -Force
Write-Output "Copied contents from $sourcePath to $destinationPath."
} else {
Write-Output "Source directory does not exist: $sourcePath"
}
Write-Output "Download and extract the git repository content"
Download-Repo -tmp_folder $gitSnap -repo $defRepo -Proxy $Proxy
Write-Output "Provide salt-data from git repository to $defRFInstallerPath."
# Copy salt-data robotframework-bootstrap-master\salt-data to $defRFInstallerPath\.
Copy-Item -Path "$gitSnap\robotframework-bootstrap-master\salt-data" -Destination $defRFInstallerPath -Recurse -Force