-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScoop-Bucket-Utils.ps1
93 lines (84 loc) · 3.01 KB
/
Scoop-Bucket-Utils.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<#
.SYNOPSIS
Utilities to assist with developing a scoop bucket.
.DESCRIPTION
Wrapper for built-in scoop utilities.
.NOTES
Information or caveats about the function e.g. 'This function is not supported in Linux'
.LINK
See tool sources at https://github.com/ScoopInstaller/Scoop/tree/master/bin
.EXAMPLE
./Scoop-Bucket-Utils.ps1 -Utility CheckHashes,CheckUrls,CheckVer,FormatJson,MissingCheckVer -App cemu
Runs several utilities on 'cemu' manifest.
.EXAMPLE
./Scoop-Bucket-Utils.ps1 -Utility CheckVer
Checks for updated versions of apps in manifests. Updates manifest(s) if needed.
.EXAMPLE
./Scoop-Bucket-Utils.ps1 -Utility Tests
Run manifest tests on all manifests in this folder.
#>
param(
# CheckHashes - Check if ALL urls inside manifest have correct hashes.
# CheckUrls - List manifests which do not have valid URLs.
# CheckVer - Check manifest for a newer version.
# Describe - Retrieve description from website's metadata.
# FormatJson - Format manifest.
# MissingCheckVer - Check if manifest contains checkver and autoupdate property.
# Tests - Run manifest tests.
[Parameter(Mandatory)]
[ValidateSet('CheckHashes','CheckUrls','CheckVer','Describe','FormatJson','MissingCheckVer','Tests')]
[string[]]$Utility,
# App to check (optional).
[string]$App,
# Directory containing manifests.
[string]$Dir = './bucket'
)
if (!$env:SCOOP_HOME) {
$env:SCOOP_HOME = Resolve-Path (scoop.ps1 prefix scoop)
}
foreach ($UtilityName in $Utility) {
"Running $UtilityName ..."
''
$UtilityNameArguments = @{ 'Dir' = $Dir }
if ($App) { $UtilityNameArguments += @{ 'App' = $App } }
switch ($UtilityName) {
'CheckHashes' {
# "-Update": update mismatched hashes.
. "$env:SCOOP_HOME/bin/checkhashes.ps1" -Update @UtilityNameArguments
}
'CheckUrls' {
. "$env:SCOOP_HOME/bin/checkurls.ps1" @UtilityNameArguments
}
'CheckVer' {
# "-Update": update given manifest.
. "$env:SCOOP_HOME/bin/checkver.ps1" -Update @UtilityNameArguments
}
'Describe' {
# Get-ChildItem $Dir -Filter '*.json' -File `
# | ForEach-Object {
# $d=Get-Content $_ | ConvertFrom-Json | Select-Object -ExpandProperty description
# "$($_.BaseName):"
# Write-Host -ForegroundColor Green " $d" }
# ''
. "$env:SCOOP_HOME/bin/describe.ps1" @UtilityNameArguments
}
'FormatJson' {
. "$env:SCOOP_HOME/bin/formatjson.ps1" @UtilityNameArguments
}
'MissingCheckVer' {
. "$env:SCOOP_HOME/bin/missing-checkver.ps1" @UtilityNameArguments
}
'Tests' {
# First, remove the built-in (old) version of Pester:
#
# $module = "C:\Program Files\WindowsPowerShell\Modules\Pester"
# & takeown.exe /F $module /A /R
# & icacls.exe $module /reset
# & icacls.exe $module /grant "*S-1-5-32-544:F" /inheritance:d /T
# Remove-Item -Path $module -Recurse -Force -Confirm:$false
. "$env:SCOOP_HOME/test/Import-Bucket-Tests.ps1" -BucketPath './bucket'
}
}
''
'Done.'
}