dogsbay 0.2.0-beta.12 → 0.2.0-beta.14
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/commands/site-dev.js +28 -9
- package/package.json +9 -9
|
@@ -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
|
|
7
|
-
* 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).
|
|
11
|
-
*
|
|
12
|
-
*
|
|
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/
|
|
86
|
-
//
|
|
87
|
-
|
|
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.
|
|
3
|
+
"version": "0.2.0-beta.14",
|
|
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-
|
|
36
|
-
"@dogsbay/format-obsidian": "0.2.0-beta.
|
|
37
|
-
"@dogsbay/format-
|
|
38
|
-
"@dogsbay/format-mdx": "0.2.0-beta.
|
|
39
|
-
"@dogsbay/format-
|
|
40
|
-
"@dogsbay/format-
|
|
41
|
-
"@dogsbay/format-openapi": "0.2.0-beta.
|
|
42
|
-
"@dogsbay/types": "0.2.0-beta.
|
|
35
|
+
"@dogsbay/format-mkdocs": "0.2.0-beta.14",
|
|
36
|
+
"@dogsbay/format-obsidian": "0.2.0-beta.14",
|
|
37
|
+
"@dogsbay/format-astro": "0.2.0-beta.14",
|
|
38
|
+
"@dogsbay/format-mdx": "0.2.0-beta.14",
|
|
39
|
+
"@dogsbay/format-dogsbay-md": "0.2.0-beta.14",
|
|
40
|
+
"@dogsbay/format-starlight": "0.2.0-beta.14",
|
|
41
|
+
"@dogsbay/format-openapi": "0.2.0-beta.14",
|
|
42
|
+
"@dogsbay/types": "0.2.0-beta.14"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/node": "^22.0.0",
|