Last active
September 23, 2015 18:40
-
-
Save allykzam/3fe006d53d1fb1749cdc to your computer and use it in GitHub Desktop.
Record definition for use with FAKE, useful for storing desired information about a project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Fake | |
type ProjectDetails = | |
{ | |
/// Project name, useful for filtering against project files | |
Name : string; | |
/// Summary for AssemblyInfo and NuGet metadata | |
Summary : string; | |
/// Longer description for NuGet metadata | |
Description : string option; | |
/// A list of the authors who have worked on the project | |
Authors : string list; | |
/// Company or organization name | |
Organization : string; | |
/// The initial copyright year, and an sprintf-style formatter ready for | |
/// the copyright years to be added, e.g.: | |
/// `sprintf "Copyright %s Your Name Here"` | |
Copyright : int * (string -> string); | |
/// For build scripts that create installers, specify true for projects | |
/// that should have an installer created | |
Installable : bool; | |
/// For projects with their own release notes, provide a value here; for | |
/// others, use the global release notes file for the solution. | |
ProjectReleaseNotes : string option; | |
/// If a project needs a special deployment, these are the files that | |
/// will be deployed | |
CustomDeployFiles : string list option; | |
} | |
/// Gets the copyright text formatted for the specified year. If the current | |
/// year is after the initial year, the two will be together, e.g., | |
/// "2011-2015"; otherwise, the initial year is provided. | |
member x.CopyrightText (now:System.DateTime) = | |
let startYear = x.Copyright |> fst | |
let format = x.Copyright |> snd | |
if now.Year > startYear then | |
format <| sprintf "%i-%i" startYear now.Year | |
else | |
format <| sprintf "%i" startYear | |
/// Build a map of projects, using their names as keys | |
static member BuildMap projects = | |
projects | |
|> Seq.map (fun x -> x.Name, x) | |
|> Map.ofSeq | |
/// Returns the project details for the specified project if it's in the map | |
/// provided. The project name can be a file path or just the name of the | |
/// desired project. | |
static member TryFindProject (allProjects:Map<string,ProjectDetails>) project = | |
let name = System.IO.Path.GetFileNameWithoutExtension project | |
let x = Map.tryFind name allProjects | |
match x with | |
| Some _ -> x | |
// Try the project name as it was given, in case the name contains a dot | |
| None -> Map.tryFind project allProjects | |
/// Returns the project details for the specified project with the given | |
/// input, if the specified project is in the map provided. The project name | |
/// can be a file path or just the name of the desired project. Use this | |
/// instead of TryFindProject when the input project name is needed (such as | |
/// when the project type needs to be pattern matched against later). | |
static member TryFindProjectWithFile (allProjects:Map<string,ProjectDetails>) project = | |
match ProjectDetails.TryFindProject allProjects project with | |
| None -> None | |
| Some(pd) -> Some(project, pd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment