sequoia-cli 0.5.5 → 0.5.7
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/dist/components/sequoia-comments.js +201 -47
- package/dist/components/sequoia-subscribe.js +401 -104
- package/dist/index.js +212 -108
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -6,39 +6,60 @@ var __defProp = Object.defineProperty;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
function __accessProp(key) {
|
|
10
|
+
return this[key];
|
|
11
|
+
}
|
|
12
|
+
var __toESMCache_node;
|
|
13
|
+
var __toESMCache_esm;
|
|
9
14
|
var __toESM = (mod, isNodeMode, target) => {
|
|
15
|
+
var canCache = mod != null && typeof mod === "object";
|
|
16
|
+
if (canCache) {
|
|
17
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
18
|
+
var cached = cache.get(mod);
|
|
19
|
+
if (cached)
|
|
20
|
+
return cached;
|
|
21
|
+
}
|
|
10
22
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
11
23
|
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
12
24
|
for (let key of __getOwnPropNames(mod))
|
|
13
25
|
if (!__hasOwnProp.call(to, key))
|
|
14
26
|
__defProp(to, key, {
|
|
15
|
-
get: (
|
|
27
|
+
get: __accessProp.bind(mod, key),
|
|
16
28
|
enumerable: true
|
|
17
29
|
});
|
|
30
|
+
if (canCache)
|
|
31
|
+
cache.set(mod, to);
|
|
18
32
|
return to;
|
|
19
33
|
};
|
|
20
|
-
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
21
34
|
var __toCommonJS = (from) => {
|
|
22
|
-
var entry = __moduleCache.get(from), desc;
|
|
35
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
23
36
|
if (entry)
|
|
24
37
|
return entry;
|
|
25
38
|
entry = __defProp({}, "__esModule", { value: true });
|
|
26
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
39
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
40
|
+
for (var key of __getOwnPropNames(from))
|
|
41
|
+
if (!__hasOwnProp.call(entry, key))
|
|
42
|
+
__defProp(entry, key, {
|
|
43
|
+
get: __accessProp.bind(from, key),
|
|
44
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
45
|
+
});
|
|
46
|
+
}
|
|
31
47
|
__moduleCache.set(from, entry);
|
|
32
48
|
return entry;
|
|
33
49
|
};
|
|
50
|
+
var __moduleCache;
|
|
34
51
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
52
|
+
var __returnValue = (v) => v;
|
|
53
|
+
function __exportSetter(name, newValue) {
|
|
54
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
55
|
+
}
|
|
35
56
|
var __export = (target, all) => {
|
|
36
57
|
for (var name in all)
|
|
37
58
|
__defProp(target, name, {
|
|
38
59
|
get: all[name],
|
|
39
60
|
enumerable: true,
|
|
40
61
|
configurable: true,
|
|
41
|
-
set: (
|
|
62
|
+
set: __exportSetter.bind(all, name)
|
|
42
63
|
});
|
|
43
64
|
};
|
|
44
65
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
@@ -60551,17 +60572,6 @@ var require_db = __commonJS((exports, module) => {
|
|
|
60551
60572
|
};
|
|
60552
60573
|
});
|
|
60553
60574
|
|
|
60554
|
-
// ../../node_modules/.bun/mime-db@1.52.0/node_modules/mime-db/index.js
|
|
60555
|
-
var require_mime_db = __commonJS((exports, module) => {
|
|
60556
|
-
/*!
|
|
60557
|
-
* mime-db
|
|
60558
|
-
* Copyright(c) 2014 Jonathan Ong
|
|
60559
|
-
* Copyright(c) 2015-2022 Douglas Christopher Wilson
|
|
60560
|
-
* MIT Licensed
|
|
60561
|
-
*/
|
|
60562
|
-
module.exports = require_db();
|
|
60563
|
-
});
|
|
60564
|
-
|
|
60565
60575
|
// ../../node_modules/.bun/@atproto-labs+fetch@0.2.3/node_modules/@atproto-labs/fetch/dist/fetch-error.js
|
|
60566
60576
|
var require_fetch_error = __commonJS((exports) => {
|
|
60567
60577
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -78864,7 +78874,7 @@ var require_undici = __commonJS((exports, module) => {
|
|
|
78864
78874
|
exports.setGlobalDispatcher = setGlobalDispatcher;
|
|
78865
78875
|
exports.getGlobalDispatcher = getGlobalDispatcher;
|
|
78866
78876
|
var fetchImpl = require_fetch2().fetch;
|
|
78867
|
-
exports.fetch = async function
|
|
78877
|
+
exports.fetch = async function fetch2(init, options = undefined) {
|
|
78868
78878
|
try {
|
|
78869
78879
|
return await fetchImpl(init, options);
|
|
78870
78880
|
} catch (err) {
|
|
@@ -93396,6 +93406,15 @@ import * as fs from "node:fs/promises";
|
|
|
93396
93406
|
import * as path from "node:path";
|
|
93397
93407
|
var CONFIG_FILENAME = "sequoia.json";
|
|
93398
93408
|
var STATE_FILENAME = ".sequoia-state.json";
|
|
93409
|
+
var DEFAULT_PUBLISHER_CONFIG = {
|
|
93410
|
+
publicDir: "./public",
|
|
93411
|
+
outputDir: "./dist",
|
|
93412
|
+
pathPrefix: "/posts",
|
|
93413
|
+
publishContent: true,
|
|
93414
|
+
removeIndexFromSlug: false,
|
|
93415
|
+
stripDatePrefix: false,
|
|
93416
|
+
autoSync: true
|
|
93417
|
+
};
|
|
93399
93418
|
async function fileExists(filePath) {
|
|
93400
93419
|
try {
|
|
93401
93420
|
await fs.access(filePath);
|
|
@@ -93432,7 +93451,7 @@ async function loadConfig(configPath) {
|
|
|
93432
93451
|
throw new Error("contentDir is required in config");
|
|
93433
93452
|
if (!config.publicationUri)
|
|
93434
93453
|
throw new Error("publicationUri is required in config");
|
|
93435
|
-
return config;
|
|
93454
|
+
return { ...DEFAULT_PUBLISHER_CONFIG, ...config };
|
|
93436
93455
|
} catch (error) {
|
|
93437
93456
|
if (error instanceof Error && error.message.includes("required")) {
|
|
93438
93457
|
throw error;
|
|
@@ -93480,7 +93499,7 @@ function generateConfigTemplate(options) {
|
|
|
93480
93499
|
if (options.textContentField) {
|
|
93481
93500
|
config.textContentField = options.textContentField;
|
|
93482
93501
|
}
|
|
93483
|
-
if (options.publishContent) {
|
|
93502
|
+
if (options.publishContent !== undefined) {
|
|
93484
93503
|
config.publishContent = options.publishContent;
|
|
93485
93504
|
}
|
|
93486
93505
|
if (options.bluesky) {
|
|
@@ -93640,7 +93659,7 @@ var import_api = __toESM(require_dist8(), 1);
|
|
|
93640
93659
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
93641
93660
|
* MIT Licensed
|
|
93642
93661
|
*/
|
|
93643
|
-
var db =
|
|
93662
|
+
var db = require_db();
|
|
93644
93663
|
var extname = __require("path").extname;
|
|
93645
93664
|
var $extensions = Object.create(null);
|
|
93646
93665
|
var $lookup = lookup;
|
|
@@ -103071,9 +103090,9 @@ function updateFrontmatterWithAtUri(rawContent, atUri) {
|
|
|
103071
103090
|
${afterEnd}`;
|
|
103072
103091
|
}
|
|
103073
103092
|
function stripMarkdownForText(markdown) {
|
|
103074
|
-
return markdown.replace(/#{1,6}\s/g, "").replace(/\*\*([^*]+)\*\*/g, "$1").replace(/\*([^*]+)\*/g, "$1").replace(/\[([^\]]+)\]\([^)]+\)/g, "$1").replace(/`{3}[\s\S]*?`{3}/g, "").replace(/`([^`]+)`/g, "$1").replace(
|
|
103093
|
+
return markdown.replace(/#{1,6}\s/g, "").replace(/\*\*([^*]+)\*\*/g, "$1").replace(/\*([^*]+)\*/g, "$1").replace(/!\[.*?\]\(.*?\)/g, "").replace(/\[([^\]]+)\]\([^)]+\)/g, "$1").replace(/`{3}[\s\S]*?`{3}/g, "").replace(/`([^`]+)`/g, "$1").replace(/\n{3,}/g, `
|
|
103075
103094
|
|
|
103076
|
-
`).trim();
|
|
103095
|
+
`).replace(/(~{1,2})([^~]+?)\1/g, "$2").replace(/<!--[\s\S]*?-->/g, "").replace(/^\s*\[\^[^\]]+\]:[^\r\n]*(?:\r?\n[ \t]+[^\r\n]*)*/gm, "").replace(/\[\^\S+\]/g, "").trim();
|
|
103077
103096
|
}
|
|
103078
103097
|
|
|
103079
103098
|
// src/lib/oauth-client.ts
|
|
@@ -103248,11 +103267,12 @@ function isAppPasswordCredentials(creds) {
|
|
|
103248
103267
|
}
|
|
103249
103268
|
|
|
103250
103269
|
// src/lib/atproto.ts
|
|
103270
|
+
var COVER_IMAGE_MAX_SIZE = 1024 * 1024 - 1;
|
|
103251
103271
|
function isDocumentRecord(value) {
|
|
103252
103272
|
if (!value || typeof value !== "object")
|
|
103253
103273
|
return false;
|
|
103254
103274
|
const v = value;
|
|
103255
|
-
return v.$type === "site.standard.document" && typeof v.title === "string" && typeof v.site === "string" && typeof v.path === "string" && typeof v.textContent === "string" && typeof v.publishedAt === "string" && (v.updatedAt === undefined || typeof v.updatedAt === "string");
|
|
103275
|
+
return v.$type === "site.standard.document" && typeof v.title === "string" && typeof v.site === "string" && typeof v.path === "string" && (v.textContent === undefined || typeof v.textContent === "string") && typeof v.publishedAt === "string" && (v.updatedAt === undefined || typeof v.updatedAt === "string");
|
|
103256
103276
|
}
|
|
103257
103277
|
async function fileExists3(filePath) {
|
|
103258
103278
|
try {
|
|
@@ -103337,13 +103357,14 @@ async function uploadImage(agent, imagePath) {
|
|
|
103337
103357
|
const response = await agent.com.atproto.repo.uploadBlob(new Uint8Array(imageBuffer), {
|
|
103338
103358
|
encoding: mimeType
|
|
103339
103359
|
});
|
|
103360
|
+
const blob = response.data.blob;
|
|
103340
103361
|
return {
|
|
103341
103362
|
$type: "blob",
|
|
103342
103363
|
ref: {
|
|
103343
|
-
$link:
|
|
103364
|
+
$link: blob.ref.toString()
|
|
103344
103365
|
},
|
|
103345
|
-
mimeType,
|
|
103346
|
-
size:
|
|
103366
|
+
mimeType: blob.mimeType,
|
|
103367
|
+
size: blob.size
|
|
103347
103368
|
};
|
|
103348
103369
|
} catch (error) {
|
|
103349
103370
|
console.error(`Error uploading image ${imagePath}:`, error);
|
|
@@ -103379,7 +103400,7 @@ async function resolveImagePath(ogImage, imagesDir, contentDir) {
|
|
|
103379
103400
|
return contentRelative;
|
|
103380
103401
|
}
|
|
103381
103402
|
}
|
|
103382
|
-
return
|
|
103403
|
+
return;
|
|
103383
103404
|
}
|
|
103384
103405
|
async function createDocument(agent, post, config, coverImage) {
|
|
103385
103406
|
const postPath = resolvePostPath(post, config.pathPrefix, config.pathTemplate);
|
|
@@ -103399,7 +103420,7 @@ async function createDocument(agent, post, config, coverImage) {
|
|
|
103399
103420
|
title: post.frontmatter.title,
|
|
103400
103421
|
site: config.publicationUri,
|
|
103401
103422
|
path: postPath,
|
|
103402
|
-
textContent
|
|
103423
|
+
textContent,
|
|
103403
103424
|
publishedAt: publishDate.toISOString(),
|
|
103404
103425
|
canonicalUrl: `${config.siteUrl}${postPath}`
|
|
103405
103426
|
};
|
|
@@ -103420,7 +103441,10 @@ async function createDocument(agent, post, config, coverImage) {
|
|
|
103420
103441
|
collection: "site.standard.document",
|
|
103421
103442
|
record
|
|
103422
103443
|
});
|
|
103423
|
-
return
|
|
103444
|
+
return {
|
|
103445
|
+
cid: response.data.cid,
|
|
103446
|
+
uri: response.data.uri
|
|
103447
|
+
};
|
|
103424
103448
|
}
|
|
103425
103449
|
async function updateDocument(agent, post, atUri, config, coverImage) {
|
|
103426
103450
|
const uriMatch = atUri.match(/^at:\/\/([^/]+)\/([^/]+)\/(.+)$/);
|
|
@@ -103449,7 +103473,7 @@ async function updateDocument(agent, post, atUri, config, coverImage) {
|
|
|
103449
103473
|
title: post.frontmatter.title,
|
|
103450
103474
|
site: config.publicationUri,
|
|
103451
103475
|
path: postPath,
|
|
103452
|
-
textContent
|
|
103476
|
+
textContent,
|
|
103453
103477
|
publishedAt: publishDate.toISOString(),
|
|
103454
103478
|
canonicalUrl: `${config.siteUrl}${postPath}`
|
|
103455
103479
|
};
|
|
@@ -103465,12 +103489,16 @@ async function updateDocument(agent, post, atUri, config, coverImage) {
|
|
|
103465
103489
|
if (post.frontmatter.tags && post.frontmatter.tags.length > 0) {
|
|
103466
103490
|
record.tags = post.frontmatter.tags;
|
|
103467
103491
|
}
|
|
103468
|
-
await agent.com.atproto.repo.putRecord({
|
|
103492
|
+
const response = await agent.com.atproto.repo.putRecord({
|
|
103469
103493
|
repo: agent.did,
|
|
103470
103494
|
collection,
|
|
103471
103495
|
rkey,
|
|
103472
103496
|
record
|
|
103473
103497
|
});
|
|
103498
|
+
return {
|
|
103499
|
+
cid: response.data.cid,
|
|
103500
|
+
uri: response.data.uri
|
|
103501
|
+
};
|
|
103474
103502
|
}
|
|
103475
103503
|
function parseAtUri(atUri) {
|
|
103476
103504
|
const match2 = atUri.match(/^at:\/\/([^/]+)\/([^/]+)\/(.+)$/);
|
|
@@ -103536,7 +103564,10 @@ async function createPublication(agent, options) {
|
|
|
103536
103564
|
collection: "site.standard.publication",
|
|
103537
103565
|
record
|
|
103538
103566
|
});
|
|
103539
|
-
return
|
|
103567
|
+
return {
|
|
103568
|
+
cid: response.data.cid,
|
|
103569
|
+
uri: response.data.uri
|
|
103570
|
+
};
|
|
103540
103571
|
}
|
|
103541
103572
|
async function getPublication(agent, publicationUri) {
|
|
103542
103573
|
const parsed = parseAtUri(publicationUri);
|
|
@@ -103624,6 +103655,8 @@ async function createBlueskyPost(agent, options) {
|
|
|
103624
103655
|
description,
|
|
103625
103656
|
bskyPost,
|
|
103626
103657
|
canonicalUrl,
|
|
103658
|
+
documentRef,
|
|
103659
|
+
publicationRef,
|
|
103627
103660
|
coverImage,
|
|
103628
103661
|
publishedAt
|
|
103629
103662
|
} = options;
|
|
@@ -103661,7 +103694,19 @@ ${truncatedDesc}`;
|
|
|
103661
103694
|
external: {
|
|
103662
103695
|
uri: canonicalUrl,
|
|
103663
103696
|
title: title.substring(0, 500),
|
|
103664
|
-
description: (description || "").substring(0, 1000)
|
|
103697
|
+
description: (description || "").substring(0, 1000),
|
|
103698
|
+
associatedRefs: [
|
|
103699
|
+
{
|
|
103700
|
+
$type: "com.atproto.repo.strongRef",
|
|
103701
|
+
cid: documentRef.cid,
|
|
103702
|
+
uri: documentRef.uri
|
|
103703
|
+
},
|
|
103704
|
+
{
|
|
103705
|
+
$type: "com.atproto.repo.strongRef",
|
|
103706
|
+
cid: publicationRef.cid,
|
|
103707
|
+
uri: publicationRef.uri
|
|
103708
|
+
}
|
|
103709
|
+
]
|
|
103665
103710
|
}
|
|
103666
103711
|
};
|
|
103667
103712
|
if (coverImage) {
|
|
@@ -104236,13 +104281,14 @@ var initCommand = import_cmd_ts3.command({
|
|
|
104236
104281
|
}, { onCancel });
|
|
104237
104282
|
s.start("Creating publication...");
|
|
104238
104283
|
try {
|
|
104239
|
-
|
|
104284
|
+
const publicationRef = await createPublication(agent, {
|
|
104240
104285
|
url: siteConfig.siteUrl,
|
|
104241
104286
|
name: publicationConfig.name,
|
|
104242
104287
|
description: publicationConfig.description || undefined,
|
|
104243
104288
|
iconPath: publicationConfig.iconPath || undefined,
|
|
104244
104289
|
showInDiscover: publicationConfig.showInDiscover
|
|
104245
104290
|
});
|
|
104291
|
+
publicationUri = publicationRef.uri;
|
|
104246
104292
|
s.stop(`Publication created: ${publicationUri}`);
|
|
104247
104293
|
} catch (error) {
|
|
104248
104294
|
s.stop("Failed to create publication");
|
|
@@ -104300,9 +104346,9 @@ var initCommand = import_cmd_ts3.command({
|
|
|
104300
104346
|
siteUrl: siteConfig.siteUrl,
|
|
104301
104347
|
contentDir: siteConfig.contentDir || "./content",
|
|
104302
104348
|
imagesDir: siteConfig.imagesDir || undefined,
|
|
104303
|
-
publicDir: siteConfig.publicDir ||
|
|
104304
|
-
outputDir: siteConfig.outputDir ||
|
|
104305
|
-
pathPrefix: siteConfig.pathPrefix ??
|
|
104349
|
+
publicDir: siteConfig.publicDir || DEFAULT_PUBLISHER_CONFIG.publicDir,
|
|
104350
|
+
outputDir: siteConfig.outputDir || DEFAULT_PUBLISHER_CONFIG.outputDir,
|
|
104351
|
+
pathPrefix: siteConfig.pathPrefix ?? DEFAULT_PUBLISHER_CONFIG.pathPrefix,
|
|
104306
104352
|
publicationUri,
|
|
104307
104353
|
pdsUrl,
|
|
104308
104354
|
frontmatter: frontmatterMapping,
|
|
@@ -104312,7 +104358,7 @@ var initCommand = import_cmd_ts3.command({
|
|
|
104312
104358
|
const configPath = path8.join(process.cwd(), "sequoia.json");
|
|
104313
104359
|
await fs7.writeFile(configPath, configContent);
|
|
104314
104360
|
R2.success(`Configuration saved to ${configPath}`);
|
|
104315
|
-
const publicDir = siteConfig.publicDir ||
|
|
104361
|
+
const publicDir = siteConfig.publicDir || DEFAULT_PUBLISHER_CONFIG.publicDir;
|
|
104316
104362
|
const resolvedPublicDir = path8.isAbsolute(publicDir) ? publicDir : path8.join(process.cwd(), publicDir);
|
|
104317
104363
|
const wellKnownDir = path8.join(resolvedPublicDir, ".well-known");
|
|
104318
104364
|
const wellKnownPath = path8.join(wellKnownDir, "site.standard.publication");
|
|
@@ -104370,7 +104416,7 @@ var injectCommand = import_cmd_ts4.command({
|
|
|
104370
104416
|
}
|
|
104371
104417
|
const config = await loadConfig(configPath);
|
|
104372
104418
|
const configDir = path9.dirname(configPath);
|
|
104373
|
-
const outputDir = outputDirArg || config.outputDir ||
|
|
104419
|
+
const outputDir = outputDirArg || config.outputDir || DEFAULT_PUBLISHER_CONFIG.outputDir;
|
|
104374
104420
|
const resolvedOutputDir = path9.isAbsolute(outputDir) ? outputDir : path9.join(configDir, outputDir);
|
|
104375
104421
|
R2.info(`Scanning for HTML files in: ${resolvedOutputDir}`);
|
|
104376
104422
|
const state = await loadState(configDir);
|
|
@@ -104426,26 +104472,20 @@ var injectCommand = import_cmd_ts4.command({
|
|
|
104426
104472
|
continue;
|
|
104427
104473
|
}
|
|
104428
104474
|
let content = await fs8.readFile(htmlPath, "utf-8");
|
|
104429
|
-
const
|
|
104430
|
-
|
|
104431
|
-
|
|
104432
|
-
|
|
104433
|
-
|
|
104434
|
-
|
|
104435
|
-
|
|
104436
|
-
|
|
104437
|
-
|
|
104438
|
-
|
|
104439
|
-
|
|
104440
|
-
|
|
104441
|
-
|
|
104442
|
-
R2.message(` ${linkTag}`);
|
|
104443
|
-
injectedCount++;
|
|
104444
|
-
continue;
|
|
104475
|
+
const injected = injectLinkTags(dryRun, relativePath, content, atUri, config.publicationUri);
|
|
104476
|
+
switch (injected) {
|
|
104477
|
+
case 0 /* AlreadyPresent */:
|
|
104478
|
+
alreadyHasCount++;
|
|
104479
|
+
continue;
|
|
104480
|
+
case 1 /* Skipped */:
|
|
104481
|
+
skippedCount++;
|
|
104482
|
+
continue;
|
|
104483
|
+
case 2 /* Faked */:
|
|
104484
|
+
injectedCount++;
|
|
104485
|
+
continue;
|
|
104486
|
+
default:
|
|
104487
|
+
content = injected;
|
|
104445
104488
|
}
|
|
104446
|
-
const indent = " ";
|
|
104447
|
-
content = content.slice(0, headCloseIndex) + `${indent}${linkTag}
|
|
104448
|
-
${indent}` + content.slice(headCloseIndex);
|
|
104449
104489
|
await fs8.writeFile(htmlPath, content);
|
|
104450
104490
|
R2.success(` Injected into: ${relativePath}`);
|
|
104451
104491
|
injectedCount++;
|
|
@@ -104464,6 +104504,47 @@ Tip: Skipped files had no matching published post. This is normal for non-post p
|
|
|
104464
104504
|
}
|
|
104465
104505
|
}
|
|
104466
104506
|
});
|
|
104507
|
+
function injectLinkTags(dryRun, relativePath, content, atUri, publicationUri) {
|
|
104508
|
+
let documentLinkTag = `<link rel="site.standard.document" href="${atUri}">`;
|
|
104509
|
+
let publicationLinkTag = `<link rel="site.standard.publication" href="${publicationUri}">`;
|
|
104510
|
+
if (content.includes('rel="site.standard.document"')) {
|
|
104511
|
+
documentLinkTag = undefined;
|
|
104512
|
+
}
|
|
104513
|
+
if (content.includes('rel="site.standard.publication"')) {
|
|
104514
|
+
publicationLinkTag = undefined;
|
|
104515
|
+
}
|
|
104516
|
+
if (!documentLinkTag && !publicationLinkTag) {
|
|
104517
|
+
return 0 /* AlreadyPresent */;
|
|
104518
|
+
}
|
|
104519
|
+
const headCloseIndex = content.indexOf("</head>");
|
|
104520
|
+
if (headCloseIndex === -1) {
|
|
104521
|
+
R2.warn(` No </head> found in ${relativePath}, skipping`);
|
|
104522
|
+
return 1 /* Skipped */;
|
|
104523
|
+
}
|
|
104524
|
+
if (dryRun) {
|
|
104525
|
+
R2.message(` Would inject into: ${relativePath}`);
|
|
104526
|
+
if (documentLinkTag) {
|
|
104527
|
+
R2.message(` ${documentLinkTag}`);
|
|
104528
|
+
}
|
|
104529
|
+
if (publicationLinkTag) {
|
|
104530
|
+
R2.message(` ${publicationLinkTag}`);
|
|
104531
|
+
}
|
|
104532
|
+
return 2 /* Faked */;
|
|
104533
|
+
}
|
|
104534
|
+
const indent = " ";
|
|
104535
|
+
const after = content.slice(headCloseIndex);
|
|
104536
|
+
content = content.slice(0, headCloseIndex);
|
|
104537
|
+
if (documentLinkTag) {
|
|
104538
|
+
content += `${indent}${documentLinkTag}
|
|
104539
|
+
${indent}`;
|
|
104540
|
+
}
|
|
104541
|
+
if (publicationLinkTag) {
|
|
104542
|
+
content += `${indent}${publicationLinkTag}
|
|
104543
|
+
${indent}`;
|
|
104544
|
+
}
|
|
104545
|
+
content += after;
|
|
104546
|
+
return content;
|
|
104547
|
+
}
|
|
104467
104548
|
|
|
104468
104549
|
// src/commands/login.ts
|
|
104469
104550
|
import * as http from "node:http";
|
|
@@ -104725,6 +104806,9 @@ async function syncStateFromPDS(agent, config, configDir, options = {}) {
|
|
|
104725
104806
|
postsByPath.set(postPath, post);
|
|
104726
104807
|
}
|
|
104727
104808
|
const state = await loadState(configDir);
|
|
104809
|
+
if (!state.publication) {
|
|
104810
|
+
state.publication = await syncPublication(agent, config.publicationUri, quiet);
|
|
104811
|
+
}
|
|
104728
104812
|
let matchedCount = 0;
|
|
104729
104813
|
let unmatchedCount = 0;
|
|
104730
104814
|
let frontmatterUpdatesApplied = 0;
|
|
@@ -104817,6 +104901,19 @@ Dry run complete. No changes made.`);
|
|
|
104817
104901
|
}
|
|
104818
104902
|
return { state, matchedCount, unmatchedCount, frontmatterUpdatesApplied };
|
|
104819
104903
|
}
|
|
104904
|
+
async function syncPublication(agent, publicationUri, quiet) {
|
|
104905
|
+
const publicationRef = await getPublication(agent, publicationUri);
|
|
104906
|
+
if (!publicationRef) {
|
|
104907
|
+
if (!quiet) {
|
|
104908
|
+
R2.error(`Publication ${publicationUri} not found. Update your publication record and try again.`);
|
|
104909
|
+
}
|
|
104910
|
+
process.exit(1);
|
|
104911
|
+
}
|
|
104912
|
+
return {
|
|
104913
|
+
cid: publicationRef.cid,
|
|
104914
|
+
uri: publicationRef.uri
|
|
104915
|
+
};
|
|
104916
|
+
}
|
|
104820
104917
|
|
|
104821
104918
|
// src/commands/publish.ts
|
|
104822
104919
|
var publishCommand = import_cmd_ts6.command({
|
|
@@ -104842,7 +104939,7 @@ var publishCommand = import_cmd_ts6.command({
|
|
|
104842
104939
|
handler: async ({ force, dryRun, verbose }) => {
|
|
104843
104940
|
const configPath = await findConfig();
|
|
104844
104941
|
if (!configPath) {
|
|
104845
|
-
R2.error(
|
|
104942
|
+
R2.error(`No ${CONFIG_FILENAME} found. Run 'sequoia init' first.`);
|
|
104846
104943
|
process.exit(1);
|
|
104847
104944
|
}
|
|
104848
104945
|
const config = await loadConfig(configPath);
|
|
@@ -104901,7 +104998,7 @@ var publishCommand = import_cmd_ts6.command({
|
|
|
104901
104998
|
let state = await loadState(configDir);
|
|
104902
104999
|
const s = Ie();
|
|
104903
105000
|
let agent;
|
|
104904
|
-
if (config.autoSync !== false && Object.keys(state.posts).length === 0 && !dryRun) {
|
|
105001
|
+
if (config.autoSync !== false && (!state.publication || Object.keys(state.posts).length === 0) && !dryRun) {
|
|
104905
105002
|
const connectingTo = credentials.type === "oauth" ? credentials.handle : credentials.pdsUrl;
|
|
104906
105003
|
s.start(`Connecting as ${connectingTo}...`);
|
|
104907
105004
|
try {
|
|
@@ -104979,10 +105076,14 @@ ${postsToPublish.length} posts to publish:
|
|
|
104979
105076
|
const maxAgeDays = config.bluesky?.maxAgeDays ?? 7;
|
|
104980
105077
|
const cutoffDate = new Date;
|
|
104981
105078
|
cutoffDate.setDate(cutoffDate.getDate() - maxAgeDays);
|
|
105079
|
+
let isValid = true;
|
|
104982
105080
|
for (const { post, action, reason } of postsToPublish) {
|
|
104983
105081
|
const icon = action === "create" ? "+" : "~";
|
|
104984
105082
|
const relativeFilePath = path12.relative(configDir, post.filePath);
|
|
104985
105083
|
const existingBskyPostRef = state.posts[relativeFilePath]?.bskyPostRef;
|
|
105084
|
+
if (post.frontmatter.ogImage) {
|
|
105085
|
+
post.coverImagePath = await resolveImagePath(post.frontmatter.ogImage, imagesDir, contentDir);
|
|
105086
|
+
}
|
|
104986
105087
|
let bskyNote = "";
|
|
104987
105088
|
if (blueskyEnabled) {
|
|
104988
105089
|
if (existingBskyPostRef) {
|
|
@@ -105003,6 +105104,11 @@ ${postsToPublish.length} posts to publish:
|
|
|
105003
105104
|
${config.siteUrl}${postPath}`;
|
|
105004
105105
|
}
|
|
105005
105106
|
R2.message(` ${icon} ${post.frontmatter.title} (${reason})${bskyNote}${postUrl}`);
|
|
105107
|
+
const postValid = await validatePost(post);
|
|
105108
|
+
isValid &&= postValid;
|
|
105109
|
+
}
|
|
105110
|
+
if (!isValid) {
|
|
105111
|
+
return;
|
|
105006
105112
|
}
|
|
105007
105113
|
if (dryRun) {
|
|
105008
105114
|
if (blueskyEnabled) {
|
|
@@ -105025,6 +105131,9 @@ Dry run complete. No changes made.`);
|
|
|
105025
105131
|
process.exit(1);
|
|
105026
105132
|
}
|
|
105027
105133
|
}
|
|
105134
|
+
if (!state.publication) {
|
|
105135
|
+
state.publication = await syncPublication(agent, config.publicationUri, false);
|
|
105136
|
+
}
|
|
105028
105137
|
let publishedCount = 0;
|
|
105029
105138
|
let updatedCount = 0;
|
|
105030
105139
|
let errorCount = 0;
|
|
@@ -105033,35 +105142,32 @@ Dry run complete. No changes made.`);
|
|
|
105033
105142
|
s.start(`Publishing: ${post.frontmatter.title}`);
|
|
105034
105143
|
try {
|
|
105035
105144
|
let coverImage;
|
|
105036
|
-
if (post.
|
|
105037
|
-
|
|
105038
|
-
|
|
105039
|
-
|
|
105040
|
-
|
|
105041
|
-
if (coverImage) {
|
|
105042
|
-
R2.info(` Uploaded image blob: ${coverImage.ref.$link}`);
|
|
105043
|
-
}
|
|
105044
|
-
} else {
|
|
105045
|
-
R2.warn(` Cover image not found: ${post.frontmatter.ogImage}`);
|
|
105145
|
+
if (post.coverImagePath) {
|
|
105146
|
+
R2.info(` Uploading cover image: ${path12.basename(post.coverImagePath)}`);
|
|
105147
|
+
coverImage = await uploadImage(agent, post.coverImagePath);
|
|
105148
|
+
if (coverImage) {
|
|
105149
|
+
R2.info(` Uploaded image blob: ${coverImage.ref.$link}`);
|
|
105046
105150
|
}
|
|
105151
|
+
} else {
|
|
105152
|
+
R2.warn(` Cover image not found: ${post.frontmatter.ogImage}`);
|
|
105047
105153
|
}
|
|
105048
|
-
let
|
|
105154
|
+
let documentRef;
|
|
105049
105155
|
let contentForHash;
|
|
105050
105156
|
let bskyPostRef;
|
|
105051
105157
|
const relativeFilePath = path12.relative(configDir, post.filePath);
|
|
105052
105158
|
const existingBskyPostRef = state.posts[relativeFilePath]?.bskyPostRef;
|
|
105053
105159
|
if (action === "create") {
|
|
105054
|
-
|
|
105055
|
-
s.stop(`Created: ${
|
|
105056
|
-
const updatedContent = updateFrontmatterWithAtUri(post.rawContent,
|
|
105160
|
+
documentRef = await createDocument(agent, post, config, coverImage);
|
|
105161
|
+
s.stop(`Created: ${documentRef.uri}`);
|
|
105162
|
+
const updatedContent = updateFrontmatterWithAtUri(post.rawContent, documentRef.uri);
|
|
105057
105163
|
await fs15.writeFile(post.filePath, updatedContent);
|
|
105058
105164
|
R2.info(` Updated frontmatter in ${path12.basename(post.filePath)}`);
|
|
105059
105165
|
contentForHash = updatedContent;
|
|
105060
105166
|
publishedCount++;
|
|
105061
105167
|
} else {
|
|
105062
|
-
atUri = post.frontmatter.atUri;
|
|
105063
|
-
await updateDocument(agent, post, atUri, config, coverImage);
|
|
105064
|
-
s.stop(`Updated: ${
|
|
105168
|
+
const atUri = post.frontmatter.atUri;
|
|
105169
|
+
documentRef = await updateDocument(agent, post, atUri, config, coverImage);
|
|
105170
|
+
s.stop(`Updated: ${documentRef.uri}`);
|
|
105065
105171
|
contentForHash = post.rawContent;
|
|
105066
105172
|
updatedCount++;
|
|
105067
105173
|
}
|
|
@@ -105081,10 +105187,12 @@ Dry run complete. No changes made.`);
|
|
|
105081
105187
|
description: post.frontmatter.description,
|
|
105082
105188
|
bskyPost: post.frontmatter.bskyPost,
|
|
105083
105189
|
canonicalUrl,
|
|
105190
|
+
documentRef,
|
|
105191
|
+
publicationRef: state.publication,
|
|
105084
105192
|
coverImage,
|
|
105085
105193
|
publishedAt: post.frontmatter.publishDate
|
|
105086
105194
|
});
|
|
105087
|
-
await addBskyPostRefToDocument(agent,
|
|
105195
|
+
await addBskyPostRefToDocument(agent, documentRef.uri, bskyPostRef);
|
|
105088
105196
|
R2.info(` Created Bluesky post: ${bskyPostRef.uri}`);
|
|
105089
105197
|
bskyPostCount++;
|
|
105090
105198
|
} catch (bskyError) {
|
|
@@ -105097,7 +105205,7 @@ Dry run complete. No changes made.`);
|
|
|
105097
105205
|
const contentHash = await getContentHash(contentForHash);
|
|
105098
105206
|
state.posts[relativeFilePath] = {
|
|
105099
105207
|
contentHash,
|
|
105100
|
-
atUri,
|
|
105208
|
+
atUri: documentRef.uri,
|
|
105101
105209
|
lastPublished: new Date().toISOString(),
|
|
105102
105210
|
slug: post.slug,
|
|
105103
105211
|
bskyPostRef
|
|
@@ -105122,6 +105230,16 @@ Dry run complete. No changes made.`);
|
|
|
105122
105230
|
}
|
|
105123
105231
|
}
|
|
105124
105232
|
});
|
|
105233
|
+
async function validatePost(post) {
|
|
105234
|
+
if (post.coverImagePath) {
|
|
105235
|
+
const stat3 = await fs15.stat(post.coverImagePath);
|
|
105236
|
+
if (stat3.size >= COVER_IMAGE_MAX_SIZE) {
|
|
105237
|
+
R2.error(` Cover image "${post.coverImagePath}" must be less than 1MB`);
|
|
105238
|
+
return false;
|
|
105239
|
+
}
|
|
105240
|
+
}
|
|
105241
|
+
return true;
|
|
105242
|
+
}
|
|
105125
105243
|
|
|
105126
105244
|
// src/commands/sync.ts
|
|
105127
105245
|
var import_cmd_ts7 = __toESM(require_cjs(), 1);
|
|
@@ -105261,7 +105379,7 @@ async function updateConfigFlow(config, configPath) {
|
|
|
105261
105379
|
const configSummary = [
|
|
105262
105380
|
`Site URL: ${config.siteUrl}`,
|
|
105263
105381
|
`Content Dir: ${config.contentDir}`,
|
|
105264
|
-
`Path Prefix: ${config.pathPrefix ??
|
|
105382
|
+
`Path Prefix: ${config.pathPrefix ?? DEFAULT_PUBLISHER_CONFIG.pathPrefix}`,
|
|
105265
105383
|
`Publication URI: ${config.publicationUri}`,
|
|
105266
105384
|
config.imagesDir ? `Images Dir: ${config.imagesDir}` : null,
|
|
105267
105385
|
config.outputDir ? `Output Dir: ${config.outputDir}` : null,
|
|
@@ -105322,24 +105440,7 @@ async function updateConfigFlow(config, configPath) {
|
|
|
105322
105440
|
initialValue: true
|
|
105323
105441
|
}));
|
|
105324
105442
|
if (shouldSave) {
|
|
105325
|
-
const configContent =
|
|
105326
|
-
siteUrl: configUpdated.siteUrl,
|
|
105327
|
-
contentDir: configUpdated.contentDir,
|
|
105328
|
-
imagesDir: configUpdated.imagesDir,
|
|
105329
|
-
publicDir: configUpdated.publicDir,
|
|
105330
|
-
outputDir: configUpdated.outputDir,
|
|
105331
|
-
pathPrefix: configUpdated.pathPrefix,
|
|
105332
|
-
publicationUri: configUpdated.publicationUri,
|
|
105333
|
-
pdsUrl: configUpdated.pdsUrl,
|
|
105334
|
-
frontmatter: configUpdated.frontmatter,
|
|
105335
|
-
ignore: configUpdated.ignore,
|
|
105336
|
-
removeIndexFromSlug: configUpdated.removeIndexFromSlug,
|
|
105337
|
-
stripDatePrefix: configUpdated.stripDatePrefix,
|
|
105338
|
-
pathTemplate: configUpdated.pathTemplate,
|
|
105339
|
-
textContentField: configUpdated.textContentField,
|
|
105340
|
-
publishContent: configUpdated.publishContent,
|
|
105341
|
-
bluesky: configUpdated.bluesky
|
|
105342
|
-
});
|
|
105443
|
+
const configContent = JSON.stringify(configUpdated, null, 2);
|
|
105343
105444
|
await fs16.writeFile(configPath, configContent);
|
|
105344
105445
|
R2.success("Configuration saved!");
|
|
105345
105446
|
} else {
|
|
@@ -105362,7 +105463,7 @@ async function editSiteSettings(config) {
|
|
|
105362
105463
|
}));
|
|
105363
105464
|
const pathPrefix = exitOnCancel(await Qt({
|
|
105364
105465
|
message: "URL path prefix for posts:",
|
|
105365
|
-
initialValue: config.pathPrefix ??
|
|
105466
|
+
initialValue: config.pathPrefix ?? DEFAULT_PUBLISHER_CONFIG.pathPrefix
|
|
105366
105467
|
}));
|
|
105367
105468
|
return {
|
|
105368
105469
|
...config,
|
|
@@ -105385,11 +105486,11 @@ async function editDirectories(config) {
|
|
|
105385
105486
|
}));
|
|
105386
105487
|
const publicDir = exitOnCancel(await Qt({
|
|
105387
105488
|
message: "Public/static directory:",
|
|
105388
|
-
initialValue: config.publicDir ||
|
|
105489
|
+
initialValue: config.publicDir || DEFAULT_PUBLISHER_CONFIG.publicDir
|
|
105389
105490
|
}));
|
|
105390
105491
|
const outputDir = exitOnCancel(await Qt({
|
|
105391
105492
|
message: "Build output directory:",
|
|
105392
|
-
initialValue: config.outputDir ||
|
|
105493
|
+
initialValue: config.outputDir || DEFAULT_PUBLISHER_CONFIG.outputDir
|
|
105393
105494
|
}));
|
|
105394
105495
|
return {
|
|
105395
105496
|
...config,
|
|
@@ -105476,7 +105577,7 @@ async function editAdvanced(config) {
|
|
|
105476
105577
|
}));
|
|
105477
105578
|
const publishContent = exitOnCancel(await Mt2({
|
|
105478
105579
|
message: "Publish the post content on the standard.site document?",
|
|
105479
|
-
initialValue: config.publishContent ??
|
|
105580
|
+
initialValue: config.publishContent ?? DEFAULT_PUBLISHER_CONFIG.publishContent
|
|
105480
105581
|
}));
|
|
105481
105582
|
const textContentField = exitOnCancel(await Qt({
|
|
105482
105583
|
message: "Frontmatter field for textContent (leave empty to use markdown body):",
|
|
@@ -105491,7 +105592,7 @@ async function editAdvanced(config) {
|
|
|
105491
105592
|
removeIndexFromSlug: removeIndexFromSlug || undefined,
|
|
105492
105593
|
stripDatePrefix: stripDatePrefix || undefined,
|
|
105493
105594
|
textContentField: textContentField || undefined,
|
|
105494
|
-
publishContent: publishContent ??
|
|
105595
|
+
publishContent: publishContent ?? DEFAULT_PUBLISHER_CONFIG.publishContent
|
|
105495
105596
|
};
|
|
105496
105597
|
}
|
|
105497
105598
|
async function editBluesky(config) {
|
|
@@ -105687,7 +105788,7 @@ Publish evergreen content to the ATmosphere
|
|
|
105687
105788
|
|
|
105688
105789
|
> https://tangled.org/stevedylan.dev/sequoia
|
|
105689
105790
|
`,
|
|
105690
|
-
version: "0.5.
|
|
105791
|
+
version: "0.5.7",
|
|
105691
105792
|
cmds: {
|
|
105692
105793
|
add: addCommand,
|
|
105693
105794
|
auth: authCommand,
|
|
@@ -105700,3 +105801,6 @@ Publish evergreen content to the ATmosphere
|
|
|
105700
105801
|
}
|
|
105701
105802
|
});
|
|
105702
105803
|
import_cmd_ts9.run(app, process.argv.slice(2));
|
|
105804
|
+
|
|
105805
|
+
//# debugId=0DA3B1F9984712F664756E2164756E21
|
|
105806
|
+
//# sourceMappingURL=index.js.map
|