2016-10-09 19:14:02 +00:00
|
|
|
"use strict";
|
|
|
|
|
2018-06-15 20:31:06 +00:00
|
|
|
const log = require("../log");
|
2018-03-02 18:28:54 +00:00
|
|
|
const colors = require("chalk");
|
2017-07-18 09:36:24 +00:00
|
|
|
const fs = require("fs");
|
|
|
|
const fsextra = require("fs-extra");
|
|
|
|
const path = require("path");
|
|
|
|
const program = require("commander");
|
|
|
|
const Helper = require("../helper");
|
2017-08-21 05:49:32 +00:00
|
|
|
const Utils = require("./utils");
|
2014-09-09 11:12:23 +00:00
|
|
|
|
|
|
|
program
|
2016-12-15 06:29:44 +00:00
|
|
|
.command("start")
|
2014-09-09 11:12:23 +00:00
|
|
|
.description("Start the server")
|
2017-08-21 05:49:32 +00:00
|
|
|
.on("--help", Utils.extraHelp)
|
2017-12-13 06:33:25 +00:00
|
|
|
.action(function() {
|
2017-07-18 09:36:24 +00:00
|
|
|
initalizeConfig();
|
|
|
|
|
|
|
|
const server = require("../server");
|
2016-06-08 09:26:24 +00:00
|
|
|
server();
|
2014-09-09 11:12:23 +00:00
|
|
|
});
|
2017-07-18 09:36:24 +00:00
|
|
|
|
|
|
|
function initalizeConfig() {
|
2017-12-07 03:54:54 +00:00
|
|
|
if (!fs.existsSync(Helper.getConfigPath())) {
|
|
|
|
fsextra.ensureDirSync(Helper.getHomePath());
|
|
|
|
fs.chmodSync(Helper.getHomePath(), "0700");
|
2017-07-18 09:36:24 +00:00
|
|
|
fsextra.copySync(path.resolve(path.join(
|
|
|
|
__dirname,
|
|
|
|
"..",
|
|
|
|
"..",
|
|
|
|
"defaults",
|
|
|
|
"config.js"
|
2017-12-07 03:54:54 +00:00
|
|
|
)), Helper.getConfigPath());
|
|
|
|
log.info(`Configuration file created at ${colors.green(Helper.getConfigPath())}.`);
|
2017-07-18 09:36:24 +00:00
|
|
|
}
|
|
|
|
|
2017-12-07 03:54:54 +00:00
|
|
|
fsextra.ensureDirSync(Helper.getUsersPath());
|
2017-07-18 09:36:24 +00:00
|
|
|
}
|