From 3ed937176e4f030d38a1a0839fff171dbbc5b864 Mon Sep 17 00:00:00 2001 From: Ruben Schmidmeister Date: Sat, 30 Apr 2016 14:15:47 +0200 Subject: [PATCH 01/10] create powershell module --- client/coop.ps1 | 47 ------------------------------ powershell/Coop/Coop.psd1 | Bin 0 -> 668 bytes powershell/Coop/STJEREM.Coop.ps1 | 48 +++++++++++++++++++++++++++++++ powershell/Installer.ps1 | 20 +++++++++++++ 4 files changed, 68 insertions(+), 47 deletions(-) delete mode 100644 client/coop.ps1 create mode 100644 powershell/Coop/Coop.psd1 create mode 100644 powershell/Coop/STJEREM.Coop.ps1 create mode 100644 powershell/Installer.ps1 diff --git a/client/coop.ps1 b/client/coop.ps1 deleted file mode 100644 index 79adb21..0000000 --- a/client/coop.ps1 +++ /dev/null @@ -1,47 +0,0 @@ -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) { - Write-Host "STJEREM/coop 0.0.1" -NoNewline - Exit -} - -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 "" -} - - -Write-Host "Press [ENTER] key to close ..." -Read-Host \ No newline at end of file diff --git a/powershell/Coop/Coop.psd1 b/powershell/Coop/Coop.psd1 new file mode 100644 index 0000000000000000000000000000000000000000..f751f2a0067f84163fb8a0d87b823195edc99d97 GIT binary patch literal 668 zcma))%}>HW6vXFj;{QP6!Hgiem)t9Hs5}VSc%H@MFmEX)E z?2NM)kTa*#fMK;}-0D$xx^m|&SRvI^M5`(*1P7VBA%dN=w{mPb5;BB%T8v}F`7$O1F#D)uP{BYR literal 0 HcmV?d00001 diff --git a/powershell/Coop/STJEREM.Coop.ps1 b/powershell/Coop/STJEREM.Coop.ps1 new file mode 100644 index 0000000..11418f7 --- /dev/null +++ b/powershell/Coop/STJEREM.Coop.ps1 @@ -0,0 +1,48 @@ +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) { + Write-Host "STJEREM/coop 0.0.1" -NoNewline + Exit + } + + 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 \ No newline at end of file diff --git a/powershell/Installer.ps1 b/powershell/Installer.ps1 new file mode 100644 index 0000000..1611cee --- /dev/null +++ b/powershell/Installer.ps1 @@ -0,0 +1,20 @@ +$version = '2d19d51a185be784935c1bbf3defb6af6d91d9ec' +$url = "https://github.com/STJEREM/coop/archive/$($version).zip" +$out = "$env:TEMP\coop-$($version).zip" +$dest = "$env:TEMP" + +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) + } +} + +Invoke-WebRequest -Uri $url -OutFile $out +Expand-ZipFile $out $dest + +Get-ChildItem -Path "$dest\coop-$version" + +# Todo: implement moving \ No newline at end of file From 4903e27c60cb7ea4a71bd8fb245495bf596a3a24 Mon Sep 17 00:00:00 2001 From: Ruben Schmidmeister Date: Sat, 30 Apr 2016 14:24:44 +0200 Subject: [PATCH 02/10] update version --- powershell/Coop/Coop.psd1 | Bin 668 -> 668 bytes powershell/Coop/STJEREM.Coop.ps1 | 5 +++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/powershell/Coop/Coop.psd1 b/powershell/Coop/Coop.psd1 index f751f2a0067f84163fb8a0d87b823195edc99d97..6fa454829493dd2b91d8fe278c3330bba16ef09a 100644 GIT binary patch delta 12 TcmbQkI)`;a6{FF{YDFdh8z%$L delta 12 TcmbQkI)`;a6{F$CYDFdh8zKYF diff --git a/powershell/Coop/STJEREM.Coop.ps1 b/powershell/Coop/STJEREM.Coop.ps1 index 11418f7..8e0a5e4 100644 --- a/powershell/Coop/STJEREM.Coop.ps1 +++ b/powershell/Coop/STJEREM.Coop.ps1 @@ -11,8 +11,9 @@ } if ($Version -eq $true) { - Write-Host "STJEREM/coop 0.0.1" -NoNewline - Exit + $module = Get-Module Coop + Write-Host "STJEREM/coop $($module.Version)" + Return } if ($location -eq "") { From 7469b0ab51571fe12d274ae4f680d015673ba5a1 Mon Sep 17 00:00:00 2001 From: Ruben Schmidmeister Date: Sat, 30 Apr 2016 14:40:46 +0200 Subject: [PATCH 03/10] update installer --- powershell/Installer.ps1 | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/powershell/Installer.ps1 b/powershell/Installer.ps1 index 1611cee..3749610 100644 --- a/powershell/Installer.ps1 +++ b/powershell/Installer.ps1 @@ -1,7 +1,8 @@ -$version = '2d19d51a185be784935c1bbf3defb6af6d91d9ec' +$version = '4903e27c60cb7ea4a71bd8fb245495bf596a3a24' $url = "https://github.com/STJEREM/coop/archive/$($version).zip" $out = "$env:TEMP\coop-$($version).zip" -$dest = "$env:TEMP" +$tmp = "$env:TEMP" +$installDir = "$Home\Documents\WindowsPowerShell\Modules" function Expand-ZipFile($file, $destination) { $shell = New-Object -com shell.application @@ -12,9 +13,23 @@ function Expand-ZipFile($file, $destination) { } } +Write-Host "Downloading package..." + Invoke-WebRequest -Uri $url -OutFile $out -Expand-ZipFile $out $dest +Expand-ZipFile $out $tmp + +if ((Test-Path $installDir) -eq $false) { + New-Item -ItemType Directory -Force -Path $installDir +} + +if ((Test-Path "$($installDir)\Coop") -eq $true) { + Write-Host "Removing previous installed version..." + Remove-Item -Force -Recurse "$($installDir)\Coop" +} -Get-ChildItem -Path "$dest\coop-$version" +Write-Host "Installing files..." +Copy-Item -Recurse "$($tmp)\coop-$($version)\powershell\Coop" $installDir -# Todo: implement moving \ No newline at end of file +Write-Host "Cleaning up..." +Remove-Item -Force $out +Remove-Item -Force -Recurse "$($tmp)\coop-$($version)" \ No newline at end of file From 9f7e8cbf47bc5d582f9affe299181295fbbbe5ed Mon Sep 17 00:00:00 2001 From: Ruben Schmidmeister Date: Sat, 30 Apr 2016 14:46:18 +0200 Subject: [PATCH 04/10] add one-line installer --- README.md | 7 +++++++ powershell/Installer.ps1 | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e2af47c..4ea7bc8 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,13 @@ brew tap bash/homebrew-coop brew install --HEAD coop ``` +### Installation on Windows +coop is avaible as a powershell module. + +```powershell +Invoke-WebRequest -OutFile CoopInstaller.ps1 -Uri https://raw.githubusercontent.com/STJEREM/coop/feature/powershell-dist/powershell/Installer.ps1; .\CoopInstaller.ps1 +``` + ## API The api is hosted at [themachine.jeremystucki.com](https://themachine.jeremystucki.com). diff --git a/powershell/Installer.ps1 b/powershell/Installer.ps1 index 3749610..68e37e5 100644 --- a/powershell/Installer.ps1 +++ b/powershell/Installer.ps1 @@ -19,7 +19,7 @@ Invoke-WebRequest -Uri $url -OutFile $out Expand-ZipFile $out $tmp if ((Test-Path $installDir) -eq $false) { - New-Item -ItemType Directory -Force -Path $installDir + New-Item -ItemType Directory -Force -Path $installDir | Out-Null } if ((Test-Path "$($installDir)\Coop") -eq $true) { From 9c8e3b503de07656cf3b44ac7ab67183562a19fa Mon Sep 17 00:00:00 2001 From: Ruben Schmidmeister Date: Sat, 30 Apr 2016 14:46:29 +0200 Subject: [PATCH 05/10] add success message --- powershell/Installer.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/powershell/Installer.ps1 b/powershell/Installer.ps1 index 68e37e5..e13de52 100644 --- a/powershell/Installer.ps1 +++ b/powershell/Installer.ps1 @@ -32,4 +32,7 @@ Copy-Item -Recurse "$($tmp)\coop-$($version)\powershell\Coop" $installDir Write-Host "Cleaning up..." Remove-Item -Force $out -Remove-Item -Force -Recurse "$($tmp)\coop-$($version)" \ No newline at end of file +Remove-Item -Force -Recurse "$($tmp)\coop-$($version)" + +Write-Host "" +Write-Host -Foreground Green "Installation Successful! Type `Coop` to see available menus." \ No newline at end of file From 2a12ef44e4f0fad7cdd10e6f82c392bbdf467e5c Mon Sep 17 00:00:00 2001 From: Ruben Schmidmeister Date: Sat, 30 Apr 2016 14:50:28 +0200 Subject: [PATCH 06/10] typos --- README.md | 2 +- powershell/Installer.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4ea7bc8..330db88 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ brew install --HEAD coop ``` ### Installation on Windows -coop is avaible as a powershell module. +coop is avaible as a powershell module: ```powershell Invoke-WebRequest -OutFile CoopInstaller.ps1 -Uri https://raw.githubusercontent.com/STJEREM/coop/feature/powershell-dist/powershell/Installer.ps1; .\CoopInstaller.ps1 diff --git a/powershell/Installer.ps1 b/powershell/Installer.ps1 index e13de52..4dea2cb 100644 --- a/powershell/Installer.ps1 +++ b/powershell/Installer.ps1 @@ -35,4 +35,4 @@ 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." \ No newline at end of file +Write-Host -Foreground Green "Installation Successful! Type 'Coop' to see available menus." \ No newline at end of file From 020eef4b590f51f7accead9de15bc71b2d3fe4e7 Mon Sep 17 00:00:00 2001 From: Ruben Schmidmeister Date: Sat, 30 Apr 2016 14:55:35 +0200 Subject: [PATCH 07/10] update version number --- powershell/Installer.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powershell/Installer.ps1 b/powershell/Installer.ps1 index 4dea2cb..10306c3 100644 --- a/powershell/Installer.ps1 +++ b/powershell/Installer.ps1 @@ -1,4 +1,4 @@ -$version = '4903e27c60cb7ea4a71bd8fb245495bf596a3a24' +$version = '0.0.2' $url = "https://github.com/STJEREM/coop/archive/$($version).zip" $out = "$env:TEMP\coop-$($version).zip" $tmp = "$env:TEMP" From f5545a797e3e6e6cc08c98aab0de4a142e1114c2 Mon Sep 17 00:00:00 2001 From: Ruben Schmidmeister Date: Sat, 30 Apr 2016 16:04:19 +0200 Subject: [PATCH 08/10] update ps installer, move to client/ --- README.md | 2 +- {powershell => client/powershell}/Coop/Coop.psd1 | Bin .../powershell}/Coop/STJEREM.Coop.ps1 | 0 {powershell => client/powershell}/Installer.ps1 | 5 ++++- client/{ => python}/coop | 0 client/{ => python}/requirements.txt | 0 6 files changed, 5 insertions(+), 2 deletions(-) rename {powershell => client/powershell}/Coop/Coop.psd1 (100%) rename {powershell => client/powershell}/Coop/STJEREM.Coop.ps1 (100%) rename {powershell => client/powershell}/Installer.ps1 (88%) rename client/{ => python}/coop (100%) rename client/{ => python}/requirements.txt (100%) diff --git a/README.md b/README.md index 330db88..729903a 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ brew install --HEAD coop coop is avaible as a powershell module: ```powershell -Invoke-WebRequest -OutFile CoopInstaller.ps1 -Uri https://raw.githubusercontent.com/STJEREM/coop/feature/powershell-dist/powershell/Installer.ps1; .\CoopInstaller.ps1 +Invoke-WebRequest -OutFile CoopInstaller.ps1 -Uri https://raw.githubusercontent.com/STJEREM/coop/feature/powershell-dist/powershell/Installer.ps1; .\CoopInstaller.ps1 "0.0.2" ``` ## API diff --git a/powershell/Coop/Coop.psd1 b/client/powershell/Coop/Coop.psd1 similarity index 100% rename from powershell/Coop/Coop.psd1 rename to client/powershell/Coop/Coop.psd1 diff --git a/powershell/Coop/STJEREM.Coop.ps1 b/client/powershell/Coop/STJEREM.Coop.ps1 similarity index 100% rename from powershell/Coop/STJEREM.Coop.ps1 rename to client/powershell/Coop/STJEREM.Coop.ps1 diff --git a/powershell/Installer.ps1 b/client/powershell/Installer.ps1 similarity index 88% rename from powershell/Installer.ps1 rename to client/powershell/Installer.ps1 index 10306c3..bd3843a 100644 --- a/powershell/Installer.ps1 +++ b/client/powershell/Installer.ps1 @@ -1,4 +1,7 @@ -$version = '0.0.2' +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" diff --git a/client/coop b/client/python/coop similarity index 100% rename from client/coop rename to client/python/coop diff --git a/client/requirements.txt b/client/python/requirements.txt similarity index 100% rename from client/requirements.txt rename to client/python/requirements.txt From 011dbf8efe1efdbc358857942d0e064e050b229c Mon Sep 17 00:00:00 2001 From: Ruben Schmidmeister Date: Sat, 30 Apr 2016 16:06:08 +0200 Subject: [PATCH 09/10] update one-liner --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 729903a..d794bf7 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ brew install --HEAD coop coop is avaible as a powershell module: ```powershell -Invoke-WebRequest -OutFile CoopInstaller.ps1 -Uri https://raw.githubusercontent.com/STJEREM/coop/feature/powershell-dist/powershell/Installer.ps1; .\CoopInstaller.ps1 "0.0.2" +Invoke-WebRequest -OutFile CoopInstaller.ps1 -Uri https://raw.githubusercontent.com/STJEREM/coop/development/client/powershell/Installer.ps1; .\CoopInstaller.ps1 "0.0.2" ``` ## API From 4b30b731c12fbd7ddf7e1c39a90878247edf93f0 Mon Sep 17 00:00:00 2001 From: Ruben Schmidmeister Date: Sat, 30 Apr 2016 16:12:21 +0200 Subject: [PATCH 10/10] sync versions, fix installer --- README.md | 2 +- client/powershell/Coop/Coop.psd1 | Bin 668 -> 668 bytes client/powershell/Installer.ps1 | 2 +- client/python/coop | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d794bf7..0b0c962 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ brew install --HEAD coop coop is avaible as a powershell module: ```powershell -Invoke-WebRequest -OutFile CoopInstaller.ps1 -Uri https://raw.githubusercontent.com/STJEREM/coop/development/client/powershell/Installer.ps1; .\CoopInstaller.ps1 "0.0.2" +Invoke-WebRequest -OutFile CoopInstaller.ps1 -Uri https://raw.githubusercontent.com/STJEREM/coop/development/client/powershell/Installer.ps1; .\CoopInstaller.ps1 "0.0.3" ``` ## API diff --git a/client/powershell/Coop/Coop.psd1 b/client/powershell/Coop/Coop.psd1 index 6fa454829493dd2b91d8fe278c3330bba16ef09a..d02127c661c38de9a190bbbfc79382b49eced815 100644 GIT binary patch delta 12 TcmbQkI)`;a6{GRSYDFdh8!Q9R delta 12 TcmbQkI)`;a6{FF{YDFdh8z%$L diff --git a/client/powershell/Installer.ps1 b/client/powershell/Installer.ps1 index bd3843a..f203233 100644 --- a/client/powershell/Installer.ps1 +++ b/client/powershell/Installer.ps1 @@ -31,7 +31,7 @@ if ((Test-Path "$($installDir)\Coop") -eq $true) { } Write-Host "Installing files..." -Copy-Item -Recurse "$($tmp)\coop-$($version)\powershell\Coop" $installDir +Copy-Item -Recurse "$($tmp)\coop-$($version)\client\powershell\Coop" $installDir Write-Host "Cleaning up..." Remove-Item -Force $out diff --git a/client/python/coop b/client/python/coop index db8b93b..dfbf78d 100755 --- a/client/python/coop +++ b/client/python/coop @@ -21,7 +21,7 @@ def print_menu(menu): def print_version(): - print('STJEREM/coop 0.0.2') + print('STJEREM/coop 0.0.3') if len(sys.argv) == 2 and sys.argv[1] == '--version':