contentbit 2.0.0-next.0 → 2.0.0-next.1
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/bin.js +320 -81
- package/dist/commands/init-blocks.d.ts.map +1 -1
- package/dist/commands/init-targets.d.ts +16 -3
- package/dist/commands/init-targets.d.ts.map +1 -1
- package/dist/commands/init.d.ts +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/studio.d.ts.map +1 -1
- package/dist/run.d.ts +1 -0
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +321 -81
- package/package.json +4 -4
package/dist/bin.js
CHANGED
|
@@ -46,7 +46,7 @@ var VERSION;
|
|
|
46
46
|
var init_version = __esm({
|
|
47
47
|
"../core/dist/version.js"() {
|
|
48
48
|
"use strict";
|
|
49
|
-
VERSION = "2.0.0-next.
|
|
49
|
+
VERSION = "2.0.0-next.1";
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
|
|
@@ -29683,7 +29683,12 @@ function duplicatePageIdFindings(pages) {
|
|
|
29683
29683
|
function evaluatePage(page, config2) {
|
|
29684
29684
|
const findings = [];
|
|
29685
29685
|
if (!page.type) {
|
|
29686
|
-
findings.push(
|
|
29686
|
+
findings.push({
|
|
29687
|
+
...finding(page, "warning", "CB_SEO_TYPE_MISSING", "page is missing an SEO page type"),
|
|
29688
|
+
line: 1,
|
|
29689
|
+
column: 1,
|
|
29690
|
+
hint: "Set type in the frontmatter, or give the page a type in the SEO config, with a pages entry or a pageDefaults entry whose pathPrefix holds the file."
|
|
29691
|
+
});
|
|
29687
29692
|
return findings;
|
|
29688
29693
|
}
|
|
29689
29694
|
const contract = config2.pageTypes[page.type];
|
|
@@ -34330,7 +34335,7 @@ var init_findings = __esm({
|
|
|
34330
34335
|
CB_LINK_PAGE_MISSING: "error",
|
|
34331
34336
|
CB_LINK_ANCHOR_MISSING: "error",
|
|
34332
34337
|
CB_LINK_FILE_MISSING: "error",
|
|
34333
|
-
CB_LINK_NOINDEX_TARGET: "
|
|
34338
|
+
CB_LINK_NOINDEX_TARGET: "info",
|
|
34334
34339
|
CB_SITE_HREFLANG_NOT_RECIPROCAL: "warning",
|
|
34335
34340
|
CB_SITE_HREFLANG_X_DEFAULT_MISSING: "warning",
|
|
34336
34341
|
CB_SITE_SITEMAP_URL_NOT_BUILT: "error",
|
|
@@ -34389,9 +34394,6 @@ function decodeSegment(segment) {
|
|
|
34389
34394
|
return segment;
|
|
34390
34395
|
}
|
|
34391
34396
|
}
|
|
34392
|
-
function linkPlacement({ landmark }) {
|
|
34393
|
-
return landmark !== void 0 && LAYOUT_LANDMARKS.has(landmark) ? "layout" : "content";
|
|
34394
|
-
}
|
|
34395
34397
|
var LAYOUT_LANDMARKS;
|
|
34396
34398
|
var init_model = __esm({
|
|
34397
34399
|
"../built-site/dist/model.js"() {
|
|
@@ -34720,7 +34722,7 @@ function checkLinkContracts(index2) {
|
|
|
34720
34722
|
const linksOut = /* @__PURE__ */ new Map();
|
|
34721
34723
|
const linksIn = /* @__PURE__ */ new Map();
|
|
34722
34724
|
forEachLinkBetweenPages(index2, (from, link, to) => {
|
|
34723
|
-
if (
|
|
34725
|
+
if (link.placement === "layout")
|
|
34724
34726
|
return;
|
|
34725
34727
|
linksOut.set(from, (linksOut.get(from) ?? /* @__PURE__ */ new Set()).add(to));
|
|
34726
34728
|
linksIn.set(to, (linksIn.get(to) ?? /* @__PURE__ */ new Set()).add(from));
|
|
@@ -34789,9 +34791,8 @@ var init_link_contract = __esm({
|
|
|
34789
34791
|
"../built-site/dist/checks/link-contract.js"() {
|
|
34790
34792
|
"use strict";
|
|
34791
34793
|
init_findings();
|
|
34792
|
-
init_model();
|
|
34793
34794
|
init_site_index();
|
|
34794
|
-
LAYOUT_LINKS = "Links in the header, nav, aside or footer do not count.";
|
|
34795
|
+
LAYOUT_LINKS = "Links in the header, nav, aside or footer, or outside the page content, do not count.";
|
|
34795
34796
|
}
|
|
34796
34797
|
});
|
|
34797
34798
|
|
|
@@ -35213,7 +35214,7 @@ var init_finding_origins = __esm({
|
|
|
35213
35214
|
});
|
|
35214
35215
|
|
|
35215
35216
|
// ../built-site/dist/context.js
|
|
35216
|
-
import { relative, resolve } from "node:path";
|
|
35217
|
+
import { basename, relative, resolve } from "node:path";
|
|
35217
35218
|
function findContextPage(input2, target, cwd) {
|
|
35218
35219
|
const index2 = siteIndex(input2);
|
|
35219
35220
|
const pageOf = /* @__PURE__ */ new Map();
|
|
@@ -35238,6 +35239,13 @@ function findContextPage(input2, target, cwd) {
|
|
|
35238
35239
|
const document3 = input2.documents.find((candidate) => candidate.file === file2);
|
|
35239
35240
|
if (document3)
|
|
35240
35241
|
return attached([document3]);
|
|
35242
|
+
const end = `/${target.replaceAll("\\", "/")}`;
|
|
35243
|
+
const named2 = input2.documents.filter((candidate) => candidate.file.replaceAll("\\", "/").endsWith(end));
|
|
35244
|
+
if (named2.length > 1) {
|
|
35245
|
+
return { kind: "ambiguous-file", files: named2.map((candidate) => candidate.file) };
|
|
35246
|
+
}
|
|
35247
|
+
if (named2.length === 1)
|
|
35248
|
+
return attached(named2);
|
|
35241
35249
|
}
|
|
35242
35250
|
const seoPages = new Map(input2.seo?.pages.map((page) => [page.path, page]));
|
|
35243
35251
|
const names = ({ file: file2, facts }, field) => [facts[field], seoPages.get(file2)?.[field]].flatMap((name) => name ?? []);
|
|
@@ -35251,7 +35259,7 @@ function findContextPage(input2, target, cwd) {
|
|
|
35251
35259
|
return { kind: "planned", page: plannedPage, seo: input2.seo };
|
|
35252
35260
|
const candidates = [
|
|
35253
35261
|
...input2.site.pages.map(({ path: path4 }) => path4),
|
|
35254
|
-
...input2.documents.
|
|
35262
|
+
...input2.documents.flatMap(({ file: file2 }) => [relative(cwd, file2), basename(file2)]),
|
|
35255
35263
|
...input2.documents.flatMap((document3) => [
|
|
35256
35264
|
...names(document3, "key"),
|
|
35257
35265
|
...names(document3, "slug")
|
|
@@ -35274,7 +35282,7 @@ function pageContext(input2, page) {
|
|
|
35274
35282
|
from: from.path,
|
|
35275
35283
|
text: link.text,
|
|
35276
35284
|
...anchor2 !== void 0 && { anchor: anchor2 },
|
|
35277
|
-
placement:
|
|
35285
|
+
placement: link.placement
|
|
35278
35286
|
});
|
|
35279
35287
|
});
|
|
35280
35288
|
return {
|
|
@@ -35302,7 +35310,7 @@ function pageContext(input2, page) {
|
|
|
35302
35310
|
linksOut: facts.links.map((link) => ({
|
|
35303
35311
|
href: link.href,
|
|
35304
35312
|
text: link.text,
|
|
35305
|
-
placement:
|
|
35313
|
+
placement: link.placement,
|
|
35306
35314
|
target: linkOutTarget(index2.resolveLink(link.href, page))
|
|
35307
35315
|
})),
|
|
35308
35316
|
findings: input2.findings.filter((finding2) => findingPages(finding2).includes(page.path)).map((finding2) => onPage(finding2, page.path)),
|
|
@@ -35335,7 +35343,7 @@ function siteContext(input2) {
|
|
|
35335
35343
|
return counts;
|
|
35336
35344
|
};
|
|
35337
35345
|
forEachLinkBetweenPages(index2, (_from, link, to) => {
|
|
35338
|
-
linksInto(to)[
|
|
35346
|
+
linksInto(to)[link.placement]++;
|
|
35339
35347
|
});
|
|
35340
35348
|
const pages = input2.site.pages.map((page) => {
|
|
35341
35349
|
const document3 = input2.sources.pages.get(page.path);
|
|
@@ -35431,7 +35439,6 @@ var init_context = __esm({
|
|
|
35431
35439
|
init_site_index();
|
|
35432
35440
|
init_finding_origins();
|
|
35433
35441
|
init_findings();
|
|
35434
|
-
init_model();
|
|
35435
35442
|
PAGE_CONTEXT_SCHEMA_VERSION = "contentbit.page-context.v1";
|
|
35436
35443
|
SITE_CONTEXT_SCHEMA_VERSION = "contentbit.site-context.v1";
|
|
35437
35444
|
ABSOLUTE_URL = /^https?:\/\//i;
|
|
@@ -37790,8 +37797,16 @@ function readRenderedPageFacts(html) {
|
|
|
37790
37797
|
const main = emptyRegion();
|
|
37791
37798
|
let hasMain = false;
|
|
37792
37799
|
let h1OutsideMain = false;
|
|
37793
|
-
const
|
|
37800
|
+
const h1Articles = /* @__PURE__ */ new Set();
|
|
37801
|
+
const regions = (frame) => [
|
|
37802
|
+
page,
|
|
37803
|
+
...frame?.main ? [main] : [],
|
|
37804
|
+
...frame?.article && !frame.articleFooter ? [frame.article] : []
|
|
37805
|
+
];
|
|
37806
|
+
const pendingLinks = [];
|
|
37794
37807
|
let permalink;
|
|
37808
|
+
const layoutAsides = [];
|
|
37809
|
+
let asides = 0;
|
|
37795
37810
|
const capture = (finish, { visibleOnly = false, imageAlts = false } = {}) => captures.push({ depth: stack.length - 1, parts: [], visibleOnly, imageAlts, finish });
|
|
37796
37811
|
let wordBreak = false;
|
|
37797
37812
|
let closed = false;
|
|
@@ -37799,7 +37814,8 @@ function readRenderedPageFacts(html) {
|
|
|
37799
37814
|
for (const open2 of captures)
|
|
37800
37815
|
if (open2.parts.at(-1) !== " ")
|
|
37801
37816
|
open2.parts.push(" ");
|
|
37802
|
-
|
|
37817
|
+
const article = stack.at(-1)?.article;
|
|
37818
|
+
for (const region of article ? [page, main, article] : [page, main]) {
|
|
37803
37819
|
const { parts } = region.open;
|
|
37804
37820
|
if (parts.at(-1) !== " ")
|
|
37805
37821
|
parts.push(" ");
|
|
@@ -37810,24 +37826,33 @@ function readRenderedPageFacts(html) {
|
|
|
37810
37826
|
parts.push(" ");
|
|
37811
37827
|
parts.push(text3);
|
|
37812
37828
|
};
|
|
37813
|
-
const parser = new Parser({
|
|
37829
|
+
const parser = new Parser(deferAsides(layoutAsides, {
|
|
37814
37830
|
onopentag(name, attribs) {
|
|
37815
37831
|
const parent = stack.at(-1);
|
|
37816
37832
|
const role = attribs.role?.trim().toLowerCase().split(WHITESPACE)[0];
|
|
37817
|
-
const own6 = landmarkOf(name, role, parent
|
|
37833
|
+
const own6 = landmarkOf(name, role, parent, name === "aside" && layoutAsides[asides++]);
|
|
37818
37834
|
const landmark = own6 ?? parent?.landmark;
|
|
37819
37835
|
const visible = (parent?.visible ?? true) && !HIDDEN_TEXT_TAGS.has(name);
|
|
37820
37836
|
const level = HEADING_LEVELS.get(name);
|
|
37837
|
+
const sectioning = SECTIONING_TAGS.has(name) || role !== void 0 && SECTIONING_ROLES.has(role);
|
|
37821
37838
|
const frame = {
|
|
37822
37839
|
name,
|
|
37823
37840
|
landmark,
|
|
37824
|
-
sectioning: (parent?.sectioning ?? false)
|
|
37841
|
+
sectioning: sectioning || (parent?.sectioning ?? false),
|
|
37842
|
+
scope: own6 === "main" ? "main" : sectioning || SECTIONING_ROOTS.has(name) ? "other" : parent?.scope ?? "page",
|
|
37825
37843
|
visible,
|
|
37826
37844
|
svg: name === "svg" || (parent?.svg ?? false),
|
|
37827
|
-
content: visible && name !== "pre" && (parent?.content ?? true) && !(landmark
|
|
37845
|
+
content: visible && name !== "pre" && (parent?.content ?? true) && !isLayout(landmark) && !(name === "a" && attribs.href !== void 0 && attribs.href === permalink),
|
|
37828
37846
|
main: own6 === "main" || (parent?.main ?? false),
|
|
37847
|
+
article: parent?.article,
|
|
37848
|
+
articleFooter: (parent?.articleFooter ?? false) || name === "footer" && own6 === void 0 && parent?.scope === "article",
|
|
37829
37849
|
heading: level !== void 0 || (parent?.heading ?? false)
|
|
37830
37850
|
};
|
|
37851
|
+
const isArticle = role ? role === "article" : name === "article";
|
|
37852
|
+
if (isArticle && frame.main && frame.content && !frame.article) {
|
|
37853
|
+
frame.article = emptyRegion();
|
|
37854
|
+
frame.scope = "article";
|
|
37855
|
+
}
|
|
37831
37856
|
if (own6 === "main" && frame.content)
|
|
37832
37857
|
hasMain = true;
|
|
37833
37858
|
if (name !== "a" && !INLINE_TAGS.has(name))
|
|
@@ -37847,8 +37872,12 @@ function readRenderedPageFacts(html) {
|
|
|
37847
37872
|
openSection(region, heading);
|
|
37848
37873
|
permalink = attribs.id === void 0 ? void 0 : `#${attribs.id}`;
|
|
37849
37874
|
}
|
|
37850
|
-
if (level === 1 && frame.content
|
|
37851
|
-
|
|
37875
|
+
if (level === 1 && frame.content) {
|
|
37876
|
+
if (frame.main)
|
|
37877
|
+
h1Articles.add(frame.article);
|
|
37878
|
+
else
|
|
37879
|
+
h1OutsideMain = true;
|
|
37880
|
+
}
|
|
37852
37881
|
capture((text3) => {
|
|
37853
37882
|
heading.text = collapseWhitespace(text3);
|
|
37854
37883
|
heading.words = countWords(heading.text);
|
|
@@ -37882,9 +37911,12 @@ function readRenderedPageFacts(html) {
|
|
|
37882
37911
|
href: attribs.href,
|
|
37883
37912
|
...attribs.rel !== void 0 && { rel: attribs.rel },
|
|
37884
37913
|
...elementContext(frame, attribs.class),
|
|
37914
|
+
placement: "layout",
|
|
37885
37915
|
text: ""
|
|
37886
37916
|
};
|
|
37887
37917
|
facts.links.push(link);
|
|
37918
|
+
if (!isLayout(frame.landmark))
|
|
37919
|
+
pendingLinks.push({ link, within: regions(frame) });
|
|
37888
37920
|
const label = attribs["aria-label"];
|
|
37889
37921
|
capture((text3) => link.text = collapseWhitespace(text3) || collapseWhitespace(label ?? ""), { visibleOnly: true, imageAlts: true });
|
|
37890
37922
|
}
|
|
@@ -37941,10 +37973,16 @@ function readRenderedPageFacts(html) {
|
|
|
37941
37973
|
open2.finish(open2.parts.join(""));
|
|
37942
37974
|
}
|
|
37943
37975
|
}
|
|
37944
|
-
}, { decodeEntities: true });
|
|
37976
|
+
}), { decodeEntities: true });
|
|
37945
37977
|
parser.write(html);
|
|
37946
37978
|
parser.end();
|
|
37947
|
-
|
|
37979
|
+
const [h1Article] = h1Articles;
|
|
37980
|
+
const content3 = !hasMain || h1OutsideMain ? page : h1Articles.size === 1 && h1Article ? h1Article : main;
|
|
37981
|
+
for (const { link, within } of pendingLinks) {
|
|
37982
|
+
if (within.includes(content3))
|
|
37983
|
+
link.placement = "content";
|
|
37984
|
+
}
|
|
37985
|
+
for (const { heading, parts } of content3.sections) {
|
|
37948
37986
|
const body = collapseWhitespace(parts.join(""));
|
|
37949
37987
|
if (!heading) {
|
|
37950
37988
|
facts.intro = body;
|
|
@@ -37959,12 +37997,94 @@ function readRenderedPageFacts(html) {
|
|
|
37959
37997
|
facts.ids = [...ids];
|
|
37960
37998
|
return facts;
|
|
37961
37999
|
}
|
|
37962
|
-
function landmarkOf(name, role,
|
|
37963
|
-
|
|
37964
|
-
|
|
37965
|
-
|
|
38000
|
+
function landmarkOf(name, role, parent, layoutAside) {
|
|
38001
|
+
switch (name) {
|
|
38002
|
+
case "main":
|
|
38003
|
+
case "nav":
|
|
38004
|
+
return name;
|
|
38005
|
+
case "header":
|
|
38006
|
+
if (!parent?.sectioning)
|
|
38007
|
+
return name;
|
|
38008
|
+
break;
|
|
38009
|
+
case "footer":
|
|
38010
|
+
if (parent === void 0 || parent.scope === "page" || parent.scope === "main")
|
|
38011
|
+
return name;
|
|
38012
|
+
break;
|
|
38013
|
+
case "aside":
|
|
38014
|
+
if (layoutAside)
|
|
38015
|
+
return name;
|
|
38016
|
+
break;
|
|
38017
|
+
}
|
|
37966
38018
|
return role === void 0 ? void 0 : LANDMARK_ROLES.get(role);
|
|
37967
38019
|
}
|
|
38020
|
+
function deferAsides(layout, reader) {
|
|
38021
|
+
const held = [];
|
|
38022
|
+
const open2 = [];
|
|
38023
|
+
const stack = [];
|
|
38024
|
+
const breakText = () => {
|
|
38025
|
+
for (const aside of open2) {
|
|
38026
|
+
aside.text.push(" ");
|
|
38027
|
+
aside.linkText.push(" ");
|
|
38028
|
+
}
|
|
38029
|
+
};
|
|
38030
|
+
return {
|
|
38031
|
+
onopentag(name, attribs, implied) {
|
|
38032
|
+
if (name === "aside") {
|
|
38033
|
+
open2.push({ index: layout.length, depth: stack.length, text: [], linkText: [] });
|
|
38034
|
+
layout.push(true);
|
|
38035
|
+
}
|
|
38036
|
+
if (open2.length === 0) {
|
|
38037
|
+
reader.onopentag(name, attribs, implied);
|
|
38038
|
+
return;
|
|
38039
|
+
}
|
|
38040
|
+
held.push(() => reader.onopentag(name, attribs, implied));
|
|
38041
|
+
if (!INLINE_TAGS.has(name))
|
|
38042
|
+
breakText();
|
|
38043
|
+
const parent = stack.at(-1);
|
|
38044
|
+
stack.push({
|
|
38045
|
+
visible: (parent?.visible ?? true) && !HIDDEN_TEXT_TAGS.has(name),
|
|
38046
|
+
link: (parent?.link ?? false) || name === "a" && attribs.href !== void 0
|
|
38047
|
+
});
|
|
38048
|
+
},
|
|
38049
|
+
ontext(text3) {
|
|
38050
|
+
if (open2.length === 0) {
|
|
38051
|
+
reader.ontext(text3);
|
|
38052
|
+
return;
|
|
38053
|
+
}
|
|
38054
|
+
held.push(() => reader.ontext(text3));
|
|
38055
|
+
const frame = stack.at(-1);
|
|
38056
|
+
if (frame?.visible === false)
|
|
38057
|
+
return;
|
|
38058
|
+
for (const aside of open2) {
|
|
38059
|
+
aside.text.push(text3);
|
|
38060
|
+
if (frame?.link)
|
|
38061
|
+
aside.linkText.push(text3);
|
|
38062
|
+
}
|
|
38063
|
+
},
|
|
38064
|
+
onclosetag(name, implied) {
|
|
38065
|
+
if (open2.length === 0) {
|
|
38066
|
+
reader.onclosetag(name, implied);
|
|
38067
|
+
return;
|
|
38068
|
+
}
|
|
38069
|
+
held.push(() => reader.onclosetag(name, implied));
|
|
38070
|
+
stack.pop();
|
|
38071
|
+
if (!INLINE_TAGS.has(name))
|
|
38072
|
+
breakText();
|
|
38073
|
+
const aside = open2.at(-1);
|
|
38074
|
+
if (aside?.depth !== stack.length)
|
|
38075
|
+
return;
|
|
38076
|
+
open2.pop();
|
|
38077
|
+
const words = countWords(aside.text.join(""));
|
|
38078
|
+
layout[aside.index] = countWords(aside.linkText.join("")) * 2 >= words;
|
|
38079
|
+
if (open2.length === 0)
|
|
38080
|
+
for (const event of held.splice(0))
|
|
38081
|
+
event();
|
|
38082
|
+
}
|
|
38083
|
+
};
|
|
38084
|
+
}
|
|
38085
|
+
function isLayout(landmark) {
|
|
38086
|
+
return landmark !== void 0 && LAYOUT_LANDMARKS.has(landmark);
|
|
38087
|
+
}
|
|
37968
38088
|
function elementContext(frame, classes) {
|
|
37969
38089
|
const classNames = classes?.split(WHITESPACE).filter(Boolean) ?? [];
|
|
37970
38090
|
return {
|
|
@@ -38038,7 +38158,7 @@ function collapseWhitespace(text3) {
|
|
|
38038
38158
|
function isWhitespace2(code2) {
|
|
38039
38159
|
return code2 === 32 || code2 === 10 || code2 === 9 || code2 === 13 || code2 === 12;
|
|
38040
38160
|
}
|
|
38041
|
-
var HEADING_LEVELS,
|
|
38161
|
+
var HEADING_LEVELS, SECTIONING_TAGS, SECTIONING_ROLES, SECTIONING_ROOTS, LANDMARK_ROLES, HIDDEN_TEXT_TAGS, INLINE_TAGS, WHITESPACE, WHITESPACE_RUNS, WORD_START, WORD_END;
|
|
38042
38162
|
var init_read_page = __esm({
|
|
38043
38163
|
"../built-site/dist/read-page.js"() {
|
|
38044
38164
|
"use strict";
|
|
@@ -38053,9 +38173,9 @@ var init_read_page = __esm({
|
|
|
38053
38173
|
["h5", 5],
|
|
38054
38174
|
["h6", 6]
|
|
38055
38175
|
]);
|
|
38056
|
-
LANDMARK_TAGS = /* @__PURE__ */ new Set(["header", "nav", "main", "aside", "footer"]);
|
|
38057
38176
|
SECTIONING_TAGS = /* @__PURE__ */ new Set(["article", "aside", "main", "nav", "section"]);
|
|
38058
38177
|
SECTIONING_ROLES = /* @__PURE__ */ new Set(["article", "complementary", "main", "navigation", "region"]);
|
|
38178
|
+
SECTIONING_ROOTS = /* @__PURE__ */ new Set(["blockquote", "details", "dialog", "fieldset", "figure", "td"]);
|
|
38059
38179
|
LANDMARK_ROLES = /* @__PURE__ */ new Map([
|
|
38060
38180
|
["banner", "header"],
|
|
38061
38181
|
["navigation", "nav"],
|
|
@@ -40625,7 +40745,7 @@ var init_dist6 = __esm({
|
|
|
40625
40745
|
import { createHash } from "node:crypto";
|
|
40626
40746
|
import { existsSync } from "node:fs";
|
|
40627
40747
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
40628
|
-
import { isAbsolute, join as join2 } from "node:path";
|
|
40748
|
+
import { extname, isAbsolute, join as join2 } from "node:path";
|
|
40629
40749
|
import { pathToFileURL } from "node:url";
|
|
40630
40750
|
import { glob } from "tinyglobby";
|
|
40631
40751
|
async function resolveContentFiles(positionals, cmd, options = {}) {
|
|
@@ -40657,12 +40777,13 @@ async function loadRegistry(registryPath2, options = {}) {
|
|
|
40657
40777
|
mod = await importFresh(resolvedPath);
|
|
40658
40778
|
} catch (err) {
|
|
40659
40779
|
if (err instanceof Error && "code" in err && err.code === "ERR_UNKNOWN_FILE_EXTENSION") {
|
|
40660
|
-
|
|
40780
|
+
const extension2 = extname(resolvedPath);
|
|
40781
|
+
throw new ProjectLoadError(2, /^\.[cm]?ts$/.test(extension2) ? `Importing a TypeScript registry needs Node 22.18+ (native type stripping): ${resolvedPath}` : `Node cannot import a ${extension2} registry module: ${resolvedPath}. Use a .ts, .mts, .js or .mjs file.`);
|
|
40661
40782
|
}
|
|
40662
40783
|
throw err;
|
|
40663
40784
|
}
|
|
40664
40785
|
if (!Array.isArray(mod.default)) {
|
|
40665
|
-
throw new
|
|
40786
|
+
throw new ProjectLoadError(2, `Registry module must default-export an array of block definitions: ${resolvedPath}`);
|
|
40666
40787
|
}
|
|
40667
40788
|
registry2.use(mod.default);
|
|
40668
40789
|
return registry2;
|
|
@@ -41372,7 +41493,7 @@ var init_project_config = __esm({
|
|
|
41372
41493
|
|
|
41373
41494
|
// src/write-file.ts
|
|
41374
41495
|
import { chmod, mkdir, realpath, rename, rm, stat as stat3, writeFile } from "node:fs/promises";
|
|
41375
|
-
import { basename, dirname as dirname4, join as join7 } from "node:path";
|
|
41496
|
+
import { basename as basename2, dirname as dirname4, join as join7 } from "node:path";
|
|
41376
41497
|
async function writeFileAtomic(path4, content3) {
|
|
41377
41498
|
const target = await realpath(path4).catch(() => path4);
|
|
41378
41499
|
const mode = await stat3(target).then(
|
|
@@ -41380,7 +41501,7 @@ async function writeFileAtomic(path4, content3) {
|
|
|
41380
41501
|
() => void 0
|
|
41381
41502
|
);
|
|
41382
41503
|
await mkdir(dirname4(target), { recursive: true });
|
|
41383
|
-
const temp = join7(dirname4(target), `.${
|
|
41504
|
+
const temp = join7(dirname4(target), `.${basename2(target)}.${process.pid}.${temps++}.tmp`);
|
|
41384
41505
|
try {
|
|
41385
41506
|
await writeFile(temp, content3, { encoding: "utf8", flush: true });
|
|
41386
41507
|
if (mode !== void 0) await chmod(temp, mode);
|
|
@@ -41837,12 +41958,12 @@ async function checkAgentIntegration(cwd, options, io) {
|
|
|
41837
41958
|
io.stdout(`would install: .claude/skills/${name}/SKILL.md (version ${shippedVersion})`);
|
|
41838
41959
|
continue;
|
|
41839
41960
|
}
|
|
41840
|
-
const
|
|
41961
|
+
const installedVersion2 = skillVersion(installed) ?? "unknown";
|
|
41841
41962
|
if (installed === content3) {
|
|
41842
|
-
io.stdout(`up-to-date: .claude/skills/${name}/SKILL.md (version ${
|
|
41963
|
+
io.stdout(`up-to-date: .claude/skills/${name}/SKILL.md (version ${installedVersion2})`);
|
|
41843
41964
|
} else {
|
|
41844
41965
|
io.stdout(
|
|
41845
|
-
`stale: .claude/skills/${name}/SKILL.md (installed ${
|
|
41966
|
+
`stale: .claude/skills/${name}/SKILL.md (installed ${installedVersion2}, package ${shippedVersion})`
|
|
41846
41967
|
);
|
|
41847
41968
|
}
|
|
41848
41969
|
}
|
|
@@ -41932,7 +42053,7 @@ var init_agents = __esm({
|
|
|
41932
42053
|
});
|
|
41933
42054
|
|
|
41934
42055
|
// src/commands/find-markdown.ts
|
|
41935
|
-
import { basename as
|
|
42056
|
+
import { basename as basename3, extname as extname2, join as join9, relative as relative6, sep as sep5 } from "node:path";
|
|
41936
42057
|
import { glob as glob2 } from "tinyglobby";
|
|
41937
42058
|
async function findMarkdown(root) {
|
|
41938
42059
|
const builds = buildFolders(root).map(
|
|
@@ -41942,7 +42063,7 @@ async function findMarkdown(root) {
|
|
|
41942
42063
|
cwd: root,
|
|
41943
42064
|
ignore: ["**/node_modules/**", "coverage/**", ...builds]
|
|
41944
42065
|
});
|
|
41945
|
-
const pages = found.filter((file2) => !NOT_PAGES.has(
|
|
42066
|
+
const pages = found.filter((file2) => !NOT_PAGES.has(basename3(file2, extname2(file2)).toLowerCase())).toSorted();
|
|
41946
42067
|
const dirs = /* @__PURE__ */ new Set();
|
|
41947
42068
|
const rootFiles = [];
|
|
41948
42069
|
for (const file2 of pages) {
|
|
@@ -41976,8 +42097,36 @@ var init_find_markdown = __esm({
|
|
|
41976
42097
|
});
|
|
41977
42098
|
|
|
41978
42099
|
// src/commands/init-targets.ts
|
|
41979
|
-
import { existsSync as existsSync7 } from "node:fs";
|
|
41980
|
-
import { join as join10 } from "node:path";
|
|
42100
|
+
import { existsSync as existsSync7, readFileSync as readFileSync4 } from "node:fs";
|
|
42101
|
+
import { dirname as dirname6, join as join10 } from "node:path";
|
|
42102
|
+
function installedManifest(cwd, name) {
|
|
42103
|
+
for (let dir = cwd; ; dir = dirname6(dir)) {
|
|
42104
|
+
const path4 = join10(dir, "node_modules", name, "package.json");
|
|
42105
|
+
if (existsSync7(path4)) return JSON.parse(readFileSync4(path4, "utf8"));
|
|
42106
|
+
if (dirname6(dir) === dir) return void 0;
|
|
42107
|
+
}
|
|
42108
|
+
}
|
|
42109
|
+
function astroMarkdown(cwd, deps) {
|
|
42110
|
+
const version2 = installedManifest(cwd, "astro")?.version ?? deps.astro ?? "";
|
|
42111
|
+
const major = Number(/\d+/.exec(version2)?.[0] ?? 7);
|
|
42112
|
+
return major < 7 ? "@astrojs/markdown-remark" : "@astrojs/markdown-satteri";
|
|
42113
|
+
}
|
|
42114
|
+
function astroMarkdownDependency(md, cwd) {
|
|
42115
|
+
const range = installedManifest(cwd, "astro")?.dependencies?.[md];
|
|
42116
|
+
return range ? `${md}@${range}` : md;
|
|
42117
|
+
}
|
|
42118
|
+
function astroMarkdownTemplate(md) {
|
|
42119
|
+
return `// Astro's own Markdown processor renders the prose between blocks and inside
|
|
42120
|
+
// them. Pass it to ContentBlocks as renderMarkdown.
|
|
42121
|
+
import { ${ASTRO_MARKDOWN[md]} } from '${md}'
|
|
42122
|
+
|
|
42123
|
+
const processor = ${ASTRO_MARKDOWN[md]}()
|
|
42124
|
+
|
|
42125
|
+
export async function renderMarkdown(markdown: string): Promise<string> {
|
|
42126
|
+
return (await (await processor).render(markdown)).code
|
|
42127
|
+
}
|
|
42128
|
+
`;
|
|
42129
|
+
}
|
|
41981
42130
|
function blockComponentsTemplate(styled) {
|
|
41982
42131
|
const body = styled ? ` return (
|
|
41983
42132
|
<figure className="my-6 border-s-2 ps-4">
|
|
@@ -42067,9 +42216,15 @@ function detectFramework2(cwd, deps) {
|
|
|
42067
42216
|
}
|
|
42068
42217
|
return { framework: null, componentPath: "components/content-blocks.tsx", pagePath: null };
|
|
42069
42218
|
}
|
|
42070
|
-
function astroPage(styled) {
|
|
42219
|
+
function astroPage(styled, md) {
|
|
42071
42220
|
const importLine = styled ? "import ContentRenderer from '../components/content-blocks/content-renderer.astro'" : "import { ContentBlocks } from '@contentbit/astro/components'";
|
|
42072
42221
|
const renderer = styled ? "ContentRenderer" : "ContentBlocks";
|
|
42222
|
+
const components = styled ? "{ quote: QuoteBlock }" : "{ callout: CalloutBlock, steps: StepsBlock, quote: QuoteBlock }";
|
|
42223
|
+
const headlessImports = styled ? "" : `import CalloutBlock from '../../blocks/CalloutBlock.astro'
|
|
42224
|
+
import StepsBlock from '../../blocks/StepsBlock.astro'
|
|
42225
|
+
`;
|
|
42226
|
+
const prose = isAstroMd(md) ? "\n renderMarkdown={renderMarkdown}" : "";
|
|
42227
|
+
const proseImport = isAstroMd(md) ? "import { renderMarkdown } from '../../blocks/markdown'\n" : "";
|
|
42073
42228
|
return `---
|
|
42074
42229
|
import { genericBlocks } from '@contentbit/blocks'
|
|
42075
42230
|
import { assertValidDocument, compileDocument, createBlockRegistry } from '@contentbit/core'
|
|
@@ -42081,7 +42236,7 @@ ${importLine}
|
|
|
42081
42236
|
|
|
42082
42237
|
// Definitions in blocks/registry.ts are shared with the validate CLI.
|
|
42083
42238
|
import customBlocks from '../../blocks/registry'
|
|
42084
|
-
import QuoteBlock from '../../blocks/QuoteBlock.astro'
|
|
42239
|
+
${proseImport}${headlessImports}import QuoteBlock from '../../blocks/QuoteBlock.astro'
|
|
42085
42240
|
|
|
42086
42241
|
const registry = createBlockRegistry().use(genericBlocks()).use(customBlocks)
|
|
42087
42242
|
// Static pages render at build time, so invalid blocks fail the build here.
|
|
@@ -42097,7 +42252,10 @@ const document = assertValidDocument(compileDocument(source, registry), 'content
|
|
|
42097
42252
|
</head>
|
|
42098
42253
|
<body>
|
|
42099
42254
|
<main style="max-width: 42rem; margin: 0 auto; padding: 3rem 1.5rem;">
|
|
42100
|
-
<${renderer}
|
|
42255
|
+
<${renderer}
|
|
42256
|
+
document={document}
|
|
42257
|
+
components={${components}}${prose}
|
|
42258
|
+
/>
|
|
42101
42259
|
</main>
|
|
42102
42260
|
</body>
|
|
42103
42261
|
</html>
|
|
@@ -42133,13 +42291,22 @@ async function createReactPlan(ctx) {
|
|
|
42133
42291
|
}
|
|
42134
42292
|
async function createAstroPlan(ctx) {
|
|
42135
42293
|
const files = [["blocks/QuoteBlock.astro", ASTRO_QUOTE_BLOCK]];
|
|
42294
|
+
if (isAstroMd(ctx.md)) {
|
|
42295
|
+
files.push(["blocks/markdown.ts", astroMarkdownTemplate(ctx.md)]);
|
|
42296
|
+
}
|
|
42136
42297
|
const componentsJsonPath = join10(ctx.cwd, "components.json");
|
|
42137
42298
|
const styled = !ctx.noStyled && existsSync7(componentsJsonPath) && await ctx.installStyledPack("@contentbit/astro-pack");
|
|
42138
|
-
if (!ctx.noPage)
|
|
42299
|
+
if (!ctx.noPage) {
|
|
42300
|
+
if (!styled) {
|
|
42301
|
+
files.push(["blocks/CalloutBlock.astro", ASTRO_CALLOUT_BLOCK]);
|
|
42302
|
+
files.push(["blocks/StepsBlock.astro", ASTRO_STEPS_BLOCK]);
|
|
42303
|
+
}
|
|
42304
|
+
files.push(["src/pages/example.astro", astroPage(styled, ctx.md)]);
|
|
42305
|
+
}
|
|
42139
42306
|
return {
|
|
42140
42307
|
files,
|
|
42141
42308
|
render: [
|
|
42142
|
-
ctx.noPage ?
|
|
42309
|
+
ctx.noPage ? `Wire content/ into your Astro content collection and render it with @contentbit/astro${isAstroMd(ctx.md) ? ", passing renderMarkdown from blocks/markdown.ts" : ""}.` : "Start the dev server and open /example to see the article rendered."
|
|
42143
42310
|
],
|
|
42144
42311
|
extras: [`Styled components: ${ctx.dlx} shadcn@latest add @contentbit/astro-pack`]
|
|
42145
42312
|
};
|
|
@@ -42149,10 +42316,15 @@ function detectTarget(deps) {
|
|
|
42149
42316
|
const hasAstro = Boolean(deps.astro);
|
|
42150
42317
|
return hasAstro ? "astro" : hasReact ? "react" : "markdown";
|
|
42151
42318
|
}
|
|
42152
|
-
var TARGETS, TANSTACK_PAGE, NEXT_PAGE, ASTRO_QUOTE_BLOCK, TARGET_ADAPTERS;
|
|
42319
|
+
var ASTRO_MARKDOWN, isAstroMd, TARGETS, TANSTACK_PAGE, NEXT_PAGE, ASTRO_QUOTE_BLOCK, ASTRO_CALLOUT_BLOCK, ASTRO_STEPS_BLOCK, TARGET_ADAPTERS;
|
|
42153
42320
|
var init_init_targets = __esm({
|
|
42154
42321
|
"src/commands/init-targets.ts"() {
|
|
42155
42322
|
"use strict";
|
|
42323
|
+
ASTRO_MARKDOWN = {
|
|
42324
|
+
"@astrojs/markdown-satteri": "createSatteriMarkdownProcessor",
|
|
42325
|
+
"@astrojs/markdown-remark": "createMarkdownProcessor"
|
|
42326
|
+
};
|
|
42327
|
+
isAstroMd = (md) => md in ASTRO_MARKDOWN;
|
|
42156
42328
|
TARGETS = ["react", "markdown", "astro"];
|
|
42157
42329
|
TANSTACK_PAGE = `import { createFileRoute } from '@tanstack/react-router'
|
|
42158
42330
|
|
|
@@ -42205,15 +42377,54 @@ const { author, role } = Astro.props
|
|
|
42205
42377
|
\u2014 {author}{role ? \`, \${role}\` : null}
|
|
42206
42378
|
</figcaption>
|
|
42207
42379
|
</figure>
|
|
42380
|
+
`;
|
|
42381
|
+
ASTRO_CALLOUT_BLOCK = `---
|
|
42382
|
+
// The Astro component for the generic \`callout\` block.
|
|
42383
|
+
// Block props arrive as component props; its Markdown arrives via <slot />.
|
|
42384
|
+
interface Props {
|
|
42385
|
+
type?: 'note' | 'tip' | 'warning' | 'important' | 'tldr'
|
|
42386
|
+
title?: string
|
|
42387
|
+
}
|
|
42388
|
+
|
|
42389
|
+
const { type = 'note', title } = Astro.props
|
|
42390
|
+
---
|
|
42391
|
+
|
|
42392
|
+
<aside
|
|
42393
|
+
data-type={type}
|
|
42394
|
+
style="margin: 1.5rem 0; border: 1px solid #d4d4d4; border-radius: 0.5rem; padding: 0 1rem;"
|
|
42395
|
+
>
|
|
42396
|
+
{title ? <p><strong>{title}</strong></p> : null}
|
|
42397
|
+
<slot />
|
|
42398
|
+
</aside>
|
|
42399
|
+
`;
|
|
42400
|
+
ASTRO_STEPS_BLOCK = `---
|
|
42401
|
+
// The Astro component for the generic \`steps\` block. Each step is Markdown,
|
|
42402
|
+
// rendered through ctx.renderMarkdown.
|
|
42403
|
+
import type { AstroBlockContext } from '@contentbit/astro'
|
|
42404
|
+
import type { StepsData } from '@contentbit/blocks'
|
|
42405
|
+
import type { ValidatedBlockNode } from '@contentbit/core'
|
|
42406
|
+
|
|
42407
|
+
interface Props {
|
|
42408
|
+
node: ValidatedBlockNode<StepsData>
|
|
42409
|
+
ctx: AstroBlockContext
|
|
42410
|
+
}
|
|
42411
|
+
|
|
42412
|
+
const { node, ctx } = Astro.props
|
|
42413
|
+
const steps = await Promise.all(node.data.items.map((item) => ctx.renderMarkdown(item.text)))
|
|
42414
|
+
---
|
|
42415
|
+
|
|
42416
|
+
<ol style="margin: 1.5rem 0; padding-left: 1.5rem;">
|
|
42417
|
+
{steps.map((html) => <li set:html={html} />)}
|
|
42418
|
+
</ol>
|
|
42208
42419
|
`;
|
|
42209
42420
|
TARGET_ADAPTERS = {
|
|
42210
42421
|
react: {
|
|
42211
|
-
markdownChoices: ["react-markdown", "none"],
|
|
42422
|
+
markdownChoices: () => ["react-markdown", "none"],
|
|
42212
42423
|
runtimeDependencies: reactRuntime,
|
|
42213
42424
|
createPlan: createReactPlan
|
|
42214
42425
|
},
|
|
42215
42426
|
markdown: {
|
|
42216
|
-
markdownChoices: ["none"],
|
|
42427
|
+
markdownChoices: () => ["none"],
|
|
42217
42428
|
runtimeDependencies: () => [],
|
|
42218
42429
|
createPlan: ({ examples: examples2 }) => Promise.resolve({
|
|
42219
42430
|
files: [],
|
|
@@ -42224,9 +42435,11 @@ const { author, role } = Astro.props
|
|
|
42224
42435
|
})
|
|
42225
42436
|
},
|
|
42226
42437
|
astro: {
|
|
42227
|
-
|
|
42228
|
-
|
|
42229
|
-
|
|
42438
|
+
markdownChoices: (cwd, deps) => [astroMarkdown(cwd, deps), "none"],
|
|
42439
|
+
runtimeDependencies: (md, cwd) => [
|
|
42440
|
+
"@contentbit/astro",
|
|
42441
|
+
...isAstroMd(md) ? [astroMarkdownDependency(md, cwd)] : []
|
|
42442
|
+
],
|
|
42230
42443
|
createPlan: createAstroPlan
|
|
42231
42444
|
}
|
|
42232
42445
|
};
|
|
@@ -42234,9 +42447,9 @@ const { author, role } = Astro.props
|
|
|
42234
42447
|
});
|
|
42235
42448
|
|
|
42236
42449
|
// src/commands/init-blocks.ts
|
|
42237
|
-
import { existsSync as existsSync8
|
|
42450
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
42238
42451
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
42239
|
-
import {
|
|
42452
|
+
import { join as join11 } from "node:path";
|
|
42240
42453
|
async function prepareBlocks(input2, cwd, deps, io) {
|
|
42241
42454
|
const interactive = !input2.yes && process.stdin.isTTY && process.stdout.isTTY;
|
|
42242
42455
|
let target;
|
|
@@ -42262,7 +42475,7 @@ async function prepareBlocks(input2, cwd, deps, io) {
|
|
|
42262
42475
|
} else {
|
|
42263
42476
|
target = detectTarget(deps);
|
|
42264
42477
|
}
|
|
42265
|
-
const choices = TARGET_ADAPTERS[target].markdownChoices;
|
|
42478
|
+
const choices = TARGET_ADAPTERS[target].markdownChoices(cwd, deps);
|
|
42266
42479
|
let md;
|
|
42267
42480
|
if (input2.md) {
|
|
42268
42481
|
if (!choices.includes(input2.md)) {
|
|
@@ -42300,7 +42513,7 @@ async function prepareBlocks(input2, cwd, deps, io) {
|
|
|
42300
42513
|
"@contentbit/core",
|
|
42301
42514
|
"@contentbit/blocks",
|
|
42302
42515
|
...zod === void 0 ? ["zod@^4"] : [],
|
|
42303
|
-
...TARGET_ADAPTERS[target].runtimeDependencies(md)
|
|
42516
|
+
...TARGET_ADAPTERS[target].runtimeDependencies(md, cwd)
|
|
42304
42517
|
],
|
|
42305
42518
|
dev: ["@contentbit/studio"]
|
|
42306
42519
|
};
|
|
@@ -42353,15 +42566,8 @@ async function writeBlockGuide(cwd, io) {
|
|
|
42353
42566
|
io.stdout(`created: ${GUIDE_PATH} (LLM authoring instructions)`);
|
|
42354
42567
|
}
|
|
42355
42568
|
function zodMajor(cwd, deps) {
|
|
42356
|
-
|
|
42357
|
-
|
|
42358
|
-
if (existsSync8(manifest)) {
|
|
42359
|
-
const { version: version2 } = JSON.parse(readFileSync4(manifest, "utf8"));
|
|
42360
|
-
return Number(version2.split(".")[0]);
|
|
42361
|
-
}
|
|
42362
|
-
if (dirname6(dir) === dir) break;
|
|
42363
|
-
}
|
|
42364
|
-
const major = deps.zod === void 0 ? void 0 : /(\d+)/.exec(deps.zod)?.[1];
|
|
42569
|
+
const version2 = installedManifest(cwd, "zod")?.version ?? deps.zod;
|
|
42570
|
+
const major = version2 === void 0 ? void 0 : /(\d+)/.exec(version2)?.[1];
|
|
42365
42571
|
return major === void 0 ? void 0 : Number(major);
|
|
42366
42572
|
}
|
|
42367
42573
|
function dlxCommand(pm) {
|
|
@@ -42657,7 +42863,7 @@ __export(init_exports, {
|
|
|
42657
42863
|
initCommand: () => initCommand
|
|
42658
42864
|
});
|
|
42659
42865
|
import { readFile as readFile6 } from "node:fs/promises";
|
|
42660
|
-
import { basename as
|
|
42866
|
+
import { basename as basename4, join as join14, resolve as resolve7 } from "node:path";
|
|
42661
42867
|
async function scaffold(path4, content3) {
|
|
42662
42868
|
try {
|
|
42663
42869
|
await readFile6(path4, "utf8");
|
|
@@ -42730,7 +42936,7 @@ async function initCommand(input2, io) {
|
|
|
42730
42936
|
...existing.config.site?.build || !site.siteBuild ? [] : siteBuildConfig(site.siteBuild),
|
|
42731
42937
|
...existing.config.links?.routes || !site.proposal ? [] : linksConfig(site.proposal)
|
|
42732
42938
|
];
|
|
42733
|
-
const name =
|
|
42939
|
+
const name = basename4(existing.path);
|
|
42734
42940
|
if (missing.length === 0) io.stdout(`kept: ${name}`);
|
|
42735
42941
|
else {
|
|
42736
42942
|
io.stdout(`kept: ${name}. Add what check needs to it, merged with the fields it has:`);
|
|
@@ -42792,6 +42998,14 @@ async function initCommand(input2, io) {
|
|
|
42792
42998
|
);
|
|
42793
42999
|
}
|
|
42794
43000
|
}
|
|
43001
|
+
for (const [name, command] of Object.entries(scripts)) {
|
|
43002
|
+
const removed = name === "content:check" ? void 0 : REMOVED_COMMAND.exec(command)?.[0];
|
|
43003
|
+
if (removed) {
|
|
43004
|
+
io.stdout(
|
|
43005
|
+
`kept script: ${name}, which runs "${removed}", a command 2.0 removed. Remove it: contentbit check and contentbit context replace the removed commands.`
|
|
43006
|
+
);
|
|
43007
|
+
}
|
|
43008
|
+
}
|
|
42795
43009
|
if (Object.keys(scripts).length !== Object.keys(fresh.scripts ?? {}).length) {
|
|
42796
43010
|
await writeFileAtomic(pkgPath, `${JSON.stringify({ ...fresh, scripts }, null, 2)}
|
|
42797
43011
|
`);
|
|
@@ -42867,11 +43081,12 @@ function siteSummary({ framework, serverRendered: serverRendered2, siteBuild, fo
|
|
|
42867
43081
|
}
|
|
42868
43082
|
return lines;
|
|
42869
43083
|
}
|
|
42870
|
-
var SEO_CONFIG_TEMPLATE, SCRIPTS;
|
|
43084
|
+
var SEO_CONFIG_TEMPLATE, SCRIPTS, REMOVED_COMMAND;
|
|
42871
43085
|
var init_init = __esm({
|
|
42872
43086
|
"src/commands/init.ts"() {
|
|
42873
43087
|
"use strict";
|
|
42874
43088
|
init_dist();
|
|
43089
|
+
init_run();
|
|
42875
43090
|
init_content_project();
|
|
42876
43091
|
init_package_manager();
|
|
42877
43092
|
init_project_config();
|
|
@@ -42941,6 +43156,7 @@ export default {
|
|
|
42941
43156
|
"content:check": "contentbit check",
|
|
42942
43157
|
"content:context": "contentbit context"
|
|
42943
43158
|
};
|
|
43159
|
+
REMOVED_COMMAND = new RegExp(`\\bcontentbit (?:${[...REMOVED_COMMANDS.keys()].join("|")})\\b`);
|
|
42944
43160
|
}
|
|
42945
43161
|
});
|
|
42946
43162
|
|
|
@@ -44066,6 +44282,11 @@ function targetPage(context, target, cwd) {
|
|
|
44066
44282
|
2,
|
|
44067
44283
|
`context: ${target} names ${found.pages.length} built pages: ${found.pages.join(", ")}. Pass the path of one of them.`
|
|
44068
44284
|
);
|
|
44285
|
+
case "ambiguous-file":
|
|
44286
|
+
throw new CliError(
|
|
44287
|
+
2,
|
|
44288
|
+
`context: ${target} names ${found.files.length} Markdown files: ${found.files.map(displayPath).join(", ")}. Pass the path of one of them.`
|
|
44289
|
+
);
|
|
44069
44290
|
case "unbuilt": {
|
|
44070
44291
|
const { file: file2, route } = found.document;
|
|
44071
44292
|
const reason = context.sources.unpublished.has(found.document) ? "It is a draft or dated after today, so the site does not publish it yet." : route === void 0 ? "links.routes gives it no route. Add its folder to links.routes in the contentbit config." : `links.routes gives it the route ${route}, which the build does not have. Build the site, or fix links.routes if the site serves the file at another URL.`;
|
|
@@ -44863,7 +45084,7 @@ function getDataProtocolModuleFormat(parsed) {
|
|
|
44863
45084
|
) || [null, null, null];
|
|
44864
45085
|
return mimeToFormat(mime);
|
|
44865
45086
|
}
|
|
44866
|
-
function
|
|
45087
|
+
function extname3(url2) {
|
|
44867
45088
|
const pathname = url2.pathname;
|
|
44868
45089
|
let index2 = pathname.length;
|
|
44869
45090
|
while (index2--) {
|
|
@@ -44878,7 +45099,7 @@ function extname2(url2) {
|
|
|
44878
45099
|
return "";
|
|
44879
45100
|
}
|
|
44880
45101
|
function getFileProtocolModuleFormat(url2, _context, ignoreErrors) {
|
|
44881
|
-
const value =
|
|
45102
|
+
const value = extname3(url2);
|
|
44882
45103
|
if (value === ".js") {
|
|
44883
45104
|
const packageType = getPackageType(url2);
|
|
44884
45105
|
if (packageType !== "none") {
|
|
@@ -45813,8 +46034,9 @@ var studio_exports = {};
|
|
|
45813
46034
|
__export(studio_exports, {
|
|
45814
46035
|
studioCommand: () => studioCommand
|
|
45815
46036
|
});
|
|
45816
|
-
import {
|
|
45817
|
-
import {
|
|
46037
|
+
import { existsSync as existsSync14, readFileSync as readFileSync5 } from "node:fs";
|
|
46038
|
+
import { dirname as dirname11, join as join18, resolve as resolve12 } from "node:path";
|
|
46039
|
+
import { fileURLToPath as fileURLToPath4, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
45818
46040
|
async function studioCommand(input2, io) {
|
|
45819
46041
|
const config2 = await resolveContentCommandConfig("studio", input2);
|
|
45820
46042
|
const port = parsePort(input2.port);
|
|
@@ -45825,26 +46047,31 @@ async function studioCommand(input2, io) {
|
|
|
45825
46047
|
const origin = input2.origin === void 0 ? void 0 : parseFlagOrigin("studio", input2.origin);
|
|
45826
46048
|
const build = input2.build === void 0 ? void 0 : resolve12(input2.build);
|
|
45827
46049
|
await requireSiteToShow(config2, { build, origin });
|
|
46050
|
+
const cwd = config2.cwd ?? process.cwd();
|
|
46051
|
+
const pm = detectPackageManager(cwd);
|
|
46052
|
+
const install = [pm, ...addCommand(pm, [`@contentbit/studio@${VERSION}`], true)].join(" ");
|
|
45828
46053
|
let studioUrl;
|
|
45829
46054
|
try {
|
|
45830
|
-
studioUrl = resolve11(
|
|
45831
|
-
"@contentbit/studio",
|
|
45832
|
-
pathToFileURL3(join18(config2.cwd ?? process.cwd(), "package.json")).href
|
|
45833
|
-
);
|
|
46055
|
+
studioUrl = resolve11("@contentbit/studio", pathToFileURL3(join18(cwd, "package.json")).href);
|
|
45834
46056
|
} catch (error62) {
|
|
45835
46057
|
if (!isMissingStudio(error62)) throw error62;
|
|
45836
46058
|
}
|
|
46059
|
+
const studioVersion = studioUrl && installedVersion(studioUrl);
|
|
46060
|
+
if (studioVersion && studioVersion !== VERSION) {
|
|
46061
|
+
throw new CliError(
|
|
46062
|
+
2,
|
|
46063
|
+
`studio: this project has @contentbit/studio ${studioVersion} and contentbit ${VERSION}, and Studio must be the same version as contentbit. Install it with ${install}, then run contentbit studio again.`
|
|
46064
|
+
);
|
|
46065
|
+
}
|
|
45837
46066
|
let startStudio;
|
|
45838
46067
|
try {
|
|
45839
46068
|
;
|
|
45840
46069
|
({ startStudio } = await (studioUrl ? import(studioUrl) : import("@contentbit/studio")));
|
|
45841
46070
|
} catch (error62) {
|
|
45842
46071
|
if (!studioUrl && isMissingStudio(error62)) {
|
|
45843
|
-
const cwd = config2.cwd ?? process.cwd();
|
|
45844
|
-
const name = detectPackageManager(cwd);
|
|
45845
46072
|
throw new CliError(
|
|
45846
46073
|
2,
|
|
45847
|
-
`studio: Studio is a separate package, a local web app that the check does not need. Install it in this project with ${
|
|
46074
|
+
`studio: Studio is a separate package, a local web app that the check does not need. Install it in this project with ${install}, then run contentbit studio again.`
|
|
45848
46075
|
);
|
|
45849
46076
|
}
|
|
45850
46077
|
throw error62;
|
|
@@ -45905,6 +46132,15 @@ function isLoopbackHost(host) {
|
|
|
45905
46132
|
const name = host.toLowerCase().replace(/^\[(.*)\]$/, "$1");
|
|
45906
46133
|
return name === "localhost" || name === "::1" || /^127\.\d+\.\d+\.\d+$/.test(name);
|
|
45907
46134
|
}
|
|
46135
|
+
function installedVersion(entryUrl) {
|
|
46136
|
+
for (let dir = dirname11(fileURLToPath4(entryUrl)); dir !== dirname11(dir); dir = dirname11(dir)) {
|
|
46137
|
+
const path4 = join18(dir, "package.json");
|
|
46138
|
+
if (!existsSync14(path4)) continue;
|
|
46139
|
+
const manifest = JSON.parse(readFileSync5(path4, "utf8"));
|
|
46140
|
+
if (manifest.name === "@contentbit/studio") return manifest.version;
|
|
46141
|
+
}
|
|
46142
|
+
return void 0;
|
|
46143
|
+
}
|
|
45908
46144
|
function isMissingStudio(error62) {
|
|
45909
46145
|
return error62 instanceof Error && "code" in error62 && error62.code === "ERR_MODULE_NOT_FOUND" && error62.message.includes("@contentbit/studio");
|
|
45910
46146
|
}
|
|
@@ -45919,6 +46155,7 @@ var init_studio = __esm({
|
|
|
45919
46155
|
"use strict";
|
|
45920
46156
|
init_run();
|
|
45921
46157
|
init_command_config();
|
|
46158
|
+
init_dist();
|
|
45922
46159
|
init_import_meta_resolve();
|
|
45923
46160
|
init_cli_format();
|
|
45924
46161
|
init_package_manager();
|
|
@@ -46092,6 +46329,8 @@ function createProgram(io, setExitCode) {
|
|
|
46092
46329
|
).addOption(
|
|
46093
46330
|
new Option("--md <library>", "With --blocks, the Markdown prose adapter to wire").choices([
|
|
46094
46331
|
"react-markdown",
|
|
46332
|
+
"@astrojs/markdown-satteri",
|
|
46333
|
+
"@astrojs/markdown-remark",
|
|
46095
46334
|
"none"
|
|
46096
46335
|
])
|
|
46097
46336
|
).option("-y, --yes", "Accept detected defaults without prompting").option("--cwd <path>", "Project directory to initialize").option("--no-install", "Scaffold files without installing packages").option("--no-page", "With --blocks, skip the example route or page").option("--no-styled", "With --blocks, skip installing the editable styled block pack").option("--no-agents", "Skip AGENTS.md and Claude Code guidance").option("--claude", "Install Claude Code skills and CLAUDE.md").option("--seo", "Scaffold SEO contracts and connect them in project config").addOption(
|