-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpec.fs
More file actions
100 lines (89 loc) · 2.83 KB
/
Spec.fs
File metadata and controls
100 lines (89 loc) · 2.83 KB
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
module Spec
open EasyBuild.FileSystemProvider
open Fake.Core
module Files =
type Root = AbsoluteFileSystem<__SOURCE_DIRECTORY__>
module Ops =
[<Literal>]
let Setup = "Setup"
[<Literal>]
let Clean = "Clean"
[<Literal>]
let GitNet = "GitNet"
[<Literal>]
let Build = "Build"
[<Literal>]
let Pack = "Pack"
[<Literal>]
let GitPush = "GitPush"
[<Literal>]
let Publish = "Publish"
[<Literal>]
let GenerateLucide = "GenerateLucide"
[<Literal>]
let GenerateTabler = "GenerateTabler"
module Args =
let mutable local: bool = false
let mutable apiKey: string option = None
let mutable parallelise: bool = false
let setArgs args =
let containsArgs arg =
args |> Array.contains arg
let getArgValue arg =
args
|> Array.tryFindIndex ((=) arg)
|> Option.map ((+) 1)
|> Option.bind(fun idx ->
Array.tryItem idx args)
parallelise <- containsArgs "--parallel"
apiKey <- getArgValue "--nuget-api-key"
local <- containsArgs "--local"
open Fake.IO.Globbing.Operators
let sourceFiles =
!! "**/*.fs"
-- "**/obj/**/*.*"
-- "**/AssemblyInfo.fs"
[<Literal>]
let githubUsername = "GitHub Action"
[<Literal>]
let githubEmail = "41898282+github-actions[bot]@users.noreply.github.com"
// Credit SAFE STACK
let initializeContext () =
let execContext = Context.FakeExecutionContext.Create false "build.fsx" []
Context.setExecutionContext (Context.RuntimeContext.Fake execContext)
let createProcess exe args dir =
CreateProcess.fromRawCommand exe args
|> CreateProcess.withWorkingDirectory dir
|> CreateProcess.ensureExitCode
let dotnet args dir = createProcess "dotnet" args dir
module Parser =
type GitStatus =
| Added of string
| Modified of string
open XParsec
open XParsec.CharParsers
let parseGitStatus (arr: string list) =
let statusChars = tuple4 anyChar anyChar anyChar (manyChars anyChar)
let getGitStatusFrom (input: string) =
let reader = Reader.ofString input false
statusChars reader
|> function
| Ok { Parsed = value } -> Some value
| Error e ->
ErrorFormatting.formatStringError input e
|> printfn "%s"
None
|> Option.bind (fun struct (c1,c2,c3,path) ->
match c1,c2 with
| 'M', _
| _, 'M' ->
GitStatus.Modified path
|> Some
| 'A', _ ->
GitStatus.Added path
|> Some
| _ -> None
)
arr
|> List.map getGitStatusFrom
|> List.choose id