This commit is contained in:
1 parent
5d549ff66a
commit
e831d0dfe0
28 files changed
+1026
-286
No files matched your search
@@ -0,0 +1,31 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$OutputPath = (Join-Path $PSScriptRoot '..\Plain Craft Launcher 2\obj\BuildCredentials.json'),
|
||||
[switch]$RequireMicrosoftClientId
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$OutputPath = [IO.Path]::GetFullPath($OutputPath)
|
||||
# Remove credentials from a previous run before validating new input.
|
||||
if (Test-Path -LiteralPath $OutputPath) { Remove-Item -LiteralPath $OutputPath -Force }
|
||||
|
||||
$clientId = $env:PCL_MS_CLIENT_ID
|
||||
if ($clientId) { $clientId = $clientId.Trim() }
|
||||
if ($RequireMicrosoftClientId -and [string]::IsNullOrWhiteSpace($clientId)) {
|
||||
throw 'Set the repository variable PCL_MS_CLIENT_ID before building a release.'
|
||||
}
|
||||
if (-not [string]::IsNullOrWhiteSpace($clientId)) {
|
||||
$parsedId = [Guid]::Empty
|
||||
if (-not [Guid]::TryParse($clientId, [ref]$parsedId) -or $parsedId -eq [Guid]::Empty) {
|
||||
throw 'PCL_MS_CLIENT_ID must be a non-empty application client GUID.'
|
||||
}
|
||||
}
|
||||
|
||||
$credentials = [ordered]@{
|
||||
PCL_MS_CLIENT_ID = [string]$clientId
|
||||
PCL_CURSEFORGE_API_KEY = [string]$env:PCL_CURSEFORGE_API_KEY
|
||||
}
|
||||
[IO.Directory]::CreateDirectory((Split-Path $OutputPath -Parent)) | Out-Null
|
||||
[IO.File]::WriteAllText($OutputPath, ($credentials | ConvertTo-Json -Compress), [Text.UTF8Encoding]::new($false))
|
||||
Write-Host ('Microsoft Client ID embedded: ' + (-not [string]::IsNullOrWhiteSpace($clientId)))
|
||||
Write-Host ('CurseForge API key embedded: ' + (-not [string]::IsNullOrWhiteSpace($env:PCL_CURSEFORGE_API_KEY)))
|
||||
Reference in new issue
Block a user