Skip to content
This repository has been archived by the owner on Feb 19, 2019. It is now read-only.

Source config implementation #101

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/chocolatey.ps1
@@ -1,7 +1,7 @@
param(
[string]$command,
[string]$packageName='',
[string]$source='https://go.microsoft.com/fwlink/?LinkID=230477',
[string]$source='',
[string]$version='',
[alias("all")][switch] $allVersions = $false,
[alias("ia","installArgs")][string] $installArguments = '',
Expand Down
2 changes: 1 addition & 1 deletion src/functions/Chocolatey-Install.ps1
@@ -1,7 +1,7 @@
function Chocolatey-Install {
param(
[string] $packageName,
[string] $source = 'https://go.microsoft.com/fwlink/?LinkID=230477',
[string] $source = '',
[string] $version = '',
[string] $installerArguments = ''
)
Expand Down
2 changes: 1 addition & 1 deletion src/functions/Chocolatey-InstallIfMissing.ps1
@@ -1,7 +1,7 @@
function Chocolatey-InstallIfMissing {
param(
[string] $packageName,
[string] $source = 'https://go.microsoft.com/fwlink/?LinkID=230477',
[string] $source = '',
[string] $version = ''
)

Expand Down
7 changes: 2 additions & 5 deletions src/functions/Chocolatey-List.ps1
@@ -1,18 +1,15 @@
function Chocolatey-List {
param(
[string] $selector='',
[string] $source='https://go.microsoft.com/fwlink/?LinkID=230477'
[string] $source=''
)

if ($source -like 'webpi') {
$webpiArgs ="/c webpicmd /List /ListOption:All"
& cmd.exe $webpiArgs
} else {

$srcArgs = "-Source `"$source`""
if ($source -like 'https://go.microsoft.com/fwlink/?LinkID=230477') {
$srcArgs = "-Source `"http://chocolatey.org/api/v2/`" -Source `"$source`""
}
$srcArgs = Get-SourceArgument $source

$parameters = "list"
if ($selector -ne '') {
Expand Down
10 changes: 5 additions & 5 deletions src/functions/Chocolatey-NuGet.ps1
@@ -1,22 +1,22 @@
function Chocolatey-NuGet {
param(
[string] $packageName,
[string] $source = 'https://go.microsoft.com/fwlink/?LinkID=230477'
[string] $source = ''
)

if ($packageName -eq 'all') {
Chocolatey-InstallAll $source
return
}

$srcArgs = "$source"
if ($source -like 'https://go.microsoft.com/fwlink/?LinkID=230477') {
$srcArgs = "http://chocolatey.org/api/v2/ OR $source"
$srcArgs = ""
if ($source -ne '') {
$srcArgs = "(from $source)"
}

@"
$h1
Chocolatey ($chocVer) is installing $packageName (from $srcArgs) to "$nugetLibPath". By installing you accept the license for the package you are installing (please run chocolatey /? for full license acceptance terms).
Chocolatey ($chocVer) is installing $packageName $srcArgs to "$nugetLibPath". By installing you accept the license for the package you are installing (please run chocolatey /? for full license acceptance terms).
$h1
"@ | Write-Host

Expand Down
3 changes: 0 additions & 3 deletions src/functions/Chocolatey-Push.ps1
Expand Up @@ -5,9 +5,6 @@ param(
)

$srcArgs = "-source $source"
if ($source -like 'https://go.microsoft.com/fwlink/?LinkID=230477') {
$srcArgs = "-source http://chocolatey.org/"
}

$packageArgs = "push $packageName $srcArgs"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still need it to default to chocolatey as a source...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter defaults to chocolatey already:
[string] $source = 'http://chocolatey.org/'

Is this not sufficient? Just let me know if this needs to be backed out.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad. I didn't RTFM, just the line above... :D

$logFile = Join-Path $nugetChocolateyPath 'push.log'
Expand Down
2 changes: 1 addition & 1 deletion src/functions/Chocolatey-Update.ps1
@@ -1,7 +1,7 @@
function Chocolatey-Update {
param(
[string] $packageName ='',
[string] $source = 'https://go.microsoft.com/fwlink/?LinkID=230477'
[string] $source = ''
)

if ($packageName -eq '') {$packageName = 'chocolatey';}
Expand Down
7 changes: 2 additions & 5 deletions src/functions/Chocolatey-Version.ps1
@@ -1,7 +1,7 @@
function Chocolatey-Version {
param(
[string] $packageName='',
[string] $source='https://go.microsoft.com/fwlink/?LinkID=230477'
[string] $source=''
)

if ($packageName -eq '') {$packageName = 'chocolatey';}
Expand All @@ -12,10 +12,7 @@ param(
$packages = $packageFolders -replace "(\.\d{1,})+"|gu
}

$srcArgs = "-Source `"$source`""
if ($source -like 'https://go.microsoft.com/fwlink/?LinkID=230477') {
$srcArgs = "-Source `"http://chocolatey.org/api/v2/`" -Source `"$source`""
}
$srcArgs = Get-SourceArgument $source

foreach ($package in $packages) {
$packageArgs = "list ""$package"" $srcArgs"
Expand Down
26 changes: 26 additions & 0 deletions src/functions/Get-SourceArgument.ps1
@@ -0,0 +1,26 @@
function Get-SourceArgument {
param(
[string] $source = ''
)
$srcArgs = ""
if ($source -ne '') {
$srcArgs = "-Source `"$source`""
}
else
{
$useNugetConfig = Get-ConfigValue 'useNuGetForSources'

if ($useNugetConfig -eq 'false') {
$sources = Get-ConfigValue 'sources'

foreach ($sourceEntry in $sources.ChildNodes) {
$srcUri = $sourceEntry.value
$srcArgs = $srcArgs + "-Source `"$srcUri`" "
}
}
}

Write-Debug "Source args: $srcArgs"

$srcArgs
}
11 changes: 2 additions & 9 deletions src/functions/Run-NuGet.ps1
@@ -1,7 +1,7 @@
function Run-NuGet {
param(
[string] $packageName,
[string] $source = 'https://go.microsoft.com/fwlink/?LinkID=230477',
[string] $source = '',
[string] $version = ''
)
@"
Expand All @@ -10,14 +10,7 @@ NuGet
$h2
"@ | Write-Debug

$srcArgs = "-Source `"$source`""
if ($source -like 'https://go.microsoft.com/fwlink/?LinkID=230477') {
$srcArgs = "-Source `"http://chocolatey.org/api/v2/`" -Source `"$source`""
}

if ($source -like '') {
$srcArgs = "-Source `"http://chocolatey.org/api/v2/`" -Source `"https://go.microsoft.com/fwlink/?LinkID=230477`""
}
$srcArgs = Get-SourceArgument $source

$packageArgs = "install $packageName -Outputdirectory `"$nugetLibPath`" $srcArgs"
if ($version -notlike '') {
Expand Down