From 827f1dab96bae79c92edf8ddf38805a853de5c95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Sun, 19 Nov 2017 13:21:37 -0500 Subject: [PATCH] Deprecate LOUNGE_HOME env var in favor of THELOUNGE_HOME, .lounge_home file in favor of .thelounge_home This is one more step towards uniformization of lounge/thelounge due with The Lounge v3. --- .npmignore | 4 ++-- .lounge_home => .thelounge_home | 0 defaults/config.js | 2 +- src/command-line/index.js | 13 +++++++++---- src/command-line/utils.js | 29 ++++++++++++++++++++++------- 5 files changed, 34 insertions(+), 14 deletions(-) rename .lounge_home => .thelounge_home (100%) diff --git a/.npmignore b/.npmignore index 21306630..8eacd35d 100644 --- a/.npmignore +++ b/.npmignore @@ -2,9 +2,9 @@ # npm-debug.log and node_modules/ are ignored by default. # See https://docs.npmjs.com/misc/developers#keeping-files-out-of-your-package -# Ignore all dot files except for .lounge_home +# Ignore all dot files except for .thelounge_home .* -!.lounge_home +!.thelounge_home # Ignore client folder as it's being built into public/ folder # except for the specified files which are used by the server diff --git a/.lounge_home b/.thelounge_home similarity index 100% rename from .lounge_home rename to .thelounge_home diff --git a/defaults/config.js b/defaults/config.js index 9f54fef9..711a9aca 100644 --- a/defaults/config.js +++ b/defaults/config.js @@ -76,7 +76,7 @@ module.exports = { // which in result fixes mixed content warnings. // // If storage is enabled, The Lounge will fetch and store images and thumbnails - // in the `${LOUNGE_HOME}/storage` folder. + // in the `${THELOUNGE_HOME}/storage` folder. // // Images are deleted when they are no longer referenced by any message (controlled by maxHistory), // and the folder is cleaned up on every The Lounge restart. diff --git a/src/command-line/index.js b/src/command-line/index.js index a1c5451c..b20865a1 100644 --- a/src/command-line/index.js +++ b/src/command-line/index.js @@ -15,13 +15,13 @@ if (require("semver").lt(process.version, "6.0.0")) { } program.version(Helper.getVersion(), "-v, --version") - .option("--home ", `${colors.bold("[DEPRECATED]")} Use the ${colors.green("LOUNGE_HOME")} environment variable instead.`) + .option("--home ", `${colors.bold("[DEPRECATED]")} Use the ${colors.green("THELOUNGE_HOME")} environment variable instead.`) .on("--help", Utils.extraHelp) .parseOptions(process.argv); if (program.home) { log.warn(`${colors.green("--home")} is ${colors.bold("deprecated")} and will be removed in The Lounge v3.`); - log.warn(`Use the ${colors.green("LOUNGE_HOME")} environment variable instead.`); + log.warn(`Use the ${colors.green("THELOUNGE_HOME")} environment variable instead.`); } // Check if the app was built before calling setHome as it wants to load manifest.json from the public folder @@ -36,10 +36,15 @@ if (!fs.existsSync(path.join( process.exit(1); } -let home = program.home || process.env.LOUNGE_HOME; +if (process.env.LOUNGE_HOME) { + log.warn(`${colors.green("LOUNGE_HOME")} is ${colors.bold("deprecated")} and will be removed in The Lounge v3.`); + log.warn(`Use ${colors.green("THELOUNGE_HOME")} instead.`); +} + +let home = process.env.THELOUNGE_HOME || program.home || process.env.LOUNGE_HOME; if (!home) { - home = Utils.defaultLoungeHome(); + home = Utils.defaultHome(); } Helper.setHome(home); diff --git a/src/command-line/utils.js b/src/command-line/utils.js index 12de6d84..ec8ed1af 100644 --- a/src/command-line/utils.js +++ b/src/command-line/utils.js @@ -4,7 +4,7 @@ const colors = require("colors/safe"); const fs = require("fs"); const path = require("path"); -let loungeHome; +let home; class Utils { static extraHelp() { @@ -13,25 +13,40 @@ class Utils { "", " Environment variable:", "", - ` LOUNGE_HOME Path for all configuration files and folders. Defaults to ${colors.green(Utils.defaultLoungeHome())}.`, + ` THELOUNGE_HOME Path for all configuration files and folders. Defaults to ${colors.green(Utils.defaultHome())}.`, "", ].forEach((e) => console.log(e)); // eslint-disable-line no-console } - static defaultLoungeHome() { - if (loungeHome) { - return loungeHome; + static defaultHome() { + if (home) { + return home; } + const distConfig = path.resolve(path.join( + __dirname, + "..", + "..", + ".thelounge_home" + )); + + // TODO: Remove this section when releasing The Lounge v3 + const deprecatedDistConfig = path.resolve(path.join( __dirname, "..", "..", ".lounge_home" )); + if (fs.existsSync(deprecatedDistConfig)) { + log.warn(`${colors.green(".lounge_home")} is ${colors.bold("deprecated")} and will be ignored as of The Lounge v3.`); + log.warn(`Renaming to ${colors.green(".thelounge_home")} instead.`); - loungeHome = fs.readFileSync(distConfig, "utf-8").trim(); + fs.renameSync(deprecatedDistConfig, distConfig); + } - return loungeHome; + home = fs.readFileSync(distConfig, "utf-8").trim(); + + return home; } }