1
0
mirror of https://github.com/louislam/uptime-kuma.git synced 2024-12-24 22:14:47 +02:00

Removed now unnecessary version checking (#4815)

This commit is contained in:
Frank Elsinga 2024-08-24 18:38:50 +02:00 committed by GitHub
parent 4b68a86524
commit 0ddf35e7b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 6 additions and 63 deletions

View File

@ -27,9 +27,7 @@
"build": "vite build --config ./config/vite.config.js",
"test": "npm run test-backend && npm run test-e2e",
"test-with-build": "npm run build && npm test",
"test-backend": "node test/backend-test-entry.js",
"test-backend:14": "cross-env TEST_BACKEND=1 NODE_OPTIONS=\"--experimental-abortcontroller --no-warnings\" node--test test/backend-test",
"test-backend:18": "cross-env TEST_BACKEND=1 node --test test/backend-test",
"test-backend": "cross-env TEST_BACKEND=1 node --test test/backend-test",
"test-e2e": "playwright test --config ./config/playwright.config.js",
"test-e2e-ui": "playwright test --config ./config/playwright.config.js --ui --ui-port=51063",
"playwright-codegen": "playwright codegen localhost:3000 --save-storage=./private/e2e-auth.json",

View File

@ -1,4 +1,3 @@
const { log } = require("../../src/util");
const NotificationProvider = require("./notification-provider");
const {
relayInit,
@ -12,16 +11,7 @@ const {
// polyfills for node versions
const semver = require("semver");
const nodeVersion = process.version;
if (semver.lt(nodeVersion, "16.0.0")) {
log.warn("monitor", "Node <= 16 is unsupported for nostr, sorry :(");
} else if (semver.lt(nodeVersion, "18.0.0")) {
// polyfills for node 16
global.crypto = require("crypto");
global.WebSocket = require("isomorphic-ws");
if (typeof crypto !== "undefined" && !crypto.subtle && crypto.webcrypto) {
crypto.subtle = crypto.webcrypto.subtle;
}
} else if (semver.lt(nodeVersion, "20.0.0")) {
if (semver.lt(nodeVersion, "20.0.0")) {
// polyfills for node 18
global.crypto = require("crypto");
global.WebSocket = require("isomorphic-ws");

View File

@ -19,7 +19,7 @@ const nodeVersion = process.versions.node;
// Get the required Node.js version from package.json
const requiredNodeVersions = require("../package.json").engines.node;
const bannedNodeVersions = " < 14 || 20.0.* || 20.1.* || 20.2.* || 20.3.* ";
const bannedNodeVersions = " < 18 || 20.0.* || 20.1.* || 20.2.* || 20.3.* ";
console.log(`Your Node.js version: ${nodeVersion}`);
const semver = require("semver");

View File

@ -1,20 +0,0 @@
// Check Node.js version
const semver = require("semver");
const childProcess = require("child_process");
const nodeVersion = process.versions.node;
console.log("Node.js version: " + nodeVersion);
// Node.js version >= 18
if (semver.satisfies(nodeVersion, ">= 18")) {
console.log("Use the native test runner: `node --test`");
childProcess.execSync("npm run test-backend:18", { stdio: "inherit" });
} else {
// 14 - 16 here
console.log("Use `test` package: `node--test`")
childProcess.execSync("npm run test-backend:14", { stdio: "inherit" });
}

View File

@ -7,15 +7,7 @@ Create a test file in this directory with the name `*.js`.
## Template
```js
const semver = require("semver");
let test;
const nodeVersion = process.versions.node;
if (semver.satisfies(nodeVersion, ">= 18")) {
test = require("node:test");
} else {
test = require("test");
}
const test = require("node:test");
const assert = require("node:assert");
test("Test name", async (t) => {
@ -25,14 +17,6 @@ test("Test name", async (t) => {
## Run
Node.js >=18
```bash
npm run test-backend:18
```
Node.js < 18
```bash
npm run test-backend:14
npm run test-backend
```

View File

@ -1,13 +1,4 @@
const semver = require("semver");
let test;
const nodeVersion = process.versions.node;
// Node.js version >= 18
if (semver.satisfies(nodeVersion, ">= 18")) {
test = require("node:test");
} else {
test = require("test");
}
const test = require("node:test");
const assert = require("node:assert");
const { UptimeCalculator } = require("../../server/uptime-calculator");
const dayjs = require("dayjs");