remanso-cli 0.1.1 → 0.2.0

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.
Files changed (2) hide show
  1. package/dist/index.js +59 -55
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -102413,6 +102413,12 @@ function parseFrontmatter(content, mapping) {
102413
102413
  if (draftValue !== undefined) {
102414
102414
  frontmatter.draft = draftValue === true || draftValue === "true";
102415
102415
  }
102416
+ const discoverableValue = raw.discoverable;
102417
+ if (discoverableValue === false || discoverableValue === "false") {
102418
+ frontmatter.discoverable = false;
102419
+ } else {
102420
+ frontmatter.discoverable = true;
102421
+ }
102416
102422
  frontmatter.atUri = raw.atUri;
102417
102423
  return {
102418
102424
  frontmatter,
@@ -102448,35 +102454,6 @@ function getSlugFromOptions(relativePath, rawFrontmatter, options = {}) {
102448
102454
  function slugifyTitle(title) {
102449
102455
  return (title || "").toLowerCase().replace(/\s+/g, "-").replace(/[^\w-]/g, "");
102450
102456
  }
102451
- function resolvePathTemplate(template, post) {
102452
- const publishDate = new Date(post.frontmatter.publishDate);
102453
- const year = String(publishDate.getFullYear());
102454
- const yearUTC = String(publishDate.getUTCFullYear());
102455
- const month = String(publishDate.getMonth() + 1).padStart(2, "0");
102456
- const monthUTC = String(publishDate.getUTCMonth() + 1).padStart(2, "0");
102457
- const day = String(publishDate.getDate()).padStart(2, "0");
102458
- const dayUTC = String(publishDate.getUTCDate()).padStart(2, "0");
102459
- const slugifiedTitle = slugifyTitle(post.frontmatter.title);
102460
- let result = template.replace(/\{slug\}/g, post.slug).replace(/\{year\}/g, year).replace(/\{yearUTC\}/g, yearUTC).replace(/\{month\}/g, month).replace(/\{monthUTC\}/g, monthUTC).replace(/\{day\}/g, day).replace(/\{dayUTC\}/g, dayUTC).replace(/\{title\}/g, slugifiedTitle);
102461
- result = result.replace(/\{(\w+)\}/g, (_match, field) => {
102462
- const value = post.rawFrontmatter[field];
102463
- if (value != null && typeof value === "string") {
102464
- return value;
102465
- }
102466
- return "";
102467
- });
102468
- if (!result.startsWith("/")) {
102469
- result = `/${result}`;
102470
- }
102471
- return result;
102472
- }
102473
- function resolvePostPath(post, pathPrefix, pathTemplate) {
102474
- if (pathTemplate) {
102475
- return resolvePathTemplate(pathTemplate, post);
102476
- }
102477
- const prefix = pathPrefix || "/posts";
102478
- return `${prefix}/${post.slug}`;
102479
- }
102480
102457
  async function getContentHash(content) {
102481
102458
  const encoder = new TextEncoder;
102482
102459
  const data = encoder.encode(content);
@@ -102866,7 +102843,6 @@ async function resolveImagePath(ogImage, imagesDir, contentDir) {
102866
102843
  return null;
102867
102844
  }
102868
102845
  async function createDocument(agent, post, config, coverImage) {
102869
- const postPath = resolvePostPath(post, config.pathPrefix, config.pathTemplate);
102870
102846
  const publishDate = new Date(post.frontmatter.publishDate);
102871
102847
  const trimmedContent = post.content.trim();
102872
102848
  const textContent = getTextContent(post, config.textContentField);
@@ -102876,13 +102852,10 @@ async function createDocument(agent, post, config, coverImage) {
102876
102852
  $type: "site.standard.document",
102877
102853
  title,
102878
102854
  site: config.publicationUri,
102879
- path: postPath,
102855
+ path: `/${post.slug}`,
102880
102856
  textContent: textContent.slice(0, 1e4),
102881
102857
  publishedAt: publishDate.toISOString()
102882
102858
  };
102883
- if (!config.canonicalUrlBuilder) {
102884
- record.canonicalUrl = `${config.siteUrl}${postPath}`;
102885
- }
102886
102859
  if (post.frontmatter.description) {
102887
102860
  record.description = post.frontmatter.description;
102888
102861
  }
@@ -102898,17 +102871,17 @@ async function createDocument(agent, post, config, coverImage) {
102898
102871
  record
102899
102872
  });
102900
102873
  const atUri = response.data.uri;
102901
- if (config.canonicalUrlBuilder) {
102902
- const parsed = parseAtUri(atUri);
102903
- if (parsed) {
102904
- record.canonicalUrl = config.canonicalUrlBuilder(atUri, post);
102905
- await agent.com.atproto.repo.putRecord({
102906
- repo: agent.did,
102907
- collection: parsed.collection,
102908
- rkey: parsed.rkey,
102909
- record
102910
- });
102911
- }
102874
+ const parsed = parseAtUri(atUri);
102875
+ if (parsed) {
102876
+ const finalPath = `/pub/${parsed.rkey}/${post.slug}`;
102877
+ record.path = finalPath;
102878
+ record.canonicalUrl = config.canonicalUrlBuilder ? config.canonicalUrlBuilder(atUri, post) : `${config.siteUrl}${finalPath}`;
102879
+ await agent.com.atproto.repo.putRecord({
102880
+ repo: agent.did,
102881
+ collection: parsed.collection,
102882
+ rkey: parsed.rkey,
102883
+ record
102884
+ });
102912
102885
  }
102913
102886
  return atUri;
102914
102887
  }
@@ -102918,7 +102891,7 @@ async function updateDocument(agent, post, atUri, config, coverImage) {
102918
102891
  throw new Error(`Invalid atUri format: ${atUri}`);
102919
102892
  }
102920
102893
  const [, , collection, rkey] = uriMatch;
102921
- const postPath = resolvePostPath(post, config.pathPrefix, config.pathTemplate);
102894
+ const finalPath = `/pub/${rkey}/${post.slug}`;
102922
102895
  const publishDate = new Date(post.frontmatter.publishDate);
102923
102896
  const trimmedContent = post.content.trim();
102924
102897
  const textContent = getTextContent(post, config.textContentField);
@@ -102928,10 +102901,10 @@ async function updateDocument(agent, post, atUri, config, coverImage) {
102928
102901
  $type: "site.standard.document",
102929
102902
  title,
102930
102903
  site: config.publicationUri,
102931
- path: postPath,
102904
+ path: finalPath,
102932
102905
  textContent: textContent.slice(0, 1e4),
102933
102906
  publishedAt: publishDate.toISOString(),
102934
- canonicalUrl: config.canonicalUrlBuilder ? config.canonicalUrlBuilder(atUri, post) : `${config.siteUrl}${postPath}`
102907
+ canonicalUrl: config.canonicalUrlBuilder ? config.canonicalUrlBuilder(atUri, post) : `${config.siteUrl}${finalPath}`
102935
102908
  };
102936
102909
  if (post.frontmatter.description) {
102937
102910
  record.description = post.frontmatter.description;
@@ -103424,8 +103397,14 @@ async function setSecrets() {
103424
103397
  appPassword = creds.password;
103425
103398
  R2.info(`Using stored credentials for: ${identifier}`);
103426
103399
  } else {
103427
- identifier = exitOnCancel(await Qt({ message: "ATProto handle (ATP_IDENTIFIER):", placeholder: "you.bsky.social" }));
103428
- appPassword = exitOnCancel(await Qt({ message: "App Password (ATP_APP_PASSWORD):", placeholder: "xxxx-xxxx-xxxx-xxxx" }));
103400
+ identifier = exitOnCancel(await Qt({
103401
+ message: "ATProto handle (ATP_IDENTIFIER):",
103402
+ placeholder: "you.bsky.social"
103403
+ }));
103404
+ appPassword = exitOnCancel(await Qt({
103405
+ message: "App Password (ATP_APP_PASSWORD):",
103406
+ placeholder: "xxxx-xxxx-xxxx-xxxx"
103407
+ }));
103429
103408
  }
103430
103409
  } else if (storedIds.length > 1) {
103431
103410
  const { select } = await Promise.resolve().then(() => (init_dist2(), exports_dist));
@@ -103441,13 +103420,27 @@ async function setSecrets() {
103441
103420
  identifier = creds.identifier;
103442
103421
  appPassword = creds.password;
103443
103422
  } else {
103444
- identifier = exitOnCancel(await Qt({ message: "ATProto handle (ATP_IDENTIFIER):", placeholder: "you.bsky.social" }));
103445
- appPassword = exitOnCancel(await Qt({ message: "App Password (ATP_APP_PASSWORD):", placeholder: "xxxx-xxxx-xxxx-xxxx" }));
103423
+ identifier = exitOnCancel(await Qt({
103424
+ message: "ATProto handle (ATP_IDENTIFIER):",
103425
+ placeholder: "you.bsky.social"
103426
+ }));
103427
+ appPassword = exitOnCancel(await Qt({
103428
+ message: "App Password (ATP_APP_PASSWORD):",
103429
+ placeholder: "xxxx-xxxx-xxxx-xxxx"
103430
+ }));
103446
103431
  }
103447
103432
  const s = Ie();
103448
103433
  const repoFlag = `${remote.owner}/${remote.repo}`;
103449
103434
  s.start("Setting ATP_IDENTIFIER secret...");
103450
- const r1 = spawnSync("gh", ["secret", "set", "ATP_IDENTIFIER", "--body", identifier, "--repo", repoFlag], { stdio: "pipe" });
103435
+ const r1 = spawnSync("gh", [
103436
+ "secret",
103437
+ "set",
103438
+ "ATP_IDENTIFIER",
103439
+ "--body",
103440
+ identifier,
103441
+ "--repo",
103442
+ repoFlag
103443
+ ], { stdio: "pipe" });
103451
103444
  if (r1.status === 0) {
103452
103445
  s.stop("ATP_IDENTIFIER set");
103453
103446
  } else {
@@ -103455,7 +103448,15 @@ async function setSecrets() {
103455
103448
  R2.warn(r1.stderr?.toString() || "Unknown error");
103456
103449
  }
103457
103450
  s.start("Setting ATP_APP_PASSWORD secret...");
103458
- const r2 = spawnSync("gh", ["secret", "set", "ATP_APP_PASSWORD", "--body", appPassword, "--repo", repoFlag], { stdio: "pipe" });
103451
+ const r2 = spawnSync("gh", [
103452
+ "secret",
103453
+ "set",
103454
+ "ATP_APP_PASSWORD",
103455
+ "--body",
103456
+ appPassword,
103457
+ "--repo",
103458
+ repoFlag
103459
+ ], { stdio: "pipe" });
103459
103460
  if (r2.status === 0) {
103460
103461
  s.stop("ATP_APP_PASSWORD set");
103461
103462
  } else {
@@ -104027,6 +104028,7 @@ async function buildNoteRecord(agent, post, options) {
104027
104028
  if (post.frontmatter.fontFamily) {
104028
104029
  record.fontFamily = post.frontmatter.fontFamily;
104029
104030
  }
104031
+ record.discoverable = post.frontmatter.discoverable ?? true;
104030
104032
  return record;
104031
104033
  }
104032
104034
  async function deleteNote(agent, atUri) {
@@ -104487,7 +104489,9 @@ async function matchesPDS(localPost, doc, agent) {
104487
104489
  rkey
104488
104490
  });
104489
104491
  const noteValue = noteResponse.data.value;
104490
- if ((localPost.frontmatter.theme || undefined) !== noteValue.theme || (localPost.frontmatter.fontSize || undefined) !== noteValue.fontSize || (localPost.frontmatter.fontFamily || undefined) !== noteValue.fontFamily) {
104492
+ const localDiscoverable = localPost.frontmatter.discoverable ?? true;
104493
+ const noteDiscoverable = noteValue.discoverable ?? true;
104494
+ if ((localPost.frontmatter.theme || undefined) !== noteValue.theme || (localPost.frontmatter.fontSize || undefined) !== noteValue.fontSize || (localPost.frontmatter.fontFamily || undefined) !== noteValue.fontFamily || localDiscoverable !== noteDiscoverable) {
104491
104495
  return false;
104492
104496
  }
104493
104497
  } catch {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remanso-cli",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "remanso": "dist/index.js"