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.
- package/package.json +1 -1
- package/src/v1/cli.js +64 -40
package/package.json
CHANGED
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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}'
|
|
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
|
|