@tryghost/mg-medium-export 0.11.12 → 0.12.0
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/README.md +3 -3
- package/index.js +3 -7
- package/lib/process-content.js +2 -2
- package/lib/process-post.js +12 -11
- package/lib/process-profile.js +2 -2
- package/lib/process.js +3 -3
- package/lib/read-zip.js +3 -3
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -38,9 +38,9 @@ It's possible to pass more options, in order to achieve a better migration file
|
|
|
38
38
|
- Create a zip file
|
|
39
39
|
- **`-s` `--scrape`**
|
|
40
40
|
- Configure scraping tasks
|
|
41
|
-
-
|
|
42
|
-
- Choices: `all`, `img`, `web`, `media`, `none`
|
|
43
|
-
- **`--
|
|
41
|
+
- string - default: `all`
|
|
42
|
+
- Choices: `all`, `img`, `web`, `media`, `files`, `none`
|
|
43
|
+
- **`--sizeLimit`**
|
|
44
44
|
- number - default: `false`
|
|
45
45
|
- Media files larger than this size (defined in MB [i.e. `5`]) will be flagged as oversize
|
|
46
46
|
- **`-e` `--email`**
|
package/index.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import readZip from './lib/read-zip.js';
|
|
2
|
+
import process from './lib/process.js';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export default (pathToZip, options) => {
|
|
5
5
|
let input = readZip(pathToZip, options);
|
|
6
6
|
let output = process(input);
|
|
7
7
|
|
|
8
8
|
return output;
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
if (require.main === module && process.argv[2]) {
|
|
12
|
-
console.log(JSON.stringify(mediumExport(process.argv[2]), null, 2)); // eslint-disable-line
|
|
13
|
-
}
|
package/lib/process-content.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import $ from 'cheerio';
|
|
2
2
|
|
|
3
3
|
const equivalentTitles = (title1, title2) => {
|
|
4
4
|
title1 = title1.replace(/[\s\n]/g, '');
|
|
@@ -7,7 +7,7 @@ const equivalentTitles = (title1, title2) => {
|
|
|
7
7
|
return title1 === title2;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
export default (content, post) => {
|
|
11
11
|
let $content = $(content);
|
|
12
12
|
|
|
13
13
|
// Medium usually has an hr divider at the very beginning of the content
|
package/lib/process-post.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import $ from 'cheerio';
|
|
2
|
+
import {formatISO} from 'date-fns';
|
|
3
|
+
import string from '@tryghost/string';
|
|
4
|
+
import processContent from './process-content.js';
|
|
5
|
+
|
|
5
6
|
const sectionTags = ['aside', 'blockquote', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'img'];
|
|
6
7
|
|
|
7
8
|
const processMeta = (name, $post) => {
|
|
@@ -32,12 +33,12 @@ const processMeta = (name, $post) => {
|
|
|
32
33
|
post.data.updated_at = $post('.dt-published').attr('datetime') || dateNow;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
$('img').map(async (i, el) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}).get();
|
|
36
|
+
// $('img').map(async (i, el) => {
|
|
37
|
+
// let $image = $(el);
|
|
38
|
+
// let type = $image.attr('src') === undefined ? 'data-src' : 'src';
|
|
39
|
+
// let newSrc = await this.downloadImage($image.attr(type));
|
|
40
|
+
// $image.attr(type, newSrc);
|
|
41
|
+
// }).get();
|
|
41
42
|
|
|
42
43
|
// Ensure the slug is clean and valid according to Ghost
|
|
43
44
|
post.data.slug = string.slugify(urlInfo[1]);
|
|
@@ -120,7 +121,7 @@ const processFeatureImage = (html, post) => {
|
|
|
120
121
|
return $html.html().trim();
|
|
121
122
|
};
|
|
122
123
|
|
|
123
|
-
|
|
124
|
+
export default (name, html, globalUser) => {
|
|
124
125
|
const $post = $.load(html, {
|
|
125
126
|
decodeEntities: false
|
|
126
127
|
});
|
package/lib/process-profile.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import cheerio from 'cheerio';
|
|
2
2
|
|
|
3
3
|
// Keys we've seen so far
|
|
4
4
|
// Profile
|
|
@@ -21,7 +21,7 @@ const mediumToGhost = {
|
|
|
21
21
|
twitter: 'twitter'
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
export default (html) => {
|
|
25
25
|
let $ = cheerio.load(html);
|
|
26
26
|
let profile = {
|
|
27
27
|
url: $('.u-url').attr('href'),
|
package/lib/process.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import processPost from './process-post.js';
|
|
2
|
+
import processProfile from './process-profile.js';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export default (input) => {
|
|
5
5
|
let output = {};
|
|
6
6
|
|
|
7
7
|
if (input.profile) {
|
package/lib/read-zip.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import fsUtils from '@tryghost/mg-fs-utils';
|
|
2
|
+
import {ui} from '@tryghost/pretty-cli';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export default (zipPath, options) => {
|
|
5
5
|
let content = {
|
|
6
6
|
posts: []
|
|
7
7
|
};
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/mg-medium-export",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "tbc",
|
|
5
5
|
"repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-medium-export",
|
|
6
6
|
"author": "Ghost Foundation",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "index.js",
|
|
9
|
+
"type": "module",
|
|
9
10
|
"scripts": {
|
|
10
11
|
"dev": "echo \"Implement me!\"",
|
|
11
|
-
"test": "
|
|
12
|
+
"test": "node --experimental-vm-modules $(yarn bin jest)",
|
|
12
13
|
"lint": "eslint . --ext .js --cache",
|
|
13
14
|
"posttest": "yarn lint"
|
|
14
15
|
},
|
|
@@ -20,15 +21,15 @@
|
|
|
20
21
|
"access": "public"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
24
|
+
"eslint": "8.25.0",
|
|
25
|
+
"jest": "29.1.2",
|
|
26
|
+
"jest-extended": "3.1.0"
|
|
26
27
|
},
|
|
27
28
|
"dependencies": {
|
|
28
|
-
"@tryghost/mg-fs-utils": "^0.
|
|
29
|
+
"@tryghost/mg-fs-utils": "^0.10.0",
|
|
29
30
|
"@tryghost/string": "^0.2.0",
|
|
30
31
|
"cheerio": "0.22.0",
|
|
31
32
|
"date-fns": "2.29.3"
|
|
32
33
|
},
|
|
33
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "35cb5c1ca6a826e1e596c4f2e209ab690fa06fa0"
|
|
34
35
|
}
|