From 281fe365c056e90107fcaf3d335565e61090f098 Mon Sep 17 00:00:00 2001 From: AnnAngela-work Date: Wed, 2 Mar 2022 15:23:08 +0800 Subject: [PATCH 1/6] Mark the version as 1.11.4 in package-lock.json --- package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index eefd9d5a..a3bfe061 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "uptime-kuma", - "version": "1.11.4", + "version": "1.12.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "uptime-kuma", - "version": "1.11.4", + "version": "1.12.1", "license": "MIT", "dependencies": { "@fortawesome/fontawesome-svg-core": "~1.2.36", From 783173fd1fa432d1c018e792e928cbf504c61f85 Mon Sep 17 00:00:00 2001 From: AnnAngela-work Date: Wed, 2 Mar 2022 15:48:08 +0800 Subject: [PATCH 2/6] Add a helper function --- extra/download-dist.js | 5 +++-- extra/fs-rmSync.js | 20 ++++++++++++++++++++ extra/update-language-files/index.js | 9 +++++---- extra/update-version.js | 9 +++++---- test/prepare-jest.js | 3 ++- test/prepare-test-server.js | 3 ++- 6 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 extra/fs-rmSync.js diff --git a/extra/download-dist.js b/extra/download-dist.js index dc64166c..c184c284 100644 --- a/extra/download-dist.js +++ b/extra/download-dist.js @@ -4,6 +4,7 @@ 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"; @@ -21,7 +22,7 @@ function download(url) { if (fs.existsSync("./dist")) { if (fs.existsSync("./dist-backup")) { - fs.rmdirSync("./dist-backup", { + rmSync("./dist-backup", { recursive: true }); } @@ -35,7 +36,7 @@ function download(url) { tarStream.on("close", () => { if (fs.existsSync("./dist-backup")) { - fs.rmdirSync("./dist-backup", { + rmSync("./dist-backup", { recursive: true }); } diff --git a/extra/fs-rmSync.js b/extra/fs-rmSync.js new file mode 100644 index 00000000..8def68d0 --- /dev/null +++ b/extra/fs-rmSync.js @@ -0,0 +1,20 @@ +const fs = require("fs"); +/** + * Detect if `fs.rmSync` is available + * to avoid the runtime warning triggered for using `fs.rmdirSync` with `{ recursive: true }` in Node.js v16, + * or the `recursive` property removing completely in the future Node.js version. + * See the link below. + * @link https://nodejs.org/docs/latest-v16.x/api/deprecations.html#dep0147-fsrmdirpath--recursive-true- + * @param {fs.PathLike} path Valid types for path values in "fs". + * @param {fs.RmDirOptions} [options] options for `fs.rmdirSync`, if `fs.rmSync` is available and property `recursive` is true, it will automatically have property `force` with value `true`. + */ +const rmSync = (path, options) => { + if (typeof fs.rmSync === "function") { + if (options.recursive) { + options.force = true; + } + return fs.rmSync(path, options); + } + return fs.rmdirSync(path, options); +}; +module.exports = rmSync; diff --git a/extra/update-language-files/index.js b/extra/update-language-files/index.js index 7ba30cc0..1f58d01f 100644 --- a/extra/update-language-files/index.js +++ b/extra/update-language-files/index.js @@ -3,6 +3,7 @@ import fs from "fs"; import path from "path"; import util from "util"; +import rmSync from "../fs-rmSync.js"; // https://stackoverflow.com/questions/13786160/copy-folder-recursively-in-node-js /** @@ -30,7 +31,7 @@ console.log("Arguments:", process.argv); const baseLangCode = process.argv[2] || "en"; console.log("Base Lang: " + baseLangCode); if (fs.existsSync("./languages")) { - fs.rmdirSync("./languages", { recursive: true }); + rmSync("./languages", { recursive: true }); } copyRecursiveSync("../../src/languages", "./languages"); @@ -61,7 +62,7 @@ for (const file of files) { // En first for (const key in en) { - if (! obj[key]) { + if (!obj[key]) { obj[key] = en[key]; } } @@ -69,7 +70,7 @@ for (const file of files) { if (baseLang !== en) { // Base second for (const key in baseLang) { - if (! obj[key]) { + if (!obj[key]) { obj[key] = key; } } @@ -82,5 +83,5 @@ for (const file of files) { fs.writeFileSync(`../../src/languages/${file}`, code); } -fs.rmdirSync("./languages", { recursive: true }); +rmSync("./languages", { recursive: true }); console.log("Done. Fixing formatting by ESLint..."); diff --git a/extra/update-version.js b/extra/update-version.js index 2e3b42da..499426b8 100644 --- a/extra/update-version.js +++ b/extra/update-version.js @@ -1,5 +1,6 @@ const pkg = require("../package.json"); const fs = require("fs"); +const rmSync = require("./fs-rmSync.js"); const child_process = require("child_process"); const util = require("../src/util"); @@ -11,14 +12,14 @@ const newVersion = process.argv[2]; console.log("Old Version: " + oldVersion); console.log("New Version: " + newVersion); -if (! newVersion) { +if (!newVersion) { console.error("invalid version"); process.exit(1); } const exists = tagExists(newVersion); -if (! exists) { +if (!exists) { // Process package.json pkg.version = newVersion; @@ -55,7 +56,7 @@ function tag(version) { } function tagExists(version) { - if (! version) { + if (!version) { throw new Error("invalid version"); } @@ -93,7 +94,7 @@ function updateWiki(oldVersion, newVersion) { function safeDelete(dir) { if (fs.existsSync(dir)) { - fs.rmdirSync(dir, { + rmSync(dir, { recursive: true, }); } diff --git a/test/prepare-jest.js b/test/prepare-jest.js index 9dfaba7d..3fd89d10 100644 --- a/test/prepare-jest.js +++ b/test/prepare-jest.js @@ -1,9 +1,10 @@ const fs = require("fs"); +const rmSync = require("../extra/fs-rmSync.js"); const path = "./data/test-chrome-profile"; if (fs.existsSync(path)) { - fs.rmdirSync(path, { + rmSync(path, { recursive: true, }); } diff --git a/test/prepare-test-server.js b/test/prepare-test-server.js index 0e49c7fb..1a9b04df 100644 --- a/test/prepare-test-server.js +++ b/test/prepare-test-server.js @@ -1,9 +1,10 @@ const fs = require("fs"); +const rmSync = require("../extra/fs-rmSync.js"); const path = "./data/test"; if (fs.existsSync(path)) { - fs.rmdirSync(path, { + rmSync(path, { recursive: true, }); } From 88a798704b793408cab3bd80077367bf863f7c54 Mon Sep 17 00:00:00 2001 From: AnnAngela Date: Wed, 2 Mar 2022 16:10:14 +0800 Subject: [PATCH 3/6] Update fs-rmSync.js --- extra/fs-rmSync.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/fs-rmSync.js b/extra/fs-rmSync.js index 8def68d0..4c12f22e 100644 --- a/extra/fs-rmSync.js +++ b/extra/fs-rmSync.js @@ -1,7 +1,7 @@ const fs = require("fs"); /** * Detect if `fs.rmSync` is available - * to avoid the runtime warning triggered for using `fs.rmdirSync` with `{ recursive: true }` in Node.js v16, + * to avoid the runtime deprecation warning triggered for using `fs.rmdirSync` with `{ recursive: true }` in Node.js v16, * or the `recursive` property removing completely in the future Node.js version. * See the link below. * @link https://nodejs.org/docs/latest-v16.x/api/deprecations.html#dep0147-fsrmdirpath--recursive-true- From 381605aca1fe80b95684fe5fbaaa8a89343f030d Mon Sep 17 00:00:00 2001 From: AnnAngela Date: Sun, 27 Mar 2022 20:55:28 +0800 Subject: [PATCH 4/6] Update update-version.js --- extra/update-version.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/extra/update-version.js b/extra/update-version.js index 30286300..21fdf322 100644 --- a/extra/update-version.js +++ b/extra/update-version.js @@ -10,14 +10,14 @@ const newVersion = process.env.VERSION; console.log("New Version: " + newVersion); -if (!newVersion) { +if (! newVersion) { console.error("invalid version"); process.exit(1); } const exists = tagExists(newVersion); -if (!exists) { +if (! exists) { // Process package.json pkg.version = newVersion; @@ -51,7 +51,7 @@ function tag(version) { } function tagExists(version) { - if (!version) { + if (! version) { throw new Error("invalid version"); } @@ -93,4 +93,4 @@ function safeDelete(dir) { recursive: true, }); } -} \ No newline at end of file +} From 96289fe014d42d2a4147d826c2d5e262b64e9d1b Mon Sep 17 00:00:00 2001 From: AnnAngela Date: Sun, 27 Mar 2022 20:56:42 +0800 Subject: [PATCH 5/6] Update index.js --- extra/update-language-files/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extra/update-language-files/index.js b/extra/update-language-files/index.js index 1f58d01f..e449fe34 100644 --- a/extra/update-language-files/index.js +++ b/extra/update-language-files/index.js @@ -41,7 +41,7 @@ const files = fs.readdirSync("./languages"); console.log("Files:", files); for (const file of files) { - if (!file.endsWith(".js")) { + if (! file.endsWith(".js")) { console.log("Skipping " + file); continue; } @@ -62,7 +62,7 @@ for (const file of files) { // En first for (const key in en) { - if (!obj[key]) { + if (! obj[key]) { obj[key] = en[key]; } } @@ -70,7 +70,7 @@ for (const file of files) { if (baseLang !== en) { // Base second for (const key in baseLang) { - if (!obj[key]) { + if (! obj[key]) { obj[key] = key; } } From 7fd5b61babcbbe6e568d7c2d8cbbe0324f52ff50 Mon Sep 17 00:00:00 2001 From: AnnAngela Date: Sun, 27 Mar 2022 21:12:51 +0800 Subject: [PATCH 6/6] Inproperly conflict resolving --- extra/update-version.js | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/extra/update-version.js b/extra/update-version.js index 21fdf322..505bb2cb 100644 --- a/extra/update-version.js +++ b/extra/update-version.js @@ -59,38 +59,3 @@ function tagExists(version) { return res.stdout.toString().trim() === version; } - -function updateWiki(oldVersion, newVersion) { - const wikiDir = "./tmp/wiki"; - const howToUpdateFilename = "./tmp/wiki/🆙-How-to-Update.md"; - - safeDelete(wikiDir); - - child_process.spawnSync("git", ["clone", "https://github.com/louislam/uptime-kuma.wiki.git", wikiDir]); - let content = fs.readFileSync(howToUpdateFilename).toString(); - content = content.replaceAll(`git checkout ${oldVersion}`, `git checkout ${newVersion}`); - fs.writeFileSync(howToUpdateFilename, content); - - child_process.spawnSync("git", ["add", "-A"], { - cwd: wikiDir, - }); - - child_process.spawnSync("git", ["commit", "-m", `Update to ${newVersion} from ${oldVersion}`], { - cwd: wikiDir, - }); - - console.log("Pushing to Github"); - child_process.spawnSync("git", ["push"], { - cwd: wikiDir, - }); - - safeDelete(wikiDir); -} - -function safeDelete(dir) { - if (fs.existsSync(dir)) { - rmSync(dir, { - recursive: true, - }); - } -}