Skip to content

Commit

Permalink
New command: paket update nuget <package id> - closes fsprojects#239
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Oct 14, 2014
1 parent 808ff68 commit ac34ee4
Show file tree
Hide file tree
Showing 13 changed files with 105 additions and 42 deletions.
7 changes: 4 additions & 3 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 0.7.1 - 14.10.2014
* New command: `paket update nuget <package id>` - http://fsprojects.github.io/Paket/paket-update.html#Updating-a-single-package

#### 0.7.0 - 14.10.2014
* Initial support for referencing full github projects - http://fsprojects.github.io/Paket/github-dependencies.html#Referencing-a-GitHub-repository
* Allow to use all branches in GitHub sources - https://github.com/fsprojects/Paket/pull/249
Expand All @@ -15,12 +18,10 @@
* New restore command - http://fsprojects.github.io/Paket/paket-restore.html
* Report if we can't find packages for top level dependencies.
* Faster resolver
* Try /FindPackagesById before /Packages for nuget package version no. retrieval
* New Paket.Core package on NuGet - https://www.nuget.org/packages/Paket.Core/
* BUGFIX: Prefer full platform builds over portable builds

#### 0.5.2 - 10.10.2014
* Try /FindPackagesById before /Packages for nuget package version no. retrieval

#### 0.5.0 - 09.10.2014
* Bootstrapper will only download stable releases by default - http://fsprojects.github.io/Paket/bootstrapper.html
* New installer model allows better compatibility with NuGet and should be much faster
Expand Down
15 changes: 14 additions & 1 deletion docs/content/paket-update.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,20 @@
Recomputes the dependency resolution, updates the [`paket.lock` file](lock-file.html) and propagates any resulting package changes into all project files referencing updated packages.

[lang=batchfile]
$ paket update [--force] [--hard]
$ paket update [--force] [--hard]

Options:

`--force`: Forces the download and reinstallation of all packages.

`--hard`: Replaces package references within project files even if they are not yet adhering to to Paket's conventions (and hence considered manually managed). See [convert from NuGet](convert-from-nuget.html).

## Updating a single package

It's also possible to update only a single package and to keep all othere dependencies fixed:

[lang=batchfile]
$ paket update nuget PACKAGENAME [--force] [--hard]

Options:

Expand Down
6 changes: 3 additions & 3 deletions src/Paket.Bootstrapper/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
[assembly: AssemblyTitleAttribute("Paket.Bootstrapper")]
[assembly: AssemblyProductAttribute("Paket")]
[assembly: AssemblyDescriptionAttribute("A package dependency manager for .NET with support for NuGet packages and GitHub repositories.")]
[assembly: AssemblyVersionAttribute("0.7.0")]
[assembly: AssemblyFileVersionAttribute("0.7.0")]
[assembly: AssemblyVersionAttribute("0.7.1")]
[assembly: AssemblyFileVersionAttribute("0.7.1")]
namespace System {
internal static class AssemblyVersionInformation {
internal const string Version = "0.7.0";
internal const string Version = "0.7.1";
}
}
6 changes: 3 additions & 3 deletions src/Paket.Core/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ open System.Reflection
[<assembly: AssemblyTitleAttribute("Paket.Core")>]
[<assembly: AssemblyProductAttribute("Paket")>]
[<assembly: AssemblyDescriptionAttribute("A package dependency manager for .NET with support for NuGet packages and GitHub repositories.")>]
[<assembly: AssemblyVersionAttribute("0.7.0")>]
[<assembly: AssemblyFileVersionAttribute("0.7.0")>]
[<assembly: AssemblyVersionAttribute("0.7.1")>]
[<assembly: AssemblyFileVersionAttribute("0.7.1")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "0.7.0"
let [<Literal>] Version = "0.7.1"
27 changes: 18 additions & 9 deletions src/Paket.Core/DependenciesFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,21 @@ type DependenciesFile(fileName,options,packages : PackageRequirement list, remot
|> fun df -> df.Packages

let remoteFiles = ModuleResolver.Resolve(resolveSourceFile,getSha1,remoteFiles)

let dependencies =
remoteFiles
let remoteDependencies =
remoteFiles
|> List.map (fun f -> f.Dependencies)
|> List.concat

{ ResolvedPackages = PackageResolver.Resolve(getVersionF, getPackageDetailsF, dependencies @ packages)
|> List.fold (fun set current -> Set.union set current) Set.empty
|> Seq.map (fun (n, v) ->
let p = packages |> Seq.last
{ p with Name = n
VersionRequirement = v })
|> Seq.toList

{ ResolvedPackages = PackageResolver.Resolve(getVersionF, getPackageDetailsF, remoteDependencies @ packages)
ResolvedSourceFiles = remoteFiles }

member this.Add(packageName,version:string) =
if this.HasPackage packageName then failwithf "%s has already package %s" Constants.DependenciesFile packageName
member this.AddAdditionionalPackage(packageName,version:string) =
let versionRange = DependenciesFileParser.parseVersionRequirement (version.Trim '!')
let sources =
match packages |> List.rev with
Expand All @@ -218,9 +222,14 @@ type DependenciesFile(fileName,options,packages : PackageRequirement list, remot
Sources = sources
ResolverStrategy = DependenciesFileParser.parseResolverStrategy version
Parent = PackageRequirementSource.DependenciesFile fileName }
tracefn "Adding %s %s to paket.dependencies" packageName (versionRange.ToString())

DependenciesFile(fileName,options,packages @ [newPackage], remoteFiles)

member this.Add(packageName,version:string) =
if this.HasPackage packageName then failwithf "%s has already package %s" Constants.DependenciesFile packageName
tracefn "Adding %s %s to paket.dependencies" packageName version
this.AddAdditionionalPackage(packageName,version)

override __.ToString() =
let sources =
packages
Expand Down
31 changes: 20 additions & 11 deletions src/Paket.Core/LockFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ module LockFileSerializer =
for file in files |> Seq.sortBy (fun f -> f.Owner.ToLower(),f.Project.ToLower(),f.Name.ToLower()) do
let path = file.Name.TrimStart '/'
yield sprintf " %s (%s)" path file.Commit
for dep in file.Dependencies do
yield sprintf " %s (%s)" dep.Name (formatVersionRange dep.VersionRequirement)]
for (name,v) in file.Dependencies do
yield sprintf " %s (%s)" name (formatVersionRange v)]

String.Join(Environment.NewLine, all)

Expand Down Expand Up @@ -116,14 +116,23 @@ module LockFileParser =
Version = SemVer.Parse version } :: state.Packages }
| None -> failwith "no source has been specified."
| NugetDependency (name, _) ->
match state.Packages with
| currentPackage :: otherPackages ->
if not state.LastWasPackage then state else
{ state with
Packages = { currentPackage with
Dependencies = Set.add (name, VersionRequirement.AllReleases) currentPackage.Dependencies
} :: otherPackages }
| [] -> failwith "cannot set a dependency - no package has been specified."
if state.LastWasPackage then
match state.Packages with
| currentPackage :: otherPackages ->
{ state with
Packages = { currentPackage with
Dependencies = Set.add (name, VersionRequirement.AllReleases) currentPackage.Dependencies
} :: otherPackages }
| [] -> failwith "cannot set a dependency - no package has been specified."
else
match state.SourceFiles with
| currentFile :: rest ->
{ state with
SourceFiles =
{ currentFile with
Dependencies = Set.add (name, VersionRequirement.AllReleases) currentFile.Dependencies
} :: rest }
| [] -> failwith "cannot set a dependency - no remote file has been specified."
| SourceFile details ->
match state.RemoteUrl |> Option.map(fun s -> s.Split '/') with
| Some [| owner; project |] ->
Expand All @@ -135,7 +144,7 @@ module LockFileParser =
SourceFiles = { Commit = commit
Owner = owner
Project = project
Dependencies = []
Dependencies = Set.empty
Name = path } :: state.SourceFiles }
| _ -> failwith "invalid remote details.")

Expand Down
6 changes: 3 additions & 3 deletions src/Paket.Core/ModuleResolver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type ResolvedSourceFile =
Project : string
Name : string
Commit : string
Dependencies : PackageRequirement list }
Dependencies : Set<string*VersionRequirement> }
member this.FilePath = this.ComputeFilePath(this.Name)

member this.ComputeFilePath(name:string) =
Expand All @@ -55,8 +55,8 @@ let Resolve(getPackages, getSha1, remoteFiles : UnresolvedSourceFile list) : Res
{ Commit = sha
Owner = file.Owner
Project = file.Project
Dependencies = []
Dependencies = Set.empty
Name = file.Name }
let packages:PackageRequirement list = getPackages naked

{naked with Dependencies = packages })
{naked with Dependencies = packages |> Seq.fold (fun set package -> Set.add (package.Name,package.VersionRequirement) set) Set.empty })
27 changes: 27 additions & 0 deletions src/Paket.Core/UpdateProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,31 @@ let Update(forceResolution, force, hard) =
|> PackageSourceParser.getSources
sources, LockFile.LoadFrom(lockFileName.FullName)

InstallProcess.Install(sources, force, hard, lockFile)

/// Update a single package command
let UpdatePackage(packageName : string, force, hard) =
let lockFileName = DependenciesFile.FindLockfile Constants.DependenciesFile

let sources, lockFile =
let dependenciesFile = DependenciesFile.ReadFromFile Constants.DependenciesFile
let oldLockFile = LockFile.LoadFrom(lockFileName.FullName)

let updatedDependenciesFile =
oldLockFile.ResolvedPackages
|> Seq.fold
(fun (dependenciesFile : DependenciesFile) kv ->
let resolvedPackage = kv.Value
if resolvedPackage.Name.ToLower() = packageName.ToLower() then dependenciesFile
else
dependenciesFile.AddAdditionionalPackage
(resolvedPackage.Name, "== " + resolvedPackage.Version.ToString())) dependenciesFile

let resolution = updatedDependenciesFile.Resolve(force)
let newLockFile =
LockFile
(lockFileName.FullName, updatedDependenciesFile.Options, resolution.ResolvedPackages.GetModelOrFail(),
oldLockFile.SourceFiles)
newLockFile.Save()
updatedDependenciesFile.Sources, newLockFile
InstallProcess.Install(sources, force, hard, lockFile)
6 changes: 3 additions & 3 deletions src/Paket/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ open System.Reflection
[<assembly: AssemblyTitleAttribute("Paket")>]
[<assembly: AssemblyProductAttribute("Paket")>]
[<assembly: AssemblyDescriptionAttribute("A package dependency manager for .NET with support for NuGet packages and GitHub repositories.")>]
[<assembly: AssemblyVersionAttribute("0.7.0")>]
[<assembly: AssemblyFileVersionAttribute("0.7.0")>]
[<assembly: AssemblyVersionAttribute("0.7.1")>]
[<assembly: AssemblyFileVersionAttribute("0.7.1")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "0.7.0"
let [<Literal>] Version = "0.7.1"
4 changes: 2 additions & 2 deletions src/Paket/Paket.fsproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -40,7 +40,7 @@
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>..\..\bin\Paket.xml</DocumentationFile>
<StartArguments>update</StartArguments>
<StartArguments>update nuget fake</StartArguments>
<StartWorkingDirectory>D:\code\PaketKopie</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup>
Expand Down
6 changes: 5 additions & 1 deletion src/Paket/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ try
AddProcess.Add(packageName,version,force,hard,interactive,noInstall |> not)
| Command.Install -> UpdateProcess.Update(false,force,hard)
| Command.Restore -> RestoreProcess.Restore(force)
| Command.Update -> UpdateProcess.Update(true,force,hard)
| Command.Update ->
match results.TryGetResult <@ CLIArguments.Nuget @> with
| Some packageName -> UpdateProcess.UpdatePackage(packageName,force,hard)
| _ -> UpdateProcess.Update(true,force,hard)

| Command.Outdated -> FindOutdated.ListOutdated(strict,includePrereleases)
| Command.InitAutoRestore -> VSIntegration.InitAutoRestore()
| Command.ConvertFromNuget -> NuGetConvert.ConvertFromNuget(force,noInstall |> not,noAutoRestore |> not)
Expand Down
2 changes: 1 addition & 1 deletion tests/Paket.Tests/Lockfile/GeneratorSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ github "owner:project2:commit2" "folder/file.fs" """
| Some commit -> { Commit = commit
Owner = f.Owner
Project = f.Project
Dependencies = []
Dependencies = Set.empty
Name = f.Name } : ModuleResolver.ResolvedSourceFile
| _ -> failwith "error")
|> LockFileSerializer.serializeSourceFiles
Expand Down
4 changes: 2 additions & 2 deletions tests/Paket.Tests/Lockfile/ParserSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ let ``should parse lock file``() =
[ { Owner = "fsharp"
Project = "FAKE"
Name = "src/app/FAKE/Cli.fs"
Dependencies = []
Dependencies = Set.empty
Commit = "7699e40e335f3cc54ab382a8969253fecc1e08a9" }
{ Owner = "fsharp"
Project = "FAKE"
Dependencies = []
Dependencies = Set.empty
Name = "src/app/Fake.Deploy.Lib/FakeDeployAgentHelper.fs"
Commit = "Globbing" } ]

Expand Down

0 comments on commit ac34ee4

Please sign in to comment.