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