Skip to content

Commit 2fccab8

Browse files
committed
bug(auth): Fixing missing email templates for production build
1 parent 981c599 commit 2fccab8

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

libs/accounts/email-renderer/project.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@
2626
"outputPath": "dist/libs/accounts/email-renderer",
2727
"main": "libs/accounts/email-renderer/src/index.ts",
2828
"tsConfig": "libs/accounts/email-renderer/tsconfig.lib.json",
29-
"assets": ["libs/accounts/email-renderer/*.md"],
29+
"assets": [
30+
"libs/accounts/email-renderer/*.md",
31+
"libs/accounts/email-renderer/src/**/*.txt",
32+
"libs/accounts/email-renderer/src/**/*.mjml"
33+
],
3034
"format": ["cjs"],
3135
"generatePackageJson": true
3236
}

libs/accounts/email-renderer/src/renderer/bindings-node.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,12 @@ export class NodeRendererBindings extends RendererBindings {
6464
}
6565

6666
async fetchResource(path: string): Promise<string> {
67+
if (!existsSync(path)) {
68+
throw new Error('Resource file does not exist: ' + path);
69+
}
6770
const raw = readFileSync(path, {
6871
encoding: 'utf8',
6972
});
70-
7173
return raw;
7274
}
7375

packages/fxa-auth-server/scripts/copy-assets.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,18 @@ xargs -L1 bash -c 'mkdir -p dist/packages/fxa-auth-server/$0'
88
find config lib scripts bin public -type f | \
99
grep --invert -E "\.js$|\.ts$|\.sh" | \
1010
xargs -L1 bash -c 'cp $0 dist/packages/fxa-auth-server/$0'
11+
12+
# Copy email templates into dist...
13+
# Note that if we ran off the dist folder in the monorepo root we would not have this problem.
14+
cd ../..
15+
16+
# First create all the directories
17+
find dist/libs/accounts/email-renderer -type d | \
18+
xargs -L1 bash -c 'mkdir -p packages/fxa-auth-server/$0'
19+
20+
# Then copy the template files
21+
find dist/libs/accounts/email-renderer -type f | \
22+
grep -E "\.mjml$|\.txt$" | \
23+
xargs -L1 bash -c 'cp $0 packages/fxa-auth-server/$0'
24+
25+
cd packages/fxa-auth-server

0 commit comments

Comments
 (0)