diff --git a/extra/beta/update-version.js b/extra/beta/update-version.js index df2cb40a6..7abac5efe 100644 --- a/extra/beta/update-version.js +++ b/extra/beta/update-version.js @@ -32,6 +32,10 @@ if (! exists) { process.exit(1); } +/** + * Commit updated files + * @param {string} version Version to update to + */ function commit(version) { let msg = "Update to " + version; @@ -47,6 +51,10 @@ function commit(version) { console.log(res.stdout.toString().trim()); } +/** + * Create a tag with the specified version + * @param {string} version Tag to create + */ function tag(version) { let res = childProcess.spawnSync("git", [ "tag", version ]); console.log(res.stdout.toString().trim()); @@ -55,6 +63,11 @@ function tag(version) { console.log(res.stdout.toString().trim()); } +/** + * Check if a tag exists for the specified version + * @param {string} version Version to check + * @returns {boolean} Does the tag already exist + */ function tagExists(version) { if (! version) { throw new Error("invalid version"); diff --git a/extra/download-cloudflared.js b/extra/download-cloudflared.js index 41519b7ca..74b9bad2a 100644 --- a/extra/download-cloudflared.js +++ b/extra/download-cloudflared.js @@ -25,6 +25,10 @@ if (platform === "linux/amd64") { const file = fs.createWriteStream("cloudflared.deb"); get("https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-" + arch + ".deb"); +/** + * Download specified file + * @param {string} url URL to request + */ function get(url) { http.get(url, function (res) { if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) { diff --git a/extra/remove-2fa.js b/extra/remove-2fa.js index 0f3f63462..f88c43fca 100644 --- a/extra/remove-2fa.js +++ b/extra/remove-2fa.js @@ -43,6 +43,11 @@ const main = async () => { console.log("Finished."); }; +/** + * Ask question of user + * @param {string} question Question to ask + * @returns {Promise} Users response + */ function question(question) { return new Promise((resolve) => { rl.question(question, (answer) => { diff --git a/extra/reset-password.js b/extra/reset-password.js index 8036a4566..168983312 100644 --- a/extra/reset-password.js +++ b/extra/reset-password.js @@ -53,6 +53,11 @@ const main = async () => { console.log("Finished."); }; +/** + * Ask question of user + * @param {string} question Question to ask + * @returns {Promise} Users response + */ function question(question) { return new Promise((resolve) => { rl.question(question, (answer) => { diff --git a/extra/simple-dns-server.js b/extra/simple-dns-server.js index 376dbdd04..a6946dcb3 100644 --- a/extra/simple-dns-server.js +++ b/extra/simple-dns-server.js @@ -135,6 +135,11 @@ server.listen({ udp: 5300 }); +/** + * Get human readable request type from request code + * @param {number} code Request code to translate + * @returns {string} Human readable request type + */ function type(code) { for (let name in Packet.TYPE) { if (Packet.TYPE[name] === code) { diff --git a/extra/simple-mqtt-server.js b/extra/simple-mqtt-server.js index 238d27726..b970a380e 100644 --- a/extra/simple-mqtt-server.js +++ b/extra/simple-mqtt-server.js @@ -11,6 +11,7 @@ class SimpleMqttServer { this.port = port; } + /** Start the MQTT server */ start() { this.server.listen(this.port, () => { console.log("server started and listening on port ", this.port); diff --git a/extra/update-version.js b/extra/update-version.js index d5c2ee5ca..246e1c1c4 100644 --- a/extra/update-version.js +++ b/extra/update-version.js @@ -36,10 +36,8 @@ if (! exists) { } /** - * Updates the version number in package.json and commits it to git. - * @param {string} version - The new version number - * - * Generated by Trelent + * Commit updated files + * @param {string} version Version to update to */ function commit(version) { let msg = "Update to " + version; @@ -53,16 +51,19 @@ function commit(version) { } } +/** + * Create a tag with the specified version + * @param {string} version Tag to create + */ function tag(version) { let res = childProcess.spawnSync("git", [ "tag", version ]); console.log(res.stdout.toString().trim()); } /** - * Checks if a given version is already tagged in the git repository. - * @param {string} version - The version to check for. - * - * Generated by Trelent + * Check if a tag exists for the specified version + * @param {string} version Version to check + * @returns {boolean} Does the tag already exist */ function tagExists(version) { if (! version) { diff --git a/extra/update-wiki-version.js b/extra/update-wiki-version.js index 65b7e7b08..880bc5568 100644 --- a/extra/update-wiki-version.js +++ b/extra/update-wiki-version.js @@ -10,6 +10,10 @@ if (!newVersion) { updateWiki(newVersion); +/** + * Update the wiki with new version number + * @param {string} newVersion Version to update to + */ function updateWiki(newVersion) { const wikiDir = "./tmp/wiki"; const howToUpdateFilename = "./tmp/wiki/🆙-How-to-Update.md"; @@ -39,6 +43,10 @@ function updateWiki(newVersion) { safeDelete(wikiDir); } +/** + * Check if a directory exists before deleting + * @param {string} dir Directory to delete + */ function safeDelete(dir) { if (fs.existsSync(dir)) { fs.rm(dir, {