@betterinternship/core 2.26.0 → 2.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,3 @@
1
1
  export * from './email.js';
2
+ export * from './preview.js';
2
3
  export * from './shell.js';
@@ -1,3 +1,4 @@
1
1
  export * from './email.js';
2
+ export * from './preview.js';
2
3
  export * from './shell.js';
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/email/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/email/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,10 @@
1
+ export interface EmailPreview {
2
+ name: string;
3
+ html: string;
4
+ }
5
+ export interface EmailPreviewCatalogOptions {
6
+ title: string;
7
+ previews: EmailPreview[];
8
+ outputDirectory: string;
9
+ }
10
+ export declare const writeEmailPreviewCatalog: ({ title, previews, outputDirectory, }: EmailPreviewCatalogOptions) => string;
@@ -0,0 +1,41 @@
1
+ import { mkdirSync, writeFileSync } from 'fs';
2
+ import { join } from 'path';
3
+ const escapeHtml = (value) => value
4
+ .replaceAll('&', '&')
5
+ .replaceAll('<', '&lt;')
6
+ .replaceAll('>', '&gt;')
7
+ .replaceAll('"', '&quot;')
8
+ .replaceAll("'", '&#39;');
9
+ export const writeEmailPreviewCatalog = ({ title, previews, outputDirectory, }) => {
10
+ mkdirSync(outputDirectory, { recursive: true });
11
+ const catalogItems = previews.map(({ name, html }, index) => {
12
+ const filename = `${String(index + 1).padStart(2, '0')}.html`;
13
+ writeFileSync(join(outputDirectory, filename), html);
14
+ const escapedName = escapeHtml(name);
15
+ return `<section><h2>${escapedName}</h2><iframe src="${filename}" title="${escapedName}"></iframe></section>`;
16
+ });
17
+ const escapedTitle = escapeHtml(title);
18
+ const catalogPath = join(outputDirectory, 'index.html');
19
+ writeFileSync(catalogPath, `<!doctype html>
20
+ <html lang="en">
21
+ <head>
22
+ <meta charset="utf-8" />
23
+ <title>${escapedTitle}</title>
24
+ <style>
25
+ body { margin: 0; padding: 32px; background: #eef2f7; color: #17213d; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
26
+ h1 { margin: 0 0 8px; }
27
+ p { margin: 0 0 32px; color: #5c6880; }
28
+ section { max-width: 680px; margin: 0 auto 36px; }
29
+ h2 { font-size: 16px; margin: 0 0 10px; }
30
+ iframe { width: 100%; height: 760px; border: 1px solid #d7deea; background: #fff; border-radius: 8px; }
31
+ </style>
32
+ </head>
33
+ <body>
34
+ <h1>${escapedTitle}</h1>
35
+ <p>Generated from the production email factories and their templates.</p>
36
+ ${catalogItems.join('\n ')}
37
+ </body>
38
+ </html>`);
39
+ return catalogPath;
40
+ };
41
+ //# sourceMappingURL=preview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview.js","sourceRoot":"","sources":["../../../lib/email/preview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAa5B,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,EAAE,CACnC,KAAK;KACF,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;KACxB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;KACvB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;KACvB,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC;KACzB,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAG9B,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,EACvC,KAAK,EACL,QAAQ,EACR,eAAe,GACY,EAAE,EAAE;IAC/B,SAAS,CAA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