mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-05 02:26:29 +01:00
75 lines
2.1 KiB
PowerShell
75 lines
2.1 KiB
PowerShell
[cmdletbinding()]
|
|
|
|
Param(
|
|
[string]$appName,
|
|
[string]$droidApiKey,
|
|
[string]$iOsApiKey)
|
|
|
|
# Sets a text to a given value.
|
|
function Update-Text()
|
|
{
|
|
param (
|
|
[string]$TargetFileName,
|
|
[String] $FindText,
|
|
[String] $ReplaceText
|
|
)
|
|
|
|
if (-not(Test-Path -Path $TargetFileName)) {
|
|
Write-Host "File to update `"" + $TargetFileName + "`" not found!"
|
|
return 1
|
|
}
|
|
|
|
((Get-Content -path $TargetFileName -Raw) -replace $FindText, $ReplaceText) | Set-Content -Path $TargetFileName -Encoding utf8 -NoNewline
|
|
return 0
|
|
}
|
|
|
|
# Sets google maps api keys in all files for a single app to a given value.
|
|
function Set-GMapsApiKey()
|
|
{
|
|
param(
|
|
[String] $ProjectName,
|
|
[String] $DroidApiKey,
|
|
[String] $iOsApiKey
|
|
)
|
|
|
|
if ($DroidApiKey.Length -le 2)
|
|
{
|
|
Write-Host "Droid api key must not be of lenght <= 2"
|
|
return -1
|
|
}
|
|
|
|
if ($iOsApiKey.Length -le 2)
|
|
{
|
|
Write-Host "iOs api key must not be of lenght <= 2"
|
|
return -1
|
|
}
|
|
|
|
$fileName = Convert-Path ('.\' + $ProjectName + '\ShareeBike.Android\Properties\AndroidManifest.xml')
|
|
$retVal = Update-Text $fileName "API_KEY`" android:value=`".*`"" "API_KEY`" android:value=`"$DroidApiKey`""
|
|
if ($retVal -ne 0)
|
|
{
|
|
return $retVal
|
|
}
|
|
Write-Host "File `"$fileName`" updated sucessfully (.."$DroidApiKey.Substring($DroidApiKey.Length - 2, 2)")."
|
|
|
|
$fileName = Convert-Path ('.\' + $ProjectName + '\ShareeBike.Android\Properties\AssemblyInfo.cs')
|
|
$retVal = Update-Text $fileName "API_KEY`", Value = `".*`"" "API_KEY`", Value = `"$DroidApiKey`""
|
|
if ($retVal -ne 0)
|
|
{
|
|
return $retVal
|
|
}
|
|
Write-Host "File `"$fileName`" updated sucessfully (.."$DroidApiKey.Substring($DroidApiKey.Length - 2, 2)")."
|
|
|
|
$fileName = Convert-Path ('.\' + $ProjectName + '\ShareeBike.iOS\AppDelegate.cs')
|
|
$retVal = Update-Text $fileName "FormsGoogleMaps\.Init\(.*\)" "FormsGoogleMaps.Init(`"$iOsApiKey`")"
|
|
if ($retVal -ne 0)
|
|
{
|
|
return $retVal
|
|
}
|
|
Write-Host "File `"$fileName`" updated sucessfully (.."$iOsApiKey.Substring($iOsApiKey.Length - 2, 2)")."
|
|
return 0
|
|
}
|
|
|
|
return Set-GMapsApiKey $appName $droidApiKey $iOsApiKey
|
|
|
|
|