feat(ST2.PackageControl): 2.0.1-beta pre-release

- fixes issues with many packages being installed and package control
   completely wigging out
 - fixed bug that prevented "Package Control.sublime-package" from being
   overwritten
 - made Merge-PackageControlSettings fancier to handle named values
This commit is contained in:
Iristyle
2013-09-16 12:11:50 -04:00
parent 9eb87efe55
commit 385ed6dff5
4 changed files with 42 additions and 11 deletions

View File

@@ -3,7 +3,7 @@
<metadata>
<id>SublimeText2.PackageControl</id>
<title>Sublime Text 2 Package Control</title>
<version>1.6.3</version>
<version>2.0.1-beta1</version>
<authors>Will Bond</authors>
<owners>Ethan J Brown</owners>
<summary>A full-featured package manager that helps discovering, installing, updating and removing packages for Sublime Text 2. It features an automatic upgrader and supports GitHub, BitBucket and a full channel/repository system.</summary>
@@ -25,6 +25,7 @@
</metadata>
<files>
<file src="tools\**" target="tools" />
<file src="..\core\JsonHelpers.ps1" target="tools" />
<file src="..\core\SublimeHelpers.ps1" target="tools" />
</files>
</package>

View File

@@ -9,8 +9,13 @@ try {
$current = Get-CurrentDirectory
. (Join-Path $current 'SublimeHelpers.ps1')
. (Join-Path $current 'JsonHelpers.ps1')
Install-SublimePackageControl
# TODO: come up with a better way to do this install / set this setting
# that will work based on the semver in this packages .nuspec file
Install-SublimePackageControl -PreRelease
$packageControl = Join-Path $current 'Package Control.sublime-settings'
Merge-PackageControlSettings -FilePath $packageControl
Write-ChocolateySuccess $package
} catch {

View File

@@ -0,0 +1,3 @@
{
"install_prereleases": true
}

View File

@@ -93,7 +93,11 @@ function Install-SublimePackageControl
[Parameter(Mandatory = $false)]
[ValidateRange(2,3)]
[int]
$Version = 2
$Version = 2,
[Parameter(Mandatory = $false)]
[Switch]
$PreRelease = $false
)
# install package control
@@ -107,12 +111,15 @@ function Install-SublimePackageControl
2 {
$packageControl = Join-Path $packagesPath 'Package Control.sublime-package'
if (!(Test-Path $packageControl))
if (Test-Path $packageControl) { Remove-item $packageControl }
# http://wbond.net/sublime_packages/package_control/installation
$packageUrl = 'http://sublime.wbond.net/Package%20Control.sublime-package'
if ($PreRelease)
{
# http://wbond.net/sublime_packages/package_control/installation
$packageUrl = 'http://sublime.wbond.net/Package%20Control.sublime-package'
Get-ChocolateyWebFile -url $packageUrl -fileFullPath $packageControl
$packageUrl = 'https://sublime.wbond.net/prerelease/Package%20Control.sublime-package'
}
Get-ChocolateyWebFile -url $packageUrl -fileFullPath $packageControl
}
3 {
@@ -151,16 +158,31 @@ function Merge-PackageControlSettings
$new = ConvertFrom-Json ([IO.File]::ReadAllText($FilePath))
# simple arrays
'installed_packages', 'repositories' |
$simpleArrays = @('installed_packages', 'repositories', 'channels',
'auto_upgrade_ignore', 'git_update_command', 'hg_update_command',
'dirs_to_ignore', 'files_to_ignore', 'files_to_include',
'files_to_ignore_binary', 'files_to_include_binary' )
$simpleArrays |
? { $new.$_ -ne $null } |
% { Merge-JsonArray -Name $_ -Destination $existing -Array $new.$_ }
# maps
'package_name_map' |
$maps = @('package_name_map')
$maps |
? { $new.$_ -ne $null } |
% { Merge-JsonSimpleMap -Name $_ -Destination $existing -SimpleMap $new.$_ }
$arrayOfMaps = @('certs')
$arrayOfMaps |
? { $new.$_ -ne $null } |
% { Merge-JsonArrayOfSimpleMap -Name $_ -Destination $existing -Array $new.$_ }
$excluded = $simpleArrays + $maps + $arrayOfMaps
$new.PSObject.Properties |
? { $excluded -inotcontains $_.Name } |
% {
Merge-JsonNamedValue -Name $_.Name -Destination $existing -Value $_.Value
}
$json = $existing | ConvertTo-Json -Depth 10 | ConvertFrom-UnicodeEscaped
Write-Verbose "Updated settings: `n`n$json`n"
[IO.File]::WriteAllText($existingPath, $json, [System.Text.Encoding]::ASCII)