qcobjects-cli
Version:
qcobjects cli command line tool
89 lines • 4.11 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/**
* QCObjects CLI 2.5
* ________________
*
* Author: Jean Machuca <correojean@gmail.com>
*
* Cross Browser Javascript Framework for MVC Patterns
* QuickCorp/QCObjects is licensed under the
* GNU Lesser General Public License v3.0
* [LICENSE] (https://github.com/QuickCorp/QCObjects/blob/master/LICENSE.txt)
*
* Permissions of this copyleft license are conditioned on making available
* complete source code of licensed works and modifications under the same
* license or the GNU GPLv3. Copyright and license notices must be preserved.
* Contributors provide an express grant of patent rights. However, a larger
* work using the licensed work through interfaces provided by the licensed
* work may be distributed under different terms and without source code for
* the larger work.
*
* Copyright (C) 2015 Jean Machuca,<correojean@gmail.com>
*
* Everyone is permitted to copy and distribute verbatim copies of this
* license document, but changing it is not allowed.
*/
/*eslint no-unused-vars: "off"*/
/*eslint no-redeclare: "off"*/
/*eslint no-empty: "off"*/
/*eslint strict: "off"*/
/*eslint no-mixed-operators: "off"*/
/*eslint no-undef: "off"*/
const node_path_1 = __importDefault(require("node:path"));
const node_os_1 = __importDefault(require("node:os"));
require("./defaultsettings");
const qcobjects_1 = require("qcobjects");
(async () => {
"use strict";
const absolutePath = node_path_1.default.resolve(__dirname, "./");
const templatePath = node_path_1.default.resolve(__dirname, "./templates/apps/") + "/";
const isWindows = () => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return node_os_1.default.platform().toLowerCase().startsWith("win");
};
const isMac = () => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return node_os_1.default.platform().toLowerCase().startsWith("darwin");
};
const { execSync } = await import("node:child_process");
class Main extends qcobjects_1.InheritClass {
constructor() {
super();
this.start();
}
start() {
const certificate_provider = qcobjects_1.CONFIG.get("certificate_provider", "self_signed");
let stdout;
switch (certificate_provider) {
case "self_signed":
// stderr is sent to stderr of parent process
// you can set options.stdio if you want it to go elsewhere
if (isWindows()) {
stdout = execSync("openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj \"/CN=" + qcobjects_1.CONFIG.get("domain") + "\" -keyout " + qcobjects_1.CONFIG.get("private-key-pem") + " -out " + qcobjects_1.CONFIG.get("private-cert-pem"));
}
else {
stdout = execSync("openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj '/CN=" + qcobjects_1.CONFIG.get("domain") + "' -keyout " + qcobjects_1.CONFIG.get("private-key-pem") + " -out " + qcobjects_1.CONFIG.get("private-cert-pem"));
}
break;
case "letsencrypt":
if (isWindows()) {
throw Error("Letsencrypt certificate is not supported in Windows");
}
else {
var prehook_posthook = "--pre-hook \"service qcobjects stop\" --post-hook=\"service qcobjects start\"";
stdout = execSync(`certbot -n -d ${qcobjects_1.CONFIG.get("domain")} certonly --standalone ${prehook_posthook}`);
}
break;
default:
break;
}
}
}
const __main__ = new Main();
})().catch(e => console.error(e));
//# sourceMappingURL=qcobjects-createcert.js.map