nrdocs 0.2.1 → 0.2.3

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/bin.mjs CHANGED
@@ -268,57 +268,24 @@ var require_punycode = __commonJS({
268
268
  }
269
269
  });
270
270
 
271
- // ../shared/dist/constants.js
272
- var NRDOCS_VERSION = "0.1.0";
273
- var ALLOWED_ASSET_EXTENSIONS = /* @__PURE__ */ new Set([
274
- ".html",
275
- ".css",
276
- ".json",
277
- ".svg",
278
- ".png",
279
- ".jpg",
280
- ".jpeg",
281
- ".gif",
282
- ".webp",
283
- ".ico",
284
- ".txt",
285
- ".pdf"
286
- ]);
287
- var REJECTED_EXTENSIONS = /* @__PURE__ */ new Set([".js", ".mjs", ".cjs"]);
288
-
289
- // ../shared/dist/naming.js
290
- var INSTANCE_NAME_REGEX = /^[a-z0-9]([a-z0-9-]{0,18}[a-z0-9])?$/;
291
- var MAX_INSTANCE_LENGTH = 20;
292
- function validateInstanceName(name) {
293
- if (!name) {
294
- return { valid: false, error: "Instance name cannot be empty" };
295
- }
296
- if (name.length > MAX_INSTANCE_LENGTH) {
297
- return { valid: false, error: `Instance name must be ${MAX_INSTANCE_LENGTH} characters or fewer` };
298
- }
299
- if (!INSTANCE_NAME_REGEX.test(name)) {
300
- return {
301
- valid: false,
302
- error: "Instance name must be lowercase alphanumeric with hyphens, cannot start or end with a hyphen"
303
- };
271
+ // src/version.ts
272
+ import { readFileSync } from "node:fs";
273
+ import * as path from "node:path";
274
+ import { fileURLToPath } from "node:url";
275
+ var cached;
276
+ function getCliVersion() {
277
+ if (cached) return cached;
278
+ try {
279
+ const pkgPath = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "package.json");
280
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
281
+ if (typeof pkg.version === "string" && pkg.version.length > 0) {
282
+ cached = pkg.version;
283
+ return cached;
284
+ }
285
+ } catch {
304
286
  }
305
- return { valid: true };
306
- }
307
- function getWorkerName(instance) {
308
- return `nrdocs-${instance}`;
309
- }
310
- function getD1Name(instance) {
311
- return `nrdocs-${instance}-db`;
312
- }
313
- function getR2BucketName(instance) {
314
- return `nrdocs-${instance}-artifacts`;
315
- }
316
- function getResourceNames(instance) {
317
- return {
318
- worker: getWorkerName(instance),
319
- d1: getD1Name(instance),
320
- r2: getR2BucketName(instance)
321
- };
287
+ cached = "0.0.0";
288
+ return cached;
322
289
  }
323
290
 
324
291
  // src/commands/auth/login.ts
@@ -326,17 +293,17 @@ import * as readline from "node:readline";
326
293
 
327
294
  // src/config/paths.ts
328
295
  import * as os from "node:os";
329
- import * as path from "node:path";
296
+ import * as path2 from "node:path";
330
297
  var APP_NAME = "nrdocs";
331
298
  var CONFIG_FILE = "config.json";
332
299
  function getConfigDir(overrideDir) {
333
300
  if (overrideDir) return overrideDir;
334
301
  const xdg = process.env["XDG_CONFIG_HOME"];
335
- const base = xdg || path.join(os.homedir(), ".config");
336
- return path.join(base, APP_NAME);
302
+ const base = xdg || path2.join(os.homedir(), ".config");
303
+ return path2.join(base, APP_NAME);
337
304
  }
338
305
  function getConfigPath(overrideDir) {
339
- return path.join(getConfigDir(overrideDir), CONFIG_FILE);
306
+ return path2.join(getConfigDir(overrideDir), CONFIG_FILE);
340
307
  }
341
308
 
342
309
  // src/config/schema.ts
@@ -366,7 +333,7 @@ function validateConfig(data) {
366
333
 
367
334
  // src/config/store.ts
368
335
  import * as fs from "node:fs";
369
- import * as path2 from "node:path";
336
+ import * as path3 from "node:path";
370
337
  var DIR_MODE = 448;
371
338
  var FILE_MODE = 384;
372
339
  function ensureConfigDir(configDir) {
@@ -403,7 +370,7 @@ function loadConfig(overrideDir) {
403
370
  }
404
371
  function saveConfig(config2, overrideDir) {
405
372
  const configDir = getConfigDir(overrideDir);
406
- const configPath = path2.join(configDir, "config.json");
373
+ const configPath = path3.join(configDir, "config.json");
407
374
  ensureConfigDir(configDir);
408
375
  const json = JSON.stringify(config2, null, 2) + "\n";
409
376
  fs.writeFileSync(configPath, json, { mode: FILE_MODE });
@@ -600,23 +567,23 @@ function authLogout(opts = {}) {
600
567
 
601
568
  // src/commands/init.ts
602
569
  import * as fs4 from "node:fs";
603
- import * as path5 from "node:path";
570
+ import * as path6 from "node:path";
604
571
  import * as readline2 from "node:readline";
605
572
 
606
573
  // src/config/docs-config.ts
607
574
  import * as fs3 from "node:fs";
608
- import * as path4 from "node:path";
575
+ import * as path5 from "node:path";
609
576
  import YAML from "yaml";
610
577
 
611
578
  // src/renderer/navigation.ts
612
579
  import * as fs2 from "node:fs";
613
- import * as path3 from "node:path";
580
+ import * as path4 from "node:path";
614
581
  function extractTitle(markdownContent, filePath) {
615
582
  const match2 = markdownContent.match(/^#\s+(.+)$/m);
616
583
  if (match2) {
617
584
  return match2[1].trim();
618
585
  }
619
- const basename3 = path3.basename(filePath, ".md");
586
+ const basename3 = path4.basename(filePath, ".md");
620
587
  if (basename3 === "index") {
621
588
  return "Home";
622
589
  }
@@ -627,11 +594,11 @@ function findMarkdownFiles(dir, relativeTo) {
627
594
  if (!fs2.existsSync(dir)) return results;
628
595
  const entries = fs2.readdirSync(dir, { withFileTypes: true });
629
596
  for (const entry of entries) {
630
- const fullPath = path3.join(dir, entry.name);
597
+ const fullPath = path4.join(dir, entry.name);
631
598
  if (entry.isDirectory()) {
632
599
  results.push(...findMarkdownFiles(fullPath, relativeTo));
633
600
  } else if (entry.isFile() && entry.name.endsWith(".md")) {
634
- results.push(path3.relative(relativeTo, fullPath).replace(/\\/g, "/"));
601
+ results.push(path4.relative(relativeTo, fullPath).replace(/\\/g, "/"));
635
602
  }
636
603
  }
637
604
  return results;
@@ -654,7 +621,7 @@ function mdPathToHref(filePath) {
654
621
  return `${withoutExt}/`;
655
622
  }
656
623
  function navEntryFromFile(contentDir, file) {
657
- const fullPath = path3.join(contentDir, file);
624
+ const fullPath = path4.join(contentDir, file);
658
625
  const content = fs2.readFileSync(fullPath, "utf-8");
659
626
  return {
660
627
  title: extractTitle(content, file),
@@ -670,7 +637,7 @@ function groupNavEntriesByFolders(files, contentDir, indexPath = "index.md") {
670
637
  const rootLinks = [];
671
638
  const byFolder = /* @__PURE__ */ new Map();
672
639
  for (const file of sorted) {
673
- const dir = path3.dirname(file).replace(/\\/g, "/");
640
+ const dir = path4.dirname(file).replace(/\\/g, "/");
674
641
  if (dir === ".") {
675
642
  rootLinks.push(navEntryFromFile(contentDir, file));
676
643
  continue;
@@ -719,7 +686,7 @@ function navConfigToNavItems(entries, contentDir) {
719
686
  throw new Error("Nav has no pages (entries need path or nested children with paths)");
720
687
  }
721
688
  for (const item of items) {
722
- const full = path3.join(contentDir, item.path);
689
+ const full = path4.join(contentDir, item.path);
723
690
  if (!fs2.existsSync(full)) {
724
691
  throw new Error(`Nav path not found: ${item.path}`);
725
692
  }
@@ -764,7 +731,7 @@ function flattenNavPaths(entries) {
764
731
 
765
732
  // src/config/docs-config.ts
766
733
  function loadDocsConfig(docsDir) {
767
- const configPath = path4.resolve(docsDir, "nrdocs.yml");
734
+ const configPath = path5.resolve(docsDir, "nrdocs.yml");
768
735
  if (!fs3.existsSync(configPath)) {
769
736
  throw new Error(`Config file not found: ${configPath}`);
770
737
  }
@@ -774,7 +741,7 @@ function loadDocsConfig(docsDir) {
774
741
  throw new Error(`Invalid config: ${configPath}`);
775
742
  }
776
743
  const sourceDir = config2.content?.source_dir ?? ".";
777
- const contentDir = path4.resolve(docsDir, sourceDir);
744
+ const contentDir = path5.resolve(docsDir, sourceDir);
778
745
  return { config: config2, configPath, contentDir };
779
746
  }
780
747
  function hasExplicitNav(config2) {
@@ -830,7 +797,7 @@ function validateNavPaths(entries, contentDir) {
830
797
  errors.push(`Duplicate nav path: ${p}`);
831
798
  }
832
799
  seen.add(p);
833
- const full = path4.join(contentDir, p);
800
+ const full = path5.join(contentDir, p);
834
801
  if (!fs3.existsSync(full)) {
835
802
  errors.push(`Nav path not found: ${p}`);
836
803
  }
@@ -1011,11 +978,11 @@ async function handleInit(args2) {
1011
978
  process.exit(2);
1012
979
  }
1013
980
  const docsDir = opts.docsDir || "docs";
1014
- const docsPath = path5.resolve(docsDir);
1015
- const configFile = path5.join(docsPath, "nrdocs.yml");
981
+ const docsPath = path6.resolve(docsDir);
982
+ const configFile = path6.join(docsPath, "nrdocs.yml");
1016
983
  const existing = readExistingConfig(configFile);
1017
984
  const configExists = fs4.existsSync(configFile);
1018
- const dirName = path5.basename(process.cwd());
985
+ const dirName = path6.basename(process.cwd());
1019
986
  let title = opts.title || existing.title;
1020
987
  if (!title) {
1021
988
  title = await prompt2("Site title", `${dirName} Docs`);
@@ -1048,8 +1015,8 @@ async function handleInit(args2) {
1048
1015
  process.exit(2);
1049
1016
  }
1050
1017
  apiUrl = normalizeUrl(apiUrl);
1051
- const workflowDir = path5.resolve(".github", "workflows");
1052
- const workflowFile = path5.join(workflowDir, "nrdocs.yml");
1018
+ const workflowDir = path6.resolve(".github", "workflows");
1019
+ const workflowFile = path6.join(workflowDir, "nrdocs.yml");
1053
1020
  if (!opts.force && fs4.existsSync(workflowFile)) {
1054
1021
  console.error("Error: Workflow already exists:");
1055
1022
  console.error(` ${workflowFile}`);
@@ -1071,12 +1038,12 @@ async function handleInit(args2) {
1071
1038
  console.log("");
1072
1039
  console.log("Created/updated:");
1073
1040
  if (createdConfig) {
1074
- console.log(` ${path5.relative(process.cwd(), configFile)}`);
1041
+ console.log(` ${path6.relative(process.cwd(), configFile)}`);
1075
1042
  }
1076
- console.log(` ${path5.relative(process.cwd(), workflowFile)}`);
1043
+ console.log(` ${path6.relative(process.cwd(), workflowFile)}`);
1077
1044
  if (!createdConfig) {
1078
1045
  console.log("");
1079
- console.log(`Using existing: ${path5.relative(process.cwd(), configFile)}`);
1046
+ console.log(`Using existing: ${path6.relative(process.cwd(), configFile)}`);
1080
1047
  }
1081
1048
  if (navPageCount > 0) {
1082
1049
  console.log(` content.nav: ${navPageCount} page(s) from markdown under ${docsDir}/`);
@@ -1086,7 +1053,7 @@ async function handleInit(args2) {
1086
1053
  if (navPageCount === 0) {
1087
1054
  console.log(` 1. Add markdown files under ${docsDir}/, then run: nrdocs nav generate`);
1088
1055
  } else {
1089
- console.log(` 1. Edit content.nav in ${path5.relative(process.cwd(), configFile)} to reorder pages`);
1056
+ console.log(` 1. Edit content.nav in ${path6.relative(process.cwd(), configFile)} to reorder pages`);
1090
1057
  }
1091
1058
  console.log(" 2. Commit and push to trigger the workflow");
1092
1059
  console.log(" 3. Ask your operator to approve the repo");
@@ -1097,7 +1064,7 @@ import * as fs8 from "node:fs";
1097
1064
 
1098
1065
  // src/renderer/index.ts
1099
1066
  import * as fs7 from "node:fs";
1100
- import * as path8 from "node:path";
1067
+ import * as path9 from "node:path";
1101
1068
 
1102
1069
  // ../../node_modules/.pnpm/markdown-it@14.1.1/node_modules/markdown-it/lib/common/utils.mjs
1103
1070
  var utils_exports = {};
@@ -6588,9 +6555,63 @@ function escapeHtml2(str) {
6588
6555
 
6589
6556
  // src/renderer/assets.ts
6590
6557
  import * as fs5 from "node:fs";
6591
- import * as path6 from "node:path";
6558
+ import * as path7 from "node:path";
6559
+
6560
+ // ../shared/dist/constants.js
6561
+ var ALLOWED_ASSET_EXTENSIONS = /* @__PURE__ */ new Set([
6562
+ ".html",
6563
+ ".css",
6564
+ ".json",
6565
+ ".svg",
6566
+ ".png",
6567
+ ".jpg",
6568
+ ".jpeg",
6569
+ ".gif",
6570
+ ".webp",
6571
+ ".ico",
6572
+ ".txt",
6573
+ ".pdf"
6574
+ ]);
6575
+ var REJECTED_EXTENSIONS = /* @__PURE__ */ new Set([".js", ".mjs", ".cjs"]);
6576
+
6577
+ // ../shared/dist/naming.js
6578
+ var INSTANCE_NAME_REGEX = /^[a-z0-9]([a-z0-9-]{0,18}[a-z0-9])?$/;
6579
+ var MAX_INSTANCE_LENGTH = 20;
6580
+ function validateInstanceName(name) {
6581
+ if (!name) {
6582
+ return { valid: false, error: "Instance name cannot be empty" };
6583
+ }
6584
+ if (name.length > MAX_INSTANCE_LENGTH) {
6585
+ return { valid: false, error: `Instance name must be ${MAX_INSTANCE_LENGTH} characters or fewer` };
6586
+ }
6587
+ if (!INSTANCE_NAME_REGEX.test(name)) {
6588
+ return {
6589
+ valid: false,
6590
+ error: "Instance name must be lowercase alphanumeric with hyphens, cannot start or end with a hyphen"
6591
+ };
6592
+ }
6593
+ return { valid: true };
6594
+ }
6595
+ function getWorkerName(instance) {
6596
+ return `nrdocs-${instance}`;
6597
+ }
6598
+ function getD1Name(instance) {
6599
+ return `nrdocs-${instance}-db`;
6600
+ }
6601
+ function getR2BucketName(instance) {
6602
+ return `nrdocs-${instance}-artifacts`;
6603
+ }
6604
+ function getResourceNames(instance) {
6605
+ return {
6606
+ worker: getWorkerName(instance),
6607
+ d1: getD1Name(instance),
6608
+ r2: getR2BucketName(instance)
6609
+ };
6610
+ }
6611
+
6612
+ // src/renderer/assets.ts
6592
6613
  function collectAssets(docsDir) {
6593
- const resolvedDocsDir = path6.resolve(docsDir);
6614
+ const resolvedDocsDir = path7.resolve(docsDir);
6594
6615
  const files = [];
6595
6616
  collectFromDir(resolvedDocsDir, resolvedDocsDir, files);
6596
6617
  return files;
@@ -6603,8 +6624,8 @@ function collectFromDir(dir, rootDir, results) {
6603
6624
  return;
6604
6625
  }
6605
6626
  for (const entry of entries) {
6606
- const fullPath = path6.join(dir, entry.name);
6607
- const resolved = path6.resolve(fullPath);
6627
+ const fullPath = path7.join(dir, entry.name);
6628
+ const resolved = path7.resolve(fullPath);
6608
6629
  if (!resolved.startsWith(rootDir)) {
6609
6630
  continue;
6610
6631
  }
@@ -6612,11 +6633,11 @@ function collectFromDir(dir, rootDir, results) {
6612
6633
  if (entry.name.startsWith(".")) continue;
6613
6634
  collectFromDir(fullPath, rootDir, results);
6614
6635
  } else if (entry.isFile()) {
6615
- const ext = path6.extname(entry.name).toLowerCase();
6636
+ const ext = path7.extname(entry.name).toLowerCase();
6616
6637
  if (ext === ".md") continue;
6617
6638
  if (REJECTED_EXTENSIONS.has(ext)) continue;
6618
6639
  if (!ALLOWED_ASSET_EXTENSIONS.has(ext)) continue;
6619
- const relativePath = path6.relative(rootDir, fullPath);
6640
+ const relativePath = path7.relative(rootDir, fullPath);
6620
6641
  if (relativePath.includes("..")) continue;
6621
6642
  results.push({
6622
6643
  path: relativePath.replace(/\\/g, "/"),
@@ -6628,15 +6649,15 @@ function collectFromDir(dir, rootDir, results) {
6628
6649
 
6629
6650
  // src/renderer/mermaid-runtime.ts
6630
6651
  import * as fs6 from "node:fs";
6631
- import * as path7 from "node:path";
6632
- import { fileURLToPath } from "node:url";
6633
- var __dirname = path7.dirname(fileURLToPath(import.meta.url));
6652
+ import * as path8 from "node:path";
6653
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
6654
+ var __dirname = path8.dirname(fileURLToPath2(import.meta.url));
6634
6655
  var MERMAID_RUNTIME_REL = "runtime/mermaid.min.js";
6635
6656
  var MERMAID_ARTIFACT_PATH = "_nrdocs/mermaid.min.js";
6636
6657
  function mermaidRuntimeCandidates() {
6637
6658
  return [
6638
- path7.join(__dirname, MERMAID_RUNTIME_REL),
6639
- path7.join(__dirname, "../../dist/runtime/mermaid.min.js")
6659
+ path8.join(__dirname, MERMAID_RUNTIME_REL),
6660
+ path8.join(__dirname, "../../dist/runtime/mermaid.min.js")
6640
6661
  ];
6641
6662
  }
6642
6663
  function loadMermaidRuntime() {
@@ -6671,18 +6692,18 @@ function resolveNav(resolvedDocsDir, nav, indexPath) {
6671
6692
  }
6672
6693
  async function renderSite(options) {
6673
6694
  const { docsDir, siteTitle, baseUrl, owner, repo, nav, indexPath = "index.md" } = options;
6674
- const resolvedDocsDir = path8.resolve(docsDir);
6695
+ const resolvedDocsDir = path9.resolve(docsDir);
6675
6696
  const { items: navItems, sidebarConfig } = resolveNav(resolvedDocsDir, nav, indexPath);
6676
6697
  const siteBase = `/${owner}/${repo}/`;
6677
6698
  const renderedFiles = [];
6678
6699
  let siteHasMermaid = false;
6679
6700
  for (const navItem of navItems) {
6680
- const filePath = path8.join(resolvedDocsDir, navItem.path);
6701
+ const filePath = path9.join(resolvedDocsDir, navItem.path);
6681
6702
  const markdownContent = fs7.readFileSync(filePath, "utf-8");
6682
6703
  const pageHasMermaid = contentHasMermaid(markdownContent);
6683
6704
  if (pageHasMermaid) siteHasMermaid = true;
6684
6705
  let html = renderMarkdown(markdownContent);
6685
- const fileDir = path8.dirname(navItem.path);
6706
+ const fileDir = path9.dirname(navItem.path);
6686
6707
  const baseLinkPath = fileDir === "." ? "" : fileDir;
6687
6708
  html = rewriteLinks(html, baseLinkPath, owner, repo);
6688
6709
  const pageTitle = extractTitle(markdownContent, navItem.path);
@@ -6806,8 +6827,8 @@ function normalizeApiBaseUrl(url) {
6806
6827
  }
6807
6828
  function buildApiUrl(baseUrl, apiPath) {
6808
6829
  const { url } = normalizeApiBaseUrl(baseUrl);
6809
- const path12 = apiPath.startsWith("/") ? apiPath : `/${apiPath}`;
6810
- return `${url}${path12}`;
6830
+ const path13 = apiPath.startsWith("/") ? apiPath : `/${apiPath}`;
6831
+ return `${url}${path13}`;
6811
6832
  }
6812
6833
  function extractFetchError(err) {
6813
6834
  if (!(err instanceof Error)) {
@@ -6950,12 +6971,12 @@ async function probeApiStatus(baseUrl, timeoutMs = 15e3) {
6950
6971
  };
6951
6972
  }
6952
6973
  const json = await res.json();
6953
- const version = json.data?.version;
6974
+ const version2 = json.data?.version;
6954
6975
  return {
6955
6976
  ok: true,
6956
6977
  status: res.status,
6957
- message: version ? `OK (nrdocs ${version})` : "OK",
6958
- version
6978
+ message: version2 ? `OK (nrdocs ${version2})` : "OK",
6979
+ version: version2
6959
6980
  };
6960
6981
  } catch (e) {
6961
6982
  clearTimeout(timer);
@@ -7055,8 +7076,8 @@ var ApiClient = class {
7055
7076
  }
7056
7077
  };
7057
7078
  }
7058
- async request(method, path12, body, timeoutMs = DEFAULT_TIMEOUT_MS) {
7059
- const url = buildApiUrl(this.baseUrl, path12);
7079
+ async request(method, path13, body, timeoutMs = DEFAULT_TIMEOUT_MS) {
7080
+ const url = buildApiUrl(this.baseUrl, path13);
7060
7081
  const controller = new AbortController();
7061
7082
  const timer = setTimeout(() => controller.abort(), timeoutMs);
7062
7083
  const init = {
@@ -7125,8 +7146,8 @@ var ApiClient = class {
7125
7146
  });
7126
7147
  }
7127
7148
  async setSelfPasswordAllow(owner, repo, allow) {
7128
- const path12 = allow ? `/api/repos/${owner}/${repo}/allow-self-password` : `/api/repos/${owner}/${repo}/disallow-self-password`;
7129
- return this.request("POST", path12);
7149
+ const path13 = allow ? `/api/repos/${owner}/${repo}/allow-self-password` : `/api/repos/${owner}/${repo}/disallow-self-password`;
7150
+ return this.request("POST", path13);
7130
7151
  }
7131
7152
  async listRules() {
7132
7153
  return this.request("GET", "/api/auto-approval-rules");
@@ -7396,7 +7417,7 @@ async function handlePublish(args2) {
7396
7417
 
7397
7418
  // src/commands/doctor.ts
7398
7419
  import * as fs9 from "node:fs";
7399
- import * as path9 from "node:path";
7420
+ import * as path10 from "node:path";
7400
7421
  function parseDoctorArgs(args2) {
7401
7422
  const opts = {};
7402
7423
  for (const arg of args2) {
@@ -7410,7 +7431,7 @@ function countMarkdownFiles(docsDir) {
7410
7431
  let count = 0;
7411
7432
  const walk = (dir) => {
7412
7433
  for (const entry of fs9.readdirSync(dir, { withFileTypes: true })) {
7413
- const full = path9.join(dir, entry.name);
7434
+ const full = path10.join(dir, entry.name);
7414
7435
  if (entry.isDirectory()) walk(full);
7415
7436
  else if (entry.name.endsWith(".md")) count++;
7416
7437
  }
@@ -7422,14 +7443,14 @@ async function handleDoctor(args2) {
7422
7443
  const opts = parseDoctorArgs(args2);
7423
7444
  const inCI = opts.ci || process.env["GITHUB_ACTIONS"] === "true";
7424
7445
  const checks = [];
7425
- const isGitRepo = fs9.existsSync(path9.resolve(".git"));
7446
+ const isGitRepo = fs9.existsSync(path10.resolve(".git"));
7426
7447
  checks.push({
7427
7448
  section: "Repo setup",
7428
7449
  name: "Git repository",
7429
7450
  status: isGitRepo ? "ok" : "fail",
7430
7451
  message: isGitRepo ? "Found .git directory" : "Not a git repository"
7431
7452
  });
7432
- const configPath = path9.resolve("docs", "nrdocs.yml");
7453
+ const configPath = path10.resolve("docs", "nrdocs.yml");
7433
7454
  const hasConfig = fs9.existsSync(configPath);
7434
7455
  checks.push({
7435
7456
  section: "Repo setup",
@@ -7437,7 +7458,7 @@ async function handleDoctor(args2) {
7437
7458
  status: hasConfig ? "ok" : "fail",
7438
7459
  message: hasConfig ? "Found docs/nrdocs.yml" : "Missing docs/nrdocs.yml \u2014 run: nrdocs init"
7439
7460
  });
7440
- const docsDir = path9.resolve("docs");
7461
+ const docsDir = path10.resolve("docs");
7441
7462
  const mdCount = countMarkdownFiles(docsDir);
7442
7463
  checks.push({
7443
7464
  section: "Repo setup",
@@ -7445,7 +7466,7 @@ async function handleDoctor(args2) {
7445
7466
  status: mdCount > 0 ? "ok" : "warn",
7446
7467
  message: mdCount > 0 ? `${mdCount} markdown file(s) in docs/` : "No .md files in docs/ \u2014 publish will produce an empty site"
7447
7468
  });
7448
- const workflowPath = path9.resolve(".github", "workflows", "nrdocs.yml");
7469
+ const workflowPath = path10.resolve(".github", "workflows", "nrdocs.yml");
7449
7470
  const hasWorkflow = fs9.existsSync(workflowPath);
7450
7471
  checks.push({
7451
7472
  section: "Repo setup",
@@ -7626,7 +7647,7 @@ async function handleDoctor(args2) {
7626
7647
 
7627
7648
  // src/commands/nav.ts
7628
7649
  import * as fs10 from "node:fs";
7629
- import * as path10 from "node:path";
7650
+ import * as path11 from "node:path";
7630
7651
  function parseNavGenerateArgs(args2) {
7631
7652
  const opts = {};
7632
7653
  for (let i = 0; i < args2.length; i++) {
@@ -7645,8 +7666,8 @@ function parseNavGenerateArgs(args2) {
7645
7666
  }
7646
7667
  async function handleNavGenerate(args2) {
7647
7668
  const opts = parseNavGenerateArgs(args2);
7648
- const docsDir = path10.resolve(opts.docsDir ?? "docs");
7649
- const configPath = path10.join(docsDir, "nrdocs.yml");
7669
+ const docsDir = path11.resolve(opts.docsDir ?? "docs");
7670
+ const configPath = path11.join(docsDir, "nrdocs.yml");
7650
7671
  if (!fs10.existsSync(configPath)) {
7651
7672
  console.error(`Error: Config file not found: ${configPath}`);
7652
7673
  console.error("Run: nrdocs init");
@@ -7680,7 +7701,7 @@ async function handleNavGenerate(args2) {
7680
7701
  }
7681
7702
  generateNavInConfig(docsDir, { generatedBy: "nrdocs nav generate", indexPath });
7682
7703
  if (!opts.json) {
7683
- console.log(`Generated navigation for ${entries.length} page(s) in ${path10.relative(process.cwd(), configPath)}`);
7704
+ console.log(`Generated navigation for ${entries.length} page(s) in ${path11.relative(process.cwd(), configPath)}`);
7684
7705
  console.log("Edit the file to reorder or rename entries, then run publish.");
7685
7706
  }
7686
7707
  }
@@ -7689,7 +7710,7 @@ async function handleNavGenerate(args2) {
7689
7710
  import * as readline3 from "node:readline";
7690
7711
  import * as crypto from "node:crypto";
7691
7712
  import * as fs11 from "node:fs";
7692
- import * as path11 from "node:path";
7713
+ import * as path12 from "node:path";
7693
7714
  import { execSync } from "node:child_process";
7694
7715
  function parseDeployArgs(args2) {
7695
7716
  const opts = {};
@@ -7756,23 +7777,52 @@ function normalizeUrl2(url) {
7756
7777
  }
7757
7778
  return normalized;
7758
7779
  }
7780
+ function packagedWorkerDir() {
7781
+ const cliEntry = process.argv[1];
7782
+ if (!cliEntry) return null;
7783
+ const distDir = path12.dirname(path12.resolve(cliEntry));
7784
+ const dir = path12.join(distDir, "deploy-worker");
7785
+ if (fs11.existsSync(path12.join(dir, "index.js"))) return dir;
7786
+ return null;
7787
+ }
7759
7788
  function findWorkerDir() {
7760
- const candidates = [
7761
- path11.resolve("packages/worker"),
7762
- path11.resolve("../worker")
7789
+ const packaged = packagedWorkerDir();
7790
+ if (packaged) return packaged;
7791
+ const monorepoCandidates = [
7792
+ path12.resolve("packages/worker"),
7793
+ path12.resolve("../worker")
7763
7794
  ];
7764
- const cliDir = process.argv[1] ? path11.dirname(process.argv[1]) : process.cwd();
7765
- candidates.push(path11.resolve(cliDir, "../../../worker"));
7766
- candidates.push(path11.resolve(cliDir, "../../../../packages/worker"));
7767
- for (const candidate of candidates) {
7768
- if (fs11.existsSync(path11.join(candidate, "src", "index.ts"))) {
7795
+ if (process.argv[1]) {
7796
+ const cliDir = path12.dirname(path12.resolve(process.argv[1]));
7797
+ monorepoCandidates.push(path12.resolve(cliDir, "../../../worker"));
7798
+ monorepoCandidates.push(path12.resolve(cliDir, "../../../../packages/worker"));
7799
+ }
7800
+ for (const candidate of monorepoCandidates) {
7801
+ if (fs11.existsSync(path12.join(candidate, "src", "index.ts"))) {
7769
7802
  return candidate;
7770
7803
  }
7771
7804
  }
7772
7805
  return null;
7773
7806
  }
7807
+ function isDocsContentRepo(cwd) {
7808
+ return fs11.existsSync(path12.join(cwd, "docs", "nrdocs.yml")) && !fs11.existsSync(path12.join(cwd, "packages", "worker", "src", "index.ts"));
7809
+ }
7810
+ function workerUsesBundledEntry(workerDir) {
7811
+ return fs11.existsSync(path12.join(workerDir, "index.js"));
7812
+ }
7774
7813
  async function handleDeploy(args2) {
7775
7814
  const opts = parseDeployArgs(args2);
7815
+ console.log("nrdocs deploy \u2014 Cloudflare infrastructure (Worker, D1, R2)");
7816
+ console.log("This does not publish markdown from the current repo.");
7817
+ console.log("Repo owners publish docs via GitHub Actions: nrdocs publish");
7818
+ console.log("");
7819
+ if (isDocsContentRepo(process.cwd())) {
7820
+ console.warn(
7821
+ "Note: This directory looks like a documentation repository (docs/nrdocs.yml)."
7822
+ );
7823
+ console.warn("You are deploying the nrdocs hosting stack, not site content here.");
7824
+ console.log("");
7825
+ }
7776
7826
  if (!checkWrangler()) {
7777
7827
  console.error("Error: Wrangler is not available.");
7778
7828
  console.error("Install it: npm install -g wrangler");
@@ -7816,7 +7866,10 @@ async function handleDeploy(args2) {
7816
7866
  }
7817
7867
  } else {
7818
7868
  instance = instance || await prompt3("Instance name", "default");
7819
- baseUrl = baseUrl || await prompt3("Docs base URL", "https://docs.example.com");
7869
+ baseUrl = baseUrl || await prompt3(
7870
+ "Public site URL (readers visit this host)",
7871
+ "https://docs.example.com"
7872
+ );
7820
7873
  }
7821
7874
  baseUrl = normalizeUrl2(baseUrl);
7822
7875
  const validation = validateInstanceName(instance);
@@ -7856,10 +7909,11 @@ async function handleDeploy(args2) {
7856
7909
  }
7857
7910
  const workerDir = findWorkerDir();
7858
7911
  if (!workerDir) {
7859
- console.error("Error: Cannot find packages/worker directory.");
7860
- console.error("Run nrdocs deploy from the nrdocs project root.");
7912
+ console.error("Error: Cannot find the nrdocs Worker bundle.");
7913
+ console.error("Reinstall the CLI (npm install -g nrdocs) or run from the nrdocs monorepo.");
7861
7914
  process.exit(4);
7862
7915
  }
7916
+ const workerMain = workerUsesBundledEntry(workerDir) ? "index.js" : "src/index.ts";
7863
7917
  console.log(`Creating R2 bucket ${names.r2}...`);
7864
7918
  const r2Check = runSilent("npx wrangler r2 bucket list");
7865
7919
  if (r2Check.ok && r2Check.stdout.includes(names.r2)) {
@@ -7893,7 +7947,7 @@ async function handleDeploy(args2) {
7893
7947
  }
7894
7948
  }
7895
7949
  const wranglerToml = `name = "${names.worker}"
7896
- main = "src/index.ts"
7950
+ main = "${workerMain}"
7897
7951
  compatibility_date = "2026-05-07"
7898
7952
 
7899
7953
  [[d1_databases]]
@@ -7908,11 +7962,11 @@ bucket_name = "${names.r2}"
7908
7962
  [vars]
7909
7963
  BASE_URL = "${baseUrl}"
7910
7964
  `;
7911
- const wranglerPath = path11.join(workerDir, "wrangler.toml");
7965
+ const wranglerPath = path12.join(workerDir, "wrangler.toml");
7912
7966
  fs11.writeFileSync(wranglerPath, wranglerToml);
7913
7967
  console.log("\u2705 wrangler.toml generated");
7914
7968
  console.log("Applying D1 migrations...");
7915
- const migrationsDir = path11.join(workerDir, "migrations");
7969
+ const migrationsDir = path12.join(workerDir, "migrations");
7916
7970
  if (fs11.existsSync(migrationsDir)) {
7917
7971
  const migResult = runSilent(`npx wrangler d1 migrations apply ${names.d1} --remote --config "${wranglerPath}"`);
7918
7972
  if (migResult.ok) {
@@ -7980,13 +8034,15 @@ BASE_URL = "${baseUrl}"
7980
8034
  console.log(`Operator profile saved: ${profileName}`);
7981
8035
  }
7982
8036
  console.log("");
7983
- console.log("Deployment complete.");
7984
- console.log(` API: ${baseUrl}/api`);
7985
- console.log(` Docs: ${baseUrl}/`);
8037
+ console.log("Infrastructure deployment complete.");
8038
+ console.log(` API: ${baseUrl}/api`);
8039
+ console.log(` Public site: ${baseUrl}/`);
7986
8040
  console.log("");
7987
- console.log("Next:");
8041
+ console.log("Next (operator):");
7988
8042
  console.log(` nrdocs rules add 'OWNER/*' --access password`);
7989
8043
  console.log(" nrdocs repos");
8044
+ console.log("");
8045
+ console.log("Repo owners publish content with GitHub Actions (nrdocs publish), not deploy.");
7990
8046
  }
7991
8047
 
7992
8048
  // src/commands/repos.ts
@@ -8879,12 +8935,13 @@ function parseAuthLogoutFlags(args2) {
8879
8935
 
8880
8936
  // src/bin.ts
8881
8937
  var args = process.argv.slice(2);
8938
+ var version = getCliVersion();
8882
8939
  if (args.includes("--version") || args.includes("-v")) {
8883
- console.log(`nrdocs ${NRDOCS_VERSION}`);
8940
+ console.log(`nrdocs ${version}`);
8884
8941
  process.exit(0);
8885
8942
  }
8886
8943
  if (args.includes("--help") || args.includes("-h") || args.length === 0) {
8887
- console.log(`nrdocs ${NRDOCS_VERSION}
8944
+ console.log(`nrdocs ${version}
8888
8945
 
8889
8946
  Usage:
8890
8947
  nrdocs <command> [options]