From 1eb6829998a5135890fe1fa5130055c640bfeb7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Denuzi=C3=A8re?= Date: Sat, 25 May 2024 17:02:19 +0200 Subject: [PATCH] feat: Group --server and --render as --render --- .build/build.fs | 43 +++++++------ CHANGELOG.md | 7 ++- README.md | 36 +++++------ .../.template.config/template.json | 63 +++++++++---------- 4 files changed, 73 insertions(+), 76 deletions(-) diff --git a/.build/build.fs b/.build/build.fs index e7aa897..d203e9c 100644 --- a/.build/build.fs +++ b/.build/build.fs @@ -40,25 +40,22 @@ let buildOutputDir = slnDir "build" let packageName = "Bolero.Templates" let packageOutputFile o = buildOutputDir $"{packageName}.{version o}.nupkg" let variantsToTest = + let serverModes = [ + ("LegacyWasm","LegacyWebAssembly") + ("LegacyServer","LegacyServer") + ("IntServer", "InteractiveServer") + ("IntWasm", "InteractiveWebAssembly") + ("IntAuto", "InteractiveAuto") + ] [ for pwak, pwav in [("Pwa", "true"); ("NoPwa", "false")] do - // Server - for hostk, hostv in [("Bolero", "bolero"); ("Razor", "razor"); ("Html", "html")] do + for minik, miniv in [("Minimal", "true"); ("Full", "false")] do for htmlk, reloadv, htmlv in [("Reload", "true", "true"); ("NoReload", "false", "true"); ("NoHtml", "false", "false")] do - for minik, miniv in [("Minimal", "true"); ("Full", "false")] do - if not (miniv = "true" && htmlv = "true") then - $"{minik}.Server{hostk}.{htmlk}.{pwak}", [ - "--server" - $"--minimal={miniv}" - $"--hostpage={hostv}" - $"--pwa={pwav}" - $"--html={htmlv}" - $"--hotreload={reloadv}" - ] - if (hostv = "bolero") then - for renderk, renderv in [("IntServer", "InteractiveServer");("IntWasm", "InteractiveWebAssembly");("IntAuto", "InteractiveAuto");] do + if not (miniv = "true" && htmlv = "true") then + for renderk, renderv in serverModes do + if renderv.StartsWith("Legacy") then + for hostk, hostv in [("Bolero", "bolero"); ("Razor", "razor"); ("Html", "html")] do $"{minik}.{renderk}.{hostk}.{htmlk}.{pwak}", [ - "--server" $"--minimal={miniv}" $"--hostpage={hostv}" $"--pwa={pwav}" @@ -66,12 +63,18 @@ let variantsToTest = $"--hotreload={reloadv}" $"--render={renderv}" ] - // Client - for htmlk, htmlv in [("Html", "true"); ("NoHtml", "false")] do - for minik, miniv in [("Minimal", "true"); ("Full", "false")] do + else + $"{minik}.{renderk}.{htmlk}.{pwak}", [ + $"--minimal={miniv}" + $"--pwa={pwav}" + $"--html={htmlv}" + $"--hotreload={reloadv}" + $"--render={renderv}" + ] + for htmlk, htmlv in [("Html", "true"); ("NoHtml", "false")] do if not (miniv = "true" && htmlv = "true") then - $"{minik}.NoServer.{htmlk}.{pwak}", [ - "--server=false" + $"{minik}.Wasm.{htmlk}.{pwak}", [ + "--render=WebAssembly" $"--minimal={miniv}" $"--pwa={pwav}" $"--html={htmlv}" diff --git a/CHANGELOG.md b/CHANGELOG.md index f6892f1..f2ab9d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,10 @@ ## 0.24 -* [#50](https://github.com/fsbolero/Template/issues/50) Add option `--render` to decide the render mode. Possible values are: - * `Server` for classic server-side mode. - * `WebAssembly` for classic client-side mode. +* [#50](https://github.com/fsbolero/Template/issues/50) Replace option `--server` with `--render` to decide the render mode. Possible values are: + * `LegacyServer` for classic server-side mode. + * `LegacyWebAssembly` for classic client-side mode. + * `WebAssembly` for client-only WebAssembly mode without a server project. * `InteractiveServer` for server-side interactive render mode (see https://learn.microsoft.com/en-us/aspnet/core/blazor/components/render-modes?view=aspnetcore-8.0). * `InteractiveWebAssembly` for client-side interactive render mode. * `InteractiveAuto` for automatic interactive render mode (client-side if available, otherwise server-side while downloading the client-side runtime in the background). diff --git a/README.md b/README.md index 36b97c9..ad6c102 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ To learn more, you can check [the documentation](https://fsbolero.io/docs). To get started, you need the following installed: -* .NET SDK 5.0. Download it [here](https://dotnet.microsoft.com/download/dotnet/5.0). +* .NET SDK 8.0. Download it [here](https://dotnet.microsoft.com/download/dotnet/8.0). ## Creating a project based on this template @@ -42,39 +42,33 @@ You can use the following options to customize the project being created: If `false` (the default), the created project includes Bolero features such as routed pages, HTML templates and remoting. - * `--server`, `-s`: - - If `true` (the default), the solution includes a `Server` project, which is an ASP.NET Core server that hosts the application. - - If `false`, the solution only contains the `Client` project that is compiled to WebAssembly. - - * `--hostpage`, `-hp`: + * `--render`, `-r`: - Determines how the server-side HTML page content is written. Can be one of: + Determines the render mode. Can be one of: - * `bolero`: using Bolero.Html functions. + * `InteractiveWebAssembly` (the default) for client-side interactive render mode. - * `razor`: using a dynamically-compiled Razor page. + * `InteractiveServer` for server-side interactive render mode (see https://learn.microsoft.com/en-us/aspnet/core/blazor/components/render-modes?view=aspnetcore-8.0). - * `html`: using a plain .html file. + * `InteractiveAuto` for automatic interactive render mode (client-side if available, otherwise server-side while downloading the client-side runtime in the background). - This is ignored if `server=false`. + * `WebAssembly` for client-only WebAssembly without a server project. - * `--render`, `-r`: + * `LegacyServer` for classic (pre-.NET 8) server-side mode. - Determines the render mode. Can be one of: + * `LegacyWebAssembly` for classic (pre-.NET 8) client-side mode. - * `Server` for classic server-side mode. + * `--hostpage`, `-hp`: - * `WebAssembly` for classic client-side mode. + Determines how the server-side HTML page content is written for `LegacyServer`. Can be one of: - * `InteractiveServer` for server-side interactive render mode (see https://learn.microsoft.com/en-us/aspnet/core/blazor/components/render-modes?view=aspnetcore-8.0). + * `bolero` (the default): using Bolero.Html functions. - * `InteractiveWebAssembly` for client-side interactive render mode. + * `razor`: using a dynamically-compiled Razor page. - * `InteractiveAuto` for automatic interactive render mode (client-side if available, otherwise server-side while downloading the client-side runtime in the background). + * `html`: using a plain .html file. - This is ignored if `server=false`. Moreover, the `Interactive*` render modes are only compatible with `hostpage=bolero`. + This is ignored if `render` is not `LegacyServer`. * `--html`, `-ht`: diff --git a/content/application/.template.config/template.json b/content/application/.template.config/template.json index 5e6556d..0740f66 100644 --- a/content/application/.template.config/template.json +++ b/content/application/.template.config/template.json @@ -19,31 +19,26 @@ "dataType": "bool", "defaultValue": "false" }, - "server": { - "type": "parameter", - "isRequired": false, - "description": "Include an ASP.NET Core server-side host", - "dataType": "bool", - "defaultValue": "true" - }, - "html": { - "type": "parameter", - "isRequired": false, - "description": "Use HTML templates (ignored if minimal=true)", - "dataType": "bool", - "defaultValue": "true" - }, - "hotreload": { + "render": { "type": "parameter", "isRequired": false, - "description": "Include hot reload for HTML templates (ignored if html=false or server=false)", - "dataType": "bool", - "defaultValue": "true" + "description": "The type of rendering to use", + "dataType": "choice", + "replaces": "RENDER_MODE", + "choices": [ + {"choice":"WebAssembly","description":"WebAssembly only (no server project)"}, + {"choice":"InteractiveServer","description":"InteractiveServer render mode"}, + {"choice":"InteractiveWebAssembly","description":"InteractiveWebAssembly render mode"}, + {"choice":"InteractiveAuto","description":"InteractiveAuto render mode"}, + {"choice":"LegacyServer","description":"Legacy server-side mode"}, + {"choice":"LegacyWebAssembly","description":"Legacy client-side mode"} + ], + "defaultValue": "InteractiveWebAssembly" }, "hostpage": { "type": "parameter", "isRequired": false, - "description": "How the static HTML content is generated (ignored if server=false)", + "description": "How the static HTML content is generated with render=LegacyServer", "dataType": "choice", "choices": [ {"choice":"bolero","description":"A page defined with Bolero's html functions"}, @@ -52,25 +47,29 @@ ], "defaultValue":"bolero" }, - "render": { + "html": { "type": "parameter", "isRequired": false, - "description": "The type of rendering to use (ignored if server=false or hostpage!=bolero)", - "dataType": "choice", - "replaces": "RENDER_MODE", - "choices": [ - {"choice":"InteractiveServer","description":"Use InteractiveServer render mode"}, - {"choice":"InteractiveWebAssembly","description":"Use InteractiveWebAssembly render mode"}, - {"choice":"InteractiveAuto","description":"Use InteractiveAuto render mode"}, - {"choice":"Server","description":"Use classic server-side mode"}, - {"choice":"WebAssembly","description":"Use classic client-side mode"} - ], - "defaultValue": "WebAssembly" + "description": "Use HTML templates (ignored if minimal=true)", + "dataType": "bool", + "defaultValue": "true" + }, + "hotreload": { + "type": "parameter", + "isRequired": false, + "description": "Include hot reload for HTML templates (ignored if html=false or render=WebAssembly)", + "dataType": "bool", + "defaultValue": "true" + }, + "server": { + "type": "computed", + "dataType": "bool", + "value": "(render != \"WebAssembly\")" }, "isInteractive": { "type": "computed", "dataType": "bool", - "value": "(hostpage == \"bolero\" && (render == \"InteractiveServer\" || render == \"InteractiveWebAssembly\" || render == \"InteractiveAuto\"))" + "value": "(render == \"InteractiveServer\" || render == \"InteractiveWebAssembly\" || render == \"InteractiveAuto\")" }, "renderServer": { "type": "generated",