Package availabity check #176
@@ -56,6 +56,19 @@ function Get-NodeBuilder {
|
|||||||
$Platform = $Platform.ToLower()
|
$Platform = $Platform.ToLower()
|
||||||
if ($Platform -match 'win32') {
|
if ($Platform -match 'win32') {
|
||||||
$builder = [WinNodeBuilder]::New($Version, $Platform, $Architecture)
|
$builder = [WinNodeBuilder]::New($Version, $Platform, $Architecture)
|
||||||
|
# Get the URL of the binaries
|
||||||
|
$binariesUri = $builder.GetBinariesUri()
|
||||||
|
|
||||||
|
# If the URL is $null, then skip the download and build process
|
||||||
|
if ($binariesUri -eq $null) {
|
||||||
|
Write-Host "The binary doesn't exist. Skipping download and build."
|
||||||
|
exit 0
|
||||||
|
} else {
|
||||||
|
# Continue with the build
|
||||||
|
$builder.Build()
|
||||||
|
return $builder
|
||||||
|
}
|
||||||
|
|
||||||
} elseif (($Platform -match 'linux') -or ($Platform -match 'darwin')) {
|
} elseif (($Platform -match 'linux') -or ($Platform -match 'darwin')) {
|
||||||
$builder = [NixNodeBuilder]::New($Version, $Platform, $Architecture)
|
$builder = [NixNodeBuilder]::New($Version, $Platform, $Architecture)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -87,8 +87,12 @@ class NodeBuilder {
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
Write-Host "Create WorkFolderLocation and ArtifactFolderLocation folders"
|
Write-Host "Create WorkFolderLocation and ArtifactFolderLocation folders"
|
||||||
|
if (-not (Test-Path -path $this.WorkFolderLocation)) {
|
||||||
New-Item -Path $this.WorkFolderLocation -ItemType "directory"
|
New-Item -Path $this.WorkFolderLocation -ItemType "directory"
|
||||||
|
}
|
||||||
|
if (-not (Test-Path -path $this.ArtifactFolderLocation)) {
|
||||||
New-Item -Path $this.ArtifactFolderLocation -ItemType "directory"
|
New-Item -Path $this.ArtifactFolderLocation -ItemType "directory"
|
||||||
|
}
|
||||||
|
|
||||||
Write-Host "Download Node.js $($this.Version) [$($this.Architecture)] executable..."
|
Write-Host "Download Node.js $($this.Version) [$($this.Architecture)] executable..."
|
||||||
$binariesArchivePath = $this.Download()
|
$binariesArchivePath = $this.Download()
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ class WinNodeBuilder : NodeBuilder {
|
|||||||
$this.OutputArtifactName = "node-$Version-$Platform-$Architecture.7z"
|
$this.OutputArtifactName = "node-$Version-$Platform-$Architecture.7z"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[uri] GetBinariesUri() {
|
[uri] GetBinariesUri() {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
@@ -37,14 +40,30 @@ class WinNodeBuilder : NodeBuilder {
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
$base = $this.GetBaseUri()
|
$base = $this.GetBaseUri()
|
||||||
return "${base}/v$($this.Version)/node-v$($this.Version)-win-$($this.Architecture).7z"
|
$uri = "${base}/v$($this.Version)/node-v$($this.Version)-win-$($this.Architecture).7z"
|
||||||
|
|
||||||
|
# Check if the package exists
|
||||||
|
try {
|
||||||
|
$response = Invoke-WebRequest -Uri $uri -Method Head -ErrorAction Stop
|
||||||
|
|
||||||
|
# If the request was successful and the status code is 200, return the URI
|
||||||
|
if ($response.StatusCode -eq 200) {
|
||||||
|
return $uri
|
||||||
|
} else {
|
||||||
|
Write-Host "Skipping build as the binary does not exist."
|
||||||
|
return $null
|
||||||
}
|
}
|
||||||
|
} catch {
|
||||||
|
Write-Host "Skipping build as the binary does not exist."
|
||||||
|
return $null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[void] ExtractBinaries($archivePath) {
|
[void] ExtractBinaries($archivePath) {
|
||||||
$extractTargetDirectory = Join-Path $this.TempFolderLocation "tempExtract"
|
$extractTargetDirectory = Join-Path $this.TempFolderLocation "tempExtract"
|
||||||
Extract-SevenZipArchive -ArchivePath $archivePath -OutputDirectory $extractTargetDirectory
|
Extract-SevenZipArchive -ArchivePath $archivePath -OutputDirectory $extractTargetDirectory
|
||||||
$nodeOutputPath = Get-Item $extractTargetDirectory\* | Select-Object -First 1 -ExpandProperty Fullname
|
$nodeOutputPath = Get-Item $extractTargetDirectory\* | Select-Object -First 1 -ExpandProperty Fullname
|
||||||
Move-Item -Path $nodeOutputPath\* -Destination $this.WorkFolderLocation
|
Move-Item -Path $nodeOutputPath\* -Destination $this.WorkFolderLocation -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
[void] CreateInstallationScript() {
|
[void] CreateInstallationScript() {
|
||||||
@@ -53,7 +72,7 @@ class WinNodeBuilder : NodeBuilder {
|
|||||||
Create Node.js artifact installation script based on specified template.
|
Create Node.js artifact installation script based on specified template.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
$installationScriptLocation = New-Item -Path $this.WorkFolderLocation -Name $this.InstallationScriptName -ItemType File
|
$installationScriptLocation = New-Item -Path $this.WorkFolderLocation -Name $this.InstallationScriptName -ItemType File -Force
|
||||||
$installationTemplateLocation = Join-Path -Path $this.InstallationTemplatesLocation -ChildPath $this.InstallationTemplateName
|
$installationTemplateLocation = Join-Path -Path $this.InstallationTemplatesLocation -ChildPath $this.InstallationTemplateName
|
||||||
$installationTemplateContent = Get-Content -Path $installationTemplateLocation -Raw
|
$installationTemplateContent = Get-Content -Path $installationTemplateLocation -Raw
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user