Skip to content

Commit

Permalink
Safeupdate (#17)
Browse files Browse the repository at this point in the history
* make it build

* shows date in title

* better date format

* tools update

* paket update

* logging smapi method as debug

* update steps safe2

* npm update

* updated github actions

* removed comments

* default is bundle
  • Loading branch information
brase committed Oct 14, 2020
1 parent b8ce7e4 commit 6fff243
Show file tree
Hide file tree
Showing 21 changed files with 9,498 additions and 6,637 deletions.
12 changes: 6 additions & 6 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
"version": 1,
"isRoot": true,
"tools": {
"fake-cli": {
"version": "5.20.1",
"paket": {
"version": "6.0.0-alpha014",
"commands": [
"fake"
"paket"
]
},
"paket": {
"version": "5.247.2",
"fake-cli": {
"version": "5.20.3",
"commands": [
"paket"
"fake"
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
dotnet: [3.1.300]
dotnet: [3.1.402]
runs-on: ${{ matrix.os }}

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dockerpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.300
dotnet-version: 3.1.402
- name: Restore tools
run: dotnet tool restore
- name: Restore dependencies
Expand Down
111 changes: 41 additions & 70 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,95 +14,74 @@ open Fake.IO

Target.initEnvironment ()

let sharedPath = Path.getFullName "./src/Shared"
let serverPath = Path.getFullName "./src/Server"
let clientPath = Path.getFullName "./src/Client"
let clientDeployPath = Path.combine clientPath "deploy"
let deployDir = Path.getFullName "./deploy"
let sharedTestsPath = Path.getFullName "./tests/Shared"
let serverTestsPath = Path.getFullName "./tests/Smapi.Tests"

let release = ReleaseNotes.load "RELEASE_NOTES.md"

let platformTool tool winTool =
let tool = if Environment.isUnix then tool else winTool
match ProcessUtils.tryFindFileOnPath tool with
| Some t -> t
| _ ->
let errorMsg =
tool + " was not found in path. " +
"Please install it and make sure it's available from your path. " +
let npm args workingDir =
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 errorMsg
|> failwith

let nodeTool = platformTool "node" "node.exe"
let yarnTool = platformTool "yarn" "yarn.cmd"

let runTool cmd args workingDir =
let arguments = args |> String.split ' ' |> Arguments.OfArgs
Command.RawCommand (cmd, arguments)

Command.RawCommand (npmPath, arguments)
|> CreateProcess.fromCommand
|> CreateProcess.withWorkingDirectory workingDir
|> CreateProcess.ensureExitCode
|> Proc.run
|> ignore

let runDotNet cmd workingDir =
let result =
DotNet.exec (DotNet.Options.withWorkingDirectory workingDir) cmd ""
let dotnet cmd workingDir =
let result = DotNet.exec (DotNet.Options.withWorkingDirectory workingDir) cmd ""
if result.ExitCode <> 0 then failwithf "'dotnet %s' failed in %s" cmd workingDir

let openBrowser url =
//https://github.com/dotnet/corefx/issues/10361
Command.ShellCommand url

let runTool cmd args workingDir =
let arguments = args |> String.split ' ' |> Arguments.OfArgs
Command.RawCommand (cmd, arguments)
|> CreateProcess.fromCommand
|> CreateProcess.ensureExitCodeWithMessage "opening browser failed"
|> CreateProcess.withWorkingDirectory workingDir
|> CreateProcess.ensureExitCode
|> Proc.run
|> ignore


Target.create "Clean" (fun _ ->
[ deployDir
clientDeployPath ]
|> Shell.cleanDirs
)

Target.create "InstallClient" (fun _ ->
printfn "Node version:"
runTool nodeTool "--version" __SOURCE_DIRECTORY__
printfn "Yarn version:"
runTool yarnTool "--version" __SOURCE_DIRECTORY__
runTool yarnTool "install --frozen-lockfile" __SOURCE_DIRECTORY__
)
Target.create "InstallClient" (fun _ -> npm "install" ".")

Target.create "Build" (fun _ ->
runDotNet "build" serverPath
Shell.regexReplaceInFileWithEncoding
"let app = \".+\""
("let app = \"" + release.NugetVersion + "\"")
System.Text.Encoding.UTF8
(Path.combine clientPath "Version.fs")
runTool yarnTool "webpack-cli -p" __SOURCE_DIRECTORY__
Target.create "Bundle" (fun _ ->
dotnet (sprintf "publish -c Release -o \"%s\"" deployDir) serverPath
npm "run build" "."
)

Target.create "Run" (fun _ ->
let server = async {
runDotNet "watch run" serverPath
}
let client = async {
runTool yarnTool "webpack-dev-server" __SOURCE_DIRECTORY__
}
let browser = async {
do! Async.Sleep 5000
openBrowser "http://localhost:8080"
}

let vsCodeSession = Environment.hasEnvironVar "vsCodeSession"
let safeClientOnly = Environment.hasEnvironVar "safeClientOnly"

let tasks =
[ if not safeClientOnly then yield server
yield client
if not vsCodeSession then yield browser ]

tasks
dotnet "build" sharedPath
[ async { dotnet "watch run" serverPath }
async { npm "run start" "." } ]
|> Async.Parallel
|> Async.RunSynchronously
|> ignore
)

Target.create "RunTests" (fun _ ->
//dotnet "build" sharedTestsPath
[ async { dotnet "watch run" serverTestsPath }
async { npm "run test:live" "." } ]
|> Async.Parallel
|> Async.RunSynchronously
|> ignore
Expand All @@ -112,17 +91,6 @@ let buildDocker tag =
let args = sprintf "build -t %s ." tag
runTool "docker" args __SOURCE_DIRECTORY__

Target.create "Bundle" (fun _ ->
let serverDir = Path.combine deployDir "Server"
let clientDir = Path.combine deployDir "Client"
let publicDir = Path.combine clientDir "public"

let publishArgs = sprintf "publish -c Release -o \"%s\"" serverDir
runDotNet publishArgs serverPath

Shell.copyDir publicDir clientDeployPath FileFilter.allFiles
)

let dockerUser = "murocast"
let dockerImageName = "murocast"
let dockerFullName = sprintf "%s/%s" dockerUser dockerImageName
Expand All @@ -135,12 +103,15 @@ open Fake.Core.TargetOperators

"Clean"
==> "InstallClient"
==> "Build"
==> "Bundle"
==> "Docker"

"Clean"
==> "InstallClient"
==> "Run"

Target.runOrDefaultWithArguments "Build"
"Clean"
==> "InstallClient"
==> "RunTests"

Target.runOrDefaultWithArguments "Bundle"
109 changes: 59 additions & 50 deletions castos.sln
Original file line number Diff line number Diff line change
@@ -1,50 +1,59 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2005
MinimumVisualStudioVersion = 10.0.40219.1
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Client", "src\Client\Client.fsproj", "{73E8E820-C8AA-47CC-BB2B-152CA4D0B855}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Server", "src\Server\Server.fsproj", "{73E8E820-C8AA-47CC-BB2B-152CA4D0B856}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Smapi", "src\Smapi\Smapi.fsproj", "{C4A9FB13-66A6-4E32-83D6-A0ED229829AA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{DDFDB8C6-E642-427C-B9D1-70C516DFCEEF}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Smapi.Tests", "tests\Smapi.Tests\Smapi.Tests.fsproj", "{43CF6E5F-3E88-4EA3-9AED-EBCF5F041EEC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{73E8E820-C8AA-47CC-BB2B-152CA4D0B855}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{73E8E820-C8AA-47CC-BB2B-152CA4D0B855}.Debug|Any CPU.Build.0 = Debug|Any CPU
{73E8E820-C8AA-47CC-BB2B-152CA4D0B855}.Release|Any CPU.ActiveCfg = Release|Any CPU
{73E8E820-C8AA-47CC-BB2B-152CA4D0B855}.Release|Any CPU.Build.0 = Release|Any CPU
{C4A9FB13-66A6-4E32-83D6-A0ED229829AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C4A9FB13-66A6-4E32-83D6-A0ED229829AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C4A9FB13-66A6-4E32-83D6-A0ED229829AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C4A9FB13-66A6-4E32-83D6-A0ED229829AA}.Release|Any CPU.Build.0 = Release|Any CPU
{43CF6E5F-3E88-4EA3-9AED-EBCF5F041EEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{43CF6E5F-3E88-4EA3-9AED-EBCF5F041EEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{43CF6E5F-3E88-4EA3-9AED-EBCF5F041EEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{43CF6E5F-3E88-4EA3-9AED-EBCF5F041EEC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{73E8E820-C8AA-47CC-BB2B-152CA4D0B856}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{73E8E820-C8AA-47CC-BB2B-152CA4D0B856}.Debug|Any CPU.Build.0 = Debug|Any CPU
{73E8E820-C8AA-47CC-BB2B-152CA4D0B856}.Release|Any CPU.ActiveCfg = Release|Any CPU
{73E8E820-C8AA-47CC-BB2B-152CA4D0B856}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7A0AA30E-4CD9-4359-9513-BA68E2E85245}
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{43CF6E5F-3E88-4EA3-9AED-EBCF5F041EEC} = {DDFDB8C6-E642-427C-B9D1-70C516DFCEEF}
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2005
MinimumVisualStudioVersion = 10.0.40219.1
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Client", "src\Client\Client.fsproj", "{73E8E820-C8AA-47CC-BB2B-152CA4D0B855}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Server", "src\Server\Server.fsproj", "{73E8E820-C8AA-47CC-BB2B-152CA4D0B856}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Smapi", "src\Smapi\Smapi.fsproj", "{C4A9FB13-66A6-4E32-83D6-A0ED229829AA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{DDFDB8C6-E642-427C-B9D1-70C516DFCEEF}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Smapi.Tests", "tests\Smapi.Tests\Smapi.Tests.fsproj", "{43CF6E5F-3E88-4EA3-9AED-EBCF5F041EEC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{3D389B64-F763-4C13-8933-330000AE22F2}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Shared", "src\Shared\Shared.fsproj", "{9280A632-14B1-4CF1-AB8E-F8A186BFE30F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{73E8E820-C8AA-47CC-BB2B-152CA4D0B855}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{73E8E820-C8AA-47CC-BB2B-152CA4D0B855}.Debug|Any CPU.Build.0 = Debug|Any CPU
{73E8E820-C8AA-47CC-BB2B-152CA4D0B855}.Release|Any CPU.ActiveCfg = Release|Any CPU
{73E8E820-C8AA-47CC-BB2B-152CA4D0B855}.Release|Any CPU.Build.0 = Release|Any CPU
{C4A9FB13-66A6-4E32-83D6-A0ED229829AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C4A9FB13-66A6-4E32-83D6-A0ED229829AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C4A9FB13-66A6-4E32-83D6-A0ED229829AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C4A9FB13-66A6-4E32-83D6-A0ED229829AA}.Release|Any CPU.Build.0 = Release|Any CPU
{43CF6E5F-3E88-4EA3-9AED-EBCF5F041EEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{43CF6E5F-3E88-4EA3-9AED-EBCF5F041EEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{43CF6E5F-3E88-4EA3-9AED-EBCF5F041EEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{43CF6E5F-3E88-4EA3-9AED-EBCF5F041EEC}.Release|Any CPU.Build.0 = Release|Any CPU
{9280A632-14B1-4CF1-AB8E-F8A186BFE30F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9280A632-14B1-4CF1-AB8E-F8A186BFE30F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9280A632-14B1-4CF1-AB8E-F8A186BFE30F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9280A632-14B1-4CF1-AB8E-F8A186BFE30F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{73E8E820-C8AA-47CC-BB2B-152CA4D0B856}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{73E8E820-C8AA-47CC-BB2B-152CA4D0B856}.Debug|Any CPU.Build.0 = Debug|Any CPU
{73E8E820-C8AA-47CC-BB2B-152CA4D0B856}.Release|Any CPU.ActiveCfg = Release|Any CPU
{73E8E820-C8AA-47CC-BB2B-152CA4D0B856}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7A0AA30E-4CD9-4359-9513-BA68E2E85245}
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{43CF6E5F-3E88-4EA3-9AED-EBCF5F041EEC} = {DDFDB8C6-E642-427C-B9D1-70C516DFCEEF}
{9280A632-14B1-4CF1-AB8E-F8A186BFE30F} = {3D389B64-F763-4C13-8933-330000AE22F2}
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "3.1.300"
"version": "3.1.402"
}
}
Loading

0 comments on commit 6fff243

Please sign in to comment.