@viewdo/dxp-story-cli
Version:
README.md
87 lines (67 loc) • 2.42 kB
JavaScript
const DXPConfig = require('../classes/dxp-config')
const StoryConfig = require('../classes/story-config')
const StoryAssetConfig = require('../classes/story-assets')
const OrganizationConfig = require('../classes/organization-config')
const OrganizationAssetConfig = require('../classes/organization-assets')
module.exports = class ConfigurationManager extends DXPConfig {
constructor({
output = '.',
explicit = false
},{
file_service
}) {
super(output, file_service)
Object.assign(this, {explicit})
}
// Story Configurations ------------------
hasStoryConfig (story_key) {
return this.story_keys.includes(story_key)
}
setStoryConfig (story) {
// create a copy of the story settings
let story_config = new StoryConfig(story.key, this.output, this.file_service)
story_config.save(story)
this.stories[story.key] = new StoryAssetConfig(story_config, this.stories[story.key])
this.save()
return story_config
}
getStoryConfig(story_key) {
return new StoryConfig(story_key, this.output, this.file_service)
}
getStoryAssetConfig(story_key) {
let story_config = this.getStoryConfig(story_key)
return new StoryAssetConfig(story_config, this.stories[story_key])
}
// Org Configurations ------------------
hasOrganizationConfig (org_key) {
return this.organization_keys.includes(org_key)
}
setOrganizationConfig (organization) {
// create a copy of the org settings
let org_config = new OrganizationConfig(organization.key, this.output, this.file_service)
org_config.save(organization)
this.organizations[organization.key] = new OrganizationAssetConfig(org_config, this.organizations[organization.key])
this.save()
return org_config
}
getOrganizationConfig(org_key) {
return new OrganizationConfig(org_key, this.output, this.file_service)
}
getOrganizationAssetConfig(org_key) {
let org_config = this.getOrganizationConfig(org_key)
return new OrganizationAssetConfig(org_config, this.organizations[org_key])
}
save() {
// TODO:
//for each org
this.organization_keys.forEach(org_key => {
let config = this.organizations[org_key]
})
// get new configurations, explicit or not
// merge with existing from file
//for each story
// get new configurations, explicit or not
// merge with existing from file
super.save()
}
}