react-email 2.1.7-canary.2 → 2.2.0-alpha-2f5a07ff-20240814
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/build-preview-server.mjs +24 -0
- package/{cli → dist/cli}/index.js +187 -118
- package/{cli → dist/cli}/index.mjs +122 -102
- package/dist/preview/.next/BUILD_ID +1 -0
- package/dist/preview/.next/app-build-manifest.json +43 -0
- package/dist/preview/.next/app-path-routes-manifest.json +1 -0
- package/dist/preview/.next/build-manifest.json +32 -0
- package/dist/preview/.next/cache/eslint/.cache_nc86h9 +1 -0
- package/dist/preview/.next/cache/webpack/client-production/0.pack +0 -0
- package/dist/preview/.next/cache/webpack/client-production/index.pack +0 -0
- package/dist/preview/.next/cache/webpack/edge-server-production/0.pack +0 -0
- package/dist/preview/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/dist/preview/.next/cache/webpack/server-production/0.pack +0 -0
- package/dist/preview/.next/cache/webpack/server-production/index.pack +0 -0
- package/dist/preview/.next/export-marker.json +1 -0
- package/dist/preview/.next/images-manifest.json +1 -0
- package/dist/preview/.next/next-minimal-server.js.nft.json +1 -0
- package/dist/preview/.next/next-server.js.nft.json +1 -0
- package/dist/preview/.next/package.json +1 -0
- package/dist/preview/.next/prerender-manifest.js +1 -0
- package/dist/preview/.next/prerender-manifest.json +1 -0
- package/dist/preview/.next/react-loadable-manifest.json +1 -0
- package/dist/preview/.next/required-server-files.json +1 -0
- package/dist/preview/.next/routes-manifest.json +1 -0
- package/dist/preview/.next/server/app/_not-found/page.js +1 -0
- package/dist/preview/.next/server/app/_not-found/page.js.nft.json +1 -0
- package/dist/preview/.next/server/app/_not-found/page_client-reference-manifest.js +1 -0
- package/dist/preview/.next/server/app/favicon.ico/route.js +12 -0
- package/dist/preview/.next/server/app/favicon.ico/route.js.nft.json +1 -0
- package/dist/preview/.next/server/app/favicon.ico.body +0 -0
- package/dist/preview/.next/server/app/favicon.ico.meta +1 -0
- package/dist/preview/.next/server/app/page.js +1 -0
- package/dist/preview/.next/server/app/page.js.nft.json +1 -0
- package/dist/preview/.next/server/app/page_client-reference-manifest.js +1 -0
- package/dist/preview/.next/server/app/preview/[...slug]/page.js +11 -0
- package/dist/preview/.next/server/app/preview/[...slug]/page.js.nft.json +1 -0
- package/dist/preview/.next/server/app/preview/[...slug]/page_client-reference-manifest.js +1 -0
- package/dist/preview/.next/server/app-paths-manifest.json +6 -0
- package/dist/preview/.next/server/chunks/260.js +6 -0
- package/dist/preview/.next/server/chunks/593.js +26 -0
- package/dist/preview/.next/server/chunks/636.js +1 -0
- package/dist/preview/.next/server/chunks/715.js +7 -0
- package/dist/preview/.next/server/chunks/826.js +4 -0
- package/dist/preview/.next/server/chunks/835.js +15 -0
- package/dist/preview/.next/server/chunks/962.js +2 -0
- package/dist/preview/.next/server/chunks/font-manifest.json +1 -0
- package/dist/preview/.next/server/font-manifest.json +1 -0
- package/dist/preview/.next/server/functions-config-manifest.json +1 -0
- package/dist/preview/.next/server/interception-route-rewrite-manifest.js +1 -0
- package/dist/preview/.next/server/middleware-build-manifest.js +1 -0
- package/dist/preview/.next/server/middleware-manifest.json +6 -0
- package/dist/preview/.next/server/middleware-react-loadable-manifest.js +1 -0
- package/dist/preview/.next/server/next-font-manifest.js +1 -0
- package/dist/preview/.next/server/next-font-manifest.json +1 -0
- package/dist/preview/.next/server/pages/500.html +1 -0
- package/dist/preview/.next/server/pages/_app.js +1 -0
- package/dist/preview/.next/server/pages/_app.js.nft.json +1 -0
- package/dist/preview/.next/server/pages/_document.js +1 -0
- package/dist/preview/.next/server/pages/_document.js.nft.json +1 -0
- package/dist/preview/.next/server/pages/_error.js +1 -0
- package/dist/preview/.next/server/pages/_error.js.nft.json +1 -0
- package/dist/preview/.next/server/pages-manifest.json +1 -0
- package/dist/preview/.next/server/server-reference-manifest.js +1 -0
- package/dist/preview/.next/server/server-reference-manifest.json +1 -0
- package/dist/preview/.next/server/webpack-runtime.js +1 -0
- package/dist/preview/.next/trace +52 -0
- package/dist/preview/.next/types/app/layout.ts +79 -0
- package/dist/preview/.next/types/app/preview/[...slug]/page.ts +79 -0
- package/dist/preview/.next/types/package.json +1 -0
- package/next.config.js +1 -1
- package/package.json +30 -30
- package/src/actions/get-emails-directory-metadata.spec.ts +8 -0
- package/src/actions/get-emails-directory-metadata.ts +21 -11
- package/src/actions/render-email-by-path.tsx +40 -0
- package/src/app/layout.tsx +2 -0
- package/src/app/preview/[...slug]/page.tsx +4 -1
- package/src/app/preview/[...slug]/preview.tsx +3 -0
- package/src/components/shell.tsx +4 -1
- package/src/components/sidebar/sidebar-directory-children.tsx +5 -12
- package/src/components/sidebar/sidebar-directory.tsx +5 -18
- package/src/components/topbar.tsx +2 -1
- package/src/contexts/emails.tsx +5 -16
- package/src/hooks/use-hot-reload.ts +0 -4
- package/src/utils/close-ora-on-sigint.ts +15 -0
- package/src/utils/emails-directory-absolute-path.ts +7 -31
- package/tsconfig.json +1 -1
- /package/{cli → dist/cli}/index.d.mts +0 -0
- /package/{cli → dist/cli}/index.d.ts +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { existsSync, promises as fs } from 'node:fs';
|
|
3
|
+
|
|
4
|
+
const nextBuildProcess = spawn('next', ['build'], {
|
|
5
|
+
detached: true,
|
|
6
|
+
stdio: "inherit"
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
process.on('SIGINT', () => {
|
|
10
|
+
nextBuildProcess.kill('SIGINT');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
nextBuildProcess.on('exit', async (code) => {
|
|
14
|
+
if (code !== 0) {
|
|
15
|
+
process.exit(code);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (existsSync('dist/preview')) {
|
|
19
|
+
await fs.rm('dist/preview', { recursive: true });
|
|
20
|
+
}
|
|
21
|
+
await fs.mkdir('dist/preview', { recursive: true });
|
|
22
|
+
await fs.rename('.next', 'dist/preview/.next');
|
|
23
|
+
});
|
|
24
|
+
|
|
@@ -340,14 +340,14 @@ var import_commander = require("commander");
|
|
|
340
340
|
// package.json
|
|
341
341
|
var package_default = {
|
|
342
342
|
name: "react-email",
|
|
343
|
-
version: "2.
|
|
343
|
+
version: "2.2.0-alpha-2f5a07ff-20240814",
|
|
344
344
|
description: "A live preview of your emails right in your browser.",
|
|
345
345
|
bin: {
|
|
346
|
-
email: "./cli/index.js"
|
|
346
|
+
email: "./dist/cli/index.js"
|
|
347
347
|
},
|
|
348
348
|
scripts: {
|
|
349
|
-
build: "tsup",
|
|
350
|
-
dev: "tsup --watch",
|
|
349
|
+
build: "tsup-node && node build-preview-server.mjs",
|
|
350
|
+
dev: "tsup-node --watch",
|
|
351
351
|
test: "vitest run",
|
|
352
352
|
"test:watch": "vitest",
|
|
353
353
|
clean: "rm -rf dist",
|
|
@@ -369,57 +369,57 @@ var package_default = {
|
|
|
369
369
|
dependencies: {
|
|
370
370
|
"@babel/core": "7.24.5",
|
|
371
371
|
"@babel/parser": "7.24.5",
|
|
372
|
+
chalk: "4.1.2",
|
|
373
|
+
chokidar: "3.6.0",
|
|
374
|
+
commander: "11.1.0",
|
|
375
|
+
debounce: "2.0.0",
|
|
376
|
+
esbuild: "0.19.11",
|
|
377
|
+
glob: "10.3.4",
|
|
378
|
+
"log-symbols": "4.1.0",
|
|
379
|
+
"mime-types": "2.1.35",
|
|
380
|
+
"normalize-path": "3.0.0",
|
|
381
|
+
ora: "5.4.1",
|
|
382
|
+
"socket.io": "4.7.5"
|
|
383
|
+
},
|
|
384
|
+
devDependencies: {
|
|
372
385
|
"@radix-ui/colors": "1.0.1",
|
|
373
386
|
"@radix-ui/react-collapsible": "1.1.0",
|
|
374
387
|
"@radix-ui/react-popover": "1.1.1",
|
|
375
388
|
"@radix-ui/react-slot": "1.1.0",
|
|
376
389
|
"@radix-ui/react-toggle-group": "1.1.0",
|
|
377
390
|
"@radix-ui/react-tooltip": "1.1.1",
|
|
378
|
-
"@
|
|
391
|
+
"@react-email/render": "0.0.18-canary.0",
|
|
392
|
+
"@swc/core": "1.4.15",
|
|
393
|
+
"@types/babel__core": "7.20.5",
|
|
394
|
+
"@types/fs-extra": "11.0.1",
|
|
395
|
+
"@types/mime-types": "2.1.4",
|
|
396
|
+
"@types/node": "18.0.0",
|
|
397
|
+
"@types/normalize-path": "3.0.2",
|
|
379
398
|
"@types/react": "^18.2.0",
|
|
380
399
|
"@types/react-dom": "^18.2.0",
|
|
381
400
|
"@types/webpack": "5.28.5",
|
|
401
|
+
"@vercel/style-guide": "5.1.0",
|
|
382
402
|
autoprefixer: "10.4.14",
|
|
383
|
-
chalk: "4.1.2",
|
|
384
|
-
chokidar: "3.5.3",
|
|
385
403
|
clsx: "2.1.0",
|
|
386
|
-
|
|
387
|
-
debounce: "2.0.0",
|
|
388
|
-
esbuild: "0.19.11",
|
|
404
|
+
eslint: "8.50.0",
|
|
389
405
|
"eslint-config-prettier": "9.0.0",
|
|
390
406
|
"eslint-config-turbo": "1.10.12",
|
|
391
407
|
"framer-motion": "12.0.0-alpha.0",
|
|
392
|
-
glob: "10.3.4",
|
|
393
|
-
"log-symbols": "4.1.0",
|
|
394
|
-
"mime-types": "2.1.35",
|
|
395
408
|
next: "14.2.3",
|
|
396
|
-
|
|
397
|
-
ora: "5.4.1",
|
|
398
|
-
postcss: "8.4.39",
|
|
409
|
+
postcss: "8.4.40",
|
|
399
410
|
"prism-react-renderer": "2.1.0",
|
|
400
411
|
react: "18.3.1",
|
|
401
412
|
"react-dom": "18.3.1",
|
|
402
|
-
|
|
413
|
+
sharp: "0.33.3",
|
|
403
414
|
"socket.io-client": "4.7.5",
|
|
404
415
|
sonner: "1.3.1",
|
|
405
416
|
"source-map-js": "1.0.2",
|
|
406
417
|
"stacktrace-parser": "0.1.10",
|
|
407
418
|
"tailwind-merge": "2.2.0",
|
|
408
419
|
tailwindcss: "3.4.0",
|
|
409
|
-
typescript: "5.1.6"
|
|
410
|
-
},
|
|
411
|
-
devDependencies: {
|
|
412
|
-
"@react-email/components": "workspace:*",
|
|
413
|
-
"@react-email/render": "workspace:*",
|
|
414
|
-
"@types/babel__core": "7.20.5",
|
|
415
|
-
"@types/fs-extra": "11.0.1",
|
|
416
|
-
"@types/mime-types": "2.1.4",
|
|
417
|
-
"@types/node": "18.0.0",
|
|
418
|
-
"@types/normalize-path": "3.0.2",
|
|
419
|
-
"@vercel/style-guide": "5.1.0",
|
|
420
|
-
eslint: "8.50.0",
|
|
421
420
|
tsup: "7.2.0",
|
|
422
421
|
tsx: "4.9.0",
|
|
422
|
+
typescript: "5.1.6",
|
|
423
423
|
vitest: "1.1.3"
|
|
424
424
|
}
|
|
425
425
|
};
|
|
@@ -628,11 +628,17 @@ var import_next = __toESM(require("next"));
|
|
|
628
628
|
var import_ora = __toESM(require("ora"));
|
|
629
629
|
var import_log_symbols = __toESM(require("log-symbols"));
|
|
630
630
|
var import_chalk = __toESM(require("chalk"));
|
|
631
|
-
// src/
|
|
632
|
-
var
|
|
633
|
-
|
|
634
|
-
|
|
631
|
+
// src/utils/close-ora-on-sigint.ts
|
|
632
|
+
var spinners = /* @__PURE__ */ new Set();
|
|
633
|
+
process.on("SIGINT", function() {
|
|
634
|
+
spinners.forEach(function(spinner) {
|
|
635
|
+
if (spinner.isSpinning) {
|
|
636
|
+
spinner.stop();
|
|
637
|
+
}
|
|
635
638
|
});
|
|
639
|
+
});
|
|
640
|
+
var closeOraOnSIGNIT = function(spinner) {
|
|
641
|
+
spinners.add(spinner);
|
|
636
642
|
};
|
|
637
643
|
// src/cli/utils/preview/serve-static-file.ts
|
|
638
644
|
var import_node_path2 = __toESM(require("path"));
|
|
@@ -701,12 +707,11 @@ var serveStaticFile = function() {
|
|
|
701
707
|
}();
|
|
702
708
|
// src/cli/utils/preview/get-env-variables-for-preview-app.ts
|
|
703
709
|
var import_path = __toESM(require("path"));
|
|
704
|
-
var getEnvVariablesForPreviewApp = function(relativePathToEmailsDirectory,
|
|
710
|
+
var getEnvVariablesForPreviewApp = function(relativePathToEmailsDirectory, cwd) {
|
|
705
711
|
return {
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
NEXT_PUBLIC_USER_PROJECT_LOCATION: cwd
|
|
712
|
+
EMAILS_DIR_RELATIVE_PATH: relativePathToEmailsDirectory,
|
|
713
|
+
EMAILS_DIR_ABSOLUTE_PATH: import_path.default.resolve(cwd, relativePathToEmailsDirectory),
|
|
714
|
+
USER_PROJECT_LOCATION: cwd
|
|
710
715
|
};
|
|
711
716
|
};
|
|
712
717
|
// src/cli/utils/preview/start-dev-server.ts
|
|
@@ -727,8 +732,9 @@ var safeAsyncServerListen = function(server, port) {
|
|
|
727
732
|
});
|
|
728
733
|
});
|
|
729
734
|
};
|
|
730
|
-
var
|
|
731
|
-
var cliPacakgeLocation =
|
|
735
|
+
var isDev = !__filename.endsWith(import_node_path3.default.join("cli", "index.js"));
|
|
736
|
+
var cliPacakgeLocation = isDev ? import_node_path3.default.resolve(__dirname, "../../../..") : import_node_path3.default.resolve(__dirname, "../..");
|
|
737
|
+
var previewServerLocation = isDev ? import_node_path3.default.resolve(__dirname, "../../../..") : import_node_path3.default.resolve(__dirname, "../preview");
|
|
732
738
|
var startDevServer = function() {
|
|
733
739
|
var _ref = _async_to_generator(function(emailsDirRelativePath, staticBaseDirRelativePath, port) {
|
|
734
740
|
var portAlreadyInUse, nextPortToTry, spinner, timeBeforeNextReady, app, isNextReady, nextReadyPromise, nextHandleRequest, secondsToNextReady;
|
|
@@ -804,13 +810,13 @@ var startDevServer = function() {
|
|
|
804
810
|
closeOraOnSIGNIT(spinner);
|
|
805
811
|
timeBeforeNextReady = performance.now();
|
|
806
812
|
process.env = _object_spread({}, process.env, getEnvVariablesForPreviewApp(// If we don't do normalization here, stuff like https://github.com/resend/react-email/issues/1354 happens.
|
|
807
|
-
import_node_path3.default.normalize(emailsDirRelativePath),
|
|
813
|
+
import_node_path3.default.normalize(emailsDirRelativePath), process.cwd()));
|
|
808
814
|
app = (0, import_next.default)({
|
|
809
815
|
// passing in env here does not get the environment variables there
|
|
810
|
-
dev:
|
|
816
|
+
dev: isDev,
|
|
811
817
|
hostname: "localhost",
|
|
812
818
|
port: port,
|
|
813
|
-
dir:
|
|
819
|
+
dir: previewServerLocation
|
|
814
820
|
});
|
|
815
821
|
isNextReady = false;
|
|
816
822
|
nextReadyPromise = app.prepare();
|
|
@@ -1074,7 +1080,7 @@ var createDependencyGraph = function() {
|
|
|
1074
1080
|
var pathWithExtension = checkFileExtensionsUntilItExists("".concat(pathToSubDirectory, "/index"));
|
|
1075
1081
|
if (pathWithExtension) {
|
|
1076
1082
|
pathToDependencyFromDirectory = pathWithExtension;
|
|
1077
|
-
} else if (
|
|
1083
|
+
} else if (isDev) {
|
|
1078
1084
|
console.warn("Could not find index file for directory at ".concat(pathToDependencyFromDirectory, ". This is probably going to cause issues with both hot reloading and your code."));
|
|
1079
1085
|
}
|
|
1080
1086
|
}
|
|
@@ -1082,7 +1088,7 @@ var createDependencyGraph = function() {
|
|
|
1082
1088
|
var pathWithExtension1 = checkFileExtensionsUntilItExists(pathToDependencyFromDirectory);
|
|
1083
1089
|
if (pathWithExtension1) {
|
|
1084
1090
|
pathToDependencyFromDirectory = pathWithExtension1;
|
|
1085
|
-
} else if (
|
|
1091
|
+
} else if (isDev) {
|
|
1086
1092
|
console.warn("Could not determine the file extension for the file at ".concat(pathWithExtension1));
|
|
1087
1093
|
}
|
|
1088
1094
|
}
|
|
@@ -1643,11 +1649,9 @@ var setupHotreloading = function() {
|
|
|
1643
1649
|
_state.sent(),
|
|
1644
1650
|
3
|
|
1645
1651
|
]), dependencyGraph = _ref[0], updateDependencyGraph = _ref[1], resolveDependentsOf = _ref[2].resolveDependentsOf;
|
|
1646
|
-
watcher = (0, import_chokidar.watch)(
|
|
1652
|
+
watcher = (0, import_chokidar.watch)("", {
|
|
1647
1653
|
ignoreInitial: true,
|
|
1648
|
-
cwd:
|
|
1649
|
-
// eslint-disable-next-line prefer-named-capture-group
|
|
1650
|
-
ignored: /(^|[/\\])\../
|
|
1654
|
+
cwd: absolutePathToEmailsDirectory
|
|
1651
1655
|
});
|
|
1652
1656
|
getFilesOutsideEmailsDirectory = function() {
|
|
1653
1657
|
return Object.keys(dependencyGraph).filter(function(p) {
|
|
@@ -1897,23 +1901,20 @@ var mergeDirectoriesWithSubDirectories = function(emailsDirectoryMetadata) {
|
|
|
1897
1901
|
var currentResultingMergedDirectory = emailsDirectoryMetadata;
|
|
1898
1902
|
while(currentResultingMergedDirectory.emailFilenames.length === 0 && currentResultingMergedDirectory.subDirectories.length === 1){
|
|
1899
1903
|
var onlySubDirectory = currentResultingMergedDirectory.subDirectories[0];
|
|
1900
|
-
currentResultingMergedDirectory = {
|
|
1901
|
-
subDirectories: onlySubDirectory.subDirectories,
|
|
1902
|
-
emailFilenames: onlySubDirectory.emailFilenames,
|
|
1903
|
-
absolutePath: onlySubDirectory.absolutePath,
|
|
1904
|
+
currentResultingMergedDirectory = _object_spread_props(_object_spread({}, onlySubDirectory), {
|
|
1904
1905
|
directoryName: import_node_path6.default.join(currentResultingMergedDirectory.directoryName, onlySubDirectory.directoryName)
|
|
1905
|
-
};
|
|
1906
|
+
});
|
|
1906
1907
|
}
|
|
1907
1908
|
return currentResultingMergedDirectory;
|
|
1908
1909
|
};
|
|
1909
1910
|
var getEmailsDirectoryMetadata = function() {
|
|
1910
1911
|
var _ref = _async_to_generator(function(absolutePathToEmailsDirectory) {
|
|
1911
|
-
var keepFileExtensions, isSubDirectory, dirents, emailFilenames, subDirectories, emailsMetadata;
|
|
1912
|
+
var keepFileExtensions, isSubDirectory, baseDirectoryPath, dirents, emailFilenames, subDirectories, emailsMetadata;
|
|
1912
1913
|
var _arguments = arguments;
|
|
1913
1914
|
return _ts_generator(this, function(_state) {
|
|
1914
1915
|
switch(_state.label){
|
|
1915
1916
|
case 0:
|
|
1916
|
-
keepFileExtensions = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : false, isSubDirectory = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : false;
|
|
1917
|
+
keepFileExtensions = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : false, isSubDirectory = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : false, baseDirectoryPath = _arguments.length > 3 && _arguments[3] !== void 0 ? _arguments[3] : absolutePathToEmailsDirectory;
|
|
1917
1918
|
if (!import_node_fs5.default.existsSync(absolutePathToEmailsDirectory)) return [
|
|
1918
1919
|
2
|
|
1919
1920
|
];
|
|
@@ -1935,13 +1936,15 @@ var getEmailsDirectoryMetadata = function() {
|
|
|
1935
1936
|
Promise.all(dirents.filter(function(dirent) {
|
|
1936
1937
|
return dirent.isDirectory() && !dirent.name.startsWith("_") && dirent.name !== "static";
|
|
1937
1938
|
}).map(function(dirent) {
|
|
1938
|
-
|
|
1939
|
+
var direntAbsolutePath = import_node_path6.default.join(absolutePathToEmailsDirectory, dirent.name);
|
|
1940
|
+
return getEmailsDirectoryMetadata(direntAbsolutePath, keepFileExtensions, true, baseDirectoryPath);
|
|
1939
1941
|
}))
|
|
1940
1942
|
];
|
|
1941
1943
|
case 2:
|
|
1942
1944
|
subDirectories = _state.sent();
|
|
1943
1945
|
emailsMetadata = {
|
|
1944
1946
|
absolutePath: absolutePathToEmailsDirectory,
|
|
1947
|
+
relativePath: import_node_path6.default.relative(baseDirectoryPath, absolutePathToEmailsDirectory),
|
|
1945
1948
|
directoryName: absolutePathToEmailsDirectory.split(import_node_path6.default.sep).pop(),
|
|
1946
1949
|
emailFilenames: emailFilenames,
|
|
1947
1950
|
subDirectories: subDirectories
|
|
@@ -2064,7 +2067,7 @@ var getEmailTemplatesFromDirectory = function(emailDirectory) {
|
|
|
2064
2067
|
};
|
|
2065
2068
|
var exportTemplates = function() {
|
|
2066
2069
|
var _ref = _async_to_generator(function(pathToWhereEmailMarkupShouldBeDumped, emailsDirectoryPath, options) {
|
|
2067
|
-
var spinner, emailsDirectoryMetadata, allTemplates, exception, buildFailure, allBuiltTemplates,
|
|
2070
|
+
var spinner, emailsDirectoryMetadata, allTemplates, exception, buildFailure, allBuiltTemplates, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, template, emailModule, rendered, htmlPath, exception1, err, staticDirectoryPath, pathToDumpStaticFilesInto, exception2, fileTree;
|
|
2068
2071
|
return _ts_generator(this, function(_state) {
|
|
2069
2072
|
switch(_state.label){
|
|
2070
2073
|
case 0:
|
|
@@ -2151,30 +2154,36 @@ var exportTemplates = function() {
|
|
|
2151
2154
|
allBuiltTemplates = import_glob.glob.sync((0, import_normalize_path.default)("".concat(pathToWhereEmailMarkupShouldBeDumped, "/**/*.cjs")), {
|
|
2152
2155
|
absolute: true
|
|
2153
2156
|
});
|
|
2154
|
-
|
|
2157
|
+
_iteratorAbruptCompletion = false, _didIteratorError = false;
|
|
2155
2158
|
_state.label = 6;
|
|
2156
2159
|
case 6:
|
|
2157
2160
|
_state.trys.push([
|
|
2158
2161
|
6,
|
|
2159
|
-
13,
|
|
2160
2162
|
14,
|
|
2161
|
-
15
|
|
2163
|
+
15,
|
|
2164
|
+
20
|
|
2162
2165
|
]);
|
|
2163
|
-
_iterator = allBuiltTemplates
|
|
2166
|
+
_iterator = _async_iterator(allBuiltTemplates);
|
|
2164
2167
|
_state.label = 7;
|
|
2165
2168
|
case 7:
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
+
return [
|
|
2170
|
+
4,
|
|
2171
|
+
_iterator.next()
|
|
2169
2172
|
];
|
|
2170
|
-
template = _step.value;
|
|
2171
|
-
_state.label = 8;
|
|
2172
2173
|
case 8:
|
|
2174
|
+
if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [
|
|
2175
|
+
3,
|
|
2176
|
+
13
|
|
2177
|
+
];
|
|
2178
|
+
_value = _step.value;
|
|
2179
|
+
template = _value;
|
|
2180
|
+
_state.label = 9;
|
|
2181
|
+
case 9:
|
|
2173
2182
|
_state.trys.push([
|
|
2174
|
-
|
|
2175
|
-
|
|
2183
|
+
9,
|
|
2184
|
+
11,
|
|
2176
2185
|
,
|
|
2177
|
-
|
|
2186
|
+
12
|
|
2178
2187
|
]);
|
|
2179
2188
|
if (spinner) {
|
|
2180
2189
|
spinner.text = "rendering ".concat(template.split("/").pop());
|
|
@@ -2186,16 +2195,16 @@ var exportTemplates = function() {
|
|
|
2186
2195
|
4,
|
|
2187
2196
|
emailModule.renderAsync(emailModule.reactEmailCreateReactElement(emailModule.default, {}), options)
|
|
2188
2197
|
];
|
|
2189
|
-
case
|
|
2198
|
+
case 10:
|
|
2190
2199
|
rendered = _state.sent();
|
|
2191
2200
|
htmlPath = template.replace(".cjs", options.plainText ? ".txt" : ".html");
|
|
2192
2201
|
(0, import_node_fs7.writeFileSync)(htmlPath, rendered);
|
|
2193
2202
|
(0, import_node_fs7.unlinkSync)(template);
|
|
2194
2203
|
return [
|
|
2195
2204
|
3,
|
|
2196
|
-
|
|
2205
|
+
12
|
|
2197
2206
|
];
|
|
2198
|
-
case
|
|
2207
|
+
case 11:
|
|
2199
2208
|
exception1 = _state.sent();
|
|
2200
2209
|
if (spinner) {
|
|
2201
2210
|
spinner.stopAndPersist({
|
|
@@ -2205,39 +2214,60 @@ var exportTemplates = function() {
|
|
|
2205
2214
|
}
|
|
2206
2215
|
console.error(exception1);
|
|
2207
2216
|
throw exception1;
|
|
2208
|
-
case
|
|
2209
|
-
|
|
2217
|
+
case 12:
|
|
2218
|
+
_iteratorAbruptCompletion = false;
|
|
2210
2219
|
return [
|
|
2211
2220
|
3,
|
|
2212
2221
|
7
|
|
2213
2222
|
];
|
|
2214
|
-
case
|
|
2223
|
+
case 13:
|
|
2215
2224
|
return [
|
|
2216
2225
|
3,
|
|
2217
|
-
|
|
2226
|
+
20
|
|
2218
2227
|
];
|
|
2219
|
-
case
|
|
2228
|
+
case 14:
|
|
2220
2229
|
err = _state.sent();
|
|
2221
2230
|
_didIteratorError = true;
|
|
2222
2231
|
_iteratorError = err;
|
|
2223
2232
|
return [
|
|
2224
2233
|
3,
|
|
2225
|
-
|
|
2234
|
+
20
|
|
2226
2235
|
];
|
|
2227
|
-
case
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
+
case 15:
|
|
2237
|
+
_state.trys.push([
|
|
2238
|
+
15,
|
|
2239
|
+
,
|
|
2240
|
+
18,
|
|
2241
|
+
19
|
|
2242
|
+
]);
|
|
2243
|
+
if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [
|
|
2244
|
+
3,
|
|
2245
|
+
17
|
|
2246
|
+
];
|
|
2247
|
+
return [
|
|
2248
|
+
4,
|
|
2249
|
+
_iterator.return()
|
|
2250
|
+
];
|
|
2251
|
+
case 16:
|
|
2252
|
+
_state.sent();
|
|
2253
|
+
_state.label = 17;
|
|
2254
|
+
case 17:
|
|
2255
|
+
return [
|
|
2256
|
+
3,
|
|
2257
|
+
19
|
|
2258
|
+
];
|
|
2259
|
+
case 18:
|
|
2260
|
+
if (_didIteratorError) {
|
|
2261
|
+
throw _iteratorError;
|
|
2236
2262
|
}
|
|
2237
2263
|
return [
|
|
2238
2264
|
7
|
|
2239
2265
|
];
|
|
2240
|
-
case
|
|
2266
|
+
case 19:
|
|
2267
|
+
return [
|
|
2268
|
+
7
|
|
2269
|
+
];
|
|
2270
|
+
case 20:
|
|
2241
2271
|
if (spinner) {
|
|
2242
2272
|
spinner.succeed("Rendered all files");
|
|
2243
2273
|
spinner.text = "Copying static files";
|
|
@@ -2246,12 +2276,12 @@ var exportTemplates = function() {
|
|
|
2246
2276
|
staticDirectoryPath = import_node_path8.default.join(emailsDirectoryPath, "static");
|
|
2247
2277
|
if (!import_node_fs7.default.existsSync(staticDirectoryPath)) return [
|
|
2248
2278
|
3,
|
|
2249
|
-
|
|
2279
|
+
25
|
|
2250
2280
|
];
|
|
2251
2281
|
pathToDumpStaticFilesInto = import_node_path8.default.join(pathToWhereEmailMarkupShouldBeDumped, "static");
|
|
2252
2282
|
if (!import_node_fs7.default.existsSync(pathToDumpStaticFilesInto)) return [
|
|
2253
2283
|
3,
|
|
2254
|
-
|
|
2284
|
+
22
|
|
2255
2285
|
];
|
|
2256
2286
|
return [
|
|
2257
2287
|
4,
|
|
@@ -2259,15 +2289,15 @@ var exportTemplates = function() {
|
|
|
2259
2289
|
recursive: true
|
|
2260
2290
|
})
|
|
2261
2291
|
];
|
|
2262
|
-
case
|
|
2292
|
+
case 21:
|
|
2263
2293
|
_state.sent();
|
|
2264
|
-
_state.label =
|
|
2265
|
-
case
|
|
2294
|
+
_state.label = 22;
|
|
2295
|
+
case 22:
|
|
2266
2296
|
_state.trys.push([
|
|
2267
|
-
|
|
2268
|
-
|
|
2297
|
+
22,
|
|
2298
|
+
24,
|
|
2269
2299
|
,
|
|
2270
|
-
|
|
2300
|
+
25
|
|
2271
2301
|
]);
|
|
2272
2302
|
return [
|
|
2273
2303
|
4,
|
|
@@ -2275,13 +2305,13 @@ var exportTemplates = function() {
|
|
|
2275
2305
|
recursive: true
|
|
2276
2306
|
})
|
|
2277
2307
|
];
|
|
2278
|
-
case
|
|
2308
|
+
case 23:
|
|
2279
2309
|
_state.sent();
|
|
2280
2310
|
return [
|
|
2281
2311
|
3,
|
|
2282
|
-
|
|
2312
|
+
25
|
|
2283
2313
|
];
|
|
2284
|
-
case
|
|
2314
|
+
case 24:
|
|
2285
2315
|
exception2 = _state.sent();
|
|
2286
2316
|
console.error(exception2);
|
|
2287
2317
|
if (spinner) {
|
|
@@ -2291,25 +2321,25 @@ var exportTemplates = function() {
|
|
|
2291
2321
|
});
|
|
2292
2322
|
}
|
|
2293
2323
|
throw new Error("Something went wrong while copying the file to ".concat(pathToWhereEmailMarkupShouldBeDumped, "/static, ").concat(exception2));
|
|
2294
|
-
case
|
|
2324
|
+
case 25:
|
|
2295
2325
|
if (!(spinner && !options.silent)) return [
|
|
2296
2326
|
3,
|
|
2297
|
-
|
|
2327
|
+
27
|
|
2298
2328
|
];
|
|
2299
2329
|
spinner.succeed();
|
|
2300
2330
|
return [
|
|
2301
2331
|
4,
|
|
2302
2332
|
tree(pathToWhereEmailMarkupShouldBeDumped, 4)
|
|
2303
2333
|
];
|
|
2304
|
-
case
|
|
2334
|
+
case 26:
|
|
2305
2335
|
fileTree = _state.sent();
|
|
2306
2336
|
console.log(fileTree);
|
|
2307
2337
|
spinner.stopAndPersist({
|
|
2308
2338
|
symbol: import_log_symbols2.default.success,
|
|
2309
2339
|
text: "Successfully exported emails"
|
|
2310
2340
|
});
|
|
2311
|
-
_state.label =
|
|
2312
|
-
case
|
|
2341
|
+
_state.label = 27;
|
|
2342
|
+
case 27:
|
|
2313
2343
|
return [
|
|
2314
2344
|
2
|
|
2315
2345
|
];
|
|
@@ -2348,15 +2378,11 @@ var buildPreviewApp = function(absoluteDirectory) {
|
|
|
2348
2378
|
};
|
|
2349
2379
|
var setNextEnvironmentVariablesForBuild = function() {
|
|
2350
2380
|
var _ref = _async_to_generator(function(emailsDirRelativePath, builtPreviewAppPath) {
|
|
2351
|
-
var
|
|
2381
|
+
var nextConfigContents;
|
|
2352
2382
|
return _ts_generator(this, function(_state) {
|
|
2353
2383
|
switch(_state.label){
|
|
2354
2384
|
case 0:
|
|
2355
|
-
|
|
2356
|
-
import_node_path9.default.normalize(emailsDirRelativePath), "PLACEHOLDER", "PLACEHOLDER")), {
|
|
2357
|
-
NEXT_PUBLIC_IS_BUILDING: "true"
|
|
2358
|
-
});
|
|
2359
|
-
nextConfigContents = "\nconst path = require('path');\n/** @type {import('next').NextConfig} */\nmodule.exports = {\n env: {\n ...".concat(JSON.stringify(envVariables), ",\n NEXT_PUBLIC_USER_PROJECT_LOCATION: path.resolve(process.cwd(), '../'),\n NEXT_PUBLIC_CLI_PACKAGE_LOCATION: process.cwd(),\n },\n // this is needed so that the code for building emails works properly\n webpack: (\n /** @type {import('webpack').Configuration & { externals: string[] }} */\n config,\n { isServer }\n ) => {\n if (isServer) {\n config.externals.push('esbuild');\n }\n\n return config;\n },\n typescript: {\n ignoreBuildErrors: true\n },\n eslint: {\n ignoreDuringBuilds: true\n },\n experimental: {\n webpackBuildWorker: true\n },\n}");
|
|
2385
|
+
nextConfigContents = "\nconst path = require('path');\nconst emailsDirRelativePath = path.normalize('".concat(emailsDirRelativePath, "');\nconst userProjectLocation = path.resolve(process.cwd(), '../');\n/** @type {import('next').NextConfig} */\nmodule.exports = {\n env: {\n NEXT_PUBLIC_IS_BUILDING: 'true',\n EMAILS_DIR_RELATIVE_PATH: emailsDirRelativePath,\n EMAILS_DIR_ABSOLUTE_PATH: path.resolve(userProjectLocation, emailsDirRelativePath),\n USER_PROJECT_LOCATION: userProjectLocation\n },\n // this is needed so that the code for building emails works properly\n webpack: (\n /** @type {import('webpack').Configuration & { externals: string[] }} */\n config,\n { isServer }\n ) => {\n if (isServer) {\n config.externals.push('esbuild');\n }\n\n return config;\n },\n typescript: {\n ignoreBuildErrors: true\n },\n eslint: {\n ignoreDuringBuilds: true\n },\n experimental: {\n webpackBuildWorker: true\n },\n}");
|
|
2360
2386
|
return [
|
|
2361
2387
|
4,
|
|
2362
2388
|
import_node_fs8.default.promises.writeFile(import_node_path9.default.resolve(builtPreviewAppPath, "./next.config.js"), nextConfigContents, "utf8")
|
|
@@ -2389,7 +2415,7 @@ var getEmailSlugsFromEmailDirectory = function(emailDirectory, emailsDirectoryAb
|
|
|
2389
2415
|
};
|
|
2390
2416
|
var forceSSGForEmailPreviews = function() {
|
|
2391
2417
|
var _ref = _async_to_generator(function(emailsDirPath, builtPreviewAppPath) {
|
|
2392
|
-
var emailDirectoryMetadata, parameters;
|
|
2418
|
+
var emailDirectoryMetadata, parameters, removeForceDynamic;
|
|
2393
2419
|
return _ts_generator(this, function(_state) {
|
|
2394
2420
|
switch(_state.label){
|
|
2395
2421
|
case 0:
|
|
@@ -2405,11 +2431,51 @@ var forceSSGForEmailPreviews = function() {
|
|
|
2405
2431
|
slug: slug
|
|
2406
2432
|
};
|
|
2407
2433
|
});
|
|
2434
|
+
removeForceDynamic = function() {
|
|
2435
|
+
var _ref = _async_to_generator(function(filePath) {
|
|
2436
|
+
var contents;
|
|
2437
|
+
return _ts_generator(this, function(_state) {
|
|
2438
|
+
switch(_state.label){
|
|
2439
|
+
case 0:
|
|
2440
|
+
return [
|
|
2441
|
+
4,
|
|
2442
|
+
import_node_fs8.default.promises.readFile(filePath, "utf8")
|
|
2443
|
+
];
|
|
2444
|
+
case 1:
|
|
2445
|
+
contents = _state.sent();
|
|
2446
|
+
return [
|
|
2447
|
+
4,
|
|
2448
|
+
import_node_fs8.default.promises.writeFile(filePath, contents.replace("export const dynamic = 'force-dynamic';", ""), "utf8")
|
|
2449
|
+
];
|
|
2450
|
+
case 2:
|
|
2451
|
+
_state.sent();
|
|
2452
|
+
return [
|
|
2453
|
+
2
|
|
2454
|
+
];
|
|
2455
|
+
}
|
|
2456
|
+
});
|
|
2457
|
+
});
|
|
2458
|
+
return function removeForceDynamic(filePath) {
|
|
2459
|
+
return _ref.apply(this, arguments);
|
|
2460
|
+
};
|
|
2461
|
+
}();
|
|
2408
2462
|
return [
|
|
2409
2463
|
4,
|
|
2410
|
-
|
|
2464
|
+
removeForceDynamic(import_node_path9.default.resolve(builtPreviewAppPath, "./src/app/layout.tsx"))
|
|
2411
2465
|
];
|
|
2412
2466
|
case 2:
|
|
2467
|
+
_state.sent();
|
|
2468
|
+
return [
|
|
2469
|
+
4,
|
|
2470
|
+
removeForceDynamic(import_node_path9.default.resolve(builtPreviewAppPath, "./src/app/preview/[...slug]/page.tsx"))
|
|
2471
|
+
];
|
|
2472
|
+
case 3:
|
|
2473
|
+
_state.sent();
|
|
2474
|
+
return [
|
|
2475
|
+
4,
|
|
2476
|
+
import_node_fs8.default.promises.appendFile(import_node_path9.default.resolve(builtPreviewAppPath, "./src/app/preview/[...slug]/page.tsx"), "\n\nexport function generateStaticParams() { \n return Promise.resolve(\n ".concat(JSON.stringify(parameters), "\n );\n}"), "utf8")
|
|
2477
|
+
];
|
|
2478
|
+
case 4:
|
|
2413
2479
|
_state.sent();
|
|
2414
2480
|
return [
|
|
2415
2481
|
2
|
|
@@ -2442,7 +2508,6 @@ var updatePackageJson = function() {
|
|
|
2442
2508
|
packageJson.name = "preview-server";
|
|
2443
2509
|
delete packageJson.devDependencies["@react-email/render"];
|
|
2444
2510
|
delete packageJson.devDependencies["@react-email/components"];
|
|
2445
|
-
packageJson.dependencies.sharp = "0.33.2";
|
|
2446
2511
|
return [
|
|
2447
2512
|
4,
|
|
2448
2513
|
import_node_fs8.default.promises.writeFile(packageJsonPath, JSON.stringify(packageJson), "utf8")
|
|
@@ -2471,7 +2536,7 @@ var npmInstall = function() {
|
|
|
2471
2536
|
childProc = (0, import_node_child_process.spawn)(packageManager, [
|
|
2472
2537
|
"install",
|
|
2473
2538
|
"--silent",
|
|
2474
|
-
"--
|
|
2539
|
+
"--include=dev"
|
|
2475
2540
|
], {
|
|
2476
2541
|
cwd: builtPreviewAppPath,
|
|
2477
2542
|
shell: true
|
|
@@ -2650,10 +2715,14 @@ var start = function() {
|
|
|
2650
2715
|
"start"
|
|
2651
2716
|
], {
|
|
2652
2717
|
cwd: builtPreviewPath,
|
|
2653
|
-
|
|
2718
|
+
stdio: "inherit"
|
|
2719
|
+
});
|
|
2720
|
+
process.on("SIGINT", function() {
|
|
2721
|
+
nextStart.kill("SIGINT");
|
|
2722
|
+
});
|
|
2723
|
+
nextStart.on("exit", function(code) {
|
|
2724
|
+
process.exit(code !== null && code !== void 0 ? code : 0);
|
|
2654
2725
|
});
|
|
2655
|
-
nextStart.stdout.pipe(process.stdout);
|
|
2656
|
-
nextStart.stderr.pipe(process.stderr);
|
|
2657
2726
|
} catch (error) {
|
|
2658
2727
|
console.log(error);
|
|
2659
2728
|
process.exit(1);
|