@tryghost/mg-chorus 0.11.2 → 0.11.3

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
@@ -89,8 +89,8 @@ pnpm dev chorus <API token>
89
89
 
90
90
  ## Test
91
91
 
92
- - `pnpm lint` run just eslint
93
- - `pnpm test` run lint and tests
92
+ - `pnpm test` runs the package tests
93
+ - Linting and formatting are run from the repo root (`pnpm lint`, `pnpm format`)
94
94
 
95
95
 
96
96
  # Copyright & License
@@ -1,26 +1,26 @@
1
- const EntryBodyList = (block) => {
1
+ const EntryBodyList = block => {
2
2
  let html = [];
3
- html.push((block.ordered) ? '<ol>' : '<ul>');
4
- block.items.forEach((item) => {
3
+ html.push(block.ordered ? '<ol>' : '<ul>');
4
+ block.items.forEach(item => {
5
5
  html.push(`<li>${item.line.html}</li>`);
6
6
  });
7
- html.push((block.ordered) ? '</ol>' : '/<ul>');
7
+ html.push(block.ordered ? '</ol>' : '/<ul>');
8
8
  return html.join('');
9
9
  };
10
10
 
11
- const EntryBodyParagraph = (block) => {
11
+ const EntryBodyParagraph = block => {
12
12
  let html = [];
13
13
  html.push(`<p>${block.contents.html}</p>`);
14
14
  return html.join('');
15
15
  };
16
16
 
17
- const EntryBodyEmbed = (block) => {
17
+ const EntryBodyEmbed = block => {
18
18
  let html = [];
19
19
  html.push(`<!--kg-card-begin: html-->${block.embed.embedHtml}<!--kg-card-end: html-->`);
20
20
  return html.join('');
21
21
  };
22
22
 
23
- const EntryBodyHeading = (block) => {
23
+ const EntryBodyHeading = block => {
24
24
  let html = [];
25
25
 
26
26
  html.push(`<h${block.level}>`);
@@ -30,13 +30,13 @@ const EntryBodyHeading = (block) => {
30
30
  return html.join('');
31
31
  };
32
32
 
33
- const EntryBodyHTML = (block) => {
33
+ const EntryBodyHTML = block => {
34
34
  let html = [];
35
35
  html.push(`<!--kg-card-begin: html-->${block.rawHtml}<!--kg-card-end: html-->`);
36
36
  return html.join('');
37
37
  };
38
38
 
39
- const EntryBodyPoll = (block) => {
39
+ const EntryBodyPoll = block => {
40
40
  let html = [];
41
41
  if (block?.poll?.title) {
42
42
  html.push(`<h3>${block.poll.title}</h3>`);
@@ -44,7 +44,7 @@ const EntryBodyPoll = (block) => {
44
44
  html.push(`<!--kg-card-begin: html-->`);
45
45
  html.push('<table>');
46
46
  html.push('<tbody>');
47
- block.poll.options.forEach((row) => {
47
+ block.poll.options.forEach(row => {
48
48
  html.push(`<tr>`);
49
49
  html.push(`<td>${row.label}</td>`);
50
50
  html.push(`<td>${row.votes}</td>`);
@@ -56,13 +56,13 @@ const EntryBodyPoll = (block) => {
56
56
  return html.join('');
57
57
  };
58
58
 
59
- const EntryBodyPullquote = (block) => {
59
+ const EntryBodyPullquote = block => {
60
60
  let html = [];
61
61
  html.push(`<blockquote class="kg-blockquote-alt">${block.quote.html}</blockquote>`);
62
62
  return html.join('');
63
63
  };
64
64
 
65
- const EntryBodyTable = (block) => {
65
+ const EntryBodyTable = block => {
66
66
  let html = [];
67
67
  if (block?.table?.title) {
68
68
  html.push(`<h3>${block.table.title}</h3>`);
@@ -70,14 +70,14 @@ const EntryBodyTable = (block) => {
70
70
  html.push(`<!--kg-card-begin: html-->`);
71
71
  html.push('<table>');
72
72
  html.push('<thead>');
73
- block.table.columns.forEach((col) => {
73
+ block.table.columns.forEach(col => {
74
74
  html.push(`<th>${col}</th>`);
75
75
  });
76
76
  html.push('</thead>');
77
77
  html.push('<tbody>');
78
- block.table.rows.forEach((row) => {
78
+ block.table.rows.forEach(row => {
79
79
  html.push(`<tr>`);
80
- row.forEach((cell) => {
80
+ row.forEach(cell => {
81
81
  html.push(`<td>${cell}</td>`);
82
82
  });
83
83
  html.push(`</tr>`);
@@ -88,10 +88,10 @@ const EntryBodyTable = (block) => {
88
88
  return html.join('');
89
89
  };
90
90
 
91
- const EntryBodyBlockquote = (block) => {
91
+ const EntryBodyBlockquote = block => {
92
92
  let html = [];
93
93
  html.push('<blockuote>');
94
- block.paragraphs.forEach((paragraph) => {
94
+ block.paragraphs.forEach(paragraph => {
95
95
  html.push(`<p>${paragraph.contents.html}</p>`);
96
96
  });
97
97
  html.push('</blockuote>');
@@ -104,7 +104,7 @@ const EntryBodyHorizontalRule = () => {
104
104
  return html.join('');
105
105
  };
106
106
 
107
- const EntryBodyRelatedList = (block) => {
107
+ const EntryBodyRelatedList = block => {
108
108
  let html = [];
109
109
  html.push('<hr>');
110
110
  html.push('<h4>Related</h4>');
@@ -117,52 +117,52 @@ const EntryBodyRelatedList = (block) => {
117
117
  return html.join('');
118
118
  };
119
119
 
120
- const jsonToHtml = (blocks) => {
120
+ const jsonToHtml = blocks => {
121
121
  let html = [];
122
122
 
123
- blocks.forEach((block) => {
123
+ blocks.forEach(block => {
124
124
  const itemType = block.__typename;
125
125
 
126
126
  switch (itemType) {
127
- case 'EntryBodyParagraph':
128
- html.push(EntryBodyParagraph(block));
129
- break;
130
- case 'EntryBodyEmbed':
131
- html.push(EntryBodyEmbed(block));
132
- break;
133
- case 'EntryBodyList':
134
- html.push(EntryBodyList(block));
135
- break;
136
- case 'EntryBodyHeading':
137
- html.push(EntryBodyHeading(block));
138
- break;
139
- case 'EntryBodyHTML':
140
- html.push(EntryBodyHTML(block));
141
- break;
142
- case 'EntryBodyPoll':
143
- html.push(EntryBodyPoll(block));
144
- break;
145
- case 'EntryBodyPullquote':
146
- html.push(EntryBodyPullquote(block));
147
- break;
148
- case 'EntryBodyTable':
149
- html.push(EntryBodyTable(block));
150
- break;
151
- case 'EntryBodyBlockquote':
152
- html.push(EntryBodyBlockquote(block));
153
- break;
154
- case 'EntryBodyHorizontalRule':
155
- html.push(EntryBodyHorizontalRule());
156
- break;
157
- case 'EntryBodyRelatedList':
158
- html.push(EntryBodyRelatedList(block));
159
- break;
160
- case 'EntryBodySidebar':
161
- case 'EntryBodyImage':
162
- case 'EntryBodyGallery':
163
- // Not used
164
- break;
165
- default:
127
+ case 'EntryBodyParagraph':
128
+ html.push(EntryBodyParagraph(block));
129
+ break;
130
+ case 'EntryBodyEmbed':
131
+ html.push(EntryBodyEmbed(block));
132
+ break;
133
+ case 'EntryBodyList':
134
+ html.push(EntryBodyList(block));
135
+ break;
136
+ case 'EntryBodyHeading':
137
+ html.push(EntryBodyHeading(block));
138
+ break;
139
+ case 'EntryBodyHTML':
140
+ html.push(EntryBodyHTML(block));
141
+ break;
142
+ case 'EntryBodyPoll':
143
+ html.push(EntryBodyPoll(block));
144
+ break;
145
+ case 'EntryBodyPullquote':
146
+ html.push(EntryBodyPullquote(block));
147
+ break;
148
+ case 'EntryBodyTable':
149
+ html.push(EntryBodyTable(block));
150
+ break;
151
+ case 'EntryBodyBlockquote':
152
+ html.push(EntryBodyBlockquote(block));
153
+ break;
154
+ case 'EntryBodyHorizontalRule':
155
+ html.push(EntryBodyHorizontalRule());
156
+ break;
157
+ case 'EntryBodyRelatedList':
158
+ html.push(EntryBodyRelatedList(block));
159
+ break;
160
+ case 'EntryBodySidebar':
161
+ case 'EntryBodyImage':
162
+ case 'EntryBodyGallery':
163
+ // Not used
164
+ break;
165
+ default:
166
166
  // console.log(`Unhandled type: ${itemType}`);
167
167
  }
168
168
  });
package/lib/processor.js CHANGED
@@ -4,7 +4,7 @@ import jsonToHtml from './json-to-html.js';
4
4
 
5
5
  const debug = debugFactory('migrate:chorus:processor');
6
6
 
7
- const processContent = (groups) => {
7
+ const processContent = groups => {
8
8
  if (!groups) {
9
9
  debug(`Post has no content`);
10
10
  return '';
@@ -63,7 +63,7 @@ const processPost = (data, options) => {
63
63
  }
64
64
 
65
65
  if (data?.source?.contributors) {
66
- data?.source?.contributors.forEach((contributor) => {
66
+ data?.source?.contributors.forEach(contributor => {
67
67
  let authorSlug = slugify(contributor.fullOrUserName);
68
68
  let authorObject = {
69
69
  url: `/author/${authorSlug}`,
@@ -91,7 +91,7 @@ const processPost = (data, options) => {
91
91
  }
92
92
 
93
93
  if (data?.source?.communityGroups) {
94
- data.source.communityGroups.forEach((tag) => {
94
+ data.source.communityGroups.forEach(tag => {
95
95
  let tagSlug = slugify(tag.name);
96
96
  let tagObject = {
97
97
  url: `migrator-added-tag-${tagSlug}`,
package/lib/read-zip.js CHANGED
@@ -19,7 +19,7 @@ const readChorusFile = ({content, entries, options, skippedFileCount}) => {
19
19
  console.log(entries, entryName, error); // eslint-disable-line no-console
20
20
  }
21
21
 
22
- // Skip if not matched above, and report skipped files if `--verbose`
22
+ // Skip if not matched above, and report skipped files if `--verbose`
23
23
  } else {
24
24
  if (options.verbose) {
25
25
  debug(`Skipped: ${entryName}`);
@@ -28,7 +28,7 @@ const readChorusFile = ({content, entries, options, skippedFileCount}) => {
28
28
  }
29
29
  });
30
30
  } else {
31
- fs.readdirSync(entries).forEach((entryName) => {
31
+ fs.readdirSync(entries).forEach(entryName => {
32
32
  if (/^Entry:.*\.json$/.test(entryName)) {
33
33
  try {
34
34
  content.posts.push({
@@ -39,7 +39,7 @@ const readChorusFile = ({content, entries, options, skippedFileCount}) => {
39
39
  console.log(entries, entryName, error); // eslint-disable-line no-console
40
40
  }
41
41
 
42
- // Skip if not matched above, and report skipped files if `--verbose`
42
+ // Skip if not matched above, and report skipped files if `--verbose`
43
43
  } else {
44
44
  if (options.verbose) {
45
45
  debug(`Skipped: ${entryName}`);
@@ -70,7 +70,7 @@ export default (entries, options) => {
70
70
  const ifIsArray = Array.isArray(entries);
71
71
 
72
72
  if (ifIsArray && entries.length > 1) {
73
- entries.forEach((file) => {
73
+ entries.forEach(file => {
74
74
  const fileContent = readChorusFile({content, entries: file, options, skippedFileCount});
75
75
  content = fileContent.content;
76
76
  skippedFileCount = fileContent.skippedFileCount;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/mg-chorus",
3
- "version": "0.11.2",
3
+ "version": "0.11.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/TryGhost/migrate.git",
@@ -17,18 +17,14 @@
17
17
  "publishConfig": {
18
18
  "access": "public"
19
19
  },
20
- "devDependencies": {
21
- "eslint": "8.57.1"
22
- },
20
+ "devDependencies": {},
23
21
  "dependencies": {
24
22
  "@tryghost/debug": "2.2.3",
25
23
  "@tryghost/string": "0.3.5",
26
- "@tryghost/mg-fs-utils": "0.26.2"
24
+ "@tryghost/mg-fs-utils": "0.26.3"
27
25
  },
28
26
  "scripts": {
29
27
  "dev": "echo \"Implement me!\"",
30
- "test": "node --test 'test/**/*.test.js'",
31
- "posttest": "pnpm lint",
32
- "lint": "eslint . --ext .js --cache"
28
+ "test": "node --test 'test/**/*.test.js'"
33
29
  }
34
30
  }