UNPKG

generator-begcode

Version:

Spring Boot + Angular/React/Vue in one handy generator

38 lines (37 loc) 1.41 kB
import { jhipsterOptionTypes, jhipsterOptionValues, jhipsterQuotedOptionNames } from '../jhipster/application-options.js'; export default class JDLApplicationDefinition { optionValues = jhipsterOptionValues; optionTypes = jhipsterOptionTypes; quotedOptionNames = jhipsterQuotedOptionNames; getTypeForOption(optionName) { if (!optionName) { throw new Error('A name has to be passed to get the option type.'); } if (!this.optionTypes[optionName]) { throw new Error(`Unrecognised application option name: ${optionName}.`); } return this.optionTypes[optionName].type; } doesOptionValueExist(name, value) { if (!this.doesOptionExist(name)) { return false; } const values = this.optionValues[name]; if (typeof values !== 'object' || Array.isArray(values)) { return true; } if (Array.isArray(value)) { return value.every(val => values[val] != null); } return values[value] != null; } doesOptionExist(optionName) { return !!optionName && optionName in this.optionTypes; } shouldTheValueBeQuoted(optionName) { if (!optionName) { throw new Error('An option name has to be passed to know whether it is quoted.'); } return this.quotedOptionNames.includes(optionName); } }