From 4eeec18ce9289d882d766f3ae2cdef8319d9ff5c Mon Sep 17 00:00:00 2001 From: Iristyle Date: Fri, 1 Mar 2013 14:41:15 -0500 Subject: [PATCH] EthanBrown.ChromeCanaryDevExtensions 0.0.1 Includes Batarang Clear Cache DevTools AutoSave PageSpeed Insights Simple REST Client Speed Tracer CoffeeConsole YSlow Does Not Include CoffeeScript IDE - Requires login PostMan - Requires login LiveReload - Not necessary with grunt Grunt DevTools - Evaluating Tincr - Might be superceded by Chrome workspaces --- ...thanBrown.ChromeCanaryDevExtensions.nuspec | 90 ++++++++++++++++ .../tools/chocolateyInstall.ps1 | 38 +++++++ .../tools/chocolateyUninstall.ps1 | 24 +++++ core/ChromeHelpers.ps1 | 102 ++++++++++++++++++ 4 files changed, 254 insertions(+) create mode 100644 EthanBrown.ChromeCanaryDevExtensions/EthanBrown.ChromeCanaryDevExtensions.nuspec create mode 100644 EthanBrown.ChromeCanaryDevExtensions/tools/chocolateyInstall.ps1 create mode 100644 EthanBrown.ChromeCanaryDevExtensions/tools/chocolateyUninstall.ps1 create mode 100644 core/ChromeHelpers.ps1 diff --git a/EthanBrown.ChromeCanaryDevExtensions/EthanBrown.ChromeCanaryDevExtensions.nuspec b/EthanBrown.ChromeCanaryDevExtensions/EthanBrown.ChromeCanaryDevExtensions.nuspec new file mode 100644 index 0000000..f88f397 --- /dev/null +++ b/EthanBrown.ChromeCanaryDevExtensions/EthanBrown.ChromeCanaryDevExtensions.nuspec @@ -0,0 +1,90 @@ + + + + EthanBrown.ChromeCanaryDevExtensions + Chrome Canary - Web Development Extensions + 0.0.1 + Various + Ethan Brown + Chrome Canary extensions for web development. + Includes a number of very useful extensions for web application + development within Chrome. + + WARNING: This is not a "silent" installer. + + Chrome no longer provides any ability to automatically install extensions + due to abuse, so the existing preferences file is examined, to determine + what is currently installed. + + For plugins that are not installed, Chrome is launched with each extension + in a new browser tab, where the user must press the 'Add To Chrome' button. + + Included + =========================================================================== + + - Batarang for AngularJS development + https://chrome.google.com/webstore/detail/ighdmehidhipcmcojjgiloacoafjmpfk + + - Clear Cache + https://chrome.google.com/webstore/detail/cppjkneekbjaeellbfkmgnhonkkjfpdn + + - DevTools AutoSave + https://chrome.google.com/webstore/detail/mlejngncgiocofkcbnnpaieapabmanfl + + - PageSpeed Insights + https://developers.google.com/speed/docs/insights/using_chrome + + - YSlow + https://chrome.google.com/webstore/detail/yslow/ninejjcohidippngpapiilnmkgllmakh + + - Simple REST Client + https://chrome.google.com/webstore/detail/simple-rest-client/fhjcajmcbmldlhcimfajhfbgofnpcjmb + + Postman is the preferred client, but requires login, which is + often undesireable with a test browser + https://chrome.google.com/webstore/detail/fdmmgilgnpjigdojojpjoooidkmcomcm + + - Speed Tracer + https://chrome.google.com/webstore/detail/ognampngfcbddbfemdapefohjiobgbdl + + - CoffeeConsole + https://chrome.google.com/webstore/detail/coffeeconsole/ladbkfdlnaibelfidknofapbbdlhadfp + + CoffeeScript IDE is preferred, but requires login + https://chrome.google.com/webstore/detail/coffeescript-ide/hikjpmfebkagiijbdinakadphhjffaik + + + Previously Included + =========================================================================== + + - LiveReload + https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei + Grunt-contrib-livereload plugin now handles this + + - Tincr + https://chrome.google.com/webstore/detail/tincr/lfjbhpnjiajjgnjganiaggebdhhpnbih + Hasn't been updated recently, and Chrome workspaces might supercede this + + Under evaluation + =========================================================================== + + - Grunt DevTools + https://chrome.google.com/webstore/detail/grunt-devtools/fbiodiodggnlakggeeckkjccjhhjndnb + + http://github.com/Iristyle/ChocolateyPackages/ + Google Chrome Canary Extension Development Web + + false + https://github.com/Iristyle/ChocolateyPackages/raw/master/GoogleChrome.Canary/GoogleChrome.Canary.png + + + + + + + + + + diff --git a/EthanBrown.ChromeCanaryDevExtensions/tools/chocolateyInstall.ps1 b/EthanBrown.ChromeCanaryDevExtensions/tools/chocolateyInstall.ps1 new file mode 100644 index 0000000..6218c97 --- /dev/null +++ b/EthanBrown.ChromeCanaryDevExtensions/tools/chocolateyInstall.ps1 @@ -0,0 +1,38 @@ +$package = 'EthanBrown.ChromeCanaryDevExtensions' + +try { + + function Get-CurrentDirectory + { + $thisName = $MyInvocation.MyCommand.Name + [IO.Path]::GetDirectoryName((Get-Content function:$thisName).File) + } + + . (Join-Path (Get-CurrentDirectory) 'ChromeHelpers.ps1') + + $toInstall = @{ + "ighdmehidhipcmcojjgiloacoafjmpfk" = "Batarang"; + "cppjkneekbjaeellbfkmgnhonkkjfpdn" = "Clear Cache"; + "mlejngncgiocofkcbnnpaieapabmanfl" = "DevTools AutoSave"; + "gplegfbjlmmehdoakndmohflojccocli" = "PageSpeed Insights"; + "fhjcajmcbmldlhcimfajhfbgofnpcjmb" = "Simple REST Client"; + "ognampngfcbddbfemdapefohjiobgbdl" = "Speed Tracer"; + "ladbkfdlnaibelfidknofapbbdlhadfp" = "CoffeeConsole"; + "ninejjcohidippngpapiilnmkgllmakh" = "YSlow"; + # has messed up install requirements + # "hikjpmfebkagiijbdinakadphhjffaik" = "CoffeeScript IDE"; + # "fdmmgilgnpjigdojojpjoooidkmcomcm" = "PostMan"; + # handled by Grunt + # "jnihajbhpnppcggbcgedagnkighmdlei" = "LiveReload"; + # deprecated for now + # "fbiodiodggnlakggeeckkjccjhhjndnb" = "Grunt DevTools"; + # "lfjbhpnjiajjgnjganiaggebdhhpnbih" = "Tincr" + } + + Install-ChromeExtensions $toInstall -Canary + + Write-ChocolateySuccess $package +} catch { + Write-ChocolateyFailure $package "$($_.Exception.Message)" + throw +} diff --git a/EthanBrown.ChromeCanaryDevExtensions/tools/chocolateyUninstall.ps1 b/EthanBrown.ChromeCanaryDevExtensions/tools/chocolateyUninstall.ps1 new file mode 100644 index 0000000..2651833 --- /dev/null +++ b/EthanBrown.ChromeCanaryDevExtensions/tools/chocolateyUninstall.ps1 @@ -0,0 +1,24 @@ +$package = 'EthanBrown.ChromeCanaryDevExtensions' + +try { + + function Get-CurrentDirectory + { + $thisName = $MyInvocation.MyCommand.Name + [IO.Path]::GetDirectoryName((Get-Content function:$thisName).File) + } + + . (Join-Path (Get-CurrentDirectory) 'ChromeHelpers.ps1') + + Write-Host "Launching Chrome Canary extensions page to remove extensions" + + $chromePath = Get-ChromePath -Canary + $chromeExe = Join-Path $chromePath 'Application\chrome.exe' + $chromeParams = @('--new-window', 'chrome://extensions/') + &$chromeExe @chromeParams + + Write-ChocolateySuccess $package +} catch { + Write-ChocolateyFailure $package "$($_.Exception.Message)" + throw +} diff --git a/core/ChromeHelpers.ps1 b/core/ChromeHelpers.ps1 new file mode 100644 index 0000000..87dc352 --- /dev/null +++ b/core/ChromeHelpers.ps1 @@ -0,0 +1,102 @@ +function Get-ChromePath +{ + [CmdletBinding()] + param( + [Parameter(Mandatory = $false)] + [Switch] + $Canary = $false + ) + + $path = if ($Canary) { 'Google\Chrome SxS' } else { 'Google\Chrome' } + + Join-Path $Env:LOCALAPPDATA $path +} + +function Get-ChromeExtensions +{ + [CmdletBinding()] + param( + [Parameter(Mandatory = $false)] + [Switch] + $Canary = $false, + + [Parameter(Mandatory = $false)] + [bool] + $ExcludeBlacklist = $true + ) + + $installed = @{} + + $root = Get-ChromePath -Canary:$Canary + $prefsPath = Join-Path $root 'User Data\Default\Preferences' + + if (Test-Path $prefsPath) + { + Write-Verbose "Examining $prefsPath for installed extensions...`n`n" + $prefs = ConvertFrom-Json ([IO.File]::ReadAllText($prefsPath)) + + $prefs.extensions.settings.PsObject.Properties | + ? { if ($ExcludeBlacklist) { -not $_.Value.blacklist } else { $true } } | + % { + $installed[$_.Name] = $_.Value + $msg = "Found Extension $($_.Value.manifest.name) [$($_.Name)]" + if (!$ExcludeBlacklist -and $_.Value.blacklist) + { + $msg += " - Blacklist [$($_.Value.blacklist)]" + } + Write-Verbose $msg + } + } + + return $installed +} + +# this is a bit of a misnomer, it just finds and launches Chrome with +# new tabs for each extension since the end user still has to click a button +function Install-ChromeExtensions +{ + [CmdletBinding()] + param( + [Parameter(Mandatory = $false)] + [Switch] + $Canary = $false, + + [Parameter(Mandatory = $true)] + [Hashtable] + $Extensions + # Expected a hash of Id / Name + ) + + $name = 'Chrome' + if ($Canary) { $name += ' Canary'} + + $installed = Get-ChromeExtensions -Canary:$Canary + $rootPath = Get-ChromePath -Canary:$Canary + $chromeExe = Join-Path $rootPath 'Application\chrome.exe' + + $Extensions.GetEnumerator() | + ? { $installed.Keys -contains $_.Key } | + % { + Write-Verbose "$name Extension $($_.Value) [$($_.Key)] is already installed!" + } + + $storeUrl = 'https://chrome.google.com/webstore/detail' + $chromeParams = @() + $neededPackages = $Extensions.GetEnumerator() | + ? { $installed.Keys -notcontains $_.Key } | + % { + Write-Host "Launching $name to install extension $($_.Value) [$($_.Key)]!" + # http://peter.sh/experiments/chromium-command-line-switches/ + $chromeParams += "--new-window", "$storeUrl/$($_.Key)" + } + + if ($chromeParams.Count -gt 0) + { + Write-Host "`n`nExecuting $chromeExe $chromeParams" + &$chromeExe @chromeParams + } + else + { + Write-Host "`n`nAll extensions already installed!" + } +}