From af055d60fbd33191fde86a579a5d68470d2f8896 Mon Sep 17 00:00:00 2001 From: SchlenkR Date: Thu, 26 Sep 2024 09:50:59 +0200 Subject: [PATCH] convert ps1 to sh --- .gitignore | 1 + build.fsx | 18 ++++++++++++++---- docu-watch.ps1 | 1 - docu-watch.sh | 1 + docu.ps1 | 39 --------------------------------------- docu.sh | 38 ++++++++++++++++++++++++++++++++++++++ publish.ps1 | 1 - publish.sh | 1 + test.ps1 | 1 - test.sh | 1 + 10 files changed, 56 insertions(+), 46 deletions(-) delete mode 100644 docu-watch.ps1 create mode 100644 docu-watch.sh delete mode 100644 docu.ps1 create mode 100644 docu.sh delete mode 100644 publish.ps1 create mode 100644 publish.sh delete mode 100644 test.ps1 create mode 100644 test.sh diff --git a/.gitignore b/.gitignore index 1a09e227..dfeeaad3 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ symbolCache.db .paket/load docs/index.md +output/ # User-specific files *.suo diff --git a/build.fsx b/build.fsx index bda65edc..ff475257 100644 --- a/build.fsx +++ b/build.fsx @@ -1,4 +1,3 @@ - System.Environment.CurrentDirectory <- __SOURCE_DIRECTORY__ #r "nuget: Fake.Core.Process" @@ -29,15 +28,26 @@ module Helper = runTarget t type Args() = + let strippedArgs = + fsi.CommandLineArgs + |> Array.skipWhile (fun x -> x <> __SOURCE_FILE__ ) + |> Array.skip 1 + |> Array.toList let taskName,taskArgs = - match fsi.CommandLineArgs |> Array.toList with - | fsi :: taskName :: taskArgs -> taskName, taskArgs + match strippedArgs with + | taskName :: taskArgs -> taskName, taskArgs | _ -> let msg = $"Wrong args. Expected: fsi :: taskName :: taskArgs" printfn "%s" msg Environment.Exit -1 failwith msg - member _.IsTask(arg) = taskName = arg + do + printfn $"Task name: {taskName}" + printfn $"Task args: {taskArgs}" + member _.IsTask(arg) = + let res = taskName = arg + printfn $"Checking task '{arg}'... {res} (taskName: '{taskName}')" + res member _.TaskArgs = taskArgs let args = Args() diff --git a/docu-watch.ps1 b/docu-watch.ps1 deleted file mode 100644 index 810ab8a8..00000000 --- a/docu-watch.ps1 +++ /dev/null @@ -1 +0,0 @@ -./docu.ps1 watch diff --git a/docu-watch.sh b/docu-watch.sh new file mode 100644 index 00000000..fd82ae09 --- /dev/null +++ b/docu-watch.sh @@ -0,0 +1 @@ +./docu.sh watch \ No newline at end of file diff --git a/docu.ps1 b/docu.ps1 deleted file mode 100644 index 8492c2cc..00000000 --- a/docu.ps1 +++ /dev/null @@ -1,39 +0,0 @@ - -$docuIndexYamlHeader = @' ---- -IMPORTANT: This file is generated by `./docu.ps1`. Please don't edit it manually! - -title: FsHttp Overview -index: 1 ---- - -'@ -$readmeContent = Get-Content ./README.md -Raw -($docuIndexYamlHeader + $readmeContent) | Out-File ./docs/index.md - - - - -if ((Test-Path .\.fsdocs) -eq $true) { - Remove-Item .\.fsdocs\ -Force -Recurse -} - -dotnet tool restore -dotnet build ./src/FsHttp/FsHttp.fsproj -c Release -f net6.0 - -# what a hack... -if ($null -eq $args[0]) { - $mode = "build" -} else { - $mode = "watch" -} - -dotnet fsdocs ` - $mode ` - --clean ` - --sourcefolder ./src ` - --properties Configuration=Release TargetFramework=net6.0 ` - --sourcerepo https://github.com/fsprojects/FsHttp/blob/master/src ` - --parameters root /FsHttp/ ` - --strict ` - --output ./.docsOutput diff --git a/docu.sh b/docu.sh new file mode 100644 index 00000000..1a78da3b --- /dev/null +++ b/docu.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +docuIndexYamlHeader="--- +IMPORTANT: This file is generated by \`./docu.sh\`. Please don't edit it manually! + +title: FsHttp Overview +index: 1 +--- + +" +readmeContent=$(cat ./README.md) +echo "$docuIndexYamlHeader$readmeContent" > ./docs/index.md + +if [ -d ./.fsdocs ]; then + rm -rf ./.fsdocs +fi + +dotnet tool restore +dotnet build ./src/FsHttp/FsHttp.fsproj -c Release -f net6.0 + +# what a hack... +if [ -z "$1" ]; then + mode="build" +else + mode="watch" +fi + +dotnet fsdocs \ + $mode \ + --clean \ + --sourcefolder ./src \ + --properties Configuration=Release TargetFramework=net6.0 \ + --sourcerepo https://github.com/fsprojects/FsHttp/blob/master/src \ + --parameters root /FsHttp/ \ + --output ./.docsOutput \ + --ignoreprojects Test.CSharp.csproj \ + --strict + \ No newline at end of file diff --git a/publish.ps1 b/publish.ps1 deleted file mode 100644 index 76f55b09..00000000 --- a/publish.ps1 +++ /dev/null @@ -1 +0,0 @@ -dotnet fsi build.fsx publish diff --git a/publish.sh b/publish.sh new file mode 100644 index 00000000..a021420e --- /dev/null +++ b/publish.sh @@ -0,0 +1 @@ +dotnet fsi build.fsx publish \ No newline at end of file diff --git a/test.ps1 b/test.ps1 deleted file mode 100644 index 0c342884..00000000 --- a/test.ps1 +++ /dev/null @@ -1 +0,0 @@ -dotnet fsi build.fsx test $Args diff --git a/test.sh b/test.sh new file mode 100644 index 00000000..6718047c --- /dev/null +++ b/test.sh @@ -0,0 +1 @@ +dotnet fsi build.fsx test \ No newline at end of file