@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
29 lines (23 loc) • 894 B
JavaScript
import { copyFile, createYAMLFile, readYAMLSync } from '@gouvfr/dsfr-forge';
class ChangelogParser {
constructor (state, partIds) {
this._state = state;
this._partIds = partIds;
}
async read () {
this._changelog = readYAMLSync(`${this._state.root}/changelog.yml`);
}
async write () {
copyFile(`${this._state.root}/changelog.yml`, this._state.configFile('changelog.yml'));
for (const partId of this._partIds) {
const state = this._state.setPart(partId);
const changelog = this._changelog.map(tag => {
const newTag = { ...tag };
newTag.commits = tag.commits.filter(commit => commit.scopes.includes(partId) || commit.scopes.includes(`${partId}s-group`));
return newTag;
}).filter(tag => tag.commits.length > 0);
createYAMLFile(state.configFile('changelog.yml'), changelog);
}
}
}
export { ChangelogParser };