fix: array tags did not propagate

This commit is contained in:
wulkanat@gmail.com
2020-09-09 10:56:19 +02:00
parent c19fd4fae2
commit e5511d0738
2 changed files with 79 additions and 21 deletions

View File

@@ -85,15 +85,18 @@ commander
});
commander
.command('mapping <srcPath> <destPath> [ignoredTags]')
.action(async (relativeSrcPath, relativeMappingPath, ignoredTags) => {
.command('mapping <relativeSrcPath>')
.option('-m, --mappingPath <relativeMappingPath>', 'Mapping Path')
.option('-i, --ignoredTags <ignoredTags>', 'Ignored Tags')
.option('-a, --aggPath <relativeAggregationPath>', 'Aggregations Path')
.option('-e, --errorPath <relativeErrorPath>', 'Error Path')
.action(async (relativeSrcPath, options) => {
// get absolute paths
const srcPath = resolve(relativeSrcPath);
const mappingPath = resolve(relativeMappingPath);
let ignoredTagsList: string[] = [];
if (typeof ignoredTags === 'string') {
ignoredTagsList = ignoredTags.split(',');
if (typeof options.ignoredTags === 'string') {
ignoredTagsList = options.ignoredTags.split(',');
}
// get project reflection
@@ -107,10 +110,24 @@ commander
}
// write documentation to file
// tslint:disable-next-line:no-magic-numbers
writeFileSync(mappingPath, JSON.stringify(result.mappings, null, 2));
Logger.ok(`Elasticsearch mapping written to ${mappingPath}.`);
if (typeof options.aggPath !== 'undefined') {
const aggPath = resolve(options.aggPath);
// tslint:disable-next-line:no-magic-numbers
writeFileSync(aggPath, JSON.stringify(result.aggregations, null, 2));
Logger.ok(`Elasticsearch aggregations written to ${aggPath}.`);
}
if (typeof options.mappingPath !== 'undefined') {
const mappingPath = resolve(options.mappingPath);
// tslint:disable-next-line:no-magic-numbers
writeFileSync(mappingPath, JSON.stringify(result.mappings, null, 2));
Logger.ok(`Elasticsearch mappings written to ${mappingPath}.`);
}
if (typeof options.errorPath !== 'undefined') {
const errPath = resolve(options.errorPath);
// tslint:disable-next-line:no-magic-numbers
writeFileSync(errPath, JSON.stringify(result.errors, null, 2));
Logger.ok(`Mapping errors written to ${errPath}.`);
}
});
commander