nrdocs 0.1.1 → 0.1.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.
Files changed (2) hide show
  1. package/dist/bin.mjs +39 -3
  2. package/package.json +1 -1
package/dist/bin.mjs CHANGED
@@ -694,6 +694,21 @@ function parseInitArgs(args2) {
694
694
  }
695
695
  return opts;
696
696
  }
697
+ function normalizeUrl(url) {
698
+ let normalized = url.trim();
699
+ if (!normalized.startsWith("http://") && !normalized.startsWith("https://")) {
700
+ normalized = `https://${normalized}`;
701
+ }
702
+ normalized = normalized.replace(/\/+$/, "");
703
+ try {
704
+ new URL(normalized);
705
+ } catch {
706
+ console.error(`Error: "${url}" is not a valid URL.`);
707
+ console.error("Expected format: https://docs.example.com");
708
+ process.exit(2);
709
+ }
710
+ return normalized;
711
+ }
697
712
  function readExistingConfig(configPath) {
698
713
  if (!fs2.existsSync(configPath)) return {};
699
714
  try {
@@ -751,6 +766,7 @@ async function handleInit(args2) {
751
766
  console.error(" nrdocs init --api-url https://your-docs-url.com");
752
767
  process.exit(2);
753
768
  }
769
+ apiUrl = normalizeUrl(apiUrl);
754
770
  const indexFile = path3.join(docsPath, "index.md");
755
771
  const workflowDir = path3.resolve(".github", "workflows");
756
772
  const workflowFile = path3.join(workflowDir, "nrdocs.yml");
@@ -6545,9 +6561,13 @@ async function handlePublish(args2) {
6545
6561
  console.log("Uploading to nrdocs...");
6546
6562
  const client = new ApiClient(apiUrl, token);
6547
6563
  const formData = new FormData();
6548
- formData.append("archive", new Blob([archive], { type: "application/gzip" }), "docs.tar.gz");
6549
- formData.append("owner", owner);
6550
- formData.append("repo", repo);
6564
+ formData.append("artifact", new Blob([archive], { type: "application/gzip" }), "docs.tar.gz");
6565
+ formData.append("metadata", JSON.stringify({
6566
+ schema_version: 1,
6567
+ site: { title: siteTitle, requested_access: "password" },
6568
+ artifact: { format: "tar.gz", size_bytes: archive.length },
6569
+ nrdocs: { cli_version: "0.1.1" }
6570
+ }));
6551
6571
  const result = await client.publish(formData);
6552
6572
  if (result.ok) {
6553
6573
  console.log("Published successfully!");
@@ -6699,6 +6719,21 @@ function checkCloudflareAuth() {
6699
6719
  const result = runSilent("npx wrangler whoami");
6700
6720
  return result.ok && !result.stdout.includes("Not authenticated");
6701
6721
  }
6722
+ function normalizeUrl2(url) {
6723
+ let normalized = url.trim();
6724
+ if (!normalized.startsWith("http://") && !normalized.startsWith("https://")) {
6725
+ normalized = `https://${normalized}`;
6726
+ }
6727
+ normalized = normalized.replace(/\/+$/, "");
6728
+ try {
6729
+ new URL(normalized);
6730
+ } catch {
6731
+ console.error(`Error: "${url}" is not a valid URL.`);
6732
+ console.error("Expected format: https://docs.example.com");
6733
+ process.exit(2);
6734
+ }
6735
+ return normalized;
6736
+ }
6702
6737
  function findWorkerDir() {
6703
6738
  const candidates = [
6704
6739
  path9.resolve("packages/worker"),
@@ -6761,6 +6796,7 @@ async function handleDeploy(args2) {
6761
6796
  instance = instance || await prompt3("Instance name", "default");
6762
6797
  baseUrl = baseUrl || await prompt3("Docs base URL", "https://docs.example.com");
6763
6798
  }
6799
+ baseUrl = normalizeUrl2(baseUrl);
6764
6800
  const validation = validateInstanceName(instance);
6765
6801
  if (!validation.valid) {
6766
6802
  console.error(`Error: ${validation.error}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nrdocs",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "CLI for nrdocs - serverless docs publishing for private GitHub repos",
5
5
  "type": "module",
6
6
  "bin": {