This repository has been archived by the owner on Jan 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.fsx
109 lines (90 loc) · 3.52 KB
/
update.fsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// This script simplifies the update process of the Eyeshot NuGet package.
// Run this after installing a new version of Eyeshot on your machine.
// This script will copy the new dll's and commit the changes.
// After running this script check the commit and change or push it.
#r "paket:
nuget FSharp.Core 6.0
nuget Fake.IO.FileSystem
nuget Fake.Core.Target
nuget Fake.Tools.Git
//"
#load "./.fake/update.fsx/intellisense.fsx"
#load "./scripts/Constants.fsx"
#load "./scripts/Helpers.fsx"
open Fake.Core
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.IO.Globbing.Operators
open Fake.Core.TargetOperators
open Fake.Tools
open System.Collections.Generic
Target.initEnvironment ()
let baseDir = __SOURCE_DIRECTORY__
let dllPath = baseDir @@ Constants.binDir
let tfms = [Constants.frameworkTfm;Constants.coreTfm]
let eyeshotFilePattern =
!! Constants.eyeshotDllPattern
++ Constants.eyeshotXmlPattern
let getEyeshotFilePaths tfm =
let filesFound =
eyeshotFilePattern.SetBaseDirectory (Constants.sourceDir @@ tfm)
:> IEnumerable<string>
tfm, filesFound
let files = tfms |> Seq.map getEyeshotFilePaths
let copyToBuildFolder (tfm, sourceFilePaths) =
let targetDir = Constants.binDir @@ tfm
let traceAndCopy = (fun file ->
Trace.trace ("copy file: " + file)
Trace.trace (" >>>>>> to >>>>>>> " + targetDir)
Directory.ensure targetDir
Shell.copyFile targetDir file
)
let moveToSubFolders file folder =
Directory.ensure folder
Shell.moveFile folder file
Seq.iter traceAndCopy sourceFilePaths
Trace.trace ("subdividing wpf and winforms")
!! Constants.eyeshotWpfFiles
|> GlobbingPattern.setBaseDir targetDir
|> Seq.iter (fun filename -> moveToSubFolders filename (targetDir @@ Constants.wpfFolder))
!! Constants.eyeshotWinFormsFiles
|> GlobbingPattern.setBaseDir targetDir
|> Seq.iter (fun filename -> moveToSubFolders filename (targetDir @@ Constants.winFormsFolder))
// *****************************************************
// ******************* T A R G E T S *******************
// *****************************************************
Target.create "Clean" (fun _ ->
Shell.cleanDir Constants.binDir
)
Target.create "CopyFiles" (fun _ ->
files
|> Seq.iter copyToBuildFolder
)
Target.create "Commit" (fun _ ->
let version =
match Helpers.getAssemblySemVer dllPath with
| Some(ver) -> ver.AsString
| None -> failwith $"could not find dlls in path {dllPath} to get a version"
Trace.trace ("assembly version = " + version)
let stageAllFilesIn = DirectoryInfo.ofPath
>> DirectoryInfo.getMatchingFilesRecursive "*"
>> Seq.map (fun fileInfo -> fileInfo.FullName)
>> Seq.map (Git.Staging.stageFile baseDir)
>> Seq.map (fun (a,b,c)->a)
>> (fun stagingBools ->
if stagingBools |> Seq.contains false then None
else Some())
match stageAllFilesIn Constants.binDir with
| Some() -> Git.Commit.exec baseDir (sprintf "Update to version %s" version)
| None -> failwith "staging failed"
)
Target.create "All" (fun _ ->
Trace.trace "~~~~~~~~~~~ update finished ~~~~~~~~~~~"
Trace.trace "check the commited files and version number"
Trace.trace "run the build script next if you want to build a local package"
)
"Clean"
==> "CopyFiles"
==> "Commit"
==> "All"
Target.runOrDefault "All"