@tryghost/mg-ghost-api 0.2.18 → 0.3.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 CHANGED
@@ -39,8 +39,8 @@ It's possible to pass more options, in order to achieve a better migration file
39
39
  - **`-s` `--scrape`**
40
40
  - Configure scraping tasks
41
41
  - string - default: `all`
42
- - Choices: `all`, `img`, `web`, `media`, `none`
43
- - **`--size_limit`**
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
  - **`-I` `--info`**
package/index.js CHANGED
@@ -1,8 +1,10 @@
1
- const fetch = require('./lib/fetch');
2
- const process = require('./lib/processor');
1
+ import fetch from './lib/fetch.js';
2
+ import process from './lib/processor.js';
3
3
 
4
- module.exports.discover = fetch.discover;
4
+ const discover = fetch.discover;
5
5
 
6
- module.exports.fetch = fetch;
7
-
8
- module.exports.process = process;
6
+ export default {
7
+ discover,
8
+ fetch,
9
+ process
10
+ };
package/lib/fetch.js CHANGED
@@ -1,6 +1,6 @@
1
- const ghostAPI = require('@tryghost/admin-api');
1
+ import ghostAPI from '@tryghost/admin-api';
2
2
 
3
- module.exports.discover = async (options) => {
3
+ const discover = async (options) => {
4
4
  const requestOptions = {
5
5
  url: options.url,
6
6
  version: 'v2',
@@ -94,12 +94,12 @@ const buildTasks = (fileCache, tasks, api, type, options) => {
94
94
  }
95
95
  };
96
96
 
97
- module.exports.tasks = async (options, ctx) => {
97
+ const tasks = async (options, ctx) => {
98
98
  const {limit} = ctx.options;
99
99
 
100
- const api = await this.discover(options, {limit});
100
+ const api = await discover(options, {limit});
101
101
 
102
- const tasks = [];
102
+ const tasks = []; // eslint-disable-line no-shadow
103
103
 
104
104
  ctx.result = {
105
105
  posts: [],
@@ -112,3 +112,8 @@ module.exports.tasks = async (options, ctx) => {
112
112
 
113
113
  return tasks;
114
114
  };
115
+
116
+ export default {
117
+ discover,
118
+ tasks
119
+ };
package/lib/processor.js CHANGED
@@ -1,4 +1,4 @@
1
- module.exports.processTags = (ghTags) => {
1
+ const processTags = (ghTags) => {
2
2
  let tags = [];
3
3
 
4
4
  ghTags.forEach((tag) => {
@@ -23,16 +23,16 @@ module.exports.processTags = (ghTags) => {
23
23
  return tags;
24
24
  };
25
25
 
26
- module.exports.processPost = (ghPost) => {
26
+ const processPost = (ghPost) => {
27
27
  const post = {
28
28
  url: ghPost.url,
29
29
  data: ghPost
30
30
  };
31
31
 
32
- post.data.authors = this.processAuthors(ghPost.authors);
32
+ post.data.authors = processAuthors(ghPost.authors);
33
33
 
34
34
  if (ghPost.tags && ghPost.tags.length > 0) {
35
- post.data.tags = this.processTags(ghPost.tags);
35
+ post.data.tags = processTags(ghPost.tags);
36
36
  } else {
37
37
  delete post.data.tags;
38
38
  }
@@ -40,11 +40,11 @@ module.exports.processPost = (ghPost) => {
40
40
  return post;
41
41
  };
42
42
 
43
- module.exports.processPosts = (posts) => {
44
- return posts.map(post => this.processPost(post));
43
+ const processPosts = (posts) => {
44
+ return posts.map(post => processPost(post));
45
45
  };
46
46
 
47
- module.exports.processAuthor = (ghAuthor) => {
47
+ const processAuthor = (ghAuthor) => {
48
48
  let authorData = {
49
49
  url: ghAuthor.url,
50
50
  data: ghAuthor
@@ -59,15 +59,24 @@ module.exports.processAuthor = (ghAuthor) => {
59
59
  return authorData;
60
60
  };
61
61
 
62
- module.exports.processAuthors = (authors) => {
63
- return authors.map(author => this.processAuthor(author));
62
+ const processAuthors = (authors) => {
63
+ return authors.map(author => processAuthor(author));
64
64
  };
65
65
 
66
- module.exports.all = async ({result: input}) => {
66
+ const all = async ({result: input}) => {
67
67
  const output = {};
68
68
 
69
- output.users = this.processAuthors(input.users);
70
- output.posts = this.processPosts(input.posts, output.users);
69
+ output.users = processAuthors(input.users);
70
+ output.posts = processPosts(input.posts, output.users);
71
71
 
72
72
  return output;
73
73
  };
74
+
75
+ export default {
76
+ processTags,
77
+ processPost,
78
+ processPosts,
79
+ processAuthor,
80
+ processAuthors,
81
+ all
82
+ };
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@tryghost/mg-ghost-api",
3
- "version": "0.2.18",
3
+ "version": "0.3.1",
4
4
  "repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-ghost-api",
5
5
  "author": "Ghost Foundation",
6
6
  "license": "MIT",
7
7
  "main": "index.js",
8
+ "type": "module",
8
9
  "scripts": {
9
10
  "dev": "echo \"Implement me!\"",
10
- "test": "NODE_ENV=testing mocha ./test/**/*.test.js",
11
+ "test": "node --experimental-vm-modules $(yarn bin jest)",
11
12
  "lint": "eslint . --ext .js --cache",
12
13
  "posttest": "yarn lint"
13
14
  },
@@ -19,12 +20,12 @@
19
20
  "access": "public"
20
21
  },
21
22
  "devDependencies": {
22
- "mocha": "10.0.0",
23
- "should": "13.2.3",
24
- "sinon": "14.0.0"
23
+ "eslint": "8.25.0",
24
+ "jest": "29.1.2",
25
+ "jest-extended": "3.1.0"
25
26
  },
26
27
  "dependencies": {
27
28
  "@tryghost/admin-api": "1.13.1"
28
29
  },
29
- "gitHead": "370c7f9973e7518cfb6433e694c8fbbf022c32cf"
30
+ "gitHead": "8f119b6c370337a90aa51dfbdb8d46ed7f5d154c"
30
31
  }