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

Former-commit-id: 1e42c3b960679c182af9fb193ee7af0dcab97123 [formerly 200b7b850e5bbd31210536e6a895b4f2c8b13b3b] [formerly a44991c0f69ff43c02d9155ae0d358329f7cc156] [formerly f3c7c6b9612b4bd1aff1dafb6cebd33e464ec33e [formerly 10e7c3d7ea31b8a119e29f1f96c865b7a80652a9 [formerly b92a54dc8c34eeb9615a720b3fc5a63b7ce7ba52]]] Former-commit-id: 16949e36e3e20b48f67727e7762625c539af5dad [formerly 58aefc34b320aa84143b527a3cd0fad58225b94b [formerly f01b63e87de93ed4c275adb12dee7e71e0fa6ac8]] Former-commit-id: fdd041e838236885bd11b50bd6d4dfc2992306a8 [formerly af0cf8cfabd605be9761614722ac25bc4bc55d0c] Former-commit-id: 6380bcbe39cc38966edb5a4811e09fb76bfb9b9c
48 lines
2.3 KiB
PowerShell
48 lines
2.3 KiB
PowerShell
# Updates the app version in all required places according to the custom value
|
|
|
|
[CmdletBinding()]
|
|
param (
|
|
[string]$customversion = ''
|
|
)
|
|
|
|
if ($customversion) {
|
|
"`nUser set custom input version: $customversion"
|
|
$INPUT_VERSION = $customversion
|
|
}
|
|
|
|
if ($INPUT_VERSION) {
|
|
$VERSION = $INPUT_VERSION
|
|
} elseif ($TAG_VERSION) {
|
|
$VERSION = $TAG_VERSION
|
|
}
|
|
|
|
if ($VERSION -match '^v?[\d.]') {
|
|
$VERSION = $VERSION -replace '^v', ''
|
|
"`nSetting App Version to $VERSION in service-worker.js and init.js ..."
|
|
(Get-Content ./service-worker.js) -replace '(appVersion\s*=\s*["''])[^"'']+', "`${1}$VERSION" | Set-Content -encoding "utf8BOM" ./service-worker.js
|
|
(Get-Content ./www/js/init.js) -replace '(appVersion..\s*=\s*["''])[^"'']+', "`${1}$VERSION" | Set-Content -encoding "utf8BOM" ./www/js/init.js
|
|
$PackageJson = Get-Content -Raw ./package.json
|
|
$PackageJsonNW = Get-Content -Raw ./package.json.nwjs
|
|
$nwVersion = $PackageJsonNW -match '"build":\s\{[^"]+"nwVersion":\s"([^"'']+)'
|
|
$nwVersion = $matches[1]
|
|
$CustomVersion = $VERSION -replace '^([^-]+)', '$1-E'
|
|
"Setting App Version to $CustomVersion in package.json ...`n"
|
|
$PackageJson = $PackageJson -replace '("version":\s+")[^"]+', "`${1}$CustomVersion"
|
|
# DEV: don't set BOM, as Linux tools crash with it
|
|
Set-Content ./package.json $PackageJson
|
|
if ($nwVersion) {
|
|
$CustomVersion = $CustomVersion -creplace '-E', '-N'
|
|
"Setting package.json.nwjs to $CustomVersion ..."
|
|
$PackageJsonNW = $PackageJsonNW -replace '("version":\s+")[^"]+', "`${1}$CustomVersion"
|
|
# DEV: don't set BOM, as Linux tools crash with it
|
|
Set-Content ./package.json.nwjs $PackageJsonNW
|
|
$BuildNWJSScript = Get-Content -Raw ./scripts/Build-NWJS.ps1
|
|
"Setting App Version to $CustomVersion in Build-NWJS.ps1 ..."
|
|
$BuildNWJSScript = $BuildNWJSScript -replace '(appBuild\s*=\s*["''])[^"'']+', ("`${1}$CustomVersion")
|
|
"Setting NWJS build to $nwVersion in Build-NWJS.ps1 ..."
|
|
$BuildNWJSScript = $BuildNWJSScript -replace '(version10\s*=\s*["''])[^"'']+', "`${1}$nwVersion"
|
|
Set-Content -encoding "utf8BOM" ./scripts/Build-NWJS.ps1 $BuildNWJSScript
|
|
}
|
|
} else {
|
|
"No valid INPUT_VERSION or TAG_VERSION were provided. File version numbers were unchanged.`n"
|
|
} |