barodoc 10.0.8 → 10.0.10

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.
@@ -0,0 +1,518 @@
1
+ // src/runtime/project.ts
2
+ import crypto from "crypto";
3
+ import { createRequire } from "module";
4
+ import fs from "fs-extra";
5
+ import path from "path";
6
+ import { fileURLToPath } from "url";
7
+ import { execa } from "execa";
8
+ import pc from "picocolors";
9
+ var BARODOC_DIR = ".barodoc";
10
+ var __dirname = path.dirname(fileURLToPath(import.meta.url));
11
+ var EXCLUDE_FROM_TEMP = /* @__PURE__ */ new Set([
12
+ "cac",
13
+ "execa",
14
+ "chokidar",
15
+ "fs-extra",
16
+ "picocolors"
17
+ ]);
18
+ function findMonorepoRoot(barodocPkgRoot) {
19
+ let dir = barodocPkgRoot;
20
+ while (dir !== path.parse(dir).root) {
21
+ const ws = path.join(dir, "pnpm-workspace.yaml");
22
+ const marker = path.join(dir, "packages", "barodoc", "package.json");
23
+ if (fs.existsSync(ws) && fs.existsSync(marker)) {
24
+ return dir;
25
+ }
26
+ dir = path.dirname(dir);
27
+ }
28
+ return null;
29
+ }
30
+ function barodocMonorepoPackageDir(monorepoRoot, name) {
31
+ if (!name.startsWith("@barodoc/")) return null;
32
+ const rest = name.slice("@barodoc/".length);
33
+ const abs = path.join(monorepoRoot, "packages", rest);
34
+ return fs.existsSync(path.join(abs, "package.json")) ? abs : null;
35
+ }
36
+ function toFileDep(projectDir, targetDir) {
37
+ let rel = path.relative(projectDir, targetDir);
38
+ if (!rel.startsWith(".")) rel = `./${rel}`;
39
+ return `file:${rel.split(path.sep).join("/")}`;
40
+ }
41
+ function collectPluginNames(config) {
42
+ const plugins = config.plugins ?? [];
43
+ const out = [];
44
+ for (const p of plugins) {
45
+ const name = Array.isArray(p) ? p[0] : p;
46
+ if (typeof name === "string") out.push(name);
47
+ }
48
+ return [...new Set(out)];
49
+ }
50
+ function resolveDepVersion(name, ver, projectDir, barodocPkgRoot, monorepoRoot, req) {
51
+ if (monorepoRoot) {
52
+ const pkgDir = barodocMonorepoPackageDir(monorepoRoot, name);
53
+ if (pkgDir) return toFileDep(projectDir, pkgDir);
54
+ }
55
+ if (ver.startsWith("workspace:")) {
56
+ try {
57
+ const resolved = path.dirname(
58
+ req.resolve(`${name}/package.json`, { paths: [barodocPkgRoot] })
59
+ );
60
+ return toFileDep(projectDir, resolved);
61
+ } catch {
62
+ throw new Error(
63
+ `Cannot resolve ${name} for quick mode. Install barodoc from npm or run from the Barodoc monorepo.`
64
+ );
65
+ }
66
+ }
67
+ return ver;
68
+ }
69
+ function resolveExtraPlugin(name, projectDir, barodocPkgRoot, monorepoRoot, req) {
70
+ if (monorepoRoot) {
71
+ const pkgDir = barodocMonorepoPackageDir(monorepoRoot, name);
72
+ if (pkgDir) return toFileDep(projectDir, pkgDir);
73
+ }
74
+ if (name.startsWith("@barodoc/")) {
75
+ try {
76
+ const resolved = path.dirname(
77
+ req.resolve(`${name}/package.json`, { paths: [barodocPkgRoot] })
78
+ );
79
+ return toFileDep(projectDir, resolved);
80
+ } catch {
81
+ return "*";
82
+ }
83
+ }
84
+ return "*";
85
+ }
86
+ function resolveTempPackageJsonSync(projectDir, config, barodocPkgRoot, monorepoRoot) {
87
+ const raw = fs.readJsonSync(path.join(barodocPkgRoot, "package.json"));
88
+ const req = createRequire(path.join(barodocPkgRoot, "package.json"));
89
+ const deps = {};
90
+ for (const [name, ver] of Object.entries(raw.dependencies)) {
91
+ if (EXCLUDE_FROM_TEMP.has(name)) continue;
92
+ deps[name] = resolveDepVersion(
93
+ name,
94
+ ver,
95
+ projectDir,
96
+ barodocPkgRoot,
97
+ monorepoRoot,
98
+ req
99
+ );
100
+ }
101
+ for (const pluginName of collectPluginNames(config)) {
102
+ if (deps[pluginName]) continue;
103
+ deps[pluginName] = resolveExtraPlugin(
104
+ pluginName,
105
+ projectDir,
106
+ barodocPkgRoot,
107
+ monorepoRoot,
108
+ req
109
+ );
110
+ }
111
+ return {
112
+ name: "barodoc-temp",
113
+ private: true,
114
+ type: "module",
115
+ dependencies: deps
116
+ };
117
+ }
118
+ async function materializeWorkspacePackagesAsTarballs(projectDir, deps, monorepoRoot) {
119
+ const packDir = path.join(projectDir, ".barodoc-packs");
120
+ const packNpmCache = path.join(projectDir, ".npm-pack-cache");
121
+ const stageRoot = path.join(packDir, ".stage");
122
+ await fs.remove(stageRoot).catch(() => {
123
+ });
124
+ await fs.ensureDir(packDir);
125
+ await fs.ensureDir(packNpmCache);
126
+ const toPack = [];
127
+ for (const name of Object.keys(deps)) {
128
+ if (!name.startsWith("@barodoc/")) continue;
129
+ const spec = deps[name];
130
+ if (!spec.startsWith("file:")) continue;
131
+ const rel = spec.replace(/^file:/, "").replace(/^\.\//, "");
132
+ const absPath = path.resolve(projectDir, rel);
133
+ try {
134
+ const st = await fs.stat(absPath);
135
+ if (!st.isDirectory()) continue;
136
+ } catch {
137
+ continue;
138
+ }
139
+ if (!await fs.pathExists(path.join(absPath, "package.json"))) continue;
140
+ toPack.push(name);
141
+ }
142
+ const tgzByPackage = /* @__PURE__ */ new Map();
143
+ for (const name of toPack) {
144
+ const spec = deps[name];
145
+ const rel = spec.replace(/^file:/, "").replace(/^\.\//, "");
146
+ const srcDir = path.resolve(projectDir, rel);
147
+ const folder = name.slice("@barodoc/".length);
148
+ const stageDir = path.join(stageRoot, folder);
149
+ await fs.remove(stageDir).catch(() => {
150
+ });
151
+ await fs.copy(srcDir, stageDir, {
152
+ filter: (p) => !p.split(path.sep).includes("node_modules"),
153
+ overwrite: true
154
+ });
155
+ const pjPath = path.join(stageDir, "package.json");
156
+ const pj = await fs.readJSON(pjPath);
157
+ for (const sect of [
158
+ "dependencies",
159
+ "peerDependencies",
160
+ "optionalDependencies",
161
+ "devDependencies"
162
+ ]) {
163
+ const o = pj[sect];
164
+ if (!o) continue;
165
+ for (const [depName, depVer] of Object.entries(o)) {
166
+ if (!depName.startsWith("@barodoc/")) continue;
167
+ if (depVer !== "workspace:*" && !String(depVer).startsWith("workspace:")) {
168
+ continue;
169
+ }
170
+ const depDir = barodocMonorepoPackageDir(monorepoRoot, depName);
171
+ if (!depDir) continue;
172
+ const ver = fs.readJsonSync(path.join(depDir, "package.json")).version;
173
+ o[depName] = ver;
174
+ }
175
+ }
176
+ await fs.writeJSON(pjPath, pj, { spaces: 2 });
177
+ const { stdout } = await execa(
178
+ "npm",
179
+ ["pack", "--pack-destination", packDir, "--cache", packNpmCache],
180
+ { cwd: stageDir }
181
+ );
182
+ const lines = stdout.trim().split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
183
+ const tgz = lines[lines.length - 1];
184
+ if (!tgz) {
185
+ throw new Error(`npm pack produced no tarball for ${name}`);
186
+ }
187
+ tgzByPackage.set(name, tgz);
188
+ }
189
+ await fs.remove(stageRoot).catch(() => {
190
+ });
191
+ const next = { ...deps };
192
+ for (const name of toPack) {
193
+ const tgz = tgzByPackage.get(name);
194
+ if (!tgz) continue;
195
+ const tgzAbs = path.join(packDir, tgz);
196
+ let relOut = path.relative(projectDir, tgzAbs);
197
+ if (!relOut.startsWith(".")) relOut = `./${relOut}`;
198
+ next[name] = `file:${relOut.split(path.sep).join("/")}`;
199
+ }
200
+ return next;
201
+ }
202
+ function hashQuickModeDeps(pkgJson, monorepoRoot) {
203
+ const lines = Object.keys(pkgJson.dependencies).sort().map((k) => `${k}@${pkgJson.dependencies[k]}`);
204
+ const parts = [lines.join("\n")];
205
+ if (monorepoRoot) {
206
+ for (const name of Object.keys(pkgJson.dependencies)) {
207
+ if (!name.startsWith("@barodoc/")) continue;
208
+ const dir = barodocMonorepoPackageDir(monorepoRoot, name);
209
+ if (!dir) continue;
210
+ const pj = path.join(dir, "package.json");
211
+ if (!fs.existsSync(pj)) continue;
212
+ const v = fs.readJsonSync(pj);
213
+ parts.push(`${name}:src@${v.version ?? "0.0.0"}`);
214
+ }
215
+ }
216
+ return crypto.createHash("sha256").update(parts.join("\n")).digest("hex");
217
+ }
218
+ function isCustomProject(dir) {
219
+ return fs.existsSync(path.join(dir, "astro.config.mjs")) || fs.existsSync(path.join(dir, "astro.config.ts")) || fs.existsSync(path.join(dir, "astro.config.js"));
220
+ }
221
+ async function loadProjectConfig(dir, configFile) {
222
+ const configPath = configFile ? path.resolve(dir, configFile) : path.join(dir, "barodoc.config.json");
223
+ if (fs.existsSync(configPath)) {
224
+ const content = await fs.readFile(configPath, "utf-8");
225
+ return {
226
+ config: JSON.parse(content),
227
+ configPath
228
+ };
229
+ }
230
+ return {
231
+ config: getDefaultConfig(),
232
+ configPath: null
233
+ };
234
+ }
235
+ function getDefaultConfig() {
236
+ return {
237
+ name: "Documentation",
238
+ navigation: [],
239
+ i18n: {
240
+ defaultLocale: "en",
241
+ locales: ["en"]
242
+ },
243
+ search: {
244
+ enabled: true
245
+ }
246
+ };
247
+ }
248
+ async function createProject(options) {
249
+ const { root, docsDir, config } = options;
250
+ const projectDir = path.join(root, BARODOC_DIR);
251
+ console.log(pc.dim(`Creating temporary project in ${BARODOC_DIR}/`));
252
+ await fs.ensureDir(projectDir);
253
+ const nodeModulesPath = path.join(projectDir, "node_modules");
254
+ if (await fs.pathExists(nodeModulesPath)) {
255
+ const st = await fs.lstat(nodeModulesPath);
256
+ if (st.isSymbolicLink()) {
257
+ await fs.remove(nodeModulesPath);
258
+ }
259
+ }
260
+ const barodocPkgRoot = path.join(__dirname, "..");
261
+ const monorepoRoot = findMonorepoRoot(barodocPkgRoot);
262
+ const pkgSync = resolveTempPackageJsonSync(
263
+ projectDir,
264
+ config,
265
+ barodocPkgRoot,
266
+ monorepoRoot
267
+ );
268
+ const hash = hashQuickModeDeps(pkgSync, monorepoRoot);
269
+ const hashFile = path.join(projectDir, ".barodoc-deps-hash");
270
+ const astroMarker = path.join(nodeModulesPath, "astro", "package.json");
271
+ let prevHash = "";
272
+ try {
273
+ prevHash = await fs.readFile(hashFile, "utf8");
274
+ } catch {
275
+ prevHash = "";
276
+ }
277
+ const needInstall = !await fs.pathExists(astroMarker) || prevHash !== hash;
278
+ if (needInstall) {
279
+ if (await fs.pathExists(nodeModulesPath)) {
280
+ await fs.remove(nodeModulesPath);
281
+ }
282
+ await fs.remove(path.join(projectDir, ".barodoc-packs")).catch(() => {
283
+ });
284
+ await fs.remove(path.join(projectDir, ".npm-pack-cache")).catch(() => {
285
+ });
286
+ console.log(pc.dim(" Installing dependencies in .barodoc/ (npm install)\u2026"));
287
+ let pkgFinal = pkgSync;
288
+ if (monorepoRoot) {
289
+ pkgFinal = {
290
+ ...pkgSync,
291
+ dependencies: await materializeWorkspacePackagesAsTarballs(
292
+ projectDir,
293
+ pkgSync.dependencies,
294
+ monorepoRoot
295
+ )
296
+ };
297
+ }
298
+ await fs.writeJSON(path.join(projectDir, "package.json"), pkgFinal, {
299
+ spaces: 2
300
+ });
301
+ const npmCache = path.join(projectDir, ".npm-cache");
302
+ await fs.ensureDir(npmCache);
303
+ await execa(
304
+ "npm",
305
+ [
306
+ "install",
307
+ "--no-fund",
308
+ "--no-audit",
309
+ "--legacy-peer-deps",
310
+ "--cache",
311
+ npmCache
312
+ ],
313
+ {
314
+ cwd: projectDir,
315
+ stdio: "inherit"
316
+ }
317
+ );
318
+ await fs.writeFile(hashFile, hash, "utf8");
319
+ }
320
+ await fs.remove(path.join(projectDir, "src"));
321
+ await fs.remove(path.join(projectDir, "public"));
322
+ await fs.remove(path.join(projectDir, "overrides"));
323
+ await fs.writeJSON(path.join(projectDir, "barodoc.config.json"), config, {
324
+ spaces: 2
325
+ });
326
+ await fs.writeJSON(
327
+ path.join(projectDir, "tsconfig.json"),
328
+ {
329
+ extends: "astro/tsconfigs/strict",
330
+ compilerOptions: {
331
+ jsx: "react-jsx",
332
+ jsxImportSource: "react"
333
+ }
334
+ },
335
+ { spaces: 2 }
336
+ );
337
+ const contentDir = path.join(projectDir, "src/content");
338
+ await fs.ensureDir(contentDir);
339
+ const docsAbsolute = path.resolve(root, docsDir);
340
+ const docsLink = path.join(contentDir, "docs");
341
+ if (fs.existsSync(docsAbsolute)) {
342
+ await fs.copy(docsAbsolute, docsLink);
343
+ } else {
344
+ await fs.ensureDir(docsLink);
345
+ }
346
+ const blogDir = path.join(root, "blog");
347
+ const blogLink = path.join(contentDir, "blog");
348
+ if (fs.existsSync(blogDir)) {
349
+ await fs.copy(blogDir, blogLink);
350
+ }
351
+ const changelogDir = path.join(root, "changelog");
352
+ const changelogLink = path.join(contentDir, "changelog");
353
+ if (fs.existsSync(changelogDir)) {
354
+ await fs.copy(changelogDir, changelogLink);
355
+ }
356
+ if (config.sections) {
357
+ for (const section of config.sections) {
358
+ const sectionDir = path.join(root, section.slug);
359
+ const sectionDest = path.join(contentDir, section.slug);
360
+ if (fs.existsSync(sectionDir)) {
361
+ await fs.copy(sectionDir, sectionDest);
362
+ console.log(pc.dim(` Copied ${section.slug}/ section`));
363
+ }
364
+ }
365
+ }
366
+ const pagesDir = path.join(root, "pages");
367
+ const pagesDest = path.join(contentDir, "pages");
368
+ if (fs.existsSync(pagesDir)) {
369
+ await fs.copy(pagesDir, pagesDest);
370
+ console.log(pc.dim(" Copied pages/ directory"));
371
+ }
372
+ await fs.writeFile(
373
+ path.join(contentDir, "config.ts"),
374
+ generateContentConfig(config),
375
+ "utf-8"
376
+ );
377
+ const publicDir = path.join(root, "public");
378
+ const publicLink = path.join(projectDir, "public");
379
+ if (fs.existsSync(publicDir)) {
380
+ await fs.symlink(publicDir, publicLink, "dir");
381
+ } else {
382
+ await fs.ensureDir(publicLink);
383
+ }
384
+ const overridesDir = path.join(root, "overrides");
385
+ const overridesLink = path.join(projectDir, "overrides");
386
+ if (fs.existsSync(overridesDir)) {
387
+ await fs.symlink(overridesDir, overridesLink, "dir");
388
+ console.log(pc.dim(" Linked overrides/ directory"));
389
+ }
390
+ await fs.writeFile(
391
+ path.join(projectDir, "astro.config.mjs"),
392
+ generateAstroConfigFile(config),
393
+ "utf-8"
394
+ );
395
+ return projectDir;
396
+ }
397
+ async function cleanupProject(root) {
398
+ const projectDir = path.join(root, BARODOC_DIR);
399
+ if (fs.existsSync(projectDir)) {
400
+ await fs.remove(projectDir);
401
+ }
402
+ }
403
+ function generateAstroConfigFile(config) {
404
+ const siteLine = config.site ? `
405
+ site: ${JSON.stringify(config.site)},` : "";
406
+ const baseLine = config.base ? `
407
+ base: ${JSON.stringify(config.base)},` : "";
408
+ return `import { defineConfig } from "astro/config";
409
+ import barodoc from "@barodoc/core";
410
+ import docsTheme from "@barodoc/theme-docs/theme";
411
+
412
+ export default defineConfig({${siteLine}${baseLine}
413
+ integrations: [
414
+ barodoc({
415
+ config: "./barodoc.config.json",
416
+ theme: docsTheme(),
417
+ }),
418
+ ],
419
+ vite: {
420
+ resolve: {
421
+ preserveSymlinks: false,
422
+ dedupe: ["react", "react-dom"],
423
+ },
424
+ optimizeDeps: {
425
+ include: ["mermaid"],
426
+ exclude: [
427
+ "fsevents",
428
+ "lightningcss",
429
+ "@tailwindcss/oxide",
430
+ "@barodoc/core",
431
+ ],
432
+ },
433
+ ssr: {
434
+ external: [
435
+ "fsevents",
436
+ "lightningcss",
437
+ "mermaid",
438
+ "d3-array",
439
+ "d3-contour",
440
+ ],
441
+ noExternal: [/^@barodoc\\//],
442
+ },
443
+ },
444
+ });
445
+ `;
446
+ }
447
+ var contentSchema = `z.object({
448
+ title: z.string().optional(),
449
+ description: z.string().optional(),
450
+ tags: z.array(z.string()).optional(),
451
+ related: z.array(z.string()).optional(),
452
+ category: z.string().optional(),
453
+ api_reference: z.boolean().optional(),
454
+ difficulty: z.enum(["beginner", "intermediate", "advanced"]).optional(),
455
+ lastUpdated: z.date().optional(),
456
+ since: z.string().optional(),
457
+ deprecated: z.union([z.boolean(), z.string()]).optional(),
458
+ experimental: z.boolean().optional(),
459
+ changelogUrl: z.string().optional(),
460
+ slides: z.boolean().optional(),
461
+ })`;
462
+ function generateContentConfig(config) {
463
+ const collections = [
464
+ `docs: defineCollection({ type: "content", schema: ${contentSchema} })`,
465
+ `blog: defineCollection({
466
+ type: "content",
467
+ schema: z.object({
468
+ title: z.string(),
469
+ description: z.string().optional(),
470
+ excerpt: z.string().optional(),
471
+ date: z.coerce.date().optional(),
472
+ author: z.string().optional(),
473
+ image: z.string().optional(),
474
+ tags: z.array(z.string()).optional(),
475
+ }),
476
+ })`,
477
+ `changelog: defineCollection({
478
+ type: "content",
479
+ schema: z.object({
480
+ title: z.string().optional(),
481
+ version: z.string(),
482
+ date: z.coerce.date(),
483
+ }),
484
+ })`,
485
+ `pages: defineCollection({ type: "content", schema: ${contentSchema} })`
486
+ ];
487
+ const sections = config.sections ?? [];
488
+ for (const section of sections) {
489
+ collections.push(
490
+ `${section.slug}: defineCollection({ type: "content", schema: ${contentSchema} })`
491
+ );
492
+ }
493
+ return `import { defineCollection, z } from "astro:content";
494
+
495
+ export const collections = {
496
+ ${collections.join(",\n ")},
497
+ };
498
+ `;
499
+ }
500
+ function findDocsDir(root) {
501
+ const candidates = ["docs", "content", "src/content/docs"];
502
+ for (const candidate of candidates) {
503
+ const fullPath = path.join(root, candidate);
504
+ if (fs.existsSync(fullPath)) {
505
+ return candidate;
506
+ }
507
+ }
508
+ return "docs";
509
+ }
510
+
511
+ export {
512
+ isCustomProject,
513
+ loadProjectConfig,
514
+ createProject,
515
+ cleanupProject,
516
+ generateAstroConfigFile,
517
+ findDocsDir
518
+ };
package/dist/cli.js CHANGED
@@ -6,21 +6,19 @@ import {
6
6
  generateAstroConfigFile,
7
7
  isCustomProject,
8
8
  loadProjectConfig
9
- } from "./chunk-FJGGWEQ6.js";
9
+ } from "./chunk-RSVNAYIQ.js";
10
10
 
11
11
  // src/cli.ts
12
12
  import cac from "cac";
13
13
  import pc10 from "picocolors";
14
14
 
15
15
  // package.json
16
- var version = "10.0.8";
16
+ var version = "10.0.10";
17
17
 
18
18
  // src/commands/serve.ts
19
19
  import path from "path";
20
20
  import pc from "picocolors";
21
21
  import { dev } from "astro";
22
- import barodoc from "@barodoc/core";
23
- import docsTheme from "@barodoc/theme-docs/theme";
24
22
  async function serve(dir, options) {
25
23
  const root = !dir || dir === "." ? path.resolve(process.cwd()) : path.resolve(process.cwd(), dir);
26
24
  console.log();
@@ -51,28 +49,11 @@ async function serve(dir, options) {
51
49
  console.log();
52
50
  const devServer = await dev({
53
51
  root: projectDir,
54
- configFile: false,
55
- integrations: [
56
- barodoc({
57
- config: "./barodoc.config.json",
58
- theme: docsTheme()
59
- })
60
- ],
61
- vite: {
62
- resolve: {
63
- preserveSymlinks: true
64
- },
65
- ssr: {
66
- noExternal: [/^@barodoc\//]
67
- }
68
- },
69
52
  server: {
70
53
  port: options.port,
71
54
  host: options.host ? true : void 0,
72
55
  open: options.open
73
- },
74
- ...config.site ? { site: config.site } : {},
75
- ...config.base ? { base: config.base } : {}
56
+ }
76
57
  });
77
58
  process.on("SIGINT", async () => {
78
59
  console.log();
@@ -87,8 +68,6 @@ import pc2 from "picocolors";
87
68
  import fs from "fs-extra";
88
69
  import { execa } from "execa";
89
70
  import { build as astroBuild } from "astro";
90
- import barodoc2 from "@barodoc/core";
91
- import docsTheme2 from "@barodoc/theme-docs/theme";
92
71
  async function build(dir, options) {
93
72
  const root = !dir || dir === "." ? path2.resolve(process.cwd()) : path2.resolve(process.cwd(), dir);
94
73
  const outputDir = path2.resolve(root, options.output);
@@ -117,24 +96,7 @@ async function build(dir, options) {
117
96
  console.log(pc2.dim("Building site..."));
118
97
  await astroBuild({
119
98
  root: projectDir,
120
- configFile: false,
121
- integrations: [
122
- barodoc2({
123
- config: "./barodoc.config.json",
124
- theme: docsTheme2()
125
- })
126
- ],
127
- vite: {
128
- resolve: {
129
- preserveSymlinks: true
130
- },
131
- ssr: {
132
- noExternal: true
133
- }
134
- },
135
- logLevel: "info",
136
- ...config.site ? { site: config.site } : {},
137
- ...config.base ? { base: config.base } : {}
99
+ logLevel: "info"
138
100
  });
139
101
  console.log();
140
102
  console.log(pc2.dim("Generating search index..."));
@@ -249,7 +211,7 @@ After creating a new file, register it in \`barodoc.config.json\`:
249
211
  {
250
212
  "group": "Getting Started",
251
213
  "group:ko": "\uC2DC\uC791\uD558\uAE30",
252
- "pages": ["introduction", "quickstart"]
214
+ "pages": ["introduction", "quickstart", "example-slides"]
253
215
  },
254
216
  {
255
217
  "group": "Guides",
@@ -471,7 +433,7 @@ async function create(name) {
471
433
  navigation: [
472
434
  {
473
435
  group: "Getting Started",
474
- pages: ["introduction", "quickstart"]
436
+ pages: ["introduction", "quickstart", "example-slides"]
475
437
  }
476
438
  ],
477
439
  i18n: {
@@ -523,6 +485,31 @@ barodoc build
523
485
  \`\`\`bash
524
486
  barodoc preview
525
487
  \`\`\`
488
+ `
489
+ );
490
+ await fs2.writeFile(
491
+ path3.join(targetDir, "docs/en/example-slides.md"),
492
+ `---
493
+ title: Example slides
494
+ description: Minimal slide deck \u2014 frontmatter plus --- between slides in the body.
495
+ slides: true
496
+ ---
497
+
498
+ # First slide
499
+
500
+ Edit \`docs/en/example-slides.md\`. Use the **Slides** control on the page (with \`slides: true\` in frontmatter) to open full-screen mode. Arrow keys move between slides; **Escape** exits.
501
+
502
+ ---
503
+
504
+ # Second slide
505
+
506
+ In the **body**, a line with only \`---\` starts the next slide (not the YAML block at the top).
507
+
508
+ ---
509
+
510
+ # Third slide
511
+
512
+ Copy this file or see the Barodoc docs **Slide mode demo** for MDX layouts (e.g. columns).
526
513
  `
527
514
  );
528
515
  await fs2.writeFile(
package/dist/index.d.ts CHANGED
@@ -9,8 +9,9 @@ interface ProjectOptions {
9
9
  }
10
10
  /**
11
11
  * Create temporary Astro project for quick mode.
12
- * Only generates config files and content symlinks no node_modules needed.
13
- * Astro is invoked programmatically from the CLI process.
12
+ * Uses a dedicated `npm install` under `.barodoc/` (not a symlink to the CLI
13
+ * or monorepo root `node_modules`) so quick mode matches real installs and
14
+ * avoids hoisted dev-tooling conflicts.
14
15
  */
15
16
  declare function createProject(options: ProjectOptions): Promise<string>;
16
17
  /**
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  cleanupProject,
3
3
  createProject
4
- } from "./chunk-FJGGWEQ6.js";
4
+ } from "./chunk-RSVNAYIQ.js";
5
5
 
6
6
  // src/index.ts
7
7
  export * from "@barodoc/core";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "barodoc",
3
- "version": "10.0.8",
3
+ "version": "10.0.10",
4
4
  "description": "Documentation framework powered by Astro",
5
5
  "type": "module",
6
6
  "bin": {
@@ -31,21 +31,22 @@
31
31
  "picocolors": "^1.1.1",
32
32
  "react": "^19.0.0",
33
33
  "react-dom": "^19.0.0",
34
+ "scheduler": "^0.27.0",
34
35
  "rst-compiler": "^0.5.7",
35
36
  "tailwindcss": "^4.0.0",
36
37
  "zod": "^3.24.0",
37
38
  "zod-to-json-schema": "^3.25.1",
38
- "@barodoc/core": "10.0.8",
39
- "@barodoc/plugin-analytics": "10.0.8",
40
- "@barodoc/plugin-docsearch": "10.0.2",
41
- "@barodoc/plugin-llms-txt": "10.0.8",
42
- "@barodoc/plugin-og-image": "9.0.2",
43
- "@barodoc/plugin-openapi": "10.0.3",
44
- "@barodoc/plugin-pwa": "10.0.2",
45
- "@barodoc/plugin-rss": "10.0.2",
46
- "@barodoc/plugin-search": "10.0.8",
47
- "@barodoc/plugin-sitemap": "10.0.8",
48
- "@barodoc/theme-docs": "10.0.8"
39
+ "@barodoc/plugin-analytics": "10.0.9",
40
+ "@barodoc/plugin-docsearch": "10.0.3",
41
+ "@barodoc/plugin-llms-txt": "10.0.9",
42
+ "@barodoc/plugin-pwa": "10.0.3",
43
+ "@barodoc/core": "10.0.9",
44
+ "@barodoc/plugin-og-image": "9.0.3",
45
+ "@barodoc/plugin-rss": "10.0.3",
46
+ "@barodoc/plugin-search": "10.0.9",
47
+ "@barodoc/plugin-openapi": "10.0.4",
48
+ "@barodoc/plugin-sitemap": "10.0.9",
49
+ "@barodoc/theme-docs": "10.0.9"
49
50
  },
50
51
  "devDependencies": {
51
52
  "@types/fs-extra": "^11.0.4",
@@ -1,240 +0,0 @@
1
- // src/runtime/project.ts
2
- import fs from "fs-extra";
3
- import path from "path";
4
- import { fileURLToPath } from "url";
5
- import pc from "picocolors";
6
- var BARODOC_DIR = ".barodoc";
7
- var __dirname = path.dirname(fileURLToPath(import.meta.url));
8
- function findCliNodeModules() {
9
- let best = null;
10
- let dir = __dirname;
11
- while (dir !== path.parse(dir).root) {
12
- const candidate = path.join(dir, "node_modules");
13
- if (fs.existsSync(candidate) && fs.existsSync(path.join(candidate, "@barodoc", "theme-docs"))) {
14
- best = candidate;
15
- }
16
- dir = path.dirname(dir);
17
- }
18
- if (!best) {
19
- throw new Error(
20
- "Could not locate node_modules for barodoc runtime dependencies"
21
- );
22
- }
23
- return best;
24
- }
25
- function isCustomProject(dir) {
26
- return fs.existsSync(path.join(dir, "astro.config.mjs")) || fs.existsSync(path.join(dir, "astro.config.ts")) || fs.existsSync(path.join(dir, "astro.config.js"));
27
- }
28
- async function loadProjectConfig(dir, configFile) {
29
- const configPath = configFile ? path.resolve(dir, configFile) : path.join(dir, "barodoc.config.json");
30
- if (fs.existsSync(configPath)) {
31
- const content = await fs.readFile(configPath, "utf-8");
32
- return {
33
- config: JSON.parse(content),
34
- configPath
35
- };
36
- }
37
- return {
38
- config: getDefaultConfig(),
39
- configPath: null
40
- };
41
- }
42
- function getDefaultConfig() {
43
- return {
44
- name: "Documentation",
45
- navigation: [],
46
- i18n: {
47
- defaultLocale: "en",
48
- locales: ["en"]
49
- },
50
- search: {
51
- enabled: true
52
- }
53
- };
54
- }
55
- async function createProject(options) {
56
- const { root, docsDir, config } = options;
57
- const projectDir = path.join(root, BARODOC_DIR);
58
- console.log(pc.dim(`Creating temporary project in ${BARODOC_DIR}/`));
59
- await fs.remove(projectDir);
60
- await fs.ensureDir(projectDir);
61
- const cliNodeModules = findCliNodeModules();
62
- await fs.symlink(cliNodeModules, path.join(projectDir, "node_modules"), "junction");
63
- await fs.writeJSON(
64
- path.join(projectDir, "package.json"),
65
- { name: "barodoc-temp", private: true },
66
- { spaces: 2 }
67
- );
68
- await fs.writeJSON(path.join(projectDir, "barodoc.config.json"), config, {
69
- spaces: 2
70
- });
71
- await fs.writeJSON(
72
- path.join(projectDir, "tsconfig.json"),
73
- {
74
- extends: "astro/tsconfigs/strict",
75
- compilerOptions: {
76
- jsx: "react-jsx",
77
- jsxImportSource: "react"
78
- }
79
- },
80
- { spaces: 2 }
81
- );
82
- const contentDir = path.join(projectDir, "src/content");
83
- await fs.ensureDir(contentDir);
84
- const docsAbsolute = path.resolve(root, docsDir);
85
- const docsLink = path.join(contentDir, "docs");
86
- if (fs.existsSync(docsAbsolute)) {
87
- await fs.copy(docsAbsolute, docsLink);
88
- } else {
89
- await fs.ensureDir(docsLink);
90
- }
91
- const blogDir = path.join(root, "blog");
92
- const blogLink = path.join(contentDir, "blog");
93
- if (fs.existsSync(blogDir)) {
94
- await fs.copy(blogDir, blogLink);
95
- }
96
- const changelogDir = path.join(root, "changelog");
97
- const changelogLink = path.join(contentDir, "changelog");
98
- if (fs.existsSync(changelogDir)) {
99
- await fs.copy(changelogDir, changelogLink);
100
- }
101
- if (config.sections) {
102
- for (const section of config.sections) {
103
- const sectionDir = path.join(root, section.slug);
104
- const sectionDest = path.join(contentDir, section.slug);
105
- if (fs.existsSync(sectionDir)) {
106
- await fs.copy(sectionDir, sectionDest);
107
- console.log(pc.dim(` Copied ${section.slug}/ section`));
108
- }
109
- }
110
- }
111
- const pagesDir = path.join(root, "pages");
112
- const pagesDest = path.join(contentDir, "pages");
113
- if (fs.existsSync(pagesDir)) {
114
- await fs.copy(pagesDir, pagesDest);
115
- console.log(pc.dim(" Copied pages/ directory"));
116
- }
117
- await fs.writeFile(
118
- path.join(contentDir, "config.ts"),
119
- generateContentConfig(config),
120
- "utf-8"
121
- );
122
- const publicDir = path.join(root, "public");
123
- const publicLink = path.join(projectDir, "public");
124
- if (fs.existsSync(publicDir)) {
125
- await fs.symlink(publicDir, publicLink, "dir");
126
- } else {
127
- await fs.ensureDir(publicLink);
128
- }
129
- const overridesDir = path.join(root, "overrides");
130
- const overridesLink = path.join(projectDir, "overrides");
131
- if (fs.existsSync(overridesDir)) {
132
- await fs.symlink(overridesDir, overridesLink, "dir");
133
- console.log(pc.dim(" Linked overrides/ directory"));
134
- }
135
- return projectDir;
136
- }
137
- async function cleanupProject(root) {
138
- const projectDir = path.join(root, BARODOC_DIR);
139
- if (fs.existsSync(projectDir)) {
140
- await fs.remove(projectDir);
141
- }
142
- }
143
- function generateAstroConfigFile(config) {
144
- const siteLine = config.site ? `
145
- site: ${JSON.stringify(config.site)},` : "";
146
- const baseLine = config.base ? `
147
- base: ${JSON.stringify(config.base)},` : "";
148
- return `import { defineConfig } from "astro/config";
149
- import barodoc from "@barodoc/core";
150
- import docsTheme from "@barodoc/theme-docs/theme";
151
-
152
- export default defineConfig({${siteLine}${baseLine}
153
- integrations: [
154
- barodoc({
155
- config: "./barodoc.config.json",
156
- theme: docsTheme(),
157
- }),
158
- ],
159
- vite: {
160
- resolve: {
161
- preserveSymlinks: true,
162
- },
163
- ssr: {
164
- noExternal: true,
165
- },
166
- },
167
- });
168
- `;
169
- }
170
- var contentSchema = `z.object({
171
- title: z.string().optional(),
172
- description: z.string().optional(),
173
- tags: z.array(z.string()).optional(),
174
- related: z.array(z.string()).optional(),
175
- category: z.string().optional(),
176
- api_reference: z.boolean().optional(),
177
- difficulty: z.enum(["beginner", "intermediate", "advanced"]).optional(),
178
- lastUpdated: z.date().optional(),
179
- since: z.string().optional(),
180
- deprecated: z.union([z.boolean(), z.string()]).optional(),
181
- experimental: z.boolean().optional(),
182
- changelogUrl: z.string().optional(),
183
- })`;
184
- function generateContentConfig(config) {
185
- const collections = [
186
- `docs: defineCollection({ type: "content", schema: ${contentSchema} })`,
187
- `blog: defineCollection({
188
- type: "content",
189
- schema: z.object({
190
- title: z.string(),
191
- description: z.string().optional(),
192
- excerpt: z.string().optional(),
193
- date: z.coerce.date().optional(),
194
- author: z.string().optional(),
195
- image: z.string().optional(),
196
- tags: z.array(z.string()).optional(),
197
- }),
198
- })`,
199
- `changelog: defineCollection({
200
- type: "content",
201
- schema: z.object({
202
- title: z.string().optional(),
203
- version: z.string(),
204
- date: z.coerce.date(),
205
- }),
206
- })`,
207
- `pages: defineCollection({ type: "content", schema: ${contentSchema} })`
208
- ];
209
- const sections = config.sections ?? [];
210
- for (const section of sections) {
211
- collections.push(
212
- `${section.slug}: defineCollection({ type: "content", schema: ${contentSchema} })`
213
- );
214
- }
215
- return `import { defineCollection, z } from "astro:content";
216
-
217
- export const collections = {
218
- ${collections.join(",\n ")},
219
- };
220
- `;
221
- }
222
- function findDocsDir(root) {
223
- const candidates = ["docs", "content", "src/content/docs"];
224
- for (const candidate of candidates) {
225
- const fullPath = path.join(root, candidate);
226
- if (fs.existsSync(fullPath)) {
227
- return candidate;
228
- }
229
- }
230
- return "docs";
231
- }
232
-
233
- export {
234
- isCustomProject,
235
- loadProjectConfig,
236
- createProject,
237
- cleanupProject,
238
- generateAstroConfigFile,
239
- findDocsDir
240
- };