locadot 1.1.1 → 1.2.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/dist/core.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const server_1 = __importDefault(require("./server"));
7
+ async function run() {
8
+ await server_1.default.startCentralProxy();
9
+ }
10
+ run();
package/dist/index.js CHANGED
@@ -4,68 +4,48 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.isValidLocalhostDomain = isValidLocalhostDomain;
8
- exports.isDomainRunning = isDomainRunning;
9
- const https_1 = __importDefault(require("https"));
10
7
  const yargs_1 = __importDefault(require("yargs"));
11
8
  const helpers_1 = require("yargs/helpers");
12
- const server_1 = require("./server");
13
- function isValidLocalhostDomain(domain) {
14
- const localhostPattern = /^(?:[a-zA-Z0-9-]+\.)*localhost$/;
15
- return localhostPattern.test(domain);
16
- }
17
- function isDomainRunning(domain, port = 443) {
18
- return new Promise((resolve) => {
19
- const req = https_1.default.request({
20
- hostname: "localhost", // we're always connecting to localhost
21
- port,
22
- method: "HEAD",
23
- rejectUnauthorized: false, // ignore self-signed certs
24
- timeout: 1000,
25
- headers: {
26
- Host: domain, // 👈 critical: ask the proxy "Do you know this host?"
27
- },
28
- }, (res) => {
29
- // Only return true if it returns a valid 2xx or 3xx status
30
- resolve(res.statusCode >= 200 && res.statusCode < 400);
31
- res.destroy();
32
- });
33
- req.on("error", () => resolve(false));
34
- req.on("timeout", () => {
35
- req.destroy();
36
- resolve(false);
37
- });
38
- req.end();
39
- });
40
- }
9
+ const commands_1 = __importDefault(require("./lib/commands"));
10
+ const constants_1 = require("./utils/constants");
41
11
  async function run() {
42
- const argv = await (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
43
- .option("host", {
44
- alias: "h",
45
- describe: "Domain to map (must point to 127.0.0.1 in hosts file)",
46
- demandOption: true,
47
- type: "string",
12
+ await (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
13
+ .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);
48
18
  })
49
- .option("port", {
50
- alias: "p",
51
- describe: "Local port to forward to",
52
- demandOption: true,
53
- type: "number",
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
+ .command("$0", "Run the proxy with a domain and port", (yargs) => {
32
+ return yargs
33
+ .option("host", {
34
+ alias: "h",
35
+ describe: "Domain to map (must point to 127.0.0.1 in hosts file)",
36
+ demandOption: true,
37
+ type: "string",
38
+ })
39
+ .option("port", {
40
+ alias: "p",
41
+ describe: "Local port to forward to",
42
+ demandOption: true,
43
+ type: "number",
44
+ })
45
+ .usage("Usage: npx locadot --host local.dev --port 3350");
46
+ }, async (argv) => {
47
+ await commands_1.default.start(argv);
54
48
  })
55
- .usage("Usage: npx locadot --host local.dev --port 3350")
56
49
  .help().argv;
57
- if (!isValidLocalhostDomain(argv.host)) {
58
- console.error("❌ Invalid domain. Please use a valid localhost domain like dev.localhost, localhost, test.localhost, etc.");
59
- process.exit(1);
60
- }
61
- const isRunning = await isDomainRunning(argv.host);
62
- if (isRunning) {
63
- console.error("❌ Domain already in use. Please choose another domain or stop the existing instance.");
64
- process.exit(1);
65
- }
66
- const domain = argv.host;
67
- const port = argv.port;
68
- await (0, server_1.startCentralProxy)();
69
- await (0, server_1.registerDomain)(domain, port);
70
50
  }
71
51
  run();
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const localhost_1 = __importDefault(require("./localhost"));
7
+ const constants_1 = require("../utils/constants");
8
+ const server_1 = __importDefault(require("../server"));
9
+ const locadot_file_1 = __importDefault(require("./locadot-file"));
10
+ class Commands {
11
+ static async start(argv) {
12
+ if (!localhost_1.default.isValidLocalhostDomain(argv.host)) {
13
+ console.error(constants_1.errorConstants.invalidHost);
14
+ process.exit(1);
15
+ }
16
+ if (await localhost_1.default.isLocalhostOpen(argv.host, argv.port)) {
17
+ console.error(constants_1.errorConstants.hostExist);
18
+ }
19
+ try {
20
+ await server_1.default.registerDomain(argv.host, argv.port);
21
+ }
22
+ catch (error) { }
23
+ }
24
+ static async stop() {
25
+ try {
26
+ await server_1.default.stopProxy();
27
+ }
28
+ catch (error) { }
29
+ }
30
+ static async restart() {
31
+ await server_1.default.restartProxy();
32
+ console.log("☑️ Proxy successfully restarted.");
33
+ }
34
+ static async getRegistry() {
35
+ try {
36
+ const registry = await locadot_file_1.default.getRegistry();
37
+ Object.entries(registry).forEach(([value, key]) => console.log(`Port: ${key} => ${value} \n`));
38
+ console.log(`☑️ Total: ${Object.keys(registry).length}.`);
39
+ }
40
+ catch (error) { }
41
+ }
42
+ static watchLogs() {
43
+ try {
44
+ console.log("☑️ Watching logs files.");
45
+ locadot_file_1.default.watchLogs();
46
+ }
47
+ catch (error) { }
48
+ }
49
+ static clearLogs() {
50
+ try {
51
+ locadot_file_1.default.clearLogs();
52
+ console.log("☑️ Logs successfully cleared.");
53
+ }
54
+ catch (error) { }
55
+ }
56
+ }
57
+ exports.default = Commands;
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const constants_1 = require("../utils/constants");
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const date_fns_1 = require("date-fns");
9
+ class locadotFile {
10
+ static async createLockFile(processId) {
11
+ fs_1.default.writeFileSync(constants_1.locadotPath.LOCK_FILE, processId);
12
+ }
13
+ static async getProcessId() {
14
+ try {
15
+ if (fs_1.default.existsSync(constants_1.locadotPath.LOCK_FILE)) {
16
+ const pid = parseInt(fs_1.default.readFileSync(constants_1.locadotPath.LOCK_FILE, "utf-8"));
17
+ return pid.toString();
18
+ }
19
+ }
20
+ catch (err) {
21
+ return;
22
+ }
23
+ }
24
+ static async deleteLockFile() {
25
+ fs_1.default.rmSync(constants_1.locadotPath.LOCK_FILE);
26
+ }
27
+ static async getRegistry() {
28
+ if (!fs_1.default.existsSync(constants_1.locadotPath.REGISTRY_FILE)) {
29
+ fs_1.default.writeFileSync(constants_1.locadotPath.REGISTRY_FILE, "{}");
30
+ }
31
+ return JSON.parse(fs_1.default.readFileSync(constants_1.locadotPath.REGISTRY_FILE, "utf-8"));
32
+ }
33
+ static async addRegistry(domain, port) {
34
+ const registry = await locadotFile.getRegistry();
35
+ registry[domain] = port;
36
+ fs_1.default.writeFileSync(constants_1.locadotPath.REGISTRY_FILE, JSON.stringify(registry, null, 2));
37
+ }
38
+ static async removeAllRegistry() {
39
+ fs_1.default.writeFileSync(constants_1.locadotPath.REGISTRY_FILE, "{}");
40
+ }
41
+ static async updateRegistry(domain, port) {
42
+ const registry = await locadotFile.getRegistry();
43
+ registry[domain] = port;
44
+ fs_1.default.writeFileSync(constants_1.locadotPath.REGISTRY_FILE, JSON.stringify(registry, null, 2));
45
+ }
46
+ static async deleteRegistry(domain) {
47
+ const registry = await locadotFile.getRegistry();
48
+ delete registry[domain];
49
+ fs_1.default.writeFileSync(constants_1.locadotPath.REGISTRY_FILE, JSON.stringify(registry, null, 2));
50
+ }
51
+ static async watchRegistry() {
52
+ return fs_1.default.watch(constants_1.locadotPath.REGISTRY_FILE, async (eventType) => {
53
+ if (eventType === "change") {
54
+ console.log("🔄 Updated domain mappings:", await locadotFile.getRegistry());
55
+ }
56
+ });
57
+ }
58
+ static async getLogs() {
59
+ if (!fs_1.default.existsSync(constants_1.locadotPath.LOGS)) {
60
+ fs_1.default.writeFileSync(constants_1.locadotPath.LOGS, "{}");
61
+ }
62
+ return JSON.parse(fs_1.default.readFileSync(constants_1.locadotPath.LOGS, "utf-8"));
63
+ }
64
+ static async updateLogs(message, status = "log", description) {
65
+ const logs = (await locadotFile.getLogs()).logs || [];
66
+ if (!Array.isArray(logs)) {
67
+ fs_1.default.writeFileSync(constants_1.locadotPath.LOGS, "{}");
68
+ }
69
+ logs.push({
70
+ message,
71
+ timestamp: Date.now(),
72
+ status: status,
73
+ description,
74
+ });
75
+ fs_1.default.writeFileSync(constants_1.locadotPath.LOGS, JSON.stringify({ logs: logs }));
76
+ }
77
+ static async clearLogs() {
78
+ fs_1.default.writeFileSync(constants_1.locadotPath.LOGS, "{}");
79
+ }
80
+ static async printLogs(log) {
81
+ console[log.status || "log"](`${(0, date_fns_1.format)(log.timestamp, "yyyy-MM-dd HH:mm:ss")}: ${log.message} ${log.description ? "==> " : ""}${log.description ? log.description : ""}\n`);
82
+ }
83
+ static async watchLogs() {
84
+ const logs = await locadotFile.getLogs();
85
+ let length = logs.logs?.length || 0;
86
+ logs.logs?.forEach((log) => this.printLogs(log));
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;
96
+ }
97
+ });
98
+ }
99
+ static async destroy(watcher) {
100
+ try {
101
+ const pid = await locadotFile.getProcessId();
102
+ locadotFile.deleteLockFile();
103
+ locadotFile.removeAllRegistry();
104
+ locadotFile.clearLogs();
105
+ watcher?.close();
106
+ if (pid) {
107
+ process.kill(parseInt(pid));
108
+ }
109
+ }
110
+ catch (error) { }
111
+ }
112
+ static async softDestroy(watcher) {
113
+ try {
114
+ const pid = await locadotFile.getProcessId();
115
+ locadotFile.deleteLockFile();
116
+ watcher?.close();
117
+ if (pid) {
118
+ process.kill(parseInt(pid));
119
+ }
120
+ }
121
+ catch (error) { }
122
+ }
123
+ }
124
+ exports.default = locadotFile;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const https_1 = __importDefault(require("https"));
7
+ class Localhost {
8
+ static async isLocalhostOpen(domain, port) {
9
+ return new Promise((resolve) => {
10
+ const req = https_1.default.request({
11
+ hostname: "localhost",
12
+ port,
13
+ method: "HEAD",
14
+ rejectUnauthorized: false,
15
+ timeout: 1000,
16
+ headers: {
17
+ Host: domain,
18
+ },
19
+ }, (res) => {
20
+ resolve(res.statusCode >= 200 && res.statusCode < 400);
21
+ res.destroy();
22
+ });
23
+ req.on("error", () => resolve(false));
24
+ req.on("timeout", () => {
25
+ req.destroy();
26
+ resolve(false);
27
+ });
28
+ req.end();
29
+ });
30
+ }
31
+ static isValidLocalhostDomain(domain) {
32
+ const localhostPattern = /^(?:[a-zA-Z0-9-]+\.)*localhost$/;
33
+ return localhostPattern.test(domain);
34
+ }
35
+ }
36
+ exports.default = Localhost;
package/dist/server.js CHANGED
@@ -3,118 +3,99 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.cleanUp = exports.REGISTRY_FILE = exports.LOCK_FILE = void 0;
7
- exports.startCentralProxy = startCentralProxy;
8
- exports.registerDomain = registerDomain;
9
- exports.isProxyAlreadyRunning = isProxyAlreadyRunning;
10
6
  const http_proxy_1 = __importDefault(require("http-proxy"));
11
7
  const certs_1 = require("./certs");
12
8
  const https_1 = __importDefault(require("https"));
13
9
  const http_1 = __importDefault(require("http"));
14
10
  const fs_1 = __importDefault(require("fs"));
15
11
  const utils_1 = require("./utils");
12
+ const constants_1 = require("./utils/constants");
13
+ const locadot_file_1 = __importDefault(require("./lib/locadot-file"));
14
+ const child_process_1 = require("child_process");
16
15
  const path_1 = __importDefault(require("path"));
17
- exports.LOCK_FILE = path_1.default.join(require("os").homedir(), ".locadot.lock");
18
- exports.REGISTRY_FILE = path_1.default.join(require("os").homedir(), ".locadot-registry.json");
19
- async function startCentralProxy() {
20
- if (await isProxyAlreadyRunning()) {
21
- console.log("🔌 Proxy is already running");
22
- return;
23
- }
24
- let domainMap = {};
25
- // Create lock file
26
- fs_1.default.writeFileSync(exports.LOCK_FILE, process.pid.toString());
27
- if (!fs_1.default.existsSync(exports.REGISTRY_FILE)) {
28
- fs_1.default.writeFileSync(exports.REGISTRY_FILE, "{}");
29
- }
30
- if (fs_1.default.existsSync(exports.REGISTRY_FILE)) {
31
- domainMap = JSON.parse(fs_1.default.readFileSync(exports.REGISTRY_FILE, "utf-8"));
32
- }
33
- const proxy = http_proxy_1.default.createProxyServer({});
34
- const defaultCert = await (0, certs_1.createSSL)("localhost");
35
- const watcher = fs_1.default.watch(exports.REGISTRY_FILE, (eventType) => {
36
- if (eventType === "change") {
37
- domainMap = JSON.parse(fs_1.default.readFileSync(exports.REGISTRY_FILE, "utf-8"));
38
- console.log("🔄 Updated domain mappings:", domainMap);
39
- }
40
- });
41
- process.on("SIGINT", cleanupFn);
42
- process.on("SIGTERM", cleanupFn);
43
- function cleanupFn() {
44
- watcher.close();
45
- (0, exports.cleanUp)();
46
- process.exit();
16
+ class ProxyHandler {
17
+ async startCentralProxy() {
18
+ let domainMap = await locadot_file_1.default.getRegistry();
19
+ const proxy = http_proxy_1.default.createProxyServer({});
20
+ const defaultCert = await (0, certs_1.createSSL)("localhost");
21
+ const watcher = await locadot_file_1.default.watchRegistry();
22
+ process.on("SIGINT", async () => await locadot_file_1.default.destroy(watcher));
23
+ process.on("SIGTERM", async () => await locadot_file_1.default.destroy(watcher));
24
+ const requestHandler = (req, res) => {
25
+ const host = req.headers.host?.split(":")[0];
26
+ const targetPort = domainMap[host];
27
+ if (!targetPort) {
28
+ res.writeHead(502, { "Content-Type": "text/html" });
29
+ res.end((0, utils_1.proxyNotFound)(host));
30
+ locadot_file_1.default.updateLogs(host || "", "warn", "Proxy not exist.");
31
+ }
32
+ proxy.web(req, res, { target: `http://localhost:${targetPort}` }, (err) => {
33
+ console.error("Proxy error:", err);
34
+ locadot_file_1.default.updateLogs(host || "", "warn", "Host not found.");
35
+ res.writeHead(502);
36
+ res.end("Connection failed. Host not found.");
37
+ });
38
+ };
39
+ const httpsServer = https_1.default.createServer(defaultCert, requestHandler);
40
+ const httpServer = http_1.default.createServer(requestHandler);
41
+ httpsServer.listen(443, () => {
42
+ locadot_file_1.default.updateLogs("🛜 HTTPS proxy running on port 443");
43
+ });
44
+ httpServer.listen(80, () => {
45
+ locadot_file_1.default.updateLogs("🛜 HTTP proxy running on port 80");
46
+ });
47
47
  }
48
- const requestHandler = (req, res) => {
49
- const host = req.headers.host?.split(":")[0];
50
- const targetPort = domainMap[host];
51
- if (!targetPort) {
52
- res.writeHead(502, { "Content-Type": "text/html" });
53
- res.end((0, utils_1.proxyNotFound)(host));
48
+ async startProxy() {
49
+ if (await locadot_file_1.default.getProcessId()) {
50
+ console.error("Proxy is already running");
54
51
  return;
55
52
  }
56
- proxy.web(req, res, { target: `http://localhost:${targetPort}` }, (err) => {
57
- console.error("Proxy error:", err);
58
- res.writeHead(502);
59
- res.end("Connection failed. Host not found.");
53
+ const proxyProcess = (0, child_process_1.spawn)("node", [
54
+ path_1.default.join(__dirname, process.env.NODE_ENV === "production" ? "core.js" : "../dist/core.js"),
55
+ ], {
56
+ detached: true,
57
+ stdio: "ignore",
60
58
  });
61
- };
62
- const httpsServer = https_1.default.createServer(defaultCert, requestHandler);
63
- const httpServer = http_1.default.createServer(requestHandler);
64
- httpsServer.listen(443, () => {
65
- console.log("🌐 HTTPS proxy running on port 443");
66
- });
67
- httpServer.listen(80, () => {
68
- console.log("🌐 HTTP proxy running on port 80");
69
- });
70
- }
71
- async function registerDomain(domain, port) {
72
- if (!(await isProxyAlreadyRunning())) {
73
- console.error('❌ Proxy is not running. Start it first with "locadot start"');
74
- process.exit(1);
75
- }
76
- let registry = {};
77
- if (!fs_1.default.existsSync(exports.REGISTRY_FILE)) {
78
- fs_1.default.writeFileSync(exports.REGISTRY_FILE, "{}");
79
- }
80
- if (fs_1.default.existsSync(exports.REGISTRY_FILE)) {
81
- registry = JSON.parse(fs_1.default.readFileSync(exports.REGISTRY_FILE, "utf-8"));
82
- }
83
- if (registry[domain]) {
84
- console.error(`❌ ${domain} already mapped to port ${registry[domain]}`);
85
- process.exit(1);
59
+ proxyProcess.on("error", (err) => {
60
+ console.error("Failed to start child process:", err);
61
+ });
62
+ if (!proxyProcess.pid) {
63
+ console.error("❌ Central proxy failed to start");
64
+ process.exit(1);
65
+ }
66
+ else {
67
+ locadot_file_1.default.createLockFile(proxyProcess.pid?.toString());
68
+ }
69
+ proxyProcess.unref();
70
+ console.log("🚀 Central proxy started in background.");
86
71
  }
87
- registry[domain] = port;
88
- fs_1.default.writeFileSync(exports.REGISTRY_FILE, JSON.stringify(registry, null, 2));
89
- console.log(`✅ ${domain} => http://localhost:${port}`);
90
- }
91
- async function isProxyAlreadyRunning() {
92
- try {
93
- if (fs_1.default.existsSync(exports.LOCK_FILE)) {
94
- const pid = parseInt(fs_1.default.readFileSync(exports.LOCK_FILE, "utf-8"));
95
- try {
96
- process.kill(pid, 0); // Check if process exists
97
- return true;
98
- }
99
- catch {
100
- // PID doesn't exist, remove stale lock file
101
- (0, exports.cleanUp)();
102
- return false;
103
- }
72
+ async registerDomain(domain, port) {
73
+ if (!(await locadot_file_1.default.getProcessId())) {
74
+ await this.startProxy();
75
+ }
76
+ let registry = await locadot_file_1.default.getRegistry();
77
+ console.log(registry);
78
+ if (!fs_1.default.existsSync(constants_1.locadotPath.REGISTRY_FILE)) {
79
+ fs_1.default.writeFileSync(constants_1.locadotPath.REGISTRY_FILE, "{}");
104
80
  }
105
- (0, exports.cleanUp)();
106
- return false;
81
+ if (fs_1.default.existsSync(constants_1.locadotPath.REGISTRY_FILE)) {
82
+ registry = JSON.parse(fs_1.default.readFileSync(constants_1.locadotPath.REGISTRY_FILE, "utf-8"));
83
+ }
84
+ if (registry[domain]) {
85
+ console.error(`❌ ${domain} already mapped to port ${registry[domain]}`);
86
+ process.exit(1);
87
+ }
88
+ registry[domain] = port;
89
+ fs_1.default.writeFileSync(constants_1.locadotPath.REGISTRY_FILE, JSON.stringify(registry, null, 2));
90
+ console.log(`✅ ${domain} => http://localhost:${port}`);
107
91
  }
108
- catch (err) {
109
- (0, exports.cleanUp)();
110
- return false;
92
+ async stopProxy() {
93
+ await locadot_file_1.default.destroy();
111
94
  }
112
- }
113
- const cleanUp = () => {
114
- try {
115
- fs_1.default.unlinkSync(exports.LOCK_FILE);
116
- fs_1.default.rmSync(exports.REGISTRY_FILE);
95
+ async restartProxy() {
96
+ await locadot_file_1.default.softDestroy();
97
+ await this.startProxy();
117
98
  }
118
- catch (error) { }
119
- };
120
- exports.cleanUp = cleanUp;
99
+ }
100
+ const locadotProxy = new ProxyHandler();
101
+ exports.default = locadotProxy;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.errorConstants = exports.locadotPath = void 0;
7
+ const appdata_path_1 = __importDefault(require("appdata-path"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const PACKAGE_PATH = (0, appdata_path_1.default)("locadot");
10
+ const LOCK_FILE = path_1.default.join(PACKAGE_PATH, ".locadot.lock");
11
+ const REGISTRY_FILE = path_1.default.join(PACKAGE_PATH, ".locadot-registry.json");
12
+ const LOGS = path_1.default.join(PACKAGE_PATH, ".locadot.log");
13
+ exports.locadotPath = {
14
+ LOCK_FILE,
15
+ REGISTRY_FILE,
16
+ LOGS,
17
+ };
18
+ exports.errorConstants = {
19
+ invalidHost: "❌ Invalid domain. Please use a valid localhost domain like dev.localhost, localhost, test.localhost, etc.",
20
+ hostExist: "❌ Domain already in use. Please choose another domain or stop the existing instance.",
21
+ proxyClose: "☑️ Successfully stopped all locadot instances.",
22
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "locadot",
3
- "version": "1.1.1",
3
+ "version": "1.2.2",
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",
@@ -32,6 +32,7 @@
32
32
  "@types/http-proxy": "^1.17.16",
33
33
  "@types/yargs": "^17.0.33",
34
34
  "appdata-path": "^1.0.0",
35
+ "date-fns": "^4.1.0",
35
36
  "detect-port": "^2.1.0",
36
37
  "http-proxy": "^1.18.1",
37
38
  "https": "^1.0.0",