-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDownloadComponents.ps1
25 lines (21 loc) · 1 KB
/
DownloadComponents.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
#simple powershell to download LemonTreeComponents files from Nexus
$json = Invoke-RestMethod -Uri https://nexus.lieberlieber.com/service/rest/v1/components?repository=LemonTree.ArchiMate.Demo -Method Get
foreach ($url in $json.items.assets.downloadUrl) {
$url = $url.Insert(4,"s")
#$file = $url.Substring($url.lastIndexOf('/') + 1)
$file = $url.Replace("https://nexus.lieberlieber.com/repository/LemonTree.ArchiMate.Demo/lemontree-component","").Replace("/","\")
$location = Get-Location
$absoluteFile = Join-Path -Path $location -ChildPath $file
$absoluteDir = Split-Path -parent $absoluteFile
$extn = [IO.Path]::GetExtension($absoluteFile)
if ($extn -eq ".mpms" )
{
Write-Host $absoluteDir
Write-Host $absoluteFile
Write-Host $url
#if directory doesn't exist we have to create it.
$foo = New-Item -ItemType Directory -Force -Path $absoluteDir
$content = ((Invoke-RestMethod -Uri $url -Method Get) -replace "")
[IO.File]::WriteAllLines($absoluteFile, $content)
}
}