dogsbay 0.2.0-beta.43 → 0.2.0-beta.44
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/migrate-mkdocs.js +69 -7
- package/package.json +10 -10
|
@@ -77,6 +77,17 @@ export async function migrateMkdocs(source, options) {
|
|
|
77
77
|
console.log("Pass --force to overwrite.");
|
|
78
78
|
process.exit(1);
|
|
79
79
|
}
|
|
80
|
+
// On a --force re-run the existing dogsbay.config.yml carries
|
|
81
|
+
// deployment config the user owns — site.url + site.basePath —
|
|
82
|
+
// that has NO other source: it isn't in mkdocs.yml, and --site-url
|
|
83
|
+
// is deliberately not inherited from the source. Read it so a
|
|
84
|
+
// re-run that omits the flags preserves those values instead of
|
|
85
|
+
// silently resetting site.url to unset and basePath to /docs.
|
|
86
|
+
// Explicit --site-url / --base-path flags still win; a fresh
|
|
87
|
+
// migration (no existing config) is unaffected.
|
|
88
|
+
const existingDeployment = existingConfig
|
|
89
|
+
? readExistingDeployment(existingConfig)
|
|
90
|
+
: {};
|
|
80
91
|
console.log();
|
|
81
92
|
console.log(pc.bold(`Migrating MkDocs site to Dogsbay-MD: ${siteName}`));
|
|
82
93
|
console.log(`Source: ${sourceDir}`);
|
|
@@ -147,13 +158,18 @@ export async function migrateMkdocs(source, options) {
|
|
|
147
158
|
// site.url is left unset and the build emits relative URLs.
|
|
148
159
|
// sourceSiteUrl is kept only to warn the user it was dropped.
|
|
149
160
|
const sourceSiteUrl = config.site_url || undefined;
|
|
150
|
-
|
|
161
|
+
// Precedence: --site-url flag → existing config (--force re-run) →
|
|
162
|
+
// unset. Never the source mkdocs.yml's site_url.
|
|
163
|
+
const siteUrl = options.siteUrl || existingDeployment.siteUrl || undefined;
|
|
151
164
|
const repoUrl = config.repo_url || undefined;
|
|
152
|
-
// --base-path controls where docs sit under the host.
|
|
153
|
-
//
|
|
154
|
-
//
|
|
155
|
-
//
|
|
156
|
-
|
|
165
|
+
// --base-path controls where docs sit under the host. Precedence:
|
|
166
|
+
// --base-path flag → existing config (--force re-run) → /docs
|
|
167
|
+
// default (matches every scaffolded dogsbay site). Pass
|
|
168
|
+
// --base-path "" to serve at the host root — common for a
|
|
169
|
+
// dedicated repo or GitHub Pages project site.
|
|
170
|
+
const basePath = options.basePath !== undefined
|
|
171
|
+
? options.basePath
|
|
172
|
+
: existingDeployment.basePath ?? "/docs";
|
|
157
173
|
const siteDescription = config.site_description || undefined;
|
|
158
174
|
const dogsbayConfig = {
|
|
159
175
|
schemaVersion: 1,
|
|
@@ -183,6 +199,17 @@ export async function migrateMkdocs(source, options) {
|
|
|
183
199
|
};
|
|
184
200
|
writeFileSync(join(outputDir, "dogsbay.config.yml"), serializeConfig(dogsbayConfig, "yaml"));
|
|
185
201
|
console.log(pc.green(`Wrote`) + ` dogsbay.config.yml`);
|
|
202
|
+
// Surface preserved deployment config so a --force re-run isn't a
|
|
203
|
+
// silent black box — the user sees what carried over.
|
|
204
|
+
if (!options.siteUrl && existingDeployment.siteUrl) {
|
|
205
|
+
console.log(pc.green(`Kept`) +
|
|
206
|
+
` site.url from the existing config: ${existingDeployment.siteUrl}`);
|
|
207
|
+
}
|
|
208
|
+
if (options.basePath === undefined &&
|
|
209
|
+
existingDeployment.basePath !== undefined) {
|
|
210
|
+
console.log(pc.green(`Kept`) +
|
|
211
|
+
` site.basePath from the existing config: "${existingDeployment.basePath}"`);
|
|
212
|
+
}
|
|
186
213
|
if (sourceSiteUrl && !siteUrl) {
|
|
187
214
|
console.log(pc.yellow(`Note:`) +
|
|
188
215
|
` source site_url (${sourceSiteUrl}) was not carried over —` +
|
|
@@ -532,6 +559,30 @@ function extractAutodocOptions(mkdocsConfig) {
|
|
|
532
559
|
}
|
|
533
560
|
return Object.keys(out).length > 0 ? out : null;
|
|
534
561
|
}
|
|
562
|
+
/**
|
|
563
|
+
* Read the user-owned deployment config — `site.url` + `site.basePath`
|
|
564
|
+
* — out of an existing `dogsbay.config.yml` so a `--force` re-run can
|
|
565
|
+
* preserve them when the `--site-url` / `--base-path` flags are
|
|
566
|
+
* omitted.
|
|
567
|
+
*
|
|
568
|
+
* Lenient on purpose: `YAML.parse` reads both .yml and .json (JSON is
|
|
569
|
+
* valid YAML), and an unparseable / unexpected-shape config falls
|
|
570
|
+
* through to `{}` rather than aborting the migration — a re-run
|
|
571
|
+
* should never be blocked by a stale config it's about to overwrite.
|
|
572
|
+
*/
|
|
573
|
+
function readExistingDeployment(configPath) {
|
|
574
|
+
try {
|
|
575
|
+
const parsed = YAML.parse(readFileSync(configPath, "utf-8"));
|
|
576
|
+
const site = parsed?.site;
|
|
577
|
+
return {
|
|
578
|
+
siteUrl: typeof site?.url === "string" ? site.url : undefined,
|
|
579
|
+
basePath: typeof site?.basePath === "string" ? site.basePath : undefined,
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
catch {
|
|
583
|
+
return {};
|
|
584
|
+
}
|
|
585
|
+
}
|
|
535
586
|
/**
|
|
536
587
|
* Extract macros plugin data file mappings from mkdocs.yml.
|
|
537
588
|
* Returns { varName: absolutePath } for each `include_yaml` entry,
|
|
@@ -929,7 +980,18 @@ function buildMigrationNotes(args) {
|
|
|
929
980
|
}
|
|
930
981
|
lines.push("Set the destination URL in `dogsbay.config.yml`:", "", "```yaml", "site:", " url: https://you.github.io/your-repo # drives sitemap, llms.txt, canonical", ` basePath: ${basePath || '""'}`, "```", "", "Or re-run the migration with `--site-url` (and optionally", "`--base-path`).", "");
|
|
931
982
|
}
|
|
932
|
-
|
|
983
|
+
// Re-run command — spell out the deployment flags so the
|
|
984
|
+
// documented command reproduces the same site.url / basePath even
|
|
985
|
+
// against a fresh output dir. (A bare `--force` re-run also
|
|
986
|
+
// preserves them now, read back from the existing config — see the
|
|
987
|
+
// note below — but a self-contained command is the safer thing to
|
|
988
|
+
// copy.)
|
|
989
|
+
const rerunFlags = ["--output", outputDir, "--force"];
|
|
990
|
+
if (siteUrl)
|
|
991
|
+
rerunFlags.push("--site-url", siteUrl);
|
|
992
|
+
if (basePath !== "/docs")
|
|
993
|
+
rerunFlags.push("--base-path", `"${basePath}"`);
|
|
994
|
+
lines.push("## Re-running the migration", "", "If you find a regression and a later release fixes it, re-run", "with `--force`:", "", "```bash", `npx dogsbay migrate-mkdocs ${sourceDir} ${rerunFlags.join(" ")}`, "```", "", "`--force` overwrites all generated files; any hand edits to", "`./content/*.md` since the last migration will be lost — commit", "your work first.", "", "Your deployment config is preserved across a re-run: `site.url`", "and `site.basePath` are read back from the existing", "`dogsbay.config.yml` when the `--site-url` / `--base-path` flags", "are omitted (the flags still win when passed). Everything else in", "the config is re-derived from the source `mkdocs.yml`.", "");
|
|
933
995
|
if (lossy.length > 0) {
|
|
934
996
|
lines.push("## Known limitations", "");
|
|
935
997
|
lines.push("The following files have content that didn't fully round-trip", "into Dogsbay-MD. Review each one and fix manually:", "");
|
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.44",
|
|
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,15 +32,15 @@
|
|
|
32
32
|
"picocolors": "^1.1.0",
|
|
33
33
|
"prompts": "^2.4.2",
|
|
34
34
|
"yaml": "^2.8.3",
|
|
35
|
-
"@dogsbay/autodoc-python": "0.2.0-beta.
|
|
36
|
-
"@dogsbay/format-mkdocs": "0.2.0-beta.
|
|
37
|
-
"@dogsbay/format-astro": "0.2.0-beta.
|
|
38
|
-
"@dogsbay/format-obsidian": "0.2.0-beta.
|
|
39
|
-
"@dogsbay/format-mdx": "0.2.0-beta.
|
|
40
|
-
"@dogsbay/format-starlight": "0.2.0-beta.
|
|
41
|
-
"@dogsbay/format-dogsbay-md": "0.2.0-beta.
|
|
42
|
-
"@dogsbay/format-openapi": "0.2.0-beta.
|
|
43
|
-
"@dogsbay/types": "0.2.0-beta.
|
|
35
|
+
"@dogsbay/autodoc-python": "0.2.0-beta.44",
|
|
36
|
+
"@dogsbay/format-mkdocs": "0.2.0-beta.44",
|
|
37
|
+
"@dogsbay/format-astro": "0.2.0-beta.44",
|
|
38
|
+
"@dogsbay/format-obsidian": "0.2.0-beta.44",
|
|
39
|
+
"@dogsbay/format-mdx": "0.2.0-beta.44",
|
|
40
|
+
"@dogsbay/format-starlight": "0.2.0-beta.44",
|
|
41
|
+
"@dogsbay/format-dogsbay-md": "0.2.0-beta.44",
|
|
42
|
+
"@dogsbay/format-openapi": "0.2.0-beta.44",
|
|
43
|
+
"@dogsbay/types": "0.2.0-beta.44"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/markdown-it": "^14.1.0",
|