@patiom/daemon 0.0.3 → 0.0.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.
Files changed (2) hide show
  1. package/dist/index.js +12 -85
  2. package/package.json +1 -2
package/dist/index.js CHANGED
@@ -14,9 +14,8 @@ import "adm-zip";
14
14
  import getPort, { portNumbers } from "get-port";
15
15
  import { parse, stringify } from "smol-toml";
16
16
  import dotenv from "dotenv";
17
- import { confirm, input } from "@inquirer/prompts";
18
17
  //#region package.json
19
- var version = "0.0.3";
18
+ var version = "0.0.4";
20
19
  //#endregion
21
20
  //#region src/config.ts
22
21
  const PATIOM_ROOT = "/var/lib/patiom";
@@ -897,81 +896,6 @@ const detectIP = async () => {
897
896
  return "unknown";
898
897
  }
899
898
  };
900
- const configureFirewall = async (os, port) => {
901
- if (!await confirm({
902
- message: "Configure firewall?",
903
- default: true
904
- })) {
905
- consola.info("Skipping firewall configuration");
906
- return;
907
- }
908
- if (os === "ubuntu" || os === "debian") {
909
- consola.start("Configuring UFW...");
910
- await execa("ufw", [
911
- "default",
912
- "deny",
913
- "incoming"
914
- ]);
915
- await execa("ufw", [
916
- "default",
917
- "allow",
918
- "outgoing"
919
- ]);
920
- await execa("ufw", ["allow", "22/tcp"]);
921
- await execa("ufw", ["allow", "80/tcp"]);
922
- await execa("ufw", ["allow", "443/tcp"]);
923
- await execa("ufw", ["allow", `${port}/tcp`]);
924
- await execa("ufw", ["--force", "enable"]);
925
- consola.success("UFW configured");
926
- } else if ([
927
- "almalinux",
928
- "rocky",
929
- "centos",
930
- "fedora",
931
- "rhel"
932
- ].includes(os)) {
933
- consola.start("Configuring Firewalld...");
934
- await execa("systemctl", [
935
- "enable",
936
- "--now",
937
- "firewalld"
938
- ]);
939
- await execa("firewall-cmd", [
940
- "--permanent",
941
- "--zone=public",
942
- "--add-port=22/tcp"
943
- ]);
944
- await execa("firewall-cmd", [
945
- "--permanent",
946
- "--zone=public",
947
- "--add-port=80/tcp"
948
- ]);
949
- await execa("firewall-cmd", [
950
- "--permanent",
951
- "--zone=public",
952
- "--add-port=443/tcp"
953
- ]);
954
- await execa("firewall-cmd", [
955
- "--permanent",
956
- "--zone=public",
957
- "--add-port",
958
- `${port}/tcp`
959
- ]);
960
- await execa("firewall-cmd", ["--reload"]);
961
- await execa("setsebool", [
962
- "-P",
963
- "httpd_can_network_connect",
964
- "1"
965
- ]);
966
- consola.success("Firewalld configured");
967
- } else consola.warn(`Unsupported OS for firewall: ${os}`);
968
- };
969
- const configureACME = async () => {
970
- return { email: await input({
971
- message: "Email for Let's Encrypt certificates:",
972
- validate: (v) => v.includes("@") ? true : "Please enter a valid email"
973
- }) };
974
- };
975
899
  const setupPatiomDirs = async () => {
976
900
  await fs.mkdir(PATIOM_ROOT, { recursive: true });
977
901
  await fs.mkdir(path.join(PATIOM_ROOT, "apps"), { recursive: true });
@@ -1010,7 +934,7 @@ const installServices = async (nodeBinPath) => {
1010
934
  await start("patiom-daemon");
1011
935
  consola.success("Patiom daemon started");
1012
936
  };
1013
- const setup = async () => {
937
+ const setup = async (email) => {
1014
938
  console.log("");
1015
939
  consola.info("Patiom Server Setup");
1016
940
  console.log("");
@@ -1020,9 +944,6 @@ const setup = async () => {
1020
944
  consola.error("Unsupported OS. Please use Ubuntu, Debian, AlmaLinux, Rocky, CentOS, Fedora, or RHEL.");
1021
945
  process.exit(1);
1022
946
  }
1023
- await configureFirewall(os, DAEMON_PORT);
1024
- console.log("");
1025
- const { email } = await configureACME();
1026
947
  console.log("");
1027
948
  consola.start("Setting up Patiom...");
1028
949
  await setupPatiomDirs();
@@ -1042,10 +963,12 @@ const setup = async () => {
1042
963
  consola.info("Next steps:");
1043
964
  console.log(` patiom login --url http://${ip}:${DAEMON_PORT} --token ${token}`);
1044
965
  console.log("");
966
+ consola.info("Firewall: ensure ports 22 (SSH), 80 (HTTP), 443 (HTTPS), and 4000 (daemon) are open");
967
+ console.log("");
1045
968
  };
1046
- const runSetup = async () => {
969
+ const runSetup = async (email) => {
1047
970
  try {
1048
- await setup();
971
+ await setup(email);
1049
972
  } catch (err) {
1050
973
  consola.error("Setup failed:", err);
1051
974
  process.exit(1);
@@ -1067,9 +990,13 @@ program.command("serve").description("Start the daemon HTTP server").option(skip
1067
990
  checkRoot(options.devSkipRootCheck);
1068
991
  startServer();
1069
992
  });
1070
- program.command("setup").description("Interactive first-time server setup").option(skipRootOpt, "Skip root check for development").action((options) => {
993
+ program.command("setup").description("First-time server setup").requiredOption("--email <email>", "Email for Let's Encrypt certificates").option(skipRootOpt, "Skip root check for development").action((options) => {
1071
994
  checkRoot(options.devSkipRootCheck);
1072
- return runSetup();
995
+ if (!/^\S+@\S+\.\S+$/u.test(options.email)) {
996
+ consola.error("Invalid email format. Provide a valid email for Let's Encrypt certificates.");
997
+ process.exit(1);
998
+ }
999
+ return runSetup(options.email);
1073
1000
  });
1074
1001
  program.command("upgrade").description("Update the daemon package and restart the service").option(skipRootOpt, "Skip root check for development").action(async (options) => {
1075
1002
  checkRoot(options.devSkipRootCheck);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patiom/daemon",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "patiom-server": "dist/index.js"
@@ -10,7 +10,6 @@
10
10
  ],
11
11
  "dependencies": {
12
12
  "@hono/node-server": "^2.0.4",
13
- "@inquirer/prompts": "^7.8.2",
14
13
  "adm-zip": "^0.5.17",
15
14
  "commander": "^15.0.0",
16
15
  "consola": "^3.4.2",