react-email 5.0.5 → 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 +2 -0
- package/dist/index.js +16 -39
- package/package.json +2 -2
- 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",
|
|
@@ -135,7 +135,7 @@ var package_default = {
|
|
|
135
135
|
"@types/babel__traverse": "7.20.7",
|
|
136
136
|
"@types/mime-types": "2.1.4",
|
|
137
137
|
"@types/prompts": "2.4.9",
|
|
138
|
-
"next": "16.0.
|
|
138
|
+
"next": "16.0.7",
|
|
139
139
|
"react": "19.0.0",
|
|
140
140
|
"react-dom": "19.0.0",
|
|
141
141
|
"typescript": "5.8.3"
|
|
@@ -188,52 +188,22 @@ const registerSpinnerAutostopping = (spinner) => {
|
|
|
188
188
|
|
|
189
189
|
//#endregion
|
|
190
190
|
//#region src/commands/build.ts
|
|
191
|
-
const buildPreviewApp = (absoluteDirectory) => {
|
|
192
|
-
return new Promise((resolve, reject) => {
|
|
193
|
-
const nextBuild = spawn("npm", ["run", "build"], {
|
|
194
|
-
cwd: absoluteDirectory,
|
|
195
|
-
shell: true
|
|
196
|
-
});
|
|
197
|
-
nextBuild.stdout.pipe(process.stdout);
|
|
198
|
-
nextBuild.stderr.pipe(process.stderr);
|
|
199
|
-
nextBuild.on("close", (code) => {
|
|
200
|
-
if (code === 0) resolve();
|
|
201
|
-
else reject(/* @__PURE__ */ new Error(`Unable to build the Next app and it exited with code: ${code}`));
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
};
|
|
205
|
-
const npmInstall = async (builtPreviewAppPath, packageManager) => {
|
|
206
|
-
return new Promise((resolve, reject) => {
|
|
207
|
-
const childProc = spawn(packageManager, [
|
|
208
|
-
"install",
|
|
209
|
-
packageManager === "deno" ? "" : "--include=dev",
|
|
210
|
-
packageManager === "deno" ? "--quiet" : "--silent"
|
|
211
|
-
], {
|
|
212
|
-
cwd: builtPreviewAppPath,
|
|
213
|
-
shell: true
|
|
214
|
-
});
|
|
215
|
-
childProc.stdout.pipe(process.stdout);
|
|
216
|
-
childProc.stderr.pipe(process.stderr);
|
|
217
|
-
childProc.on("close", (code) => {
|
|
218
|
-
if (code === 0) resolve();
|
|
219
|
-
else reject(/* @__PURE__ */ new Error(`Unable to install the dependencies and it exited with code: ${code}`));
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
};
|
|
223
191
|
const setNextEnvironmentVariablesForBuild = async (emailsDirRelativePath, builtPreviewAppPath) => {
|
|
224
192
|
const nextConfigContents = `
|
|
225
193
|
import path from 'path';
|
|
226
194
|
const emailsDirRelativePath = path.normalize('${emailsDirRelativePath}');
|
|
227
195
|
const userProjectLocation = '${process.cwd().replace(/\\/g, "/")}';
|
|
196
|
+
const previewServerLocation = '${builtPreviewAppPath.replace(/\\/g, "/")}';
|
|
228
197
|
/** @type {import('next').NextConfig} */
|
|
229
198
|
const nextConfig = {
|
|
230
199
|
env: {
|
|
231
200
|
NEXT_PUBLIC_IS_BUILDING: 'true',
|
|
232
201
|
EMAILS_DIR_RELATIVE_PATH: emailsDirRelativePath,
|
|
233
202
|
EMAILS_DIR_ABSOLUTE_PATH: path.resolve(userProjectLocation, emailsDirRelativePath),
|
|
234
|
-
PREVIEW_SERVER_LOCATION:
|
|
203
|
+
PREVIEW_SERVER_LOCATION: previewServerLocation,
|
|
235
204
|
USER_PROJECT_LOCATION: userProjectLocation
|
|
236
205
|
},
|
|
206
|
+
outputFileTracingRoot: previewServerLocation,
|
|
237
207
|
serverExternalPackages: ['esbuild'],
|
|
238
208
|
typescript: {
|
|
239
209
|
ignoreBuildErrors: true
|
|
@@ -317,12 +287,19 @@ const build$1 = async ({ dir: emailsDirRelativePath, packageManager }) => {
|
|
|
317
287
|
spinner.text = "Updating package.json's build and start scripts";
|
|
318
288
|
await updatePackageJson(builtPreviewAppPath);
|
|
319
289
|
spinner.text = "Installing dependencies on `.react-email`";
|
|
320
|
-
await
|
|
290
|
+
await installDependencies({
|
|
291
|
+
cwd: builtPreviewAppPath,
|
|
292
|
+
silent: true,
|
|
293
|
+
packageManager
|
|
294
|
+
});
|
|
321
295
|
spinner.stopAndPersist({
|
|
322
296
|
text: "Successfully prepared `.react-email` for `next build`",
|
|
323
297
|
symbol: logSymbols.success
|
|
324
298
|
});
|
|
325
|
-
await
|
|
299
|
+
await runScript("build", {
|
|
300
|
+
packageManager,
|
|
301
|
+
cwd: builtPreviewAppPath
|
|
302
|
+
});
|
|
326
303
|
} catch (error) {
|
|
327
304
|
console.log(error);
|
|
328
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"
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@types/babel__traverse": "7.20.7",
|
|
50
50
|
"@types/mime-types": "2.1.4",
|
|
51
51
|
"@types/prompts": "2.4.9",
|
|
52
|
-
"next": "16.0.
|
|
52
|
+
"next": "16.0.7",
|
|
53
53
|
"react": "19.0.0",
|
|
54
54
|
"react-dom": "19.0.0",
|
|
55
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);
|