UNPKG

@viewdo/dxp-story-cli

Version:
85 lines (72 loc) 2.35 kB
const Listr = require('listr') const console = require('../services/console-service') const FileService = require('../services/file-service') module.exports = class TemplateManager { constructor(options = {}, configuration_manager, namespace = 'dev', authentication_manager) { Object.assign(this, { options, configuration_manager, namespace, file_service: new FileService() }) } // SCAFFOLD API ---------------------------------------------- scaffoldStories(story_keys, organization_key) { return this._runTasks(story_keys.map(story_key => { let fake_story = this._getFakeStory(story_key, organization_key) let story_asset_config = this.configuration_manager.setStoryConfig(story) this.configuration_manager.setStoryConfig(story_asset_config) return this._getStoryScaffoldTask(fake_story) })) } _getStoryScaffoldTask(story, story_asset_config) { return this._getStoryTasksPerType(story, story_asset_config, `Scaffolding`, ({file}) => this.file_service.ensure(file.local_path)) } _getFakeStory (story_key, organization_key) { return { name: story_key.toUpperCase(), key: story_key, organizationKey: organization_key, milestones: [ "milestone-1" ], events: [ "event-1" ], externalEvents: [ { "key": "1tcNMfvsSkiwQbpQ6t32dg", "name": "Externy", "slug": "externy", "url": "https://dxp-xapi.develop.viewdo.run/v1/story/tech-sample/record-external-event/externy?xid=" } ], emailTemplates: [{key:'example-email'}], htmlTemplates: [{key:'example-html'}], textTemplates: [ {key:'example-javascript', type: 'js'}, {key:'example-object', type: 'json'}, {key:'example-data', type: 'csv'}, {key:'example-text', type: 'text'}, {key:'example-page', type: 'html'}, {key:'example-less', type: 'less'}, {key:'example-styles', type: 'css'} ], episodes: [ { key: 'example-episode', isEnabled: true, jsonAttachmentKey: true, cssAttachmentKey: true, jsAttachmentKey: true } ], actions: [], customLinks: [], customKPIs: [], inputMaps: [] } } }