Skip to content

Commit 2885eef

Browse files
committed
Initial email template proposal
1 parent 22d1845 commit 2885eef

21 files changed

Lines changed: 2949 additions & 223 deletions

.github/workflows/ci-build.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ jobs:
4949
with:
5050
dotnet-version: '${{ env.DOTNET_VERSION }}'
5151

52+
# API.csproj builds the React-Email templates during dotnet build/test.
53+
- uses: pnpm/action-setup@v4
54+
- uses: actions/setup-node@v6
55+
with:
56+
node-version: '20'
57+
cache: 'pnpm'
58+
cache-dependency-path: API/SmtpTemplates/pnpm-lock.yaml
59+
5260
- name: Run tests
5361
run: |
5462
set -euo pipefail

.github/workflows/codeql.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ jobs:
4141
with:
4242
dotnet-version: ${{ env.DOTNET_VERSION }}
4343

44+
# API.csproj builds the React-Email templates during dotnet publish.
45+
- uses: pnpm/action-setup@v4
46+
- uses: actions/setup-node@v6
47+
with:
48+
node-version: '20'
49+
cache: 'pnpm'
50+
cache-dependency-path: API/SmtpTemplates/pnpm-lock.yaml
51+
4452
- name: Build .NET
4553
shell: bash
4654
run: |

API/API.csproj

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
<!-- Keep the SmtpTemplates React-Email source tree out of the SDK's default
3+
Compile/Content/None globs so package.json, tsconfig.json, *.tsx, etc.
4+
don't get swept into the build or published. -->
5+
<PropertyGroup>
6+
<DefaultItemExcludes>$(DefaultItemExcludes);SmtpTemplates\**</DefaultItemExcludes>
7+
<SmtpTemplatesDir>$(MSBuildProjectDirectory)\SmtpTemplates</SmtpTemplatesDir>
8+
</PropertyGroup>
9+
210
<ItemGroup>
311
<ProjectReference Include="..\Common\Common.csproj" />
412
</ItemGroup>
@@ -8,7 +16,7 @@
816
<!-- Expose API internals to IntegrationTest project -->
917
<InternalsVisibleTo Include="$(AssemblyName).Tests.Integration" />
1018
</ItemGroup>
11-
19+
1220
<!-- NuGet packages -->
1321
<ItemGroup>
1422
<PackageReference Include="AspNet.Security.OAuth.Discord" />
@@ -20,15 +28,74 @@
2028

2129
<!-- Files to copy -->
2230
<ItemGroup>
23-
<!-- Copy all Liquid templates (recursively) to build and publish outputs -->
24-
<None Update="SmtpTemplates\**\*.liquid">
25-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
26-
</None>
27-
2831
<!-- Dev cert included on publish -->
2932
<None Include="devcert.pfx" CopyToPublishDirectory="Always" />
3033
</ItemGroup>
3134

35+
<!-- Show the React-Email sources in the IDE without copying them anywhere. -->
36+
<ItemGroup>
37+
<None Include="SmtpTemplates\emails\**\*.tsx" />
38+
<None Include="SmtpTemplates\scripts\**\*.ts" />
39+
<None Include="SmtpTemplates\package.json" />
40+
<None Include="SmtpTemplates\pnpm-lock.yaml" />
41+
<None Include="SmtpTemplates\tsconfig.json" />
42+
<None Include="SmtpTemplates\README.md" />
43+
<None Include="SmtpTemplates\.gitignore" />
44+
</ItemGroup>
45+
46+
<!-- React-Email template build pipeline -->
47+
48+
<ItemGroup>
49+
<SmtpTemplateSources Include="$(SmtpTemplatesDir)\emails\**\*.tsx" />
50+
<SmtpTemplateSources Include="$(SmtpTemplatesDir)\emails\**\*.ts" />
51+
<SmtpTemplateSources Include="$(SmtpTemplatesDir)\scripts\**\*.ts" />
52+
<SmtpTemplateSources Include="$(SmtpTemplatesDir)\package.json" />
53+
<SmtpTemplateSources Include="$(SmtpTemplatesDir)\pnpm-lock.yaml" />
54+
<SmtpTemplateSources Include="$(SmtpTemplatesDir)\tsconfig.json" />
55+
</ItemGroup>
56+
57+
<Target Name="InstallEmailTemplateDeps"
58+
Inputs="$(SmtpTemplatesDir)\package.json;$(SmtpTemplatesDir)\pnpm-lock.yaml"
59+
Outputs="$(SmtpTemplatesDir)\node_modules\.package-lock.json">
60+
<Exec WorkingDirectory="$(SmtpTemplatesDir)" Command="pnpm install --frozen-lockfile" />
61+
</Target>
62+
63+
<Target Name="BuildEmailTemplates"
64+
DependsOnTargets="InstallEmailTemplateDeps"
65+
Inputs="@(SmtpTemplateSources)"
66+
Outputs="$(SmtpTemplatesDir)\dist\.stamp">
67+
<Exec WorkingDirectory="$(SmtpTemplatesDir)" Command="pnpm export" />
68+
<Touch Files="$(SmtpTemplatesDir)\dist\.stamp" AlwaysCreate="true" />
69+
</Target>
70+
71+
<!-- Glob the generated .liquid files into Content items so the SDK copies
72+
them to the output dir and propagates them transitively via
73+
GetCopyToOutputDirectoryItems to ProjectReference dependents. Done in a
74+
target (rather than a top-level ItemGroup) so the glob is evaluated
75+
AFTER BuildEmailTemplates has materialised dist/. Safe because
76+
DefaultItemExcludes above stops the SDK from globbing SmtpTemplates\**
77+
on its own. -->
78+
<Target Name="IncludeEmailTemplates"
79+
DependsOnTargets="BuildEmailTemplates"
80+
BeforeTargets="AssignTargetPaths;GetCopyToOutputDirectoryItems">
81+
<ItemGroup>
82+
<!-- Stage in a private item type first so the %(Filename) batching is
83+
qualified to these items only — an unqualified %(Filename) inside a
84+
<Content> ItemGroup batches across ALL existing Content items
85+
(including appsettings*.json), producing a cartesian-product mess. -->
86+
<_EmailTemplateLiquid Include="$(SmtpTemplatesDir)\dist\*.liquid" />
87+
<Content Include="@(_EmailTemplateLiquid)">
88+
<Link>SmtpTemplates\%(_EmailTemplateLiquid.Filename)%(_EmailTemplateLiquid.Extension)</Link>
89+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
90+
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
91+
</Content>
92+
</ItemGroup>
93+
</Target>
94+
95+
<Target Name="CleanEmailTemplates" BeforeTargets="Clean">
96+
<RemoveDir Directories="$(SmtpTemplatesDir)\dist" />
97+
</Target>
98+
3299
<!-- Git stuff -->
33100
<Target Name="SetHash" AfterTargets="InitializeSourceControlInformation">
34101
<ItemGroup>

API/SmtpTemplates/.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules
2+
.react-email
3+
.next
4+
out
5+
dist
6+
.env
7+
.env.local
8+
*.log
9+
.DS_Store

API/SmtpTemplates/AccountActivation.liquid

Lines changed: 0 additions & 55 deletions
This file was deleted.

API/SmtpTemplates/EmailChangeNotice.liquid

Lines changed: 0 additions & 51 deletions
This file was deleted.

API/SmtpTemplates/EmailVerification.liquid

Lines changed: 0 additions & 55 deletions
This file was deleted.

API/SmtpTemplates/PasswordReset.liquid

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)