vintasend-react-email 0.10.0 → 0.11.0
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.
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/react-email-inline-template-renderer.d.ts +1 -5
- package/dist/react-email-inline-template-renderer.d.ts.map +1 -1
- package/dist/react-email-inline-template-renderer.js +1 -1
- package/dist/react-email-template-renderer.d.ts +1 -5
- package/dist/react-email-template-renderer.d.ts.map +1 -1
- package/dist/react-email-template-renderer.js +2 -2
- package/package.json +7 -2
- package/src/scripts/compile-react-email-templates.ts +140 -140
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { ReactEmailTemplateRenderer, ReactEmailTemplateRendererFactory } from './react-email-template-renderer';
|
|
2
1
|
export { ReactEmailInlineTemplateRenderer, ReactEmailInlineTemplateRendererFactory, } from './react-email-inline-template-renderer';
|
|
2
|
+
export { ReactEmailTemplateRenderer, ReactEmailTemplateRendererFactory, } from './react-email-template-renderer';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gCAAgC,EAChC,uCAAuC,GACxC,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,0BAA0B,EAC1B,iCAAiC,GAClC,MAAM,iCAAiC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ReactEmailTemplateRenderer, ReactEmailTemplateRendererFactory } from './react-email-template-renderer';
|
|
2
1
|
export { ReactEmailInlineTemplateRenderer, ReactEmailInlineTemplateRendererFactory, } from './react-email-inline-template-renderer';
|
|
2
|
+
export { ReactEmailTemplateRenderer, ReactEmailTemplateRendererFactory, } from './react-email-template-renderer';
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type { BaseEmailTemplateRenderer, EmailTemplate, EmailTemplateContent } from 'vintasend
|
|
2
|
-
import type { JsonObject } from 'vintasend/dist/types/json-values';
|
|
3
|
-
import type { BaseLogger } from 'vintasend/dist/services/loggers/base-logger';
|
|
4
|
-
import type { AnyNotification, DatabaseNotification } from 'vintasend/dist/types/notification';
|
|
5
|
-
import type { BaseNotificationTypeConfig } from 'vintasend/dist/types/notification-type-config';
|
|
1
|
+
import type { AnyNotification, BaseEmailTemplateRenderer, BaseLogger, BaseNotificationTypeConfig, DatabaseNotification, EmailTemplate, EmailTemplateContent, JsonObject } from 'vintasend';
|
|
6
2
|
export declare class ReactEmailInlineTemplateRenderer<Config extends BaseNotificationTypeConfig> implements BaseEmailTemplateRenderer<Config> {
|
|
7
3
|
private readonly templates;
|
|
8
4
|
private logger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-email-inline-template-renderer.d.ts","sourceRoot":"","sources":["../src/react-email-inline-template-renderer.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,yBAAyB,EACzB,
|
|
1
|
+
{"version":3,"file":"react-email-inline-template-renderer.d.ts","sourceRoot":"","sources":["../src/react-email-inline-template-renderer.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,eAAe,EACf,yBAAyB,EACzB,UAAU,EACV,0BAA0B,EAC1B,oBAAoB,EACpB,aAAa,EACb,oBAAoB,EACpB,UAAU,EACX,MAAM,WAAW,CAAC;AAWnB,qBAAa,gCAAgC,CAAC,MAAM,SAAS,0BAA0B,CACrF,YAAW,yBAAyB,CAAC,MAAM,CAAC;IAE5C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAyB;IACnD,OAAO,CAAC,MAAM,CAA2B;gBAE7B,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAItD,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAIhC,MAAM,CACV,YAAY,EAAE,oBAAoB,CAAC,MAAM,CAAC,EAC1C,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,aAAa,CAAC;IAyCnB,yBAAyB,CAC7B,YAAY,EAAE,eAAe,CAAC,MAAM,CAAC,EACrC,eAAe,EAAE,oBAAoB,EACrC,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,aAAa,CAAC;YA2BX,wBAAwB;YAwBxB,8BAA8B;IAqB5C,OAAO,CAAC,wBAAwB;IAmBhC,OAAO,CAAC,uBAAuB;IAI/B,OAAO,CAAC,qBAAqB;YAMf,gBAAgB;IAQ9B,OAAO,CAAC,mBAAmB;CAO5B;AAED,qBAAa,uCAAuC,CAAC,MAAM,SAAS,0BAA0B;IAC5F,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAGlD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { mkdir, writeFile } from 'node:fs/promises';
|
|
3
|
-
import { dirname, join } from 'node:path';
|
|
4
3
|
import { tmpdir } from 'node:os';
|
|
4
|
+
import { dirname, join } from 'node:path';
|
|
5
5
|
import { pathToFileURL } from 'node:url';
|
|
6
6
|
import { render as renderReactEmail } from '@react-email/render';
|
|
7
7
|
import { transform } from 'esbuild';
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type { BaseEmailTemplateRenderer, EmailTemplate, EmailTemplateContent } from 'vintasend
|
|
2
|
-
import type { JsonObject } from 'vintasend/dist/types/json-values';
|
|
3
|
-
import type { BaseLogger } from 'vintasend/dist/services/loggers/base-logger';
|
|
4
|
-
import type { AnyNotification, DatabaseNotification } from 'vintasend/dist/types/notification';
|
|
5
|
-
import type { BaseNotificationTypeConfig } from 'vintasend/dist/types/notification-type-config';
|
|
1
|
+
import type { AnyNotification, BaseEmailTemplateRenderer, BaseLogger, BaseNotificationTypeConfig, DatabaseNotification, EmailTemplate, EmailTemplateContent, JsonObject } from 'vintasend';
|
|
6
2
|
export declare class ReactEmailTemplateRenderer<Config extends BaseNotificationTypeConfig> implements BaseEmailTemplateRenderer<Config> {
|
|
7
3
|
private logger;
|
|
8
4
|
injectLogger(logger: BaseLogger): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-email-template-renderer.d.ts","sourceRoot":"","sources":["../src/react-email-template-renderer.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,yBAAyB,EACzB,
|
|
1
|
+
{"version":3,"file":"react-email-template-renderer.d.ts","sourceRoot":"","sources":["../src/react-email-template-renderer.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,eAAe,EACf,yBAAyB,EACzB,UAAU,EACV,0BAA0B,EAC1B,oBAAoB,EACpB,aAAa,EACb,oBAAoB,EACpB,UAAU,EACX,MAAM,WAAW,CAAC;AAYnB,qBAAa,0BAA0B,CAAC,MAAM,SAAS,0BAA0B,CAC/E,YAAW,yBAAyB,CAAC,MAAM,CAAC;IAE5C,OAAO,CAAC,MAAM,CAA2B;IAEzC,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAIhC,MAAM,CACV,YAAY,EAAE,oBAAoB,CAAC,MAAM,CAAC,EAC1C,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,aAAa,CAAC;IAoBnB,yBAAyB,CAC7B,YAAY,EAAE,eAAe,CAAC,MAAM,CAAC,EACrC,eAAe,EAAE,oBAAoB,EACrC,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,aAAa,CAAC;YA0BX,mBAAmB;YAenB,0BAA0B;YAK1B,wBAAwB;YAyBxB,8BAA8B;IAqB5C,OAAO,CAAC,wBAAwB;IAmBhC,OAAO,CAAC,uBAAuB;IAI/B,OAAO,CAAC,qBAAqB;IAM7B,OAAO,CAAC,gBAAgB;YAQV,gBAAgB;IAQ9B,OAAO,CAAC,mBAAmB;CAO5B;AAED,qBAAa,iCAAiC,CAAC,MAAM,SAAS,0BAA0B;IACtF,MAAM;CAGP"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
3
|
-
import { dirname, extname, join } from 'node:path';
|
|
4
3
|
import { tmpdir } from 'node:os';
|
|
4
|
+
import { dirname, extname, join } from 'node:path';
|
|
5
5
|
import { pathToFileURL } from 'node:url';
|
|
6
6
|
import { render as renderReactEmail } from '@react-email/render';
|
|
7
7
|
import { transform } from 'esbuild';
|
|
@@ -51,7 +51,7 @@ export class ReactEmailTemplateRenderer {
|
|
|
51
51
|
const templateModule = (await import(pathToFileURL(importPath).href));
|
|
52
52
|
const templateExport = templateModule.default ?? templateModule.render;
|
|
53
53
|
if (typeof templateExport !== 'function') {
|
|
54
|
-
throw new Error(`Template at
|
|
54
|
+
throw new Error(`Template at "${templatePath}" must export a function`);
|
|
55
55
|
}
|
|
56
56
|
return templateExport;
|
|
57
57
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vintasend-react-email",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "VintaSend template renderer implementation for React Email",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "tsc",
|
|
8
8
|
"prepublishOnly": "npm run build",
|
|
9
|
+
"prepare": "husky",
|
|
10
|
+
"lint": "biome check .",
|
|
11
|
+
"format": "biome check --write .",
|
|
9
12
|
"test": "vitest run",
|
|
10
13
|
"test:watch": "vitest",
|
|
11
14
|
"test:coverage": "vitest run --coverage",
|
|
@@ -25,11 +28,13 @@
|
|
|
25
28
|
"esbuild": "^0.25.11",
|
|
26
29
|
"react": "^19.2.0",
|
|
27
30
|
"react-dom": "^19.2.0",
|
|
28
|
-
"vintasend": "^0.
|
|
31
|
+
"vintasend": "^0.11.0"
|
|
29
32
|
},
|
|
30
33
|
"devDependencies": {
|
|
34
|
+
"@biomejs/biome": "^2.4.5",
|
|
31
35
|
"@types/node": "^25.3.3",
|
|
32
36
|
"@vitest/coverage-v8": "4.0.18",
|
|
37
|
+
"husky": "^9.1.7",
|
|
33
38
|
"typescript": "^5.9.3",
|
|
34
39
|
"vitest": "4.0.18"
|
|
35
40
|
}
|
|
@@ -1,140 +1,140 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import * as fs from 'node:fs';
|
|
3
|
-
import * as path from 'node:path';
|
|
4
|
-
import { pathToFileURL } from 'node:url';
|
|
5
|
-
|
|
6
|
-
interface ReactEmailTemplatesMap {
|
|
7
|
-
[key: string]: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const SUPPORTED_TEMPLATE_EXTENSIONS = new Set([
|
|
11
|
-
'.ts',
|
|
12
|
-
'.tsx',
|
|
13
|
-
'.js',
|
|
14
|
-
'.jsx',
|
|
15
|
-
'.mts',
|
|
16
|
-
'.cts',
|
|
17
|
-
'.mjs',
|
|
18
|
-
'.cjs',
|
|
19
|
-
]);
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Recursively finds all supported template files in a directory
|
|
23
|
-
*/
|
|
24
|
-
export function findTemplateFiles(
|
|
25
|
-
dir: string,
|
|
26
|
-
baseDir: string,
|
|
27
|
-
files: Map<string, string> = new Map(),
|
|
28
|
-
): Map<string, string> {
|
|
29
|
-
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
30
|
-
|
|
31
|
-
for (const entry of entries) {
|
|
32
|
-
const fullPath = path.join(dir, entry.name);
|
|
33
|
-
|
|
34
|
-
if (entry.isDirectory()) {
|
|
35
|
-
findTemplateFiles(fullPath, baseDir, files);
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (!entry.isFile()) {
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const extension = path.extname(entry.name).toLowerCase();
|
|
44
|
-
if (!SUPPORTED_TEMPLATE_EXTENSIONS.has(extension)) {
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
49
|
-
const relativePath = path.relative(baseDir, fullPath).replace(/\\/g, '/');
|
|
50
|
-
files.set(relativePath, content);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return files;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Main function to compile react email templates to JSON
|
|
58
|
-
*/
|
|
59
|
-
export function compileReactEmailTemplates(
|
|
60
|
-
inputDir: string = './templates',
|
|
61
|
-
outputFile: string = 'compiled-react-email-templates.json',
|
|
62
|
-
): void {
|
|
63
|
-
if (!fs.existsSync(inputDir)) {
|
|
64
|
-
throw new Error(`Directory "${inputDir}" does not exist.`);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (!fs.statSync(inputDir).isDirectory()) {
|
|
68
|
-
throw new Error(`"${inputDir}" is not a directory.`);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
console.log(`Searching for template files in: ${inputDir}`);
|
|
72
|
-
|
|
73
|
-
const templateFiles = findTemplateFiles(inputDir, inputDir);
|
|
74
|
-
|
|
75
|
-
console.log(`Found ${templateFiles.size} template file(s)`);
|
|
76
|
-
|
|
77
|
-
const result: ReactEmailTemplatesMap = {};
|
|
78
|
-
for (const [filePath, content] of templateFiles.entries()) {
|
|
79
|
-
result[filePath] = content;
|
|
80
|
-
console.log(` - ${filePath}`);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const outputContent = JSON.stringify(result, null, 2);
|
|
84
|
-
fs.writeFileSync(outputFile, outputContent, 'utf-8');
|
|
85
|
-
|
|
86
|
-
console.log(`\nSuccessfully compiled templates to: ${outputFile}`);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function runFromCli(): void {
|
|
90
|
-
const args = process.argv.slice(2);
|
|
91
|
-
|
|
92
|
-
if (args.includes('--help') || args.includes('-h')) {
|
|
93
|
-
console.log('Usage: compile-react-email-templates [input-directory] [output-file]');
|
|
94
|
-
console.log('');
|
|
95
|
-
console.log('Arguments:');
|
|
96
|
-
console.log(
|
|
97
|
-
' input-directory Directory containing React Email templates (default: ./templates)',
|
|
98
|
-
);
|
|
99
|
-
console.log(
|
|
100
|
-
' output-file Output JSON file path (default: compiled-react-email-templates.json)',
|
|
101
|
-
);
|
|
102
|
-
console.log('');
|
|
103
|
-
console.log('Supported extensions: .ts, .tsx, .js, .jsx, .mts, .cts, .mjs, .cjs');
|
|
104
|
-
console.log('');
|
|
105
|
-
console.log('Examples:');
|
|
106
|
-
console.log(' compile-react-email-templates');
|
|
107
|
-
console.log(' compile-react-email-templates ./notification-templates');
|
|
108
|
-
console.log(
|
|
109
|
-
' compile-react-email-templates ./notification-templates ./compiled-notification-templates.json',
|
|
110
|
-
);
|
|
111
|
-
process.exit(0);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const [inputDir, outputFile] = args;
|
|
115
|
-
|
|
116
|
-
try {
|
|
117
|
-
compileReactEmailTemplates(inputDir, outputFile);
|
|
118
|
-
} catch (error) {
|
|
119
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
120
|
-
console.error(`Error: ${message}`);
|
|
121
|
-
process.exit(1);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const isCliEntryPoint = (() => {
|
|
126
|
-
const entry = process.argv[1];
|
|
127
|
-
if (!entry) {
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
try {
|
|
132
|
-
return pathToFileURL(entry).href === import.meta.url;
|
|
133
|
-
} catch {
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
136
|
-
})();
|
|
137
|
-
|
|
138
|
-
if (isCliEntryPoint) {
|
|
139
|
-
runFromCli();
|
|
140
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import { pathToFileURL } from 'node:url';
|
|
5
|
+
|
|
6
|
+
interface ReactEmailTemplatesMap {
|
|
7
|
+
[key: string]: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const SUPPORTED_TEMPLATE_EXTENSIONS = new Set([
|
|
11
|
+
'.ts',
|
|
12
|
+
'.tsx',
|
|
13
|
+
'.js',
|
|
14
|
+
'.jsx',
|
|
15
|
+
'.mts',
|
|
16
|
+
'.cts',
|
|
17
|
+
'.mjs',
|
|
18
|
+
'.cjs',
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Recursively finds all supported template files in a directory
|
|
23
|
+
*/
|
|
24
|
+
export function findTemplateFiles(
|
|
25
|
+
dir: string,
|
|
26
|
+
baseDir: string,
|
|
27
|
+
files: Map<string, string> = new Map(),
|
|
28
|
+
): Map<string, string> {
|
|
29
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
30
|
+
|
|
31
|
+
for (const entry of entries) {
|
|
32
|
+
const fullPath = path.join(dir, entry.name);
|
|
33
|
+
|
|
34
|
+
if (entry.isDirectory()) {
|
|
35
|
+
findTemplateFiles(fullPath, baseDir, files);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!entry.isFile()) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const extension = path.extname(entry.name).toLowerCase();
|
|
44
|
+
if (!SUPPORTED_TEMPLATE_EXTENSIONS.has(extension)) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
49
|
+
const relativePath = path.relative(baseDir, fullPath).replace(/\\/g, '/');
|
|
50
|
+
files.set(relativePath, content);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return files;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Main function to compile react email templates to JSON
|
|
58
|
+
*/
|
|
59
|
+
export function compileReactEmailTemplates(
|
|
60
|
+
inputDir: string = './templates',
|
|
61
|
+
outputFile: string = 'compiled-react-email-templates.json',
|
|
62
|
+
): void {
|
|
63
|
+
if (!fs.existsSync(inputDir)) {
|
|
64
|
+
throw new Error(`Directory "${inputDir}" does not exist.`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (!fs.statSync(inputDir).isDirectory()) {
|
|
68
|
+
throw new Error(`"${inputDir}" is not a directory.`);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
console.log(`Searching for template files in: ${inputDir}`);
|
|
72
|
+
|
|
73
|
+
const templateFiles = findTemplateFiles(inputDir, inputDir);
|
|
74
|
+
|
|
75
|
+
console.log(`Found ${templateFiles.size} template file(s)`);
|
|
76
|
+
|
|
77
|
+
const result: ReactEmailTemplatesMap = {};
|
|
78
|
+
for (const [filePath, content] of templateFiles.entries()) {
|
|
79
|
+
result[filePath] = content;
|
|
80
|
+
console.log(` - ${filePath}`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const outputContent = JSON.stringify(result, null, 2);
|
|
84
|
+
fs.writeFileSync(outputFile, outputContent, 'utf-8');
|
|
85
|
+
|
|
86
|
+
console.log(`\nSuccessfully compiled templates to: ${outputFile}`);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function runFromCli(): void {
|
|
90
|
+
const args = process.argv.slice(2);
|
|
91
|
+
|
|
92
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
93
|
+
console.log('Usage: compile-react-email-templates [input-directory] [output-file]');
|
|
94
|
+
console.log('');
|
|
95
|
+
console.log('Arguments:');
|
|
96
|
+
console.log(
|
|
97
|
+
' input-directory Directory containing React Email templates (default: ./templates)',
|
|
98
|
+
);
|
|
99
|
+
console.log(
|
|
100
|
+
' output-file Output JSON file path (default: compiled-react-email-templates.json)',
|
|
101
|
+
);
|
|
102
|
+
console.log('');
|
|
103
|
+
console.log('Supported extensions: .ts, .tsx, .js, .jsx, .mts, .cts, .mjs, .cjs');
|
|
104
|
+
console.log('');
|
|
105
|
+
console.log('Examples:');
|
|
106
|
+
console.log(' compile-react-email-templates');
|
|
107
|
+
console.log(' compile-react-email-templates ./notification-templates');
|
|
108
|
+
console.log(
|
|
109
|
+
' compile-react-email-templates ./notification-templates ./compiled-notification-templates.json',
|
|
110
|
+
);
|
|
111
|
+
process.exit(0);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const [inputDir, outputFile] = args;
|
|
115
|
+
|
|
116
|
+
try {
|
|
117
|
+
compileReactEmailTemplates(inputDir, outputFile);
|
|
118
|
+
} catch (error) {
|
|
119
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
120
|
+
console.error(`Error: ${message}`);
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const isCliEntryPoint = (() => {
|
|
126
|
+
const entry = process.argv[1];
|
|
127
|
+
if (!entry) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
try {
|
|
132
|
+
return pathToFileURL(entry).href === import.meta.url;
|
|
133
|
+
} catch {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
})();
|
|
137
|
+
|
|
138
|
+
if (isCliEntryPoint) {
|
|
139
|
+
runFromCli();
|
|
140
|
+
}
|