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
|
# Prompt for URL
|
||||||
While ($url.Length -eq 0) {
|
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
|
$OFS
|
||||||
|
|
||||||
write-host "Downloading URL. This will take awhile... " -ForeGroundColor Blue
|
write-host "Downloading URL. This will take awhile... " -ForeGroundColor Blue
|
||||||
@@ -26,13 +27,13 @@ catch {
|
|||||||
|
|
||||||
|
|
||||||
# This command will get the sha256 hash
|
# This command will get the sha256 hash
|
||||||
$Hash=get-filehash -InputStream $stream
|
$Hash = get-filehash -InputStream $stream
|
||||||
$stream.Close()
|
$stream.Close()
|
||||||
|
|
||||||
|
|
||||||
$string = "Url: " + $URL ;
|
$string = "Url: " + $URL ;
|
||||||
Write-Output $string
|
Write-Output $string
|
||||||
$string = "Sha256: " + $Hash.Hash
|
$string = "Sha256: " + $Hash.Hash
|
||||||
$string
|
$string
|
||||||
$OFS
|
$OFS
|
||||||
write-host "File downloaded. Please Fill out required fields. "
|
write-host "File downloaded. Please Fill out required fields. "
|
||||||
@@ -42,35 +43,34 @@ write-host "File downloaded. Please Fill out required fields. "
|
|||||||
##########################################
|
##########################################
|
||||||
|
|
||||||
While ($id.Length -lt 4 -or $id.length -ge 255) {
|
While ($id.Length -lt 4 -or $id.length -ge 255) {
|
||||||
write-host 'Enter the package Id, in the following format <Publisher.Appname>'
|
write-host 'Enter the package Id, in the following format <Publisher.Appname>'
|
||||||
$id = Read-Host -Prompt 'For example: Microsoft.Excel'
|
$id = Read-Host -Prompt 'For example: Microsoft.Excel'
|
||||||
}
|
}
|
||||||
|
|
||||||
$host.UI.RawUI.ForegroundColor = "White"
|
$host.UI.RawUI.ForegroundColor = "White"
|
||||||
While ($publisher.Length -eq 0 -or $publisher.length -ge 128) {
|
While ($publisher.Length -eq 0 -or $publisher.length -ge 128) {
|
||||||
$publisher = Read-Host -Prompt 'Enter the publisher'
|
$publisher = Read-Host -Prompt 'Enter the publisher'
|
||||||
}
|
}
|
||||||
|
|
||||||
While ($AppName.Length -eq 0 -or $AppName.length -ge 128) {
|
While ($AppName.Length -eq 0 -or $AppName.length -ge 128) {
|
||||||
$AppName = Read-Host -Prompt 'Enter the application name'
|
$AppName = Read-Host -Prompt 'Enter the application name'
|
||||||
}
|
}
|
||||||
|
|
||||||
While ($version.Length -eq 0) {
|
While ($version.Length -eq 0) {
|
||||||
$version = Read-Host -Prompt 'Enter the version. For example: 1.0, 1.0.0.0'
|
$version = Read-Host -Prompt 'Enter the version. For example: 1.0, 1.0.0.0'
|
||||||
$filename=$version + ".yaml"
|
$filename = $version + ".yaml"
|
||||||
$filename = Join-Path $CurrentDirectory $filename
|
|
||||||
}
|
}
|
||||||
|
|
||||||
While ($License.Length -eq 0 -or $License.length -ge 40) {
|
While ($License.Length -eq 0 -or $License.length -ge 40) {
|
||||||
$License = Read-Host -Prompt 'Enter the License, For example: MIT, or Copyright (c) Microsoft Corporation'
|
$License = Read-Host -Prompt 'Enter the License, For example: MIT, or Copyright (c) Microsoft Corporation'
|
||||||
}
|
}
|
||||||
|
|
||||||
While ($InstallerType -notin ("exe","msi","msix","inno","nullsoft","appx","wix","zip")) {
|
While ($InstallerType -notin ("exe", "msi", "msix", "inno", "nullsoft", "appx", "wix", "zip")) {
|
||||||
$InstallerType = Read-Host -Prompt 'Enter the InstallerType. For example: exe, msi, msix, inno, nullsoft'
|
$InstallerType = Read-Host -Prompt 'Enter the InstallerType. For example: exe, msi, msix, inno, nullsoft'
|
||||||
}
|
}
|
||||||
|
|
||||||
While ($architecture -notin ("x86", "x64", "arm", "arm64", "neutral")) {
|
While ($architecture -notin ("x86", "x64", "arm", "arm64", "neutral")) {
|
||||||
$architecture = Read-Host -Prompt 'Enter the architecture (x86, x64, arm, arm64, Neutral)'
|
$architecture = Read-Host -Prompt 'Enter the architecture (x86, x64, arm, arm64, Neutral)'
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@@ -95,8 +95,8 @@ do {
|
|||||||
|
|
||||||
# Only prompt for silent switches if $InstallerType is "exe"
|
# Only prompt for silent switches if $InstallerType is "exe"
|
||||||
if ($InstallerType.ToLower() -eq "exe") {
|
if ($InstallerType.ToLower() -eq "exe") {
|
||||||
$Silent = Read-Host -Prompt '[OPTIONAL] Enter the silent install switch'
|
$Silent = Read-Host -Prompt '[OPTIONAL] Enter the silent install switch'
|
||||||
$SilentWithProgress = Read-Host -Prompt '[OPTIONAL] Enter the silent (with progress) install switch'
|
$SilentWithProgress = Read-Host -Prompt '[OPTIONAL] Enter the silent (with progress) install switch'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -133,55 +133,55 @@ write-host $License -ForeGroundColor White
|
|||||||
|
|
||||||
if (!($LicenseUrl.length -eq 0)) {
|
if (!($LicenseUrl.length -eq 0)) {
|
||||||
|
|
||||||
$string = "LicenseUrl: " + $LicenseUrl
|
$string = "LicenseUrl: " + $LicenseUrl
|
||||||
write-output $string | out-file $filename -append
|
write-output $string | out-file $filename -append
|
||||||
write-host "LicenseUrl: " -ForeGroundColor Blue -NoNewLine
|
write-host "LicenseUrl: " -ForeGroundColor Blue -NoNewLine
|
||||||
write-host $LicenseUrl -ForeGroundColor White
|
write-host $LicenseUrl -ForeGroundColor White
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!($AppMoniker.length -eq 0)) {
|
if (!($AppMoniker.length -eq 0)) {
|
||||||
|
|
||||||
$string = "AppMoniker: " + $AppMoniker
|
$string = "AppMoniker: " + $AppMoniker
|
||||||
write-output $string | out-file $filename -append
|
write-output $string | out-file $filename -append
|
||||||
write-host "AppMoniker: " -ForeGroundColor Blue -NoNewLine
|
write-host "AppMoniker: " -ForeGroundColor Blue -NoNewLine
|
||||||
write-host $AppMoniker -ForeGroundColor White
|
write-host $AppMoniker -ForeGroundColor White
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!($Commands.length -eq 0)) {
|
if (!($Commands.length -eq 0)) {
|
||||||
|
|
||||||
$string = "Commands: " + $Commands
|
$string = "Commands: " + $Commands
|
||||||
write-output $string | out-file $filename -append
|
write-output $string | out-file $filename -append
|
||||||
write-host "Commands: " -ForeGroundColor Blue -NoNewLine
|
write-host "Commands: " -ForeGroundColor Blue -NoNewLine
|
||||||
write-host $Commands -ForeGroundColor White
|
write-host $Commands -ForeGroundColor White
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!($Tags.length -eq 0)) {
|
if (!($Tags.length -eq 0)) {
|
||||||
|
|
||||||
$string = "Tags: " + $Tags
|
$string = "Tags: " + $Tags
|
||||||
write-output $string | out-file $filename -append
|
write-output $string | out-file $filename -append
|
||||||
write-host "Tags: " -ForeGroundColor Blue -NoNewLine
|
write-host "Tags: " -ForeGroundColor Blue -NoNewLine
|
||||||
write-host $Tags -ForeGroundColor White
|
write-host $Tags -ForeGroundColor White
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!($Description.length -eq 0)) {
|
if (!($Description.length -eq 0)) {
|
||||||
|
|
||||||
$string = "Description: " + $Description
|
$string = "Description: " + $Description
|
||||||
write-output $string | out-file $filename -append
|
write-output $string | out-file $filename -append
|
||||||
write-host "Description: " -ForeGroundColor Blue -NoNewLine
|
write-host "Description: " -ForeGroundColor Blue -NoNewLine
|
||||||
write-host $Description -ForeGroundColor White
|
write-host $Description -ForeGroundColor White
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!($Homepage.Length -eq 0)) {
|
if (!($Homepage.Length -eq 0)) {
|
||||||
|
|
||||||
$string = "Homepage: "+ $Homepage
|
$string = "Homepage: " + $Homepage
|
||||||
write-output $string | out-file $filename -append
|
write-output $string | out-file $filename -append
|
||||||
write-host "Homepage: " -ForeGroundColor Blue -NoNewLine
|
write-host "Homepage: " -ForeGroundColor Blue -NoNewLine
|
||||||
write-host $Homepage -ForeGroundColor White
|
write-host $Homepage -ForeGroundColor White
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,38 +209,54 @@ write-output $string | out-file $filename -append
|
|||||||
write-host "InstallerType: " -ForeGroundColor Blue -NoNewLine
|
write-host "InstallerType: " -ForeGroundColor Blue -NoNewLine
|
||||||
write-host $InstallerType -ForeGroundColor White
|
write-host $InstallerType -ForeGroundColor White
|
||||||
|
|
||||||
if (!($Silent.Length) -eq 0 -Or !($SilentWithProgress.Length -eq 0)) {
|
if (!($Silent.Length) -eq 0 -Or !($SilentWithProgress.Length -eq 0)) {
|
||||||
|
|
||||||
$string = " Switches:"
|
$string = " Switches:"
|
||||||
write-output $string | out-file $filename -append
|
write-output $string | out-file $filename -append
|
||||||
write-host "Switches: " -ForeGroundColor Blue -NoNewLine
|
write-host "Switches: " -ForeGroundColor Blue -NoNewLine
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!($Silent.Length -eq 0)) {
|
if (!($Silent.Length -eq 0)) {
|
||||||
|
|
||||||
$string = " Silent: " + $Silent
|
$string = " Silent: " + $Silent
|
||||||
write-output $string | out-file $filename -append
|
write-output $string | out-file $filename -append
|
||||||
write-host "Silent " -ForeGroundColor Blue -NoNewLine
|
write-host "Silent: " -ForeGroundColor Blue -NoNewLine
|
||||||
write-host $Silent -ForeGroundColor White
|
write-host $Silent -ForeGroundColor White
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!($SilentWithProgress.Length -eq 0)) {
|
if (!($SilentWithProgress.Length -eq 0)) {
|
||||||
|
|
||||||
$string = " SilentWithProgress: " + $SilentWithProgress
|
$string = " SilentWithProgress: " + $SilentWithProgress
|
||||||
write-output $string | out-file $filename -append
|
write-output $string | out-file $filename -append
|
||||||
write-host "SilentWithProgress " -ForeGroundColor Blue -NoNewLine
|
write-host "SilentWithProgress: " -ForeGroundColor Blue -NoNewLine
|
||||||
write-host $SilentWithProgress -ForeGroundColor White
|
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
|
$FileOldEnconding = Get-Content -Raw $filename
|
||||||
Remove-Item -Path $filename
|
Remove-Item -Path $filename
|
||||||
|
$filename = Join-Path $AbsoluteFileLocation $filename
|
||||||
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
|
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
|
||||||
[System.IO.File]::WriteAllLines($filename, $FileOldEnconding, $Utf8NoBomEncoding)
|
[System.IO.File]::WriteAllLines($filename, $FileOldEnconding, $Utf8NoBomEncoding)
|
||||||
|
|
||||||
$string = "Yaml file created: " + $filename
|
$string = "Yaml file created: " + $filename
|
||||||
write-output $string
|
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