locadot 1.2.2 → 1.2.3

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/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,16 +1,12 @@
1
1
  {
2
2
  "name": "locadot",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
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",
7
7
  "bin": {
8
8
  "locadot": "./dist/index.js"
9
9
  },
10
- "scripts": {
11
- "dev": "tsx --watch src/index.ts",
12
- "build": "tsc"
13
- },
14
10
  "repository": {
15
11
  "type": "git",
16
12
  "url": "git+https://github.com/avinashid/locadot.git"
@@ -42,5 +38,9 @@
42
38
  "devDependencies": {
43
39
  "tsx": "^4.19.3",
44
40
  "typescript": "^5.8.3"
41
+ },
42
+ "scripts": {
43
+ "dev": "tsx --watch src/index.ts",
44
+ "build": "tsc"
45
45
  }
46
- }
46
+ }