Files
furumi-tui/integrations/opendeck/package.ps1
T

38 lines
2.2 KiB
PowerShell

param(
[string]$Target = '',
[string]$BuildProfile = 'release',
[string]$OutputDirectory = "$PSScriptRoot/dist"
)
$ErrorActionPreference = 'Stop'
$repo = (Resolve-Path "$PSScriptRoot/../..").Path
if (!$Target) {
$hostLine = & rustc -vV | Select-String '^host: '
$Target = $hostLine.ToString().Substring(6).Trim()
$binaryDirectory = Join-Path $repo "target/$BuildProfile"
} else {
$binaryDirectory = Join-Path $repo "target/$Target/$BuildProfile"
}
$extension = if ($Target -like '*windows*') { '.exe' } else { '' }
$binary = Join-Path $binaryDirectory "furumi-opendeck$extension"
if (!(Test-Path -LiteralPath $binary)) { throw "Build the plugin first; missing $binary" }
$bundle = Join-Path $OutputDirectory 'org.furumi.opendeck.sdPlugin'
$binaryName = "furumi-opendeck-$Target$extension"
if (Test-Path -LiteralPath $bundle) {
$packageFiles = @($binaryName, 'manifest.json', 'icon.svg', 'property-inspector.html', 'property-inspector.js', 'FONT-LICENSE.txt', 'PHOSPHOR-LICENSE.txt', 'README.md', 'LICENSE')
$extra = Get-ChildItem -LiteralPath $bundle -Force | Where-Object { $_.PSIsContainer -or $_.Name -notin $packageFiles }
if ($extra) { throw "The output bundle contains additional files. Choose a separate OutputDirectory: $bundle" }
}
New-Item -ItemType Directory -Force -Path $bundle | Out-Null
Copy-Item -LiteralPath $binary -Destination (Join-Path $bundle $binaryName)
Copy-Item -LiteralPath "$PSScriptRoot/assets/manifest.json" -Destination $bundle
Copy-Item -LiteralPath "$PSScriptRoot/assets/icon.svg" -Destination $bundle
Copy-Item -LiteralPath "$PSScriptRoot/assets/property-inspector.html" -Destination $bundle
Copy-Item -LiteralPath "$PSScriptRoot/assets/property-inspector.js" -Destination $bundle
Copy-Item -LiteralPath "$PSScriptRoot/assets/FONT-LICENSE.txt" -Destination $bundle
Copy-Item -LiteralPath "$PSScriptRoot/assets/PHOSPHOR-LICENSE.txt" -Destination $bundle
Copy-Item -LiteralPath "$PSScriptRoot/README.md" -Destination $bundle
Copy-Item -LiteralPath "$repo/LICENSE" -Destination $bundle
$archive = Join-Path $OutputDirectory "furumi-opendeck-$Target.zip"
Compress-Archive -LiteralPath $bundle -DestinationPath $archive -Force
Write-Output $archive