1 | "use strict";
|
2 |
|
3 | global.log = require("../log.js");
|
4 |
|
5 | const _ = require("lodash");
|
6 | const fs = require("fs");
|
7 | const path = require("path");
|
8 | const program = require("commander");
|
9 | const colors = require("colors/safe");
|
10 | const Helper = require("../helper");
|
11 | const Utils = require("./utils");
|
12 |
|
13 | if (require("semver").lt(process.version, "6.0.0")) {
|
14 | log.warn(`Support of Node.js v4 is ${colors.bold.red("deprecated")} and will be removed in The Lounge v3.`);
|
15 | log.warn("Please upgrade to Node.js v6 or more recent.");
|
16 | }
|
17 |
|
18 | program.version(Helper.getVersion(), "-v, --version")
|
19 | .option("--home <path>", `${colors.bold.red("[DEPRECATED]")} Use the ${colors.green("THELOUNGE_HOME")} environment variable instead.`)
|
20 | .option(
|
21 | "-c, --config <key=value>",
|
22 | "override entries of the configuration file, must be specified for each entry that needs to be overriden",
|
23 | Utils.parseConfigOptions
|
24 | )
|
25 | .on("--help", Utils.extraHelp);
|
26 |
|
27 |
|
28 | const argvWithoutOptions = program.parseOptions(process.argv);
|
29 |
|
30 | if (program.home) {
|
31 | log.warn(`${colors.bold("--home")} is ${colors.bold.red("deprecated")} and will be removed in The Lounge v3. Use the ${colors.bold("THELOUNGE_HOME")} environment variable instead.`);
|
32 | }
|
33 |
|
34 |
|
35 | if (!fs.existsSync(path.join(
|
36 | __dirname,
|
37 | "..",
|
38 | "..",
|
39 | "public",
|
40 | "manifest.json"
|
41 | ))) {
|
42 | log.error(`The client application was not built. Run ${colors.bold("NODE_ENV=production npm run build")} to resolve this.`);
|
43 | process.exit(1);
|
44 | }
|
45 |
|
46 | if (process.env.LOUNGE_HOME) {
|
47 | log.warn(`${colors.green("LOUNGE_HOME")} is ${colors.bold.red("deprecated")} and will be removed in The Lounge v3.`);
|
48 | log.warn(`Use ${colors.green("THELOUNGE_HOME")} instead.`);
|
49 | }
|
50 |
|
51 | let home = process.env.THELOUNGE_HOME || program.home || process.env.LOUNGE_HOME;
|
52 |
|
53 | if (!home) {
|
54 | home = Utils.defaultHome();
|
55 | }
|
56 |
|
57 | Helper.setHome(home);
|
58 |
|
59 |
|
60 | _.merge(Helper.config, program.config);
|
61 |
|
62 | require("./start");
|
63 | require("./config");
|
64 | if (!Helper.config.public && !Helper.config.ldap.enable) {
|
65 | require("./users");
|
66 | }
|
67 | require("./install");
|
68 | require("./uninstall");
|
69 |
|
70 |
|
71 | if (process.argv[1].endsWith(`${require("path").sep}lounge`)) {
|
72 | log.warn(`The ${colors.red("lounge")} CLI is ${colors.bold.red("deprecated")} and will be removed in v3.`);
|
73 | log.warn(`Use ${colors.green("thelounge")} instead.`);
|
74 | process.argv[1] = "thelounge";
|
75 | }
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 | program.parse(argvWithoutOptions.args.concat(argvWithoutOptions.unknown));
|
84 |
|
85 | if (!program.args.length) {
|
86 | program.help();
|
87 | }
|