react-email 1.9.4 → 1.10.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/.eslintrc.js +5 -2
- package/dist/package.json +14 -17
- package/dist/source/commands/dev.d.ts +3 -1
- package/dist/source/commands/dev.d.ts.map +1 -0
- package/dist/source/commands/dev.js +72 -20
- package/dist/source/commands/export.d.ts +2 -1
- package/dist/source/commands/export.d.ts.map +1 -0
- package/dist/source/commands/export.js +137 -57
- package/dist/source/commands/preview.d.ts +1 -0
- package/dist/source/commands/preview.d.ts.map +1 -0
- package/dist/source/commands/preview.js +98 -30
- package/dist/source/index.d.ts +1 -0
- package/dist/source/index.d.ts.map +1 -0
- package/dist/source/index.js +12 -7
- package/dist/source/utils/close-ora-on-sigint.d.ts +2 -1
- package/dist/source/utils/close-ora-on-sigint.d.ts.map +1 -0
- package/dist/source/utils/close-ora-on-sigint.js +1 -1
- package/dist/source/utils/constants.d.ts +1 -0
- package/dist/source/utils/constants.d.ts.map +1 -0
- package/dist/source/utils/constants.js +6 -6
- package/dist/source/utils/convert-to-absolute-path.d.ts +1 -0
- package/dist/source/utils/convert-to-absolute-path.d.ts.map +1 -0
- package/dist/source/utils/convert-to-absolute-path.js +4 -2
- package/dist/source/utils/download-client.d.ts +1 -0
- package/dist/source/utils/download-client.d.ts.map +1 -0
- package/dist/source/utils/download-client.js +63 -18
- package/dist/source/utils/generate-email-preview.d.ts +1 -0
- package/dist/source/utils/generate-email-preview.d.ts.map +1 -0
- package/dist/source/utils/generate-email-preview.js +122 -63
- package/dist/source/utils/index.d.ts +1 -0
- package/dist/source/utils/index.d.ts.map +1 -0
- package/dist/source/utils/install-dependencies.d.ts +2 -1
- package/dist/source/utils/install-dependencies.d.ts.map +1 -0
- package/dist/source/utils/install-dependencies.js +10 -10
- package/dist/source/utils/run-server.d.ts +5 -4
- package/dist/source/utils/run-server.d.ts.map +1 -0
- package/dist/source/utils/run-server.js +90 -35
- package/dist/source/utils/start-server-command.d.ts +1 -0
- package/dist/source/utils/start-server-command.d.ts.map +1 -0
- package/dist/source/utils/start-server-command.js +17 -17
- package/dist/source/utils/sync-package.d.ts +1 -0
- package/dist/source/utils/sync-package.d.ts.map +1 -0
- package/dist/source/utils/sync-package.js +69 -16
- package/dist/source/utils/tree.d.ts +2 -0
- package/dist/source/utils/tree.d.ts.map +1 -0
- package/dist/source/utils/tree.js +58 -0
- package/dist/source/utils/watcher.d.ts +3 -2
- package/dist/source/utils/watcher.d.ts.map +1 -0
- package/dist/source/utils/watcher.js +21 -28
- package/package.json +14 -17
- package/source/commands/dev.ts +6 -5
- package/source/commands/export.ts +48 -20
- package/source/commands/preview.ts +1 -1
- package/source/index.ts +3 -1
- package/source/utils/close-ora-on-sigint.ts +2 -2
- package/source/utils/constants.ts +1 -1
- package/source/utils/convert-to-absolute-path.ts +1 -1
- package/source/utils/download-client.ts +3 -3
- package/source/utils/generate-email-preview.ts +31 -32
- package/source/utils/install-dependencies.ts +3 -3
- package/source/utils/run-server.ts +11 -8
- package/source/utils/start-server-command.ts +4 -5
- package/source/utils/sync-package.ts +2 -2
- package/source/utils/tree.ts +10 -0
- package/source/utils/watcher.ts +18 -28
- package/tsconfig.export.json +31 -0
- package/tsconfig.json +8 -31
package/.eslintrc.js
CHANGED
package/dist/package.json
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-email",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "A live preview of your emails right in your browser.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"email": "./dist/source/index.js"
|
|
7
7
|
},
|
|
8
8
|
"types": "./dist/source/index.d.ts",
|
|
9
9
|
"scripts": {
|
|
10
|
-
"build": "tsc",
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"lint": "eslint",
|
|
14
|
-
"clean": "rm -rf dist"
|
|
10
|
+
"build": "tsc -p ./tsconfig.json",
|
|
11
|
+
"clean": "rm -rf dist",
|
|
12
|
+
"lint": "eslint ."
|
|
15
13
|
},
|
|
16
14
|
"license": "MIT",
|
|
17
15
|
"repository": {
|
|
@@ -24,33 +22,32 @@
|
|
|
24
22
|
"email"
|
|
25
23
|
],
|
|
26
24
|
"engines": {
|
|
27
|
-
"node": ">=
|
|
25
|
+
"node": ">=18.0.0"
|
|
28
26
|
},
|
|
29
27
|
"dependencies": {
|
|
30
28
|
"@commander-js/extra-typings": "9.4.1",
|
|
31
|
-
"@manypkg/find-root": "2.1
|
|
29
|
+
"@manypkg/find-root": "2.2.1",
|
|
32
30
|
"@octokit/rest": "19.0.7",
|
|
33
|
-
"@react-email/render": "0.0.
|
|
31
|
+
"@react-email/render": "0.0.10",
|
|
34
32
|
"chokidar": "3.5.3",
|
|
35
33
|
"commander": "9.4.1",
|
|
36
34
|
"detect-package-manager": "2.0.1",
|
|
37
35
|
"esbuild": "0.16.4",
|
|
38
|
-
"fs-extra": "11.1.
|
|
39
|
-
"glob": "
|
|
36
|
+
"fs-extra": "11.1.1",
|
|
37
|
+
"glob": "10.3.4",
|
|
40
38
|
"log-symbols": "4.1.0",
|
|
41
39
|
"normalize-path": "3.0.0",
|
|
42
40
|
"ora": "5.4.1",
|
|
43
41
|
"read-pkg": "5.2.0",
|
|
44
42
|
"shelljs": "0.8.5",
|
|
45
|
-
"tree-
|
|
43
|
+
"tree-cli": "0.6.7"
|
|
46
44
|
},
|
|
47
45
|
"devDependencies": {
|
|
48
46
|
"@types/fs-extra": "11.0.1",
|
|
49
|
-
"@types/node": "18.11.9",
|
|
50
47
|
"@types/normalize-path": "3.0.0",
|
|
51
|
-
"@types/shelljs": "0.8.
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"typescript": "5.
|
|
48
|
+
"@types/shelljs": "0.8.12",
|
|
49
|
+
"eslint-config-custom": "workspace:*",
|
|
50
|
+
"tsconfig": "workspace:*",
|
|
51
|
+
"typescript": "5.1.6"
|
|
55
52
|
}
|
|
56
53
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
interface Args {
|
|
2
2
|
dir: string;
|
|
3
3
|
port: string;
|
|
4
|
+
skipInstall: boolean;
|
|
4
5
|
}
|
|
5
|
-
export declare const dev: ({ dir, port }: Args) => Promise<void>;
|
|
6
|
+
export declare const dev: ({ dir, port, skipInstall }: Args) => Promise<void>;
|
|
6
7
|
export {};
|
|
8
|
+
//# sourceMappingURL=dev.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../source/commands/dev.ts"],"names":[],"mappings":"AAKA,UAAU,IAAI;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,GAAG,+BAAsC,IAAI,kBAkBzD,CAAC"}
|
|
@@ -1,28 +1,80 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
2
38
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
40
|
};
|
|
5
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
42
|
exports.dev = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
43
|
+
var node_fs_1 = __importDefault(require("node:fs"));
|
|
44
|
+
var shelljs_1 = __importDefault(require("shelljs"));
|
|
45
|
+
var utils_1 = require("../utils");
|
|
46
|
+
var run_server_1 = require("../utils/run-server");
|
|
47
|
+
var dev = function (_a) {
|
|
48
|
+
var dir = _a.dir, port = _a.port, skipInstall = _a.skipInstall;
|
|
49
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
50
|
+
var error_1;
|
|
51
|
+
return __generator(this, function (_b) {
|
|
52
|
+
switch (_b.label) {
|
|
53
|
+
case 0:
|
|
54
|
+
_b.trys.push([0, 5, , 6]);
|
|
55
|
+
if (!node_fs_1.default.existsSync(dir)) {
|
|
56
|
+
throw new Error("Missing ".concat(dir, " folder"));
|
|
57
|
+
}
|
|
58
|
+
if (!node_fs_1.default.existsSync(utils_1.REACT_EMAIL_ROOT)) return [3 /*break*/, 2];
|
|
59
|
+
return [4 /*yield*/, (0, run_server_1.setupServer)('dev', dir, port, skipInstall)];
|
|
60
|
+
case 1:
|
|
61
|
+
_b.sent();
|
|
62
|
+
return [2 /*return*/];
|
|
63
|
+
case 2: return [4 /*yield*/, (0, utils_1.downloadClient)()];
|
|
64
|
+
case 3:
|
|
65
|
+
_b.sent();
|
|
66
|
+
return [4 /*yield*/, (0, run_server_1.setupServer)('dev', dir, port, skipInstall)];
|
|
67
|
+
case 4:
|
|
68
|
+
_b.sent();
|
|
69
|
+
return [3 /*break*/, 6];
|
|
70
|
+
case 5:
|
|
71
|
+
error_1 = _b.sent();
|
|
72
|
+
console.log(error_1);
|
|
73
|
+
shelljs_1.default.exit(1);
|
|
74
|
+
return [3 /*break*/, 6];
|
|
75
|
+
case 6: return [2 /*return*/];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
27
79
|
};
|
|
28
80
|
exports.dev = dev;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../../source/commands/export.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAWnD,eAAO,MAAM,eAAe,WAClB,MAAM,UACN,MAAM,WACL,OAAO,mBA0FjB,CAAC"}
|
|
@@ -22,73 +22,153 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
+
function step(op) {
|
|
39
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
+
switch (op[0]) {
|
|
44
|
+
case 0: case 1: t = op; break;
|
|
45
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
+
default:
|
|
49
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
+
if (t[2]) _.ops.pop();
|
|
54
|
+
_.trys.pop(); continue;
|
|
55
|
+
}
|
|
56
|
+
op = body.call(thisArg, _);
|
|
57
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
25
61
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
62
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
63
|
};
|
|
28
64
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
65
|
exports.exportTemplates = void 0;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const close_ora_on_sigint_1 = require("../utils/close-ora-on-sigint");
|
|
66
|
+
var node_fs_1 = __importStar(require("node:fs"));
|
|
67
|
+
var node_path_1 = __importDefault(require("node:path"));
|
|
68
|
+
var glob_1 = require("glob");
|
|
69
|
+
var esbuild_1 = __importDefault(require("esbuild"));
|
|
70
|
+
var ora_1 = __importDefault(require("ora"));
|
|
71
|
+
var log_symbols_1 = __importDefault(require("log-symbols"));
|
|
72
|
+
var render_1 = require("@react-email/render");
|
|
73
|
+
var normalize_path_1 = __importDefault(require("normalize-path"));
|
|
74
|
+
var shelljs_1 = __importDefault(require("shelljs"));
|
|
75
|
+
var close_ora_on_sigint_1 = require("../utils/close-ora-on-sigint");
|
|
76
|
+
var tree_1 = require("../utils/tree");
|
|
42
77
|
/*
|
|
43
78
|
This first builds all the templates using esbuild and then puts the output in the `.js`
|
|
44
79
|
files. Then these `.js` files are imported dynamically and rendered to `.html` files
|
|
45
80
|
using the `render` function.
|
|
46
81
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
var exportTemplates = function (outDir, srcDir, options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
83
|
+
var spinner, allTemplates, buildResult, allBuiltTemplates, _i, allBuiltTemplates_1, template, component, rendered, htmlPath, exception_1, staticDir, hasStaticDirectory, result, fileTree;
|
|
84
|
+
return __generator(this, function (_a) {
|
|
85
|
+
switch (_a.label) {
|
|
86
|
+
case 0:
|
|
87
|
+
spinner = (0, ora_1.default)('Preparing files...\n').start();
|
|
88
|
+
(0, close_ora_on_sigint_1.closeOraOnSIGNIT)(spinner);
|
|
89
|
+
allTemplates = glob_1.glob.sync((0, normalize_path_1.default)(node_path_1.default.join(srcDir, '*.{tsx,jsx}')));
|
|
90
|
+
buildResult = esbuild_1.default.buildSync({
|
|
91
|
+
bundle: true,
|
|
92
|
+
entryPoints: allTemplates,
|
|
93
|
+
platform: 'node',
|
|
94
|
+
write: true,
|
|
95
|
+
tsconfig: node_path_1.default.join(__dirname, '../../..', 'tsconfig.export.json'),
|
|
96
|
+
outdir: outDir,
|
|
97
|
+
});
|
|
98
|
+
if (buildResult.warnings.length > 0) {
|
|
99
|
+
console.warn(buildResult.warnings);
|
|
100
|
+
}
|
|
101
|
+
if (buildResult.errors.length > 0) {
|
|
102
|
+
spinner.stopAndPersist({
|
|
103
|
+
symbol: log_symbols_1.default.error,
|
|
104
|
+
text: 'Failed to build emails',
|
|
105
|
+
});
|
|
106
|
+
console.error(buildResult.errors);
|
|
107
|
+
throw new Error("esbuild bundling process for email templates:\n".concat(allTemplates
|
|
108
|
+
.map(function (p) { return "- ".concat(p); })
|
|
109
|
+
.join('\n')));
|
|
110
|
+
}
|
|
111
|
+
spinner.succeed();
|
|
112
|
+
allBuiltTemplates = glob_1.glob.sync((0, normalize_path_1.default)("".concat(outDir, "/*.js")), {
|
|
113
|
+
absolute: true,
|
|
114
|
+
});
|
|
115
|
+
_i = 0, allBuiltTemplates_1 = allBuiltTemplates;
|
|
116
|
+
_a.label = 1;
|
|
117
|
+
case 1:
|
|
118
|
+
if (!(_i < allBuiltTemplates_1.length)) return [3 /*break*/, 6];
|
|
119
|
+
template = allBuiltTemplates_1[_i];
|
|
120
|
+
_a.label = 2;
|
|
121
|
+
case 2:
|
|
122
|
+
_a.trys.push([2, 4, , 5]);
|
|
123
|
+
spinner.text = "rendering ".concat(template.split('/').pop());
|
|
124
|
+
spinner.render();
|
|
125
|
+
return [4 /*yield*/, Promise.resolve("".concat(template)).then(function (s) { return __importStar(require(s)); })];
|
|
126
|
+
case 3:
|
|
127
|
+
component = _a.sent();
|
|
128
|
+
rendered = (0, render_1.render)(component.default({}), options);
|
|
129
|
+
htmlPath = template.replace('.js', options.plainText ? '.txt' : '.html');
|
|
130
|
+
(0, node_fs_1.writeFileSync)(htmlPath, rendered);
|
|
131
|
+
(0, node_fs_1.unlinkSync)(template);
|
|
132
|
+
return [3 /*break*/, 5];
|
|
133
|
+
case 4:
|
|
134
|
+
exception_1 = _a.sent();
|
|
135
|
+
spinner.stopAndPersist({
|
|
136
|
+
symbol: log_symbols_1.default.error,
|
|
137
|
+
text: "failed when rendering ".concat(template.split('/').pop()),
|
|
138
|
+
});
|
|
139
|
+
console.error(exception_1);
|
|
140
|
+
throw exception_1;
|
|
141
|
+
case 5:
|
|
142
|
+
_i++;
|
|
143
|
+
return [3 /*break*/, 1];
|
|
144
|
+
case 6:
|
|
145
|
+
spinner.succeed('Rendered all files');
|
|
146
|
+
spinner.text = "Copying static files";
|
|
147
|
+
spinner.render();
|
|
148
|
+
staticDir = node_path_1.default.join(srcDir, 'static');
|
|
149
|
+
hasStaticDirectory = node_fs_1.default.existsSync(staticDir);
|
|
150
|
+
if (hasStaticDirectory) {
|
|
151
|
+
result = shelljs_1.default.cp('-r', staticDir, node_path_1.default.join(outDir, 'static'));
|
|
152
|
+
if (result.code > 0) {
|
|
153
|
+
spinner.stopAndPersist({
|
|
154
|
+
symbol: log_symbols_1.default.error,
|
|
155
|
+
text: 'Failed to copy static files',
|
|
156
|
+
});
|
|
157
|
+
throw new Error("Something went wrong while copying the file to ".concat(outDir, "/static, ").concat(result.cat()));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
spinner.succeed();
|
|
161
|
+
return [4 /*yield*/, (0, tree_1.tree)(outDir, 4)];
|
|
162
|
+
case 7:
|
|
163
|
+
fileTree = _a.sent();
|
|
164
|
+
console.log(fileTree);
|
|
165
|
+
spinner.stopAndPersist({
|
|
166
|
+
symbol: log_symbols_1.default.success,
|
|
167
|
+
text: 'Successfully exported emails',
|
|
168
|
+
});
|
|
169
|
+
process.exit();
|
|
170
|
+
return [2 /*return*/];
|
|
80
171
|
}
|
|
81
|
-
}
|
|
82
|
-
spinner.succeed();
|
|
83
|
-
const fileTree = (0, tree_node_cli_1.default)(outDir, {
|
|
84
|
-
allFiles: true,
|
|
85
|
-
maxDepth: 4,
|
|
86
172
|
});
|
|
87
|
-
|
|
88
|
-
spinner.stopAndPersist({
|
|
89
|
-
symbol: log_symbols_1.default.success,
|
|
90
|
-
text: 'Successfully exported emails',
|
|
91
|
-
});
|
|
92
|
-
process.exit();
|
|
93
|
-
};
|
|
173
|
+
}); };
|
|
94
174
|
exports.exportTemplates = exportTemplates;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../source/commands/preview.ts"],"names":[],"mappings":"AAKA,UAAU,gBAAgB;IACxB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,YAAY,YAAmB,gBAAgB,kBAc3D,CAAC;AAEF,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,YAAY,aAAoB,gBAAgB,kBAc5D,CAAC"}
|
|
@@ -1,40 +1,108 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
2
38
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
40
|
};
|
|
5
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
42
|
exports.startPreview = exports.buildPreview = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
43
|
+
var node_fs_1 = __importDefault(require("node:fs"));
|
|
44
|
+
var shelljs_1 = __importDefault(require("shelljs"));
|
|
45
|
+
var utils_1 = require("../utils");
|
|
46
|
+
var run_server_1 = require("../utils/run-server");
|
|
47
|
+
var buildPreview = function (_a) {
|
|
48
|
+
var dir = _a.dir;
|
|
49
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
50
|
+
var error_1;
|
|
51
|
+
return __generator(this, function (_b) {
|
|
52
|
+
switch (_b.label) {
|
|
53
|
+
case 0:
|
|
54
|
+
_b.trys.push([0, 5, , 6]);
|
|
55
|
+
if (!node_fs_1.default.existsSync(utils_1.REACT_EMAIL_ROOT)) return [3 /*break*/, 2];
|
|
56
|
+
return [4 /*yield*/, (0, run_server_1.setupServer)('build', dir, '')];
|
|
57
|
+
case 1:
|
|
58
|
+
_b.sent();
|
|
59
|
+
return [2 /*return*/];
|
|
60
|
+
case 2: return [4 /*yield*/, (0, utils_1.downloadClient)()];
|
|
61
|
+
case 3:
|
|
62
|
+
_b.sent();
|
|
63
|
+
return [4 /*yield*/, (0, run_server_1.setupServer)('build', dir, '')];
|
|
64
|
+
case 4:
|
|
65
|
+
_b.sent();
|
|
66
|
+
return [3 /*break*/, 6];
|
|
67
|
+
case 5:
|
|
68
|
+
error_1 = _b.sent();
|
|
69
|
+
console.log(error_1);
|
|
70
|
+
shelljs_1.default.exit(1);
|
|
71
|
+
return [3 /*break*/, 6];
|
|
72
|
+
case 6: return [2 /*return*/];
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
24
76
|
};
|
|
25
77
|
exports.buildPreview = buildPreview;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
78
|
+
var startPreview = function (_a) {
|
|
79
|
+
var port = _a.port;
|
|
80
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
81
|
+
var error_2;
|
|
82
|
+
return __generator(this, function (_b) {
|
|
83
|
+
switch (_b.label) {
|
|
84
|
+
case 0:
|
|
85
|
+
_b.trys.push([0, 5, , 6]);
|
|
86
|
+
if (!node_fs_1.default.existsSync(utils_1.REACT_EMAIL_ROOT)) return [3 /*break*/, 2];
|
|
87
|
+
return [4 /*yield*/, (0, run_server_1.setupServer)('start', '', port)];
|
|
88
|
+
case 1:
|
|
89
|
+
_b.sent();
|
|
90
|
+
return [2 /*return*/];
|
|
91
|
+
case 2: return [4 /*yield*/, (0, utils_1.downloadClient)()];
|
|
92
|
+
case 3:
|
|
93
|
+
_b.sent();
|
|
94
|
+
return [4 /*yield*/, (0, run_server_1.setupServer)('start', '', port)];
|
|
95
|
+
case 4:
|
|
96
|
+
_b.sent();
|
|
97
|
+
return [3 /*break*/, 6];
|
|
98
|
+
case 5:
|
|
99
|
+
error_2 = _b.sent();
|
|
100
|
+
console.log(error_2);
|
|
101
|
+
shelljs_1.default.exit(1);
|
|
102
|
+
return [3 /*break*/, 6];
|
|
103
|
+
case 6: return [2 /*return*/];
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
});
|
|
39
107
|
};
|
|
40
108
|
exports.startPreview = startPreview;
|
package/dist/source/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/index.ts"],"names":[],"mappings":""}
|
package/dist/source/index.js
CHANGED
|
@@ -4,12 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
var extra_typings_1 = require("@commander-js/extra-typings");
|
|
9
|
+
var package_json_1 = __importDefault(require("../package.json"));
|
|
10
|
+
var dev_1 = require("./commands/dev");
|
|
11
|
+
var preview_1 = require("./commands/preview");
|
|
12
|
+
var export_1 = require("./commands/export");
|
|
13
|
+
var constants_1 = require("./utils/constants");
|
|
13
14
|
extra_typings_1.program
|
|
14
15
|
.name(constants_1.PACKAGE_NAME)
|
|
15
16
|
.description('A live preview of your emails right in your browser')
|
|
@@ -19,6 +20,7 @@ extra_typings_1.program
|
|
|
19
20
|
.description('Starts the application in development mode')
|
|
20
21
|
.option('-d, --dir <path>', 'Directory with your email templates', './emails')
|
|
21
22
|
.option('-p --port <port>', 'Port to run dev server on', '3000')
|
|
23
|
+
.option('-s, --skip-install', 'Do not install dependencies', false)
|
|
22
24
|
.action(dev_1.dev);
|
|
23
25
|
extra_typings_1.program
|
|
24
26
|
.command('build')
|
|
@@ -37,5 +39,8 @@ extra_typings_1.program
|
|
|
37
39
|
.option('-p, --pretty', 'Pretty print the output', false)
|
|
38
40
|
.option('-t, --plainText', 'Set output format as plain text', false)
|
|
39
41
|
.option('-d, --dir <path>', 'Directory with your email templates', './emails')
|
|
40
|
-
.action(
|
|
42
|
+
.action(function (_a) {
|
|
43
|
+
var outDir = _a.outDir, pretty = _a.pretty, plainText = _a.plainText, srcDir = _a.dir;
|
|
44
|
+
return (0, export_1.exportTemplates)(outDir, srcDir, { pretty: pretty, plainText: plainText });
|
|
45
|
+
});
|
|
41
46
|
extra_typings_1.program.parse();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"close-ora-on-sigint.d.ts","sourceRoot":"","sources":["../../../source/utils/close-ora-on-sigint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE/B,eAAO,MAAM,gBAAgB,YAAa,GAAG,SAI5C,CAAC"}
|