create-dox 0.4.0 → 0.5.0

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.
@@ -19,9 +19,9 @@ function shouldInclude(path) {
19
19
  }
20
20
  return true;
21
21
  }
22
- async function downloadTemplate(targetDir) {
22
+ async function downloadTemplate(targetDir, siteName) {
23
23
  console.log("");
24
- console.log(" \u23F3 Downloading Dox template...");
24
+ console.log(` \u23F3 Creating ${siteName?.trim() || "your docs site"}...`);
25
25
  const response = await fetch(TARBALL_URL);
26
26
  if (!response.ok) {
27
27
  throw new Error(`Failed to download template: ${response.status} ${response.statusText}`);
@@ -135,6 +135,11 @@ function buildStarterDocsJson({
135
135
  i18nLocales
136
136
  }) {
137
137
  const config = {};
138
+ config.theme = "sharp";
139
+ config.fonts = {
140
+ body: { family: "Plus Jakarta Sans", weight: ["400", "500", "600", "700"] },
141
+ heading: { family: "Outfit", weight: ["600", "700"] }
142
+ };
138
143
  if (enableAiChat) {
139
144
  config.ai = { chat: true };
140
145
  }
@@ -201,20 +206,15 @@ function updateSiteConfig(targetDir, projectName, description, brandPreset, repo
201
206
  /const brandPreset:\s*BrandPresetKey\s*=\s*'[^']*'/,
202
207
  `const brandPreset: BrandPresetKey = '${brandPreset}'`
203
208
  );
204
- if (repoUrl) {
205
- source = source.replace(
206
- /repoUrl:\s*'[^']*'/,
207
- `repoUrl: '${repoUrl}'`
208
- );
209
- source = source.replace(
210
- /\{\s*label:\s*'GitHub',\s*href:\s*'[^']*'\s*\}/,
211
- `{ label: 'GitHub', href: '${repoUrl}' }`
212
- );
213
- source = source.replace(
214
- /\{\s*label:\s*'Support',\s*href:\s*'[^']*'\s*\}/,
215
- `{ label: 'Support', href: '${repoUrl}/issues/new' }`
216
- );
217
- }
209
+ source = source.replace(/repoUrl:\s*'[^']*'/, `repoUrl: '${repoUrl}'`);
210
+ source = source.replace(
211
+ /\{\s*label:\s*'GitHub',\s*href:\s*'[^']*'\s*\}/,
212
+ `{ label: 'GitHub', href: '${repoUrl}' }`
213
+ );
214
+ source = source.replace(
215
+ /\{\s*label:\s*'Support',\s*href:\s*'[^']*'\s*\}/,
216
+ `{ label: 'Support', href: '${repoUrl ? `${repoUrl}/issues/new` : ""}' }`
217
+ );
218
218
  writeFileSync(siteFile, source, "utf8");
219
219
  }
220
220
  function patchApiReferenceGuard(targetDir) {
@@ -366,7 +366,7 @@ async function scaffold(options) {
366
366
  }
367
367
  mkdirSync2(targetDir, { recursive: true });
368
368
  const slug = slugify(projectName);
369
- await downloadTemplate(targetDir);
369
+ await downloadTemplate(targetDir, projectName);
370
370
  writeStarterContent(targetDir, projectName, slug, enableAiChat, repoUrl, i18nLocales);
371
371
  updateSiteConfig(targetDir, projectName, description, brandPreset, repoUrl);
372
372
  patchApiReferenceGuard(targetDir);
@@ -3,7 +3,7 @@ import {
3
3
  initGit,
4
4
  installDeps,
5
5
  scaffold
6
- } from "./chunk-YY5QPPAG.js";
6
+ } from "./chunk-23YWNWTH.js";
7
7
 
8
8
  // src/migrate/index.ts
9
9
  import { mkdirSync as mkdirSync2, copyFileSync as copyFileSync2, readFileSync as readFileSync3, writeFileSync, existsSync as existsSync3, mkdtempSync, rmSync } from "fs";
package/dist/index.js CHANGED
@@ -2,13 +2,13 @@
2
2
  import {
3
3
  migrateDocs,
4
4
  parseGitHubUrl
5
- } from "./chunk-QB4U3KFX.js";
5
+ } from "./chunk-GVYVHLAP.js";
6
6
  import {
7
7
  logo,
8
8
  scaffold,
9
9
  slugify,
10
10
  success
11
- } from "./chunk-YY5QPPAG.js";
11
+ } from "./chunk-23YWNWTH.js";
12
12
 
13
13
  // src/index.ts
14
14
  import { existsSync as existsSync3, readdirSync as readdirSync2 } from "fs";
@@ -99,6 +99,7 @@ async function gatherAnswers(dirArg, useDefaults) {
99
99
  // src/check.ts
100
100
  import { existsSync, readFileSync as readFileSync2, readdirSync, statSync } from "fs";
101
101
  import { join as join2, extname, relative } from "path";
102
+ import { execFileSync } from "child_process";
102
103
  import matter from "gray-matter";
103
104
  import { parse as parseYaml } from "yaml";
104
105
 
@@ -116,6 +117,57 @@ function writeDocsJson(projectDir, config) {
116
117
  }
117
118
 
118
119
  // src/check.ts
120
+ function gitLocal(projectDir, args2) {
121
+ try {
122
+ const out = execFileSync("git", args2, { cwd: projectDir, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
123
+ return { ok: true, out: out.trim() };
124
+ } catch {
125
+ return { ok: false, out: "" };
126
+ }
127
+ }
128
+ function checkDrift(projectDir, file, data, issues) {
129
+ const sources = data.sources;
130
+ const verifiedCommit = data.verifiedCommit;
131
+ if (!Array.isArray(sources) || sources.length === 0 || typeof verifiedCommit !== "string" || !verifiedCommit.trim()) {
132
+ return;
133
+ }
134
+ const commit = verifiedCommit.trim();
135
+ if (!gitLocal(projectDir, ["cat-file", "-e", `${commit}^{commit}`]).ok) {
136
+ issues.push({
137
+ severity: "warning",
138
+ message: `Cannot verify freshness: verifiedCommit "${commit.slice(0, 8)}" is not in git history \u2014 run with a full clone (fetch-depth: 0).`,
139
+ file
140
+ });
141
+ return;
142
+ }
143
+ for (const src of sources) {
144
+ if (typeof src !== "string" || !src.trim()) continue;
145
+ const colon = src.indexOf(":");
146
+ let filePath = src;
147
+ if (colon > 0) {
148
+ const alias = src.slice(0, colon);
149
+ if (alias !== "." && alias !== "self") {
150
+ issues.push({
151
+ severity: "warning",
152
+ message: `Cross-repo source "${src}" \u2014 drift check skipped (needs the referenced repo; see multi-repo setup).`,
153
+ file
154
+ });
155
+ continue;
156
+ }
157
+ filePath = src.slice(colon + 1);
158
+ }
159
+ filePath = filePath.replace(/^\.\//, "").replace(/#.*$/, "");
160
+ const changed = gitLocal(projectDir, ["log", "--format=%H", `${commit}..HEAD`, "--", filePath]).out;
161
+ if (changed) {
162
+ const n = changed.split("\n").filter(Boolean).length;
163
+ issues.push({
164
+ severity: "warning",
165
+ message: `Drift: source "${src}" changed in ${n} commit(s) since it was verified \u2014 this page may be stale.`,
166
+ file
167
+ });
168
+ }
169
+ }
170
+ }
119
171
  function collectNavPageIds(groups, seen, duplicates) {
120
172
  for (const page of groups) {
121
173
  if (typeof page === "string") {
@@ -294,6 +346,7 @@ async function runCheck(projectDir, options) {
294
346
  if (!data.title) issues.push({ severity: "warning", message: `Missing "title" in frontmatter`, file: rel2 });
295
347
  if (!data.description) issues.push({ severity: "warning", message: `Missing "description" in frontmatter`, file: rel2 });
296
348
  if (content.trim().length < 50) issues.push({ severity: "warning", message: `Very short body (${content.trim().length} chars) \u2014 page may be empty`, file: rel2 });
349
+ if (options.drift) checkDrift(projectDir, rel2, data, issues);
297
350
  const path = pageIdToPath(pageId);
298
351
  const anchors = extractHeadingAnchors(content);
299
352
  validPaths.add(path);
@@ -704,7 +757,8 @@ async function runCheckCommand() {
704
757
  const exitCode = await runCheck(projectDir, {
705
758
  fix: flags.includes("--fix"),
706
759
  ci: flags.includes("--ci"),
707
- external: flags.includes("--external")
760
+ external: flags.includes("--external"),
761
+ drift: flags.includes("--drift")
708
762
  });
709
763
  process.exit(exitCode);
710
764
  }
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  migrateDocs
4
- } from "../chunk-QB4U3KFX.js";
5
- import "../chunk-YY5QPPAG.js";
4
+ } from "../chunk-GVYVHLAP.js";
5
+ import "../chunk-23YWNWTH.js";
6
6
  export {
7
7
  migrateDocs
8
8
  };
package/dist/scaffold.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  scaffold
4
- } from "./chunk-YY5QPPAG.js";
4
+ } from "./chunk-23YWNWTH.js";
5
5
  export {
6
6
  scaffold
7
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-dox",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Scaffold a new Dox documentation project",
5
5
  "type": "module",
6
6
  "engines": {