UNPKG

adr

Version:

轻量级架构记录工具 - Command-line tools for working with Architecture Decision Records

32 lines 2.76 kB
import { JsonGenerateBuilder } from '../base/JsonGenerateBuilder'; let fs = require('fs'); let moment = require('moment'); import BasicOutput from './BasicOutput'; import StatusHelper from '../StatusHelper'; import Config from '../Config'; let savePath = Config.getSavePath(); class JSONBuilder extends BasicOutput { buildFunc(index, decision, file, bodyString) { let lastStatus = StatusHelper.getLatestStatus(savePath + file.relativePath); let body = { index: index, decision: decision, modifiedDate: moment(file.mtime).format('YYYY-MM-DD'), lastStatus: lastStatus }; return bodyString.push(body); } buildContent() { let path = Config.getSavePath(); let graphGenerate = new JsonGenerateBuilder(path); this.result = graphGenerate .setBody(this.buildFunc) .build(); return JSON.stringify(this.result); } output() { fs.writeFileSync(this.workDir + '/export.json', JSON.stringify(this.result), 'utf-8'); } } export default JSONBuilder; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSlNPTkJ1aWxkZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvbGliL291dHB1dC9KU09OQnVpbGRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQTtBQUVqRSxJQUFJLEVBQUUsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUE7QUFDdEIsSUFBSSxNQUFNLEdBQUcsT0FBTyxDQUFDLFFBQVEsQ0FBQyxDQUFBO0FBRTlCLE9BQU8sV0FBVyxNQUFNLGVBQWUsQ0FBQTtBQUN2QyxPQUFPLFlBQVksTUFBTSxpQkFBaUIsQ0FBQTtBQUMxQyxPQUFPLE1BQU0sTUFBTSxXQUFXLENBQUE7QUFFOUIsSUFBSSxRQUFRLEdBQUcsTUFBTSxDQUFDLFdBQVcsRUFBRSxDQUFBO0FBRW5DLE1BQU0sV0FBWSxTQU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