@tryghost/mg-medium-export 0.13.7 → 0.14.1
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 +7 -4
- package/index.js +5 -1
- package/lib/read-zip.js +20 -3
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -25,13 +25,16 @@ or
|
|
|
25
25
|
To run a Medium migration, the required command is:
|
|
26
26
|
|
|
27
27
|
```sh
|
|
28
|
-
migrate medium
|
|
28
|
+
migrate medium --pathToZip /path/to/my-export.zip
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
**Note:** The zip path can be to a singular zip file or a folder of zip files
|
|
32
32
|
|
|
33
33
|
It's possible to pass more options, in order to achieve a better migration file for Ghost:
|
|
34
34
|
|
|
35
|
+
- **`--pathToZip`** (required)
|
|
36
|
+
- Path to a zip file
|
|
37
|
+
- string - default: `null`
|
|
35
38
|
- **`-V` `--verbose`**
|
|
36
39
|
- bool - default: `false`
|
|
37
40
|
- Show verbose output
|
|
@@ -49,7 +52,7 @@ It's possible to pass more options, in order to achieve a better migration file
|
|
|
49
52
|
- string - default: `false`
|
|
50
53
|
- Provide an email domain for users e.g. example.com
|
|
51
54
|
- **`--fallBackHTMLCard`**
|
|
52
|
-
- bool - default: `
|
|
55
|
+
- bool - default: `true`
|
|
53
56
|
- Fall back to convert to HTMLCard, if standard Mobiledoc convert fails
|
|
54
57
|
- **`--cache`**
|
|
55
58
|
- Persist local cache after migration is complete (Only if `--zip` is `true`)
|
|
@@ -58,7 +61,7 @@ It's possible to pass more options, in order to achieve a better migration file
|
|
|
58
61
|
A more complex migration command could look like this:
|
|
59
62
|
|
|
60
63
|
```sh
|
|
61
|
-
migrate medium
|
|
64
|
+
migrate medium --pathToZip /path/to/my-export.zip --email example.com
|
|
62
65
|
```
|
|
63
66
|
|
|
64
67
|
This will process all posts from the zip file, and all authors will have an email address ending in 'example.com'
|
|
@@ -78,7 +81,7 @@ Follow the instructions for the top-level repo.
|
|
|
78
81
|
To run a local development copy, `cd` into this directory, and use `yarn dev` instead of `migrate` like so:
|
|
79
82
|
|
|
80
83
|
```sh
|
|
81
|
-
yarn dev medium
|
|
84
|
+
yarn dev medium --pathToZip /path/to/my-export.zip
|
|
82
85
|
```
|
|
83
86
|
|
|
84
87
|
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import readZip from './lib/read-zip.js';
|
|
1
|
+
import readZip, {contentStats} from './lib/read-zip.js';
|
|
2
2
|
import process from './lib/process.js';
|
|
3
3
|
|
|
4
4
|
export default (pathToZip, options) => {
|
|
@@ -7,3 +7,7 @@ export default (pathToZip, options) => {
|
|
|
7
7
|
|
|
8
8
|
return output;
|
|
9
9
|
};
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
contentStats
|
|
13
|
+
};
|
package/lib/read-zip.js
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import {lstatSync, readdirSync} from 'node:fs';
|
|
2
2
|
import {join} from 'node:path';
|
|
3
3
|
import fsUtils from '@tryghost/mg-fs-utils';
|
|
4
|
-
import {
|
|
4
|
+
import {_base as debugFactory} from '@tryghost/debug';
|
|
5
|
+
|
|
6
|
+
const debug = debugFactory('migrate:medium:lib:read-zip');
|
|
7
|
+
|
|
8
|
+
const contentStats = async (zipPath) => {
|
|
9
|
+
const entries = await fsUtils.readZipEntries(zipPath);
|
|
10
|
+
const posts = entries.filter(value => /^posts\/.*\.html$/.test(value)).length;
|
|
11
|
+
const users = entries.filter(value => /^profile\/profile\.html/.test(value)).length;
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
posts: posts,
|
|
15
|
+
users: users
|
|
16
|
+
};
|
|
17
|
+
};
|
|
5
18
|
|
|
6
19
|
const readMediumZip = ({content, zipPath, options, skippedFileCount}) => {
|
|
7
20
|
fsUtils.zip.read(zipPath, (entryName, zipEntry) => {
|
|
@@ -19,7 +32,7 @@ const readMediumZip = ({content, zipPath, options, skippedFileCount}) => {
|
|
|
19
32
|
// Skip if not matched above, and report skipped files if `--verbose`
|
|
20
33
|
} else if (/.html$/.test(entryName)) {
|
|
21
34
|
if (options.verbose) {
|
|
22
|
-
|
|
35
|
+
debug(`Skipped: ${entryName}`);
|
|
23
36
|
}
|
|
24
37
|
skippedFileCount += 1;
|
|
25
38
|
}
|
|
@@ -61,7 +74,11 @@ export default (zipPath, options) => {
|
|
|
61
74
|
skippedFileCount = zipContent.skippedFileCount;
|
|
62
75
|
}
|
|
63
76
|
|
|
64
|
-
|
|
77
|
+
debug(`Skipped files: ${skippedFileCount}`);
|
|
65
78
|
|
|
66
79
|
return content;
|
|
67
80
|
};
|
|
81
|
+
|
|
82
|
+
export {
|
|
83
|
+
contentStats
|
|
84
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/mg-medium-export",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"description": "tbc",
|
|
5
5
|
"repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-medium-export",
|
|
6
6
|
"author": "Ghost Foundation",
|
|
@@ -21,15 +21,16 @@
|
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"eslint": "8.
|
|
25
|
-
"jest": "29.3
|
|
26
|
-
"jest-extended": "3.2.
|
|
24
|
+
"eslint": "8.35.0",
|
|
25
|
+
"jest": "29.4.3",
|
|
26
|
+
"jest-extended": "3.2.4"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@tryghost/
|
|
29
|
+
"@tryghost/debug": "0.1.21",
|
|
30
|
+
"@tryghost/mg-fs-utils": "^0.12.1",
|
|
30
31
|
"@tryghost/string": "^0.2.0",
|
|
31
32
|
"cheerio": "0.22.0",
|
|
32
33
|
"date-fns": "2.29.3"
|
|
33
34
|
},
|
|
34
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "c2534e3c865cf26f7598f8f05dee5ca399c7a4f4"
|
|
35
36
|
}
|