@tryghost/mg-substack 0.8.8 → 0.8.10

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
@@ -55,10 +55,11 @@ It's possible to pass more options, in order to achieve a better migration file
55
55
  - **`-s` `--scrape`**
56
56
  - Configure scraping tasks
57
57
  - string - default: `all`
58
- - Choices: `all`, `img`, `web`, `media`, `files`, `none`
59
- - **`--sizeLimit`**
60
- - number - default: `false`
61
- - Media files larger than this size (defined in MB [i.e. `5`]) will be flagged as oversize
58
+ - Choices: `all`, `web`, `assets`, `none`
59
+ - `all`: Scrape web metadata and download assets
60
+ - `web`: Only scrape metadata from web pages
61
+ - `assets`: Only download assets (images, media, files)
62
+ - `none`: Skip all scraping tasks
62
63
  - **`-e` `--email`**
63
64
  - Provide an email domain for users e.g. `person@example.com` (Is ignored if `--useMetaAuthor` is provided)
64
65
  - bool/string - default: `false`
@@ -92,6 +93,9 @@ It's possible to pass more options, in order to achieve a better migration file
92
93
  - **`--subscribeLink`**
93
94
  - Provide a path that existing `/subscribe` anchors will link to e.g. `/join-us` or `#/portal/signup` (`#` characters need to be escaped with a `\`)
94
95
  - string - default: `#/portal/signup`
96
+ - **`--noSubscribeButtons`**
97
+ - Remove subscribe buttons and links from content (no replacement link)
98
+ - bool - default: `false`
95
99
  - **`--comments`**
96
100
  - Keep comment buttons
97
101
  - bool - default: `true`
package/lib/process.js CHANGED
@@ -561,6 +561,10 @@ const processContent = (post, siteUrl, options) => {
561
561
  }
562
562
 
563
563
  if (buttonHref === '/subscribe/') {
564
+ if (options.noSubscribeButtons) {
565
+ $html(button).remove();
566
+ return;
567
+ }
564
568
  buttonHref = options.subscribeLink || '#/portal/signup';
565
569
  }
566
570
 
@@ -621,8 +625,23 @@ const processContent = (post, siteUrl, options) => {
621
625
  }
622
626
  });
623
627
 
624
- // Replace any subscribe link on the same domain with a specific link
625
- if (options.subscribeLink) {
628
+ // Remove or replace subscribe links on the same domain
629
+ if (options.noSubscribeButtons) {
630
+ $html('a').each((i, anchor) => {
631
+ let href = $html(anchor).attr('href');
632
+ let linkRegex = new RegExp(`^(${siteUrl})?(/subscribe)(.*)`, 'gi');
633
+
634
+ if (!href) {
635
+ return;
636
+ }
637
+
638
+ let matches = href.replace(linkRegex, '$2');
639
+
640
+ if (matches === '/subscribe') {
641
+ $html(anchor).remove();
642
+ }
643
+ });
644
+ } else if (options.subscribeLink) {
626
645
  $html('a').each((i, anchor) => {
627
646
  let href = $html(anchor).attr('href');
628
647
  let linkRegex = new RegExp(`^(${siteUrl})?(/subscribe)(.*)`, 'gi');
@@ -639,8 +658,12 @@ const processContent = (post, siteUrl, options) => {
639
658
  });
640
659
  }
641
660
 
642
- // Replace any signup forms with a Portal signup button
643
- if (options.subscribeLink) {
661
+ // Remove or replace signup forms with a Portal signup button
662
+ if (options.noSubscribeButtons) {
663
+ $html('.subscription-widget-wrap, .subscription-widget-wrap-editor').each((i, div) => {
664
+ $html(div).remove();
665
+ });
666
+ } else if (options.subscribeLink) {
644
667
  $html('.subscription-widget-wrap, .subscription-widget-wrap-editor').each((i, div) => {
645
668
  const hasForm = $html(div).find('form');
646
669
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/mg-substack",
3
- "version": "0.8.8",
3
+ "version": "0.8.10",
4
4
  "repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-substack",
5
5
  "author": "Ghost Foundation",
6
6
  "license": "MIT",
@@ -21,21 +21,21 @@
21
21
  },
22
22
  "devDependencies": {
23
23
  "eslint": "8.57.0",
24
- "jest": "30.0.5",
25
- "jest-extended": "6.0.0"
24
+ "jest": "30.2.0",
25
+ "jest-extended": "7.0.0"
26
26
  },
27
27
  "dependencies": {
28
- "@tryghost/debug": "0.1.35",
28
+ "@tryghost/debug": "0.1.36",
29
29
  "@tryghost/errors": "1.3.8",
30
- "@tryghost/kg-default-cards": "10.2.3",
31
- "@tryghost/mg-fs-utils": "0.16.3",
30
+ "@tryghost/kg-default-cards": "10.2.6",
31
+ "@tryghost/mg-fs-utils": "0.16.5",
32
32
  "@tryghost/string": "0.2.21",
33
- "cheerio": "1.1.2",
33
+ "cheerio": "1.2.0",
34
34
  "he": "1.2.0",
35
35
  "html-entities": "2.6.0",
36
- "lodash": "4.17.21",
36
+ "lodash": "4.17.23",
37
37
  "simple-dom": "1.4.0",
38
38
  "srcset": "5.0.3"
39
39
  },
40
- "gitHead": "027225930710c0643603f6ae346dc76504d9bb7a"
40
+ "gitHead": "5526338b0a5aee977b735a03f490d21f60c10ebd"
41
41
  }