Skip to content

Commit

Permalink
Updates to the Powershell script (#98)
Browse files Browse the repository at this point in the history
* Refactored to an Proxy interface to address #47

* Added remaining EventsSent to ConfigurationManager

* Attempting to eliminate memory leak

* Adding script to test the Plugin template

* WIP

* Updated to be more cross-platform friendly

* Re-added cheer graffiti
  • Loading branch information
csharpfritz authored Feb 8, 2019
1 parent b1693ac commit a4a9ea7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 20 deletions.
32 changes: 19 additions & 13 deletions src/SamplePlugin/RegisterPluginAndStartStreamDeck.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ Write-Host "Script root: $PSScriptRoot`n"

$basePath = $PSScriptRoot

if ($PSSCriptRoot.Length -eq 0) {
if (!($PSSCriptRoot)) {
$basePath = $PWD.Path;
}


# Load and parse the plugin project file
$pluginProjectFile = "$basePath\SamplePlugin.csproj"
$pluginProjectFile = Join-Path $basePath "SamplePlugin.csproj"
$projectContent = Get-Content $pluginProjectFile | Out-String;
$projectXML = [xml]$projectContent;

Expand All @@ -20,10 +20,13 @@ $buildConfiguration = "Debug"
$targetFrameworkName = $projectXML.Project.PropertyGroup.TargetFramework;

# Set local path references
$streamDeckExePath = "$($ENV:ProgramFiles)\Elgato\StreamDeck\StreamDeck.exe"

# For now, this PS script will only be run on Windows.
$bindir = "$basePath\bin\Debug\$targetFrameworkName\win-x64"
if ($IsMacOS) {
$streamDeckExePath = "/Applications/Stream Deck.app"
$bindir = "$basePath/bin/Debug/$targetFrameworkName/osx-x64"
} else {
$streamDeckExePath = "$($ENV:ProgramFiles)\Elgato\StreamDeck\StreamDeck.exe"
$bindir = "$basePath\bin\Debug\$targetFrameworkName\win-x64"
}

# Make sure we actually have a directory/build to deploy
If (-not (Test-Path $bindir)) {
Expand All @@ -32,22 +35,26 @@ If (-not (Test-Path $bindir)) {
}

# Load and parse the plugin's manifest file
$manifestFile = $bindir +"\manifest.json"
$manifestContent = Get-Content $manifestFile | Out-String
$json = ConvertFrom-JSON $manifestcontent
$manifestPath = Join-Path $bindir "manifest.json"
$json = Get-Content -Path $manifestPath -Raw | ConvertFrom-Json

$uuidAction = $json.Actions[0].UUID

$pluginID = $uuidAction.substring(0, $uuidAction.Length - ".action".Length)
$destDir = "$($env:APPDATA)\Elgato\StreamDeck\Plugins\$pluginID.sdPlugin"

if($IsMacOS) {
$destDir = "$HOME/Library/Application Support/com.elgato.StreamDeck/Plugins/$pluginID.sdPlugin"
} else {
$destDir = "$($env:APPDATA)\Elgato\StreamDeck\Plugins\$pluginID.sdPlugin"
}

$pluginName = Split-Path $basePath -leaf

Get-Process StreamDeck,$pluginName | Stop-Process –force -ErrorAction SilentlyContinue

# Delete the target directory, make sure the deployment/copy is clean
Remove-Item -Recurse -Force -Path $destDir
$bindir = $bindir +"\*"
Remove-Item -Recurse -Force -Path $destDir -ErrorAction SilentlyContinue
$bindir = Join-Path $bindir "*"

# Then copy all deployment items to the plugin directory
New-Item -Type Directory -Path $destDir -ErrorAction SilentlyContinue # | Out-Null
Expand All @@ -56,4 +63,3 @@ Copy-Item -Path $bindir -Destination $destDir -Recurse

Write-Host "Deployment complete. We will NOT restart the Stream Deck here, but will from the template..."
# Start-Process $streamDeckExePath
exit 0
2 changes: 1 addition & 1 deletion src/StreamDeckLib/ConnectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public async Task<ConnectionManager> StartAsync(CancellationToken token)
{
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;

await Task.Factory.StartNew(() => Run(token), TaskCreationOptions.LongRunning);
await Run(token);

return this;
}
Expand Down
3 changes: 1 addition & 2 deletions src/StreamDeckLib/StreamDeckProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ protected virtual void Dispose(bool disposing)
if (!disposedValue)
{
if (disposing)
{
// TODO: dispose managed state (managed objects).
{ // TODO: dispose managed state (managed objects).
}

_Socket.Dispose();
Expand Down
8 changes: 4 additions & 4 deletions testTemplate.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/env bash

set -e
set -o pipefail
set -o nounset

## Supported by
## Cheer 100 svavablount February 1, 2019
## Cheer 1000 Auth0bobby February 1, 2019
## Cheer 100 devlead February 1, 2019
## Cheer 100 ramblinggeek February 1, 2019

set -e
set -o pipefail
set -o nounset

dotnet new -i Templates/StreamDeck.PluginTemplate.Csharp

dotnet new streamdeck-plugin -o testPlugin -pn IntegrationTestPlugin -uu test.plugin.integrationtest
Expand Down

0 comments on commit a4a9ea7

Please sign in to comment.