@tryghost/mg-json 0.12.0 → 0.14.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
@@ -16,7 +16,7 @@ or
16
16
 
17
17
  ## Develop
18
18
 
19
- This is a mono repository, managed with [lerna](https://lernajs.io/).
19
+ This is a mono repository, managed with [Nx](https://nx.dev/) and yarn workspaces.
20
20
 
21
21
  Follow the instructions for the top-level repo.
22
22
  1. `git clone` this repo & `cd` into it as usual
@@ -1,11 +1,14 @@
1
1
  import baseTemplate from './base-template.js';
2
- import stripMeta from './meta-to-ghost.js';
2
+ import stripMeta, {resetSlugs} from './meta-to-ghost.js';
3
3
  import processPostRelations from './process-post-relations.js';
4
4
  import validate from './validate.js';
5
5
  import reorderTags from './reorder-tags.js';
6
6
  import {removeEmptyUsers} from './remove-empty.js';
7
7
 
8
8
  export default async (input, options = {}, ctx) => {
9
+ // Reset module-level slug deduplication state so each call is independent
10
+ resetSlugs();
11
+
9
12
  // Construct a basic Ghost JSON template
10
13
  let output = baseTemplate();
11
14
 
@@ -23,6 +23,10 @@ const removeMeta = (resource) => {
23
23
 
24
24
  let slugs = {};
25
25
 
26
+ export const resetSlugs = () => {
27
+ slugs = {};
28
+ };
29
+
26
30
  // Ghost's post/tag slug max length (MySQL utf8mb4 index limit)
27
31
  const GHOST_SLUG_MAX = 191;
28
32
  const DEDUP_SUFFIX_LENGTH = 25; // '-' + 24-char ObjectID
@@ -108,7 +108,7 @@ export default (json) => {
108
108
 
109
109
  if (!tag) {
110
110
  tag = postTag;
111
- tag.data.id = new ObjectID();
111
+ tag.data.id = tag.data.id || new ObjectID();
112
112
  json.tags.push(tag);
113
113
  }
114
114
 
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "@tryghost/mg-json",
3
- "version": "0.12.0",
4
- "repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-json",
3
+ "version": "0.14.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+https://github.com/TryGhost/migrate.git",
7
+ "directory": "packages/mg-json"
8
+ },
5
9
  "author": "Ghost Foundation",
6
10
  "license": "MIT",
7
11
  "main": "index.js",
@@ -9,8 +13,8 @@
9
13
  "scripts": {
10
14
  "dev": "echo \"Implement me!\"",
11
15
  "test": "node --test 'test/**/*.test.js'",
12
- "lint": "eslint . --ext .js --cache",
13
- "posttest": "yarn lint"
16
+ "posttest": "yarn lint",
17
+ "lint": "eslint . --ext .js --cache"
14
18
  },
15
19
  "files": [
16
20
  "index.js",
@@ -26,8 +30,7 @@
26
30
  "@tryghost/string": "0.3.1",
27
31
  "bson-objectid": "2.0.4",
28
32
  "html-entities": "2.6.0",
29
- "lodash": "4.17.23",
33
+ "lodash": "4.18.1",
30
34
  "node-email-verifier": "4.0.0"
31
- },
32
- "gitHead": "e1680568191322d738c188f03298910aa3622735"
35
+ }
33
36
  }