react-email 1.7.11 → 1.7.12

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/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-email",
3
- "version": "1.7.11",
3
+ "version": "1.7.12",
4
4
  "description": "A live preview of your emails right in your browser.",
5
5
  "bin": {
6
6
  "email": "./dist/source/index.js"
@@ -33,7 +33,6 @@
33
33
  "@react-email/render": "0.0.6",
34
34
  "chokidar": "3.5.3",
35
35
  "commander": "9.4.1",
36
- "cpy": "8.1.2",
37
36
  "detect-package-manager": "2.0.1",
38
37
  "esbuild": "0.16.4",
39
38
  "glob": "8.0.3",
@@ -11,7 +11,6 @@ const components_1 = require("../_preview/components");
11
11
  const utils_2 = require("../_preview/utils");
12
12
  const root_1 = require("../_preview/root");
13
13
  const pages_1 = require("../_preview/pages");
14
- const cpy_1 = __importDefault(require("cpy"));
15
14
  const detect_package_manager_1 = require("detect-package-manager");
16
15
  const log_symbols_1 = __importDefault(require("log-symbols"));
17
16
  const ora_1 = __importDefault(require("ora"));
@@ -136,27 +135,35 @@ const createEmailPreviews = async (emailDir) => {
136
135
  if (hasPackageEmailsDirectory) {
137
136
  await fs_1.default.promises.rm(utils_1.PACKAGE_EMAILS_PATH, { recursive: true });
138
137
  }
139
- await (0, cpy_1.default)(path_1.default.join(emailDir, '**'), utils_1.PACKAGE_EMAILS_PATH);
138
+ const result = shelljs_1.default.cp('-r', emailDir, utils_1.PACKAGE_EMAILS_PATH);
139
+ if (result.code > 0) {
140
+ throw new Error(`Something went wrong while copying the file to ${utils_1.PACKAGE_EMAILS_PATH}, ${result.cat()}`);
141
+ }
140
142
  };
141
143
  const createStaticFiles = async (emailDir) => {
142
- const hasPackageStaticDirectory = (0, utils_1.checkDirectoryExist)(`${utils_1.REACT_EMAIL_ROOT}/public/static`);
144
+ const reactEmailPublicFolder = path_1.default.join(utils_1.REACT_EMAIL_ROOT, 'public', 'static');
145
+ const hasPackageStaticDirectory = (0, utils_1.checkDirectoryExist)(reactEmailPublicFolder);
143
146
  if (hasPackageStaticDirectory) {
144
- await fs_1.default.promises.rm(`${utils_1.REACT_EMAIL_ROOT}/public/static`, {
147
+ await fs_1.default.promises.rm(reactEmailPublicFolder, {
145
148
  recursive: true,
146
149
  });
147
150
  }
148
151
  // Make sure that the "static" folder does not exists in .react-email/emails
149
152
  // since it should only exists in .react-email/public, but the "createEmailPreviews"-function will blindly copy the complete emails folder
150
- const hasPackageStaticDirectoryInEmails = (0, utils_1.checkDirectoryExist)(`${utils_1.REACT_EMAIL_ROOT}/emails/static`);
153
+ const reactEmailEmailStaticFolder = path_1.default.join(utils_1.REACT_EMAIL_ROOT, 'emails', 'static');
154
+ const hasPackageStaticDirectoryInEmails = (0, utils_1.checkDirectoryExist)(reactEmailEmailStaticFolder);
151
155
  if (hasPackageStaticDirectoryInEmails) {
152
- await fs_1.default.promises.rm(`${utils_1.REACT_EMAIL_ROOT}/emails/static`, {
156
+ await fs_1.default.promises.rm(reactEmailEmailStaticFolder, {
153
157
  recursive: true,
154
158
  });
155
159
  }
156
160
  const staticDir = path_1.default.join(emailDir, 'static');
157
161
  const hasStaticDirectory = (0, utils_1.checkDirectoryExist)(staticDir);
158
162
  if (hasStaticDirectory) {
159
- await (0, cpy_1.default)(staticDir, `${utils_1.REACT_EMAIL_ROOT}/public/static`);
163
+ const result = shelljs_1.default.cp('-r', staticDir, reactEmailPublicFolder);
164
+ if (result.code > 0) {
165
+ throw new Error(`Something went wrong while copying the file to ${reactEmailPublicFolder}, ${result.cat()}`);
166
+ }
160
167
  }
161
168
  };
162
169
  const syncPkg = async () => {
@@ -34,10 +34,10 @@ const ora_1 = __importDefault(require("ora"));
34
34
  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
- const cpy_1 = __importDefault(require("cpy"));
38
37
  const normalize_path_1 = __importDefault(require("normalize-path"));
39
38
  const utils_1 = require("../utils");
40
39
  const path_1 = __importDefault(require("path"));
40
+ const shelljs_1 = __importDefault(require("shelljs"));
41
41
  /*
42
42
  This first builds all the templates using esbuild and then puts the output in the `.js`
43
43
  files. Then these `.js` files are imported dynamically and rendered to `.html` files
@@ -66,7 +66,10 @@ const exportTemplates = async (outDir, srcDir, options) => {
66
66
  const staticDir = path_1.default.join(srcDir, 'static');
67
67
  const hasStaticDirectory = (0, utils_1.checkDirectoryExist)(staticDir);
68
68
  if (hasStaticDirectory) {
69
- await (0, cpy_1.default)(staticDir, `${outDir}/static`);
69
+ const result = shelljs_1.default.cp('-r', staticDir, path_1.default.join(outDir, 'static'));
70
+ if (result.code > 0) {
71
+ throw new Error(`Something went wrong while copying the file to ${outDir}/static, ${result.cat()}`);
72
+ }
70
73
  }
71
74
  const fileTree = (0, tree_node_cli_1.default)(outDir, {
72
75
  allFiles: true,
@@ -8,7 +8,7 @@ const chokidar_1 = __importDefault(require("chokidar"));
8
8
  const constants_1 = require("./constants");
9
9
  const fs_1 = __importDefault(require("fs"));
10
10
  const path_1 = __importDefault(require("path"));
11
- const cpy_1 = __importDefault(require("cpy"));
11
+ const shelljs_1 = __importDefault(require("shelljs"));
12
12
  const createWatcherInstance = (watchDir) => chokidar_1.default.watch(watchDir, {
13
13
  ignoreInitial: true,
14
14
  cwd: constants_1.CURRENT_PATH,
@@ -31,10 +31,16 @@ const watcher = (watcherInstance, watchDir) => {
31
31
  }
32
32
  if (file[1] === 'static' && file[2]) {
33
33
  const srcPath = path_1.default.join(watchDir, 'static', file[2]);
34
- await (0, cpy_1.default)(srcPath, `${constants_1.REACT_EMAIL_ROOT}/public/static`);
34
+ const result = shelljs_1.default.cp('-r', srcPath, path_1.default.join(constants_1.REACT_EMAIL_ROOT, 'public', 'static'));
35
+ if (result.code > 0) {
36
+ throw new Error(`Something went wrong while copying the file to ${constants_1.PACKAGE_EMAILS_PATH}, ${result.cat()}`);
37
+ }
35
38
  return;
36
39
  }
37
- await (0, cpy_1.default)(path_1.default.join(watchDir, ...file.slice(1)), path_1.default.join(constants_1.PACKAGE_EMAILS_PATH, ...file.slice(1, -1)));
40
+ const result = shelljs_1.default.cp('-r', path_1.default.join(watchDir, ...file.slice(1)), path_1.default.join(constants_1.PACKAGE_EMAILS_PATH, ...file.slice(1, -1)));
41
+ if (result.code > 0) {
42
+ throw new Error(`Something went wrong while copying the file to ${constants_1.PACKAGE_EMAILS_PATH}, ${result.cat()}`);
43
+ }
38
44
  });
39
45
  };
40
46
  exports.watcher = watcher;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-email",
3
- "version": "1.7.11",
3
+ "version": "1.7.12",
4
4
  "description": "A live preview of your emails right in your browser.",
5
5
  "bin": {
6
6
  "email": "./dist/source/index.js"
@@ -33,7 +33,6 @@
33
33
  "@react-email/render": "0.0.6",
34
34
  "chokidar": "3.5.3",
35
35
  "commander": "9.4.1",
36
- "cpy": "8.1.2",
37
36
  "detect-package-manager": "2.0.1",
38
37
  "esbuild": "0.16.4",
39
38
  "glob": "8.0.3",
@@ -18,7 +18,6 @@ import { components } from '../_preview/components';
18
18
  import { utils } from '../_preview/utils';
19
19
  import { root } from '../_preview/root';
20
20
  import { pages } from '../_preview/pages';
21
- import copy from 'cpy';
22
21
  import { detect as detectPackageManager } from 'detect-package-manager';
23
22
  import logSymbols from 'log-symbols';
24
23
  import ora from 'ora';
@@ -167,26 +166,39 @@ const createEmailPreviews = async (emailDir: string) => {
167
166
  await fs.promises.rm(PACKAGE_EMAILS_PATH, { recursive: true });
168
167
  }
169
168
 
170
- await copy(path.join(emailDir, '**'), PACKAGE_EMAILS_PATH);
169
+ const result = shell.cp('-r', emailDir, PACKAGE_EMAILS_PATH);
170
+ if (result.code > 0) {
171
+ throw new Error(
172
+ `Something went wrong while copying the file to ${PACKAGE_EMAILS_PATH}, ${result.cat()}`,
173
+ );
174
+ }
171
175
  };
172
176
 
173
177
  const createStaticFiles = async (emailDir: string) => {
174
- const hasPackageStaticDirectory = checkDirectoryExist(
175
- `${REACT_EMAIL_ROOT}/public/static`,
178
+ const reactEmailPublicFolder = path.join(
179
+ REACT_EMAIL_ROOT,
180
+ 'public',
181
+ 'static',
176
182
  );
183
+ const hasPackageStaticDirectory = checkDirectoryExist(reactEmailPublicFolder);
177
184
  if (hasPackageStaticDirectory) {
178
- await fs.promises.rm(`${REACT_EMAIL_ROOT}/public/static`, {
185
+ await fs.promises.rm(reactEmailPublicFolder, {
179
186
  recursive: true,
180
187
  });
181
188
  }
182
189
 
183
190
  // Make sure that the "static" folder does not exists in .react-email/emails
184
191
  // since it should only exists in .react-email/public, but the "createEmailPreviews"-function will blindly copy the complete emails folder
192
+ const reactEmailEmailStaticFolder = path.join(
193
+ REACT_EMAIL_ROOT,
194
+ 'emails',
195
+ 'static',
196
+ );
185
197
  const hasPackageStaticDirectoryInEmails = checkDirectoryExist(
186
- `${REACT_EMAIL_ROOT}/emails/static`,
198
+ reactEmailEmailStaticFolder,
187
199
  );
188
200
  if (hasPackageStaticDirectoryInEmails) {
189
- await fs.promises.rm(`${REACT_EMAIL_ROOT}/emails/static`, {
201
+ await fs.promises.rm(reactEmailEmailStaticFolder, {
190
202
  recursive: true,
191
203
  });
192
204
  }
@@ -195,7 +207,12 @@ const createStaticFiles = async (emailDir: string) => {
195
207
  const hasStaticDirectory = checkDirectoryExist(staticDir);
196
208
 
197
209
  if (hasStaticDirectory) {
198
- await copy(staticDir, `${REACT_EMAIL_ROOT}/public/static`);
210
+ const result = shell.cp('-r', staticDir, reactEmailPublicFolder);
211
+ if (result.code > 0) {
212
+ throw new Error(
213
+ `Something went wrong while copying the file to ${reactEmailPublicFolder}, ${result.cat()}`,
214
+ );
215
+ }
199
216
  }
200
217
  };
201
218
 
@@ -5,10 +5,10 @@ import ora from 'ora';
5
5
  import logSymbols from 'log-symbols';
6
6
  import { render, Options } from '@react-email/render';
7
7
  import { unlinkSync, writeFileSync } from 'fs';
8
- import copy from 'cpy';
9
8
  import normalize from 'normalize-path';
10
9
  import { checkDirectoryExist } from '../utils';
11
10
  import path from 'path';
11
+ import shell from 'shelljs';
12
12
  /*
13
13
  This first builds all the templates using esbuild and then puts the output in the `.js`
14
14
  files. Then these `.js` files are imported dynamically and rendered to `.html` files
@@ -49,7 +49,12 @@ export const exportTemplates = async (
49
49
  const hasStaticDirectory = checkDirectoryExist(staticDir);
50
50
 
51
51
  if (hasStaticDirectory) {
52
- await copy(staticDir, `${outDir}/static`);
52
+ const result = shell.cp('-r', staticDir, path.join(outDir, 'static'));
53
+ if (result.code > 0) {
54
+ throw new Error(
55
+ `Something went wrong while copying the file to ${outDir}/static, ${result.cat()}`,
56
+ );
57
+ }
53
58
  }
54
59
 
55
60
  const fileTree = tree(outDir, {
@@ -7,7 +7,7 @@ import {
7
7
  } from './constants';
8
8
  import fs from 'fs';
9
9
  import path from 'path';
10
- import copy from 'cpy';
10
+ import shell from 'shelljs';
11
11
 
12
12
  export const createWatcherInstance = (watchDir: string) =>
13
13
  chokidar.watch(watchDir, {
@@ -37,12 +37,28 @@ export const watcher = (watcherInstance: FSWatcher, watchDir: string) => {
37
37
 
38
38
  if (file[1] === 'static' && file[2]) {
39
39
  const srcPath = path.join(watchDir, 'static', file[2]);
40
- await copy(srcPath, `${REACT_EMAIL_ROOT}/public/static`);
40
+ const result = shell.cp(
41
+ '-r',
42
+ srcPath,
43
+ path.join(REACT_EMAIL_ROOT, 'public', 'static'),
44
+ );
45
+ if (result.code > 0) {
46
+ throw new Error(
47
+ `Something went wrong while copying the file to ${PACKAGE_EMAILS_PATH}, ${result.cat()}`,
48
+ );
49
+ }
41
50
  return;
42
51
  }
43
- await copy(
52
+
53
+ const result = shell.cp(
54
+ '-r',
44
55
  path.join(watchDir, ...file.slice(1)),
45
56
  path.join(PACKAGE_EMAILS_PATH, ...file.slice(1, -1)),
46
57
  );
58
+ if (result.code > 0) {
59
+ throw new Error(
60
+ `Something went wrong while copying the file to ${PACKAGE_EMAILS_PATH}, ${result.cat()}`,
61
+ );
62
+ }
47
63
  });
48
64
  };