Skip to content

Commit

Permalink
Initial support for autocomplete of private sources - references #1298
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jan 16, 2016
1 parent 2953930 commit 154d5ad
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#### 2.44.4 - 16.01.2016
* Initial support for autocomplete of private sources - https://github.com/fsprojects/Paket/issues/1298
* Allow to set project url in paket pack

#### 2.44.3 - 15.01.2016
Expand Down
17 changes: 16 additions & 1 deletion integrationtests/Paket.IntegrationTests/AutocompleteSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,19 @@ let ``#1298 should autocomplete for FAKE on NuGet 2``() =
let ``#1298 should autocomplete for FAKE on NuGet3``() =
let result = Dependencies.FindPackagesByName([PackageSource.NuGetV3Source Constants.DefaultNuGetV3Stream],"fake")
result |> shouldContain "FAKE"
result |> shouldContain "FAKE.IIS"
result |> shouldContain "FAKE.IIS"

[<Test>]
let ``#1298 should autocomplete for nunit on NuGet3``() =
let result = Dependencies.FindPackagesByName([PackageSource.NuGetV3Source Constants.DefaultNuGetV3Stream],"nunit")
result |> shouldContain "NUnit.Runners"
result |> shouldContain "Cloak.NUnit"
result |> shouldContain "NUnit"

[<Test>]
[<Ignore>] // it's only wrking on forki's machine
let ``#1298 should autocomplete for msu on local teamcity``() =
let result = Dependencies.FindPackagesByName([PackageSource.NuGetV2Source "http://teamcity/guestAuth/app/nuget/v1/FeedService.svc/"],"msu")
result |> shouldContain "msu.Addins"


19 changes: 19 additions & 0 deletions src/Paket.Core/NuGetV2.fs
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,25 @@ let getVersionsCached key f (source, auth, nugetURL, package) =
| _ -> return None
}

/// Uses the NuGet v2 API to retrieve all packages with the given prefix.
let FindPackages(auth, nugetURL, packageNamePrefix, maxResults) =
async {
try
let url = sprintf "%s/Packages()?$filter=IsLatestVersion and IsAbsoluteLatestVersion and substringof('%s',Id)" nugetURL packageNamePrefix
let! raw = getFromUrl(auth |> Option.map toBasicAuth,url,acceptXml)
let doc = XmlDocument()
doc.LoadXml raw
return
match doc |> getNode "feed" with
| Some n ->
[| for entry in n |> getNodes "entry" do
match (entry |> getNode "properties" |> optGetNode "Id") ++ (entry |> getNode "title") with
| Some node -> yield node.InnerText
| _ -> () |]
| _ -> [||]
with _ -> return [||]
}

/// Allows to retrieve all version no. for a package from the given sources.
let GetVersions force root (sources, packageName:PackageName) =
let trial force =
Expand Down
6 changes: 5 additions & 1 deletion src/Paket.Core/PublicAPI.fs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,11 @@ type Dependencies(dependenciesFileName: string) =
|> Seq.distinct
|> Seq.choose (fun source ->
match source with
| NuGetV2 s -> Some(NuGetV3.FindPackages(s.Authentication, s.Url, searchTerm, maxResults))
| NuGetV2 s ->
if s.Url.Contains "nuget.org" || s.Url.Contains "myget.org" then
Some(NuGetV3.FindPackages(s.Authentication, s.Url, searchTerm, maxResults))
else
Some(NuGetV2.FindPackages(s.Authentication, s.Url, searchTerm, maxResults))
| NuGetV3 s -> Some(NuGetV3.FindPackages(s.Authentication, s.Url, searchTerm, maxResults))
| _ -> None)

Expand Down

0 comments on commit 154d5ad

Please sign in to comment.