@tryghost/mg-substack 0.6.3 → 0.6.5

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.
Files changed (2) hide show
  1. package/lib/mapper.js +8 -14
  2. package/package.json +6 -7
package/lib/mapper.js CHANGED
@@ -1,4 +1,3 @@
1
- import {formatISO, parseISO, isBefore, isAfter, add} from 'date-fns';
2
1
  import _ from 'lodash';
3
2
  import errors from '@tryghost/errors';
4
3
  import {slugify} from '@tryghost/string';
@@ -11,8 +10,7 @@ const mapConfig = (data, options) => {
11
10
  const {url, email, useMetaAuthor, addTag, addPlatformTag, addTypeTag, addAccessTag} = options;
12
11
  const slug = data.post_id.replace(/^(?:\d{1,10}\.)(\S*)/gm, '$1');
13
12
 
14
- // Get an ISO 8601 date - https://date-fns.org/docs/formatISO
15
- const dateNow = formatISO(new Date());
13
+ const dateNow = new Date();
16
14
 
17
15
  const typeSlug = slugify(data.type);
18
16
  const visibilitySlug = slugify(data.audience);
@@ -166,34 +164,30 @@ export default async (input, options) => {
166
164
  }
167
165
 
168
166
  if (options.postsBefore && options.postsAfter) {
169
- const startDate = parseISO(formatISO(new Date(options.postsAfter)));
170
- const endDate = add(parseISO(formatISO(new Date(options.postsBefore))), {
171
- days: 1
172
- });
167
+ const startDate = new Date(options.postsAfter);
168
+ const endDate = new Date(new Date(options.postsBefore).setDate(new Date(options.postsBefore).getDate() + 1));
173
169
  debug(`Getting posts between ${startDate} and ${endDate}`);
174
170
 
175
171
  await input.forEach((data) => {
176
- if (isAfter(parseISO(data.post_date), startDate) && isBefore(parseISO(data.post_date), endDate)) {
172
+ if ((new Date(data.post_date) > startDate) && (new Date(data.post_date) < endDate)) {
177
173
  output.posts.push(mapConfig(data, options));
178
174
  }
179
175
  });
180
176
  } else if (options.postsAfter) {
181
- const startDate = parseISO(formatISO(new Date(options.postsAfter)));
177
+ const startDate = new Date(options.postsAfter);
182
178
  debug(`Getting posts after ${startDate}`);
183
179
 
184
180
  await input.forEach((data) => {
185
- if (isAfter(parseISO(data.post_date), startDate)) {
181
+ if ((new Date(data.post_date) > startDate)) {
186
182
  output.posts.push(mapConfig(data, options));
187
183
  }
188
184
  });
189
185
  } else if (options.postsBefore) {
190
- const endDate = add(parseISO(formatISO(new Date(options.postsBefore))), {
191
- days: 1
192
- });
186
+ const endDate = new Date(new Date(options.postsBefore).setDate(new Date(options.postsBefore).getDate() + 1));
193
187
  debug(`Getting posts until ${endDate}`);
194
188
 
195
189
  await input.forEach((data) => {
196
- if (isBefore(parseISO(data.post_date), endDate)) {
190
+ if (new Date(data.post_date) < endDate) {
197
191
  output.posts.push(mapConfig(data, options));
198
192
  }
199
193
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/mg-substack",
3
- "version": "0.6.3",
3
+ "version": "0.6.5",
4
4
  "repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-substack",
5
5
  "author": "Ghost Foundation",
6
6
  "license": "MIT",
@@ -25,18 +25,17 @@
25
25
  "jest-extended": "4.0.2"
26
26
  },
27
27
  "dependencies": {
28
- "@tryghost/debug": "0.1.30",
29
- "@tryghost/errors": "1.3.2",
30
- "@tryghost/kg-default-cards": "10.0.5",
31
- "@tryghost/mg-fs-utils": "0.14.1",
28
+ "@tryghost/debug": "0.1.32",
29
+ "@tryghost/errors": "1.3.5",
30
+ "@tryghost/kg-default-cards": "10.0.9",
31
+ "@tryghost/mg-fs-utils": "0.15.0",
32
32
  "@tryghost/string": "0.2.12",
33
33
  "cheerio": "1.0.0-rc.12",
34
- "date-fns": "2.30.0",
35
34
  "he": "1.2.0",
36
35
  "html-entities": "2.5.2",
37
36
  "lodash": "4.17.21",
38
37
  "simple-dom": "1.4.0",
39
38
  "srcset": "5.0.1"
40
39
  },
41
- "gitHead": "f824cede3d1123defe3e4575536dd579984f7fe2"
40
+ "gitHead": "c1d13ccea270adcaf60dfc9d1e371ef25dfad31e"
42
41
  }