diff --git a/.github/workflows/beta-release.yml b/.github/workflows/beta-release.yml index e4e668fc2..ff40e86e6 100644 --- a/.github/workflows/beta-release.yml +++ b/.github/workflows/beta-release.yml @@ -43,15 +43,15 @@ jobs: VERSION: ${{ inputs.version }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - git config user.name "louislam" - git config user.email "1336778+louislam@users.noreply.github.com" + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git" - # Delete the branch remotely if it already exists + # Delete remote branch if it exists git push origin --delete "release-${VERSION}" || true - # Delete locally if it exists + # Delete local branch if it exists git branch -D "release-${VERSION}" || true # For testing purpose - git checkout beta-workflow + # git checkout beta-workflow git checkout -b "release-${VERSION}" - name: Install dependencies diff --git a/extra/beta/update-version.mjs b/extra/beta/update-version.mjs index 91515ca13..116824dd7 100644 --- a/extra/beta/update-version.mjs +++ b/extra/beta/update-version.mjs @@ -10,7 +10,7 @@ util.polyfill(); const version = process.env.RELEASE_BETA_VERSION; -console.log("Update to Beta Version: " + version); +console.log("Beta Version: " + version); if (!version || !version.includes("-beta.")) { console.error("invalid version, beta version only"); @@ -26,25 +26,19 @@ if (!exists) { // Also update package-lock.json const npm = /^win/.test(process.platform) ? "npm.cmd" : "npm"; - const resultVersion = childProcess.spawnSync(npm, ["--no-git-tag-version", "version", version], { - shell: true, - }); + const resultVersion = childProcess.spawnSync(npm, ["--no-git-tag-version", "version", version], { shell: true }); if (resultVersion.error) { console.error(resultVersion.error); console.error("error npm version!"); process.exit(1); } - const resultInstall = childProcess.spawnSync(npm, ["install"], { - shell: true, - }); + const resultInstall = childProcess.spawnSync(npm, ["install"], { shell: true }); if (resultInstall.error) { console.error(resultInstall.error); console.error("error update package-lock!"); process.exit(1); } - console.log("Try to commit"); commit(version); - console.log("OK"); } else { console.log("version tag exists, please delete the tag or use another tag"); process.exit(1); @@ -67,8 +61,6 @@ function commit(version) { throw new Error("commit error"); } - console.log("Committed"); - // Get the current branch name res = childProcess.spawnSync("git", ["rev-parse", "--abbrev-ref", "HEAD"]); let branchName = res.stdout.toString().trim(); @@ -76,8 +68,6 @@ function commit(version) { // Git push the branch childProcess.spawnSync("git", ["push", "origin", branchName, "--force"], { stdio: "inherit" }); - - console.log("Pushed"); } /** diff --git a/src/util.js b/src/util.js index df90a740c..07c40cbb3 100644 --- a/src/util.js +++ b/src/util.js @@ -10,12 +10,99 @@ */ var _a; Object.defineProperty(exports, "__esModule", { value: true }); -exports.CONSOLE_STYLE_FgViolet = exports.CONSOLE_STYLE_FgLightBlue = exports.CONSOLE_STYLE_FgLightGreen = exports.CONSOLE_STYLE_FgOrange = exports.CONSOLE_STYLE_FgGray = exports.CONSOLE_STYLE_FgWhite = exports.CONSOLE_STYLE_FgCyan = exports.CONSOLE_STYLE_FgMagenta = exports.CONSOLE_STYLE_FgBlue = exports.CONSOLE_STYLE_FgYellow = exports.CONSOLE_STYLE_FgGreen = exports.CONSOLE_STYLE_FgRed = exports.CONSOLE_STYLE_FgBlack = exports.CONSOLE_STYLE_Hidden = exports.CONSOLE_STYLE_Reverse = exports.CONSOLE_STYLE_Blink = exports.CONSOLE_STYLE_Underscore = exports.CONSOLE_STYLE_Dim = exports.CONSOLE_STYLE_Bright = exports.CONSOLE_STYLE_Reset = exports.RESPONSE_BODY_LENGTH_MAX = exports.RESPONSE_BODY_LENGTH_DEFAULT = exports.PING_PER_REQUEST_TIMEOUT_DEFAULT = exports.PING_PER_REQUEST_TIMEOUT_MAX = exports.PING_PER_REQUEST_TIMEOUT_MIN = exports.PING_COUNT_DEFAULT = exports.PING_COUNT_MAX = exports.PING_COUNT_MIN = exports.PING_GLOBAL_TIMEOUT_DEFAULT = exports.PING_GLOBAL_TIMEOUT_MAX = exports.PING_GLOBAL_TIMEOUT_MIN = exports.PING_PACKET_SIZE_DEFAULT = exports.PING_PACKET_SIZE_MAX = exports.PING_PACKET_SIZE_MIN = exports.MIN_INTERVAL_SECOND = exports.MAX_INTERVAL_SECOND = exports.SQL_DATETIME_FORMAT_WITHOUT_SECOND = exports.SQL_DATETIME_FORMAT = exports.SQL_DATE_FORMAT = exports.STATUS_PAGE_MAINTENANCE = exports.STATUS_PAGE_PARTIAL_DOWN = exports.STATUS_PAGE_ALL_UP = exports.STATUS_PAGE_ALL_DOWN = exports.MAINTENANCE = exports.PENDING = exports.UP = exports.DOWN = exports.appName = exports.isNode = exports.isDev = void 0; -exports.TYPES_WITH_DOMAIN_EXPIRY_SUPPORT_VIA_FIELD = exports.evaluateJsonQuery = exports.intHash = exports.localToUTC = exports.utcToLocal = exports.utcToISODateTime = exports.isoToUTCDateTime = exports.parseTimeFromTimeObject = exports.parseTimeObject = exports.getMonitorRelativeURL = exports.genSecret = exports.getCryptoRandomInt = exports.getRandomInt = exports.getRandomArbitrary = exports.TimeLogger = exports.polyfill = exports.log = exports.debug = exports.ucfirst = exports.sleep = exports.flipStatus = exports.badgeConstants = exports.CONSOLE_STYLE_BgGray = exports.CONSOLE_STYLE_BgWhite = exports.CONSOLE_STYLE_BgCyan = exports.CONSOLE_STYLE_BgMagenta = exports.CONSOLE_STYLE_BgBlue = exports.CONSOLE_STYLE_BgYellow = exports.CONSOLE_STYLE_BgGreen = exports.CONSOLE_STYLE_BgRed = exports.CONSOLE_STYLE_BgBlack = exports.CONSOLE_STYLE_FgPink = exports.CONSOLE_STYLE_FgBrown = void 0; +exports.CONSOLE_STYLE_FgViolet = + exports.CONSOLE_STYLE_FgLightBlue = + exports.CONSOLE_STYLE_FgLightGreen = + exports.CONSOLE_STYLE_FgOrange = + exports.CONSOLE_STYLE_FgGray = + exports.CONSOLE_STYLE_FgWhite = + exports.CONSOLE_STYLE_FgCyan = + exports.CONSOLE_STYLE_FgMagenta = + exports.CONSOLE_STYLE_FgBlue = + exports.CONSOLE_STYLE_FgYellow = + exports.CONSOLE_STYLE_FgGreen = + exports.CONSOLE_STYLE_FgRed = + exports.CONSOLE_STYLE_FgBlack = + exports.CONSOLE_STYLE_Hidden = + exports.CONSOLE_STYLE_Reverse = + exports.CONSOLE_STYLE_Blink = + exports.CONSOLE_STYLE_Underscore = + exports.CONSOLE_STYLE_Dim = + exports.CONSOLE_STYLE_Bright = + exports.CONSOLE_STYLE_Reset = + exports.RESPONSE_BODY_LENGTH_MAX = + exports.RESPONSE_BODY_LENGTH_DEFAULT = + exports.PING_PER_REQUEST_TIMEOUT_DEFAULT = + exports.PING_PER_REQUEST_TIMEOUT_MAX = + exports.PING_PER_REQUEST_TIMEOUT_MIN = + exports.PING_COUNT_DEFAULT = + exports.PING_COUNT_MAX = + exports.PING_COUNT_MIN = + exports.PING_GLOBAL_TIMEOUT_DEFAULT = + exports.PING_GLOBAL_TIMEOUT_MAX = + exports.PING_GLOBAL_TIMEOUT_MIN = + exports.PING_PACKET_SIZE_DEFAULT = + exports.PING_PACKET_SIZE_MAX = + exports.PING_PACKET_SIZE_MIN = + exports.MIN_INTERVAL_SECOND = + exports.MAX_INTERVAL_SECOND = + exports.SQL_DATETIME_FORMAT_WITHOUT_SECOND = + exports.SQL_DATETIME_FORMAT = + exports.SQL_DATE_FORMAT = + exports.STATUS_PAGE_MAINTENANCE = + exports.STATUS_PAGE_PARTIAL_DOWN = + exports.STATUS_PAGE_ALL_UP = + exports.STATUS_PAGE_ALL_DOWN = + exports.MAINTENANCE = + exports.PENDING = + exports.UP = + exports.DOWN = + exports.appName = + exports.isNode = + exports.isDev = + void 0; +exports.TYPES_WITH_DOMAIN_EXPIRY_SUPPORT_VIA_FIELD = + exports.evaluateJsonQuery = + exports.intHash = + exports.localToUTC = + exports.utcToLocal = + exports.utcToISODateTime = + exports.isoToUTCDateTime = + exports.parseTimeFromTimeObject = + exports.parseTimeObject = + exports.getMonitorRelativeURL = + exports.genSecret = + exports.getCryptoRandomInt = + exports.getRandomInt = + exports.getRandomArbitrary = + exports.TimeLogger = + exports.polyfill = + exports.log = + exports.debug = + exports.ucfirst = + exports.sleep = + exports.flipStatus = + exports.badgeConstants = + exports.CONSOLE_STYLE_BgGray = + exports.CONSOLE_STYLE_BgWhite = + exports.CONSOLE_STYLE_BgCyan = + exports.CONSOLE_STYLE_BgMagenta = + exports.CONSOLE_STYLE_BgBlue = + exports.CONSOLE_STYLE_BgYellow = + exports.CONSOLE_STYLE_BgGreen = + exports.CONSOLE_STYLE_BgRed = + exports.CONSOLE_STYLE_BgBlack = + exports.CONSOLE_STYLE_FgPink = + exports.CONSOLE_STYLE_FgBrown = + void 0; const dayjs_1 = require("dayjs"); const jsonata = require("jsonata"); exports.isDev = process.env.NODE_ENV === "development"; -exports.isNode = typeof process !== "undefined" && ((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node); +exports.isNode = + typeof process !== "undefined" && + ((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 + ? void 0 + : _a.node); const dayjs = exports.isNode ? require("dayjs") : dayjs_1.default; exports.appName = "Uptime Kuma"; exports.DOWN = 0; @@ -170,8 +257,7 @@ class Logger { let now; if (dayjs.tz) { now = dayjs.tz(new Date()).format(); - } - else { + } else { now = dayjs().format(); } const levelColor = consoleLevelColors[level]; @@ -190,8 +276,7 @@ class Logger { } modulePart = "[" + moduleColor + module + exports.CONSOLE_STYLE_Reset + "]"; levelPart = levelColor + `${level}:` + exports.CONSOLE_STYLE_Reset; - } - else { + } else { timePart = now; modulePart = `[${module}]`; levelPart = `${level}:`; @@ -265,21 +350,21 @@ function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } exports.getRandomInt = getRandomInt; -const getRandomBytes = (typeof window !== "undefined" && window.crypto - ? - function () { - return (numBytes) => { - const randomBytes = new Uint8Array(numBytes); - for (let i = 0; i < numBytes; i += 65536) { - window.crypto.getRandomValues(randomBytes.subarray(i, i + Math.min(numBytes - i, 65536))); - } - return randomBytes; - }; - } - : - function () { - return require("crypto").randomBytes; - })(); +const getRandomBytes = ( + typeof window !== "undefined" && window.crypto + ? function () { + return (numBytes) => { + const randomBytes = new Uint8Array(numBytes); + for (let i = 0; i < numBytes; i += 65536) { + window.crypto.getRandomValues(randomBytes.subarray(i, i + Math.min(numBytes - i, 65536))); + } + return randomBytes; + }; + } + : function () { + return require("crypto").randomBytes; + } +)(); function getCryptoRandomInt(min, max) { const range = max - min; if (range >= Math.pow(2, 32)) { @@ -305,8 +390,7 @@ function getCryptoRandomInt(min, max) { randomValue = randomValue & mask; if (randomValue <= range) { return min + randomValue; - } - else { + } else { return getCryptoRandomInt(min, max); } } @@ -387,8 +471,7 @@ async function evaluateJsonQuery(data, jsonPath, jsonPathOperator, expectedValue let response; try { response = JSON.parse(data); - } - catch (_a) { + } catch (_a) { response = (typeof data === "object" || typeof data === "number") && !Buffer.isBuffer(data) ? data : data.toString(); } @@ -400,13 +483,17 @@ async function evaluateJsonQuery(data, jsonPath, jsonPathOperator, expectedValue if (Array.isArray(response)) { const responseStr = JSON.stringify(response); const truncatedResponse = responseStr.length > 25 ? responseStr.substring(0, 25) + "...]" : responseStr; - throw new Error("JSON query returned the array " + - truncatedResponse + - ", but a primitive value is required. " + - "Modify your query to return a single value via [0] to get the first element or use an aggregation like $count(), $sum() or $boolean()."); + throw new Error( + "JSON query returned the array " + + truncatedResponse + + ", but a primitive value is required. " + + "Modify your query to return a single value via [0] to get the first element or use an aggregation like $count(), $sum() or $boolean()." + ); } if (typeof response === "object" || response instanceof Date || typeof response === "function") { - throw new Error(`The post-JSON query evaluated response from the server is of type ${typeof response}, which cannot be directly compared to the expected value`); + throw new Error( + `The post-JSON query evaluated response from the server is of type ${typeof response}, which cannot be directly compared to the expected value` + ); } let jsonQueryExpression; switch (jsonPathOperator) { @@ -434,14 +521,15 @@ async function evaluateJsonQuery(data, jsonPath, jsonPathOperator, expectedValue expected: expectedValue.toString(), }); if (status === undefined) { - throw new Error("Query evaluation returned undefined. Check query syntax and the structure of the response data"); + throw new Error( + "Query evaluation returned undefined. Check query syntax and the structure of the response data" + ); } return { status, response, }; - } - catch (err) { + } catch (err) { response = JSON.stringify(response); response = response && response.length > 50 ? `${response.substring(0, 100)}… (truncated)` : response; throw new Error(`Error evaluating JSON query: ${err.message}. Response from server was: ${response}`);