locadot
Version:
Secure your local development environment with HTTPS and custom domains like dev.localhost.
136 lines (135 loc) • 4.09 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const commander_1 = require("commander");
const commands_1 = __importDefault(require("./lib/commands"));
const logger_1 = __importDefault(require("./utils/logger"));
const package_json_1 = require("../package.json");
const constants_1 = __importDefault(require("./constants"));
const program = new commander_1.Command();
program
.name("locadot")
.description("Locadot CLI - Local domain proxy manager")
.version(package_json_1.version);
program
.command("add")
.description("Add a new localhost domain and port")
.requiredOption("-h, --host <host>", "Domain to map must be ends with localhost. Example: dev.localhost, localhost, test.localhost, etc.")
.requiredOption("-p, --port <port>", "Local port to forward to")
.action(async (options) => {
await commands_1.default.add(options);
process.exit(0);
});
program
.command("update")
.requiredOption("-h, --host <host>", "Domain to map must be ends with localhost. Example: dev.localhost, localhost, test.localhost, etc.")
.requiredOption("-p, --port <port>", "Local port to forward to")
.description("Update a domain")
.action(async (options) => {
await commands_1.default.update(options);
process.exit(0);
});
program
.command("remove")
.requiredOption("-h, --host <host>", "Host must ends with localhost. Example: dev.localhost, localhost, test.localhost, etc.")
.description("Remove a domain")
.action(async (options) => {
await commands_1.default.remove(options);
process.exit(0);
});
program
.command("host")
.description("Show all hosts")
.action(async () => {
await commands_1.default.getRegistry();
process.exit(0);
});
program
.command("watch:logs")
.description("Watch log files")
.action(() => {
commands_1.default.watchLogs();
});
program
.command("clear:logs")
.description("Clear logs")
.action(async () => {
await commands_1.default.clearLogs();
process.exit(0);
});
program
.command("clear:hosts")
.description("Clear all host file.")
.action(async () => {
await commands_1.default.clearHosts();
process.exit(0);
});
program
.command("path")
.description("Show configuration paths.")
.action(() => {
commands_1.default.configPath();
process.exit(0);
});
program
.command("path:logs")
.description("Show logs path file.")
.action(() => {
commands_1.default.logPath();
process.exit(0);
});
program
.command("path:hosts")
.description("Show hosts path file.")
.action(async () => {
await commands_1.default.hostPath();
process.exit(0);
});
program
.command("startup:enable")
.description("Enable locadot on reboot.")
.action(async () => {
await commands_1.default.enableStartup();
process.exit(0);
});
program
.command("startup:disable")
.description("Disable locadot on reboot.")
.action(async () => {
await commands_1.default.disableStartup();
process.exit(0);
});
program
.command("startup:status")
.description("Check locadot status on reboot.")
.action(async () => {
await commands_1.default.statusStartup();
process.exit(0);
});
program
.command("restart")
.description("Restart locadot")
.action(async () => {
await commands_1.default.restart();
process.exit(0);
});
program
.command("stop")
.description("Stop central proxy and logs")
.action(async () => {
await commands_1.default.stop();
logger_1.default.info(constants_1.default.proxyInfo.softClose);
process.exit(0);
});
program
.command("kill")
.description("Stop proxy, clear logs, and hosts file.")
.action(async () => {
await commands_1.default.kill();
logger_1.default.info(constants_1.default.proxyInfo.softClose);
process.exit(0);
});
program.parse(process.argv);