-
Notifications
You must be signed in to change notification settings - Fork 1
/
commands.ps1
98 lines (88 loc) · 3.66 KB
/
commands.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
param([string]$type, [string]$Configuration = "Release")
$ErrorActionPreferenceOld = $ErrorActionPreference;
$ErrorActionPreference = "Stop";
$DeployPath = $type -eq "build-dev" ? "vortex_devel/plugins" : "vortex/plugins"
$type = $type -eq "build-dev" ? "build" : $type;
try {
# Clean
if ($type -eq "build" -or $type -eq "build-extended" -or $type -eq "build-update" -or $type -eq "clear") {
Write-Host "Clean";
Remove-Item *.tgz, *.7z, dist -Recurse -Force -ErrorAction Ignore;
}
# Update @butr/vortexextensionnative from File
if ($type -eq "build-extended") {
Write-Host "Updating @butr/vortexextensionnative from File";
$ExtensionBasePath = "../Bannerlord.LauncherManager";
$ExtensionPath = "$ExtensionBasePath/src/Bannerlord.LauncherManager.Native.TypeScript";
Invoke-Command -ScriptBlock {
npm remove @butr/vortexextensionnative;
}
Push-Location "$ExtensionPath";
try {
Invoke-Command -ScriptBlock {
npm run clean;
npm run build -- $Configuration;
npm pack;
}
}
catch {
exit;
}
finally {
Pop-Location;
Copy-Item -Path "$ExtensionPath\butr-vortexextensionnative-1.0.0.tgz" -Destination $ThisPath;
Invoke-Command -ScriptBlock {
npm i ./butr-vortexextensionnative-1.0.0.tgz;
}
}
}
# Update @butr/vortexextensionnative from NPM
if ($type -eq "build-update") {
Write-Host "Updating @butr/vortexextensionnative from NPM";
Invoke-Command -ScriptBlock {
npx tsc -p tsconfig.json;
npx tsc -p tsconfig.module.json;
}
}
# Webpack
if ($type -eq "build" -or $type -eq "build-extended" -or $type -eq "build-update" -or $type -eq "build-webpack") {
Write-Host "Webpack";
Invoke-Command -ScriptBlock {
npx webpack --config webpack.config.js --color;
npx extractInfo;
}
}
# 7z
if ($type -eq "build" -or $type -eq "build-extended" -or $type -eq "build-update" -or $type -eq "build-7z") {
Write-Host "Pack 7z";
Invoke-Command -ScriptBlock {
7z a -t7z "game-mount-and-blade2.7z" "./dist/*.*";
}
}
# Copy to Vortex if available
if ($type -eq "build" -or $type -eq "build-extended" -or $type -eq "build-update" -or $type -eq "build-webpack" -or $type -eq "build-7z") {
# TODO: On linux won't work
try {
if (-not (Test-Path -Path "/vortex-plugins")) {
# Create a folder junction named /vortex-plugins pointing to %appdata%/vortex_devel/plugins
$appDataPath = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::ApplicationData)
$junctionPath = "/vortex-plugins"
$targetPath = Join-Path $appDataPath $DeployPath
if (-not (Test-Path $junctionPath -PathType Container)) {
New-Item -ItemType Junction -Path $junctionPath -Target $targetPath
Write-Host "Created folder junction at $junctionPath pointing to $targetPath"
} else {
Write-Host "Folder junction already exists at $junctionPath"
}
}
Write-Host "Copy dist to Vortex plugins mount";
Remove-Item "/vortex-plugins/bannerlord" -Recurse -Force -ErrorAction Ignore;
Copy-Item "./dist" -Destination "/vortex-plugins/bannerlord" -Recurse;
}
catch {
}
}
}
finally {
$ErrorActionPreference = $ErrorActionPreferenceOld;
}