@tryghost/mg-medium-export 0.11.13 → 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 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
- - array - default: `all`
42
- - Choices: `all`, `img`, `web`, `media`, `none`
43
- - **`--size_limit`**
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
- const readZip = require('./lib/read-zip');
2
- const process = require('./lib/process');
1
+ import readZip from './lib/read-zip.js';
2
+ import process from './lib/process.js';
3
3
 
4
- const mediumExport = module.exports = (pathToZip, options) => {
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
- }
@@ -1,4 +1,4 @@
1
- const $ = require('cheerio');
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
- module.exports = (content, post) => {
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
@@ -1,7 +1,8 @@
1
- const $ = require('cheerio');
2
- const {formatISO} = require('date-fns');
3
- const string = require('@tryghost/string');
4
- const processContent = require('./process-content');
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
- let $image = $(el);
37
- let type = $image.attr('src') === undefined ? 'data-src' : 'src';
38
- let newSrc = await this.downloadImage($image.attr(type));
39
- $image.attr(type, newSrc);
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
- module.exports = (name, html, globalUser) => {
124
+ export default (name, html, globalUser) => {
124
125
  const $post = $.load(html, {
125
126
  decodeEntities: false
126
127
  });
@@ -1,4 +1,4 @@
1
- const cheerio = require('cheerio');
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
- module.exports = (html) => {
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
- const processPost = require('./process-post');
2
- const processProfile = require('./process-profile');
1
+ import processPost from './process-post.js';
2
+ import processProfile from './process-profile.js';
3
3
 
4
- module.exports = (input) => {
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
- const fsUtils = require('@tryghost/mg-fs-utils');
2
- const ui = require('@tryghost/pretty-cli').ui;
1
+ import fsUtils from '@tryghost/mg-fs-utils';
2
+ import {ui} from '@tryghost/pretty-cli';
3
3
 
4
- module.exports = (zipPath, options) => {
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.11.13",
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": "NODE_ENV=testing mocha ./test/**/*.test.js",
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
- "mocha": "10.0.0",
24
- "should": "13.2.3",
25
- "sinon": "14.0.0"
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.9.3",
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": "eb8c218c3b133ec2babb7c1911a8792d95c7e976"
34
+ "gitHead": "35cb5c1ca6a826e1e596c4f2e209ab690fa06fa0"
34
35
  }