forked from goatcorp/DalamudPlugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Make-PluginMaster.ps1
124 lines (93 loc) · 4.9 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
$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
$dlTemplateInstall = "https://us-central1-xl-functions.cloudfunctions.net/download-plugin/?plugin={0}&isUpdate=False&isTesting={1}&branch=master"
$dlTemplateUpdate = "https://raw.githubusercontent.com/goatcorp/DalamudPlugins/master/{0}/{1}/latest.zip"
$apiLevel = 3
$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 -Name "IsHide" -value "True" -MemberType NoteProperty
}
else
{
$content | add-member -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 -Name "TestingAssemblyVersion" -value $testingContent.AssemblyVersion -MemberType NoteProperty
}
$content | add-member -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 -Name "DownloadCount" $dlCount -MemberType NoteProperty
$internalName = $content.InternalName
$updateDate = git log -1 --pretty="format:%ct" plugins/$internalName/latest.zip
if ($updateDate -eq $null){
$updateDate = 0;
}
$content | add-member -Name "LastUpdate" $updateDate -MemberType NoteProperty
$installLink = $dlTemplateInstall -f $internalName, "False"
$content | add-member -Name "DownloadLinkInstall" $installLink -MemberType NoteProperty
$installLink = $dlTemplateInstall -f $internalName, "True"
$content | add-member -Name "DownloadLinkTesting" $installLink -MemberType NoteProperty
$updateLink = $dlTemplateUpdate -f "plugins", $internalName
$content | add-member -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 -Name "IsHide" -value "True" -MemberType NoteProperty
}
else
{
$content | add-member -Name "IsHide" -value "False" -MemberType NoteProperty
# $table = $table + "| " + $content.Author + " | " + $content.Name + " | " + $content.Description + " |`n"
}
$dlCount = 0;
$content | add-member -Name "DownloadCount" $dlCount -MemberType NoteProperty
if (($output | Where-Object {$_.InternalName -eq $content.InternalName}).Count -eq 0)
{
$content | add-member -Name "TestingAssemblyVersion" -value $content.AssemblyVersion -MemberType NoteProperty
$content | add-member -Name "IsTestingExclusive" -value "True" -MemberType NoteProperty
$internalName = $content.InternalName
$updateDate = git log -1 --pretty="format:%ct" testing/$internalName/latest.zip
if ($updateDate -eq $null){
$updateDate = 0;
}
$content | add-member -Name "LastUpdate" $updateDate -MemberType NoteProperty
$installLink = $dlTemplateInstall -f $internalName, "True"
$content | add-member -Name "DownloadLinkInstall" $installLink -MemberType NoteProperty
$installLink = $dlTemplateInstall -f $internalName, "True"
$content | add-member -Name "DownloadLinkTesting" $installLink -MemberType NoteProperty
$updateLink = $dlTemplateUpdate -f "testing", $internalName
$content | add-member -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