react-email 1.5.0 → 1.5.2
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/commands/export.d.ts +1 -0
- package/dist/commands/export.js +79 -0
- package/dist/commands/exportTemplates.js +3 -2
- package/dist/utils/watcher.js +2 -2
- package/package.json +6 -4
- package/preview/package.json +2 -2
- package/source/commands/exportTemplates.ts +3 -2
- package/source/utils/watcher.ts +2 -2
- package/preview/src/components/kbd.tsx +0 -21
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const exportTemplates: (outDir: string, pretty: boolean) => Promise<void>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.exportTemplates = void 0;
|
|
30
|
+
const glob_1 = require("glob");
|
|
31
|
+
const esbuild_1 = __importDefault(require("esbuild"));
|
|
32
|
+
const tree_node_cli_1 = __importDefault(require("tree-node-cli"));
|
|
33
|
+
const ora_1 = __importDefault(require("ora"));
|
|
34
|
+
const log_symbols_1 = __importDefault(require("log-symbols"));
|
|
35
|
+
const render_1 = require("@react-email/render");
|
|
36
|
+
const fs_1 = require("fs");
|
|
37
|
+
const cpy_1 = __importDefault(require("cpy"));
|
|
38
|
+
const normalize_path_1 = __importDefault(require("normalize-path"));
|
|
39
|
+
const utils_1 = require("../utils");
|
|
40
|
+
/*
|
|
41
|
+
This first builds all the templates using esbuild and then puts the output in the `.js`
|
|
42
|
+
files. Then these `.js` files are imported dynamically and rendered to `.html` files
|
|
43
|
+
using the `render` function.
|
|
44
|
+
*/
|
|
45
|
+
const exportTemplates = async (outDir, pretty) => {
|
|
46
|
+
const spinner = (0, ora_1.default)('Preparing files...\n').start();
|
|
47
|
+
const allTemplates = glob_1.glob.sync((0, normalize_path_1.default)(`${utils_1.CLIENT_EMAILS_PATH}/*.{tsx,jsx}`));
|
|
48
|
+
esbuild_1.default.buildSync({
|
|
49
|
+
bundle: true,
|
|
50
|
+
entryPoints: allTemplates,
|
|
51
|
+
platform: 'node',
|
|
52
|
+
write: true,
|
|
53
|
+
outdir: outDir,
|
|
54
|
+
});
|
|
55
|
+
const allBuiltTemplates = glob_1.glob.sync((0, normalize_path_1.default)(`${outDir}/*.js`), {
|
|
56
|
+
absolute: true,
|
|
57
|
+
});
|
|
58
|
+
for (const template of allBuiltTemplates) {
|
|
59
|
+
const component = await Promise.resolve().then(() => __importStar(require(template)));
|
|
60
|
+
const rendered = (0, render_1.render)(component.default(), { pretty });
|
|
61
|
+
const htmlPath = template.replace('.js', '.html');
|
|
62
|
+
(0, fs_1.writeFileSync)(htmlPath, rendered);
|
|
63
|
+
(0, fs_1.unlinkSync)(template);
|
|
64
|
+
}
|
|
65
|
+
const hasStaticDirectory = (0, utils_1.checkDirectoryExist)(`${utils_1.CLIENT_EMAILS_PATH}/static`);
|
|
66
|
+
if (hasStaticDirectory) {
|
|
67
|
+
await (0, cpy_1.default)(`${utils_1.CLIENT_EMAILS_PATH}/static`, `${outDir}/static`);
|
|
68
|
+
}
|
|
69
|
+
const fileTree = (0, tree_node_cli_1.default)(outDir, {
|
|
70
|
+
allFiles: true,
|
|
71
|
+
maxDepth: 4,
|
|
72
|
+
});
|
|
73
|
+
console.log(fileTree);
|
|
74
|
+
spinner.stopAndPersist({
|
|
75
|
+
symbol: log_symbols_1.default.success,
|
|
76
|
+
text: 'Successfully exported emails',
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
exports.exportTemplates = exportTemplates;
|
|
@@ -35,6 +35,7 @@ const log_symbols_1 = __importDefault(require("log-symbols"));
|
|
|
35
35
|
const render_1 = require("@react-email/render");
|
|
36
36
|
const fs_1 = require("fs");
|
|
37
37
|
const cpy_1 = __importDefault(require("cpy"));
|
|
38
|
+
const normalize_path_1 = __importDefault(require("normalize-path"));
|
|
38
39
|
const utils_1 = require("../utils");
|
|
39
40
|
/*
|
|
40
41
|
This first builds all the templates using esbuild and then puts the output in the `.js`
|
|
@@ -43,7 +44,7 @@ const utils_1 = require("../utils");
|
|
|
43
44
|
*/
|
|
44
45
|
const exportTemplates = async (outDir, pretty) => {
|
|
45
46
|
const spinner = (0, ora_1.default)('Preparing files...\n').start();
|
|
46
|
-
const allTemplates = glob_1.glob.sync(`${utils_1.CLIENT_EMAILS_PATH}/*.{tsx,jsx}`);
|
|
47
|
+
const allTemplates = glob_1.glob.sync((0, normalize_path_1.default)(`${utils_1.CLIENT_EMAILS_PATH}/*.{tsx,jsx}`));
|
|
47
48
|
esbuild_1.default.buildSync({
|
|
48
49
|
bundle: true,
|
|
49
50
|
entryPoints: allTemplates,
|
|
@@ -51,7 +52,7 @@ const exportTemplates = async (outDir, pretty) => {
|
|
|
51
52
|
write: true,
|
|
52
53
|
outdir: outDir,
|
|
53
54
|
});
|
|
54
|
-
const allBuiltTemplates = glob_1.glob.sync(`${outDir}/*.js
|
|
55
|
+
const allBuiltTemplates = glob_1.glob.sync((0, normalize_path_1.default)(`${outDir}/*.js`), {
|
|
55
56
|
absolute: true,
|
|
56
57
|
});
|
|
57
58
|
for (const template of allBuiltTemplates) {
|
package/dist/utils/watcher.js
CHANGED
|
@@ -16,7 +16,7 @@ exports.watcherInstance = chokidar_1.default.watch(constants_1.CLIENT_EMAILS_PAT
|
|
|
16
16
|
});
|
|
17
17
|
const watcher = () => exports.watcherInstance.on('all', async (event, filename) => {
|
|
18
18
|
if (event === constants_1.EVENT_FILE_DELETED) {
|
|
19
|
-
const file = filename.split(
|
|
19
|
+
const file = filename.split(path_1.default.sep);
|
|
20
20
|
if (file[1] === 'static') {
|
|
21
21
|
if (file[2]) {
|
|
22
22
|
await fs_1.default.promises.rm(path_1.default.join(constants_1.REACT_EMAIL_ROOT, 'public', 'static', file[2]));
|
|
@@ -26,7 +26,7 @@ const watcher = () => exports.watcherInstance.on('all', async (event, filename)
|
|
|
26
26
|
await fs_1.default.promises.rm(path_1.default.join(constants_1.REACT_EMAIL_ROOT, filename));
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
|
-
const file = filename.split(
|
|
29
|
+
const file = filename.split(path_1.default.sep);
|
|
30
30
|
if (file[1] === 'static') {
|
|
31
31
|
await (0, cpy_1.default)(`${constants_1.CLIENT_EMAILS_PATH}/static/${file[2]}`, `${constants_1.REACT_EMAIL_ROOT}/public/static`);
|
|
32
32
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-email",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "A live preview of your emails right in your browser.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"email": "./dist/index.js"
|
|
@@ -30,22 +30,24 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@commander-js/extra-typings": "9.4.1",
|
|
33
|
-
"@react-email/render": "
|
|
33
|
+
"@react-email/render": "0.0.3",
|
|
34
34
|
"chokidar": "3.5.3",
|
|
35
35
|
"commander": "9.4.1",
|
|
36
36
|
"cpy": "8.1.2",
|
|
37
37
|
"esbuild": "0.16.4",
|
|
38
38
|
"glob": "8.0.3",
|
|
39
39
|
"log-symbols": "4.1.0",
|
|
40
|
+
"normalize-path": "3.0.0",
|
|
40
41
|
"ora": "5.4.1",
|
|
41
42
|
"read-pkg": "5.2.0",
|
|
42
43
|
"shelljs": "0.8.5",
|
|
43
|
-
"tree-node-cli": "
|
|
44
|
+
"tree-node-cli": "1.6.0"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@types/node": "18.11.9",
|
|
48
|
+
"@types/normalize-path": "3.0.0",
|
|
47
49
|
"@types/shelljs": "0.8.11",
|
|
48
50
|
"prettier": "2.7.1",
|
|
49
51
|
"ts-node": "10.9.1"
|
|
50
52
|
}
|
|
51
|
-
}
|
|
53
|
+
}
|
package/preview/package.json
CHANGED
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"@next/font": "13.0.4",
|
|
19
19
|
"@radix-ui/colors": "0.1.8",
|
|
20
20
|
"@radix-ui/react-collapsible": "1.0.1",
|
|
21
|
-
"@radix-ui/react-popover": "
|
|
21
|
+
"@radix-ui/react-popover": "1.0.2",
|
|
22
22
|
"@radix-ui/react-slot": "1.0.1",
|
|
23
23
|
"@radix-ui/react-toggle-group": "1.0.1",
|
|
24
|
-
"@radix-ui/react-tooltip": "
|
|
24
|
+
"@radix-ui/react-tooltip": "1.0.2",
|
|
25
25
|
"@react-email/render": "0.0.2",
|
|
26
26
|
"classnames": "2.3.2",
|
|
27
27
|
"next": "13.0.4",
|
|
@@ -6,6 +6,7 @@ import logSymbols from 'log-symbols';
|
|
|
6
6
|
import { render } from '@react-email/render';
|
|
7
7
|
import { unlinkSync, writeFileSync } from 'fs';
|
|
8
8
|
import copy from 'cpy';
|
|
9
|
+
import normalize from 'normalize-path';
|
|
9
10
|
import { checkDirectoryExist, CLIENT_EMAILS_PATH } from '../utils';
|
|
10
11
|
|
|
11
12
|
/*
|
|
@@ -15,7 +16,7 @@ import { checkDirectoryExist, CLIENT_EMAILS_PATH } from '../utils';
|
|
|
15
16
|
*/
|
|
16
17
|
export const exportTemplates = async (outDir: string, pretty: boolean) => {
|
|
17
18
|
const spinner = ora('Preparing files...\n').start();
|
|
18
|
-
const allTemplates = glob.sync(`${CLIENT_EMAILS_PATH}/*.{tsx,jsx}`);
|
|
19
|
+
const allTemplates = glob.sync(normalize(`${CLIENT_EMAILS_PATH}/*.{tsx,jsx}`));
|
|
19
20
|
|
|
20
21
|
esbuild.buildSync({
|
|
21
22
|
bundle: true,
|
|
@@ -25,7 +26,7 @@ export const exportTemplates = async (outDir: string, pretty: boolean) => {
|
|
|
25
26
|
outdir: outDir,
|
|
26
27
|
});
|
|
27
28
|
|
|
28
|
-
const allBuiltTemplates = glob.sync(`${outDir}/*.js
|
|
29
|
+
const allBuiltTemplates = glob.sync(normalize(`${outDir}/*.js`), {
|
|
29
30
|
absolute: true,
|
|
30
31
|
});
|
|
31
32
|
|
package/source/utils/watcher.ts
CHANGED
|
@@ -19,7 +19,7 @@ export const watcherInstance = chokidar.watch(CLIENT_EMAILS_PATH, {
|
|
|
19
19
|
export const watcher = () =>
|
|
20
20
|
watcherInstance.on('all', async (event, filename) => {
|
|
21
21
|
if (event === EVENT_FILE_DELETED) {
|
|
22
|
-
const file = filename.split(
|
|
22
|
+
const file = filename.split(path.sep);
|
|
23
23
|
|
|
24
24
|
if (file[1] === 'static') {
|
|
25
25
|
if (file[2]) {
|
|
@@ -32,7 +32,7 @@ export const watcher = () =>
|
|
|
32
32
|
|
|
33
33
|
await fs.promises.rm(path.join(REACT_EMAIL_ROOT, filename));
|
|
34
34
|
} else {
|
|
35
|
-
const file = filename.split(
|
|
35
|
+
const file = filename.split(path.sep);
|
|
36
36
|
|
|
37
37
|
if (file[1] === 'static') {
|
|
38
38
|
await copy(
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
export interface KbdProps { }
|
|
4
|
-
|
|
5
|
-
type KbdElement = React.ElementRef<'kbd'>;
|
|
6
|
-
type RootProps = React.ComponentPropsWithoutRef<'kbd'>;
|
|
7
|
-
|
|
8
|
-
export interface KbdProps extends RootProps { }
|
|
9
|
-
|
|
10
|
-
export const Kbd = React.forwardRef<KbdElement, Readonly<KbdProps>>(
|
|
11
|
-
({ children }, forwardedRef) => (
|
|
12
|
-
<kbd
|
|
13
|
-
ref={forwardedRef}
|
|
14
|
-
className="uppercase bg-slate-7 text-slate-11 rounded-md py-[2px] px-[6px] ml-1 text-xs"
|
|
15
|
-
>
|
|
16
|
-
{children}
|
|
17
|
-
</kbd>
|
|
18
|
-
),
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
Kbd.displayName = 'Kbd';
|