Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade v4 #109

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
e4bc38c
docs: declaring safestack
Feb 12, 2022
d772393
docs: change logo and some description
Feb 12, 2022
c4dad6b
feat: init safe stack project
Feb 12, 2022
2e4afca
milestone: wip installing fable.reactstrap
Feb 13, 2022
8280b51
feat: make navbar conduit
Feb 14, 2022
0ac9062
feat: login page
riza-wartek May 15, 2022
9130803
feat: separate into client components
riza-wartek May 15, 2022
ae9923c
refactor: cleaning index
riza-wartek May 15, 2022
583d0d8
refactor: rename index into Conduit
riza-wartek Jun 19, 2022
48b8fe1
refactor: rename folder
riza-wartek Jun 19, 2022
a8a8418
refactor: reorg files in client project
riza-wartek Jul 2, 2022
71d9d4e
feat: adding interface for login API. Interface only, logic not imple…
riza-wartek Jul 3, 2022
476e7f1
feat: add register page
riza-wartek Jul 31, 2022
55f0d75
feat: halfway home page
Aug 5, 2022
803c4aa
TDD preparation
Aug 6, 2022
dc5a9b7
error: still cannot compile
Aug 7, 2022
9b47093
feat: this is the last time continue with own effort. After this, go …
Aug 7, 2022
85756a0
uncompiled
Aug 7, 2022
745462e
fix: router compilable
Aug 7, 2022
a59e1c3
fix: login alright
Aug 7, 2022
0363318
feat: login without API done
Aug 8, 2022
855a67f
refactor: move some code to Shared project, connect to page register,…
Aug 17, 2022
a8c7a6e
add changes for page login only
Aug 20, 2022
72ca1bd
feat: implement register, copy and edit from login
Aug 20, 2022
e5cb373
fix: adding dispatch when input on field
Aug 20, 2022
3912489
refactor: adding new line
Aug 20, 2022
31a3fa9
Merge pull request #2 from rizaramadan/register-page
rizaramadan Aug 20, 2022
15b1efc
refactor: remove combine navigation and home
Jan 21, 2023
c9add56
refactor: handle warnings
Jan 21, 2023
bff8f22
feat: implementation of login in server side
Jan 22, 2023
d484913
feat: working skeleton login
Jan 23, 2023
b185c74
feat: add New Article skeleton
Jan 29, 2023
5b50057
feat: checkpoint
Apr 3, 2023
d8d2690
skeleton new article
Apr 4, 2023
70692eb
feat: register implemented
Apr 5, 2023
3f05bce
add setting page skeleton
Apr 5, 2023
117d05b
feat: server tests using real db
Apr 7, 2023
cf74340
feat: update SAFE-stack v3 to v4
Apr 8, 2023
955f185
upgrade: safe stack v3 to v4, still error
Apr 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"version": 1,
"isRoot": true,
"tools": {
"paket": {
"version": "7.0.2",
"commands": [
"paket"
]
},
"fable": {
"version": "3.7.5",
"commands": [
"fable"
]
},
"fantomas-tool": {
"version": "4.7.1",
"commands": [
"fantomas"
]
},
"femto": {
"version": "0.12.0",
"commands": [
"femto"
]
}
}
}
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false

[src/Client/*.fs]
# Feliz style
fsharp_single_argument_web_mode=true
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
.fable/
*.fs.js
*.fs.js.map
.fake/
.farmer/
.idea/
.ionide/
.vs/
deploy/
obj/
bin/
output/
packages/
paket-files/
node_modules/
release.cmd
release.sh
*.orig
*.DotSettings.user
*.fsproj.user

# See http://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
557 changes: 557 additions & 0 deletions .paket/Paket.Restore.targets

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp

// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"ionide.ionide-fsharp",
"ms-dotnettools.csharp",
"editorconfig.editorconfig"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": [

]
}
83 changes: 83 additions & 0 deletions Build.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
open Fake.Core
open Fake.IO
open Farmer
open Farmer.Builders

open Helpers

initializeContext()

let sharedPath = Path.getFullName "src/Shared"
let serverPath = Path.getFullName "src/Server"
let clientPath = Path.getFullName "src/Client"
let deployPath = Path.getFullName "deploy"
let sharedTestsPath = Path.getFullName "tests/Shared"
let serverTestsPath = Path.getFullName "tests/Server"
let clientTestsPath = Path.getFullName "tests/Client"

Target.create "Clean" (fun _ ->
Shell.cleanDir deployPath
run dotnet "fable clean --yes" clientPath // Delete *.fs.js files created by Fable
)

Target.create "InstallClient" (fun _ -> run npm "install" ".")

Target.create "Bundle" (fun _ ->
[ "server", dotnet $"publish -c Release -o \"{deployPath}\"" serverPath
"client", dotnet "fable -o output -s --run npm run build" clientPath ]
|> runParallel
)

Target.create "Azure" (fun _ ->
let web = webApp {
name "safestack_realworld_example_app"
operating_system OS.Windows
runtime_stack Runtime.DotNet60
zip_deploy "deploy"
}
let deployment = arm {
location Location.WestEurope
add_resource web
}

deployment
|> Deploy.execute "safestack_realworld_example_app" Deploy.NoParameters
|> ignore
)

Target.create "Run" (fun _ ->
run dotnet "build" sharedPath
[ "server", dotnet "watch run" serverPath
"client", dotnet "fable watch -o output -s --run npm run start" clientPath ]
|> runParallel
)

Target.create "RunTests" (fun _ ->
run dotnet "build" sharedTestsPath
[ "server", dotnet "watch run" serverTestsPath
"client", dotnet "fable watch -o output -s --run npm run test:live" clientTestsPath ]
|> runParallel
)

Target.create "Format" (fun _ ->
run dotnet "fantomas . -r" "src"
)

open Fake.Core.TargetOperators

let dependencies = [
"Clean"
==> "InstallClient"
==> "Bundle"
==> "Azure"

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

"InstallClient"
==> "RunTests"
]

[<EntryPoint>]
let main args = runOrDefault args
11 changes: 11 additions & 0 deletions Build.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Helpers.fs" />
<Compile Include="Build.fs" />
</ItemGroup>
<Import Project=".paket\Paket.Restore.targets" />
</Project>
104 changes: 104 additions & 0 deletions Helpers.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
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
54 changes: 44 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,57 @@
# ![RealWorld Example App](logo.png)
# SAFE Template

> ### [YOUR_FRAMEWORK] codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the [RealWorld](https://github.com/gothinkster/realworld) spec and API.
This template can be used to generate a full-stack web application using the [SAFE Stack](https://safe-stack.github.io/). It was created using the dotnet [SAFE Template](https://safe-stack.github.io/docs/template-overview/). If you want to learn more about the template why not start with the [quick start](https://safe-stack.github.io/docs/quickstart/) guide?

## Install pre-requisites

### [Demo](https://demo.realworld.io/)&nbsp;&nbsp;&nbsp;&nbsp;[RealWorld](https://github.com/gothinkster/realworld)
You'll need to install the following pre-requisites in order to build SAFE applications

* [.NET Core SDK](https://www.microsoft.com/net/download) 6.0 or higher
* [Node 16](https://nodejs.org/en/download/)

This codebase was created to demonstrate a fully fledged fullstack application built with **[YOUR_FRAMEWORK]** including CRUD operations, authentication, routing, pagination, and more.
## Starting the application

We've gone to great lengths to adhere to the **[YOUR_FRAMEWORK]** community styleguides & best practices.
Before you run the project **for the first time only** you must install dotnet "local tools" with this command:

For more information on how to this works with other frontends/backends, head over to the [RealWorld](https://github.com/gothinkster/realworld) repo.
```bash
dotnet tool restore
```

To concurrently run the server and the client components in watch mode use the following command:

# How it works
```bash
dotnet run
```

> Describe the general architecture of your app here
Then open `http://localhost:8080` in your browser.

# Getting started
The build project in root directory contains a couple of different build targets. You can specify them after `--` (target name is case-insensitive).

> npm install, npm start, etc.
To run concurrently server and client tests in watch mode (you can run this command in parallel to the previous one in new terminal):

```bash
dotnet run -- RunTests
```

Client tests are available under `http://localhost:8081` in your browser and server tests are running in watch mode in console.

Finally, there are `Bundle` and `Azure` targets that you can use to package your app and deploy to Azure, respectively:

```bash
dotnet run -- Bundle
dotnet run -- Azure
```

## SAFE Stack Documentation

If you want to know more about the full Azure Stack and all of it's components (including Azure) visit the official [SAFE documentation](https://safe-stack.github.io/docs/).

You will find more documentation about the used F# components at the following places:

* [Saturn](https://saturnframework.org/)
* [Fable](https://fable.io/docs/)
* [Elmish](https://elmish.github.io/elmish/)

# MISC

install Feliz.Router, see https://www.compositional-it.com/news-blog/elmish-navigation-with-feliz-router/
Loading