mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-07 03:01:56 -04:00

# Conflicts: # scripts/Build-NWJS.ps1 Former-commit-id: a015d626c29a79a6d0fc3b0690c617ef5c8ddabc [formerly bf31d9708702a709ffc3151d401d3e61855ce5c2] [formerly a81f7c492a2c0ceb1a8cd2f5aaee151a88915783] [formerly db857c3ac31874b9dbb379e6732d3a7081e9773b [formerly 6af903ce51a28167279050a344ffc0211af534b7 [formerly 8c27c6ba51043b574a17c6041d4917851d351083]]] Former-commit-id: babe850ffee6d362d7df16c9f8c821491cbab85d [formerly 7d827efa6393e1452cfa0a6f5ffd1ed6cabdacbf [formerly 2d94d1677a35b76ad0e79c7a269cb8c8e5c4ac18]] Former-commit-id: f8fdfefa9dfb3560357a2fe4ce948597f8a0dcbf [formerly e337f78e0cabca5dbfcd91043429ada135c1d9c2] Former-commit-id: 505cfa12ed0d7925f96b6631c3c75f5451dce1dc
83 lines
3.4 KiB
PowerShell
83 lines
3.4 KiB
PowerShell
param (
|
|
[switch]$only32bit = $false
|
|
)
|
|
$builds = @("win-ia32", "win-xp")
|
|
if (-Not $only32bit) {
|
|
$builds += "win-x64"
|
|
"Caller requested 32bit and 64bit build"
|
|
} else {
|
|
"Caller requested 32bitonly build"
|
|
}
|
|
$version10 = "0.54.0" # <<< value updated automatically from package.json if launched from Create-DraftRelease
|
|
$versionXP = "0.14.7"
|
|
$appBuild = "1.6.0N" # <<< value updated auotmatically from package.json if launched form Create-DraftRelease
|
|
$ZIMbase = "wikipedia_en_100_maxi"
|
|
foreach ($build in $builds) {
|
|
$version = $version10
|
|
$OBuild = $build
|
|
$sep = '-'
|
|
if ($build -eq "win-xp") {
|
|
$build = "win-ia32"
|
|
$version = $versionXP
|
|
$sep = '-XP-'
|
|
}
|
|
"`nBuilding $build $version..."
|
|
$folderTarget = "$PSScriptRoot\..\bld\nwjs\$build-$version"
|
|
$target = "$folderTarget\kiwix_js_windows$sep$appBuild"
|
|
$fullTarget = "$target-$build"
|
|
$ZipLocation = "$PSScriptRoot\..\node_modules\nwjs-builder-phoenix\caches\nwjs-v$version-$build.zip"
|
|
$UnzipLocation = "$ZipLocation-extracted\"
|
|
$buildLocation = "$ZipLocation-extracted\nwjs-v$version-$build\"
|
|
if (-Not (Test-Path $buildLocation -PathType Container)) {
|
|
# We need to download and/or unzip the release, as it is not available
|
|
if (-Not (Test-Path $ZipLocation -PathType Leaf)) {
|
|
$serverFile = "https://dl.nwjs.io/v$version/nwjs-v$version-$build.zip"
|
|
"Downloading $serverFile"
|
|
Invoke-WebRequest -Uri $serverFile -OutFile $ZipLocation
|
|
}
|
|
"Unzipping archive $ZipLocation"
|
|
Expand-Archive $ZipLocation $UnzipLocation
|
|
if (-Not (Test-Path $buildLocation -PathType Container)) {
|
|
"There was an error! The unzipped folder $buildLocation could not be found!"
|
|
return
|
|
}
|
|
}
|
|
$archiveFolder = "$fullTarget\archives"
|
|
if (Test-Path $folderTarget -PathType Container) {
|
|
"Removing directory $folderTarget..."
|
|
rm $folderTarget\* -Recurse
|
|
rm $folderTarget
|
|
}
|
|
md $fullTarget
|
|
# Copy latest binary x64
|
|
cp $buildLocation\* $fullTarget -Recurse
|
|
$root = $PSScriptRoot -replace 'scripts.*$', ''
|
|
cp $root\package.json, $root\pwabuilder-sw.js, $root\index.html, $root\CHANGELOG.md, $root\LICENSE, $root\www $fullTarget -Recurse
|
|
"Copying archive..."
|
|
md $archiveFolder
|
|
cp "$root\archives\$ZIMbase*.*", "$root\archives\README.md" $archiveFolder
|
|
"Creating launchers..."
|
|
$launcherStub = $PSScriptRoot -replace 'scripts.*$', "bld\nwjs\$build-$version\Start Kiwix JS Windows"
|
|
$foldername = "kiwix_js_windows$sep$appBuild-$build"
|
|
# Batch file
|
|
$batch = '@cd "' + $foldername + '"' + "`r`n" + '@start "Kiwix JS Windows" "nw.exe"' + "`r`n"
|
|
$batch > "$launcherStub.bat"
|
|
# Shortcut
|
|
$WshShell = New-Object -ComObject WScript.Shell
|
|
$Shortcut = $WshShell.CreateShortcut("$launcherStub.lnk")
|
|
$Shortcut.TargetPath = '%windir%\explorer.exe'
|
|
$Shortcut.Arguments = "$foldername\nw.exe"
|
|
$Shortcut.IconLocation = '%windir%\explorer.exe,12'
|
|
$Shortcut.Save()
|
|
# Zip everything up
|
|
$ZipBuild = "$PSScriptRoot\..\bld\nwjs\$foldername.zip"
|
|
if (Test-Path $ZipBuild -PathType Leaf) {
|
|
"Deleting old Zip build $ZipBuild..."
|
|
del $ZipBuild
|
|
}
|
|
"Compressing folder..."
|
|
Compress-Archive "$PSScriptRoot\..\bld\nwjs\$build-$version\*" "$PSScriptRoot\..\bld\nwjs\$foldername.zip" -Force
|
|
"Build $OBuild finished.`n"
|
|
}
|
|
|