-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path.packager.ps1
71 lines (54 loc) · 1.33 KB
/
.packager.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
Set-Location $PSScriptRoot
if (-Not (Test-Path "C:\PROGRA~1\7-Zip\7z.exe")) {
Write-Host "7z.exe not found"
return Read-Host
}
Set-Alias 7z "C:\PROGRA~1\7-Zip\7z.exe"
$name = (Get-Item .).Name
if (-Not (Test-Path (".\" + $name + ".toc"))) {
Write-Host ".toc not found"
return Read-Host
}
if (Get-Content (".\" + $name + ".toc") | Where-Object { $_ -match "Version:\s*([a-zA-Z0-9.-]+)" }) {
$version = $matches[1]
} else {
Write-Host "Bad version format"
return Read-Host
}
$includedItems = @(
".\init.lua",
".\LICENSE.txt",
".\ls_UI.toc",
".\assets\",
".\config\",
".\core\",
".\embeds\",
".\locales\",
".\modules\"
)
$filesToRemove = @(
"*.doc*"
"*.editorconfig",
"*.git*",
"*.luacheck*",
"*.pkg*",
"*.ps1",
"*.yml",
"CHANGELOG*",
"README*"
)
$foldersToRemove = @(
".\temp\ls_UI\embeds\oUF\utils"
)
if (Test-Path ".\temp\") {
Remove-Item ".\temp\" -Recurse -Force
}
New-Item -Path (".\temp\" + $name) -ItemType Directory | Out-Null
Copy-Item $includedItems -Destination (".\temp\" + $name) -Recurse
Remove-Item ".\temp" -Include $filesToRemove -Recurse -Force
Remove-Item $foldersToRemove -Recurse -Force
Set-Location ".\temp\"
7z a -tzip -mx9 ($name + "-" + $version + ".zip") (Get-ChildItem -Path "..\temp")
Set-Location "..\"
Move-Item ".\temp\*.zip" -Destination "..\" -Force
Remove-Item ".\temp" -Recurse -Force