react-email 1.5.1 → 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.
@@ -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/index.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-email",
3
- "version": "1.5.1",
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,13 +30,14 @@
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",
@@ -44,6 +45,7 @@
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"
@@ -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