UNPKG

@gouvfr/dsfr-nexus

Version:

Le module `dsfr-nexus` est l'interface de ligne de commande (CLI) centrale du Système de Design de l’État - DSFR. Il offre des outils pour gérer et compiler les ressources du DSFR

40 lines (28 loc) 1.01 kB
import { getStates } from '../../common/state/state.js'; import { PartInterpreter } from './part/part-interpreter.js'; import { CGUInterpreter } from './part/page/resource/cgu-interpreter.js'; class DSFRInterpreter { async interpret (settings) { const states = await getStates(); for (const state of states) { await this._interpret(settings, state); } } async _interpret (settings, state) { const partIds = settings.partIds ? state.partIds.filter(id => settings.partIds.includes(id)) : state.partIds; const cguInterpreter = new CGUInterpreter(state); await cguInterpreter.read(); const mainState = state.store('cgu', cguInterpreter.data); this._parts = []; for (const id of partIds) { const partState = mainState.setPart(id); const part = new PartInterpreter(partState); this._parts.push(part); await part.read(); } for (const part of this._parts) { await part.write(); } } } export { DSFRInterpreter };