diff --git a/scripts/__tests__/import-linear.test.ts b/scripts/__tests__/import-linear.test.ts index 1dd23605..4e0f42f1 100644 --- a/scripts/__tests__/import-linear.test.ts +++ b/scripts/__tests__/import-linear.test.ts @@ -32,15 +32,21 @@ function makeIssue(overrides: Record = {}) { description: 'Test description', url: 'https://linear.app/team/issue/LIN-1', priority: 3, + createdAt: new Date('2024-01-02T03:04:05.000Z'), state: Promise.resolve({ name: 'In Progress' }), - labels: vi.fn().mockResolvedValue({ nodes: [{ name: 'Bug' }] }), + labels: vi.fn().mockResolvedValue({ + nodes: [{ name: 'Bug' }], + pageInfo: { hasNextPage: false, endCursor: null }, + }), comments: vi.fn().mockResolvedValue({ nodes: [ { body: 'First comment', + createdAt: new Date('2024-01-02T04:05:06.000Z'), user: Promise.resolve({ name: 'Alice' }), }, ], + pageInfo: { hasNextPage: false, endCursor: null }, }), attachments: vi.fn().mockResolvedValue({ nodes: [] }), ...overrides, @@ -57,12 +63,14 @@ function makeMockLinearClient(issues: ReturnType[] = [makeIssu } function makeMockPrisma() { - return { + const prisma = { ticket: { findFirst: vi.fn().mockResolvedValue(null), - create: vi.fn().mockImplementation(({ data }: { data: { displayId: string } }) => - Promise.resolve({ id: `ticket-${data.displayId}` }), - ), + create: vi + .fn() + .mockImplementation(({ data }: { data: { displayId: string } }) => + Promise.resolve({ id: `ticket-${data.displayId}` }), + ), }, ticketExternalLink: { findUnique: vi.fn().mockResolvedValue(null), @@ -70,10 +78,13 @@ function makeMockPrisma() { create: vi.fn().mockResolvedValue({ id: 'link-1' }), }, message: { - create: vi.fn().mockResolvedValue({ id: 'msg-1' }), + createMany: vi.fn().mockResolvedValue({ count: 1 }), }, + $transaction: vi.fn(), $disconnect: vi.fn().mockResolvedValue(undefined), }; + prisma.$transaction.mockImplementation(async (fn) => fn(prisma)); + return prisma; } // ─── Tests ───────────────────────────────────────────────────────────────── @@ -89,34 +100,44 @@ describe('importLinearIssues', () => { }); it('creates tickets with correct data', async () => { - const report = await importLinearIssues( - mockLinear as never, - mockPrisma as never, - { teamId: 'team-1', dryRun: false, since: null }, - ); + const report = await importLinearIssues(mockLinear as never, mockPrisma as never, { + teamId: 'team-1', + dryRun: false, + since: null, + }); expect(report.created).toBe(1); expect(report.failed).toBe(0); + expect(mockPrisma.$transaction).toHaveBeenCalledTimes(1); + expect(mockPrisma.$transaction).toHaveBeenCalledWith(expect.any(Function), { + timeout: 30_000, + }); // Ticket was created expect(mockPrisma.ticket.create).toHaveBeenCalledTimes(1); - const ticketData = (mockPrisma.ticket.create as ReturnType).mock.calls[0][0].data; + const ticketData = (mockPrisma.ticket.create as ReturnType).mock.calls[0][0] + .data; expect(ticketData.title).toBe('Test Issue'); expect(ticketData.description).toBe('Test description'); expect(ticketData.status).toBe('IN_PROGRESS'); expect(ticketData.priority).toBe('MEDIUM'); // priority 3 → MEDIUM + expect(ticketData.displayId).toMatch(/^TKT-[A-Z2-9]{8}$/); + expect(ticketData.createdAt).toEqual(new Date('2024-01-02T03:04:05.000Z')); // External link was created expect(mockPrisma.ticketExternalLink.create).toHaveBeenCalledTimes(1); - const linkData = (mockPrisma.ticketExternalLink.create as ReturnType).mock.calls[0][0].data; + const linkData = (mockPrisma.ticketExternalLink.create as ReturnType).mock + .calls[0][0].data; expect(linkData.plugin).toBe('linear'); expect(linkData.externalId).toBe('issue-1'); - // Comment was imported - expect(mockPrisma.message.create).toHaveBeenCalledTimes(1); - const msgData = (mockPrisma.message.create as ReturnType).mock.calls[0][0].data; + // Comments were imported in one bulk write + expect(mockPrisma.message.createMany).toHaveBeenCalledTimes(1); + const msgData = (mockPrisma.message.createMany as ReturnType).mock.calls[0][0] + .data[0]; expect(msgData.content).toBe('First comment'); expect(msgData.author).toBe('Alice'); + expect(msgData.createdAt).toEqual(new Date('2024-01-02T04:05:06.000Z')); }); it('skips already-linked issues', async () => { @@ -125,11 +146,11 @@ describe('importLinearIssues', () => { ticketId: 'existing-ticket', }); - const report = await importLinearIssues( - mockLinear as never, - mockPrisma as never, - { teamId: 'team-1', dryRun: false, since: null }, - ); + const report = await importLinearIssues(mockLinear as never, mockPrisma as never, { + teamId: 'team-1', + dryRun: false, + since: null, + }); expect(report.skipped).toBe(1); expect(report.created).toBe(0); @@ -149,40 +170,43 @@ describe('importLinearIssues', () => { ticketId: 'github-ticket-1', }); - const report = await importLinearIssues( - mockLinear as never, - mockPrisma as never, - { teamId: 'team-1', dryRun: false, since: null }, - ); + const report = await importLinearIssues(mockLinear as never, mockPrisma as never, { + teamId: 'team-1', + dryRun: false, + since: null, + }); expect(report.matched).toBe(1); expect(report.created).toBe(0); // Should create the link to the existing ticket expect(mockPrisma.ticketExternalLink.create).toHaveBeenCalledTimes(1); - const linkData = (mockPrisma.ticketExternalLink.create as ReturnType).mock.calls[0][0].data; + const linkData = (mockPrisma.ticketExternalLink.create as ReturnType).mock + .calls[0][0].data; expect(linkData.ticketId).toBe('github-ticket-1'); expect(linkData.plugin).toBe('linear'); }); it('dry-run does not write to database', async () => { - const report = await importLinearIssues( - mockLinear as never, - mockPrisma as never, - { teamId: 'team-1', dryRun: true, since: null }, - ); + const report = await importLinearIssues(mockLinear as never, mockPrisma as never, { + teamId: 'team-1', + dryRun: true, + since: null, + }); expect(report.created).toBe(1); expect(mockPrisma.ticket.create).not.toHaveBeenCalled(); expect(mockPrisma.ticketExternalLink.create).not.toHaveBeenCalled(); - expect(mockPrisma.message.create).not.toHaveBeenCalled(); + expect(mockPrisma.message.createMany).not.toHaveBeenCalled(); + expect(mockPrisma.$transaction).not.toHaveBeenCalled(); }); it('handles pagination', async () => { const issue1 = makeIssue({ id: 'issue-1', identifier: 'LIN-1' }); const issue2 = makeIssue({ id: 'issue-2', identifier: 'LIN-2' }); - mockLinear.issues = vi.fn() + mockLinear.issues = vi + .fn() .mockResolvedValueOnce({ nodes: [issue1], pageInfo: { hasNextPage: true, endCursor: 'cursor-1' }, @@ -192,24 +216,243 @@ describe('importLinearIssues', () => { pageInfo: { hasNextPage: false, endCursor: null }, }); - const report = await importLinearIssues( - mockLinear as never, - mockPrisma as never, - { teamId: 'team-1', dryRun: false, since: null }, - ); + const report = await importLinearIssues(mockLinear as never, mockPrisma as never, { + teamId: 'team-1', + dryRun: false, + since: null, + }); expect(report.created).toBe(2); expect(mockLinear.issues).toHaveBeenCalledTimes(2); }); + it('uses random display IDs instead of the sequential counter', async () => { + mockPrisma.ticket.findFirst.mockResolvedValue({ displayId: 'TKT-K7QX2M9P' }); + + await importLinearIssues(mockLinear as never, mockPrisma as never, { + teamId: 'team-1', + dryRun: false, + since: null, + }); + + const ticketData = (mockPrisma.ticket.create as ReturnType).mock.calls[0][0] + .data; + expect(ticketData.displayId).toMatch(/^TKT-[A-Z2-9]{8}$/); + expect(mockPrisma.ticket.findFirst).not.toHaveBeenCalled(); + }); + + it('wraps ticket, link and comments in one transaction', async () => { + mockPrisma.ticketExternalLink.create.mockRejectedValue(new Error('link write failed')); + + const report = await importLinearIssues(mockLinear as never, mockPrisma as never, { + teamId: 'team-1', + dryRun: false, + since: null, + }); + + expect(report.failed).toBe(1); + expect(report.errors[0].message).toBe('link write failed'); + expect(mockPrisma.$transaction).toHaveBeenCalledTimes(1); + expect(mockPrisma.ticket.create).toHaveBeenCalledTimes(1); + expect(mockPrisma.message.createMany).not.toHaveBeenCalled(); + }); + + it('stops when Linear reports another issue page without a cursor', async () => { + mockLinear.issues.mockResolvedValue({ + nodes: [], + pageInfo: { hasNextPage: true, endCursor: null }, + }); + + await expect( + importLinearIssues(mockLinear as never, mockPrisma as never, { + teamId: 'team-1', + dryRun: false, + since: null, + }), + ).rejects.toThrow('endCursor'); + expect(mockLinear.issues).toHaveBeenCalledTimes(1); + }); + + it('stops when Linear repeats an issue cursor', async () => { + mockLinear.issues.mockResolvedValue({ + nodes: [], + pageInfo: { hasNextPage: true, endCursor: 'same-cursor' }, + }); + + await expect( + importLinearIssues(mockLinear as never, mockPrisma as never, { + teamId: 'team-1', + dryRun: false, + since: null, + }), + ).rejects.toThrow('non-advancing endCursor'); + expect(mockLinear.issues).toHaveBeenCalledTimes(2); + }); + + it('imports every page of labels and comments', async () => { + const issue = makeIssue({ + labels: vi + .fn() + .mockResolvedValueOnce({ + nodes: [{ name: 'Bug' }], + pageInfo: { hasNextPage: true, endCursor: 'label-cursor' }, + }) + .mockResolvedValueOnce({ + nodes: [{ name: 'Feature' }], + pageInfo: { hasNextPage: false, endCursor: null }, + }), + comments: vi + .fn() + .mockResolvedValueOnce({ + nodes: [ + { + body: 'First comment', + createdAt: new Date('2024-01-02T04:05:06.000Z'), + user: Promise.resolve({ name: 'Alice' }), + }, + ], + pageInfo: { hasNextPage: true, endCursor: 'comment-cursor' }, + }) + .mockResolvedValueOnce({ + nodes: [ + { + body: 'Second comment', + createdAt: new Date('2024-01-02T05:06:07.000Z'), + user: Promise.resolve({ name: 'Bob' }), + }, + ], + pageInfo: { hasNextPage: false, endCursor: null }, + }), + }); + mockLinear = makeMockLinearClient([issue]); + + const report = await importLinearIssues(mockLinear as never, mockPrisma as never, { + teamId: 'team-1', + dryRun: false, + since: null, + }); + + expect(report.created).toBe(1); + expect(issue.labels).toHaveBeenNthCalledWith(1, { first: 50, after: undefined }); + expect(issue.labels).toHaveBeenNthCalledWith(2, { first: 50, after: 'label-cursor' }); + expect(issue.comments).toHaveBeenNthCalledWith(1, { first: 50, after: undefined }); + expect(issue.comments).toHaveBeenNthCalledWith(2, { first: 50, after: 'comment-cursor' }); + expect(mockPrisma.message.createMany).toHaveBeenCalledTimes(1); + expect(mockPrisma.message.createMany).toHaveBeenCalledWith({ + data: [ + expect.objectContaining({ content: 'First comment', author: 'Alice' }), + expect.objectContaining({ content: 'Second comment', author: 'Bob' }), + ], + }); + + const ticketData = (mockPrisma.ticket.create as ReturnType).mock.calls[0][0] + .data; + expect(ticketData.additionalInfo.tags).toEqual(['Bug', 'Feature']); + }); + + it('fails the issue when a comment page has no cursor', async () => { + const issue = makeIssue({ + comments: vi.fn().mockResolvedValue({ + nodes: [], + pageInfo: { hasNextPage: true, endCursor: null }, + }), + }); + mockLinear = makeMockLinearClient([issue]); + + const report = await importLinearIssues(mockLinear as never, mockPrisma as never, { + teamId: 'team-1', + dryRun: false, + since: null, + }); + + expect(report.failed).toBe(1); + expect(report.errors[0].message).toContain('endCursor'); + expect(mockPrisma.$transaction).not.toHaveBeenCalled(); + }); + + it('fails the issue when a label cursor does not advance', async () => { + const issue = makeIssue({ + labels: vi.fn().mockResolvedValue({ + nodes: [], + pageInfo: { hasNextPage: true, endCursor: 'same-label-cursor' }, + }), + }); + mockLinear = makeMockLinearClient([issue]); + + const report = await importLinearIssues(mockLinear as never, mockPrisma as never, { + teamId: 'team-1', + dryRun: false, + since: null, + }); + + expect(report.failed).toBe(1); + expect(report.errors[0].message).toContain('non-advancing endCursor'); + expect(issue.labels).toHaveBeenCalledTimes(2); + expect(mockPrisma.$transaction).not.toHaveBeenCalled(); + }); + + it('resolves comment authors sequentially and reuses repeated authors', async () => { + let active = 0; + let maxActive = 0; + let aliceFetches = 0; + const userPromise = (name: string) => { + active++; + maxActive = Math.max(maxActive, active); + if (name === 'Alice') aliceFetches++; + return Promise.resolve({ name }).finally(() => { + active--; + }); + }; + const issue = makeIssue({ + comments: vi.fn().mockResolvedValue({ + nodes: [ + { + body: 'First', + createdAt: new Date('2024-01-02T04:05:06.000Z'), + userId: 'alice', + get user() { + return userPromise('Alice'); + }, + }, + { + body: 'Second', + createdAt: new Date('2024-01-02T05:06:07.000Z'), + userId: 'alice', + get user() { + return userPromise('Alice'); + }, + }, + ], + pageInfo: { hasNextPage: false, endCursor: null }, + }), + }); + mockLinear = makeMockLinearClient([issue]); + + const report = await importLinearIssues(mockLinear as never, mockPrisma as never, { + teamId: 'team-1', + dryRun: false, + since: null, + }); + + expect(report.created).toBe(1); + expect(maxActive).toBe(1); + expect(aliceFetches).toBe(1); + expect(mockPrisma.message.createMany).toHaveBeenCalledWith({ + data: [ + expect.objectContaining({ author: 'Alice', content: 'First' }), + expect.objectContaining({ author: 'Alice', content: 'Second' }), + ], + }); + }); + it('counts failures and continues', async () => { mockPrisma.ticket.create = vi.fn().mockRejectedValue(new Error('DB error')); - const report = await importLinearIssues( - mockLinear as never, - mockPrisma as never, - { teamId: 'team-1', dryRun: false, since: null }, - ); + const report = await importLinearIssues(mockLinear as never, mockPrisma as never, { + teamId: 'team-1', + dryRun: false, + since: null, + }); expect(report.failed).toBe(1); expect(report.errors).toHaveLength(1); @@ -219,11 +462,11 @@ describe('importLinearIssues', () => { it('passes since filter to Linear API', async () => { const sinceDate = new Date('2024-06-01'); - await importLinearIssues( - mockLinear as never, - mockPrisma as never, - { teamId: 'team-1', dryRun: false, since: sinceDate }, - ); + await importLinearIssues(mockLinear as never, mockPrisma as never, { + teamId: 'team-1', + dryRun: false, + since: sinceDate, + }); expect(mockLinear.issues).toHaveBeenCalledWith( expect.objectContaining({ diff --git a/scripts/import-linear.ts b/scripts/import-linear.ts index d336aef2..94bc90da 100644 --- a/scripts/import-linear.ts +++ b/scripts/import-linear.ts @@ -17,6 +17,7 @@ import { createLinearPriorityMap, createLinearLabelMapper, } from '../packages/outpost/shared/src/sync/index.js'; +import { generateTicketId } from '../packages/outpost/shared/src/utils.js'; // ─── Types ──────────────────────────────────────────────────────────────── @@ -72,25 +73,44 @@ function parseArgs(argv: string[]): CliArgs { return args; } -// ─── Display ID Generator ───────────────────────────────────────────────── +// ─── Pagination ──────────────────────────────────────────────────────────── -let displayIdCounter = 0; +function requireAdvancingCursor( + pageInfo: { hasNextPage: boolean; endCursor?: string | null }, + seenCursors: Set, + context: string, +): string | undefined { + if (!pageInfo.hasNextPage) return undefined; + if (!pageInfo.endCursor) { + throw new Error(`Linear returned hasNextPage=true without an endCursor ${context}`); + } + if (seenCursors.has(pageInfo.endCursor)) { + throw new Error(`Linear returned a non-advancing endCursor ${context}`); + } + seenCursors.add(pageInfo.endCursor); + return pageInfo.endCursor; +} -async function nextDisplayId(prisma: PrismaClient): Promise { - if (displayIdCounter === 0) { - const latest = await (prisma.ticket as { findFirst: (args: Record) => Promise<{ displayId: string } | null> }).findFirst({ - orderBy: { createdAt: 'desc' }, - select: { displayId: true }, - }); - if (latest) { - const num = parseInt(latest.displayId.replace('TKT-', ''), 10); - displayIdCounter = isNaN(num) ? 1000 : num; - } else { - displayIdCounter = 1000; +async function fetchAllPages( + fetchPage: (after?: string) => Promise<{ + nodes: T[]; + pageInfo: { hasNextPage: boolean; endCursor?: string | null }; + }>, +): Promise { + const items: T[] = []; + const seenCursors = new Set(); + let after: string | undefined; + + while (true) { + const page = await fetchPage(after); + items.push(...page.nodes); + + const nextCursor = requireAdvancingCursor(page.pageInfo, seenCursors, 'while paginating'); + if (nextCursor === undefined) { + return items; } + after = nextCursor; } - displayIdCounter++; - return `TKT-${String(displayIdCounter).padStart(4, '0')}`; } // ─── Import Logic ───────────────────────────────────────────────────────── @@ -118,6 +138,7 @@ export async function importLinearIssues( // Paginate through all issues let hasMore = true; let afterCursor: string | undefined; + const seenIssueCursors = new Set(); while (hasMore) { const issuesPage = await linearClient.issues({ @@ -129,12 +150,16 @@ export async function importLinearIssues( after: afterCursor, }); + const nextIssueCursor = requireAdvancingCursor( + issuesPage.pageInfo, + seenIssueCursors, + 'while listing issues', + ); + for (const issue of issuesPage.nodes) { try { // Check if this issue is already linked - const existingLink = await (prisma.ticketExternalLink as { - findUnique: (args: Record) => Promise<{ id: string; ticketId: string } | null>; - }).findUnique({ + const existingLink = await prisma.ticketExternalLink.findUnique({ where: { plugin_externalId: { plugin: 'linear', @@ -145,7 +170,9 @@ export async function importLinearIssues( if (existingLink) { report.skipped++; - console.log(` SKIP ${issue.identifier}: already linked to ${existingLink.ticketId}`); + console.log( + ` SKIP ${issue.identifier}: already linked to ${existingLink.ticketId}`, + ); continue; } @@ -157,9 +184,7 @@ export async function importLinearIssues( const url = attachment.url; if (url && /github\.com\/.*\/(issues|pull)\/\d+/.test(url)) { // Try to find an existing ticket linked to this GitHub URL - const githubLink = await (prisma.ticketExternalLink as { - findFirst: (args: Record) => Promise<{ ticketId: string } | null>; - }).findFirst({ + const githubLink = await prisma.ticketExternalLink.findFirst({ where: { plugin: 'github', externalUrl: url, @@ -175,9 +200,7 @@ export async function importLinearIssues( if (matchedTicketId) { // Cross-reference match: link to existing ticket if (!args.dryRun) { - await (prisma.ticketExternalLink as { - create: (args: Record) => Promise; - }).create({ + await prisma.ticketExternalLink.create({ data: { ticketId: matchedTicketId, plugin: 'linear', @@ -198,71 +221,111 @@ export async function importLinearIssues( const outpostPriority = priorityMap.toOutpost(String(issue.priority)); // Resolve labels - const issueLabels = await issue.labels(); - const labelNames = issueLabels.nodes.map((l: { name: string }) => l.name); + const issueLabels = await fetchAllPages((after) => + issue.labels({ first: 50, after }), + ); + const labelNames = issueLabels.map((label) => label.name); const outpostTags = labelMapper.toOutpost(labelNames); if (args.dryRun) { - console.log(` DRY-RUN ${issue.identifier}: would create ticket (${outpostStatus}, ${outpostPriority})`); + console.log( + ` DRY-RUN ${issue.identifier}: would create ticket (${outpostStatus}, ${outpostPriority})`, + ); report.created++; continue; } - // Create the Outpost ticket - const displayId = await nextDisplayId(prisma); - const ticket = await (prisma.ticket as { - create: (args: Record) => Promise<{ id: string }>; - }).create({ - data: { - displayId, - title: issue.title, - description: issue.description ?? '', - status: outpostStatus, - priority: outpostPriority, - type: 'OTHER', - source: 'LINEAR', - internalTracker: 'linear', - internalId: issue.id, - internalUrl: issue.url, - additionalInfo: { - linearIdentifier: issue.identifier, - linearUrl: issue.url, - tags: outpostTags, - }, - }, - }); - - // Create the external link - await (prisma.ticketExternalLink as { - create: (args: Record) => Promise; - }).create({ - data: { - ticketId: ticket.id, - plugin: 'linear', - externalId: issue.id, - externalUrl: issue.url, - metadata: { identifier: issue.identifier }, - }, - }); - - // Import comments - const comments = await issue.comments(); - for (const comment of comments.nodes) { - const authorUser = await comment.user; - await (prisma.message as { - create: (args: Record) => Promise; - }).create({ - data: { - ticketId: ticket.id, - author: authorUser?.name ?? 'Unknown', - content: comment.body, - type: 'USER', - }, + // Fetch every comment before opening the transaction, so network + // calls never keep a database write lock open. + const comments = await fetchAllPages((after) => + issue.comments({ first: 50, after }), + ); + const commentRows: Array<{ + author: string; + content: string; + createdAt: Date; + }> = []; + const authorNames = new Map(); + for (const comment of comments) { + let author = 'Unknown'; + if (comment.userId) { + const cached = authorNames.get(comment.userId); + if (cached !== undefined) { + author = cached; + } else { + const authorUser = await comment.user; + author = authorUser?.name ?? 'Unknown'; + authorNames.set(comment.userId, author); + } + } else { + const authorUser = await comment.user; + author = authorUser?.name ?? 'Unknown'; + } + commentRows.push({ + author, + content: comment.body, + createdAt: comment.createdAt, }); } + // Keep the ticket, its Linear link and its comments atomic. A + // failed link or comment write must not leave a ticket that a + // rerun would duplicate. + const displayId = generateTicketId(); + await prisma.$transaction( + async (tx) => { + const ticket = await tx.ticket.create({ + data: { + displayId, + title: issue.title, + description: issue.description ?? '', + status: outpostStatus, + priority: outpostPriority, + type: 'OTHER', + source: 'LINEAR', + internalTracker: 'linear', + internalId: issue.id, + internalUrl: issue.url, + createdAt: issue.createdAt, + additionalInfo: { + linearIdentifier: issue.identifier, + linearUrl: issue.url, + tags: outpostTags, + }, + }, + }); + + await tx.ticketExternalLink.create({ + data: { + ticketId: ticket.id, + plugin: 'linear', + externalId: issue.id, + externalUrl: issue.url, + metadata: { identifier: issue.identifier }, + }, + }); + + if (commentRows.length > 0) { + await tx.message.createMany({ + data: commentRows.map((row) => ({ + ticketId: ticket.id, + author: row.author, + content: row.content, + type: 'USER' as const, + createdAt: row.createdAt, + })), + }); + } + }, + // Long threads are the reason this importer exists. Keep the + // atomic write comfortably above Prisma's five-second default. + { timeout: 30_000 }, + ); + report.created++; - console.log(` CREATE ${issue.identifier} → ${displayId} (${comments.nodes.length} comments)`); + console.log( + ` CREATE ${issue.identifier} → ${displayId} (${commentRows.length} comments)`, + ); } catch (err) { const message = err instanceof Error ? err.message : String(err); report.failed++; @@ -275,7 +338,7 @@ export async function importLinearIssues( } hasMore = issuesPage.pageInfo.hasNextPage; - afterCursor = issuesPage.pageInfo.endCursor; + afterCursor = nextIssueCursor; } return report; @@ -287,7 +350,9 @@ async function main(): Promise { const args = parseArgs(process.argv); if (!args.teamId) { - console.error('Usage: npx tsx scripts/import-linear.ts --team-id [--dry-run] [--since DATE]'); + console.error( + 'Usage: npx tsx scripts/import-linear.ts --team-id [--dry-run] [--since DATE]', + ); process.exit(1); } @@ -331,7 +396,8 @@ async function main(): Promise { } // Only run when executed directly (not when imported by tests) -const isDirectRun = process.argv[1] && import.meta.url.endsWith(process.argv[1].replace(/.*\//, '')); +const isDirectRun = + process.argv[1] && import.meta.url.endsWith(process.argv[1].replace(/.*\//, '')); if (isDirectRun) { main().catch((err) => { console.error('Fatal error:', err);