2016-10-09 21:14:02 +02:00
|
|
|
"use strict";
|
|
|
|
|
2018-06-15 22:31:06 +02:00
|
|
|
const log = require("../log");
|
2018-03-02 19:28:54 +01:00
|
|
|
const colors = require("chalk");
|
2017-07-18 11:36:24 +02:00
|
|
|
const fs = require("fs");
|
|
|
|
const path = require("path");
|
|
|
|
const program = require("commander");
|
|
|
|
const Helper = require("../helper");
|
2017-08-21 07:49:32 +02:00
|
|
|
const Utils = require("./utils");
|
2014-09-09 13:12:23 +02:00
|
|
|
|
|
|
|
program
|
2016-12-15 07:29:44 +01:00
|
|
|
.command("start")
|
2014-09-09 13:12:23 +02:00
|
|
|
.description("Start the server")
|
2019-11-07 21:19:54 +01:00
|
|
|
.option("--dev", "Development mode with hot module reloading")
|
2017-08-21 07:49:32 +02:00
|
|
|
.on("--help", Utils.extraHelp)
|
2020-03-21 21:55:36 +01:00
|
|
|
.action(function (options) {
|
2017-07-18 11:36:24 +02:00
|
|
|
initalizeConfig();
|
|
|
|
|
|
|
|
const server = require("../server");
|
2019-11-07 21:19:54 +01:00
|
|
|
server(options);
|
2014-09-09 13:12:23 +02:00
|
|
|
});
|
2017-07-18 11:36:24 +02:00
|
|
|
|
|
|
|
function initalizeConfig() {
|
2017-12-07 04:54:54 +01:00
|
|
|
if (!fs.existsSync(Helper.getConfigPath())) {
|
2020-03-16 12:53:48 +01:00
|
|
|
fs.mkdirSync(Helper.getHomePath(), {recursive: true});
|
2017-12-07 04:54:54 +01:00
|
|
|
fs.chmodSync(Helper.getHomePath(), "0700");
|
2020-03-16 12:53:48 +01:00
|
|
|
fs.copyFileSync(
|
2019-07-17 11:33:59 +02:00
|
|
|
path.resolve(path.join(__dirname, "..", "..", "defaults", "config.js")),
|
|
|
|
Helper.getConfigPath()
|
|
|
|
);
|
2017-12-07 04:54:54 +01:00
|
|
|
log.info(`Configuration file created at ${colors.green(Helper.getConfigPath())}.`);
|
2017-07-18 11:36:24 +02:00
|
|
|
}
|
|
|
|
|
2022-04-12 02:47:22 +02:00
|
|
|
fs.mkdirSync(Helper.getUsersPath(), {recursive: true, mode: 0o700});
|
2017-07-18 11:36:24 +02:00
|
|
|
}
|