UNPKG

generator-begcode

Version:

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

38 lines (37 loc) 1.62 kB
import { applyDerivedProperty } from '../utils/derived-property.js'; export function loadConfig(configsDef, { application, config }) { if (configsDef) { for (const [name, def] of Object.entries(configsDef)) { let value = application[name]; if (value === undefined || value === null) { let source = config; if (!source) { if (def.scope === 'context') { source = this.context; } else if (def.scope === 'blueprint') { source = this.blueprintStorage.getAll(); } else if (def.scope === 'storage' || def.scope === undefined) { source = this.jhipsterConfigWithDefaults; } } if (source) { value = application[name] = source[name] ?? undefined; if (value === undefined && def.default !== undefined) { application[name] = typeof def.default === 'function' ? def.default.call(this, source) : def.default; } } } } } } export const loadDerivedConfig = (configsDef, { application }) => { if (configsDef) { for (const [name, def] of Object.entries(configsDef)) { if ((def.scope === undefined || ['storage', 'blueprint', 'context'].includes(def.scope)) && def.choices) { applyDerivedProperty(application, name, def.choices, { addAny: true }); } } } };