Skip to content

Commit

Permalink
Merge branch 'louislam:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
BuloZB authored Oct 10, 2024
2 parents 6f25912 + bbc75b8 commit f45e48a
Show file tree
Hide file tree
Showing 51 changed files with 720 additions and 447 deletions.
28 changes: 14 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Project Info

First of all, I want to thank everyone who have wrote issues or shared pull requests for Uptime Kuma.
First of all, I want to thank everyone who has submitted issues or shared pull requests for Uptime Kuma.
I never thought the GitHub community would be so nice!
Because of this, I also never thought that other people would actually read and edit my code.
Parts of the code are not very well-structured or commented, sorry about that.
Expand All @@ -9,7 +9,7 @@ The project was created with `vite.js` and is written in `vue3`.
Our backend lives in the `server`-directory and mostly communicates via websockets.
Both frontend and backend share the same `package.json`.

For production, the frontend is build into `dist`-directory and the server (`express.js`) exposes the `dist` directory as the root of the endpoint.
For production, the frontend is built into the `dist`-directory and the server (`express.js`) exposes the `dist` directory as the root of the endpoint.
For development, we run vite in development mode on another port.

## Directories
Expand All @@ -28,7 +28,7 @@ For development, we run vite in development mode on another port.
## Can I create a pull request for Uptime Kuma?

Yes or no, it depends on what you will try to do.
Both your and our maintainers time is precious, and we don't want to waste both time.
Both yours and our maintainers' time is precious, and we don't want to waste either.

If you have any questions about any process/.. is not clear, you are likely not alone => please ask them ^^

Expand All @@ -49,11 +49,11 @@ Different guidelines exist for different types of pull requests (PRs):
<p>

If you come across a bug and think you can solve, we appreciate your work.
Please make sure that you follow by these rules:
Please make sure that you follow these rules:
- keep the PR as small as possible, fix only one thing at a time => keeping it reviewable
- test that your code does what you came it does.
- test that your code does what you claim it does.

<sub>Because maintainer time is precious junior maintainers may merge uncontroversial PRs in this area.</sub>
<sub>Because maintainer time is precious, junior maintainers may merge uncontroversial PRs in this area.</sub>
</p>
</details>
- <details><summary><b>translations / internationalisation (i18n)</b></summary>
Expand All @@ -68,7 +68,7 @@ Different guidelines exist for different types of pull requests (PRs):
- language keys need to be **added to `en.json`** to be visible in weblate. If this has not happened, a PR is appreciated.
- **Adding a new language** requires a new file see [these instructions](https://github.com/louislam/uptime-kuma/blob/master/src/lang/README.md)

<sub>Because maintainer time is precious junior maintainers may merge uncontroversial PRs in this area.</sub>
<sub>Because maintainer time is precious, junior maintainers may merge uncontroversial PRs in this area.</sub>
</p>
</details>
- <details><summary><b>new notification providers</b></summary>
Expand Down Expand Up @@ -102,7 +102,7 @@ Different guidelines exist for different types of pull requests (PRs):
Therefore, making sure that they work is also really important.
Because testing notification providers is quite time intensive, we mostly offload this onto the person contributing a notification provider.

To make shure you have tested the notification provider, please include screenshots of the following events in the pull-request description:
To make sure you have tested the notification provider, please include screenshots of the following events in the pull-request description:
- `UP`/`DOWN`
- Certificate Expiry via https://expired.badssl.com/
- Testing (the test button on the notification provider setup page)
Expand All @@ -117,7 +117,7 @@ Different guidelines exist for different types of pull requests (PRs):
| Testing | paste-image-here | paste-image-here |
```

<sub>Because maintainer time is precious junior maintainers may merge uncontroversial PRs in this area.</sub>
<sub>Because maintainer time is precious, junior maintainers may merge uncontroversial PRs in this area.</sub>
</p>
</details>
- <details><summary><b>new monitoring types</b></summary>
Expand All @@ -138,14 +138,14 @@ Different guidelines exist for different types of pull requests (PRs):
-


<sub>Because maintainer time is precious junior maintainers may merge uncontroversial PRs in this area.</sub>
<sub>Because maintainer time is precious, junior maintainers may merge uncontroversial PRs in this area.</sub>
</p>
</details>
- <details><summary><b>new features/ major changes / breaking bugfixes</b></summary>
<p>

be sure to **create an empty draft pull request or open an issue, so we can have a discussion first**.
This is especially important for a large pull request or you don't know if it will be merged or not.
This is especially important for a large pull request or when you don't know if it will be merged or not.
<sub>Because of the large impact of this work, only senior maintainers may merge PRs in this area.</sub>
</p>
Expand Down Expand Up @@ -201,7 +201,7 @@ The rationale behind this is that we can align the direction and scope of the fe
## Project Styles
I personally do not like something that requires so many configurations before you can finally start the app.
I personally do not like something that requires a lot of configuration before you can finally start the app.
The goal is to make the Uptime Kuma installation as easy as installing a mobile app.
- Easy to install for non-Docker users
Expand Down Expand Up @@ -260,7 +260,7 @@ Port `3000` and port `3001` will be used.
npm run dev
```
But sometimes, you would like to restart the server, but not the frontend, you can run these commands in two terminals:
But sometimes you may want to restart the server without restarting the frontend. In that case, you can run these commands in two terminals:
```bash
npm run start-frontend-dev
Expand Down Expand Up @@ -409,7 +409,7 @@ https://github.com/louislam/uptime-kuma/issues?q=sort%3Aupdated-desc

### What is a maintainer and what are their roles?

This project has multiple maintainers which specialise in different areas.
This project has multiple maintainers who specialise in different areas.
Currently, there are 3 maintainers:

| Person | Role | Main Area |
Expand Down
4 changes: 1 addition & 3 deletions config/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ export default defineConfig({
},
define: {
"FRONTEND_VERSION": JSON.stringify(process.env.npm_package_version),
"DEVCONTAINER": JSON.stringify(process.env.DEVCONTAINER),
"GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN": JSON.stringify(process.env.GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN),
"CODESPACE_NAME": JSON.stringify(process.env.CODESPACE_NAME),
"process.env": {},
},
plugins: [
vue(),
Expand Down
11 changes: 6 additions & 5 deletions extra/download-dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const tar = require("tar");

const packageJSON = require("../package.json");
const fs = require("fs");
const rmSync = require("./fs-rmSync.js");
const version = packageJSON.version;

const filename = "dist.tar.gz";
Expand All @@ -29,8 +28,9 @@ function download(url) {
if (fs.existsSync("./dist")) {

if (fs.existsSync("./dist-backup")) {
rmSync("./dist-backup", {
recursive: true
fs.rmSync("./dist-backup", {
recursive: true,
force: true,
});
}

Expand All @@ -43,8 +43,9 @@ function download(url) {

tarStream.on("close", () => {
if (fs.existsSync("./dist-backup")) {
rmSync("./dist-backup", {
recursive: true
fs.rmSync("./dist-backup", {
recursive: true,
force: true,
});
}
console.log("Done");
Expand Down
23 changes: 0 additions & 23 deletions extra/fs-rmSync.js

This file was deleted.

11 changes: 8 additions & 3 deletions extra/update-language-files/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import fs from "fs";
import util from "util";
import rmSync from "../fs-rmSync.js";

/**
* Copy across the required language files
Expand All @@ -16,7 +15,10 @@ import rmSync from "../fs-rmSync.js";
*/
function copyFiles(langCode, baseLang) {
if (fs.existsSync("./languages")) {
rmSync("./languages", { recursive: true });
fs.rmSync("./languages", {
recursive: true,
force: true,
});
}
fs.mkdirSync("./languages");

Expand Down Expand Up @@ -93,6 +95,9 @@ console.log("Updating: " + langCode);

copyFiles(langCode, baseLangCode);
await updateLanguage(langCode, baseLangCode);
rmSync("./languages", { recursive: true });
fs.rmSync("./languages", {
recursive: true,
force: true,
});

console.log("Done. Fixing formatting by ESLint...");
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@
"sort-contributors": "node extra/sort-contributors.js",
"quick-run-nightly": "docker run --rm --env NODE_ENV=development -p 3001:3001 louislam/uptime-kuma:nightly2",
"start-dev-container": "cd docker && docker-compose -f docker-compose-dev.yml up --force-recreate",
"rebase-pr-to-1.23.X": "node extra/rebase-pr.js 1.23.X",
"start-server-node14-win": "private\\node14\\node.exe server/server.js"
"rebase-pr-to-1.23.X": "node extra/rebase-pr.js 1.23.X"
},
"dependencies": {
"@grpc/grpc-js": "~1.8.22",
Expand Down
3 changes: 2 additions & 1 deletion server/auth.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const basicAuth = require("express-basic-auth");
const passwordHash = require("./password-hash");
const { R } = require("redbean-node");
const { setting } = require("./util-server");
const { log } = require("../src/util");
const { loginRateLimiter, apiRateLimiter } = require("./rate-limiter");
const { Settings } = require("./settings");
Expand Down Expand Up @@ -138,7 +139,7 @@ exports.basicAuth = async function (req, res, next) {
challenge: true,
});

const disabledAuth = await Settings.get("disableAuth");
const disabledAuth = await setting("disableAuth");

if (!disabledAuth) {
middleware(req, res, next);
Expand Down
8 changes: 4 additions & 4 deletions server/check-version.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { setSetting, setting } = require("./util-server");
const axios = require("axios");
const compareVersions = require("compare-versions");
const { log } = require("../src/util");
const { Settings } = require("./settings");

exports.version = require("../package.json").version;
exports.latestVersion = null;
Expand All @@ -14,7 +14,7 @@ let interval;

exports.startInterval = () => {
let check = async () => {
if (await Settings.get("checkUpdate") === false) {
if (await setting("checkUpdate") === false) {
return;
}

Expand All @@ -28,7 +28,7 @@ exports.startInterval = () => {
res.data.slow = "1000.0.0";
}

let checkBeta = await Settings.get("checkBeta");
let checkBeta = await setting("checkBeta");

if (checkBeta && res.data.beta) {
if (compareVersions.compare(res.data.beta, res.data.slow, ">")) {
Expand Down Expand Up @@ -57,7 +57,7 @@ exports.startInterval = () => {
* @returns {Promise<void>}
*/
exports.enableCheckUpdate = async (value) => {
await Settings.set("checkUpdate", value);
await setSetting("checkUpdate", value);

clearInterval(interval);

Expand Down
4 changes: 2 additions & 2 deletions server/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const { R } = require("redbean-node");
const { UptimeKumaServer } = require("./uptime-kuma-server");
const server = UptimeKumaServer.getInstance();
const io = server.io;
const { setting } = require("./util-server");
const checkVersion = require("./check-version");
const { Settings } = require("./settings");
const Database = require("./database");

/**
Expand Down Expand Up @@ -158,8 +158,8 @@ async function sendInfo(socket, hideVersion = false) {
version,
latestVersion,
isContainer,
primaryBaseURL: await Settings.get("primaryBaseURL"),
dbType,
primaryBaseURL: await setting("primaryBaseURL"),
serverTimezone: await server.getTimezone(),
serverTimezoneOffset: server.getTimezoneOffset(),
});
Expand Down
34 changes: 17 additions & 17 deletions server/database.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const fs = require("fs");
const { R } = require("redbean-node");
const { setSetting, setting } = require("./util-server");
const { log, sleep } = require("../src/util");
const knex = require("knex");
const path = require("path");
const { EmbeddedMariaDB } = require("./embedded-mariadb");
const mysql = require("mysql2/promise");
const { Settings } = require("./settings");

/**
* Database & App Data Folder
Expand Down Expand Up @@ -420,7 +420,7 @@ class Database {
* @deprecated
*/
static async patchSqlite() {
let version = parseInt(await Settings.get("database_version"));
let version = parseInt(await setting("database_version"));

if (! version) {
version = 0;
Expand All @@ -445,7 +445,7 @@ class Database {
log.info("db", `Patching ${sqlFile}`);
await Database.importSQLFile(sqlFile);
log.info("db", `Patched ${sqlFile}`);
await Settings.set("database_version", i);
await setSetting("database_version", i);
}
} catch (ex) {
await Database.close();
Expand All @@ -471,7 +471,7 @@ class Database {
*/
static async patchSqlite2() {
log.debug("db", "Database Patch 2.0 Process");
let databasePatchedFiles = await Settings.get("databasePatchedFiles");
let databasePatchedFiles = await setting("databasePatchedFiles");

if (! databasePatchedFiles) {
databasePatchedFiles = {};
Expand Down Expand Up @@ -499,7 +499,7 @@ class Database {
process.exit(1);
}

await Settings.set("databasePatchedFiles", databasePatchedFiles);
await setSetting("databasePatchedFiles", databasePatchedFiles);
}

/**
Expand All @@ -512,27 +512,27 @@ class Database {
// Fix 1.13.0 empty slug bug
await R.exec("UPDATE status_page SET slug = 'empty-slug-recover' WHERE TRIM(slug) = ''");

let title = await Settings.get("title");
let title = await setting("title");

if (title) {
log.info("database", "Migrating Status Page");
console.log("Migrating Status Page");

let statusPageCheck = await R.findOne("status_page", " slug = 'default' ");

if (statusPageCheck !== null) {
log.info("database", "Migrating Status Page - Skip, default slug record is already existing");
console.log("Migrating Status Page - Skip, default slug record is already existing");
return;
}

let statusPage = R.dispense("status_page");
statusPage.slug = "default";
statusPage.title = title;
statusPage.description = await Settings.get("description");
statusPage.icon = await Settings.get("icon");
statusPage.theme = await Settings.get("statusPageTheme");
statusPage.published = !!await Settings.get("statusPagePublished");
statusPage.search_engine_index = !!await Settings.get("searchEngineIndex");
statusPage.show_tags = !!await Settings.get("statusPageTags");
statusPage.description = await setting("description");
statusPage.icon = await setting("icon");
statusPage.theme = await setting("statusPageTheme");
statusPage.published = !!await setting("statusPagePublished");
statusPage.search_engine_index = !!await setting("searchEngineIndex");
statusPage.show_tags = !!await setting("statusPageTags");
statusPage.password = null;

if (!statusPage.title) {
Expand Down Expand Up @@ -560,13 +560,13 @@ class Database {
await R.exec("DELETE FROM setting WHERE type = 'statusPage'");

// Migrate Entry Page if it is status page
let entryPage = await Settings.get("entryPage");
let entryPage = await setting("entryPage");

if (entryPage === "statusPage") {
await Settings.set("entryPage", "statusPage-default", "general");
await setSetting("entryPage", "statusPage-default", "general");
}

log.info("database", "Migrating Status Page - Done");
console.log("Migrating Status Page - Done");
}

}
Expand Down
Loading

0 comments on commit f45e48a

Please sign in to comment.