@tryghost/mg-ghost-authors 0.0.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2013-2026 Ghost Foundation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # Migrate Ghost Authors
2
+
3
+ Fetch existing Ghost users and merge with migrated authors to prevent duplicate author creation during migrations.
4
+
5
+
6
+ ## Install
7
+
8
+ To use this package in your own project:
9
+
10
+ `npm install @tryghost/mg-ghost-authors --save`
11
+
12
+ or
13
+
14
+ `yarn add @tryghost/mg-ghost-authors`
15
+
16
+
17
+ ## Usage
18
+
19
+ This package provides utilities to fetch existing users from a Ghost instance and merge them with authors from a migration source. When a match is found by email address, the Ghost user's ID is used so content is attributed to the existing author rather than creating a duplicate.
20
+
21
+ ### Basic Usage
22
+
23
+ ```js
24
+ import {fetchGhostUsers, mergeUsersWithGhost} from '@tryghost/mg-ghost-authors';
25
+
26
+ // Fetch existing users from Ghost
27
+ const ghostUsers = await fetchGhostUsers({
28
+ apiUrl: 'https://example.ghost.io',
29
+ adminKey: 'your-admin-api-key'
30
+ });
31
+
32
+ // Merge with migrated users
33
+ const mergedUsers = mergeUsersWithGhost(sourceUsers, ghostUsers);
34
+ ```
35
+
36
+ ### CLI Options
37
+
38
+ When integrating into a migration source, this package exports CLI option definitions:
39
+
40
+ ```js
41
+ import {ghostAuthOptions} from '@tryghost/mg-ghost-authors';
42
+
43
+ // Spread into your command's options
44
+ const options = [
45
+ ...otherOptions,
46
+ ...ghostAuthOptions
47
+ ];
48
+ ```
49
+
50
+ This adds the following CLI options:
51
+
52
+ - **`--ghostApiUrl`**
53
+ - Ghost site URL to fetch existing users (e.g. `https://example.ghost.io`)
54
+ - string - default: `null`
55
+ - **`--ghostAdminKey`**
56
+ - Ghost Admin API key to authenticate with Ghost (format: `id:secret`)
57
+ - string - default: `null`
58
+
59
+ ### Task Integration
60
+
61
+ For use with the listr task runner:
62
+
63
+ ```js
64
+ import {createGhostUserTasks} from '@tryghost/mg-ghost-authors';
65
+
66
+ const tasks = [
67
+ // ... other tasks
68
+ ...createGhostUserTasks(options)
69
+ ];
70
+ ```
71
+
72
+
73
+ ## Develop
74
+
75
+ This is a mono repository, managed with [lerna](https://lerna.js.org).
76
+
77
+ Follow the instructions for the top-level repo.
78
+ 1. `git clone` this repo & `cd` into it as usual
79
+ 2. Run `yarn` to install top-level dependencies.
80
+
81
+
82
+ ## Test
83
+
84
+ - `yarn lint` run just eslint
85
+ - `yarn test` run lint and tests
86
+
87
+
88
+ # Copyright & License
89
+
90
+ Copyright (c) 2013-2026 Ghost Foundation - Released under the [MIT license](LICENSE).
@@ -0,0 +1,50 @@
1
+ import { fetchGhostUsers } from './lib/fetch-users.js';
2
+ import { mergeUsersWithGhost } from './lib/merge-users.js';
3
+ import type { GhostUser, FetchUsersOptions } from './lib/fetch-users.js';
4
+ import type { MigratedUser } from './lib/merge-users.js';
5
+ export { fetchGhostUsers };
6
+ export type { GhostUser, FetchUsersOptions } from './lib/fetch-users.js';
7
+ export { mergeUsersWithGhost };
8
+ export type { MigratedUser, MergeOptions } from './lib/merge-users.js';
9
+ /**
10
+ * CLI option definitions for Ghost API credentials
11
+ * These can be spread into any migration command's options array
12
+ */
13
+ export declare const ghostAuthOptions: {
14
+ type: string;
15
+ flags: string;
16
+ defaultValue: null;
17
+ desc: string;
18
+ }[];
19
+ interface GhostUserTaskOptions {
20
+ ghostApiUrl?: string;
21
+ ghostAdminKey?: string;
22
+ }
23
+ interface MigrationContext {
24
+ fileCache: FetchUsersOptions['fileCache'] & {
25
+ hasFile: (filename: string, subdir: string) => boolean;
26
+ };
27
+ ghostUsers: GhostUser[];
28
+ result: {
29
+ users?: MigratedUser[];
30
+ };
31
+ errors: Array<{
32
+ message: string;
33
+ error: unknown;
34
+ }>;
35
+ }
36
+ interface ListrTask {
37
+ output: string;
38
+ }
39
+ /**
40
+ * Creates the task runner tasks for fetching and merging Ghost users
41
+ * This can be spread into any migration source's task array after the initial data processing
42
+ *
43
+ * @param options - The options object containing ghostApiUrl and ghostAdminKey
44
+ * @returns Array of task objects for the task runner
45
+ */
46
+ export declare const createGhostUserTasks: (options: GhostUserTaskOptions) => {
47
+ title: string;
48
+ skip: () => boolean;
49
+ task: (ctx: MigrationContext, task: ListrTask) => Promise<void>;
50
+ }[];
package/build/index.js ADDED
@@ -0,0 +1,60 @@
1
+ import { fetchGhostUsers } from './lib/fetch-users.js';
2
+ import { mergeUsersWithGhost } from './lib/merge-users.js';
3
+ export { fetchGhostUsers };
4
+ export { mergeUsersWithGhost };
5
+ /**
6
+ * CLI option definitions for Ghost API credentials
7
+ * These can be spread into any migration command's options array
8
+ */
9
+ export const ghostAuthOptions = [
10
+ {
11
+ type: 'string',
12
+ flags: '--ghostApiUrl',
13
+ defaultValue: null,
14
+ desc: 'Ghost site URL to fetch existing users (e.g. https://example.ghost.io)'
15
+ },
16
+ {
17
+ type: 'string',
18
+ flags: '--ghostAdminKey',
19
+ defaultValue: null,
20
+ desc: 'Ghost Admin API key to authenticate with Ghost (format: id:secret)'
21
+ }
22
+ ];
23
+ /**
24
+ * Creates the task runner tasks for fetching and merging Ghost users
25
+ * This can be spread into any migration source's task array after the initial data processing
26
+ *
27
+ * @param options - The options object containing ghostApiUrl and ghostAdminKey
28
+ * @returns Array of task objects for the task runner
29
+ */
30
+ export const createGhostUserTasks = (options) => {
31
+ return [
32
+ {
33
+ title: 'Fetch existing Ghost users',
34
+ skip: () => !options.ghostApiUrl || !options.ghostAdminKey,
35
+ task: async (ctx, task) => {
36
+ try {
37
+ const wasCached = ctx.fileCache.hasFile('ghost-existing-users.json', 'tmp');
38
+ ctx.ghostUsers = await fetchGhostUsers({
39
+ apiUrl: options.ghostApiUrl,
40
+ adminKey: options.ghostAdminKey,
41
+ fileCache: ctx.fileCache
42
+ });
43
+ const cacheStatus = wasCached ? ' (from cache)' : '';
44
+ task.output = `Fetched ${ctx.ghostUsers.length} Ghost users${cacheStatus}`;
45
+ // Merge existing Ghost users with imported authors
46
+ if (ctx.ghostUsers.length > 0 && ctx.result.users) {
47
+ ctx.result.users = mergeUsersWithGhost(ctx.result.users, ctx.ghostUsers);
48
+ task.output = `Merged ${ctx.ghostUsers.length} Ghost users with imported authors`;
49
+ }
50
+ }
51
+ catch (error) {
52
+ ctx.errors.push({ message: 'Failed to fetch Ghost users', error });
53
+ // Don't throw - continue with migration without Ghost user matching
54
+ ctx.ghostUsers = [];
55
+ }
56
+ }
57
+ }
58
+ ];
59
+ };
60
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAC,mBAAmB,EAAC,MAAM,sBA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,EAAE,CAAC;wBAChD,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,mBAAmB,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;wBACzE,IAAI,CAAC,MAAM,GAAG,UAAU,GAAG,CAAC,UAAU,CAAC,MAAM,oCAAoC,CAAC;oBACtF,CAAC;gBACL,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACb,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAC,OAAO,EAAE,6BAA6B,EAAE,KAAK,EAAC,CAAC,CAAC;oBACjE,oEAAoE;oBACpE,GAAG,CAAC,UAAU,GAAG,EAAE,CAAC;gBACxB,CAAC;YACL,CAAC;SACJ;KACJ,CAAC;AACN,CAAC,CAAC"}
@@ -0,0 +1,27 @@
1
+ export interface GhostUser {
2
+ id: string;
3
+ slug: string;
4
+ name: string;
5
+ email: string;
6
+ bio?: string;
7
+ profile_image?: string;
8
+ website?: string;
9
+ roles?: Array<{
10
+ name: string;
11
+ } | string>;
12
+ }
13
+ export interface FetchUsersOptions {
14
+ apiUrl: string;
15
+ adminKey: string;
16
+ /** Optional file cache instance for caching fetched users */
17
+ fileCache?: {
18
+ hasFile: (filename: string, type: string) => boolean;
19
+ readTmpJSONFile: (filename: string) => Promise<GhostUser[]>;
20
+ writeTmpFile: (data: unknown, filename: string) => Promise<void>;
21
+ };
22
+ }
23
+ /**
24
+ * Fetch all users from an existing Ghost instance via Admin API
25
+ * Results are cached to avoid repeated API calls during re-runs
26
+ */
27
+ export declare function fetchGhostUsers(options: FetchUsersOptions): Promise<GhostUser[]>;
@@ -0,0 +1,77 @@
1
+ import GhostAdminAPI from '@tryghost/admin-api';
2
+ import errors from '@tryghost/errors';
3
+ const CACHE_FILENAME = 'ghost-existing-users.json';
4
+ /**
5
+ * Fetch all users from an existing Ghost instance via Admin API
6
+ * Results are cached to avoid repeated API calls during re-runs
7
+ */
8
+ export async function fetchGhostUsers(options) {
9
+ const { apiUrl, adminKey, fileCache } = options;
10
+ if (!apiUrl || !adminKey) {
11
+ return [];
12
+ }
13
+ // Check cache first
14
+ if (fileCache?.hasFile(CACHE_FILENAME, 'tmp')) {
15
+ try {
16
+ const cached = await fileCache.readTmpJSONFile(CACHE_FILENAME);
17
+ return cached;
18
+ }
19
+ catch {
20
+ // If cache read fails, continue to fetch fresh data
21
+ }
22
+ }
23
+ try {
24
+ // Validate admin key format (id:secret)
25
+ const keyParts = adminKey.split(':');
26
+ if (keyParts.length !== 2 || !keyParts[0] || !keyParts[1]) {
27
+ throw new errors.IncorrectUsageError({
28
+ message: 'Invalid Admin API key format. Expected format: id:secret'
29
+ });
30
+ }
31
+ // Initialize the Ghost Admin API client
32
+ const api = new GhostAdminAPI({
33
+ url: apiUrl.endsWith('/') ? apiUrl.slice(0, -1) : apiUrl,
34
+ key: adminKey,
35
+ version: 'v5.0'
36
+ });
37
+ // Fetch all users with pagination
38
+ const allUsers = [];
39
+ let page = 1;
40
+ let hasMore = true;
41
+ while (hasMore) {
42
+ const response = await api.users.browse({
43
+ limit: 100,
44
+ page,
45
+ include: 'roles'
46
+ });
47
+ allUsers.push(...response);
48
+ // Check if there are more pages
49
+ if (response.meta?.pagination) {
50
+ hasMore = page < response.meta.pagination.pages;
51
+ page += 1;
52
+ }
53
+ else {
54
+ hasMore = false;
55
+ }
56
+ }
57
+ // Cache the users for future runs
58
+ if (fileCache) {
59
+ try {
60
+ await fileCache.writeTmpFile(allUsers, CACHE_FILENAME);
61
+ }
62
+ catch {
63
+ // Continue even if caching fails
64
+ }
65
+ }
66
+ return allUsers;
67
+ }
68
+ catch (error) {
69
+ // Log but don't throw - migrations should continue without Ghost user matching
70
+ if (error instanceof errors.IncorrectUsageError) {
71
+ throw error;
72
+ }
73
+ // For other errors (network, auth, etc.), return empty array
74
+ return [];
75
+ }
76
+ }
77
+ //# sourceMappingURL=fetch-users.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-users.js","sourceRo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EAAE,MAAM;SAClB,CAAC,CAAC;QAEH,kCAAkC;QAClC,MAAM,QAAQ,GAAgB,EAAE,CAAC;QACjC,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,IAAI,OAAO,GAAG,IAAI,CAAC;QAEnB,OAAO,OAAO,EAAE,CAAC;YACb,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC;gBACpC,KAAK,EAAE,GAAG;gBACV,IAAI;gBACJ,OAAO,EAAE,OAAO;aACnB,CAAC,CAAC;YAEH,QAAQ,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC;YAE3B,gCAAgC;YAChC,IAAI,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC;gBAC5B,OAAO,GAAG,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;gBAChD,IAAI,IAAI,CAAC,CAAC;YACd,CAAC;iBAAM,CAAC;gBACJ,OAAO,GAAG,KAAK,CAAC;YACpB,CAAC;QACL,CAAC;QAED,kCAAkC;QAClC,IAAI,SAAS,EAAE,CAAC;YACZ,IAAI,CAAC;gBACD,MAAM,SAAS,CAAC,YAAY,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;YAC3D,CAAC;YAAC,MAAM,CAAC;gBACL,iCAAiC;YACrC,CAAC;QACL,CAAC;QAED,OAAO,QAAQ,CAAC;IACpB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,+EAA+E;QAC/E,IAAI,KAAK,YAAY,MAAM,CAAC,mBAAmB,EAAE,CAAC;YAC9C,MAAM,KAAK,CAAC;QAChB,CAAC;QACD,6DAA6D;QAC7D,OAAO,EAAE,CAAC;IACd,CAAC;AACL,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { GhostUser } from './fetch-users.js';
2
+ export interface MigratedUser {
3
+ url: string;
4
+ data: {
5
+ id?: string;
6
+ slug: string;
7
+ name?: string;
8
+ email?: string;
9
+ bio?: string;
10
+ profile_image?: string;
11
+ website?: string;
12
+ roles?: string[];
13
+ };
14
+ }
15
+ export interface MergeOptions {
16
+ /** Prefer Ghost bio over source bio when both exist */
17
+ preferGhostBio?: boolean;
18
+ }
19
+ /**
20
+ * Merge migrated users with existing Ghost users by matching email addresses.
21
+ * When a match is found, the Ghost user's ID is used so content is attributed
22
+ * to the existing author rather than creating a duplicate.
23
+ *
24
+ * @param sourceUsers - Users from the source platform being migrated
25
+ * @param ghostUsers - Existing users fetched from the target Ghost instance
26
+ * @param options - Merge options
27
+ * @returns Merged user array with Ghost IDs where matches were found
28
+ */
29
+ export declare function mergeUsersWithGhost(sourceUsers: MigratedUser[], ghostUsers: GhostUser[], options?: MergeOptions): MigratedUser[];
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Clean and normalize bio text by stripping HTML and extra whitespace
3
+ */
4
+ function cleanBioText(bioHtml) {
5
+ if (!bioHtml || typeof bioHtml !== 'string') {
6
+ return undefined;
7
+ }
8
+ // Strip HTML tags
9
+ let bioText = bioHtml.replace(/<[^>]+>/g, '');
10
+ // Decode common HTML entities
11
+ bioText = bioText
12
+ .replace(/&amp;/g, '&')
13
+ .replace(/&lt;/g, '<')
14
+ .replace(/&gt;/g, '>')
15
+ .replace(/&quot;/g, '"')
16
+ .replace(/&#39;/g, '\'')
17
+ .replace(/&nbsp;/g, ' ');
18
+ // Remove extra whitespace and newlines, then trim
19
+ bioText = bioText.replace(/\s+/g, ' ').trim();
20
+ return bioText.length > 0 ? bioText : undefined;
21
+ }
22
+ /**
23
+ * Merge migrated users with existing Ghost users by matching email addresses.
24
+ * When a match is found, the Ghost user's ID is used so content is attributed
25
+ * to the existing author rather than creating a duplicate.
26
+ *
27
+ * @param sourceUsers - Users from the source platform being migrated
28
+ * @param ghostUsers - Existing users fetched from the target Ghost instance
29
+ * @param options - Merge options
30
+ * @returns Merged user array with Ghost IDs where matches were found
31
+ */
32
+ export function mergeUsersWithGhost(sourceUsers, ghostUsers, options = {}) {
33
+ if (!ghostUsers || ghostUsers.length === 0) {
34
+ return sourceUsers;
35
+ }
36
+ return sourceUsers.map((sourceUser) => {
37
+ // Try to find a matching Ghost user by email (case-insensitive)
38
+ const matchedGhostUser = ghostUsers.find((ghostUser) => {
39
+ return ghostUser.email &&
40
+ sourceUser.data.email &&
41
+ ghostUser.email.toLowerCase() === sourceUser.data.email.toLowerCase();
42
+ });
43
+ if (!matchedGhostUser) {
44
+ return sourceUser;
45
+ }
46
+ // Determine which bio to use
47
+ let bio;
48
+ if (options.preferGhostBio && matchedGhostUser.bio) {
49
+ bio = cleanBioText(matchedGhostUser.bio);
50
+ }
51
+ else if (sourceUser.data.bio) {
52
+ bio = sourceUser.data.bio; // Source bio is already cleaned by the source processor
53
+ }
54
+ else if (matchedGhostUser.bio) {
55
+ bio = cleanBioText(matchedGhostUser.bio);
56
+ }
57
+ // Extract roles from Ghost user
58
+ let roles = ['Contributor']; // Default role
59
+ if (matchedGhostUser.roles && Array.isArray(matchedGhostUser.roles) && matchedGhostUser.roles.length > 0) {
60
+ // Ghost API returns roles as objects with name property
61
+ const firstRole = matchedGhostUser.roles[0];
62
+ if (typeof firstRole === 'object' && firstRole.name) {
63
+ roles = matchedGhostUser.roles.map((r) => {
64
+ if (typeof r === 'object' && r.name) {
65
+ return r.name;
66
+ }
67
+ return String(r);
68
+ });
69
+ }
70
+ else if (typeof firstRole === 'string') {
71
+ roles = matchedGhostUser.roles;
72
+ }
73
+ }
74
+ // Return merged user - use Ghost ID/slug/name/email but prefer source data for profile fields
75
+ return {
76
+ url: sourceUser.url,
77
+ data: {
78
+ id: matchedGhostUser.id,
79
+ slug: matchedGhostUser.slug,
80
+ name: matchedGhostUser.name,
81
+ email: matchedGhostUser.email,
82
+ bio,
83
+ profile_image: sourceUser.data.profile_image || matchedGhostUser.profile_image,
84
+ website: sourceUser.data.website || matchedGhostUser.website,
85
+ roles
86
+ }
87
+ };
88
+ });
89
+ }
90
+ //# sourceMappingURL=merge-users.js.map
@@ -0,0 +1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AI,CAAC;oBAClB,CAAC;oBACD,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;gBACrB,CAAC,CAAC,CAAC;YACP,CAAC;iBAAM,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;gBACvC,KAAK,GAAG,gBAAgB,CAAC,KAAiB,CAAC;YAC/C,CAAC;QACL,CAAC;QAED,8FAA8F;QAC9F,OAAO;YACH,GAAG,EAAE,UAAU,CAAC,GAAG;YACnB,IAAI,EAAE;gBACF,EAAE,EAAE,gBAAgB,CAAC,EAAE;gBACvB,IAAI,EAAE,gBAAgB,CAAC,IAAI;gBAC3B,IAAI,EAAE,gBAAgB,CAAC,IAAI;gBAC3B,KAAK,EAAE,gBAAgB,CAAC,KAAK;gBAC7B,GAAG;gBACH,aAAa,EAAE,UAAU,CAAC,IAAI,CAAC,aAAa,IAAI,gBAAgB,CAAC,aAAa;gBAC9E,OAAO,EAAE,UAAU,CAAC,IAAI,CAAC,OAAO,IAAI,gBAAgB,CAAC,OAAO;gBAC5D,KAAK;aACR;SACJ,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,71 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { describe, it, expect } from '@jest/globals';
3
+ import { fetchGhostUsers } from '../lib/fetch-users.js';
4
+ describe('fetchGhostUsers', function () {
5
+ it('returns empty array when apiUrl is not provided', async function () {
6
+ const options = {
7
+ apiUrl: '',
8
+ adminKey: 'valid:key'
9
+ };
10
+ const result = await fetchGhostUsers(options);
11
+ expect(result).toEqual([]);
12
+ });
13
+ it('returns empty array when adminKey is not provided', async function () {
14
+ const options = {
15
+ apiUrl: 'https://example.ghost.io',
16
+ adminKey: ''
17
+ };
18
+ const result = await fetchGhostUsers(options);
19
+ expect(result).toEqual([]);
20
+ });
21
+ it('throws error for invalid admin key format', async function () {
22
+ const options = {
23
+ apiUrl: 'https://example.ghost.io',
24
+ adminKey: 'invalid-key-without-colon'
25
+ };
26
+ await expect(fetchGhostUsers(options)).rejects.toThrow('Invalid Admin API key format');
27
+ });
28
+ it('throws error for admin key with empty parts', async function () {
29
+ const options = {
30
+ apiUrl: 'https://example.ghost.io',
31
+ adminKey: ':secret'
32
+ };
33
+ await expect(fetchGhostUsers(options)).rejects.toThrow('Invalid Admin API key format');
34
+ });
35
+ it('throws error for admin key with empty id', async function () {
36
+ const options = {
37
+ apiUrl: 'https://example.ghost.io',
38
+ adminKey: 'id:'
39
+ };
40
+ await expect(fetchGhostUsers(options)).rejects.toThrow('Invalid Admin API key format');
41
+ });
42
+ it('returns cached users when available', async function () {
43
+ const cachedUsers = [
44
+ { id: 'cached-1', slug: 'john', name: 'John', email: 'john@example.com' }
45
+ ];
46
+ const mockFileCache = {
47
+ hasFile: () => true,
48
+ readTmpJSONFile: async () => cachedUsers,
49
+ writeTmpFile: async () => { }
50
+ };
51
+ const options = {
52
+ apiUrl: 'https://example.ghost.io',
53
+ adminKey: 'valid:key',
54
+ fileCache: mockFileCache
55
+ };
56
+ const result = await fetchGhostUsers(options);
57
+ expect(result).toEqual(cachedUsers);
58
+ });
59
+ it('returns empty array when API call fails', async function () {
60
+ // This test relies on the fact that an invalid URL/key combination
61
+ // will fail and return an empty array (graceful failure)
62
+ const options = {
63
+ apiUrl: 'https://invalid-url-that-does-not-exist.ghost.io',
64
+ adminKey: 'abc123def456abc123def456abc123de:1234567890abcdef1234567890abcdef'
65
+ };
66
+ const result = await fetchGhostUsers(options);
67
+ // Should return empty array on failure, not throw
68
+ expect(result).toEqual([]);
69
+ });
70
+ });
71
+ //# sourceMappingURL=fetch-users.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-users.test.js","sourceRoot":"","sources":["../../src/test/fetch-users.test.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,OAAO,EAAC,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAC,MAAM,eAAe,CAAC;AACnD,OAAO,EAAC,eAAe,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* as ghostAuthors from '../index.js';
3
+ describe('mg-ghost-authors exports', function () {
4
+ it('exports fetchGhostUsers function', function () {
5
+ expect(typeof ghostAuthors.fetchGhostUsers).toBe('function');
6
+ });
7
+ it('exports mergeUsersWithGhost function', function () {
8
+ expect(typeof ghostAuthors.mergeUsersWithGhost).toBe('function');
9
+ });
10
+ it('exports ghostAuthOptions array', function () {
11
+ expect(Array.isArray(ghostAuthors.ghostAuthOptions)).toBe(true);
12
+ expect(ghostAuthors.ghostAuthOptions.length).toBe(2);
13
+ const apiUrlOption = ghostAuthors.ghostAuthOptions.find(o => o.flags === '--ghostApiUrl');
14
+ expect(apiUrlOption).toBeDefined();
15
+ expect(apiUrlOption?.type).toBe('string');
16
+ expect(apiUrlOption?.defaultValue).toBe(null);
17
+ const adminKeyOption = ghostAuthors.ghostAuthOptions.find(o => o.flags === '--ghostAdminKey');
18
+ expect(adminKeyOption).toBeDefined();
19
+ expect(adminKeyOption?.type).toBe('string');
20
+ expect(adminKeyOption?.defaultValue).toBe(null);
21
+ });
22
+ });
23
+ //# sourceMappingURL=index.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/test/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAC,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,YAAY,MAAM,aAAa,CAAC;AAE5C,QAAQ,CAAC,0BAA0B,EAAE;IACjC,EAAE,CAAC,kCAAkC,EAAE;QACnC,MAAM,CAAC,OAAO,YAAY,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sCAAsC,EAAE;QACvC,MAAM,CAAC,OAAO,YAAY,CAAC,mBAAmB,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gCAAgC,EAAE;QACjC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChE,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAErD,MAAM,YAAY,GAAG,YAAY,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,eAAe,CAAC,CAAC;QAC1F,MAAM,CAAC,YAAY,CAAC,CAAC,WAAW,EAAE,CAAC;QACnC,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1C,MAAM,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE9C,MAAM,cAAc,GAAG,YAAY,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,iBAAiB,CAAC,CAAC;QAC9F,MAAM,CAAC,cAAc,CAAC,CAAC,WAAW,EAAE,CAAC;QACrC,MAAM,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5C,MAAM,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,272 @@
1
+ import { describe, it, expect } from '@jest/globals';
2
+ import { mergeUsersWithGhost } from '../lib/merge-users.js';
3
+ describe('mergeUsersWithGhost', function () {
4
+ it('returns source users unchanged when no Ghost users provided', function () {
5
+ const sourceUsers = [
6
+ {
7
+ url: '/author/john-doe',
8
+ data: {
9
+ slug: 'john-doe',
10
+ name: 'John Doe',
11
+ email: 'john@example.com'
12
+ }
13
+ }
14
+ ];
15
+ const result = mergeUsersWithGhost(sourceUsers, []);
16
+ expect(result).toEqual(sourceUsers);
17
+ });
18
+ it('returns source users unchanged when no email matches', function () {
19
+ const sourceUsers = [
20
+ {
21
+ url: '/author/john-doe',
22
+ data: {
23
+ slug: 'john-doe',
24
+ name: 'John Doe',
25
+ email: 'john@example.com'
26
+ }
27
+ }
28
+ ];
29
+ const ghostUsers = [
30
+ {
31
+ id: 'ghost-123',
32
+ slug: 'jane-doe',
33
+ name: 'Jane Doe',
34
+ email: 'jane@example.com'
35
+ }
36
+ ];
37
+ const result = mergeUsersWithGhost(sourceUsers, ghostUsers);
38
+ expect(result).toEqual(sourceUsers);
39
+ });
40
+ it('merges user when email matches (case-insensitive)', function () {
41
+ const sourceUsers = [
42
+ {
43
+ url: '/author/john-doe',
44
+ data: {
45
+ slug: 'john-doe',
46
+ name: 'John Doe',
47
+ email: 'JOHN@EXAMPLE.COM',
48
+ bio: 'Source bio'
49
+ }
50
+ }
51
+ ];
52
+ const ghostUsers = [
53
+ {
54
+ id: 'ghost-123',
55
+ slug: 'john-d',
56
+ name: 'John D.',
57
+ email: 'john@example.com',
58
+ bio: 'Ghost bio'
59
+ }
60
+ ];
61
+ const result = mergeUsersWithGhost(sourceUsers, ghostUsers);
62
+ expect(result.length).toBe(1);
63
+ expect(result[0].data.id).toBe('ghost-123');
64
+ expect(result[0].data.slug).toBe('john-d'); // Uses Ghost slug
65
+ expect(result[0].data.name).toBe('John D.'); // Uses Ghost name
66
+ expect(result[0].data.email).toBe('john@example.com'); // Uses Ghost email
67
+ expect(result[0].data.bio).toBe('Source bio'); // Prefers source bio by default
68
+ });
69
+ it('uses Ghost bio when source has none', function () {
70
+ const sourceUsers = [
71
+ {
72
+ url: '/author/john-doe',
73
+ data: {
74
+ slug: 'john-doe',
75
+ name: 'John Doe',
76
+ email: 'john@example.com'
77
+ }
78
+ }
79
+ ];
80
+ const ghostUsers = [
81
+ {
82
+ id: 'ghost-123',
83
+ slug: 'john-d',
84
+ name: 'John D.',
85
+ email: 'john@example.com',
86
+ bio: '<p>Ghost bio with <strong>HTML</strong></p>'
87
+ }
88
+ ];
89
+ const result = mergeUsersWithGhost(sourceUsers, ghostUsers);
90
+ expect(result[0].data.bio).toBe('Ghost bio with HTML');
91
+ });
92
+ it('prefers Ghost bio when option is set', function () {
93
+ const sourceUsers = [
94
+ {
95
+ url: '/author/john-doe',
96
+ data: {
97
+ slug: 'john-doe',
98
+ name: 'John Doe',
99
+ email: 'john@example.com',
100
+ bio: 'Source bio'
101
+ }
102
+ }
103
+ ];
104
+ const ghostUsers = [
105
+ {
106
+ id: 'ghost-123',
107
+ slug: 'john-d',
108
+ name: 'John D.',
109
+ email: 'john@example.com',
110
+ bio: 'Ghost bio'
111
+ }
112
+ ];
113
+ const result = mergeUsersWithGhost(sourceUsers, ghostUsers, { preferGhostBio: true });
114
+ expect(result[0].data.bio).toBe('Ghost bio');
115
+ });
116
+ it('extracts roles from Ghost user objects', function () {
117
+ const sourceUsers = [
118
+ {
119
+ url: '/author/john-doe',
120
+ data: {
121
+ slug: 'john-doe',
122
+ name: 'John Doe',
123
+ email: 'john@example.com'
124
+ }
125
+ }
126
+ ];
127
+ const ghostUsers = [
128
+ {
129
+ id: 'ghost-123',
130
+ slug: 'john-d',
131
+ name: 'John D.',
132
+ email: 'john@example.com',
133
+ roles: [{ name: 'Editor' }, { name: 'Author' }]
134
+ }
135
+ ];
136
+ const result = mergeUsersWithGhost(sourceUsers, ghostUsers);
137
+ expect(result[0].data.roles).toEqual(['Editor', 'Author']);
138
+ });
139
+ it('handles roles as string array', function () {
140
+ const sourceUsers = [
141
+ {
142
+ url: '/author/john-doe',
143
+ data: {
144
+ slug: 'john-doe',
145
+ name: 'John Doe',
146
+ email: 'john@example.com'
147
+ }
148
+ }
149
+ ];
150
+ const ghostUsers = [
151
+ {
152
+ id: 'ghost-123',
153
+ slug: 'john-d',
154
+ name: 'John D.',
155
+ email: 'john@example.com',
156
+ roles: ['Editor', 'Author']
157
+ }
158
+ ];
159
+ const result = mergeUsersWithGhost(sourceUsers, ghostUsers);
160
+ expect(result[0].data.roles).toEqual(['Editor', 'Author']);
161
+ });
162
+ it('defaults to Contributor role when no roles present', function () {
163
+ const sourceUsers = [
164
+ {
165
+ url: '/author/john-doe',
166
+ data: {
167
+ slug: 'john-doe',
168
+ name: 'John Doe',
169
+ email: 'john@example.com'
170
+ }
171
+ }
172
+ ];
173
+ const ghostUsers = [
174
+ {
175
+ id: 'ghost-123',
176
+ slug: 'john-d',
177
+ name: 'John D.',
178
+ email: 'john@example.com'
179
+ }
180
+ ];
181
+ const result = mergeUsersWithGhost(sourceUsers, ghostUsers);
182
+ expect(result[0].data.roles).toEqual(['Contributor']);
183
+ });
184
+ it('prefers source profile_image and website, falls back to Ghost', function () {
185
+ const sourceUsers = [
186
+ {
187
+ url: '/author/john-doe',
188
+ data: {
189
+ slug: 'john-doe',
190
+ name: 'John Doe',
191
+ email: 'john@example.com',
192
+ profile_image: 'https://source.com/john.jpg'
193
+ // No website
194
+ }
195
+ }
196
+ ];
197
+ const ghostUsers = [
198
+ {
199
+ id: 'ghost-123',
200
+ slug: 'john-d',
201
+ name: 'John D.',
202
+ email: 'john@example.com',
203
+ profile_image: 'https://ghost.com/john.jpg',
204
+ website: 'https://johndoe.com'
205
+ }
206
+ ];
207
+ const result = mergeUsersWithGhost(sourceUsers, ghostUsers);
208
+ expect(result[0].data.profile_image).toBe('https://source.com/john.jpg'); // Source preferred
209
+ expect(result[0].data.website).toBe('https://johndoe.com'); // Falls back to Ghost
210
+ });
211
+ it('handles multiple users with partial matches', function () {
212
+ const sourceUsers = [
213
+ {
214
+ url: '/author/john',
215
+ data: { slug: 'john', name: 'John', email: 'john@example.com' }
216
+ },
217
+ {
218
+ url: '/author/jane',
219
+ data: { slug: 'jane', name: 'Jane', email: 'jane@example.com' }
220
+ },
221
+ {
222
+ url: '/author/bob',
223
+ data: { slug: 'bob', name: 'Bob', email: 'bob@example.com' }
224
+ }
225
+ ];
226
+ const ghostUsers = [
227
+ {
228
+ id: 'ghost-1',
229
+ slug: 'john-existing',
230
+ name: 'John Existing',
231
+ email: 'john@example.com'
232
+ }
233
+ // Jane and Bob not in Ghost
234
+ ];
235
+ const result = mergeUsersWithGhost(sourceUsers, ghostUsers);
236
+ expect(result.length).toBe(3);
237
+ // John is matched
238
+ expect(result[0].data.id).toBe('ghost-1');
239
+ expect(result[0].data.slug).toBe('john-existing');
240
+ // Jane is unchanged
241
+ expect(result[1].data.id).toBeUndefined();
242
+ expect(result[1].data.slug).toBe('jane');
243
+ // Bob is unchanged
244
+ expect(result[2].data.id).toBeUndefined();
245
+ expect(result[2].data.slug).toBe('bob');
246
+ });
247
+ it('skips matching when source user has no email', function () {
248
+ const sourceUsers = [
249
+ {
250
+ url: '/author/john-doe',
251
+ data: {
252
+ slug: 'john-doe',
253
+ name: 'John Doe'
254
+ // No email
255
+ }
256
+ }
257
+ ];
258
+ const ghostUsers = [
259
+ {
260
+ id: 'ghost-123',
261
+ slug: 'john-d',
262
+ name: 'John D.',
263
+ email: 'john@example.com'
264
+ }
265
+ ];
266
+ const result = mergeUsersWithGhost(sourceUsers, ghostUsers);
267
+ // Should not match since source has no email
268
+ expect(result[0].data.id).toBeUndefined();
269
+ expect(result[0].data.slug).toBe('john-doe');
270
+ });
271
+ });
272
+ //# sourceMappingURL=merge-users.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-users.test.js","sourceRoot":"","sources":["../../src/test/merge-users.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAC,MAAM,eAAe,CAAC;AACnD,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAI1D,QAAQ,CAAC,qBAAqB,EAAE;IAC5B,EAAE,CAAC,6DAA6D,EAAE;QAC9D,MAAM,WAAW,GAAmB;YAChC;gBACI,GAAG,EAAE,kBAAkB;gBACvB,IAAI,EAAE;oBACF,IAAI,EA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AK,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8CAA8C,EAAE;QAC/C,MAAM,WAAW,GAAmB;YAChC;gBACI,GAAG,EAAE,kBAAkB;gBACvB,IAAI,EAAE;oBACF,IAAI,EAAE,UAAU;oBAChB,IAAI,EAAE,UAAU;oBAChB,WAAW;iBACd;aACJ;SACJ,CAAC;QAEF,MAAM,UAAU,GAAgB;YAC5B;gBACI,EAAE,EAAE,WAAW;gBACf,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,kBAAkB;aAC5B;SACJ,CAAC;QAEF,MAAM,MAAM,GAAG,mBAAmB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QAE5D,6CAA6C;QAC7C,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,aAAa,EAAE,CAAC;QAC1C,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@tryghost/mg-ghost-authors",
3
+ "version": "0.0.2",
4
+ "description": "Fetch existing Ghost users and merge with migrated authors",
5
+ "repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-ghost-authors",
6
+ "author": "Ghost Foundation",
7
+ "license": "MIT",
8
+ "type": "module",
9
+ "main": "build/index.js",
10
+ "types": "build/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "development": "./src/index.ts",
14
+ "default": "./build/index.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "build"
19
+ ],
20
+ "scripts": {
21
+ "dev": "echo \"Implement me!\"",
22
+ "build:watch": "tsc --watch --preserveWatchOutput --sourceMap",
23
+ "build": "rm -rf build && rm -rf tsconfig.tsbuildinfo && tsc --build --sourceMap",
24
+ "prepare": "yarn build",
25
+ "lint": "eslint src/ --ext .ts --cache",
26
+ "posttest": "yarn lint",
27
+ "test": "rm -rf build && yarn build --force && NODE_OPTIONS=--experimental-vm-modules c8 --src src --all --reporter text --reporter cobertura jest build/test"
28
+ },
29
+ "devDependencies": {
30
+ "@types/jest": "30.0.0",
31
+ "@typescript-eslint/eslint-plugin": "8.56.0",
32
+ "@typescript-eslint/parser": "8.56.0",
33
+ "c8": "10.1.3",
34
+ "eslint": "8.57.0",
35
+ "eslint-plugin-ghost": "3.4.4",
36
+ "jest": "30.2.0",
37
+ "typescript": "5.9.3"
38
+ },
39
+ "dependencies": {
40
+ "@tryghost/admin-api": "1.14.4",
41
+ "@tryghost/errors": "1.3.8"
42
+ },
43
+ "gitHead": "ac9a868976ef5963df7fc2426af9e298bd5d8666"
44
+ }