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 Nov 2, 2024
2 parents 902deb4 + 595b35f commit e4609ca
Show file tree
Hide file tree
Showing 90 changed files with 5,207 additions and 4,422 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: json-yaml-validate
name: validate
on:
push:
branches:
Expand All @@ -25,3 +25,19 @@ jobs:
with:
comment: "true" # enable comment mode
exclude_file: ".github/config/exclude.txt" # gitignore style file for exclusions

# General validations
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20

- name: Validate language JSON files
run: node ./extra/check-lang-json.js

- name: Validate knex migrations filename
run: node ./extra/check-knex-filenames.mjs
17 changes: 17 additions & 0 deletions db/knex_migrations/2024-10-1315-rabbitmq-monitor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
exports.up = function (knex) {
return knex.schema.alterTable("monitor", function (table) {
table.text("rabbitmq_nodes");
table.string("rabbitmq_username");
table.string("rabbitmq_password");
});

};

exports.down = function (knex) {
return knex.schema.alterTable("monitor", function (table) {
table.dropColumn("rabbitmq_nodes");
table.dropColumn("rabbitmq_username");
table.dropColumn("rabbitmq_password");
});

};
13 changes: 13 additions & 0 deletions db/knex_migrations/2024-11-27-1927-fix-info-json-data-type.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Update info_json column to LONGTEXT mainly for MariaDB
exports.up = function (knex) {
return knex.schema
.alterTable("monitor_tls_info", function (table) {
table.text("info_json", "longtext").alter();
});
};

exports.down = function (knex) {
return knex.schema.alterTable("monitor_tls_info", function (table) {
table.text("info_json", "text").alter();
});
};
15 changes: 13 additions & 2 deletions docker/debian-base.dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Download Apprise deb package
FROM node:20-bookworm-slim AS download-apprise
WORKDIR /app
COPY ./extra/download-apprise.mjs ./download-apprise.mjs
RUN apt update && \
apt --yes --no-install-recommends install curl && \
npm install cheerio semver && \
node ./download-apprise.mjs

# Base Image (Slim)
# If the image changed, the second stage image should be changed too
FROM node:20-bookworm-slim AS base2-slim
ARG TARGETPLATFORM
Expand Down Expand Up @@ -27,8 +37,9 @@ RUN apt update && \
# apprise = for notifications (Install from the deb package, as the stable one is too old) (workaround for #4867)
# Switching to testing repo is no longer working, as the testing repo is not bookworm anymore.
# python3-paho-mqtt (#4859)
RUN curl http://ftp.debian.org/debian/pool/main/a/apprise/apprise_1.8.0-2_all.deb --output apprise.deb && \
apt update && \
# TODO: no idea how to delete the deb file after installation as it becomes a layer already
COPY --from=download-apprise /app/apprise.deb ./apprise.deb
RUN apt update && \
apt --yes --no-install-recommends install ./apprise.deb python3-paho-mqtt && \
rm -rf /var/lib/apt/lists/* && \
rm -f apprise.deb && \
Expand Down
2 changes: 1 addition & 1 deletion docker/dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ RUN mkdir ./data
# ⭐ Main Image
############################################
FROM $BASE_IMAGE AS release
USER node
WORKDIR /app

LABEL org.opencontainers.image.source="https://github.com/louislam/uptime-kuma"
Expand All @@ -46,6 +45,7 @@ CMD ["node", "server/server.js"]
# Rootless Image
############################################
FROM release AS rootless
USER node

############################################
# Mark as Nightly
Expand Down
2 changes: 1 addition & 1 deletion extra/beta/update-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const util = require("../../src/util");

util.polyfill();

const version = process.env.VERSION;
const version = process.env.RELEASE_BETA_VERSION;

console.log("Beta Version: " + version);

Expand Down
72 changes: 72 additions & 0 deletions extra/check-knex-filenames.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import fs from "fs";
const dir = "./db/knex_migrations";

// Get the file list (ending with .js) from the directory
const files = fs.readdirSync(dir).filter((file) => file !== "README.md");

// They are wrong, but they had been merged, so allowed.
const exceptionList = [
"2024-08-24-000-add-cache-bust.js",
"2024-10-1315-rabbitmq-monitor.js",
];

// Correct format: YYYY-MM-DD-HHmm-description.js

for (const file of files) {
if (exceptionList.includes(file)) {
continue;
}

// Check ending with .js
if (!file.endsWith(".js")) {
console.error(`It should end with .js: ${file}`);
process.exit(1);
}

const parts = file.split("-");

// Should be at least 5 parts
if (parts.length < 5) {
console.error(`Invalid format: ${file}`);
process.exit(1);
}

// First part should be a year >= 2024
const year = parseInt(parts[0], 10);
if (isNaN(year) || year < 2023) {
console.error(`Invalid year: ${file}`);
process.exit(1);
}

// Second part should be a month
const month = parseInt(parts[1], 10);
if (isNaN(month) || month < 1 || month > 12) {
console.error(`Invalid month: ${file}`);
process.exit(1);
}

// Third part should be a day
const day = parseInt(parts[2], 10);
if (isNaN(day) || day < 1 || day > 31) {
console.error(`Invalid day: ${file}`);
process.exit(1);
}

// Fourth part should be HHmm
const time = parts[3];

// Check length is 4
if (time.length !== 4) {
console.error(`Invalid time: ${file}`);
process.exit(1);
}

const hour = parseInt(time.substring(0, 2), 10);
const minute = parseInt(time.substring(2), 10);
if (isNaN(hour) || hour < 0 || hour > 23 || isNaN(minute) || minute < 0 || minute > 59) {
console.error(`Invalid time: ${file}`);
process.exit(1);
}
}

console.log("All knex filenames are correct.");
27 changes: 27 additions & 0 deletions extra/check-lang-json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// For #5231

const fs = require("fs");

let path = "./src/lang";

// list directories in the lang directory
let jsonFileList = fs.readdirSync(path);

for (let jsonFile of jsonFileList) {
if (!jsonFile.endsWith(".json")) {
continue;
}

let jsonPath = path + "/" + jsonFile;
let originalContent = fs.readFileSync(jsonPath, "utf8");
let langData = JSON.parse(originalContent);

let formattedContent = JSON.stringify(langData, null, 4) + "\n";

if (originalContent !== formattedContent) {
console.error(`File ${jsonFile} is not formatted correctly.`);
process.exit(1);
}
}

console.log("All lang json files are formatted correctly.");
57 changes: 57 additions & 0 deletions extra/download-apprise.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Go to http://ftp.debian.org/debian/pool/main/a/apprise/ using fetch api, where it is a apache directory listing page
// Use cheerio to parse the html and get the latest version of Apprise
// call curl to download the latest version of Apprise
// Target file: the latest version of Apprise, which the format is apprise_{VERSION}_all.deb

import * as cheerio from "cheerio";
import semver from "semver";
import * as childProcess from "child_process";

const baseURL = "http://ftp.debian.org/debian/pool/main/a/apprise/";
const response = await fetch(baseURL);

if (!response.ok) {
throw new Error("Failed to fetch page of Apprise Debian repository.");
}

const html = await response.text();

const $ = cheerio.load(html);

// Get all the links in the page
const linkElements = $("a");

// Filter the links which match apprise_{VERSION}_all.deb
const links = [];
const pattern = /apprise_(.*?)_all.deb/;

for (let i = 0; i < linkElements.length; i++) {
const link = linkElements[i];
if (link.attribs.href.match(pattern) && !link.attribs.href.includes("~")) {
links.push({
filename: link.attribs.href,
version: link.attribs.href.match(pattern)[1],
});
}
}

console.log(links);

// semver compare and download
let latestLink = {
filename: "",
version: "0.0.0",
};

for (const link of links) {
if (semver.gt(link.version, latestLink.version)) {
latestLink = link;
}
}

const downloadURL = baseURL + latestLink.filename;
console.log(`Downloading ${downloadURL}...`);
let result = childProcess.spawnSync("curl", [ downloadURL, "--output", "apprise.deb" ]);
console.log(result.stdout?.toString());
console.error(result.stderr?.toString());
process.exit(result.status !== null ? result.status : 1);
19 changes: 0 additions & 19 deletions extra/env2arg.js

This file was deleted.

1 change: 0 additions & 1 deletion extra/exe-builder/.gitignore

This file was deleted.

35 changes: 0 additions & 35 deletions extra/exe-builder/App.config

This file was deleted.

Loading

0 comments on commit e4609ca

Please sign in to comment.