Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Oct 4, 2018
0 parents commit 14bbcfe
Show file tree
Hide file tree
Showing 30 changed files with 9,027 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.fake/
.vs/
obj/
bin/
packages/
paket-files/
node_modules/
src/Client/public/js/
release.cmd
release.sh
.idea/
*.DotSettings.user
deploy
/src/Server/bar.jpg
/tools/
/audio
/.ionide/symbolCache.db
/yarn-error.log
19 changes: 19 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cache:
paths:
- packages/
- node_modules/

stages:
- build

build:win:
stage: build
cache:
key: "%CI_COMMIT_REF_NAME"
script:
# - .\dotnet-install.ps1 -InstallDir tools
- IF EXIST build.cmd build.cmd Build
tags:
- Build
- NodeJS

300 changes: 300 additions & 0 deletions .paket/Paket.Restore.targets

Large diffs are not rendered by default.

Binary file added .paket/paket.exe
Binary file not shown.
10 changes: 10 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@echo off
cls

.paket\paket.exe restore
if errorlevel 1 (
exit /b %errorlevel%
)

dotnet tool install --tool-path tools fake-cli
tools\fake.exe build --target %*
122 changes: 122 additions & 0 deletions build.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#r "paket: groupref build //"
#load "./.fake/build.fsx/intellisense.fsx"

#if !FAKE
#r "netstandard"
#r "Facades/netstandard" // https://github.com/ionide/ionide-vscode-fsharp/issues/839#issuecomment-396296095
#endif

open System

open Fake.Core
open Fake.DotNet
open Fake.IO

let serverPath = Path.getFullName "./src/Server"
let piServerPath = Path.getFullName "./src/PiServer"
let clientPath = Path.getFullName "./src/Client"
let deployDir = Path.getFullName "./deploy"

let platformTool tool winTool =
let tool = if Environment.isUnix then tool else winTool
match Process.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. " +
"See https://safe-stack.github.io/docs/quickstart/#install-pre-requisites for more info"
failwith errorMsg

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

let install = lazy DotNet.install DotNet.Versions.FromGlobalJson

let inline withWorkDir wd =
DotNet.Options.lift install.Value
>> DotNet.Options.withWorkingDirectory wd

let runTool cmd args workingDir =
let result =
Process.execSimple (fun info ->
{ info with
FileName = cmd
WorkingDirectory = workingDir
Arguments = args })
TimeSpan.MaxValue
if result <> 0 then failwithf "'%s %s' failed" cmd args

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

let openBrowser url =
let result =
//https://github.com/dotnet/corefx/issues/10361
Process.execSimple (fun info ->
{ info with
FileName = url
UseShellExecute = true })
TimeSpan.MaxValue
if result <> 0 then failwithf "opening browser failed"

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

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__
runDotNet "restore" clientPath
)

Target.create "RestoreServer" (fun _ ->
runDotNet "restore" serverPath
runDotNet "restore" piServerPath
)

Target.create "Build" (fun _ ->
runDotNet "build" serverPath
runDotNet "build" piServerPath
runDotNet "fable webpack-cli -- --config src/Client/webpack.config.js -p" clientPath
)

Target.create "Run" (fun _ ->
let server = async {
runDotNet "watch run" serverPath
}
let piServer = async {
runDotNet "watch run" piServerPath
}
let client = async {
runDotNet "fable webpack-dev-server -- --config src/Client/webpack.config.js" clientPath
}
let browser = async {
do! Async.Sleep 5000
openBrowser "http://localhost:8080"
}

[ server; piServer; client; browser ]
|> Async.Parallel
|> Async.RunSynchronously
|> ignore
)


open Fake.Core.TargetOperators

"Clean"
==> "InstallClient"
==> "Build"

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

Target.runOrDefault "Build"
1 change: 1 addition & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "sdk": { "version": "2.1.402" } }
30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"private": true,
"dependencies": {
"@babel/polyfill": "7.0.0",
"@babel/runtime": "7.1.2",
"proj4": "^2.5.0",
"react": "16.5.2",
"react-bootstrap": "0.32.4",
"react-dom": "16.5.2",
"whatwg-fetch": "^3.0.0"
},
"devDependencies": {
"@babel/core": "7.1.2",
"@babel/plugin-transform-runtime": "7.1.0",
"@babel/preset-env": "7.1.0",
"@babel/preset-react": "7.0.0",
"babel-loader": "8.0.4",
"concurrently": "4.0.1",
"fable-loader": "2.0.0",
"fable-utils": "1.2.0",
"node-sass": "4.9.3",
"remotedev": "0.2.7",
"sass-loader": "7.1.0",
"style-loader": "0.23.0",
"terser-webpack-plugin": "^1.1.0",
"webpack": "4.20.2",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "3.1.9"
}
}
37 changes: 37 additions & 0 deletions paket.dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
group Server
storage: none
source https://api.nuget.org/v3/index.json

nuget FSharp.Core
nuget Saturn
nuget Microsoft.AspNetCore.NodeServices

group Client
storage: none
source https://api.nuget.org/v3/index.json

nuget Fable.Core
nuget Fable.Elmish.Debugger
nuget Fable.Elmish.React
nuget Fable.Elmish.HMR
nuget Fulma

clitool dotnet-fable

group Build
storage: none
source https://api.nuget.org/v3/index.json

nuget FSharp.Core 4.3.4 // https://github.com/fsharp/FAKE/issues/2001
nuget Fake.Core.Target
nuget Fake.DotNet.Cli
nuget Fake.IO.FileSystem


group Test
storage: none
source https://api.nuget.org/v3/index.json

nuget FSharp.Core
nuget expecto
nuget Expecto.FsCheck
Loading

0 comments on commit 14bbcfe

Please sign in to comment.