From d76a515cbfbf8002debc1237282b7c630f3b0ff4 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Thu, 3 Aug 2023 20:51:11 +0800 Subject: [PATCH] WIP --- extra/cli.js | 18 ++++++++++++++++++ package-lock.json | 3 +++ package.json | 3 +++ 3 files changed, 24 insertions(+) create mode 100644 extra/cli.js diff --git a/extra/cli.js b/extra/cli.js new file mode 100644 index 000000000..7f1228373 --- /dev/null +++ b/extra/cli.js @@ -0,0 +1,18 @@ +#!/usr/bin/env node + +if (!process.env.DATA_DIR) { + if (process.platform === "win32") { + process.env.DATA_DIR = process.env.LOCALAPPDATA + "\\uptime-kuma\\"; + } else if (process.platform === "linux") { + process.env.DATA_DIR = process.env.HOME + "/.local/share/uptime-kuma/"; + } else if (process.platform === "darwin") { + // TODO: Not sure if this is the correct path for macOS + process.env.DATA_DIR = process.env.HOME + "/Library/Preferences/uptime-kuma/"; + } else { + console.error("Unable to detect app data directory on platform: " + process.platform); + console.error("Please set the DATA_DIR environment variable or `--data-dir=` to the directory where you want to store your data."); + process.exit(1); + } +} + +require("../server/server"); diff --git a/package-lock.json b/package-lock.json index da1524c79..a4d2050a2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -75,6 +75,9 @@ "thirty-two": "~1.0.2", "ws": "^8.13.0" }, + "bin": { + "uptime-kuma": "extra/cli.js" + }, "devDependencies": { "@actions/github": "~5.0.1", "@babel/eslint-parser": "^7.22.7", diff --git a/package.json b/package.json index 9f57e99b7..d575153c9 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,9 @@ "engines": { "node": "14 || 16 || 18 || >= 20.4.0" }, + "bin": { + "uptime-kuma": "./extra/cli.js" + }, "scripts": { "install-legacy": "npm install", "update-legacy": "npm update",