2016-10-09 15:14:02 -04:00
|
|
|
"use strict";
|
|
|
|
|
2016-04-28 14:36:09 -04:00
|
|
|
global.log = require("../log.js");
|
2016-04-16 07:32:38 -04:00
|
|
|
|
2017-12-09 15:06:41 -05:00
|
|
|
const _ = require("lodash");
|
2017-11-12 13:28:13 -05:00
|
|
|
const fs = require("fs");
|
|
|
|
const path = require("path");
|
2017-07-18 05:36:24 -04:00
|
|
|
const program = require("commander");
|
|
|
|
const colors = require("colors/safe");
|
|
|
|
const Helper = require("../helper");
|
2017-08-21 01:49:32 -04:00
|
|
|
const Utils = require("./utils");
|
2014-08-18 21:18:40 -04:00
|
|
|
|
2017-11-18 13:52:31 -05:00
|
|
|
if (require("semver").lt(process.version, "6.0.0")) {
|
|
|
|
log.warn(`Support of Node.js v4 is ${colors.bold("deprecated")} and will be removed in The Lounge v3.`);
|
|
|
|
log.warn("Please upgrade to Node.js v6 or more recent.");
|
|
|
|
}
|
|
|
|
|
2017-02-17 22:23:01 -05:00
|
|
|
program.version(Helper.getVersion(), "-v, --version")
|
2017-11-19 13:21:37 -05:00
|
|
|
.option("--home <path>", `${colors.bold("[DEPRECATED]")} Use the ${colors.green("THELOUNGE_HOME")} environment variable instead.`)
|
2017-12-09 15:06:41 -05:00
|
|
|
.option(
|
|
|
|
"-c, --config <key=value>",
|
|
|
|
"override entries of the configuration file, must be specified for each entry that needs to be overriden",
|
|
|
|
Utils.parseConfigOptions
|
|
|
|
)
|
2017-08-21 01:49:32 -04:00
|
|
|
.on("--help", Utils.extraHelp)
|
2017-02-17 22:23:01 -05:00
|
|
|
.parseOptions(process.argv);
|
2016-05-09 12:19:16 -04:00
|
|
|
|
2017-08-15 14:57:47 -04:00
|
|
|
if (program.home) {
|
2017-11-18 13:52:31 -05:00
|
|
|
log.warn(`${colors.green("--home")} is ${colors.bold("deprecated")} and will be removed in The Lounge v3.`);
|
2017-11-19 13:21:37 -05:00
|
|
|
log.warn(`Use the ${colors.green("THELOUNGE_HOME")} environment variable instead.`);
|
2017-08-15 14:57:47 -04:00
|
|
|
}
|
|
|
|
|
2017-11-12 13:28:13 -05:00
|
|
|
// Check if the app was built before calling setHome as it wants to load manifest.json from the public folder
|
|
|
|
if (!fs.existsSync(path.join(
|
|
|
|
__dirname,
|
|
|
|
"..",
|
|
|
|
"..",
|
|
|
|
"public",
|
|
|
|
"manifest.json"
|
|
|
|
))) {
|
|
|
|
log.error(`The client application was not built. Run ${colors.bold("NODE_ENV=production npm run build")} to resolve this.`);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
2017-11-19 13:21:37 -05:00
|
|
|
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;
|
2017-08-15 14:57:47 -04:00
|
|
|
|
|
|
|
if (!home) {
|
2017-11-19 13:21:37 -05:00
|
|
|
home = Utils.defaultHome();
|
2017-08-15 14:57:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Helper.setHome(home);
|
2014-10-03 19:33:44 -04:00
|
|
|
|
2017-12-09 15:06:41 -05:00
|
|
|
// Merge config key-values passed as CLI options into the main config
|
|
|
|
_.merge(Helper.config, program.config);
|
|
|
|
|
2016-04-19 16:58:49 -04:00
|
|
|
require("./start");
|
|
|
|
require("./config");
|
2017-12-06 21:28:21 -05:00
|
|
|
if (!Helper.config.public && !Helper.config.ldap.enable) {
|
|
|
|
require("./users");
|
|
|
|
}
|
2017-09-18 11:57:24 -04:00
|
|
|
require("./install");
|
2016-04-19 16:58:49 -04:00
|
|
|
|
2017-11-12 15:49:04 -05:00
|
|
|
// TODO: Remove this when releasing The Lounge v3
|
|
|
|
if (process.argv[1].endsWith(`${require("path").sep}lounge`)) {
|
|
|
|
log.warn(`The ${colors.red("lounge")} CLI is ${colors.bold("deprecated")} and will be removed in v3.`);
|
|
|
|
log.warn(`Use ${colors.green("thelounge")} instead.`);
|
|
|
|
process.argv[1] = "thelounge";
|
|
|
|
}
|
|
|
|
|
2017-02-17 22:23:01 -05:00
|
|
|
program.parse(process.argv);
|
2014-10-14 16:53:26 -04:00
|
|
|
|
2014-08-18 21:18:40 -04:00
|
|
|
if (!program.args.length) {
|
2017-02-17 22:23:01 -05:00
|
|
|
program.help();
|
2014-08-18 21:18:40 -04:00
|
|
|
}
|