this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refacto: move extension to remanso package

+6 -95
+2 -1
package.json
··· 17 17 "deploy:docs": "cd docs && bun run deploy", 18 18 "deploy:cli": "cd packages/cli && bun run deploy", 19 19 "deploy:remanso": "cd packages/remanso && bun run deploy", 20 - "test:cli": "cd packages/cli && bun test" 20 + "test:cli": "cd packages/cli && bun test", 21 + "test:remanso": "cd packages/remanso && bun test" 21 22 }, 22 23 "devDependencies": { 23 24 "@types/bun": "latest",
-90
packages/cli/src/commands/publish.ts
··· 28 28 } from "../lib/markdown"; 29 29 import type { BlogPost, BlobObject, StrongRef } from "../lib/types"; 30 30 import { exitOnCancel } from "../lib/prompts"; 31 - import { 32 - createNote, 33 - updateNote, 34 - deleteNote, 35 - findPostsWithStaleLinks, 36 - type NoteOptions, 37 - } from "../extensions/remanso"; 38 31 import { fileExists } from "../lib/utils"; 39 32 40 33 export const publishCommand = command({ ··· 379 372 let errorCount = 0; 380 373 let bskyPostCount = 0; 381 374 382 - const context: NoteOptions = { 383 - contentDir, 384 - imagesDir, 385 - allPosts: posts, 386 - }; 387 - 388 - // Pass 1: Create/update document records and collect note queue 389 - const noteQueue: Array<{ 390 - post: BlogPost; 391 - action: "create" | "update"; 392 - atUri: string; 393 - }> = []; 394 - 395 375 for (const { post, action } of postsToPublish) { 396 376 const trimmedContent = post.content.trim(); 397 377 const titleMatch = trimmedContent.match(/^# (.+)$/m); ··· 510 490 bskyPostRef, 511 491 }; 512 492 513 - noteQueue.push({ post, action, atUri }); 514 493 } catch (error) { 515 494 const errorMessage = 516 495 error instanceof Error ? error.message : String(error); ··· 520 499 } 521 500 } 522 501 523 - // Pass 2: Create/update Remanso notes (atUris are now available for link resolution) 524 - for (const { post, action, atUri } of noteQueue) { 525 - try { 526 - if (action === "create") { 527 - await createNote(agent, post, atUri, context); 528 - } else { 529 - await updateNote(agent, post, atUri, context); 530 - } 531 - } catch (error) { 532 - log.warn( 533 - `Failed to create note for "${post.frontmatter.title}": ${error instanceof Error ? error.message : String(error)}`, 534 - ); 535 - } 536 - } 537 - 538 - // Re-process already-published posts with stale links to newly created posts 539 - const newlyCreatedSlugs = noteQueue 540 - .filter((r) => r.action === "create") 541 - .map((r) => r.post.slug); 542 - 543 - if (newlyCreatedSlugs.length > 0) { 544 - const batchFilePaths = new Set(noteQueue.map((r) => r.post.filePath)); 545 - const stalePosts = findPostsWithStaleLinks( 546 - posts, 547 - newlyCreatedSlugs, 548 - batchFilePaths, 549 - ); 550 - 551 - for (const stalePost of stalePosts) { 552 - try { 553 - s.start(`Updating links in: ${stalePost.frontmatter.title}`); 554 - await updateNote( 555 - agent, 556 - stalePost, 557 - stalePost.frontmatter.atUri!, 558 - context, 559 - ); 560 - s.stop(`Updated links: ${stalePost.frontmatter.title}`); 561 - } catch (error) { 562 - s.stop(`Failed to update links: ${stalePost.frontmatter.title}`); 563 - log.warn( 564 - ` ${error instanceof Error ? error.message : String(error)}`, 565 - ); 566 - } 567 - } 568 - } 569 - 570 502 // Delete records for removed files 571 503 let deletedCount = 0; 572 504 for (const { filePath, atUri } of deletedEntries) { ··· 575 507 s.start(`Deleting: ${filePath}`); 576 508 await deleteRecord(ag, atUri); 577 509 578 - // Try to delete the corresponding Remanso note 579 - try { 580 - const noteAtUri = atUri.replace( 581 - "site.standard.document", 582 - "space.remanso.note", 583 - ); 584 - await deleteNote(ag, noteAtUri); 585 - } catch { 586 - // Note may not exist, ignore 587 - } 588 - 589 510 delete state.posts[filePath]; 590 511 s.stop(`Deleted: ${filePath}`); 591 512 deletedCount++; ··· 602 523 const ag = await getAgent(); 603 524 s.start(`Deleting unmatched: ${title}`); 604 525 await deleteRecord(ag, atUri); 605 - 606 - // Try to delete the corresponding Remanso note 607 - try { 608 - const noteAtUri = atUri.replace( 609 - "site.standard.document", 610 - "space.remanso.note", 611 - ); 612 - await deleteNote(ag, noteAtUri); 613 - } catch { 614 - // Note may not exist, ignore 615 - } 616 526 617 527 s.stop(`Deleted unmatched: ${title}`); 618 528 unmatchedDeletedCount++;
+2 -2
packages/cli/src/extensions/remanso.test.ts packages/remanso/src/lib/note.test.ts
··· 1 1 import { describe, expect, test } from "bun:test"; 2 - import { resolveInternalLinks, findPostsWithStaleLinks } from "./remanso"; 3 - import type { BlogPost } from "../lib/types"; 2 + import { resolveInternalLinks, findPostsWithStaleLinks } from "./note"; 3 + import type { BlogPost } from "../../../cli/src/lib/types"; 4 4 5 5 function makePost( 6 6 slug: string,
+1 -1
packages/cli/src/extensions/remanso.ts packages/remanso/src/lib/note.ts
··· 2 2 import * as fs from "node:fs/promises"; 3 3 import * as path from "node:path"; 4 4 import mimeTypes from "mime-types"; 5 - import type { BlogPost, BlobObject } from "../lib/types"; 5 + import type { BlogPost, BlobObject } from "../../../cli/src/lib/types"; 6 6 7 7 const LEXICON = "space.remanso.note"; 8 8 const MAX_CONTENT = 10000;
+1 -1
packages/remanso/src/commands/publish.ts
··· 35 35 deleteNote, 36 36 findPostsWithStaleLinks, 37 37 type NoteOptions, 38 - } from "../../../cli/src/extensions/remanso"; 38 + } from "../lib/note"; 39 39 40 40 async function fileExists(filePath: string): Promise<boolean> { 41 41 try {