Skip to content

Commit

Permalink
Change Settings to allow for negative suppression (#46)
Browse files Browse the repository at this point in the history
* Change Settings to allow for negative suppression

* Fix sample settings file

* Invalid SandboxTest variable

Co-authored-by: Vedant Mohan Goyal <[email protected]>

Co-authored-by: Kaleb Luedtke <[email protected]>
Co-authored-by: Esco <[email protected]>
Co-authored-by: Vedant Mohan Goyal <[email protected]>
  • Loading branch information
4 people committed Sep 27, 2021
1 parent 49e8454 commit 98fbca5
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 44 deletions.
81 changes: 47 additions & 34 deletions Tools/YamlCreate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ Function Read-WinGet-InstallerValues {
# Get or request Installer Sha256
# Check the settings to see if we need to display this menu
switch ($ScriptSettings.SaveToTemporaryFolder) {
'true' { $script:SaveOption = '0' }
'false' { $script:SaveOption = '1' }
'always' { $script:SaveOption = '0' }
'never' { $script:SaveOption = '1' }
'manual' { $script:SaveOption = '2' }
default {
$_menu = @{
Expand Down Expand Up @@ -514,12 +514,17 @@ Function Read-WinGet-InstallerValues {
# If user selected to find automatically -
# Install package, get family name, uninstall package
if ($ChoicePfn -eq '0') {
Add-AppxPackage -Path $script:dest
$InstalledPkg = Get-AppxPackage | Select-Object -Last 1 | Select-Object PackageFamilyName, PackageFullName
$PackageFamilyName = $InstalledPkg.PackageFamilyName
Remove-AppxPackage $InstalledPkg.PackageFullName
if (String.Validate $PackageFamilyName -IsNull) {
$script:_returnValue = [ReturnValue]::new(500, 'Could not find PackageFamilyName', 'Value should be entered manually', 1)
try {
Add-AppxPackage -Path $script:dest
$InstalledPkg = Get-AppxPackage | Select-Object -Last 1 | Select-Object PackageFamilyName, PackageFullName
$PackageFamilyName = $InstalledPkg.PackageFamilyName
Remove-AppxPackage $InstalledPkg.PackageFullName
} catch {
Out-Null
} finally {
if (String.Validate $PackageFamilyName -IsNull) {
$script:_returnValue = [ReturnValue]::new(500, 'Could not find PackageFamilyName', 'Value should be entered manually', 1)
}
}
}

Expand Down Expand Up @@ -711,8 +716,8 @@ Function Read-WinGet-InstallerValues-Minimal {
# Get or request Installer Sha256
# Check the settings to see if we need to display this menu
switch ($ScriptSettings.SaveToTemporaryFolder) {
'true' { $script:SaveOption = '0' }
'false' { $script:SaveOption = '1' }
'always' { $script:SaveOption = '0' }
'never' { $script:SaveOption = '1' }
'manual' { $script:SaveOption = '2' }
default {
$_menu = @{
Expand Down Expand Up @@ -1543,8 +1548,8 @@ Function Write-WinGet-InstallerManifest-Yaml {
$_FirstInstallerKeyValue = ConvertTo-Json($InstallerManifest.Installers[0].$_Key)
foreach ($_Installer in $InstallerManifest.Installers) {
$_CurrentInstallerKeyValue = ConvertTo-Json($_Installer.$_Key)
if (String.Validate $_CurrentInstallerKeyValue -IsNull) {$_AllAreSame = $false}
else {$_AllAreSame = $_AllAreSame -and (@(Compare-Object $_CurrentInstallerKeyValue $_FirstInstallerKeyValue).Length -eq 0)}
if (String.Validate $_CurrentInstallerKeyValue -IsNull) { $_AllAreSame = $false }
else { $_AllAreSame = $_AllAreSame -and (@(Compare-Object $_CurrentInstallerKeyValue $_FirstInstallerKeyValue).Length -eq 0) }
}
# If all installers are the same move the key to the manifest level
if ($_AllAreSame) {
Expand Down Expand Up @@ -1950,20 +1955,22 @@ if ($script:Option -ne 'RemoveManifest') {
# If the user has sandbox enabled, request to test the manifest in the sandbox
if (Get-Command 'WindowsSandbox.exe' -ErrorAction SilentlyContinue) {
# Check the settings to see if we need to display this menu
if ($ScriptSettings.AlwaysTestManifests -eq 'true') {
$script:SandboxTest = '0'
} else {
$_menu = @{
entries = @('*[Y] Yes'; '[N] No')
Prompt = '[Recommended] Do you want to test your Manifest in Windows Sandbox?'
DefaultString = 'Y'
}
switch ( KeypressMenu -Prompt $_menu['Prompt'] -Entries $_menu['Entries'] -DefaultString $_menu['DefaultString']) {
'Y' { $script:SandboxTest = '0' }
'N' { $script:SandboxTest = '1' }
default { $script:SandboxTest = '0' }
switch ($ScriptSettings.TestManifestsInSandbox) {
'always' { $script:SandboxTest = '0' }
'never' { $script:SandboxTest = '1' }
default {
$_menu = @{
entries = @('*[Y] Yes'; '[N] No')
Prompt = '[Recommended] Do you want to test your Manifest in Windows Sandbox?'
DefaultString = 'Y'
}
switch ( KeypressMenu -Prompt $_menu['Prompt'] -Entries $_menu['Entries'] -DefaultString $_menu['DefaultString']) {
'Y' { $script:SandboxTest = '0' }
'N' { $script:SandboxTest = '1' }
default { $script:SandboxTest = '0' }
}
Write-Host
}
Write-Host
}
if ($script:SandboxTest -eq '0') {
if (Test-Path -Path "$PSScriptRoot\SandboxTest.ps1") {
Expand All @@ -1981,15 +1988,21 @@ if ($script:Option -ne 'RemoveManifest') {
}
# If the user has git installed, request to automatically submit the PR
if (Get-Command 'git.exe' -ErrorAction SilentlyContinue) {
$_menu = @{
entries = @('*[Y] Yes'; '[N] No')
Prompt = 'Do you want to submit your PR now?'
DefaultString = 'Y'
}
switch ( KeypressMenu -Prompt $_menu['Prompt'] -Entries $_menu['Entries'] -DefaultString $_menu['DefaultString']) {
'Y' { $PromptSubmit = '0' }
'N' { $PromptSubmit = '1' }
default { $PromptSubmit = '0' }
switch ($ScriptSettings.AutoSubmitPRs) {
'always' { $PromptSubmit = '0' }
'never' { $PromptSubmit = '1' }
default {
$_menu = @{
entries = @('*[Y] Yes'; '[N] No')
Prompt = 'Do you want to submit your PR now?'
DefaultString = 'Y'
}
switch ( KeypressMenu -Prompt $_menu['Prompt'] -Entries $_menu['Entries'] -DefaultString $_menu['DefaultString']) {
'Y' { $PromptSubmit = '0' }
'N' { $PromptSubmit = '1' }
default { $PromptSubmit = '0' }
}
}
}
}
Write-Host
Expand Down
26 changes: 16 additions & 10 deletions doc/tools/YamlCreate.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,21 @@ If you have Git installed, you can also create the pull request for your manifes
# YamlCreate Settings
YamlCreate offers a few settings to customize your manifest creation experience. The settings file is found in your local appdata folder under `YamlCreate`. It is empty by default, but you can copy the sample below which describes what all of the available options are; or, you can enter just specific keys as you see fit.
```yaml
# This setting allows you to skip the prompt to test your manifest in windows sandbox
# If this value is set to true, all manifests will be tested by default
AlwaysTestManifests: false

# This setting allows you to set a default installer locale
# Any value defined here will be set as the installer locale if one is not entered
DefaultInstallerLocale: en-US
# This setting allows you to set a default action for whether or not to test your manifest in windows sandbox
# always - Always tests manifests
# never - Never tests manifests
TestManifestsInSandbox: ask

# This setting allows you to define a default action for whether or not to save files to the temprorary folder
# true - Always saves files to the temporary folder
# false - Always removes the files from the temporary folder after secript excecution
# always - Always saves files to the temporary folder
# never - Always removes the files from the temporary folder after secript excecution
# manual - Never downloads any files. All InstallerSha256 values must be entered manually
SaveToTemporaryFolder: false
SaveToTemporaryFolder: ask

# This setting allows you to set a default action for whether or not to submit PR's
# always - Always submits PR's automatically
# never - Never submits PR's automatically
AutoSubmitPRs: ask

# This setting allows you to set a default value for whether or not you have signed the Microsoft CLA
# If this value is set to true, all automatic PR's will be marked as having the CLA signed
Expand All @@ -40,4 +42,8 @@ SignedCLA: false
# This setting allows you to skip the prompt to confirm you want to use quick update mode
# If this value is set to true, the Quick Update Warning will be skipped
SuppressQuickUpdateWarning: false

# This setting allows you to set a default installer locale
# Any value defined here will be set as the installer locale if one is not entered
DefaultInstallerLocale: en-US
```

0 comments on commit 98fbca5

Please sign in to comment.