@tryghost/mg-json 0.11.6 → 0.11.8
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import {slugify} from '@tryghost/string';
|
|
3
|
-
import
|
|
3
|
+
import {decode} from 'html-entities';
|
|
4
4
|
/**
|
|
5
5
|
* Hydrate Ghost objects
|
|
6
6
|
* Extend object with the minimum data needed for an import to succeed
|
|
@@ -91,7 +91,7 @@ const hydratePost = (input, options) => {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
// Cleanup titles
|
|
94
|
-
input.title =
|
|
94
|
+
input.title = decode(input.title);
|
|
95
95
|
|
|
96
96
|
// @TODO: log some sort of warning for things like this?
|
|
97
97
|
if (!_.includes(['published', 'draft', 'scheduled'], input.status)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {slugify} from '@tryghost/string';
|
|
2
2
|
import emailValidator from 'node-email-verifier';
|
|
3
3
|
|
|
4
|
-
export default async (json
|
|
4
|
+
export default async (json) => {
|
|
5
5
|
if (!json.posts) {
|
|
6
6
|
return json;
|
|
7
7
|
}
|
|
@@ -12,7 +12,7 @@ export default async (json, ctx = null) => {
|
|
|
12
12
|
// String length data from https://github.com/TryGhost/Ghost/blob/main/ghost/core/core/server/data/schema/schema.js
|
|
13
13
|
let properties = {
|
|
14
14
|
title: 255,
|
|
15
|
-
slug:
|
|
15
|
+
slug: 185,
|
|
16
16
|
custom_excerpt: 300,
|
|
17
17
|
og_title: 300,
|
|
18
18
|
og_description: 500,
|
|
@@ -28,9 +28,8 @@ export default async (json, ctx = null) => {
|
|
|
28
28
|
if (input[propKey] && input[propKey].length > propValue) {
|
|
29
29
|
let truncated = input[propKey].substring(0, propValue).trim();
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
31
|
+
// eslint-disable-next-line no-console
|
|
32
|
+
console.warn(`${propKey} for slug "${item.data.slug}" is too long.\nOriginal: "${input[propKey]}"\nTruncated to: "${truncated}"`);
|
|
34
33
|
|
|
35
34
|
input[propKey] = truncated;
|
|
36
35
|
}
|
|
@@ -41,7 +40,14 @@ export default async (json, ctx = null) => {
|
|
|
41
40
|
|
|
42
41
|
if (json?.users?.length) {
|
|
43
42
|
for await (const [index, item] of json.users.entries()) {
|
|
44
|
-
|
|
43
|
+
let isEmailValid = false;
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
isEmailValid = await emailValidator(item.data.email);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
// Silently fail here as we don't want to break the migration
|
|
49
|
+
// Just fall back to the <user-slug>@example.com
|
|
50
|
+
}
|
|
45
51
|
|
|
46
52
|
if (!isEmailValid) {
|
|
47
53
|
item.data.email = `${slugify(item?.data?.slug || item?.data?.name || 'author')}@example.com`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/mg-json",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.8",
|
|
4
4
|
"repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-json",
|
|
5
5
|
"author": "Ghost Foundation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"eslint": "8.57.0",
|
|
24
|
-
"jest": "
|
|
25
|
-
"jest-extended": "
|
|
24
|
+
"jest": "30.0.3",
|
|
25
|
+
"jest-extended": "6.0.0"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@tryghost/string": "0.2.
|
|
28
|
+
"@tryghost/string": "0.2.17",
|
|
29
29
|
"bson-objectid": "2.0.4",
|
|
30
|
-
"html-entities": "2.
|
|
30
|
+
"html-entities": "2.6.0",
|
|
31
31
|
"lodash": "4.17.21",
|
|
32
32
|
"node-email-verifier": "2.0.0"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "958389c2c9667c0e7e44f983d4fd1aa256caff4d"
|
|
35
35
|
}
|