-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_new_gameslib.ps1
39 lines (28 loc) · 1.31 KB
/
install_new_gameslib.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
# Running this script will build, pack and install a new local version of the gameslib package from disc (assumed to be at ../gameslib). It assumes the renderer library didn't change.
$versionStrings = npm cache ls | Select-String '\\gameslib\\abstractplay-gameslib-[0-9]+\.[0-9]+\.([0-9]+)(-beta)?\.tgz' -AllMatches
# Convert the matches to integers
$versions = $versionStrings.Matches | ForEach-Object { [int]$_.Groups[1].Value }
# Find the maximum plus one.
$maxNumber = ($versions | Measure-Object -Maximum).Maximum + 1
$NEW_VERSION = "1.0." + $maxNumber
Write-Output "The new version is: $NEW_VERSION"
# Save the current directory
$CURRENT_DIR = Get-Location
# Define the path to your package
$PACKAGE_PATH = "../gameslib"
# Change to the package directory
Set-Location $PACKAGE_PATH
# Update the version number in the package.json file
npm version $NEW_VERSION --no-git-tag-version
# Package the library into a .tgz file
npm run build
if ($LASTEXITCODE -ne 0) {
Set-Location $CURRENT_DIR
throw "npm run build failed in gameslib!"
}
# Save the path to the .tgz file
$PACKAGE_TGZ_PATH = "${PACKAGE_PATH}\abstractplay-gameslib-${NEW_VERSION}.tgz"
# Change back to the original directory
Set-Location $CURRENT_DIR
# Install the package
npm install $PACKAGE_TGZ_PATH --loglevel verbose