From 5e70a9213167f68f8a10a966017d112662f29011 Mon Sep 17 00:00:00 2001 From: Isaac Abraham Date: Sat, 30 May 2020 16:40:09 +0200 Subject: [PATCH] Updated full version of template. --- Content/.config/dotnet-tools.json | 6 - Content/.config/safe.json | 3 - Content/.devcontainer/Dockerfile | 19 --- Content/.devcontainer/devcontainer.json | 11 -- Content/.devcontainer/settings.vscode.json | 3 - Content/.gitignore | 9 +- Content/.template.config/template.json | 1 - Content/.vscode/extensions.json | 3 +- Content/.vscode/launch.json | 51 ------- Content/.vscode/tasks.json | 81 ----------- Content/README.md | 2 - Content/RELEASE_NOTES.md | 2 - Content/build.fsx | 102 ++++---------- Content/src/Client/Client.fs | 138 +++++++++++-------- Content/src/Client/Client.fsproj | 1 - Content/src/Client/Version.fs | 5 - Content/src/Client/webpack.default.config.js | 2 +- build.fsx | 6 - 18 files changed, 111 insertions(+), 334 deletions(-) delete mode 100644 Content/.config/safe.json delete mode 100644 Content/.devcontainer/Dockerfile delete mode 100644 Content/.devcontainer/devcontainer.json delete mode 100644 Content/.devcontainer/settings.vscode.json delete mode 100644 Content/.vscode/launch.json delete mode 100644 Content/.vscode/tasks.json delete mode 100644 Content/RELEASE_NOTES.md delete mode 100644 Content/src/Client/Version.fs diff --git a/Content/.config/dotnet-tools.json b/Content/.config/dotnet-tools.json index 092cbc28..eb503a71 100644 --- a/Content/.config/dotnet-tools.json +++ b/Content/.config/dotnet-tools.json @@ -2,12 +2,6 @@ "version": 1, "isRoot": true, "tools": { - "safe.tool": { - "version": "0.0.6", - "commands": [ - "safe" - ] - }, "paket": { "version": "6.0.0-alpha014", "commands": [ diff --git a/Content/.config/safe.json b/Content/.config/safe.json deleted file mode 100644 index 04f01a26..00000000 --- a/Content/.config/safe.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "plugins": [ ] -} \ No newline at end of file diff --git a/Content/.devcontainer/Dockerfile b/Content/.devcontainer/Dockerfile deleted file mode 100644 index 9b9a516c..00000000 --- a/Content/.devcontainer/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -FROM mcr.microsoft.com/dotnet/core/sdk:2.2 - -# Add keys and sources lists -RUN curl -sL https://deb.nodesource.com/setup_11.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 yarn git procps - -# Clean up -RUN apt-get autoremove -y \ - && apt-get clean -y \ - && rm -rf /var/lib/apt/lists/* - -# 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 diff --git a/Content/.devcontainer/devcontainer.json b/Content/.devcontainer/devcontainer.json deleted file mode 100644 index 7ce9e100..00000000 --- a/Content/.devcontainer/devcontainer.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "SAFE", - "dockerFile": "Dockerfile", - "appPort": [8080, 8085], - "extensions": [ - "ionide.ionide-fsharp", - "ms-vscode.csharp", - "editorconfig.editorconfig", - "msjsdiag.debugger-for-chrome" - ] -} \ No newline at end of file diff --git a/Content/.devcontainer/settings.vscode.json b/Content/.devcontainer/settings.vscode.json deleted file mode 100644 index 5b238fae..00000000 --- a/Content/.devcontainer/settings.vscode.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "FSharp.fsacRuntime":"netcore" -} \ No newline at end of file diff --git a/Content/.gitignore b/Content/.gitignore index 96c20b51..958c47bd 100644 --- a/Content/.gitignore +++ b/Content/.gitignore @@ -1,16 +1,15 @@ .fable/ .fake/ +.idea/ +.ionide/ .vs/ +deploy/ obj/ bin/ packages/ paket-files/ node_modules/ -src/Client/public/js/ release.cmd release.sh -.idea/ *.orig -*.DotSettings.user -deploy -.ionide/ \ No newline at end of file +*.DotSettings.user \ No newline at end of file diff --git a/Content/.template.config/template.json b/Content/.template.config/template.json index fd9afa3b..ad5caa84 100644 --- a/Content/.template.config/template.json +++ b/Content/.template.config/template.json @@ -49,7 +49,6 @@ "RELEASE_NOTES.md", "**/paket.*", "*.fsx", - "src/Client/Version.fs", "src/Client/webpack.default.config.js", "README.md" ], diff --git a/Content/.vscode/extensions.json b/Content/.vscode/extensions.json index a453eb87..3feca77c 100644 --- a/Content/.vscode/extensions.json +++ b/Content/.vscode/extensions.json @@ -7,8 +7,7 @@ "ionide.ionide-fsharp", "ms-dotnettools.csharp", "editorconfig.editorconfig", - "msjsdiag.debugger-for-chrome", - "ms-vscode-remote.remote-containers" + "msjsdiag.debugger-for-chrome" ], // List of extensions recommended by VS Code that should not be recommended for users of this workspace. "unwantedRecommendations": [ diff --git a/Content/.vscode/launch.json b/Content/.vscode/launch.json deleted file mode 100644 index 009d776f..00000000 --- a/Content/.vscode/launch.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": "Debug Server", - "type": "coreclr", - "request": "launch", - "preLaunchTask": "Build Server", - "program": "${workspaceFolder}/src/Server/bin/Debug/netcoreapp3.0/Server.dll", - "args": [], - "logging": { - "moduleLoad": false - }, - "stopAtEntry": false, - "console": "internalConsole", - }, - { - "name": "Debug Client", - "type": "chrome", - "request": "launch", - "preLaunchTask": "Watch Client", - "url": "http://localhost:8080", - "webRoot": "${workspaceFolder}/src/Client", - "sourceMaps": true, - "sourceMapPathOverrides": { - "webpack:///*": "${workspaceFolder}/*", - } - }, - { - "name": "Watch SAFE App", - "type": "chrome", - "request": "launch", - "preLaunchTask": "Watch Client and Server", - "url": "http://localhost:8080", - "env": { - "vsCodeSession":"true" - }, - "webRoot": "${workspaceFolder}/src/Client", - "sourceMaps": true, - "sourceMapPathOverrides": { - "webpack:///*": "${workspaceFolder}/*", - } - } - ], - "compounds": [ - { - "name": "Debug SAFE App", - "configurations": [ "Debug Server", "Debug Client" ], - } - ] -} \ No newline at end of file diff --git a/Content/.vscode/tasks.json b/Content/.vscode/tasks.json deleted file mode 100644 index 45d34316..00000000 --- a/Content/.vscode/tasks.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format - "version": "2.0.0", - "tasks": [ - { - "label": "Build Server", - "command": "dotnet", - "args": [ "build" ], - "type": "shell", - "options": { "cwd": "${workspaceFolder}/src/Server" }, - "group": "build", - "problemMatcher": [ "$msCompile" ] - }, - { - "label": "Watch Client and Server", - "command": "dotnet", - "args": [ "fake", "build", "-t", "Run" ], - "type": "shell", - "options": { - "cwd": "${workspaceFolder}", - "env": { - "vsCodeSession": "true" - } - }, - "group": "build", - "isBackground": true, - "problemMatcher": { - "fileLocation": "absolute", - "background": { - "beginsPattern": { "regexp": "run Run" }, - "endsPattern": { "regexp": "i 「wdm」: Compiled|ℹ 「wdm」: Compiled|The terminal process terminated" }, - "activeOnStart": true - }, - "pattern": { - "regexp": "^(.*)\\((\\d+),(\\d+)\\): \\((\\d+),(\\d+)\\) (warning|error) FABLE: (.*)$", - "file": 1, - "line": 2, - "column": 3, - "endLine": 4, - "endColumn": 5, - "severity": 6, - "message": 7 - } - } - }, - { - "label": "Watch Client", - "command": "dotnet", - "args": [ "fake", "build", "-t", "Run" ], - "type": "shell", - "options": { - "cwd": "${workspaceFolder}", - "env": { - "vsCodeSession": "true", - "safeClientOnly": "true" - } - }, - "group": "build", - "isBackground": true, - "problemMatcher": { - "fileLocation": "absolute", - "background": { - "beginsPattern": { "regexp": "run Run" }, - "endsPattern": { "regexp": "i 「wdm」: Compiled|ℹ 「wdm」: Compiled|The terminal process terminated" }, - "activeOnStart": true - }, - "pattern": { - "regexp": "^(.*)\\((\\d+),(\\d+)\\): \\((\\d+),(\\d+)\\) (warning|error) FABLE: (.*)$", - "file": 1, - "line": 2, - "column": 3, - "endLine": 4, - "endColumn": 5, - "severity": 6, - "message": 7 - } - } - } - ] -} \ No newline at end of file diff --git a/Content/README.md b/Content/README.md index b374970b..fc991780 100644 --- a/Content/README.md +++ b/Content/README.md @@ -9,7 +9,6 @@ You'll need to install the following pre-requisites in order to build SAFE appli * The [.NET Core SDK](https://www.microsoft.com/net/download) * The [Yarn](https://yarnpkg.com/lang/en/docs/install/) package manager (you can also use `npm` but the usage of `yarn` is encouraged). * [Node LTS](https://nodejs.org/en/download/) installed for the front end components. -* If you're running on OSX or Linux, you'll also need to install [Mono](https://www.mono-project.com/docs/getting-started/install/). ## Work with the application @@ -19,7 +18,6 @@ Before you run the project **for the first time only** you should install its lo dotnet tool restore ``` - To concurrently run the server and the client components in watch mode use the following command: ```bash diff --git a/Content/RELEASE_NOTES.md b/Content/RELEASE_NOTES.md deleted file mode 100644 index 645750fd..00000000 --- a/Content/RELEASE_NOTES.md +++ /dev/null @@ -1,2 +0,0 @@ -### 0.0.1 - 1970-01-01 -* Initial release diff --git a/Content/build.fsx b/Content/build.fsx index 58eca60d..c2724bf7 100644 --- a/Content/build.fsx +++ b/Content/build.fsx @@ -1,10 +1,7 @@ #r "paket: groupref build //" #load "./.fake/build.fsx/intellisense.fsx" - #r "netstandard" -open System - open Fake.Core open Fake.DotNet open Fake.IO @@ -13,92 +10,47 @@ Target.initEnvironment () let serverPath = Path.getFullName "./src/Server" let clientPath = Path.getFullName "./src/Client" -let clientDeployPath = Path.combine clientPath "deploy" let deployDir = Path.getFullName "./deploy" -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. " + - "See https://safe-stack.github.io/docs/quickstart/#install-pre-requisites for more info" - failwith errorMsg - -let nodeTool = platformTool "node" "node.exe" -let npmTool = platformTool "npm" "npm.cmd" -let npxTool = platformTool "npx" "npx.cmd" -let runTool cmd args workingDir = +let npm args workingDir = + let npmPath = + let npmPath = if Environment.isUnix then "npm" else "npm.cmd" + + npmPath + |> ProcessUtils.tryFindFileOnPath + |> Option.defaultWith(fun () -> + let errorMsg = + npmPath + + " 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 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 - |> CreateProcess.fromCommand - |> CreateProcess.ensureExitCodeWithMessage "opening browser failed" - |> Proc.run - |> ignore +Target.create "Clean" (fun _ -> Shell.cleanDir deployDir) -Target.create "Clean" (fun _ -> - [ deployDir - clientDeployPath ] - |> Shell.cleanDirs -) - -Target.create "InstallClient" (fun _ -> - printfn "Node version:" - runTool nodeTool "--version" clientPath - printfn "Npm version:" - runTool npmTool "--version" clientPath - runTool npmTool "install" clientPath -) +Target.create "InstallClient" (fun _ -> npm "install" clientPath) -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 npxTool "webpack-cli -p" clientPath +Target.create "Bundle" (fun _ -> + dotnet (sprintf "publish -c Release -o \"%s\"" deployDir) serverPath + npm "run build" clientPath ) Target.create "Run" (fun _ -> - let server = async { - runDotNet "watch run" serverPath - } - let client = async { - runTool npxTool "webpack-dev-server" clientPath - } - 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 + [ async { dotnet "watch run" serverPath } + async { npm "run start" clientPath } ] |> Async.Parallel |> Async.RunSynchronously |> ignore @@ -108,10 +60,10 @@ open Fake.Core.TargetOperators "Clean" ==> "InstallClient" - ==> "Build" + ==> "Bundle" "Clean" ==> "InstallClient" ==> "Run" -Target.runOrDefaultWithArguments "Build" +Target.runOrDefaultWithArguments "Bundle" diff --git a/Content/src/Client/Client.fs b/Content/src/Client/Client.fs index 42af10f4..6ac3fda4 100644 --- a/Content/src/Client/Client.fs +++ b/Content/src/Client/Client.fs @@ -58,72 +58,90 @@ open Fulma let safeComponents = let components = - span [] - [ a [ Href "https://github.com/SAFE-Stack/SAFE-template" ] - [ str "SAFE " - str Version.template ] - str ", " - a [ Href "https://saturnframework.github.io" ] [ str "Saturn" ] - str ", " - a [ Href "http://fable.io" ] [ str "Fable" ] - str ", " - a [ Href "https://elmish.github.io" ] [ str "Elmish" ] ] - - footer [ ] - [ str "Version " - strong [] [ str Version.app ] - str " powered by: " - components ] + span [] [ + a [ Href "https://github.com/SAFE-Stack/SAFE-template" ] [ str "SAFE" ] + str ", " + a [ Href "https://saturnframework.github.io" ] [ str "Saturn" ] + str ", " + a [ Href "http://fable.io" ] [ str "Fable" ] + str ", " + a [ Href "https://elmish.github.io" ] [ str "Elmish" ] + ] + + footer [ ] [ + str "Version " + str " powered by: " + components + ] let navBrand = - Navbar.Brand.div [ ] - [ Navbar.Item.a - [ Navbar.Item.Props [ Href "https://safe-stack.github.io/" ] - Navbar.Item.IsActive true ] - [ img [ Src "https://safe-stack.github.io/images/safe_top.png" - Alt "Logo" ] ] ] + Navbar.Brand.div [ ] [ + Navbar.Item.a [ + Navbar.Item.Props [ Href "https://safe-stack.github.io/" ] + Navbar.Item.IsActive true + ] [ + img [ Src "https://safe-stack.github.io/images/safe_top.png" + Alt "Logo" ] + ] + ] let containerBox (model : Model) (dispatch : Msg -> unit) = - Box.box' [ ] - [ Field.div [ Field.IsGrouped ] - [ Control.p [ Control.IsExpanded ] - [ Input.text - [ Input.Disabled true - Input.Value (show model) ] ] - Control.p [ ] - [ Button.a - [ Button.Color IsPrimary - Button.OnClick (fun _ -> dispatch Increment) ] - [ str "+" ] ] - Control.p [ ] - [ Button.a - [ Button.Color IsPrimary - Button.OnClick (fun _ -> dispatch Decrement) ] - [ str "-" ] ] ] ] + Box.box' [ ] [ + Field.div [ Field.IsGrouped ] [ + Control.p [ Control.IsExpanded ] [ + Input.text [ Input.Disabled true; Input.Value (show model) ] + ] + Control.p [ ] [ + Button.a [ + Button.Color IsPrimary + Button.OnClick (fun _ -> dispatch Increment) + ] [ + str "+" + ] + ] + Control.p [ ] [ + Button.a [ + Button.Color IsPrimary + Button.OnClick (fun _ -> dispatch Decrement) + ] [ + str "-" + ] + ] + ] + ] let view (model : Model) (dispatch : Msg -> unit) = - Hero.hero - [ Hero.Color IsPrimary - Hero.IsFullHeight - Hero.Props - [ Style - [ Background """linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url("https://unsplash.it/1200/900?random") no-repeat center center fixed""" - BackgroundSize "cover" ] ] ] - [ Hero.head [ ] - [ Navbar.navbar [ ] - [ Container.container [ ] - [ navBrand ] ] ] - - Hero.body [ ] - [ Container.container [ Container.Modifiers [ Modifier.TextAlignment (Screen.All, TextAlignment.Centered) ] ] - [ Column.column - [ Column.Width (Screen.All, Column.Is6) - Column.Offset (Screen.All, Column.Is3) ] - [ Heading.p [ ] - [ str "SAFE Template" ] - Heading.p [ Heading.IsSubtitle ] - [ safeComponents ] - containerBox model dispatch ] ] ] ] + Hero.hero [ + Hero.Color IsPrimary + Hero.IsFullHeight + Hero.Props [ + Style [ + Background """linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url("https://unsplash.it/1200/900?random") no-repeat center center fixed""" + BackgroundSize "cover" + ] + ] + ] [ + Hero.head [ ] [ + Navbar.navbar [ ] [ + Container.container [ ] [ navBrand ] + ] + ] + + Hero.body [ ] [ + Container.container [ + Container.Modifiers [ Modifier.TextAlignment (Screen.All, TextAlignment.Centered) ] + ] [ + Column.column [ + Column.Width (Screen.All, Column.Is6) + Column.Offset (Screen.All, Column.Is3) + ] [ + Heading.p [ ] [ str "SAFE Template" ] + Heading.p [ Heading.IsSubtitle ] [ safeComponents ] + containerBox model dispatch + ] + ] + ] + ] (*#endif*) //-:cnd:noEmit diff --git a/Content/src/Client/Client.fsproj b/Content/src/Client/Client.fsproj index 8c586734..770f843d 100644 --- a/Content/src/Client/Client.fsproj +++ b/Content/src/Client/Client.fsproj @@ -12,7 +12,6 @@ - diff --git a/Content/src/Client/Version.fs b/Content/src/Client/Version.fs deleted file mode 100644 index 38210593..00000000 --- a/Content/src/Client/Version.fs +++ /dev/null @@ -1,5 +0,0 @@ -module Version - -let template = "2.0.0-alpha001" - -let app = "0.0.1" \ No newline at end of file diff --git a/Content/src/Client/webpack.default.config.js b/Content/src/Client/webpack.default.config.js index edea9b84..780ba49f 100644 --- a/Content/src/Client/webpack.default.config.js +++ b/Content/src/Client/webpack.default.config.js @@ -17,7 +17,7 @@ var CONFIG = { indexHtmlTemplate: './index.html', fsharpEntry: './Client.fsproj', cssEntry: './style.scss', - outputDir: './deploy', + outputDir: './../../deploy/public', assetsDir: './public', devServerPort: 8080, // When using webpack-dev-server, you may need to redirect some calls diff --git a/build.fsx b/build.fsx index a167bba3..de6f104c 100644 --- a/build.fsx +++ b/build.fsx @@ -15,7 +15,6 @@ open Fake.IO.Globbing.Operators open Fake.Tools let templatePath = "./Content/.template.config/template.json" -let versionFilePath = "./Content/src/Client/Version.fs" let templateProj = "SAFE.Template.proj" let templateName = "SAFE-Stack Web App" let nupkgDir = Path.getFullName "./nupkg" @@ -74,11 +73,6 @@ Target.create "Pack" (fun _ -> (" \"name\": \"" + templateName + " v" + release.NugetVersion + "\",") System.Text.Encoding.UTF8 templatePath - Shell.regexReplaceInFileWithEncoding - "let template = \".+\"" - ("let template = \"" + release.NugetVersion + "\"") - System.Text.Encoding.UTF8 - versionFilePath DotNet.pack (fun args -> { args with