gen-jhipster
Version:
VHipster - Spring Boot + Angular/React/Vue in one handy generator
32 lines (31 loc) • 963 B
JavaScript
export const extractArgumentsFromConfigs = (configs) => {
if (!configs)
return {};
return Object.fromEntries(Object.entries(configs)
.filter(([_name, def]) => def.argument)
.map(([name, def]) => [
name,
{
description: def.description,
scope: def.scope,
choices: def.choices,
...def.argument,
},
]));
};
export const convertConfigToOption = (name, config) => {
const { cli } = config;
const type = cli?.type ?? config.internal?.type;
if (!type && config?.internal)
return undefined;
const choices = config.choices?.map(choice => (typeof choice === 'string' ? choice : choice.value));
return {
...cli,
name: cli?.name ?? name,
default: config.default ?? cli?.default,
description: config.description ?? cli?.description,
choices,
scope: config.scope,
type: type,
};
};