nrdocs 0.2.1 → 0.2.2

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
@@ -7756,23 +7756,52 @@ function normalizeUrl2(url) {
7756
7756
  }
7757
7757
  return normalized;
7758
7758
  }
7759
+ function packagedWorkerDir() {
7760
+ const cliEntry = process.argv[1];
7761
+ if (!cliEntry) return null;
7762
+ const distDir = path11.dirname(path11.resolve(cliEntry));
7763
+ const dir = path11.join(distDir, "deploy-worker");
7764
+ if (fs11.existsSync(path11.join(dir, "index.js"))) return dir;
7765
+ return null;
7766
+ }
7759
7767
  function findWorkerDir() {
7760
- const candidates = [
7768
+ const packaged = packagedWorkerDir();
7769
+ if (packaged) return packaged;
7770
+ const monorepoCandidates = [
7761
7771
  path11.resolve("packages/worker"),
7762
7772
  path11.resolve("../worker")
7763
7773
  ];
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) {
7774
+ if (process.argv[1]) {
7775
+ const cliDir = path11.dirname(path11.resolve(process.argv[1]));
7776
+ monorepoCandidates.push(path11.resolve(cliDir, "../../../worker"));
7777
+ monorepoCandidates.push(path11.resolve(cliDir, "../../../../packages/worker"));
7778
+ }
7779
+ for (const candidate of monorepoCandidates) {
7768
7780
  if (fs11.existsSync(path11.join(candidate, "src", "index.ts"))) {
7769
7781
  return candidate;
7770
7782
  }
7771
7783
  }
7772
7784
  return null;
7773
7785
  }
7786
+ function isDocsContentRepo(cwd) {
7787
+ return fs11.existsSync(path11.join(cwd, "docs", "nrdocs.yml")) && !fs11.existsSync(path11.join(cwd, "packages", "worker", "src", "index.ts"));
7788
+ }
7789
+ function workerUsesBundledEntry(workerDir) {
7790
+ return fs11.existsSync(path11.join(workerDir, "index.js"));
7791
+ }
7774
7792
  async function handleDeploy(args2) {
7775
7793
  const opts = parseDeployArgs(args2);
7794
+ console.log("nrdocs deploy \u2014 Cloudflare infrastructure (Worker, D1, R2)");
7795
+ console.log("This does not publish markdown from the current repo.");
7796
+ console.log("Repo owners publish docs via GitHub Actions: nrdocs publish");
7797
+ console.log("");
7798
+ if (isDocsContentRepo(process.cwd())) {
7799
+ console.warn(
7800
+ "Note: This directory looks like a documentation repository (docs/nrdocs.yml)."
7801
+ );
7802
+ console.warn("You are deploying the nrdocs hosting stack, not site content here.");
7803
+ console.log("");
7804
+ }
7776
7805
  if (!checkWrangler()) {
7777
7806
  console.error("Error: Wrangler is not available.");
7778
7807
  console.error("Install it: npm install -g wrangler");
@@ -7816,7 +7845,10 @@ async function handleDeploy(args2) {
7816
7845
  }
7817
7846
  } else {
7818
7847
  instance = instance || await prompt3("Instance name", "default");
7819
- baseUrl = baseUrl || await prompt3("Docs base URL", "https://docs.example.com");
7848
+ baseUrl = baseUrl || await prompt3(
7849
+ "Public site URL (readers visit this host)",
7850
+ "https://docs.example.com"
7851
+ );
7820
7852
  }
7821
7853
  baseUrl = normalizeUrl2(baseUrl);
7822
7854
  const validation = validateInstanceName(instance);
@@ -7856,10 +7888,11 @@ async function handleDeploy(args2) {
7856
7888
  }
7857
7889
  const workerDir = findWorkerDir();
7858
7890
  if (!workerDir) {
7859
- console.error("Error: Cannot find packages/worker directory.");
7860
- console.error("Run nrdocs deploy from the nrdocs project root.");
7891
+ console.error("Error: Cannot find the nrdocs Worker bundle.");
7892
+ console.error("Reinstall the CLI (npm install -g nrdocs) or run from the nrdocs monorepo.");
7861
7893
  process.exit(4);
7862
7894
  }
7895
+ const workerMain = workerUsesBundledEntry(workerDir) ? "index.js" : "src/index.ts";
7863
7896
  console.log(`Creating R2 bucket ${names.r2}...`);
7864
7897
  const r2Check = runSilent("npx wrangler r2 bucket list");
7865
7898
  if (r2Check.ok && r2Check.stdout.includes(names.r2)) {
@@ -7893,7 +7926,7 @@ async function handleDeploy(args2) {
7893
7926
  }
7894
7927
  }
7895
7928
  const wranglerToml = `name = "${names.worker}"
7896
- main = "src/index.ts"
7929
+ main = "${workerMain}"
7897
7930
  compatibility_date = "2026-05-07"
7898
7931
 
7899
7932
  [[d1_databases]]
@@ -7980,13 +8013,15 @@ BASE_URL = "${baseUrl}"
7980
8013
  console.log(`Operator profile saved: ${profileName}`);
7981
8014
  }
7982
8015
  console.log("");
7983
- console.log("Deployment complete.");
7984
- console.log(` API: ${baseUrl}/api`);
7985
- console.log(` Docs: ${baseUrl}/`);
8016
+ console.log("Infrastructure deployment complete.");
8017
+ console.log(` API: ${baseUrl}/api`);
8018
+ console.log(` Public site: ${baseUrl}/`);
7986
8019
  console.log("");
7987
- console.log("Next:");
8020
+ console.log("Next (operator):");
7988
8021
  console.log(` nrdocs rules add 'OWNER/*' --access password`);
7989
8022
  console.log(" nrdocs repos");
8023
+ console.log("");
8024
+ console.log("Repo owners publish content with GitHub Actions (nrdocs publish), not deploy.");
7990
8025
  }
7991
8026
 
7992
8027
  // src/commands/repos.ts