feat: initial commit
This commit is contained in:
73
.build/Build.fs
Normal file
73
.build/Build.fs
Normal file
@@ -0,0 +1,73 @@
|
||||
open Fake.Core
|
||||
open Fake.IO
|
||||
open Farmer
|
||||
open Farmer.Builders
|
||||
|
||||
open Helpers
|
||||
|
||||
initializeContext()
|
||||
|
||||
let srcPath = Path.getFullName "src"
|
||||
let testPath = Path.getFullName "test"
|
||||
let libPath = None
|
||||
|
||||
let distPath = Path.getFullName "dist"
|
||||
let packPath = Path.getFullName "packages"
|
||||
let versionFile = Path.getFullName ".version"
|
||||
|
||||
Target.create "Clean" (fun _ -> Shell.cleanDir distPath)
|
||||
|
||||
Target.create "InstallClient" (fun _ ->
|
||||
run npm "install" "."
|
||||
run dotnet "tool restore" "."
|
||||
)
|
||||
|
||||
Target.create "Bundle" (fun _ ->
|
||||
run dotnet $"publish -c Release -o {distPath}" srcPath
|
||||
)
|
||||
|
||||
Target.create "BundleDebug" (fun _ ->
|
||||
run dotnet $"publish -c Debug -o {distPath}" srcPath
|
||||
)
|
||||
|
||||
Target.create "Pack" (fun _ ->
|
||||
match libPath with
|
||||
| Some p -> run dotnet $"pack -c Release -o {packPath}" p
|
||||
| None -> ()
|
||||
)
|
||||
|
||||
Target.create "Run" (fun _ -> run dotnet "watch run" srcPath)
|
||||
|
||||
Target.create "Format" (fun _ ->
|
||||
run dotnet "fantomas . -r" "src"
|
||||
)
|
||||
|
||||
Target.create "Test" (fun _ ->
|
||||
if System.IO.Directory.Exists testPath then
|
||||
run dotnet "run" testPath
|
||||
else ()
|
||||
)
|
||||
|
||||
open Fake.Core.TargetOperators
|
||||
|
||||
let dependencies = [
|
||||
"Clean"
|
||||
==> "InstallClient"
|
||||
==> "Bundle"
|
||||
|
||||
"Clean"
|
||||
==> "BundleDebug"
|
||||
|
||||
"Clean"
|
||||
==> "Test"
|
||||
|
||||
"Clean"
|
||||
==> "InstallClient"
|
||||
==> "Run"
|
||||
|
||||
"Clean"
|
||||
==> "Pack"
|
||||
]
|
||||
|
||||
[<EntryPoint>]
|
||||
let main args = runOrDefault args
|
||||
105
.build/Helpers.fs
Normal file
105
.build/Helpers.fs
Normal file
@@ -0,0 +1,105 @@
|
||||
module Helpers
|
||||
|
||||
open Fake.Core
|
||||
|
||||
let initializeContext () =
|
||||
let execContext = Context.FakeExecutionContext.Create false "build.fsx" [ ]
|
||||
Context.setExecutionContext (Context.RuntimeContext.Fake execContext)
|
||||
|
||||
module Proc =
|
||||
module Parallel =
|
||||
open System
|
||||
|
||||
let locker = obj()
|
||||
|
||||
let colors =
|
||||
[| ConsoleColor.Blue
|
||||
ConsoleColor.Yellow
|
||||
ConsoleColor.Magenta
|
||||
ConsoleColor.Cyan
|
||||
ConsoleColor.DarkBlue
|
||||
ConsoleColor.DarkYellow
|
||||
ConsoleColor.DarkMagenta
|
||||
ConsoleColor.DarkCyan |]
|
||||
|
||||
let print color (colored: string) (line: string) =
|
||||
lock locker
|
||||
(fun () ->
|
||||
let currentColor = Console.ForegroundColor
|
||||
Console.ForegroundColor <- color
|
||||
Console.Write colored
|
||||
Console.ForegroundColor <- currentColor
|
||||
Console.WriteLine line)
|
||||
|
||||
let onStdout index name (line: string) =
|
||||
let color = colors.[index % colors.Length]
|
||||
if isNull line then
|
||||
print color $"{name}: --- END ---" ""
|
||||
else if String.isNotNullOrEmpty line then
|
||||
print color $"{name}: " line
|
||||
|
||||
let onStderr name (line: string) =
|
||||
let color = ConsoleColor.Red
|
||||
if isNull line |> not then
|
||||
print color $"{name}: " line
|
||||
|
||||
let redirect (index, (name, createProcess)) =
|
||||
createProcess
|
||||
|> CreateProcess.redirectOutputIfNotRedirected
|
||||
|> CreateProcess.withOutputEvents (onStdout index name) (onStderr name)
|
||||
|
||||
let printStarting indexed =
|
||||
for (index, (name, c: CreateProcess<_>)) in indexed do
|
||||
let color = colors.[index % colors.Length]
|
||||
let wd =
|
||||
c.WorkingDirectory
|
||||
|> Option.defaultValue ""
|
||||
let exe = c.Command.Executable
|
||||
let args = c.Command.Arguments.ToStartInfo
|
||||
print color $"{name}: {wd}> {exe} {args}" ""
|
||||
|
||||
let run cs =
|
||||
cs
|
||||
|> Seq.toArray
|
||||
|> Array.indexed
|
||||
|> fun x -> printStarting x; x
|
||||
|> Array.map redirect
|
||||
|> Array.Parallel.map Proc.run
|
||||
|
||||
let createProcess exe arg dir =
|
||||
CreateProcess.fromRawCommandLine exe arg
|
||||
|> CreateProcess.withWorkingDirectory dir
|
||||
|> CreateProcess.ensureExitCode
|
||||
|
||||
let dotnet = createProcess "dotnet"
|
||||
let npm =
|
||||
let npmPath =
|
||||
match ProcessUtils.tryFindFileOnPath "npm" with
|
||||
| Some path -> path
|
||||
| None ->
|
||||
"npm was not found in path. Please install it and make sure it's available from your path. " +
|
||||
"See https://safe-stack.github.io/docs/quickstart/#install-pre-requisites for more info"
|
||||
|> failwith
|
||||
|
||||
createProcess npmPath
|
||||
|
||||
let run proc arg dir =
|
||||
proc arg dir
|
||||
|> Proc.run
|
||||
|> ignore
|
||||
|
||||
let runParallel processes =
|
||||
processes
|
||||
|> Proc.Parallel.run
|
||||
|> ignore
|
||||
|
||||
let runOrDefault args =
|
||||
try
|
||||
match args with
|
||||
| [| target |] -> Target.runOrDefault target
|
||||
| _ ->
|
||||
Target.runOrDefault "Run"
|
||||
0
|
||||
with e ->
|
||||
printfn "%A" e
|
||||
1
|
||||
18
.config/dotnet-tools.json
Normal file
18
.config/dotnet-tools.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"fable": {
|
||||
"version": "4.0.6",
|
||||
"commands": [
|
||||
"fable"
|
||||
]
|
||||
},
|
||||
"fantomas": {
|
||||
"version": "6.0.0-beta-001",
|
||||
"commands": [
|
||||
"fantomas"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
29
.devcontainer/Dockerfile
Normal file
29
.devcontainer/Dockerfile
Normal file
@@ -0,0 +1,29 @@
|
||||
FROM mcr.microsoft.com/dotnet/sdk:7.0
|
||||
|
||||
# Add keys and sources lists
|
||||
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash
|
||||
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
||||
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" \
|
||||
| tee /etc/apt/sources.list.d/yarn.list
|
||||
|
||||
# Install node, 7zip, yarn, git, process tools
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y nodejs p7zip-full git procps ssh-client
|
||||
|
||||
# Clean up
|
||||
RUN apt-get autoremove -y \
|
||||
&& apt-get clean -y \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install dotnet tools
|
||||
RUN dotnet tool install fable -g
|
||||
|
||||
# Trouble brewing
|
||||
RUN rm /etc/ssl/openssl.cnf
|
||||
|
||||
# add dotnet tools to path to pick up fake and paket installation
|
||||
ENV PATH="/root/.dotnet/tools:${PATH}"
|
||||
|
||||
# Copy endpoint specific user settings into container to specify
|
||||
# .NET Core should be used as the runtime.
|
||||
COPY settings.vscode.json /root/.vscode-remote/data/Machine/settings.json
|
||||
11
.devcontainer/devcontainer.json
Normal file
11
.devcontainer/devcontainer.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "SAFE",
|
||||
"dockerFile": "Dockerfile",
|
||||
"appPort": [8080, 8085],
|
||||
"extensions": [
|
||||
"ionide.ionide-fsharp",
|
||||
"ms-dotnettools.csharp",
|
||||
"editorconfig.editorconfig",
|
||||
"msjsdiag.debugger-for-chrome"
|
||||
]
|
||||
}
|
||||
3
.devcontainer/settings.vscode.json
Normal file
3
.devcontainer/settings.vscode.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"FSharp.fsacRuntime":"netcore"
|
||||
}
|
||||
32
.editorconfig
Normal file
32
.editorconfig
Normal file
@@ -0,0 +1,32 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = false
|
||||
|
||||
[*.fs]
|
||||
max_line_length=120
|
||||
# Feliz style
|
||||
fsharp_single_argument_web_mode=true
|
||||
fsharp_space_before_colon=false
|
||||
fsharp_max_if_then_else_short_width=60
|
||||
fsharp_max_infix_operator_expression=50
|
||||
fsharp_max_record_width=70
|
||||
fsharp_max_record_number_of_items=1
|
||||
fsharp_max_array_or_list_width=70
|
||||
fsharp_max_array_or_list_number_of_items=1
|
||||
fsharp_max_value_binding_width=70
|
||||
fsharp_max_function_binding_width=40
|
||||
fsharp_max_dot_get_expression_width=50
|
||||
fsharp_multiline_block_brackets_on_same_column=true
|
||||
fsharp_newline_between_type_definition_and_members=false
|
||||
fsharp_max_elmish_width=40
|
||||
fsharp_align_function_signature_to_indentation=false
|
||||
fsharp_alternative_long_member_definitions=false
|
||||
fsharp_multi_line_lambda_closing_newline=false
|
||||
fsharp_disable_elmish_syntax=false
|
||||
fsharp_keep_indent_in_branch=false
|
||||
fsharp_blank_lines_around_nested_multiline_expressions=false
|
||||
20
.gitignore
vendored
Normal file
20
.gitignore
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
.fable/
|
||||
.fake/
|
||||
.vs/
|
||||
.idea/
|
||||
.ionide/
|
||||
obj/
|
||||
bin/
|
||||
packages/
|
||||
node_modules/
|
||||
src/Client/public/js/
|
||||
release.cmd
|
||||
release.sh
|
||||
*.orig
|
||||
*.DotSettings.user
|
||||
deploy/
|
||||
dist/
|
||||
build/
|
||||
*.db
|
||||
build.fsx.lock
|
||||
_*.yaml
|
||||
8
.gitlab-ci.yml
Normal file
8
.gitlab-ci.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
variables:
|
||||
SKIP_TESTS: "true"
|
||||
|
||||
include:
|
||||
- project: oceanbox/gitlab-ci
|
||||
ref: v2
|
||||
file: Dotnet.gitlab-ci.yml
|
||||
|
||||
41
.releaserc.yaml
Normal file
41
.releaserc.yaml
Normal file
@@ -0,0 +1,41 @@
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
- name: develop
|
||||
prerelease: true
|
||||
|
||||
plugins:
|
||||
- '@semantic-release/commit-analyzer'
|
||||
- '@semantic-release/release-notes-generator'
|
||||
- - '@semantic-release/changelog'
|
||||
- changelogFile: RELEASE_NOTES.md
|
||||
changelogTitle: "# Changelog"
|
||||
- - 'semantic-release-dotnet'
|
||||
- paths: [ "src/*.fsproj", "src/*/*.fsproj" ]
|
||||
- - '@semantic-release/exec'
|
||||
- generateNotesCmd: "echo ${nextRelease.version} > .version"
|
||||
- - '@semantic-release/git'
|
||||
- message: "chore(release): ${nextRelease.version}\n\n${nextRelease.notes}"
|
||||
assets: [ "RELEASE_NOTES.md", ".version", "src/*.fsproj", "src/*/*.fsproj" ]
|
||||
- - '@semantic-release/gitlab'
|
||||
- assets: []
|
||||
|
||||
analyzeCommits:
|
||||
- path: "@semantic-release/commit-analyzer"
|
||||
releaseRules:
|
||||
- type: "fix"
|
||||
release: "patch"
|
||||
- type: "patch"
|
||||
release: "patch"
|
||||
- type: "feat"
|
||||
release: "minor"
|
||||
- type: "feature"
|
||||
release: "minor"
|
||||
- type: "minor"
|
||||
release: "minor"
|
||||
- type: "breaking"
|
||||
release: "major"
|
||||
- type: "major"
|
||||
release: "major"
|
||||
|
||||
|
||||
16
Build.fsproj
Normal file
16
Build.fsproj
Normal file
@@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include=".build/Helpers.fs" />
|
||||
<Compile Include=".build/Build.fs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Fake.Core.Target" Version="6.0.0" />
|
||||
<PackageReference Include="Fake.DotNet.Cli" Version="6.0.0" />
|
||||
<PackageReference Include="Fake.IO.FileSystem" Version="6.0.0" />
|
||||
<PackageReference Include="Farmer" Version="1.7.18" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
78
Cancan.sln
Normal file
78
Cancan.sln
Normal file
@@ -0,0 +1,78 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27004.2005
|
||||
MinimumVisualStudioVersion = 15.0.26124.0
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8FB8B894-4C13-4AD1-9D61-1DB30538F6D0}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
README.md = README.md
|
||||
LICENSE = LICENSE
|
||||
Dockerfile = Dockerfile
|
||||
.gitlab-ci.yml = .gitlab-ci.yml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Build", "Build.fsproj", "{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}"
|
||||
EndProject
|
||||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "src", "src/Cancan.fsproj", "{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}"
|
||||
EndProject
|
||||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "test", "test\Tests.fsproj", "{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}.Release|x64.Build.0 = Release|Any CPU
|
||||
{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{AF32198A-0A4C-4B12-82B2-5ABBC41EEBD9}.Release|x86.Build.0 = Release|Any CPU
|
||||
|
||||
{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}.Release|x64.Build.0 = Release|Any CPU
|
||||
{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{7C6E903C-53B7-425B-B562-3E4E0B10B3E6}.Release|x86.Build.0 = Release|Any CPU
|
||||
|
||||
{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}.Release|x64.Build.0 = Release|Any CPU
|
||||
{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{6A5C16D7-A2AA-4A7E-BC3C-DA59B577BD33}.Release|x86.Build.0 = Release|Any CPU
|
||||
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {F7486515-1BC3-4F9C-BE05-05466043A1AA}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
7
Dockerfile
Normal file
7
Dockerfile
Normal file
@@ -0,0 +1,7 @@
|
||||
FROM mcr.microsoft.com/dotnet/runtime:7.0
|
||||
RUN rm /etc/ssl/openssl.cnf
|
||||
|
||||
COPY deploy/ /app
|
||||
|
||||
WORKDIR /app
|
||||
CMD /app/PLACEHOLDER
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 Serit Tromsø AS
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
9
README.md
Normal file
9
README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# Cancan
|
||||
|
||||
## Run
|
||||
|
||||
`dotnet run`
|
||||
|
||||
## Build
|
||||
|
||||
`dotnet run Bundle`
|
||||
1
RELEASE_NOTES.md
Normal file
1
RELEASE_NOTES.md
Normal file
@@ -0,0 +1 @@
|
||||
# Changelog
|
||||
10009
package-lock.json
generated
Normal file
10009
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
11
package.json
Normal file
11
package.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"@semantic-release/changelog": "^6.0.1",
|
||||
"@semantic-release/exec": "^6.0.3",
|
||||
"@semantic-release/git": "^10.0.1",
|
||||
"@semantic-release/gitlab": "^7.0.4",
|
||||
"semantic-release-dotnet": "^1.0.0"
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
21
src/Cancan.fsproj
Normal file
21
src/Cancan.fsproj
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Settings.fs" />
|
||||
<Compile Include="Main.fs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Argu" Version="6.1.1" />
|
||||
<PackageReference Include="FSharp.Data" Version="5.0.2" />
|
||||
<PackageReference Include="FSharpPlus" Version="1.4.0" />
|
||||
<PackageReference Include="Serilog" Version="2.12.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Seq" Version="5.2.2" />
|
||||
<PackageReference Include="Thoth.Json.Net" Version="11.0.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
47
src/Main.fs
Normal file
47
src/Main.fs
Normal file
@@ -0,0 +1,47 @@
|
||||
module Main
|
||||
|
||||
open System
|
||||
open Serilog
|
||||
open Serilog.Events
|
||||
open Argu
|
||||
|
||||
open Settings
|
||||
|
||||
let configureSerilog level =
|
||||
let n =
|
||||
match level with
|
||||
| 0 -> LogEventLevel.Error
|
||||
| 1 -> LogEventLevel.Warning
|
||||
| 2 -> LogEventLevel.Information
|
||||
| 3 -> LogEventLevel.Debug
|
||||
| _ -> LogEventLevel.Verbose
|
||||
LoggerConfiguration()
|
||||
.MinimumLevel.Is(n)
|
||||
.WriteTo.Console()
|
||||
.CreateLogger()
|
||||
|
||||
type Arguments =
|
||||
| Log_Level of level: int
|
||||
| [<MainCommand; ExactlyOnce; Last>] File of file: string
|
||||
interface IArgParserTemplate with
|
||||
member this.Usage =
|
||||
match this with
|
||||
| Log_Level _ -> "0=Error, 1=Warning, 2=Info, 3=Debug, 4=Verbose"
|
||||
| File _ -> "file"
|
||||
|
||||
let colorizer =
|
||||
function
|
||||
| ErrorCode.HelpText -> None
|
||||
| _ -> Some ConsoleColor.Red
|
||||
|
||||
let errorHandler = ProcessExiter(colorizer = colorizer)
|
||||
|
||||
[<EntryPoint>]
|
||||
let main argv =
|
||||
let parser =
|
||||
ArgumentParser.Create<Arguments>(programName = "Cancan", errorHandler = errorHandler)
|
||||
let args = parser.Parse argv
|
||||
|
||||
Log.Logger <- configureSerilog (args.GetResult(Log_Level, defaultValue = 2))
|
||||
Log.Information $"File is {args.GetResult File}"
|
||||
0
|
||||
23
src/Settings.fs
Normal file
23
src/Settings.fs
Normal file
@@ -0,0 +1,23 @@
|
||||
module Settings
|
||||
|
||||
open System.IO
|
||||
open Thoth.Json.Net
|
||||
open Serilog
|
||||
|
||||
type Settings = { Setting: string }
|
||||
|
||||
let tryGetEnv =
|
||||
System.Environment.GetEnvironmentVariable
|
||||
>> function
|
||||
| null
|
||||
| "" -> None
|
||||
| x -> Some x
|
||||
|
||||
let appsettings =
|
||||
let settings = System.IO.File.ReadAllText "appsettings.json"
|
||||
|
||||
match Decode.Auto.fromString<Settings> settings with
|
||||
| Ok s -> s
|
||||
| Error e -> failwith e
|
||||
|
||||
sprintf "AppSettings: %A" appsettings |> Log.Debug
|
||||
3
src/appsettings.json
Normal file
3
src/appsettings.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"Setting" : "example setting"
|
||||
}
|
||||
18
test/Tests.fs
Normal file
18
test/Tests.fs
Normal file
@@ -0,0 +1,18 @@
|
||||
module Tests
|
||||
|
||||
open Expecto
|
||||
|
||||
let server =
|
||||
testList
|
||||
"Server"
|
||||
[
|
||||
testCase "Adding valid Todo"
|
||||
<| fun _ ->
|
||||
let expectedResult = Ok()
|
||||
Expect.equal (Ok()) expectedResult "Result should be ok"
|
||||
]
|
||||
|
||||
let all = testList "All" [ server ]
|
||||
|
||||
[<EntryPoint>]
|
||||
let main _ = runTests defaultConfig all
|
||||
16
test/Tests.fsproj
Normal file
16
test/Tests.fsproj
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Tests.fs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\src\Cancan.fsproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Expecto" Version="9.0.4" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user