caddy-subdomain 1.1.1 → 1.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/package.json +1 -1
  2. package/src/v1/cli.js +64 -40
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "caddy-subdomain",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Atomic CLI and library to inspect, validate, and programmatically add subdomains to Caddy JSON configurations",
5
5
  "license": "ISC",
6
6
  "author": "KeshavSoft",
package/src/v1/cli.js CHANGED
@@ -9,6 +9,8 @@ import {
9
9
  addProbeSubdomainToFile
10
10
  } from "./index.js";
11
11
 
12
+ const VERSION = "1.1.2";
13
+
12
14
  /**
13
15
  * Automatically discovers the Caddy configuration file:
14
16
  * 1. Explicit path if provided
@@ -34,51 +36,58 @@ export function resolveDefaultPath(customPath) {
34
36
  return vps;
35
37
  }
36
38
 
37
- export function printHelp() {
39
+ export function printHelp(isMissing = false) {
40
+ const header = isMissing
41
+ ? "⚠️ No command provided! Here is how to use caddy-subdomain:"
42
+ : "caddy-subdomain — Zero-Config Subdomain Engine for Caddy Server";
43
+
38
44
  console.log(`
39
- caddy-subdomain (v1.0.0)
40
- The Zero-Config Subdomain Engine for Caddy Server.
41
-
42
- Zero configuration required:
43
- - Caddy config location (/etc/caddy/caddy.json) is detected automatically.
44
- - Caddy hot-reload is executed automatically.
45
- - Instant Yes/No verification for domain presence and live HTTPS traffic.
46
-
47
- Usage:
48
- npx caddy-subdomain probe <domain>
49
- npx caddy-subdomain add <domain> <port>
50
- npx caddy-subdomain check <domain>
51
- npx caddy-subdomain list
52
-
53
- Commands:
54
- probe <domain> Add Level-1 smoke probe (zero ports), auto-reload & test live HTTPS
55
- add <domain> <port> Connect subdomain to backend port & auto-reload with zero downtime
56
- check <domain> Check if subdomain is already registered in Caddy (Yes / No)
57
- list List all configured subdomains
58
-
59
- Options:
60
- --no-reload Skip automatic 'caddy reload'
61
- --no-backup Skip automatic timestamped backup file creation
62
- --force Force overwrite of an existing route
63
- -h, --help Show help message
64
- -v, --version Show version number
65
-
66
- Examples:
67
- npx caddy-subdomain probe call.keshavsoft.com
68
- npx caddy-subdomain add call.keshavsoft.com 5000
69
- npx caddy-subdomain check call.keshavsoft.com
70
- npx caddy-subdomain list
45
+ ============================================================
46
+ ${header}
47
+ ============================================================
48
+
49
+ Here are the 2 primary commands you need:
50
+
51
+ 1️⃣ LEVEL 1: SMOKE TEST (Verify DNS & SSL with ZERO ports/processes)
52
+ Required Input : <domain>
53
+ Sample Command : npx caddy-subdomain probe call.keshavsoft.com
54
+ What it does : Injects a 200 OK test route, automatically reloads
55
+ Caddy, and verifies live HTTPS & SSL certificate.
56
+
57
+ 2️⃣ LEVEL 2: BACKEND PROMOTION (Connect to your Node.js / Docker app)
58
+ Required Inputs : <domain> <port>
59
+ Sample Command : npx caddy-subdomain add call.keshavsoft.com 5000
60
+ What it does : Upgrades the probe to a reverse proxy on port 5000
61
+ with zero downtime and automatic backup.
62
+
63
+ ------------------------------------------------------------
64
+ UTILITY COMMANDS:
65
+ • Check existence : npx caddy-subdomain check call.keshavsoft.com
66
+ • List subdomains : npx caddy-subdomain list
67
+
68
+ OPTIONS:
69
+ --no-reload Skip automatic Caddy reload
70
+ --no-backup Skip timestamped backup file creation
71
+ --force Force overwrite of existing route
72
+ -h, --help Show this guide
73
+ -v, --version Show version (${VERSION})
74
+ ============================================================
71
75
  `);
72
76
  }
73
77
 
74
78
  export async function run(args = process.argv.slice(2)) {
75
- if (args.length === 0 || args.includes("-h") || args.includes("--help")) {
76
- printHelp();
79
+ if (args.length === 0) {
80
+ printHelp(true);
81
+ return;
82
+ }
83
+
84
+ if (args.includes("-h") || args.includes("--help")) {
85
+ printHelp(false);
77
86
  return;
78
87
  }
79
88
 
80
89
  if (args.includes("-v") || args.includes("--version")) {
81
- console.log("1.0.0");
90
+ console.log(VERSION);
82
91
  return;
83
92
  }
84
93
 
@@ -90,7 +99,12 @@ export async function run(args = process.argv.slice(2)) {
90
99
  if (command === "probe") {
91
100
  const domain = args[1];
92
101
  if (!domain || domain.startsWith("-")) {
93
- console.error("Error: 'probe' requires a domain.\n Usage: npx caddy-subdomain probe <domain>\n Example: npx caddy-subdomain probe call.keshavsoft.com");
102
+ console.error(`
103
+ ❌ Error: 'probe' requires 1 input: <domain>
104
+
105
+ Sample:
106
+ npx caddy-subdomain probe call.keshavsoft.com
107
+ `);
94
108
  process.exitCode = 1;
95
109
  return;
96
110
  }
@@ -154,7 +168,12 @@ export async function run(args = process.argv.slice(2)) {
154
168
  if (command === "check") {
155
169
  const domain = args[1];
156
170
  if (!domain || domain.startsWith("-")) {
157
- console.error("Error: 'check' requires a domain.\n Usage: npx caddy-subdomain check <domain>\n Example: npx caddy-subdomain check call.keshavsoft.com");
171
+ console.error(`
172
+ ❌ Error: 'check' requires 1 input: <domain>
173
+
174
+ Sample:
175
+ npx caddy-subdomain check call.keshavsoft.com
176
+ `);
158
177
  process.exitCode = 1;
159
178
  return;
160
179
  }
@@ -185,7 +204,12 @@ export async function run(args = process.argv.slice(2)) {
185
204
  const port = args[2];
186
205
 
187
206
  if (!domain || !port || domain.startsWith("-") || port.startsWith("-")) {
188
- console.error("Error: 'add' requires both <domain> and <port>.\n Usage: npx caddy-subdomain add <domain> <port>\n Example: npx caddy-subdomain add call.keshavsoft.com 5000");
207
+ console.error(`
208
+ ❌ Error: 'add' requires 2 inputs: <domain> <port>
209
+
210
+ Sample:
211
+ npx caddy-subdomain add call.keshavsoft.com 5000
212
+ `);
189
213
  process.exitCode = 1;
190
214
  return;
191
215
  }
@@ -248,7 +272,7 @@ export async function run(args = process.argv.slice(2)) {
248
272
  return;
249
273
  }
250
274
 
251
- console.error(`Unknown command: '${command}'. Run 'npx caddy-subdomain --help' for usage.`);
275
+ console.error(`Unknown command: '${command}'.\nRun 'npx caddy-subdomain' without arguments to see available commands.`);
252
276
  process.exitCode = 1;
253
277
  }
254
278