-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathlazymoderation.ps1
More file actions
76 lines (62 loc) · 1.99 KB
/
lazymoderation.ps1
File metadata and controls
76 lines (62 loc) · 1.99 KB
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
[cmdletbinding()]
param(
[Parameter(Mandatory = $false)]
[AllowEmptyString()]
[string] $DiffTool,
[Parameter(Mandatory = $false)]
[int]$ModQueuePage = 1
)
Import-Module (Join-Path $PSScriptRoot "../chocolatey-diff/chocolatey-diff.psm1")
$packageBaseUri = "https://community.chocolatey.org/packages"
$queueUri = "$packageBaseUri/?q=&moderatorQueue=true&moderationStatus=ready-status&prerelease=false&sortOrder=package-download-count&page=$ModQueuePage"
$pkgsMatcher = [regex]"href\s*=\s*[`"|']\/packages\/(.+)\/(\d.+)#status[`"|']"
$htmlData = (Invoke-WebRequest -Uri $queueUri -UseBasicParsing).Content
$packages = $pkgsMatcher.Matches($htmlData) | Foreach-Object {
$id = $_.Groups[1]
$version = $_.Groups[2]
@{
id = $id
version = $version
uri = "{0}/{1}/{2}" -f $packageBaseUri, $id, $version
}
}
$useDiffTool = ("" -ne $DiffTool)
if ($useDiffTool) {
$env:difftool = $DiffTool
}
$packageIgnoreList = @()
foreach ($pkg in $packages) {
"`n === {0} === " -f $pkg.id
if ($packageIgnoreList -contains [string]$pkg.id) {
" {0} is on ignore list -> NEXT!" -f $pkg.id
continue;
}
$sel = Read-Host " (s) .. skip | (i) .. ignore | other .. let's do this!`nyour choice"
if ("s" -eq $sel) {
" SKIP! "
continue;
} elseif ("i" -eq $sel) {
" ... ignore pkg id {0}" -f $pkg.id
$packageIgnoreList += [string]$pkg.id
continue;
}
try {
$dArgs = @{
PackageName = $pkg.id
NewPackageVersion = $pkg.version
Verbose = $VerbosePreference
}
if ($useDiffTool) {
$dArgs.useDiffTool = $useDiffTool
$dArgs.CompareFolder = $true
}
$diffObj = Get-ChocolateyPackageDiff @dArgs
if (-not $useDiffTool) {
$diffObj
}
} catch {
$_.Exception.Message
}
" url: {0} " -f $pkg.uri
Read-Host "press key to continue with next package..."
}