-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from STJEREM/feature/powershell-dist
Powershell One-Line Installer
- Loading branch information
Showing
7 changed files
with
98 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
function Coop { | ||
[CmdletBinding()] | ||
param ( | ||
[switch] $Version, | ||
[string] $location = "", | ||
[string] $menuFilter = "" | ||
) | ||
|
||
function Get-Unix-Midnight() { | ||
return [int][double]::Parse($(Get-Date -date (Get-Date -Hour 0 -Minute 00 -Second 00 -Millisecond 0000).ToUniversalTime()-uformat %s)) | ||
} | ||
|
||
if ($Version -eq $true) { | ||
$module = Get-Module Coop | ||
Write-Host "STJEREM/coop $($module.Version)" | ||
Return | ||
} | ||
|
||
if ($location -eq "") { | ||
$location = $(Read-Host "Location") | ||
} | ||
|
||
$timestamp = Get-Unix-Midnight | ||
|
||
$client = New-Object System.Net.WebClient | ||
$url = "https://themachine.jeremystucki.com/api/v1/coop/menus/$($location)/$($timestamp)" | ||
|
||
$response = $client.DownloadString($url) | ||
$json = ConvertFrom-Json $response | ||
|
||
Write-Host "" | ||
|
||
foreach ($menu in $json.results) { | ||
if ($menuFilter -ne "" -and $menu.title -ne $menuFilter) { | ||
continue; | ||
} | ||
|
||
Write-Host -NoNewline $menu.title | ||
Write-Host -Foreground Magenta " $($menu.price)" | ||
|
||
foreach($item in $menu.menu) { | ||
Write-Host "- $($item)" | ||
} | ||
|
||
Write-Host "" | ||
} | ||
} | ||
|
||
Export-ModuleMember -Cmdlet Coop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
param ( | ||
[string] $version = (Read-Host "Commit - SHA or Tag") | ||
) | ||
|
||
$url = "https://github.com/STJEREM/coop/archive/$($version).zip" | ||
$out = "$env:TEMP\coop-$($version).zip" | ||
$tmp = "$env:TEMP" | ||
$installDir = "$Home\Documents\WindowsPowerShell\Modules" | ||
|
||
function Expand-ZipFile($file, $destination) { | ||
$shell = New-Object -com shell.application | ||
$zip = $shell.NameSpace($file) | ||
|
||
foreach($item in $zip.items()) { | ||
$shell.Namespace($destination).copyhere($item) | ||
} | ||
} | ||
|
||
Write-Host "Downloading package..." | ||
|
||
Invoke-WebRequest -Uri $url -OutFile $out | ||
Expand-ZipFile $out $tmp | ||
|
||
if ((Test-Path $installDir) -eq $false) { | ||
New-Item -ItemType Directory -Force -Path $installDir | Out-Null | ||
} | ||
|
||
if ((Test-Path "$($installDir)\Coop") -eq $true) { | ||
Write-Host "Removing previous installed version..." | ||
Remove-Item -Force -Recurse "$($installDir)\Coop" | ||
} | ||
|
||
Write-Host "Installing files..." | ||
Copy-Item -Recurse "$($tmp)\coop-$($version)\client\powershell\Coop" $installDir | ||
|
||
Write-Host "Cleaning up..." | ||
Remove-Item -Force $out | ||
Remove-Item -Force -Recurse "$($tmp)\coop-$($version)" | ||
|
||
Write-Host "" | ||
Write-Host -Foreground Green "Installation Successful! Type 'Coop' to see available menus." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.