Skip to content

Commit

Permalink
wip: add Config.fs
Browse files Browse the repository at this point in the history
  • Loading branch information
tehraninasab committed Aug 3, 2023
1 parent 0db7884 commit ac9324e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
8 changes: 4 additions & 4 deletions scripts/styleApply.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ open FileConventions

let rootDir = Path.Combine(__SOURCE_DIRECTORY__, "..") |> DirectoryInfo

StyleFSharpFiles rootDir fantomlessToolVersion
StyleTypeScriptFiles prettierVersion
StyleYmlFiles prettierVersion
StyleFSharpFiles rootDir
StyleTypeScriptFiles()
StyleYmlFiles()
StyleCSharpFiles rootDir
StyleXamlFiles prettierVersion pluginXmlVersion
StyleXamlFiles()
8 changes: 4 additions & 4 deletions scripts/styleCheck.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ let CheckStyleOfFSharpFiles(rootDir: DirectoryInfo) : bool =

let success =
if ContainsFiles rootDir "*.fs" || ContainsFiles rootDir ".fsx" then
StyleFSharpFiles rootDir fantomlessToolVersion
StyleFSharpFiles rootDir
let processResult = GitDiff()
UnwrapProcessResult suggestion true processResult |> ignore
IsProcessSuccessful processResult
Expand All @@ -85,7 +85,7 @@ let CheckStyleOfTypeScriptFiles(rootDir: DirectoryInfo) : bool =

let success =
if ContainsFiles rootDir "*.ts" then
StyleTypeScriptFiles prettierVersion
StyleTypeScriptFiles()
let processResult = GitDiff()
UnwrapProcessResult suggestion true processResult |> ignore
IsProcessSuccessful processResult
Expand All @@ -107,7 +107,7 @@ let CheckStyleOfYmlFiles(rootDir: DirectoryInfo) : bool =

let success =
if ContainsFiles rootDir "*.yml" then
StyleYmlFiles prettierVersion
StyleYmlFiles()
let processResult = GitDiff()
UnwrapProcessResult suggestion true processResult |> ignore
IsProcessSuccessful processResult
Expand Down Expand Up @@ -149,7 +149,7 @@ let CheckStyleOfXamlFiles(rootDir: DirectoryInfo) : bool =

let success =
if ContainsFiles rootDir "*.xaml" then
StyleXamlFiles prettierVersion pluginXmlVersion
StyleXamlFiles()
let processResult = GitDiff()
UnwrapProcessResult suggestion true processResult |> ignore
IsProcessSuccessful processResult
Expand Down
6 changes: 6 additions & 0 deletions src/FileConventions/Config.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

module Config

let fantomlessToolVersion = "4.7.997-prerelease"
let prettierVersion = "2.8.3"
let pluginXmlVersion = "v2.2.0"
1 change: 1 addition & 0 deletions src/FileConventions/FileConventions.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</ItemGroup>

<ItemGroup>
<Compile Include="Config.fs" />
<Compile Include="Helpers.fs" />
<Compile Include="Library.fs" />
</ItemGroup>
Expand Down
9 changes: 5 additions & 4 deletions src/FileConventions/Library.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ open Fsdk
open Fsdk.Process

open Helpers
open Config

let HasCorrectShebang(fileInfo: FileInfo) =
let fileText = File.ReadLines fileInfo.FullName
Expand Down Expand Up @@ -385,7 +386,7 @@ let NonVerboseFlags(fileInfo: FileInfo) =
numInvalidFlags > 0


let StyleFSharpFiles (rootDir: DirectoryInfo) (fantomlessToolVersion: string) =
let StyleFSharpFiles (rootDir: DirectoryInfo) =
InstallFantomlessTool fantomlessToolVersion

Process
Expand All @@ -411,7 +412,7 @@ let StyleCSharpFiles(rootDir: DirectoryInfo) =
.UnwrapDefault()
|> ignore

let StyleXamlFiles (prettierVersion: string) (pluginXmlVersion: string) =
let StyleXamlFiles () =
InstallPrettier prettierVersion
InstallPrettierPluginXml pluginXmlVersion

Expand Down Expand Up @@ -448,15 +449,15 @@ let StyleXamlFiles (prettierVersion: string) (pluginXmlVersion: string) =
.UnwrapDefault()
|> ignore

let StyleTypeScriptFiles(prettierVersion: string) =
let StyleTypeScriptFiles() =
InstallPrettier prettierVersion

let pattern =
$"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}**{Path.DirectorySeparatorChar}*.ts"

RunPrettier $"--quote-props=consistent --write {pattern}"

let StyleYmlFiles(prettierVersion: string) =
let StyleYmlFiles() =
InstallPrettier prettierVersion

let pattern =
Expand Down

0 comments on commit ac9324e

Please sign in to comment.