This repository has been archived by the owner on Aug 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 167
/
Make-PluginMaster.ps1
171 lines (134 loc) · 6.54 KB
/
Make-PluginMaster.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
$ErrorActionPreference = 'SilentlyContinue'
$output = New-Object Collections.Generic.List[object]
$notInclude = "sdgfdsgfgdfs", "sdfgdfg", "XIVStats", "bffbbf", "VoidList", "asdfsad", "sdfgdfsg", "vrgnddgv";
$counts = Get-Content "downloadcounts.json" | ConvertFrom-Json
$categoryFallbacksMap = Get-Content "categoryfallbacks.json" | ConvertFrom-Json
$pluginBlacklistUrl = "https://goatcorp.github.io/DalamudAssets/UIRes/bannedplugin.json"
$wc = New-Object system.Net.WebClient
$blackList = $wc.downloadString($pluginBlacklistUrl) | ConvertFrom-Json
$dlTemplateInstall = "https://kamori.goats.dev/Plugin/Download/{0}?isUpdate=False&isTesting={1}&branch=api6"
$dlTemplateUpdate = "https://raw.githubusercontent.com/goatcorp/DalamudPlugins/api6/{0}/{1}/latest.zip"
$apiLevel = 6
$thisPath = Get-Location
$table = ""
function Is-Banned {
param (
$PluginName,
$AssemblyVersion
)
foreach ($blackItem in $blackList) {
if ($blackItem.Name -eq $PluginName) {
if ([System.Version]$blackItem.AssemblyVersion -ge [System.Version]$AssemblyVersion) {
return $true
}
}
}
return $false
}
Get-ChildItem -Path plugins -File -Recurse -Include *.json |
Foreach-Object {
$content = Get-Content $_.FullName | ConvertFrom-Json
$isBanned = Is-Banned -PluginName $content.InternalName -AssemblyVersion $content.AssemblyVersion
if ($notInclude.Contains($content.InternalName) -or $isBanned) {
$content | add-member -Force -Name "IsHide" -value "True" -MemberType NoteProperty
}
else
{
$content | add-member -Force -Name "IsHide" -value "False" -MemberType NoteProperty
$newDesc = $content.Description -replace "\n", "<br>"
$newDesc = $newDesc -replace "\|", "I"
if ($content.DalamudApiLevel -eq $apiLevel) {
if ($content.RepoUrl) {
$table = $table + "| " + $content.Author + " | [" + $content.Name + "](" + $content.RepoUrl + ") | " + $newDesc + " |`n"
}
else {
$table = $table + "| " + $content.Author + " | " + $content.Name + " | " + $newDesc + " |`n"
}
}
}
$testingPath = Join-Path $thisPath -ChildPath "testing" | Join-Path -ChildPath $content.InternalName | Join-Path -ChildPath $_.Name
if ($testingPath | Test-Path)
{
$testingContent = Get-Content $testingPath | ConvertFrom-Json
$content | add-member -Force -Name "TestingAssemblyVersion" -value $testingContent.AssemblyVersion -MemberType NoteProperty
}
$content | add-member -Force -Name "IsTestingExclusive" -value "False" -MemberType NoteProperty
$dlCount = $counts | Select-Object -ExpandProperty $content.InternalName
if ($dlCount -eq $null){
$dlCount = 0;
}
$content | add-member -Force -Name "DownloadCount" $dlCount -MemberType NoteProperty
if ($content.CategoryTags -eq $null) {
$fallbackCategoryTags = $categoryFallbacksMap | Select-Object -ExpandProperty $content.InternalName
if ($fallbackCategoryTags -ne $null) {
$content | add-member -Force -Name "CategoryTags" -value @() -MemberType NoteProperty
$content.CategoryTags += $fallbackCategoryTags
}
}
$internalName = $content.InternalName
$path = "plugins/$internalName/latest.zip"
if (!($path | Test-Path)) {
exit 1;
}
$updateDate = git log -1 --pretty="format:%ct" $path
if ($updateDate -eq $null){
$updateDate = 0;
}
$content | add-member -Force -Name "LastUpdate" $updateDate -MemberType NoteProperty
$installLink = $dlTemplateInstall -f $internalName, "False"
$content | add-member -Force -Name "DownloadLinkInstall" $installLink -MemberType NoteProperty
$installLink = $dlTemplateInstall -f $internalName, "True"
$content | add-member -Force -Name "DownloadLinkTesting" $installLink -MemberType NoteProperty
$updateLink = $dlTemplateUpdate -f "plugins", $internalName
$content | add-member -Force -Name "DownloadLinkUpdate" $updateLink -MemberType NoteProperty
$output.Add($content)
}
Get-ChildItem -Path testing -File -Recurse -Include *.json |
Foreach-Object {
$content = Get-Content $_.FullName | ConvertFrom-Json
$isBanned = Is-Banned -PluginName $content.InternalName -AssemblyVersion $content.AssemblyVersion
if ($notInclude.Contains($content.InternalName) -or $isBanned) {
$content | add-member -Force -Name "IsHide" -value "True" -MemberType NoteProperty
}
else
{
$content | add-member -Force -Name "IsHide" -value "False" -MemberType NoteProperty
# $table = $table + "| " + $content.Author + " | " + $content.Name + " | " + $content.Description + " |`n"
}
$dlCount = 0;
$content | add-member -Force -Name "DownloadCount" $dlCount -MemberType NoteProperty
if (($output | Where-Object {$_.InternalName -eq $content.InternalName}).Count -eq 0)
{
$content | add-member -Force -Name "TestingAssemblyVersion" -value $content.AssemblyVersion -MemberType NoteProperty
$content | add-member -Force -Name "IsTestingExclusive" -value "True" -MemberType NoteProperty
if ($content.CategoryTags -eq $null) {
$fallbackCategoryTags = $categoryFallbacksMap | Select-Object -ExpandProperty $content.InternalName
if ($fallbackCategoryTags -ne $null) {
$content | add-member -Force -Name "CategoryTags" -value @() -MemberType NoteProperty
$content.CategoryTags += $fallbackCategoryTags
}
}
$internalName = $content.InternalName
$path = "testing/$internalName/latest.zip"
if (!($path | Test-Path)) {
exit 1;
}
$updateDate = git log -1 --pretty="format:%ct" $path
if ($updateDate -eq $null){
$updateDate = 0;
}
$content | add-member -Force -Name "LastUpdate" $updateDate -MemberType NoteProperty
$installLink = $dlTemplateInstall -f $internalName, "True"
$content | add-member -Force -Name "DownloadLinkInstall" $installLink -MemberType NoteProperty
$installLink = $dlTemplateInstall -f $internalName, "True"
$content | add-member -Force -Name "DownloadLinkTesting" $installLink -MemberType NoteProperty
$updateLink = $dlTemplateUpdate -f "plugins", $internalName
$content | add-member -Force -Name "DownloadLinkUpdate" $updateLink -MemberType NoteProperty
$output.Add($content)
}
}
$outputStr = $output | ConvertTo-Json
Out-File -FilePath .\pluginmaster.json -InputObject $outputStr
$template = Get-Content -Path mdtemplate.txt
$template = $template + $table
Out-File -FilePath .\plugins.md -InputObject $template