Skip to content

Commit

Permalink
implement exclude parameter for pack
Browse files Browse the repository at this point in the history
  • Loading branch information
eiriktsarpalis committed Dec 1, 2015
1 parent 68b16db commit 638628f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
13 changes: 10 additions & 3 deletions src/Paket.Core/PackageProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ let private merge buildConfig version projectFile templateFile =
| Valid completeCore -> { templateFile with Contents = CompleteInfo(completeCore, opt) }
| _ -> templateFile

let Pack(workingDir,dependencies : DependenciesFile, packageOutputPath, buildConfig, version, releaseNotes, templateFile, lockDependencies) =
let Pack(workingDir,dependencies : DependenciesFile, packageOutputPath, buildConfig, version, releaseNotes, templateFile, excludedTemplates, lockDependencies) =
let buildConfig = defaultArg buildConfig "Release"
let packageOutputPath = if Path.IsPathRooted(packageOutputPath) then packageOutputPath else Path.Combine(workingDir,packageOutputPath)
Utils.createDir packageOutputPath |> returnOrFail
Expand Down Expand Up @@ -115,12 +115,19 @@ let Pack(workingDir,dependencies : DependenciesFile, packageOutputPath, buildCon
| [] -> failwithf "There was no project file found for template file %s" fileName
| _ -> failwithf "There was more than one project file found for template file %s" fileName
| _ -> templateFile ]

let excludedTemplates =
match excludedTemplates with
| None -> allTemplates
| Some excluded ->
let excluded = set excluded
allTemplates |> List.filter (fun t -> match t with CompleteTemplate(c,_) -> not (excluded.Contains c.Id) | _ -> true)

// set version
let templatesWithVersion =
match version with
| None -> allTemplates
| Some v -> allTemplates |> List.map (TemplateFile.setVersion v)
| None -> excludedTemplates
| Some v -> excludedTemplates |> List.map (TemplateFile.setVersion v)

// set release notes
let processedTemplates =
Expand Down
4 changes: 2 additions & 2 deletions src/Paket.Core/PublicAPI.fs
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,11 @@ type Dependencies(dependenciesFileName: string) =
FindReferences.FindReferencesForPackage (GroupName group) (PackageName package) |> this.Process

// Packs all paket.template files.
member this.Pack(outputPath, ?buildConfig, ?version, ?releaseNotes, ?templateFile, ?workingDir, ?lockDependencies) =
member this.Pack(outputPath, ?buildConfig, ?version, ?releaseNotes, ?templateFile, ?workingDir, ?excludedTemplates, ?lockDependencies) =
let dependenciesFile = DependenciesFile.ReadFromFile dependenciesFileName
let workingDir = defaultArg workingDir (dependenciesFile.FileName |> Path.GetDirectoryName)
let lockDependencies = defaultArg lockDependencies false
PackageProcess.Pack(workingDir, dependenciesFile, outputPath, buildConfig, version, releaseNotes, templateFile, lockDependencies)
PackageProcess.Pack(workingDir, dependenciesFile, outputPath, buildConfig, version, releaseNotes, templateFile, excludedTemplates, lockDependencies)

/// Pushes a nupkg file.
static member Push(packageFileName, ?url, ?apiKey, (?endPoint: string), ?maxTrials) =
Expand Down
2 changes: 2 additions & 0 deletions src/Paket/Commands.fs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ type PackArgs =
| [<CustomCommandLine("buildconfig")>] BuildConfig of string
| [<CustomCommandLine("version")>] Version of string
| [<CustomCommandLine("templatefile")>] TemplateFile of string
| [<CustomCommandLine("exclude")>] ExcludedTemplate of string
| [<CustomCommandLine("releaseNotes")>] ReleaseNotes of string
| [<CustomCommandLine("lock-dependencies")>] LockDependencies
with
Expand All @@ -304,6 +305,7 @@ with
| BuildConfig(_) -> "Optionally specify build configuration that should be packaged (defaults to Release)."
| Version(_) -> "Specify version of the package."
| TemplateFile(_) -> "Allows to specify a single template file."
| ExcludedTemplate(_) -> "Exclude template file by id."
| ReleaseNotes(_) -> "Specify relase notes for the package."
| LockDependencies -> "Get the version requirements from paket.lock instead of paket.dependencies."

Expand Down
1 change: 1 addition & 0 deletions src/Paket/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ let pack (results : ParseResults<_>) =
?version = results.TryGetResult <@ PackArgs.Version @>,
?releaseNotes = results.TryGetResult <@ PackArgs.ReleaseNotes @>,
?templateFile = results.TryGetResult <@ PackArgs.TemplateFile @>,
excludedTemplates = results.GetResults <@ PackArgs.ExcludedTemplate @>,
workingDir = Environment.CurrentDirectory,
lockDependencies = results.Contains <@ PackArgs.LockDependencies @>)

Expand Down

0 comments on commit 638628f

Please sign in to comment.