nope/lib/cli/generateDefaultConfig.ts
2021-01-08 08:56:01 +01:00

66 lines
1.6 KiB
TypeScript

/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2020-11-11 13:27:58
* @modify date 2021-01-08 08:37:04
* @desc [description]
*/
import { ArgumentParser } from "argparse";
import { writeFile } from "fs/promises";
import { getNopeLogger } from "../logger/getLogger";
// Define the Main Function.
// This function is used as cli tool.
const main = async function () {
const parser = new ArgumentParser({
version: "1.0.0",
addHelp: true,
description: "Command Line interface, determines the available Packages."
});
parser.addArgument(["-f", "--file"], {
help: "File containing containing the package definitions.",
defaultValue: "./nopeconfig.json",
type: "string",
dest: "file"
});
const args = parser.parseArgs();
// Define a Logger
const logger = getNopeLogger("Setup-CLI");
try {
// Try to read in the default config file.
await writeFile(
args.file,
JSON.stringify(
{
analyzers: {
typescript: {
inputDir: "./modules/**/*.ts",
tsConfig: "tsconfigBackend.json"
}
},
parsers: {
openApi: {
outputDir: "./open-api/backend-api"
}
},
tempDir: "./temp/",
configDir: "./config",
modules: "./dist/modules"
},
undefined,
4
)
);
// Inform the user.
logger.info("Created Nope-Config at " + args.file);
} catch (error) {
logger.error("Failed generating the Config");
logger.error(error);
}
};
main().catch((e) => console.error(e));