update yaml create script (#2378)
* Refactor format * Add colon writing metadata * Change file location to absolute * Supress extra output * support running any location
This commit is contained in:
@@ -9,7 +9,8 @@ $CurrentDirectory = Get-Location
|
||||
|
||||
# Prompt for URL
|
||||
While ($url.Length -eq 0) {
|
||||
$url = Read-Host -Prompt 'Enter the URL to the installer' }
|
||||
$url = Read-Host -Prompt 'Enter the URL to the installer'
|
||||
}
|
||||
$OFS
|
||||
|
||||
write-host "Downloading URL. This will take awhile... " -ForeGroundColor Blue
|
||||
@@ -58,7 +59,6 @@ $AppName = Read-Host -Prompt 'Enter the application name'
|
||||
While ($version.Length -eq 0) {
|
||||
$version = Read-Host -Prompt 'Enter the version. For example: 1.0, 1.0.0.0'
|
||||
$filename = $version + ".yaml"
|
||||
$filename = Join-Path $CurrentDirectory $filename
|
||||
}
|
||||
|
||||
While ($License.Length -eq 0 -or $License.length -ge 40) {
|
||||
@@ -221,7 +221,7 @@ if (!($Silent.Length -eq 0)) {
|
||||
|
||||
$string = " Silent: " + $Silent
|
||||
write-output $string | out-file $filename -append
|
||||
write-host "Silent " -ForeGroundColor Blue -NoNewLine
|
||||
write-host "Silent: " -ForeGroundColor Blue -NoNewLine
|
||||
write-host $Silent -ForeGroundColor White
|
||||
|
||||
}
|
||||
@@ -230,17 +230,33 @@ if (!($SilentWithProgress.Length -eq 0)) {
|
||||
|
||||
$string = " SilentWithProgress: " + $SilentWithProgress
|
||||
write-output $string | out-file $filename -append
|
||||
write-host "SilentWithProgress " -ForeGroundColor Blue -NoNewLine
|
||||
write-host "SilentWithProgress: " -ForeGroundColor Blue -NoNewLine
|
||||
write-host $SilentWithProgress -ForeGroundColor White
|
||||
|
||||
}
|
||||
|
||||
if ($CurrentDirectory -match "winget-pkgs\\manifests\\(?<publisher>.+?)\\(?<appname>.+?)$") {
|
||||
$FileLocation = Join-Path "\" "manifests" $Matches.publisher $Matches.appname
|
||||
$AbsoluteFileLocation = $CurrentDirectory
|
||||
} elseif ($CurrentDirectory -match "winget-pkgs\\manifests\\(?<publisher>.+?)$") {
|
||||
$appNameDirectory = $id.Split('.')[1]
|
||||
$FileLocation = Join-Path "\" "manifests" $Matches.publisher $appNameDirectory
|
||||
$AbsoluteFileLocation = Join-Path $CurrentDirectory $appNameDirectory
|
||||
} else {
|
||||
$RepositoryRoot = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Source)
|
||||
$FileLocation = Join-Path "\" "manifests" $id.Split('.')[0..1]
|
||||
$AbsoluteFileLocation = Join-Path $RepositoryRoot $FileLocation
|
||||
}
|
||||
if (-not (Test-Path $AbsoluteFileLocation)) {
|
||||
New-Item $AbsoluteFileLocation -ItemType Directory | Out-Null
|
||||
}
|
||||
$FileOldEnconding = Get-Content -Raw $filename
|
||||
Remove-Item -Path $filename
|
||||
$filename = Join-Path $AbsoluteFileLocation $filename
|
||||
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
|
||||
[System.IO.File]::WriteAllLines($filename, $FileOldEnconding, $Utf8NoBomEncoding)
|
||||
|
||||
$string = "Yaml file created: " + $filename
|
||||
write-output $string
|
||||
|
||||
write-host "Now place this file in the following location: \manifests\<publisher>\<appname> "
|
||||
write-host "Now place this file in the following location: $FileLocation "
|
||||
|
Reference in New Issue
Block a user