UNPKG

@viewdo/dxp-story-cli

Version:
52 lines (40 loc) 907 B
const JSONFile = require('./json-file') module.exports = class DXPConfig { constructor(output, file_service) { Object.assign(this, { output, stories: {}, organizations: {}, file: new JSONFile(`./dxp-config.json`, file_service), file_service }) // load the file contents let config = this.file.read() if(config) Object.assign(this, config) } get organization_keys () { return Object.keys(this.organizations) } get story_keys () { return Object.keys(this.stories) } save() { let { output, organizations, stories } = this // merge file with date let config = { kind: 'Configuration', apiVersion: 'api.view.do/v1/attachments', output, organizations, stories, updated: new Date() } Object.assign(this, config) this.file.write(config) } }