nope-js-node
Version:
NoPE Runtime for Nodejs. For Browser-Support please use nope-browser
124 lines (119 loc) • 4.42 kB
JavaScript
;
/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @desc [description]
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.main = void 0;
const promises_1 = require("fs/promises");
const helpers_nodejs_1 = require("../ui/helpers.nodejs");
const createService_1 = require("./createService");
const generateDefaultPackageConfig_1 = require("./generateDefaultPackageConfig");
const interact_1 = require("./interact");
const projectHelper_1 = require("./projectHelper");
const repl_1 = require("./repl");
const runNopeBackend_1 = require("./runNopeBackend");
const path_1 = require("path");
/**
* Main Function.
*
* @export
*/
async function main() {
const args = {
mode: process.argv[2] || "none",
params: process.argv.slice(3),
};
const additionalArg = {
help: "Command to run the backend",
name: args.mode,
type: "str",
};
const showLog = () => {
console.log(`NoPE - Command Line Interface.
Please select the option you want. Therefore add one of the following options:
\x1b[4mhelp\x1b[0m Show this help.
\x1b[4mconf\x1b[0m Generates a new configuration file which will used in \x1b[4mrun\x1b[0m.
\x1b[4mrun\x1b[0m Start a NoPE-Backend.
\x1b[4mproject\x1b[0m Helper to create a new Project or add new items to a project.
\x1b[4mscan-ui\x1b[0m Scans and extracts the provided uis.
\x1b[4mupload-ui\x1b[0m Uploads the determined ui-file
\x1b[4mservice\x1b[0m Generate Helper Files to provide windows/linux-services for your configuration. (autorun)
\x1b[4mrepl\x1b[0m Opens an interactive console (REPL).
\x1b[4minteract\x1b[0m Opens an interactive tool, to inspect the current environment.
\x1b[4mversion\x1b[0m Shows the current version
Have fun using NoPE :)
*-*,
,*\\\/|\`| \\
\\' | |'| *,
\\ \`| | |/ )
| |'| , /
|'| |, /
___|_|_|_|___
[_____________]
| |
| This is |
| NoPE! |
| Sometimes |
| itchy! |
|___________|
`);
};
switch (args.mode) {
default:
showLog();
break;
case "help":
showLog();
break;
case "none":
showLog();
break;
case "run":
additionalArg.help = "Command to run the backend";
await (0, runNopeBackend_1.main)([additionalArg]);
break;
case "project":
additionalArg.help =
"Helper to create a new Project or add new items to a project.";
await (0, projectHelper_1.project)([additionalArg]);
break;
case "conf":
additionalArg.help = "Command to generate the Config of the backend";
await (0, generateDefaultPackageConfig_1.generateDefaultPackageConfig)([additionalArg]);
break;
case "service":
additionalArg.help = "Command to generate the Service Files";
await (0, createService_1.createService)([additionalArg]);
break;
case "repl":
await (0, repl_1.repl)([additionalArg]);
break;
case "scan-ui":
additionalArg.help =
"Command to readin the UI-Files and store them in a config";
await (0, helpers_nodejs_1.writeUiFile)((0, helpers_nodejs_1.readInWriteUiFileArgs)([additionalArg]));
break;
case "upload-ui":
additionalArg.help = "to upload the determined ui-config.";
await (0, helpers_nodejs_1.main)([additionalArg]);
break;
case "interact":
additionalArg.help = "tool for live system interaction.";
await (0, interact_1.interact)([additionalArg]);
break;
case "version":
const dirName = (0, path_1.join)(__dirname, "..", "..");
const packageJson = JSON.parse((await (0, promises_1.readFile)((0, path_1.join)(dirName, "package.json"))).toString("utf-8"));
const version = packageJson.version;
console.log(version);
break;
}
}
exports.main = main;
exports.default = main;
// If requested As Main => Perform the Operation.
if (require.main === module) {
main().catch((e) => console.error(e));
}