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

Former-commit-id: b5cf86be1da6658f3472dfd76dbb29089eb65d56 [formerly 1f95281076e61bbdc3eaa3c5390bb0c2d2ea6535 [formerly 47eda10d96f1327f617d4a338fba82726262f6f9 [formerly 6bdfb9abdfaabc14b47ef44b60db78b76bab73d1]]] Former-commit-id: 37eec8a4a13f201852a996231a8b4e4a35dd974e [formerly e171b06da31a637c31d235d16a570a497e2f3c4d [formerly 77ea2c5ced2e7b88863a2db9eaa2beb037ddc083]] Former-commit-id: febdd7d97f82602e155f55c28886d1f2c1f33136 [formerly cdcf52853ea7b444dcccdfe4a459e722e24b7627] Former-commit-id: 5d97501216a0ebce3acc029ddcc97b3d8d7116a3
119 lines
4.2 KiB
PowerShell
119 lines
4.2 KiB
PowerShell
[CmdletBinding()]
|
|
param (
|
|
[switch]$only32bit = $false
|
|
)
|
|
$builds = @("win-ia32", "win-xp")
|
|
if (-Not $only32bit) {
|
|
$builds += "win-x64"
|
|
"Caller requested 32bit and 64bit build"
|
|
} else {
|
|
"Caller requested only32bit build"
|
|
}
|
|
$version10 = "0.63.1" # <<< value updated automatically from package.json if launched from Create-DraftRelease
|
|
$versionXP = "0.14.7"
|
|
$appBuild = "1.9.91-N" # <<< value updated auotmatically from package.json if launched from Create-DraftRelease
|
|
# $ZIMbase = "wikipedia_en_100"
|
|
# Check that the dev has included the correct archive in this branch
|
|
$init_params = Get-Content -Raw "$PSScriptRoot\..\www\js\init.js"
|
|
$PackagedArchive = $init_params -imatch 'params\[.packagedFile.][^;]+?[''"]([^\s]+?\.zim)[''"];'
|
|
$archiveExists = $false
|
|
if ($PackagedArchive) {
|
|
$PackagedArchive = $matches[1]
|
|
"`nSearching for packaged archive $PackagedArchive..."
|
|
$archiveExists = Test-Path "$PSScriptRoot\..\archives\$PackagedArchive" -PathType Leaf
|
|
}
|
|
if (-Not $archiveExists) {
|
|
"`n***** WARNING: PACKAGED ARCHIVE $PackagedArchive COULD NOT BE FOUND IN ARCHIVE FOLDER!!! *****"
|
|
"Please place the requested package in this folder and run script again.`n"
|
|
exit 1
|
|
}
|
|
"Found."
|
|
|
|
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"
|
|
$ZipFolder = "$PSScriptRoot\..\node_modules\nwjs-builder-phoenix\caches\"
|
|
$ZipLocation = $ZipFolder + "nwjs-v$version-$build.zip"
|
|
$UnzipLocation = "$ZipLocation-extracted\"
|
|
$buildLocation = "$ZipLocation-extracted\nwjs-v$version-$build\"
|
|
if (-Not (Test-Path $ZipFolder -PathType Container)) {
|
|
mkdir $ZipFolder
|
|
}
|
|
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\service-worker.js, $root\index.html, $root\CHANGELOG.md, $root\LICENSE, $root\www $fullTarget -Recurse
|
|
"Copying archive..."
|
|
md $archiveFolder
|
|
cp "$root\archives\$PackagedArchive", "$root\archives\*.txt", "$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"
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|