Skip to content

Commit

Permalink
Update FAKE sample to format out of process. Fixes #686. (#1911)
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Oct 8, 2021
1 parent 565d6ae commit c12fa2d
Show file tree
Hide file tree
Showing 4 changed files with 211 additions and 75 deletions.
8 changes: 7 additions & 1 deletion fake-sample/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
"isRoot": true,
"tools": {
"fake-cli": {
"version": "5.20.3",
"version": "5.20.4",
"commands": [
"fake"
]
},
"fantomas-tool": {
"version": "4.5.4",
"commands": [
"fantomas"
]
}
}
}
9 changes: 7 additions & 2 deletions fake-sample/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# FAKE sample - .NET Core 3
# FAKE sample

1. Restore FAKE locally:

Expand All @@ -8,7 +8,12 @@ This was installed by:

> dotnet new tool-manifest
> dotnet tool install fake-cli
> dotnet tool install fantomas-tool
2. Execute script:

> dotnet fake run script.fsx -t Format
> dotnet fake run script.fsx -t Format
Check the format afterwards:

> dotnet fake run script.fsx -t CheckFormat
56 changes: 32 additions & 24 deletions fake-sample/script.fsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
#r "paket:
nuget Fantomas.Extras 4.3.0
nuget Fake.Core.Target //"
nuget Fake.Core.Target
nuget Fake.DotNet.Cli
nuget FSharp.Core 5.0.2 //"
#load "./.fake/script.fsx/intellisense.fsx"

open Fake.Core
open Fake.IO
open Fake.IO.Globbing.Operators
open Fantomas
open Fantomas.Extras
open Fantomas.FormatConfig
open Fake.DotNet

Target.create "CheckCodeFormat" (fun _ ->
let result =
!!"*.fs"
|> FakeHelpers.checkCode
|> Async.RunSynchronously
let sourceFiles = !! "*.fs"

if result.IsValid then
Trace.log "No files need formatting"
elif result.NeedsFormatting then
Trace.log "The following files need formatting:"
List.iter Trace.log result.Formatted
failwith "Some files need formatting, check output for more info"
else
Trace.logf "Errors while formatting: %A" result.Errors)
Target.create
"CheckFormat"
(fun _ ->
let result =
sourceFiles
|> Seq.map (sprintf "\"%s\"")
|> String.concat " "
|> sprintf "%s --check"
|> DotNet.exec id "fantomas"

Target.create "Format" (fun _ ->
!!"*.fs"
|> FakeHelpers.formatCode
|> Async.RunSynchronously
|> printfn "Formatted files: %A")
if result.ExitCode = 0 then
Trace.log "No files need formatting"
elif result.ExitCode = 99 then
failwith "Some files need formatting, check output for more info"
else
Trace.logf "Errors while formatting: %A" result.Errors)

Target.runOrList()
Target.create
"Format"
(fun _ ->
let result =
sourceFiles
|> Seq.map (sprintf "\"%s\"")
|> String.concat " "
|> DotNet.exec id "fantomas"

if not result.OK then
printfn "Errors while formatting all files: %A" result.Messages)

Target.runOrList ()
213 changes: 165 additions & 48 deletions fake-sample/script.fsx.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,69 +2,162 @@ STORAGE: NONE
RESTRICTION: == netstandard2.0
NUGET
remote: https://api.nuget.org/v3/index.json
editorconfig (0.12.2)
Fake.Core.CommandLineParsing (5.20.3)
BlackFox.VsWhere (1.1)
FSharp.Core (>= 4.2.3)
Microsoft.Win32.Registry (>= 4.7)
Fake.Core.CommandLineParsing (5.20.4)
FParsec (>= 1.1.1)
FSharp.Core (>= 4.7.2)
Fake.Core.Context (5.20.3)
Fake.Core.Context (5.20.4)
FSharp.Core (>= 4.7.2)
Fake.Core.Environment (5.20.3)
Fake.Core.Environment (5.20.4)
FSharp.Core (>= 4.7.2)
Fake.Core.FakeVar (5.20.3)
Fake.Core.Context (>= 5.20.3)
Fake.Core.FakeVar (5.20.4)
Fake.Core.Context (>= 5.20.4)
FSharp.Core (>= 4.7.2)
Fake.Core.Process (5.20.3)
Fake.Core.Environment (>= 5.20.3)
Fake.Core.FakeVar (>= 5.20.3)
Fake.Core.String (>= 5.20.3)
Fake.Core.Trace (>= 5.20.3)
Fake.IO.FileSystem (>= 5.20.3)
Fake.Core.Process (5.20.4)
Fake.Core.Environment (>= 5.20.4)
Fake.Core.FakeVar (>= 5.20.4)
Fake.Core.String (>= 5.20.4)
Fake.Core.Trace (>= 5.20.4)
Fake.IO.FileSystem (>= 5.20.4)
FSharp.Core (>= 4.7.2)
System.Collections.Immutable (>= 1.7.1)
Fake.Core.String (5.20.3)
FSharp.Core (>= 4.7.2)
Fake.Core.Target (5.20.3)
Fake.Core.CommandLineParsing (>= 5.20.3)
Fake.Core.Context (>= 5.20.3)
Fake.Core.Environment (>= 5.20.3)
Fake.Core.FakeVar (>= 5.20.3)
Fake.Core.Process (>= 5.20.3)
Fake.Core.String (>= 5.20.3)
Fake.Core.Trace (>= 5.20.3)
Fake.Core.SemVer (5.20.4)
FSharp.Core (>= 4.7.2)
Fake.Core.String (5.20.4)
FSharp.Core (>= 4.7.2)
Fake.Core.Target (5.20.4)
Fake.Core.CommandLineParsing (>= 5.20.4)
Fake.Core.Context (>= 5.20.4)
Fake.Core.Environment (>= 5.20.4)
Fake.Core.FakeVar (>= 5.20.4)
Fake.Core.Process (>= 5.20.4)
Fake.Core.String (>= 5.20.4)
Fake.Core.Trace (>= 5.20.4)
FSharp.Control.Reactive (>= 4.4.2)
FSharp.Core (>= 4.7.2)
Fake.Core.Trace (5.20.3)
Fake.Core.Environment (>= 5.20.3)
Fake.Core.FakeVar (>= 5.20.3)
FSharp.Core (>= 4.7.2)
Fake.IO.FileSystem (5.20.3)
Fake.Core.String (>= 5.20.3)
FSharp.Core (>= 4.7.2)
Fantomas (4.3)
FSharp.Compiler.Service (>= 38.0)
FSharp.Core (>= 5.0)
Fantomas.Extras (4.3)
editorconfig (>= 0.12.2)
Fantomas (>= 4.3)
FSharp.Core (>= 5.0)
MAB.DotIgnore (>= 3.0.2)
Fake.Core.Tasks (5.20.4)
Fake.Core.Trace (>= 5.20.4)
FSharp.Core (>= 4.7.2)
Fake.Core.Trace (5.20.4)
Fake.Core.Environment (>= 5.20.4)
Fake.Core.FakeVar (>= 5.20.4)
FSharp.Core (>= 4.7.2)
Fake.Core.Xml (5.20.4)
Fake.Core.String (>= 5.20.4)
FSharp.Core (>= 4.7.2)
Fake.DotNet.Cli (5.20.4)
Fake.Core.Environment (>= 5.20.4)
Fake.Core.Process (>= 5.20.4)
Fake.Core.String (>= 5.20.4)
Fake.Core.Trace (>= 5.20.4)
Fake.DotNet.MSBuild (>= 5.20.4)
Fake.DotNet.NuGet (>= 5.20.4)
Fake.IO.FileSystem (>= 5.20.4)
FSharp.Core (>= 4.7.2)
Mono.Posix.NETStandard (>= 1.0)
Newtonsoft.Json (>= 12.0.3)
Fake.DotNet.MSBuild (5.20.4)
BlackFox.VsWhere (>= 1.1)
Fake.Core.Environment (>= 5.20.4)
Fake.Core.Process (>= 5.20.4)
Fake.Core.String (>= 5.20.4)
Fake.Core.Trace (>= 5.20.4)
Fake.IO.FileSystem (>= 5.20.4)
FSharp.Core (>= 4.7.2)
MSBuild.StructuredLogger (>= 2.1.176)
Fake.DotNet.NuGet (5.20.4)
Fake.Core.Environment (>= 5.20.4)
Fake.Core.Process (>= 5.20.4)
Fake.Core.SemVer (>= 5.20.4)
Fake.Core.String (>= 5.20.4)
Fake.Core.Tasks (>= 5.20.4)
Fake.Core.Trace (>= 5.20.4)
Fake.Core.Xml (>= 5.20.4)
Fake.IO.FileSystem (>= 5.20.4)
Fake.Net.Http (>= 5.20.4)
FSharp.Core (>= 4.7.2)
Newtonsoft.Json (>= 12.0.3)
NuGet.Protocol (>= 5.6)
Fake.IO.FileSystem (5.20.4)
Fake.Core.String (>= 5.20.4)
FSharp.Core (>= 4.7.2)
Fake.Net.Http (5.20.4)
Fake.Core.Trace (>= 5.20.4)
FSharp.Core (>= 4.7.2)
FParsec (1.1.1)
FSharp.Core (>= 4.3.4)
FSharp.Compiler.Service (38.0)
FSharp.Core (5.0)
FSharp.Control.Reactive (4.5)
FSharp.Core (>= 4.7.2)
System.Reactive (>= 4.4.1)
FSharp.Core (5.0)
MAB.DotIgnore (3.0.2)
NETStandard.Library (>= 1.6.1)
Microsoft.NETCore.Platforms (5.0)
FSharp.Control.Reactive (5.0.2)
FSharp.Core (>= 4.7.2)
System.Reactive (>= 5.0)
FSharp.Core (5.0.2)
Microsoft.Build (16.11)
Microsoft.Build.Framework (16.11)
System.Security.Permissions (>= 4.7)
Microsoft.Build.Tasks.Core (16.11)
Microsoft.Build.Framework (>= 16.11)
Microsoft.Build.Utilities.Core (>= 16.11)
Microsoft.NET.StringTools (>= 1.0)
Microsoft.Win32.Registry (>= 4.3)
System.CodeDom (>= 4.4)
System.Collections.Immutable (>= 5.0)
System.Reflection.Metadata (>= 1.6)
System.Resources.Extensions (>= 4.6)
System.Security.Cryptography.Pkcs (>= 4.7)
System.Security.Cryptography.Xml (>= 4.7)
System.Security.Permissions (>= 4.7)
System.Threading.Tasks.Dataflow (>= 4.9)
Microsoft.Build.Utilities.Core (16.11)
Microsoft.Build.Framework (>= 16.11)
Microsoft.NET.StringTools (>= 1.0)
Microsoft.Win32.Registry (>= 4.3)
System.Collections.Immutable (>= 5.0)
System.Configuration.ConfigurationManager (>= 4.7)
System.Security.Permissions (>= 4.7)
System.Text.Encoding.CodePages (>= 4.0.1)
Microsoft.NET.StringTools (1.0)
System.Memory (>= 4.5.4)
System.Runtime.CompilerServices.Unsafe (>= 5.0)
Microsoft.NETCore.Platforms (5.0.3)
Microsoft.NETCore.Targets (5.0)
NETStandard.Library (2.0.3)
Microsoft.NETCore.Platforms (>= 1.1)
Microsoft.Win32.Registry (5.0)
System.Buffers (>= 4.5.1)
System.Memory (>= 4.5.4)
System.Security.AccessControl (>= 5.0)
System.Security.Principal.Windows (>= 5.0)
Mono.Posix.NETStandard (1.0)
MSBuild.StructuredLogger (2.1.545)
Microsoft.Build (>= 16.10)
Microsoft.Build.Framework (>= 16.10)
Microsoft.Build.Tasks.Core (>= 16.10)
Microsoft.Build.Utilities.Core (>= 16.10)
Newtonsoft.Json (13.0.1)
NuGet.Common (5.11)
NuGet.Frameworks (>= 5.11)
NuGet.Configuration (5.11)
NuGet.Common (>= 5.11)
System.Security.Cryptography.ProtectedData (>= 4.4)
NuGet.Frameworks (5.11)
NuGet.Packaging (5.11)
Newtonsoft.Json (>= 9.0.1)
NuGet.Configuration (>= 5.11)
NuGet.Versioning (>= 5.11)
System.Security.Cryptography.Cng (>= 5.0)
System.Security.Cryptography.Pkcs (>= 5.0)
NuGet.Protocol (5.11)
NuGet.Packaging (>= 5.11)
NuGet.Versioning (5.11)
System.Buffers (4.5.1)
System.CodeDom (5.0)
System.Collections.Immutable (5.0)
System.Memory (>= 4.5.4)
System.Configuration.ConfigurationManager (5.0)
System.Security.Cryptography.ProtectedData (>= 5.0)
System.Security.Permissions (>= 5.0)
System.Formats.Asn1 (5.0)
System.Buffers (>= 4.5.1)
System.Memory (>= 4.5.4)
System.Memory (4.5.4)
System.Buffers (>= 4.5.1)
System.Numerics.Vectors (>= 4.4)
Expand All @@ -73,11 +166,35 @@ NUGET
System.Reactive (5.0)
System.Runtime.InteropServices.WindowsRuntime (>= 4.3)
System.Threading.Tasks.Extensions (>= 4.5.4)
System.Reflection.Metadata (5.0)
System.Collections.Immutable (>= 5.0)
System.Resources.Extensions (5.0)
System.Memory (>= 4.5.4)
System.Runtime (4.3.1)
Microsoft.NETCore.Platforms (>= 1.1.1)
Microsoft.NETCore.Targets (>= 1.1.3)
System.Runtime.CompilerServices.Unsafe (5.0)
System.Runtime.InteropServices.WindowsRuntime (4.3)
System.Runtime (>= 4.3)
System.Security.AccessControl (5.0)
System.Security.Principal.Windows (>= 5.0)
System.Security.Cryptography.Cng (5.0)
System.Security.Cryptography.Pkcs (5.0.1)
System.Buffers (>= 4.5.1)
System.Formats.Asn1 (>= 5.0)
System.Memory (>= 4.5.4)
System.Security.Cryptography.Cng (>= 5.0)
System.Security.Cryptography.ProtectedData (5.0)
System.Memory (>= 4.5.4)
System.Security.Cryptography.Xml (5.0)
System.Memory (>= 4.5.4)
System.Security.Cryptography.Pkcs (>= 5.0)
System.Security.Permissions (>= 5.0)
System.Security.Permissions (5.0)
System.Security.AccessControl (>= 5.0)
System.Security.Principal.Windows (5.0)
System.Text.Encoding.CodePages (5.0)
System.Runtime.CompilerServices.Unsafe (>= 5.0)
System.Threading.Tasks.Dataflow (5.0)
System.Threading.Tasks.Extensions (4.5.4)
System.Runtime.CompilerServices.Unsafe (>= 4.5.3)

0 comments on commit c12fa2d

Please sign in to comment.