-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreate-Layout.ps1
40 lines (31 loc) · 1.13 KB
/
Create-Layout.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
foreach($mod in @('tbm930-improvements')) {
Set-Location $mod
# Get all files (and only files) in mod dir, excluding layout.json and manifest.json
$files = Get-ChildItem "." -Recurse -Attributes !Directory -Exclude "layout.json", "manifest.json"
# Create basic JSON structure
$json = @{
"content" = @()
}
# Resolve the relative path of all files
$files = Resolve-Path -Relative $files
# Stores the sum of the size of all files in the project
$total_file_size = 0
foreach ($file in $files) {
# Create the correct structure
$entry = @{
"path" = $file.Replace(".\", "").Replace("\", "/")
"size" = (Get-ItemProperty $file).Length
"date" = (Get-ItemProperty $file).LastWriteTime.ToFileTime()
}
$json["content"] += $entry
$total_file_size += (Get-ItemProperty $file).Length
}
# Convert to JSON and output in layout.json
$json | ConvertTo-Json > layout.json
if (Test-Path "./manifest.json") {
$manifest = (Get-Content "manifest.json" | ConvertFrom-Json)
$manifest.total_package_size = $total_file_size.ToString().PadLeft(20,'0')
$manifest | ConvertTo-Json > manifest.json
}
Set-Location ..
}