dogsbay 0.2.0-beta.12 → 0.2.0-beta.13

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.
@@ -3,13 +3,18 @@
3
3
  * run `dogsbay site build`, watch content for changes, and hand
4
4
  * control over to the Astro CLI inside the site directory.
5
5
  *
6
- * dev → astro dev (live HMR for already-built pages)
7
- * preview → astro build && astro preview
6
+ * dev → astro dev (live HMR for already-built pages)
7
+ * preview → <pm> run build astro preview
8
8
  *
9
9
  * The site dir is found by locating `dogsbay.config.{yml,yaml,json}`
10
- * at or above cwd (or via --config). `npm run build` (the user's
11
- * existing script) is *not* what runs here — we shell out to `astro`
12
- * directly so this works whether the user uses pnpm / npm / yarn.
10
+ * at or above cwd (or via --config).
11
+ *
12
+ * site dev shells `npx astro dev` directly fast, no script
13
+ * indirection. site preview needs the production build to match
14
+ * what's actually deployed, which means running the scaffolded
15
+ * package.json `build` script (chains `astro build && pagefind
16
+ * --site dist` so Cmd+K search works in the previewed dist/). The
17
+ * package manager is auto-detected (pnpm if on PATH, otherwise npm).
13
18
  *
14
19
  * `site dev` also installs a content watcher that re-runs
15
20
  * `dogsbay site build` whenever a markdown / yaml / json file under
@@ -37,6 +42,18 @@ const defaultRunner = (siteRoot, args) => new Promise((resolve) => {
37
42
  resolve(1);
38
43
  });
39
44
  });
45
+ const defaultBuildRunner = (siteRoot) => new Promise((resolve) => {
46
+ const pm = pickPackageManager();
47
+ const child = spawn(pm, ["run", "build"], {
48
+ cwd: siteRoot,
49
+ stdio: "inherit",
50
+ });
51
+ child.on("exit", (code) => resolve(code ?? 0));
52
+ child.on("error", (err) => {
53
+ console.error(pc.red(`Error: failed to spawn ${pm} run build: ${err.message}`));
54
+ resolve(1);
55
+ });
56
+ });
40
57
  /**
41
58
  * Pick the first available package manager from a preference list.
42
59
  * Defaults to pnpm (matches the dogsbay tooling chain); falls back
@@ -80,11 +97,13 @@ export async function siteDev(cwd, options, runner = defaultRunner) {
80
97
  throw err;
81
98
  }
82
99
  }
83
- export async function sitePreview(cwd, options, runner = defaultRunner) {
100
+ export async function sitePreview(cwd, options, runner = defaultRunner, buildRunner = defaultBuildRunner) {
84
101
  const { outputDir } = await prepareForAstro(cwd, options);
85
- // Two-step: produce dist/ then serve it. Each spawn is independent
86
- // so we can still surface its exit code cleanly.
87
- const buildCode = await runner(outputDir, ["build"]);
102
+ // Two-step: produce dist/ via the scaffolded `build` script
103
+ // (astro build + pagefind), then serve it via astro preview. The
104
+ // build script is the source of truth — `astro build` alone would
105
+ // skip pagefind and Cmd+K search in the previewed dist/ would 404.
106
+ const buildCode = await buildRunner(outputDir);
88
107
  if (buildCode !== 0)
89
108
  process.exit(buildCode);
90
109
  const previewCode = await runner(outputDir, ["preview"]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dogsbay",
3
- "version": "0.2.0-beta.12",
3
+ "version": "0.2.0-beta.13",
4
4
  "description": "CLI for Dogsbay — scaffold, build, and serve documentation sites with markdown / MkDocs / Obsidian / OpenAPI sources",
5
5
  "type": "module",
6
6
  "bin": {
@@ -32,14 +32,14 @@
32
32
  "picocolors": "^1.1.0",
33
33
  "prompts": "^2.4.2",
34
34
  "yaml": "^2.8.3",
35
- "@dogsbay/format-astro": "0.2.0-beta.12",
36
- "@dogsbay/format-obsidian": "0.2.0-beta.12",
37
- "@dogsbay/format-mkdocs": "0.2.0-beta.12",
38
- "@dogsbay/format-mdx": "0.2.0-beta.12",
39
- "@dogsbay/format-starlight": "0.2.0-beta.12",
40
- "@dogsbay/format-dogsbay-md": "0.2.0-beta.12",
41
- "@dogsbay/format-openapi": "0.2.0-beta.12",
42
- "@dogsbay/types": "0.2.0-beta.12"
35
+ "@dogsbay/format-mkdocs": "0.2.0-beta.13",
36
+ "@dogsbay/format-astro": "0.2.0-beta.13",
37
+ "@dogsbay/format-mdx": "0.2.0-beta.13",
38
+ "@dogsbay/format-starlight": "0.2.0-beta.13",
39
+ "@dogsbay/format-obsidian": "0.2.0-beta.13",
40
+ "@dogsbay/format-dogsbay-md": "0.2.0-beta.13",
41
+ "@dogsbay/format-openapi": "0.2.0-beta.13",
42
+ "@dogsbay/types": "0.2.0-beta.13"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/node": "^22.0.0",