93 lines
2.3 KiB
TypeScript
93 lines
2.3 KiB
TypeScript
/**
|
|
* @author Martin Karkowski
|
|
* @email m.karkowski@zema.de
|
|
* @create date 2021-01-18 17:29:44
|
|
* @modify date 2021-02-05 10:06:53
|
|
* @desc [description]
|
|
*/
|
|
|
|
import { generateDefaultConfig } from "./generateDefaultConfig";
|
|
import { generateDefaultPackageConfig } from "./generateDefaultPackageConfig";
|
|
import { generateFolderStructure } from "./generateFolderStructure";
|
|
import { NOPELOGO } from "./renderNope";
|
|
import { readInArgs as getRunArgs, runNopeBackend } from "./runNopeBackend";
|
|
|
|
/**
|
|
* Main Function.
|
|
*
|
|
* @export
|
|
*/
|
|
export async function main() {
|
|
const args: {
|
|
mode: "run" | "init" | "none" | "scan" | "help";
|
|
params: string[];
|
|
} = {
|
|
mode: (process.argv[2] as any) || "none",
|
|
params: process.argv.slice(3)
|
|
};
|
|
|
|
const additionalArg: any = {
|
|
help: "Command to run the backend",
|
|
name: args.mode,
|
|
type: "string"
|
|
};
|
|
|
|
switch (args.mode) {
|
|
default:
|
|
case "help":
|
|
case "none":
|
|
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[4mrun\x1b[0m Start a NoPE-Backend.
|
|
\x1b[4minit\x1b[0m Initialize a new project. This project is empty.
|
|
\x1b[4mscan\x1b[0m Trys to update the configuration file.
|
|
|
|
Have fun using NoPE :)
|
|
|
|
*-*,
|
|
,*\\\/|\`| \\
|
|
\\' | |'| *,
|
|
\\ \`| | |/ )
|
|
| |'| , /
|
|
|'| |, /
|
|
___|_|_|_|___
|
|
[_____________]
|
|
| |
|
|
| This is |
|
|
| NoPE! |
|
|
| Sometimes |
|
|
| itchy! |
|
|
|___________|
|
|
|
|
`);
|
|
return;
|
|
case "run":
|
|
console.log(NOPELOGO);
|
|
|
|
getRunArgs([additionalArg])
|
|
.then((args) => runNopeBackend(args).catch(console.error))
|
|
.catch(console.error);
|
|
break;
|
|
case "init":
|
|
additionalArg.help = "Command to run init";
|
|
await generateFolderStructure([additionalArg]);
|
|
await generateDefaultConfig([additionalArg]);
|
|
await generateDefaultPackageConfig([additionalArg]);
|
|
|
|
break;
|
|
case "scan":
|
|
additionalArg.help = "Command to generate the Config of the backend";
|
|
await generateDefaultPackageConfig([additionalArg]);
|
|
break;
|
|
}
|
|
}
|
|
|
|
export default main;
|
|
|
|
// If requested As Main => Perform the Operation.
|
|
if (require.main === module) {
|
|
main().catch((e) => console.error(e));
|
|
}
|