@tryghost/mg-json 0.11.4 → 0.11.5

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.
@@ -4,12 +4,12 @@ import processPostRelations from './process-post-relations.js';
4
4
  import validate from './validate.js';
5
5
  import reorderTags from './reorder-tags.js';
6
6
 
7
- export default (input, options = {}, ctx) => {
7
+ export default async (input, options = {}, ctx) => {
8
8
  // Construct a basic Ghost JSON template
9
9
  let output = baseTemplate();
10
10
 
11
11
  // Validate data and potentially alter if needed
12
- input = validate(input, ctx);
12
+ input = await validate(input, ctx);
13
13
 
14
14
  // Reorder tags so #internal-tags appear last
15
15
  input = reorderTags(input);
@@ -1,4 +1,7 @@
1
- export default (json, ctx = null) => {
1
+ import {slugify} from '@tryghost/string';
2
+ import emailValidator from 'node-email-verifier';
3
+
4
+ export default async (json, ctx = null) => {
2
5
  if (!json.posts) {
3
6
  return json;
4
7
  }
@@ -36,5 +39,17 @@ export default (json, ctx = null) => {
36
39
  json.posts[index].data = input;
37
40
  });
38
41
 
42
+ if (json?.users?.length) {
43
+ for await (const [index, item] of json.users.entries()) {
44
+ const isEmailValid = await emailValidator(item.data.email);
45
+
46
+ if (!isEmailValid) {
47
+ item.data.email = `${slugify(item?.data?.slug || item?.data?.name || 'author')}@example.com`;
48
+ }
49
+
50
+ json.users[index] = item;
51
+ }
52
+ }
53
+
39
54
  return json;
40
55
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/mg-json",
3
- "version": "0.11.4",
3
+ "version": "0.11.5",
4
4
  "repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-json",
5
5
  "author": "Ghost Foundation",
6
6
  "license": "MIT",
@@ -28,7 +28,8 @@
28
28
  "@tryghost/string": "0.2.12",
29
29
  "bson-objectid": "2.0.4",
30
30
  "html-entities": "2.5.2",
31
- "lodash": "4.17.21"
31
+ "lodash": "4.17.21",
32
+ "node-email-verifier": "2.0.0"
32
33
  },
33
- "gitHead": "fd2fdb1542c90de5caac0feaa76e8ea599ef202f"
34
+ "gitHead": "c0d0850c491eb693ffbd33fd68f88ca87bb15f6a"
34
35
  }