react-email 1.7.9 → 1.7.11

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.9",
3
+ "version": "1.7.11",
4
4
  "description": "A live preview of your emails right in your browser.",
5
5
  "bin": {
6
6
  "email": "./dist/source/index.js"
@@ -23,13 +23,9 @@ const dev = async ({ dir, port }) => {
23
23
  const watcherInstance = (0, utils_1.createWatcherInstance)(emailDir);
24
24
  try {
25
25
  const hasReactEmailDirectory = (0, utils_1.checkDirectoryExist)(utils_1.REACT_EMAIL_ROOT);
26
- let packageManager;
27
- try {
28
- packageManager = await (0, detect_package_manager_1.detect)({ cwd: utils_1.CURRENT_PATH });
29
- }
30
- catch (_) {
31
- packageManager = 'yarn';
32
- }
26
+ const packageManager = await (0, detect_package_manager_1.detect)({
27
+ cwd: utils_1.CURRENT_PATH,
28
+ }).catch(() => 'npm');
33
29
  if (hasReactEmailDirectory) {
34
30
  const isUpToDate = await (0, utils_1.checkPackageIsUpToDate)();
35
31
  if (isUpToDate) {
@@ -56,7 +52,7 @@ const dev = async ({ dir, port }) => {
56
52
  };
57
53
  exports.dev = dev;
58
54
  const startDevServer = (packageManager, port) => {
59
- shelljs_1.default.exec(`${packageManager} run dev -p ${port}`, { async: true });
55
+ shelljs_1.default.exec(`${packageManager} run dev -- -p ${port}`, { async: true });
60
56
  };
61
57
  const convertToAbsolutePath = (dir) => path_1.default.isAbsolute(dir) ? dir : path_1.default.join(process.cwd(), dir);
62
58
  const createBasicStructure = async () => {
@@ -122,7 +118,6 @@ const generateEmailsPreview = async (emailDir) => {
122
118
  const spinner = (0, ora_1.default)('Generating emails preview').start();
123
119
  await createEmailPreviews(emailDir);
124
120
  await createStaticFiles(emailDir);
125
- await createComponents(emailDir);
126
121
  spinner.stopAndPersist({
127
122
  symbol: log_symbols_1.default.success,
128
123
  text: 'Emails preview generated',
@@ -134,41 +129,34 @@ const generateEmailsPreview = async (emailDir) => {
134
129
  };
135
130
  const createEmailPreviews = async (emailDir) => {
136
131
  const hasEmailsDirectory = (0, utils_1.checkDirectoryExist)(emailDir);
137
- const isEmailsDirectoryEmpty = hasEmailsDirectory
138
- ? await (0, utils_1.checkEmptyDirectory)(emailDir)
139
- : true;
140
- if (isEmailsDirectoryEmpty) {
132
+ if (hasEmailsDirectory) {
133
+ await (0, utils_1.checkEmptyDirectory)(emailDir);
141
134
  }
142
135
  const hasPackageEmailsDirectory = (0, utils_1.checkDirectoryExist)(utils_1.PACKAGE_EMAILS_PATH);
143
136
  if (hasPackageEmailsDirectory) {
144
137
  await fs_1.default.promises.rm(utils_1.PACKAGE_EMAILS_PATH, { recursive: true });
145
138
  }
146
- await (0, cpy_1.default)(path_1.default.join(emailDir, '*{.tsx,.jsx}'), utils_1.PACKAGE_EMAILS_PATH);
139
+ await (0, cpy_1.default)(path_1.default.join(emailDir, '**'), utils_1.PACKAGE_EMAILS_PATH);
147
140
  };
148
141
  const createStaticFiles = async (emailDir) => {
149
142
  const hasPackageStaticDirectory = (0, utils_1.checkDirectoryExist)(`${utils_1.REACT_EMAIL_ROOT}/public/static`);
150
- const staticDir = path_1.default.join(emailDir, 'static');
151
- const hasStaticDirectory = (0, utils_1.checkDirectoryExist)(staticDir);
152
143
  if (hasPackageStaticDirectory) {
153
144
  await fs_1.default.promises.rm(`${utils_1.REACT_EMAIL_ROOT}/public/static`, {
154
145
  recursive: true,
155
146
  });
156
147
  }
157
- if (hasStaticDirectory) {
158
- await (0, cpy_1.default)(staticDir, `${utils_1.REACT_EMAIL_ROOT}/public/static`);
159
- }
160
- };
161
- const createComponents = async (emailDir) => {
162
- const hasPackageComponentsDirectory = (0, utils_1.checkDirectoryExist)(`${utils_1.PACKAGE_EMAILS_PATH}/components`);
163
- const componentDir = path_1.default.join(emailDir, 'components');
164
- const hasComponentsDirectory = (0, utils_1.checkDirectoryExist)(componentDir);
165
- if (hasPackageComponentsDirectory) {
166
- await fs_1.default.promises.rm(`${utils_1.PACKAGE_EMAILS_PATH}/components`, {
148
+ // Make sure that the "static" folder does not exists in .react-email/emails
149
+ // 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`);
151
+ if (hasPackageStaticDirectoryInEmails) {
152
+ await fs_1.default.promises.rm(`${utils_1.REACT_EMAIL_ROOT}/emails/static`, {
167
153
  recursive: true,
168
154
  });
169
155
  }
170
- if (hasComponentsDirectory) {
171
- await (0, cpy_1.default)(componentDir, `${utils_1.PACKAGE_EMAILS_PATH}/components`);
156
+ const staticDir = path_1.default.join(emailDir, 'static');
157
+ const hasStaticDirectory = (0, utils_1.checkDirectoryExist)(staticDir);
158
+ if (hasStaticDirectory) {
159
+ await (0, cpy_1.default)(staticDir, `${utils_1.REACT_EMAIL_ROOT}/public/static`);
172
160
  }
173
161
  };
174
162
  const syncPkg = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-email",
3
- "version": "1.7.9",
3
+ "version": "1.7.11",
4
4
  "description": "A live preview of your emails right in your browser.",
5
5
  "bin": {
6
6
  "email": "./dist/source/index.js"
@@ -36,12 +36,9 @@ export const dev = async ({ dir, port }: Args) => {
36
36
  const watcherInstance = createWatcherInstance(emailDir);
37
37
  try {
38
38
  const hasReactEmailDirectory = checkDirectoryExist(REACT_EMAIL_ROOT);
39
- let packageManager: PackageManager;
40
- try {
41
- packageManager = await detectPackageManager({ cwd: CURRENT_PATH });
42
- } catch (_) {
43
- packageManager = 'yarn';
44
- }
39
+ const packageManager: PackageManager = await detectPackageManager({
40
+ cwd: CURRENT_PATH,
41
+ }).catch(() => 'npm');
45
42
 
46
43
  if (hasReactEmailDirectory) {
47
44
  const isUpToDate = await checkPackageIsUpToDate();
@@ -71,8 +68,8 @@ export const dev = async ({ dir, port }: Args) => {
71
68
  };
72
69
 
73
70
  const startDevServer = (packageManager: string, port: string) => {
74
- shell.exec(`${packageManager} run dev -p ${port}`, { async: true });
75
- }
71
+ shell.exec(`${packageManager} run dev -- -p ${port}`, { async: true });
72
+ };
76
73
 
77
74
  const convertToAbsolutePath = (dir: string): string =>
78
75
  path.isAbsolute(dir) ? dir : path.join(process.cwd(), dir);
@@ -148,7 +145,6 @@ const generateEmailsPreview = async (emailDir: string) => {
148
145
 
149
146
  await createEmailPreviews(emailDir);
150
147
  await createStaticFiles(emailDir);
151
- await createComponents(emailDir);
152
148
 
153
149
  spinner.stopAndPersist({
154
150
  symbol: logSymbols.success,
@@ -161,12 +157,8 @@ const generateEmailsPreview = async (emailDir: string) => {
161
157
 
162
158
  const createEmailPreviews = async (emailDir: string) => {
163
159
  const hasEmailsDirectory = checkDirectoryExist(emailDir);
164
-
165
- const isEmailsDirectoryEmpty = hasEmailsDirectory
166
- ? await checkEmptyDirectory(emailDir)
167
- : true;
168
-
169
- if (isEmailsDirectoryEmpty) {
160
+ if (hasEmailsDirectory) {
161
+ await checkEmptyDirectory(emailDir);
170
162
  }
171
163
 
172
164
  const hasPackageEmailsDirectory = checkDirectoryExist(PACKAGE_EMAILS_PATH);
@@ -175,42 +167,35 @@ const createEmailPreviews = async (emailDir: string) => {
175
167
  await fs.promises.rm(PACKAGE_EMAILS_PATH, { recursive: true });
176
168
  }
177
169
 
178
- await copy(path.join(emailDir, '*{.tsx,.jsx}'), PACKAGE_EMAILS_PATH);
170
+ await copy(path.join(emailDir, '**'), PACKAGE_EMAILS_PATH);
179
171
  };
180
172
 
181
173
  const createStaticFiles = async (emailDir: string) => {
182
174
  const hasPackageStaticDirectory = checkDirectoryExist(
183
175
  `${REACT_EMAIL_ROOT}/public/static`,
184
176
  );
185
- const staticDir = path.join(emailDir, 'static');
186
- const hasStaticDirectory = checkDirectoryExist(staticDir);
187
-
188
177
  if (hasPackageStaticDirectory) {
189
178
  await fs.promises.rm(`${REACT_EMAIL_ROOT}/public/static`, {
190
179
  recursive: true,
191
180
  });
192
181
  }
193
182
 
194
- if (hasStaticDirectory) {
195
- await copy(staticDir, `${REACT_EMAIL_ROOT}/public/static`);
196
- }
197
- };
198
-
199
- const createComponents = async (emailDir: string) => {
200
- const hasPackageComponentsDirectory = checkDirectoryExist(
201
- `${PACKAGE_EMAILS_PATH}/components`,
183
+ // Make sure that the "static" folder does not exists in .react-email/emails
184
+ // since it should only exists in .react-email/public, but the "createEmailPreviews"-function will blindly copy the complete emails folder
185
+ const hasPackageStaticDirectoryInEmails = checkDirectoryExist(
186
+ `${REACT_EMAIL_ROOT}/emails/static`,
202
187
  );
203
- const componentDir = path.join(emailDir, 'components');
204
- const hasComponentsDirectory = checkDirectoryExist(componentDir);
205
-
206
- if (hasPackageComponentsDirectory) {
207
- await fs.promises.rm(`${PACKAGE_EMAILS_PATH}/components`, {
188
+ if (hasPackageStaticDirectoryInEmails) {
189
+ await fs.promises.rm(`${REACT_EMAIL_ROOT}/emails/static`, {
208
190
  recursive: true,
209
191
  });
210
192
  }
211
193
 
212
- if (hasComponentsDirectory) {
213
- await copy(componentDir, `${PACKAGE_EMAILS_PATH}/components`);
194
+ const staticDir = path.join(emailDir, 'static');
195
+ const hasStaticDirectory = checkDirectoryExist(staticDir);
196
+
197
+ if (hasStaticDirectory) {
198
+ await copy(staticDir, `${REACT_EMAIL_ROOT}/public/static`);
214
199
  }
215
200
  };
216
201