nope/lib/cli/generateDefaultConfig.ts
Martin Karkowski bbcaec5850 Fixing analyzer.
Fixing Communicators,
Fixing Package Loaders,
writing CLIs
2020-11-11 17:08:11 +01:00

62 lines
1.7 KiB
TypeScript

/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2020-11-11 13:27:58
* @modify date 2020-11-11 16:20:22
* @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": "./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));