forked from goatcorp/DalamudPlugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Make-PluginMaster.ps1
145 lines (110 loc) · 5.91 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
$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
$dlTemplateInstall = "https://us-central1-xl-functions.cloudfunctions.net/download-plugin/?plugin={0}&isUpdate=False&isTesting={1}&branch=api5"
$dlTemplateUpdate = "https://raw.githubusercontent.com/goatcorp/DalamudPlugins/api5/{0}/{1}/latest.zip"
$apiLevel = 4
$thisPath = Get-Location
$table = ""
Get-ChildItem -Path plugins -File -Recurse -Include *.json |
Foreach-Object {
$content = Get-Content $_.FullName | ConvertFrom-Json
if ($notInclude.Contains($content.InternalName)) {
$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 | Select-Object -ExpandProperty "count"
if ($dlCount -eq $null){
$dlCount = 0;
}
$content | add-member -Force -Name "DownloadCount" $dlCount -MemberType NoteProperty
if ($content.CategoryTags -eq $null) {
$content | Select-Object -Property * -ExcludeProperty CategoryTags
$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
$updateDate = git log -1 --pretty="format:%ct" plugins/$internalName/latest.zip
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
if ($notInclude.Contains($content.InternalName)) {
$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) {
$content | Select-Object -Property * -ExcludeProperty CategoryTags
$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
$updateDate = git log -1 --pretty="format:%ct" testing/$internalName/latest.zip
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
Write-Output $outputStr
Out-File -FilePath .\pluginmaster.json -InputObject $outputStr
$template = Get-Content -Path mdtemplate.txt
$template = $template + $table
Out-File -FilePath .\plugins.md -InputObject $template