@contentbit/studio 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/README.md +3 -2
- package/dist/server/index.js +141 -30
- package/package.json +4 -4
- package/src/server/scan.test.ts +3 -3
- package/src/server/site.test.ts +3 -3
package/README.md
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
The local read-only dashboard of [contentbit](https://contentbit.dev), the SEO
|
|
4
4
|
content check for agents.
|
|
5
5
|
|
|
6
|
-
Studio is launched by the `contentbit` CLI
|
|
6
|
+
Studio is launched by the `contentbit` CLI, which starts only the Studio of
|
|
7
|
+
its own version. Install the same version as `contentbit`:
|
|
7
8
|
|
|
8
9
|
```bash
|
|
9
10
|
pnpm add -D @contentbit/studio
|
|
@@ -13,7 +14,7 @@ contentbit studio
|
|
|
13
14
|
`contentbit.config.ts` supplies the content glob, registry, and build folder.
|
|
14
15
|
Explicit globs and flags still override it for one invocation.
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
`contentbit init --blocks` adds a shorter script:
|
|
17
18
|
|
|
18
19
|
```bash
|
|
19
20
|
pnpm studio
|
package/dist/server/index.js
CHANGED
|
@@ -1842,7 +1842,7 @@ var DEFAULT_SEVERITY_BY_CODE = {
|
|
|
1842
1842
|
CB_LINK_PAGE_MISSING: "error",
|
|
1843
1843
|
CB_LINK_ANCHOR_MISSING: "error",
|
|
1844
1844
|
CB_LINK_FILE_MISSING: "error",
|
|
1845
|
-
CB_LINK_NOINDEX_TARGET: "
|
|
1845
|
+
CB_LINK_NOINDEX_TARGET: "info",
|
|
1846
1846
|
CB_SITE_HREFLANG_NOT_RECIPROCAL: "warning",
|
|
1847
1847
|
CB_SITE_HREFLANG_X_DEFAULT_MISSING: "warning",
|
|
1848
1848
|
CB_SITE_SITEMAP_URL_NOT_BUILT: "error",
|
|
@@ -1929,9 +1929,6 @@ var LAYOUT_LANDMARKS = /* @__PURE__ */ new Set([
|
|
|
1929
1929
|
"aside",
|
|
1930
1930
|
"footer"
|
|
1931
1931
|
]);
|
|
1932
|
-
function linkPlacement({ landmark }) {
|
|
1933
|
-
return landmark !== void 0 && LAYOUT_LANDMARKS.has(landmark) ? "layout" : "content";
|
|
1934
|
-
}
|
|
1935
1932
|
|
|
1936
1933
|
// ../built-site/dist/origin.js
|
|
1937
1934
|
function httpOrigin(value) {
|
|
@@ -2195,7 +2192,7 @@ function checkImages(index) {
|
|
|
2195
2192
|
}
|
|
2196
2193
|
|
|
2197
2194
|
// ../built-site/dist/checks/link-contract.js
|
|
2198
|
-
var LAYOUT_LINKS = "Links in the header, nav, aside or footer do not count.";
|
|
2195
|
+
var LAYOUT_LINKS = "Links in the header, nav, aside or footer, or outside the page content, do not count.";
|
|
2199
2196
|
function checkLinkContracts(index) {
|
|
2200
2197
|
const { sources, seo } = index;
|
|
2201
2198
|
if (!sources || !seo)
|
|
@@ -2204,7 +2201,7 @@ function checkLinkContracts(index) {
|
|
|
2204
2201
|
const linksOut = /* @__PURE__ */ new Map();
|
|
2205
2202
|
const linksIn = /* @__PURE__ */ new Map();
|
|
2206
2203
|
forEachLinkBetweenPages(index, (from, link, to) => {
|
|
2207
|
-
if (
|
|
2204
|
+
if (link.placement === "layout")
|
|
2208
2205
|
return;
|
|
2209
2206
|
linksOut.set(from, (linksOut.get(from) ?? /* @__PURE__ */ new Set()).add(to));
|
|
2210
2207
|
linksIn.set(to, (linksIn.get(to) ?? /* @__PURE__ */ new Set()).add(from));
|
|
@@ -2472,7 +2469,7 @@ function compare(a, b) {
|
|
|
2472
2469
|
}
|
|
2473
2470
|
|
|
2474
2471
|
// ../built-site/dist/context.js
|
|
2475
|
-
import { relative, resolve } from "node:path";
|
|
2472
|
+
import { basename, relative, resolve } from "node:path";
|
|
2476
2473
|
import { closest, createSeoBrief } from "@contentbit/core";
|
|
2477
2474
|
|
|
2478
2475
|
// ../built-site/dist/finding-origins.js
|
|
@@ -2642,7 +2639,7 @@ function pageContext(input, page) {
|
|
|
2642
2639
|
from: from.path,
|
|
2643
2640
|
text: link.text,
|
|
2644
2641
|
...anchor !== void 0 && { anchor },
|
|
2645
|
-
placement:
|
|
2642
|
+
placement: link.placement
|
|
2646
2643
|
});
|
|
2647
2644
|
});
|
|
2648
2645
|
return {
|
|
@@ -2670,7 +2667,7 @@ function pageContext(input, page) {
|
|
|
2670
2667
|
linksOut: facts.links.map((link) => ({
|
|
2671
2668
|
href: link.href,
|
|
2672
2669
|
text: link.text,
|
|
2673
|
-
placement:
|
|
2670
|
+
placement: link.placement,
|
|
2674
2671
|
target: linkOutTarget(index.resolveLink(link.href, page))
|
|
2675
2672
|
})),
|
|
2676
2673
|
findings: input.findings.filter((finding) => findingPages(finding).includes(page.path)).map((finding) => onPage(finding, page.path)),
|
|
@@ -2690,7 +2687,7 @@ function siteContext(input) {
|
|
|
2690
2687
|
return counts;
|
|
2691
2688
|
};
|
|
2692
2689
|
forEachLinkBetweenPages(index, (_from, link, to) => {
|
|
2693
|
-
linksInto(to)[
|
|
2690
|
+
linksInto(to)[link.placement]++;
|
|
2694
2691
|
});
|
|
2695
2692
|
const pages = input.site.pages.map((page) => {
|
|
2696
2693
|
const document = input.sources.pages.get(page.path);
|
|
@@ -4972,9 +4969,9 @@ var HEADING_LEVELS = /* @__PURE__ */ new Map([
|
|
|
4972
4969
|
["h5", 5],
|
|
4973
4970
|
["h6", 6]
|
|
4974
4971
|
]);
|
|
4975
|
-
var LANDMARK_TAGS = /* @__PURE__ */ new Set(["header", "nav", "main", "aside", "footer"]);
|
|
4976
4972
|
var SECTIONING_TAGS = /* @__PURE__ */ new Set(["article", "aside", "main", "nav", "section"]);
|
|
4977
4973
|
var SECTIONING_ROLES = /* @__PURE__ */ new Set(["article", "complementary", "main", "navigation", "region"]);
|
|
4974
|
+
var SECTIONING_ROOTS = /* @__PURE__ */ new Set(["blockquote", "details", "dialog", "fieldset", "figure", "td"]);
|
|
4978
4975
|
var LANDMARK_ROLES = /* @__PURE__ */ new Map([
|
|
4979
4976
|
["banner", "header"],
|
|
4980
4977
|
["navigation", "nav"],
|
|
@@ -5046,8 +5043,16 @@ function readRenderedPageFacts(html) {
|
|
|
5046
5043
|
const main = emptyRegion();
|
|
5047
5044
|
let hasMain = false;
|
|
5048
5045
|
let h1OutsideMain = false;
|
|
5049
|
-
const
|
|
5046
|
+
const h1Articles = /* @__PURE__ */ new Set();
|
|
5047
|
+
const regions = (frame) => [
|
|
5048
|
+
page,
|
|
5049
|
+
...frame?.main ? [main] : [],
|
|
5050
|
+
...frame?.article && !frame.articleFooter ? [frame.article] : []
|
|
5051
|
+
];
|
|
5052
|
+
const pendingLinks = [];
|
|
5050
5053
|
let permalink;
|
|
5054
|
+
const layoutAsides = [];
|
|
5055
|
+
let asides = 0;
|
|
5051
5056
|
const capture = (finish, { visibleOnly = false, imageAlts = false } = {}) => captures.push({ depth: stack.length - 1, parts: [], visibleOnly, imageAlts, finish });
|
|
5052
5057
|
let wordBreak = false;
|
|
5053
5058
|
let closed = false;
|
|
@@ -5055,7 +5060,8 @@ function readRenderedPageFacts(html) {
|
|
|
5055
5060
|
for (const open of captures)
|
|
5056
5061
|
if (open.parts.at(-1) !== " ")
|
|
5057
5062
|
open.parts.push(" ");
|
|
5058
|
-
|
|
5063
|
+
const article = stack.at(-1)?.article;
|
|
5064
|
+
for (const region of article ? [page, main, article] : [page, main]) {
|
|
5059
5065
|
const { parts } = region.open;
|
|
5060
5066
|
if (parts.at(-1) !== " ")
|
|
5061
5067
|
parts.push(" ");
|
|
@@ -5066,24 +5072,33 @@ function readRenderedPageFacts(html) {
|
|
|
5066
5072
|
parts.push(" ");
|
|
5067
5073
|
parts.push(text);
|
|
5068
5074
|
};
|
|
5069
|
-
const parser = new Parser({
|
|
5075
|
+
const parser = new Parser(deferAsides(layoutAsides, {
|
|
5070
5076
|
onopentag(name, attribs) {
|
|
5071
5077
|
const parent = stack.at(-1);
|
|
5072
5078
|
const role = attribs.role?.trim().toLowerCase().split(WHITESPACE)[0];
|
|
5073
|
-
const own = landmarkOf(name, role, parent
|
|
5079
|
+
const own = landmarkOf(name, role, parent, name === "aside" && layoutAsides[asides++]);
|
|
5074
5080
|
const landmark = own ?? parent?.landmark;
|
|
5075
5081
|
const visible = (parent?.visible ?? true) && !HIDDEN_TEXT_TAGS.has(name);
|
|
5076
5082
|
const level = HEADING_LEVELS.get(name);
|
|
5083
|
+
const sectioning = SECTIONING_TAGS.has(name) || role !== void 0 && SECTIONING_ROLES.has(role);
|
|
5077
5084
|
const frame = {
|
|
5078
5085
|
name,
|
|
5079
5086
|
landmark,
|
|
5080
|
-
sectioning: (parent?.sectioning ?? false)
|
|
5087
|
+
sectioning: sectioning || (parent?.sectioning ?? false),
|
|
5088
|
+
scope: own === "main" ? "main" : sectioning || SECTIONING_ROOTS.has(name) ? "other" : parent?.scope ?? "page",
|
|
5081
5089
|
visible,
|
|
5082
5090
|
svg: name === "svg" || (parent?.svg ?? false),
|
|
5083
|
-
content: visible && name !== "pre" && (parent?.content ?? true) && !(landmark
|
|
5091
|
+
content: visible && name !== "pre" && (parent?.content ?? true) && !isLayout(landmark) && !(name === "a" && attribs.href !== void 0 && attribs.href === permalink),
|
|
5084
5092
|
main: own === "main" || (parent?.main ?? false),
|
|
5093
|
+
article: parent?.article,
|
|
5094
|
+
articleFooter: (parent?.articleFooter ?? false) || name === "footer" && own === void 0 && parent?.scope === "article",
|
|
5085
5095
|
heading: level !== void 0 || (parent?.heading ?? false)
|
|
5086
5096
|
};
|
|
5097
|
+
const isArticle = role ? role === "article" : name === "article";
|
|
5098
|
+
if (isArticle && frame.main && frame.content && !frame.article) {
|
|
5099
|
+
frame.article = emptyRegion();
|
|
5100
|
+
frame.scope = "article";
|
|
5101
|
+
}
|
|
5087
5102
|
if (own === "main" && frame.content)
|
|
5088
5103
|
hasMain = true;
|
|
5089
5104
|
if (name !== "a" && !INLINE_TAGS.has(name))
|
|
@@ -5103,8 +5118,12 @@ function readRenderedPageFacts(html) {
|
|
|
5103
5118
|
openSection(region, heading);
|
|
5104
5119
|
permalink = attribs.id === void 0 ? void 0 : `#${attribs.id}`;
|
|
5105
5120
|
}
|
|
5106
|
-
if (level === 1 && frame.content
|
|
5107
|
-
|
|
5121
|
+
if (level === 1 && frame.content) {
|
|
5122
|
+
if (frame.main)
|
|
5123
|
+
h1Articles.add(frame.article);
|
|
5124
|
+
else
|
|
5125
|
+
h1OutsideMain = true;
|
|
5126
|
+
}
|
|
5108
5127
|
capture((text) => {
|
|
5109
5128
|
heading.text = collapseWhitespace(text);
|
|
5110
5129
|
heading.words = countWords(heading.text);
|
|
@@ -5138,9 +5157,12 @@ function readRenderedPageFacts(html) {
|
|
|
5138
5157
|
href: attribs.href,
|
|
5139
5158
|
...attribs.rel !== void 0 && { rel: attribs.rel },
|
|
5140
5159
|
...elementContext(frame, attribs.class),
|
|
5160
|
+
placement: "layout",
|
|
5141
5161
|
text: ""
|
|
5142
5162
|
};
|
|
5143
5163
|
facts.links.push(link);
|
|
5164
|
+
if (!isLayout(frame.landmark))
|
|
5165
|
+
pendingLinks.push({ link, within: regions(frame) });
|
|
5144
5166
|
const label = attribs["aria-label"];
|
|
5145
5167
|
capture((text) => link.text = collapseWhitespace(text) || collapseWhitespace(label ?? ""), { visibleOnly: true, imageAlts: true });
|
|
5146
5168
|
}
|
|
@@ -5197,10 +5219,16 @@ function readRenderedPageFacts(html) {
|
|
|
5197
5219
|
open.finish(open.parts.join(""));
|
|
5198
5220
|
}
|
|
5199
5221
|
}
|
|
5200
|
-
}, { decodeEntities: true });
|
|
5222
|
+
}), { decodeEntities: true });
|
|
5201
5223
|
parser.write(html);
|
|
5202
5224
|
parser.end();
|
|
5203
|
-
|
|
5225
|
+
const [h1Article] = h1Articles;
|
|
5226
|
+
const content = !hasMain || h1OutsideMain ? page : h1Articles.size === 1 && h1Article ? h1Article : main;
|
|
5227
|
+
for (const { link, within } of pendingLinks) {
|
|
5228
|
+
if (within.includes(content))
|
|
5229
|
+
link.placement = "content";
|
|
5230
|
+
}
|
|
5231
|
+
for (const { heading, parts } of content.sections) {
|
|
5204
5232
|
const body = collapseWhitespace(parts.join(""));
|
|
5205
5233
|
if (!heading) {
|
|
5206
5234
|
facts.intro = body;
|
|
@@ -5215,12 +5243,94 @@ function readRenderedPageFacts(html) {
|
|
|
5215
5243
|
facts.ids = [...ids];
|
|
5216
5244
|
return facts;
|
|
5217
5245
|
}
|
|
5218
|
-
function landmarkOf(name, role,
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5246
|
+
function landmarkOf(name, role, parent, layoutAside) {
|
|
5247
|
+
switch (name) {
|
|
5248
|
+
case "main":
|
|
5249
|
+
case "nav":
|
|
5250
|
+
return name;
|
|
5251
|
+
case "header":
|
|
5252
|
+
if (!parent?.sectioning)
|
|
5253
|
+
return name;
|
|
5254
|
+
break;
|
|
5255
|
+
case "footer":
|
|
5256
|
+
if (parent === void 0 || parent.scope === "page" || parent.scope === "main")
|
|
5257
|
+
return name;
|
|
5258
|
+
break;
|
|
5259
|
+
case "aside":
|
|
5260
|
+
if (layoutAside)
|
|
5261
|
+
return name;
|
|
5262
|
+
break;
|
|
5263
|
+
}
|
|
5222
5264
|
return role === void 0 ? void 0 : LANDMARK_ROLES.get(role);
|
|
5223
5265
|
}
|
|
5266
|
+
function deferAsides(layout, reader) {
|
|
5267
|
+
const held = [];
|
|
5268
|
+
const open = [];
|
|
5269
|
+
const stack = [];
|
|
5270
|
+
const breakText = () => {
|
|
5271
|
+
for (const aside of open) {
|
|
5272
|
+
aside.text.push(" ");
|
|
5273
|
+
aside.linkText.push(" ");
|
|
5274
|
+
}
|
|
5275
|
+
};
|
|
5276
|
+
return {
|
|
5277
|
+
onopentag(name, attribs, implied) {
|
|
5278
|
+
if (name === "aside") {
|
|
5279
|
+
open.push({ index: layout.length, depth: stack.length, text: [], linkText: [] });
|
|
5280
|
+
layout.push(true);
|
|
5281
|
+
}
|
|
5282
|
+
if (open.length === 0) {
|
|
5283
|
+
reader.onopentag(name, attribs, implied);
|
|
5284
|
+
return;
|
|
5285
|
+
}
|
|
5286
|
+
held.push(() => reader.onopentag(name, attribs, implied));
|
|
5287
|
+
if (!INLINE_TAGS.has(name))
|
|
5288
|
+
breakText();
|
|
5289
|
+
const parent = stack.at(-1);
|
|
5290
|
+
stack.push({
|
|
5291
|
+
visible: (parent?.visible ?? true) && !HIDDEN_TEXT_TAGS.has(name),
|
|
5292
|
+
link: (parent?.link ?? false) || name === "a" && attribs.href !== void 0
|
|
5293
|
+
});
|
|
5294
|
+
},
|
|
5295
|
+
ontext(text) {
|
|
5296
|
+
if (open.length === 0) {
|
|
5297
|
+
reader.ontext(text);
|
|
5298
|
+
return;
|
|
5299
|
+
}
|
|
5300
|
+
held.push(() => reader.ontext(text));
|
|
5301
|
+
const frame = stack.at(-1);
|
|
5302
|
+
if (frame?.visible === false)
|
|
5303
|
+
return;
|
|
5304
|
+
for (const aside of open) {
|
|
5305
|
+
aside.text.push(text);
|
|
5306
|
+
if (frame?.link)
|
|
5307
|
+
aside.linkText.push(text);
|
|
5308
|
+
}
|
|
5309
|
+
},
|
|
5310
|
+
onclosetag(name, implied) {
|
|
5311
|
+
if (open.length === 0) {
|
|
5312
|
+
reader.onclosetag(name, implied);
|
|
5313
|
+
return;
|
|
5314
|
+
}
|
|
5315
|
+
held.push(() => reader.onclosetag(name, implied));
|
|
5316
|
+
stack.pop();
|
|
5317
|
+
if (!INLINE_TAGS.has(name))
|
|
5318
|
+
breakText();
|
|
5319
|
+
const aside = open.at(-1);
|
|
5320
|
+
if (aside?.depth !== stack.length)
|
|
5321
|
+
return;
|
|
5322
|
+
open.pop();
|
|
5323
|
+
const words = countWords(aside.text.join(""));
|
|
5324
|
+
layout[aside.index] = countWords(aside.linkText.join("")) * 2 >= words;
|
|
5325
|
+
if (open.length === 0)
|
|
5326
|
+
for (const event of held.splice(0))
|
|
5327
|
+
event();
|
|
5328
|
+
}
|
|
5329
|
+
};
|
|
5330
|
+
}
|
|
5331
|
+
function isLayout(landmark) {
|
|
5332
|
+
return landmark !== void 0 && LAYOUT_LANDMARKS.has(landmark);
|
|
5333
|
+
}
|
|
5224
5334
|
function elementContext(frame, classes) {
|
|
5225
5335
|
const classNames = classes?.split(WHITESPACE).filter(Boolean) ?? [];
|
|
5226
5336
|
return {
|
|
@@ -5627,7 +5737,7 @@ import { createBlockRegistry, scanContentProject } from "@contentbit/core";
|
|
|
5627
5737
|
import { createHash } from "node:crypto";
|
|
5628
5738
|
import { existsSync } from "node:fs";
|
|
5629
5739
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
5630
|
-
import { isAbsolute, join as join2 } from "node:path";
|
|
5740
|
+
import { extname, isAbsolute, join as join2 } from "node:path";
|
|
5631
5741
|
import { pathToFileURL } from "node:url";
|
|
5632
5742
|
import { glob } from "tinyglobby";
|
|
5633
5743
|
var ProjectLoadError = class extends Error {
|
|
@@ -5667,12 +5777,13 @@ async function loadRegistry(registryPath, options = {}) {
|
|
|
5667
5777
|
mod = await importFresh(resolvedPath);
|
|
5668
5778
|
} catch (err) {
|
|
5669
5779
|
if (err instanceof Error && "code" in err && err.code === "ERR_UNKNOWN_FILE_EXTENSION") {
|
|
5670
|
-
|
|
5780
|
+
const extension = extname(resolvedPath);
|
|
5781
|
+
throw new ProjectLoadError(2, /^\.[cm]?ts$/.test(extension) ? `Importing a TypeScript registry needs Node 22.18+ (native type stripping): ${resolvedPath}` : `Node cannot import a ${extension} registry module: ${resolvedPath}. Use a .ts, .mts, .js or .mjs file.`);
|
|
5671
5782
|
}
|
|
5672
5783
|
throw err;
|
|
5673
5784
|
}
|
|
5674
5785
|
if (!Array.isArray(mod.default)) {
|
|
5675
|
-
throw new
|
|
5786
|
+
throw new ProjectLoadError(2, `Registry module must default-export an array of block definitions: ${resolvedPath}`);
|
|
5676
5787
|
}
|
|
5677
5788
|
registry.use(mod.default);
|
|
5678
5789
|
return registry;
|
|
@@ -5977,7 +6088,7 @@ function resolveOrigin(flag, configured, site) {
|
|
|
5977
6088
|
}
|
|
5978
6089
|
|
|
5979
6090
|
// src/server/scan.ts
|
|
5980
|
-
import { basename } from "node:path";
|
|
6091
|
+
import { basename as basename2 } from "node:path";
|
|
5981
6092
|
|
|
5982
6093
|
// src/server/preview.ts
|
|
5983
6094
|
import { ContentBlocks } from "@contentbit/react";
|
|
@@ -6278,7 +6389,7 @@ function fileSummary(file, cwd, frontmatter, stats, findings, options, seoPage)
|
|
|
6278
6389
|
};
|
|
6279
6390
|
}
|
|
6280
6391
|
function titleFor(file, frontmatter, stats) {
|
|
6281
|
-
return stringValue(frontmatter.title) ?? stats.outline[0]?.text ??
|
|
6392
|
+
return stringValue(frontmatter.title) ?? stats.outline[0]?.text ?? basename2(file);
|
|
6282
6393
|
}
|
|
6283
6394
|
function summarize(findings) {
|
|
6284
6395
|
const count = (severity) => findings.filter((finding) => finding.severity === severity).length;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentbit/studio",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.1",
|
|
4
4
|
"description": "Local read-only dashboard for contentbit: a site's built pages, page context, template findings, and Markdown.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"contentbit",
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"tinyglobby": "^0.2.10",
|
|
58
58
|
"tw-animate-css": "^1.4.0",
|
|
59
59
|
"vite": "^8",
|
|
60
|
-
"@contentbit/blocks": "2.0.0-next.
|
|
61
|
-
"@contentbit/core": "2.0.0-next.
|
|
62
|
-
"@contentbit/react": "2.0.0-next.
|
|
60
|
+
"@contentbit/blocks": "2.0.0-next.1",
|
|
61
|
+
"@contentbit/core": "2.0.0-next.1",
|
|
62
|
+
"@contentbit/react": "2.0.0-next.1"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@testing-library/dom": "^10.4.2",
|
package/src/server/scan.test.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { mkdir,
|
|
2
|
-
import { tmpdir } from 'node:os'
|
|
1
|
+
import { mkdir, symlink, writeFile } from 'node:fs/promises'
|
|
3
2
|
import { dirname, join } from 'node:path'
|
|
4
3
|
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
5
4
|
import { afterEach, expect, test } from 'vitest'
|
|
6
5
|
|
|
7
6
|
import { scanDocument, scanProject } from './scan'
|
|
8
7
|
import { startStudio, type StudioServer } from './index'
|
|
8
|
+
import { tempDir } from '../../../../test/temp-dir.js'
|
|
9
9
|
|
|
10
10
|
const root = fileURLToPath(new URL('../../../..', import.meta.url))
|
|
11
11
|
const runningServers: StudioServer[] = []
|
|
@@ -523,7 +523,7 @@ export function Callout() { return createElement('aside', { 'data-project-styled
|
|
|
523
523
|
})
|
|
524
524
|
|
|
525
525
|
async function fixture(files: Record<string, string>): Promise<string> {
|
|
526
|
-
const dir = await
|
|
526
|
+
const dir = await tempDir('cb-studio-')
|
|
527
527
|
for (const [path, content] of Object.entries(files)) {
|
|
528
528
|
const fullPath = join(dir, path)
|
|
529
529
|
await mkdir(dirname(fullPath), { recursive: true })
|
package/src/server/site.test.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { mkdir,
|
|
1
|
+
import { mkdir, realpath, writeFile } from 'node:fs/promises'
|
|
2
2
|
import { connect } from 'node:net'
|
|
3
|
-
import { tmpdir } from 'node:os'
|
|
4
3
|
import { dirname, join } from 'node:path'
|
|
5
4
|
import { afterEach, assert, expect, test } from 'vitest'
|
|
6
5
|
|
|
@@ -8,6 +7,7 @@ import { startStudio, type StudioServer } from './index'
|
|
|
8
7
|
import { scanDocument, scanProject } from './scan'
|
|
9
8
|
import { scanPage, scanSite } from './site'
|
|
10
9
|
import type { StudioOptions } from './types'
|
|
10
|
+
import { tempDir } from '../../../../test/temp-dir.js'
|
|
11
11
|
|
|
12
12
|
const runningServers: StudioServer[] = []
|
|
13
13
|
|
|
@@ -345,7 +345,7 @@ function withoutMarkdown(files: Record<string, string>): Record<string, string>
|
|
|
345
345
|
}
|
|
346
346
|
|
|
347
347
|
async function fixture(files: Record<string, string>): Promise<string> {
|
|
348
|
-
const dir = await realpath(await
|
|
348
|
+
const dir = await realpath(await tempDir('cb-studio-site-'))
|
|
349
349
|
for (const [path, content] of Object.entries(files)) {
|
|
350
350
|
const fullPath = join(dir, path)
|
|
351
351
|
await mkdir(dirname(fullPath), { recursive: true })
|