@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
34 lines (25 loc) • 841 B
JavaScript
import fs from 'fs';
import { log } from '@gouvfr/dsfr-forge';
import { DSFRPublisher } from './dsfr/dsfr-publisher.js';
import { DSFRArchivePublisher } from './dsfr-archive/dsfr-archive-publisher.js';
class Publication {
async publish (settings) {
log.section('Publication');
const publication = await this.getPublication();
await publication.publish(settings);
}
async getPublication () {
const pckFile = fs.readFileSync('package.json');
const pck = JSON.parse(pckFile.toString('utf-8'));
log.info(`package ${pck.name}`);
switch (pck.name) {
case '@gouvfr/dsfr':
return new DSFRPublisher();
case '@gouvfr/dsfr-archive':
return new DSFRArchivePublisher();
default:
throw new Error(`No publisher found for ${pck.name}`);
}
}
}
export { Publication };