locadot 1.2.2 β†’ 1.2.4

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/README.md CHANGED
@@ -1,20 +1,76 @@
1
- # πŸ” locadot
2
-
3
- Secure your local development environment with **HTTPS** and **custom domains** like `https://dev.localhost`, powered by `mkcert`.
4
-
5
- ---
1
+ # locadot πŸ”
6
2
 
7
3
  ## ✨ Features
8
4
 
9
- - βœ… Automatically generates **trusted local SSL certificates**
10
- - πŸ” Reverse proxies `https://your.custom.domain` β†’ `app.localhost`
11
- - πŸ–₯️ Works on **Windows**, **macOS**, and **Linux**
5
+ - βœ… Automatically generates trusted local SSL certificates
6
+ - πŸ” Reverse proxies `https://your.custom.domain` β†’ `localhost:your-port`
7
+ - πŸ–₯️ Works on Windows, macOS, and Linux
12
8
  - πŸ› οΈ OS-specific guidance for host setup
13
9
  - ⚠️ Warns and exits if domain isn’t correctly mapped to a local IP
10
+ - ❌ Only supports proxying to localhost ports – external IPs are not allowed for security
14
11
 
15
12
  ---
16
13
 
17
14
  ## πŸš€ Usage
18
15
 
19
16
  ```bash
20
- npx locadot --host dev.localhost --port 3350
17
+ npx locadot --host dev.localhost --port 3350
18
+ ```
19
+
20
+ ---
21
+
22
+ ## πŸ“¦ Commands
23
+
24
+ ##### ▢️ Default (Run Proxy)
25
+ ###### Starts a reverse proxy to the specified localhost port.
26
+
27
+ ```bash
28
+ npx locadot --host <custom.localhost> --port <localhost-port>
29
+ ```
30
+
31
+ ##### 🧾 View Registered Hosts
32
+ ###### Displays all domains currently registered with locadot.
33
+
34
+
35
+ ```bash
36
+ npx locadot host
37
+ ```
38
+ ##### πŸ“Ί Watch Logs
39
+ ###### Continuously watches and outputs proxy logs in real time.
40
+
41
+
42
+ ```bash
43
+ npx locadot log
44
+ ```
45
+
46
+ ##### 🧹 Clear Logs
47
+ ###### Clears all saved logs.
48
+
49
+
50
+ ```bash
51
+ npx locadot clear logs
52
+ ```
53
+
54
+ ##### πŸ”„ Restart Proxy
55
+ ###### Restarts the proxy server and reloads configuration.
56
+
57
+ ```bash
58
+ npx locadot restart
59
+ ```
60
+
61
+ ##### πŸ›‘ Stop All
62
+ ###### Stops all running locadot hosts and shuts down the proxy server.
63
+
64
+
65
+ ```bash
66
+ npx locadot stop
67
+ ```
68
+ ---
69
+
70
+
71
+ ### πŸ™Œ Contributing:
72
+
73
+ Pull requests are welcome! Feel free to open issues for bugs or feature requests. Contributions help improve locadot for everyone, so don't hesitate to get involved.
74
+
75
+ ---
76
+ ##### Made with ❀️ to make secure local development simple.
package/dist/index.js CHANGED
@@ -10,24 +10,8 @@ const commands_1 = __importDefault(require("./lib/commands"));
10
10
  const constants_1 = require("./utils/constants");
11
11
  async function run() {
12
12
  await (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
13
+ .scriptName("locadot")
13
14
  .usage("Usage: npx locadot --host local.dev --port 3350")
14
- .command("stop", "Stop all kill all locadot hosts", () => { }, async (argv) => {
15
- await commands_1.default.stop();
16
- console.log(constants_1.errorConstants.proxyClose);
17
- process.exit(0);
18
- })
19
- .command("logs", "Watch logs", () => { }, async (argv) => {
20
- commands_1.default.watchLogs();
21
- })
22
- .command("clear logs", "Clear logs", () => { }, async (argv) => {
23
- commands_1.default.clearLogs();
24
- })
25
- .command("restart", "Restart locadot", () => { }, async (argv) => {
26
- commands_1.default.restart();
27
- })
28
- .command("hosts", "Show all hosts.", () => {
29
- commands_1.default.getRegistry();
30
- })
31
15
  .command("$0", "Run the proxy with a domain and port", (yargs) => {
32
16
  return yargs
33
17
  .option("host", {
@@ -41,10 +25,26 @@ async function run() {
41
25
  describe: "Local port to forward to",
42
26
  demandOption: true,
43
27
  type: "number",
44
- })
45
- .usage("Usage: npx locadot --host local.dev --port 3350");
28
+ });
46
29
  }, async (argv) => {
47
30
  await commands_1.default.start(argv);
31
+ })
32
+ .command("host", "Show all hosts.", () => {
33
+ commands_1.default.getRegistry();
34
+ })
35
+ .command("log", "Watch logs", () => { }, async (argv) => {
36
+ commands_1.default.watchLogs();
37
+ })
38
+ .command("clear logs", "Clear logs", () => { }, async (argv) => {
39
+ commands_1.default.clearLogs();
40
+ })
41
+ .command("restart", "Restart locadot", () => { }, async (argv) => {
42
+ commands_1.default.restart();
43
+ })
44
+ .command("stop", "Stop all kill all locadot hosts", () => { }, async (argv) => {
45
+ await commands_1.default.stop();
46
+ console.log(constants_1.errorConstants.proxyClose);
47
+ process.exit(0);
48
48
  })
49
49
  .help().argv;
50
50
  }
@@ -51,7 +51,7 @@ class locadotFile {
51
51
  static async watchRegistry() {
52
52
  return fs_1.default.watch(constants_1.locadotPath.REGISTRY_FILE, async (eventType) => {
53
53
  if (eventType === "change") {
54
- console.log("πŸ”„ Updated domain mappings:", await locadotFile.getRegistry());
54
+ this.updateLogs("πŸ”„ Updated domain mappings.");
55
55
  }
56
56
  });
57
57
  }
@@ -85,15 +85,18 @@ class locadotFile {
85
85
  let length = logs.logs?.length || 0;
86
86
  logs.logs?.forEach((log) => this.printLogs(log));
87
87
  fs_1.default.watch(constants_1.locadotPath.LOGS, async (eventType) => {
88
- if (eventType === "change") {
89
- const newLog = await locadotFile.getLogs();
90
- newLog.logs?.forEach((log, i) => {
91
- if (i > length - 2) {
92
- this.printLogs(log);
93
- }
94
- });
95
- length = newLog.logs?.length || 0;
88
+ try {
89
+ if (eventType === "change") {
90
+ const newLog = await locadotFile.getLogs();
91
+ newLog.logs?.forEach((log, i) => {
92
+ if (i > length - 1) {
93
+ this.printLogs(log);
94
+ }
95
+ });
96
+ length = newLog.logs?.length || 0;
97
+ }
96
98
  }
99
+ catch (error) { }
97
100
  });
98
101
  }
99
102
  static async destroy(watcher) {
package/dist/server.js CHANGED
@@ -30,7 +30,6 @@ class ProxyHandler {
30
30
  locadot_file_1.default.updateLogs(host || "", "warn", "Proxy not exist.");
31
31
  }
32
32
  proxy.web(req, res, { target: `http://localhost:${targetPort}` }, (err) => {
33
- console.error("Proxy error:", err);
34
33
  locadot_file_1.default.updateLogs(host || "", "warn", "Host not found.");
35
34
  res.writeHead(502);
36
35
  res.end("Connection failed. Host not found.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "locadot",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "Secure your local development environment with HTTPS and custom domains like dev.localhost.",
5
5
  "homepage": "https://www.npmjs.com/package/locadot",
6
6
  "main": "dist/index.js",