@viewdo/dxp-story-cli
Version:
README.md
84 lines (72 loc) • 2.56 kB
JavaScript
module.exports = class OrganizationAssetConfig {
constructor(organization_config, organization_asset_config) {
// setup defaults
Object.assign(this,
this.getConfig(organization_config),
{
organization_config
})
// override from config
Object.assign(this, organization_asset_config)
}
getConfig(organization_config, explicit = true) {
let config = {
name: organization_config.name,
sync_file: organization_config.file.path
}
if(!explicit)
// only return the simple object
return config
let file_types = this.getFileTypeDefinitions(organization_config)
return Object.assign(config, {
scripts_html_file: file_types.scripts_html_file.paths[0].local_path,
email_layout_file: file_types.email_layout_file.paths[0].local_path,
flashboard_css_file: file_types.flashboard_css_file.paths[0].local_path
})
}
// Organization File Type Definitions ---------------------------------------
getFileTypeDefinitions(organization_config = this.organization_config) {
let resolvePath = (file_type, child_key, sub_type) => {
let path = this[file_type]
if(path && path[child_key]){
if(path[child_key] && path[child_key][sub_type])
path = path[child_key][sub_type]
else
path = path[child_key]
}
return (typeof path == 'string') ? path : null
}
return {
scripts_html_file: {
name: 'Html Script File',
description: 'Used for adding script-based widgets to the dashboard page for this org',
paths:
[{
remote_path: `/organizations/${organization_config.key}/script-file`,
local_path: resolvePath('scripts_html_file') ||
`${organization_config.root}/dashboard-scripts.html`
}]
},
flashboard_css_file: {
name: 'Flashboard CSS File',
description: '',
paths:
[{
remote_path: `/organizations/${organization_config.key}/flashboard-css`,
local_path: resolvePath('flashboard_css_file') ||
`${organization_config.root}/flashboards.css`
}]
},
email_layout_file: {
name: 'Email Layout File',
description: '',
paths:
[{
remote_path: `/organizations/${organization_config.key}/email-layout`,
local_path: resolvePath('email_layout_file') ||
`${organization_config.root}/email-layout.liquid`
}]
}
}
}
}