forked from louislam/uptime-kuma
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'louislam:master' into master
- Loading branch information
Showing
90 changed files
with
5,207 additions
and
4,422 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
13
db/knex_migrations/2024-11-27-1927-fix-info-json-data-type.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.