bbcaec5850
Fixing Communicators, Fixing Package Loaders, writing CLIs
62 lines
1.7 KiB
TypeScript
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)); |