Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…emplate into generic-host-builder
  • Loading branch information
slang25 committed Jun 27, 2020
2 parents be14bbe + 8c7d97a commit 510db15
Show file tree
Hide file tree
Showing 45 changed files with 236 additions and 75 deletions.
16 changes: 8 additions & 8 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ Remove-OldBuildArtifacts

# Test Giraffe template
Write-Host "Building and testing Giraffe tempalte..." -ForegroundColor Magenta
$giraffeApp = "src/content/Giraffe/src/AppNamePlaceholder/AppNamePlaceholder.fsproj"
$giraffeTests = "src/content/Giraffe/tests/AppNamePlaceholder.Tests/AppNamePlaceholder.Tests.fsproj"
$giraffeApp = "src/content/Giraffe/src/AppName/AppName.fsproj"
$giraffeTests = "src/content/Giraffe/tests/AppName.Tests/AppName.Tests.fsproj"

dotnet-restore $giraffeApp
dotnet-build $giraffeApp
Expand All @@ -47,8 +47,8 @@ dotnet-test $giraffeTests

# Test Razor template
Write-Host "Building and testing Razor tempalte..." -ForegroundColor Magenta
$razorApp = "src/content/Razor/src/AppNamePlaceholder/AppNamePlaceholder.fsproj"
$razorTests = "src/content/Razor/tests/AppNamePlaceholder.Tests/AppNamePlaceholder.Tests.fsproj"
$razorApp = "src/content/Razor/src/AppName/AppName.fsproj"
$razorTests = "src/content/Razor/tests/AppName.Tests/AppName.Tests.fsproj"

dotnet-restore $razorApp
dotnet-build $razorApp
Expand All @@ -58,8 +58,8 @@ dotnet-test $razorTests

# Test DotLiquid template
Write-Host "Building and testing DotLiquid tempalte..." -ForegroundColor Magenta
$dotLiquidApp = "src/content/DotLiquid/src/AppNamePlaceholder/AppNamePlaceholder.fsproj"
$dotLiquidTests = "src/content/DotLiquid/tests/AppNamePlaceholder.Tests/AppNamePlaceholder.Tests.fsproj"
$dotLiquidApp = "src/content/DotLiquid/src/AppName/AppName.fsproj"
$dotLiquidTests = "src/content/DotLiquid/tests/AppName.Tests/AppName.Tests.fsproj"

dotnet-restore $dotLiquidApp
dotnet-build $dotLiquidApp
Expand All @@ -69,8 +69,8 @@ dotnet-test $dotLiquidTests

# Test None template
Write-Host "Building and testing None tempalte..." -ForegroundColor Magenta
$noneApp = "src/content/None/src/AppNamePlaceholder/AppNamePlaceholder.fsproj"
$noneTests = "src/content/None/tests/AppNamePlaceholder.Tests/AppNamePlaceholder.Tests.fsproj"
$noneApp = "src/content/None/src/AppName/AppName.fsproj"
$noneTests = "src/content/None/tests/AppName.Tests/AppName.Tests.fsproj"

dotnet-restore $noneApp
dotnet-build $noneApp
Expand Down
18 changes: 9 additions & 9 deletions src/content/.template.config/template.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"identity": "Giraffe.Template",
"shortName": "giraffe",
"name": "Giraffe Web App",
"name": "Giraffe",
"author": "Dustin Moris Gorski, David Sinclair and contributors",
"classifications": [ "Web", "Giraffe", "ASP.NET" ],
"tags": {
"language": "F#"
},
"sourceName": "AppNamePlaceholder",
"sourceName": "AppName",
"symbols": {
"ViewEngine": {
"type": "parameter",
Expand All @@ -16,15 +16,15 @@
"choices": [
{
"choice": "giraffe",
"description": "Default GiraffeViewEngine"
"description": "Giraffe.ViewEngine views"
},
{
"choice": "razor",
"description": "MVC Razor views"
},
{
"choice": "dotliquid",
"description": "DotLiquid template engine"
"description": "DotLiquid template views"
},
{
"choice": "none",
Expand All @@ -51,7 +51,7 @@
"modifiers": [
{
"condition": "(!IncludeTests)",
"exclude": [ "**/AppNamePlaceholder.Tests/**/*" ]
"exclude": [ "**/AppName.Tests/**/*" ]
},
{
"condition": "(!UsePaket)",
Expand All @@ -66,7 +66,7 @@
"modifiers": [
{
"condition": "(!IncludeTests)",
"exclude": [ "**/AppNamePlaceholder.Tests/**/*" ]
"exclude": [ "**/AppName.Tests/**/*" ]
},
{
"condition": "(!UsePaket)",
Expand All @@ -81,7 +81,7 @@
"modifiers": [
{
"condition": "(!IncludeTests)",
"exclude": [ "**/AppNamePlaceholder.Tests/**/*" ]
"exclude": [ "**/AppName.Tests/**/*" ]
},
{
"condition": "(!UsePaket)",
Expand All @@ -96,7 +96,7 @@
"modifiers": [
{
"condition": "(!IncludeTests)",
"exclude": [ "**/AppNamePlaceholder.Tests/**/*" ]
"exclude": [ "**/AppName.Tests/**/*" ]
},
{
"condition": "(!UsePaket)",
Expand All @@ -111,7 +111,7 @@
"modifiers": [
{
"condition": "(!IncludeTests)",
"exclude": [ "**/AppNamePlaceholder.Tests/**/*" ]
"exclude": [ "**/AppName.Tests/**/*" ]
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>AppNamePlaceholder.App</AssemblyName>
<AssemblyName>AppName.App</AssemblyName>
<EnableDefaultContentItems>false</EnableDefaultContentItems>
</PropertyGroup>

Expand All @@ -23,6 +23,7 @@

<ItemGroup>
<None Include="web.config" CopyToOutputDirectory="PreserveNewest" />
<None Condition="'$(UsePaket)' == true" Include="paket.references" />
<Content Include="Views\*.html;WebRoot\**\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace AppNamePlaceholder.Models
namespace AppName.Models

[<CLIMutable>]
type Message =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module AppNamePlaceholder.App
module AppName.App

open System
open System.IO
Expand All @@ -10,7 +10,7 @@ open Microsoft.Extensions.Logging
open Microsoft.Extensions.DependencyInjection
open Giraffe
open DotLiquid
open AppNamePlaceholder.Models
open AppName.Models

// ---------------------------------
// Web app
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>AppNamePlaceholder</title>
<title>AppName</title>
<link rel="stylesheet" type="text/css" href="/main.css">
</head>
<body>
<h1>AppNamePlaceholder</h1>
<h1>AppName</h1>
<p>
{{ text }}
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments="AppNamePlaceholder.dll" stdoutLogEnabled="false" stdoutLogFile="logs/stdout" />
<aspNetCore processPath="dotnet" arguments="AppName.dll" stdoutLogEnabled="false" stdoutLogFile="logs/stdout" />
</system.webServer>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup Condition="'$(UsePaket)' == false OR '$(UsePaket)' == ''">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.*" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.*" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.*" />
<PackageReference Include="xunit" Version="2.4.*" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.*" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../../src/AppNamePlaceholder/AppNamePlaceholder.fsproj" />
<ProjectReference Include="../../src/AppName/AppName.fsproj" />
</ItemGroup>

<ItemGroup>
<Compile Include="Tests.fs" />
</ItemGroup>
<ItemGroup>
<None Condition="'$(UsePaket)' == true" Include="paket.references" />
</ItemGroup>
<Import Condition="'$(UsePaket)' == true" Project="..\..\.paket\Paket.Restore.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ open Microsoft.Extensions.DependencyInjection
let createHost() =
WebHostBuilder()
.UseContentRoot(Directory.GetCurrentDirectory())
.Configure(Action<IApplicationBuilder> AppNamePlaceholder.App.configureApp)
.ConfigureServices(Action<IServiceCollection> AppNamePlaceholder.App.configureServices)
.Configure(Action<IApplicationBuilder> AppName.App.configureApp)
.ConfigureServices(Action<IServiceCollection> AppName.App.configureServices)

let runTask task =
task
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>AppNamePlaceholder.App</AssemblyName>
<AssemblyName>AppName.App</AssemblyName>
<EnableDefaultContentItems>false</EnableDefaultContentItems>
</PropertyGroup>

Expand All @@ -17,6 +17,7 @@

<ItemGroup>
<None Include="web.config" CopyToOutputDirectory="PreserveNewest" />
<None Condition="'$(UsePaket)' == true" Include="paket.references" />
<Content Include="WebRoot\**\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module AppNamePlaceholder.App
module AppName.App

open System
open System.IO
Expand Down Expand Up @@ -29,7 +29,7 @@ module Views =
let layout (content: XmlNode list) =
html [] [
head [] [
title [] [ encodedText "AppNamePlaceholder" ]
title [] [ encodedText "AppName" ]
link [ _rel "stylesheet"
_type "text/css"
_href "/main.css" ]
Expand All @@ -38,7 +38,7 @@ module Views =
]

let partial () =
h1 [] [ encodedText "AppNamePlaceholder" ]
h1 [] [ encodedText "AppName" ]

let index (model : Message) =
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments="AppNamePlaceholder.dll" stdoutLogEnabled="false" stdoutLogFile="logs/stdout" />
<aspNetCore processPath="dotnet" arguments="AppName.dll" stdoutLogEnabled="false" stdoutLogFile="logs/stdout" />
</system.webServer>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup Condition="'$(UsePaket)' == false OR '$(UsePaket)' == ''">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.*" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.*" />
Expand All @@ -11,11 +10,14 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../../src/AppNamePlaceholder/AppNamePlaceholder.fsproj" />
<ProjectReference Include="../../src/AppName/AppName.fsproj" />
</ItemGroup>

<ItemGroup>
<Compile Include="Tests.fs" />
</ItemGroup>
<ItemGroup>
<None Condition="'$(UsePaket)' == true" Include="paket.references" />
</ItemGroup>
<Import Condition="'$(UsePaket)' == true" Project="..\..\.paket\Paket.Restore.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ open Microsoft.Extensions.DependencyInjection
let createHost() =
WebHostBuilder()
.UseContentRoot(Directory.GetCurrentDirectory())
.Configure(Action<IApplicationBuilder> AppNamePlaceholder.App.configureApp)
.ConfigureServices(Action<IServiceCollection> AppNamePlaceholder.App.configureServices)
.Configure(Action<IApplicationBuilder> AppName.App.configureApp)
.ConfigureServices(Action<IServiceCollection> AppName.App.configureServices)

let runTask task =
task
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>AppNamePlaceholder.App</AssemblyName>
<AssemblyName>AppName.App</AssemblyName>
<EnableDefaultContentItems>false</EnableDefaultContentItems>
</PropertyGroup>

Expand All @@ -19,6 +19,7 @@

<ItemGroup>
<None Include="web.config" CopyToOutputDirectory="PreserveNewest" />
<None Condition="'$(UsePaket)' == true" Include="paket.references" />
</ItemGroup>

<Import Condition="'$(UsePaket)' == true" Project="..\..\.paket\Paket.Restore.targets" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
namespace AppNamePlaceholder
namespace AppName

module HttpHandlers =

open Microsoft.AspNetCore.Http
open FSharp.Control.Tasks.V2.ContextInsensitive
open Giraffe
open AppNamePlaceholder.Models
open AppName.Models

let handleGetHello =
fun (next : HttpFunc) (ctx : HttpContext) ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace AppNamePlaceholder.Models
namespace AppName.Models

[<CLIMutable>]
type Message =
Expand Down
Loading

0 comments on commit 510db15

Please sign in to comment.