react-email 5.0.4 → 5.0.6
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/CHANGELOG.md +4 -0
- package/dist/index.js +21 -40
- package/package.json +9 -3
- package/src/commands/build.ts +14 -61
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { program } from "commander";
|
|
4
|
-
import { spawn } from "node:child_process";
|
|
5
4
|
import fs, { existsSync, promises, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
6
5
|
import path from "node:path";
|
|
7
6
|
import logSymbols from "log-symbols";
|
|
7
|
+
import { addDevDependency, installDependencies, runScript } from "nypm";
|
|
8
8
|
import ora from "ora";
|
|
9
9
|
import url from "node:url";
|
|
10
10
|
import { createJiti } from "jiti";
|
|
11
|
-
import { addDevDependency } from "nypm";
|
|
12
11
|
import prompts from "prompts";
|
|
13
12
|
import { watch } from "chokidar";
|
|
14
13
|
import debounce from "debounce";
|
|
@@ -24,6 +23,7 @@ import os from "node:os";
|
|
|
24
23
|
import { build } from "esbuild";
|
|
25
24
|
import { glob } from "glob";
|
|
26
25
|
import normalize from "normalize-path";
|
|
26
|
+
import { spawn } from "node:child_process";
|
|
27
27
|
|
|
28
28
|
//#region src/utils/get-emails-directory-metadata.ts
|
|
29
29
|
const isFileAnEmail = async (fullPath) => {
|
|
@@ -87,7 +87,7 @@ const getEmailsDirectoryMetadata = async (absolutePathToEmailsDirectory, keepFil
|
|
|
87
87
|
//#region package.json
|
|
88
88
|
var package_default = {
|
|
89
89
|
name: "react-email",
|
|
90
|
-
version: "5.0.
|
|
90
|
+
version: "5.0.6",
|
|
91
91
|
description: "A live preview of your emails right in your browser.",
|
|
92
92
|
bin: { "email": "./dist/index.js" },
|
|
93
93
|
type: "module",
|
|
@@ -105,7 +105,11 @@ var package_default = {
|
|
|
105
105
|
"directory": "packages/react-email"
|
|
106
106
|
},
|
|
107
107
|
keywords: ["react", "email"],
|
|
108
|
-
engines: { "node": ">=
|
|
108
|
+
engines: { "node": ">=20.0.0" },
|
|
109
|
+
devEngines: { "runtime": {
|
|
110
|
+
"name": "node",
|
|
111
|
+
"version": ">=22.0.0"
|
|
112
|
+
} },
|
|
109
113
|
dependencies: {
|
|
110
114
|
"@babel/parser": "^7.27.0",
|
|
111
115
|
"@babel/traverse": "^7.27.0",
|
|
@@ -131,7 +135,7 @@ var package_default = {
|
|
|
131
135
|
"@types/babel__traverse": "7.20.7",
|
|
132
136
|
"@types/mime-types": "2.1.4",
|
|
133
137
|
"@types/prompts": "2.4.9",
|
|
134
|
-
"next": "16.0.
|
|
138
|
+
"next": "16.0.7",
|
|
135
139
|
"react": "19.0.0",
|
|
136
140
|
"react-dom": "19.0.0",
|
|
137
141
|
"typescript": "5.8.3"
|
|
@@ -184,52 +188,22 @@ const registerSpinnerAutostopping = (spinner) => {
|
|
|
184
188
|
|
|
185
189
|
//#endregion
|
|
186
190
|
//#region src/commands/build.ts
|
|
187
|
-
const buildPreviewApp = (absoluteDirectory) => {
|
|
188
|
-
return new Promise((resolve, reject) => {
|
|
189
|
-
const nextBuild = spawn("npm", ["run", "build"], {
|
|
190
|
-
cwd: absoluteDirectory,
|
|
191
|
-
shell: true
|
|
192
|
-
});
|
|
193
|
-
nextBuild.stdout.pipe(process.stdout);
|
|
194
|
-
nextBuild.stderr.pipe(process.stderr);
|
|
195
|
-
nextBuild.on("close", (code) => {
|
|
196
|
-
if (code === 0) resolve();
|
|
197
|
-
else reject(/* @__PURE__ */ new Error(`Unable to build the Next app and it exited with code: ${code}`));
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
};
|
|
201
|
-
const npmInstall = async (builtPreviewAppPath, packageManager) => {
|
|
202
|
-
return new Promise((resolve, reject) => {
|
|
203
|
-
const childProc = spawn(packageManager, [
|
|
204
|
-
"install",
|
|
205
|
-
packageManager === "deno" ? "" : "--include=dev",
|
|
206
|
-
packageManager === "deno" ? "--quiet" : "--silent"
|
|
207
|
-
], {
|
|
208
|
-
cwd: builtPreviewAppPath,
|
|
209
|
-
shell: true
|
|
210
|
-
});
|
|
211
|
-
childProc.stdout.pipe(process.stdout);
|
|
212
|
-
childProc.stderr.pipe(process.stderr);
|
|
213
|
-
childProc.on("close", (code) => {
|
|
214
|
-
if (code === 0) resolve();
|
|
215
|
-
else reject(/* @__PURE__ */ new Error(`Unable to install the dependencies and it exited with code: ${code}`));
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
};
|
|
219
191
|
const setNextEnvironmentVariablesForBuild = async (emailsDirRelativePath, builtPreviewAppPath) => {
|
|
220
192
|
const nextConfigContents = `
|
|
221
193
|
import path from 'path';
|
|
222
194
|
const emailsDirRelativePath = path.normalize('${emailsDirRelativePath}');
|
|
223
195
|
const userProjectLocation = '${process.cwd().replace(/\\/g, "/")}';
|
|
196
|
+
const previewServerLocation = '${builtPreviewAppPath.replace(/\\/g, "/")}';
|
|
224
197
|
/** @type {import('next').NextConfig} */
|
|
225
198
|
const nextConfig = {
|
|
226
199
|
env: {
|
|
227
200
|
NEXT_PUBLIC_IS_BUILDING: 'true',
|
|
228
201
|
EMAILS_DIR_RELATIVE_PATH: emailsDirRelativePath,
|
|
229
202
|
EMAILS_DIR_ABSOLUTE_PATH: path.resolve(userProjectLocation, emailsDirRelativePath),
|
|
230
|
-
PREVIEW_SERVER_LOCATION:
|
|
203
|
+
PREVIEW_SERVER_LOCATION: previewServerLocation,
|
|
231
204
|
USER_PROJECT_LOCATION: userProjectLocation
|
|
232
205
|
},
|
|
206
|
+
outputFileTracingRoot: previewServerLocation,
|
|
233
207
|
serverExternalPackages: ['esbuild'],
|
|
234
208
|
typescript: {
|
|
235
209
|
ignoreBuildErrors: true
|
|
@@ -313,12 +287,19 @@ const build$1 = async ({ dir: emailsDirRelativePath, packageManager }) => {
|
|
|
313
287
|
spinner.text = "Updating package.json's build and start scripts";
|
|
314
288
|
await updatePackageJson(builtPreviewAppPath);
|
|
315
289
|
spinner.text = "Installing dependencies on `.react-email`";
|
|
316
|
-
await
|
|
290
|
+
await installDependencies({
|
|
291
|
+
cwd: builtPreviewAppPath,
|
|
292
|
+
silent: true,
|
|
293
|
+
packageManager
|
|
294
|
+
});
|
|
317
295
|
spinner.stopAndPersist({
|
|
318
296
|
text: "Successfully prepared `.react-email` for `next build`",
|
|
319
297
|
symbol: logSymbols.success
|
|
320
298
|
});
|
|
321
|
-
await
|
|
299
|
+
await runScript("build", {
|
|
300
|
+
packageManager,
|
|
301
|
+
cwd: builtPreviewAppPath
|
|
302
|
+
});
|
|
322
303
|
} catch (error) {
|
|
323
304
|
console.log(error);
|
|
324
305
|
process.exit(1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-email",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.6",
|
|
4
4
|
"description": "A live preview of your emails right in your browser.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"email": "./dist/index.js"
|
|
@@ -17,7 +17,13 @@
|
|
|
17
17
|
"email"
|
|
18
18
|
],
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
20
|
+
"node": ">=20.0.0"
|
|
21
|
+
},
|
|
22
|
+
"devEngines": {
|
|
23
|
+
"runtime": {
|
|
24
|
+
"name": "node",
|
|
25
|
+
"version": ">=22.0.0"
|
|
26
|
+
}
|
|
21
27
|
},
|
|
22
28
|
"dependencies": {
|
|
23
29
|
"@babel/parser": "^7.27.0",
|
|
@@ -43,7 +49,7 @@
|
|
|
43
49
|
"@types/babel__traverse": "7.20.7",
|
|
44
50
|
"@types/mime-types": "2.1.4",
|
|
45
51
|
"@types/prompts": "2.4.9",
|
|
46
|
-
"next": "16.0.
|
|
52
|
+
"next": "16.0.7",
|
|
47
53
|
"react": "19.0.0",
|
|
48
54
|
"react-dom": "19.0.0",
|
|
49
55
|
"typescript": "5.8.3",
|
package/src/commands/build.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
1
|
import fs from 'node:fs';
|
|
3
2
|
import path from 'node:path';
|
|
4
3
|
import logSymbols from 'log-symbols';
|
|
4
|
+
import { installDependencies, type PackageManagerName, runScript } from 'nypm';
|
|
5
5
|
import ora from 'ora';
|
|
6
6
|
import {
|
|
7
7
|
type EmailsDirectory,
|
|
@@ -12,65 +12,9 @@ import { registerSpinnerAutostopping } from '../utils/register-spinner-autostopp
|
|
|
12
12
|
|
|
13
13
|
interface Args {
|
|
14
14
|
dir: string;
|
|
15
|
-
packageManager:
|
|
15
|
+
packageManager: PackageManagerName;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const buildPreviewApp = (absoluteDirectory: string) => {
|
|
19
|
-
return new Promise<void>((resolve, reject) => {
|
|
20
|
-
const nextBuild = spawn('npm', ['run', 'build'], {
|
|
21
|
-
cwd: absoluteDirectory,
|
|
22
|
-
shell: true,
|
|
23
|
-
});
|
|
24
|
-
nextBuild.stdout.pipe(process.stdout);
|
|
25
|
-
nextBuild.stderr.pipe(process.stderr);
|
|
26
|
-
|
|
27
|
-
nextBuild.on('close', (code) => {
|
|
28
|
-
if (code === 0) {
|
|
29
|
-
resolve();
|
|
30
|
-
} else {
|
|
31
|
-
reject(
|
|
32
|
-
new Error(
|
|
33
|
-
`Unable to build the Next app and it exited with code: ${code}`,
|
|
34
|
-
),
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const npmInstall = async (
|
|
42
|
-
builtPreviewAppPath: string,
|
|
43
|
-
packageManager: string,
|
|
44
|
-
) => {
|
|
45
|
-
return new Promise<void>((resolve, reject) => {
|
|
46
|
-
const childProc = spawn(
|
|
47
|
-
packageManager,
|
|
48
|
-
[
|
|
49
|
-
'install',
|
|
50
|
-
packageManager === 'deno' ? '' : '--include=dev',
|
|
51
|
-
packageManager === 'deno' ? '--quiet' : '--silent',
|
|
52
|
-
],
|
|
53
|
-
{
|
|
54
|
-
cwd: builtPreviewAppPath,
|
|
55
|
-
shell: true,
|
|
56
|
-
},
|
|
57
|
-
);
|
|
58
|
-
childProc.stdout.pipe(process.stdout);
|
|
59
|
-
childProc.stderr.pipe(process.stderr);
|
|
60
|
-
childProc.on('close', (code) => {
|
|
61
|
-
if (code === 0) {
|
|
62
|
-
resolve();
|
|
63
|
-
} else {
|
|
64
|
-
reject(
|
|
65
|
-
new Error(
|
|
66
|
-
`Unable to install the dependencies and it exited with code: ${code}`,
|
|
67
|
-
),
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
|
|
74
18
|
const setNextEnvironmentVariablesForBuild = async (
|
|
75
19
|
emailsDirRelativePath: string,
|
|
76
20
|
builtPreviewAppPath: string,
|
|
@@ -79,15 +23,17 @@ const setNextEnvironmentVariablesForBuild = async (
|
|
|
79
23
|
import path from 'path';
|
|
80
24
|
const emailsDirRelativePath = path.normalize('${emailsDirRelativePath}');
|
|
81
25
|
const userProjectLocation = '${process.cwd().replace(/\\/g, '/')}';
|
|
26
|
+
const previewServerLocation = '${builtPreviewAppPath.replace(/\\/g, '/')}';
|
|
82
27
|
/** @type {import('next').NextConfig} */
|
|
83
28
|
const nextConfig = {
|
|
84
29
|
env: {
|
|
85
30
|
NEXT_PUBLIC_IS_BUILDING: 'true',
|
|
86
31
|
EMAILS_DIR_RELATIVE_PATH: emailsDirRelativePath,
|
|
87
32
|
EMAILS_DIR_ABSOLUTE_PATH: path.resolve(userProjectLocation, emailsDirRelativePath),
|
|
88
|
-
PREVIEW_SERVER_LOCATION:
|
|
33
|
+
PREVIEW_SERVER_LOCATION: previewServerLocation,
|
|
89
34
|
USER_PROJECT_LOCATION: userProjectLocation
|
|
90
35
|
},
|
|
36
|
+
outputFileTracingRoot: previewServerLocation,
|
|
91
37
|
serverExternalPackages: ['esbuild'],
|
|
92
38
|
typescript: {
|
|
93
39
|
ignoreBuildErrors: true
|
|
@@ -281,14 +227,21 @@ export const build = async ({
|
|
|
281
227
|
await updatePackageJson(builtPreviewAppPath);
|
|
282
228
|
|
|
283
229
|
spinner.text = 'Installing dependencies on `.react-email`';
|
|
284
|
-
await
|
|
230
|
+
await installDependencies({
|
|
231
|
+
cwd: builtPreviewAppPath,
|
|
232
|
+
silent: true,
|
|
233
|
+
packageManager,
|
|
234
|
+
});
|
|
285
235
|
|
|
286
236
|
spinner.stopAndPersist({
|
|
287
237
|
text: 'Successfully prepared `.react-email` for `next build`',
|
|
288
238
|
symbol: logSymbols.success,
|
|
289
239
|
});
|
|
290
240
|
|
|
291
|
-
await
|
|
241
|
+
await runScript('build', {
|
|
242
|
+
packageManager,
|
|
243
|
+
cwd: builtPreviewAppPath,
|
|
244
|
+
});
|
|
292
245
|
} catch (error) {
|
|
293
246
|
console.log(error);
|
|
294
247
|
process.exit(1);
|