diff --git a/package.json b/package.json index 88725e0..521c7e9 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "deploy:docs": "cd docs && bun run deploy", "deploy:cli": "cd packages/cli && bun run deploy", "deploy:remanso": "cd packages/remanso && bun run deploy", - "test:cli": "cd packages/cli && bun test" + "test:cli": "cd packages/cli && bun test", + "test:remanso": "cd packages/remanso && bun test" }, "devDependencies": { "@types/bun": "latest", diff --git a/packages/cli/src/commands/publish.ts b/packages/cli/src/commands/publish.ts index 6734ec8..8b903ea 100644 --- a/packages/cli/src/commands/publish.ts +++ b/packages/cli/src/commands/publish.ts @@ -28,13 +28,6 @@ import { } from "../lib/markdown"; import type { BlogPost, BlobObject, StrongRef } from "../lib/types"; import { exitOnCancel } from "../lib/prompts"; -import { - createNote, - updateNote, - deleteNote, - findPostsWithStaleLinks, - type NoteOptions, -} from "../extensions/remanso"; import { fileExists } from "../lib/utils"; export const publishCommand = command({ @@ -379,19 +372,6 @@ export const publishCommand = command({ let errorCount = 0; let bskyPostCount = 0; - const context: NoteOptions = { - contentDir, - imagesDir, - allPosts: posts, - }; - - // Pass 1: Create/update document records and collect note queue - const noteQueue: Array<{ - post: BlogPost; - action: "create" | "update"; - atUri: string; - }> = []; - for (const { post, action } of postsToPublish) { const trimmedContent = post.content.trim(); const titleMatch = trimmedContent.match(/^# (.+)$/m); @@ -510,7 +490,6 @@ export const publishCommand = command({ bskyPostRef, }; - noteQueue.push({ post, action, atUri }); } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); @@ -520,53 +499,6 @@ export const publishCommand = command({ } } - // Pass 2: Create/update Remanso notes (atUris are now available for link resolution) - for (const { post, action, atUri } of noteQueue) { - try { - if (action === "create") { - await createNote(agent, post, atUri, context); - } else { - await updateNote(agent, post, atUri, context); - } - } catch (error) { - log.warn( - `Failed to create note for "${post.frontmatter.title}": ${error instanceof Error ? error.message : String(error)}`, - ); - } - } - - // Re-process already-published posts with stale links to newly created posts - const newlyCreatedSlugs = noteQueue - .filter((r) => r.action === "create") - .map((r) => r.post.slug); - - if (newlyCreatedSlugs.length > 0) { - const batchFilePaths = new Set(noteQueue.map((r) => r.post.filePath)); - const stalePosts = findPostsWithStaleLinks( - posts, - newlyCreatedSlugs, - batchFilePaths, - ); - - for (const stalePost of stalePosts) { - try { - s.start(`Updating links in: ${stalePost.frontmatter.title}`); - await updateNote( - agent, - stalePost, - stalePost.frontmatter.atUri!, - context, - ); - s.stop(`Updated links: ${stalePost.frontmatter.title}`); - } catch (error) { - s.stop(`Failed to update links: ${stalePost.frontmatter.title}`); - log.warn( - ` ${error instanceof Error ? error.message : String(error)}`, - ); - } - } - } - // Delete records for removed files let deletedCount = 0; for (const { filePath, atUri } of deletedEntries) { @@ -575,17 +507,6 @@ export const publishCommand = command({ s.start(`Deleting: ${filePath}`); await deleteRecord(ag, atUri); - // Try to delete the corresponding Remanso note - try { - const noteAtUri = atUri.replace( - "site.standard.document", - "space.remanso.note", - ); - await deleteNote(ag, noteAtUri); - } catch { - // Note may not exist, ignore - } - delete state.posts[filePath]; s.stop(`Deleted: ${filePath}`); deletedCount++; @@ -603,17 +524,6 @@ export const publishCommand = command({ s.start(`Deleting unmatched: ${title}`); await deleteRecord(ag, atUri); - // Try to delete the corresponding Remanso note - try { - const noteAtUri = atUri.replace( - "site.standard.document", - "space.remanso.note", - ); - await deleteNote(ag, noteAtUri); - } catch { - // Note may not exist, ignore - } - s.stop(`Deleted unmatched: ${title}`); unmatchedDeletedCount++; } catch (error) { diff --git a/packages/remanso/src/commands/publish.ts b/packages/remanso/src/commands/publish.ts index 6587f29..fa79b4a 100644 --- a/packages/remanso/src/commands/publish.ts +++ b/packages/remanso/src/commands/publish.ts @@ -35,7 +35,7 @@ import { deleteNote, findPostsWithStaleLinks, type NoteOptions, -} from "../../../cli/src/extensions/remanso"; +} from "../lib/note"; async function fileExists(filePath: string): Promise { try { diff --git a/packages/cli/src/extensions/remanso.test.ts b/packages/remanso/src/lib/note.test.ts similarity index 98% rename from packages/cli/src/extensions/remanso.test.ts rename to packages/remanso/src/lib/note.test.ts index 9627c17..d4884a1 100644 --- a/packages/cli/src/extensions/remanso.test.ts +++ b/packages/remanso/src/lib/note.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from "bun:test"; -import { resolveInternalLinks, findPostsWithStaleLinks } from "./remanso"; -import type { BlogPost } from "../lib/types"; +import { resolveInternalLinks, findPostsWithStaleLinks } from "./note"; +import type { BlogPost } from "../../../cli/src/lib/types"; function makePost( slug: string, diff --git a/packages/cli/src/extensions/remanso.ts b/packages/remanso/src/lib/note.ts similarity index 99% rename from packages/cli/src/extensions/remanso.ts rename to packages/remanso/src/lib/note.ts index 14caa72..9f8a306 100644 --- a/packages/cli/src/extensions/remanso.ts +++ b/packages/remanso/src/lib/note.ts @@ -2,7 +2,7 @@ import type { Agent } from "@atproto/api"; import * as fs from "node:fs/promises"; import * as path from "node:path"; import mimeTypes from "mime-types"; -import type { BlogPost, BlobObject } from "../lib/types"; +import type { BlogPost, BlobObject } from "../../../cli/src/lib/types"; const LEXICON = "space.remanso.note"; const MAX_CONTENT = 10000;