@@ -236,7 +236,7 @@ if ($Settings) {
236236 exit
237237}
238238
239- $ScriptHeader = ' # Created with YamlCreate.ps1 v2.5 .0'
239+ $ScriptHeader = ' # Created with YamlCreate.ps1 v2.6 .0'
240240$ManifestVersion = ' 1.10.0'
241241$PSDefaultParameterValues = @ { ' *:Encoding' = ' UTF8' }
242242$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
@@ -273,11 +273,18 @@ $useDirectSchemaLink = if ($env:GITHUB_ACTIONS -eq $true) {
273273} else {
274274 (Invoke-WebRequest " https://aka.ms/winget-manifest.version.$ManifestVersion .schema.json" - UseBasicParsing).Content -match ' <!doctype html>'
275275}
276+
277+ if ($ManifestVersion -ne ' latest' ) {
278+ $FullManifestVersion = " v$ManifestVersion "
279+ } else {
280+ $FullManifestVersion = $ManifestVersion
281+ }
282+
276283$SchemaUrls = @ {
277- version = if ($useDirectSchemaLink ) { " https://raw.githubusercontent.com/microsoft/winget-cli/master/schemas/JSON/manifests/v $ManifestVersion /manifest.version.$ManifestVersion .json" } else { " https://aka.ms/winget-manifest.version.$ManifestVersion .schema.json" }
278- defaultLocale = if ($useDirectSchemaLink ) { " https://raw.githubusercontent.com/microsoft/winget-cli/master/schemas/JSON/manifests/v $ManifestVersion /manifest.defaultLocale.$ManifestVersion .json" } else { " https://aka.ms/winget-manifest.defaultLocale.$ManifestVersion .schema.json" }
279- locale = if ($useDirectSchemaLink ) { " https://raw.githubusercontent.com/microsoft/winget-cli/master/schemas/JSON/manifests/v $ManifestVersion /manifest.locale.$ManifestVersion .json" } else { " https://aka.ms/winget-manifest.locale.$ManifestVersion .schema.json" }
280- installer = if ($useDirectSchemaLink ) { " https://raw.githubusercontent.com/microsoft/winget-cli/master/schemas/JSON/manifests/v $ManifestVersion /manifest.installer.$ManifestVersion .json" } else { " https://aka.ms/winget-manifest.installer.$ManifestVersion .schema.json" }
284+ version = if ($useDirectSchemaLink ) { " https://raw.githubusercontent.com/microsoft/winget-cli/master/schemas/JSON/manifests/$FullManifestVersion /manifest.version.$ManifestVersion .json" } else { " https://aka.ms/winget-manifest.version.$ManifestVersion .schema.json" }
285+ defaultLocale = if ($useDirectSchemaLink ) { " https://raw.githubusercontent.com/microsoft/winget-cli/master/schemas/JSON/manifests/$FullManifestVersion /manifest.defaultLocale.$ManifestVersion .json" } else { " https://aka.ms/winget-manifest.defaultLocale.$ManifestVersion .schema.json" }
286+ locale = if ($useDirectSchemaLink ) { " https://raw.githubusercontent.com/microsoft/winget-cli/master/schemas/JSON/manifests/$FullManifestVersion /manifest.locale.$ManifestVersion .json" } else { " https://aka.ms/winget-manifest.locale.$ManifestVersion .schema.json" }
287+ installer = if ($useDirectSchemaLink ) { " https://raw.githubusercontent.com/microsoft/winget-cli/master/schemas/JSON/manifests/$FullManifestVersion /manifest.installer.$ManifestVersion .json" } else { " https://aka.ms/winget-manifest.installer.$ManifestVersion .schema.json" }
281288}
282289
283290# Fetch Schema data from github for entry validation, key ordering, and automatic commenting
@@ -292,6 +299,13 @@ try {
292299 $InstallerEntryProperties = (ConvertTo-Yaml $InstallerSchema.definitions.Installer.properties | ConvertFrom-Yaml - Ordered).Keys
293300 $InstallerDependencyProperties = (ConvertTo-Yaml $InstallerSchema.definitions.Dependencies.properties | ConvertFrom-Yaml - Ordered).Keys
294301 $AppsAndFeaturesEntryProperties = (ConvertTo-Yaml $InstallerSchema.definitions.AppsAndFeaturesEntry.properties | ConvertFrom-Yaml - Ordered).Keys
302+
303+ # Update the manifest version in case `latest` was specified
304+ $ManifestVersion = $VersionSchema.properties.ManifestVersion.default
305+ # Update the schema URLs to reflect the correct version for use in the manifest header
306+ @ ($SchemaUrls.Keys ) | ForEach-Object {
307+ $SchemaUrls [$_ ] = " https://aka.ms/winget-manifest.$_ .$ManifestVersion .schema.json"
308+ }
295309} catch {
296310 # Here we want to pass the exception as an inner exception for debugging if necessary
297311 throw [System.Net.WebException ]::new(' Manifest schemas could not be downloaded. Try running the script again' , $_.Exception )
@@ -851,6 +865,22 @@ Function Read-NestedInstaller {
851865 }
852866 }
853867 }
868+
869+ if ($_EffectiveType -eq ' font' ) {
870+ # Prompt to see if multiple entries are needed
871+ $_menu = @ {
872+ entries = @ (
873+ ' [Y] Yes'
874+ ' *[N] No'
875+ )
876+ Prompt = ' Do you want to create another font entry?'
877+ DefaultString = ' N'
878+ }
879+ switch ( Invoke-KeypressMenu - Prompt $_menu [' Prompt' ] - Entries $_menu [' Entries' ] - DefaultString $_menu [' DefaultString' ]) {
880+ ' Y' { $AnotherNestedInstaller = $true }
881+ default { $AnotherNestedInstaller = $false }
882+ }
883+ }
854884 $_NestedInstallerFiles += $_InstallerFile
855885 } until (! $AnotherNestedInstaller )
856886 $_Installer [' NestedInstallerFiles' ] = $_NestedInstallerFiles
@@ -1307,6 +1337,11 @@ Function Read-InstallerEntry {
13071337 if ($AnotherInstaller -eq ' 0' ) {
13081338 Write-Host ; Read-InstallerEntry
13091339 }
1340+
1341+ # If the app folder is in manifests and the installer type is font, change the app folder to point at fonts
1342+ if ($script :AppFolder -match ' manifests' -and (Get-EffectiveInstallerType $_Installer ) -eq ' font' ) {
1343+ $script :AppFolder = $script :AppFolder -replace ' manifests' , ' fonts'
1344+ }
13101345}
13111346
13121347# Prompts user for Installer Values using the `Quick Update` Method
@@ -2435,6 +2470,13 @@ if (Test-Path -Path "$PSScriptRoot\..\manifests") {
24352470 $ManifestsFolder = (Resolve-Path ' .\' ).Path
24362471}
24372472
2473+ # Set the root folder where new font manifests should be created
2474+ if (Test-Path - Path " $PSScriptRoot \..\fonts" ) {
2475+ $FontsFolder = (Resolve-Path " $PSScriptRoot \..\fonts" ).Path
2476+ } else {
2477+ $FontsFolder = (Resolve-Path ' .\' ).Path
2478+ }
2479+
24382480# Initialize the return value to be a success
24392481$script :_returnValue = [ReturnValue ]::new(200 )
24402482
@@ -2695,13 +2737,45 @@ if ($ScriptSettings.ContinueWithExistingPRs -ne 'always' -and $script:Option -ne
26952737
26962738# Set the folder for the specific package and version
26972739$script :AppFolder = Join-Path $ManifestsFolder - ChildPath $PackageIdentifier.ToLower ().Chars(0 ) | Join-Path - ChildPath $PackageIdentifierFolder | Join-Path - ChildPath $PackageVersion
2740+ $script :FontFolder = Join-Path $FontsFolder - ChildPath $PackageIdentifier.ToLower ().Chars(0 ) | Join-Path - ChildPath $PackageIdentifierFolder | Join-Path - ChildPath $PackageVersion
2741+
2742+ # Attempt to see if the old package exists in the manifests folder, font folder, or both
2743+ $script :DestinationFolder = $null ;
2744+ if (Test-Path - Path (Split-Path $script :AppFolder )) {
2745+ $script :DestinationFolder = $script :AppFolder
2746+ }
2747+ if (Test-Path - Path (Split-Path $script :FontFolder )) {
2748+ if ($script :DestinationFolder ) {
2749+ $script :DestinationFolder = @ ($script :DestinationFolder ; $script :FontFolder )
2750+ } else {
2751+ $script :DestinationFolder = $script :FontFolder
2752+ }
2753+ }
2754+ if ($script :DestinationFolder -and $script :DestinationFolder.Count -gt 1 ) {
2755+ $_menu = @ {
2756+ entries = @ (' [1] Manifests Folder' ; ' [2] Fonts Folder' )
2757+ Prompt = ' The package exists in both the manifests and fonts folder. Which folder do you want to use?'
2758+ DefaultString = ' 1'
2759+ }
2760+ switch ( Invoke-KeypressMenu - Prompt $_menu [' Prompt' ] - Entries $_menu [' Entries' ] - DefaultString $_menu [' DefaultString' ] ) {
2761+ ' 1' { $script :AppFolder = $script :AppFolder }
2762+ ' 2' { $script :AppFolder = $script :FontFolder }
2763+ }
2764+ } elseif ($script :DestinationFolder -and $script :DestinationFolder.Count -eq 1 ) {
2765+ $script :AppFolder = $script :DestinationFolder
2766+ }
26982767
26992768# If the user selected `NewLocale` or `EditMetadata` the version *MUST* already exist in the folder structure
27002769if ($script :Option -in @ (' NewLocale' ; ' EditMetadata' ; ' RemoveManifest' )) {
27012770 # Try getting the old manifests from the specified folder
27022771 if (Test-Path - Path " $AppFolder \..\$PackageVersion " ) {
27032772 $script :OldManifests = Get-ChildItem - Path " $AppFolder \..\$PackageVersion "
27042773 $LastVersion = $PackageVersion
2774+ } elseif (Test-Path - Path " $FontFolder \..\$PackageVersion " ) {
2775+ $script :OldManifests = Get-ChildItem - Path " $FontFolder \..\$PackageVersion "
2776+ $LastVersion = $PackageVersion
2777+ # Intentionally override AppFolder here to ensure the rest of the script works as expected
2778+ $script :AppFolder = $script :FontFolder
27052779 }
27062780 # If the old manifests could not be found, request a new version
27072781 while (-not ($OldManifests.Name -like " $PackageIdentifier *.yaml" )) {
@@ -2713,17 +2787,21 @@ if ($script:Option -in @('NewLocale'; 'EditMetadata'; 'RemoveManifest')) {
27132787 }
27142788 if (Test-Path - Path " $AppFolder \..\$PromptVersion " ) {
27152789 $script :OldManifests = Get-ChildItem - Path " $AppFolder \..\$PromptVersion "
2790+ $script :AppFolder = Join-Path (Split-Path $AppFolder ) - ChildPath $LastVersion
2791+ } elseif (Test-Path - Path " $FontFolder \..\$PromptVersion " ) {
2792+ $script :OldManifests = Get-ChildItem - Path " $FontFolder \..\$PromptVersion "
2793+ # Intentionally use AppFolder here to ensure the rest of the script works as expected
2794+ $script :AppFolder = Join-Path (Split-Path $FontFolder ) - ChildPath $LastVersion
27162795 }
27172796 # If a new version is entered, we need to be sure to update the folder for writing manifests
27182797 $LastVersion = $PromptVersion
2719- $script :AppFolder = Join-Path (Split-Path $AppFolder ) - ChildPath $LastVersion
27202798 $script :PackageVersion = $LastVersion
27212799 }
27222800}
27232801
27242802# If the user selected `QuickUpdateVersion`, the old manifests must exist
27252803# If the user selected `New`, the old manifest type is specified as none
2726- if (-not (Test-Path - Path " $AppFolder \.." )) {
2804+ if (-not (Test-Path - Path " $AppFolder \.." ) -and -not ( Test-Path - Path " $FontFolder \.. " ) ) {
27272805 if ($script :Option -in @ (' QuickUpdateVersion' , ' Auto' )) {
27282806 Write-Host - ForegroundColor Red ' This option requires manifest of previous version of the package. If you want to create a new package, please select Option 1.'
27292807 Invoke-CleanExit
0 commit comments