UNPKG

@viewdo/dxp-story-cli

Version:
137 lines (114 loc) 6.95 kB
const HtmlStateFileCreator = require("./html-state"); const VideoStateFileCreator = require("./video-state"); const VideoTracksFileCreator = require("./video-state/tracks"); const NavigationStateFileCreator = require("./navigation-state"); const NavigationLinksFileCreator = require("./navigation-state/links"); const NavigationLinkFileCreator = require("./navigation-state/links/link"); const InputStateFileCreator = require("./input-state"); const InputStateInputsFileCreator = require("./input-state/inputs"); const InputFileCreator = require("./input-state/inputs/input"); // const InputFileCreator = require("./input-state/input"); const RootConfigFileCreator = require('./root-config') const StatesFileCreator = require("./states"); const PageElementsFileCreator = require('./page-elements'); const PageElementHtmlFileCreator = require('./page-element-html'); const PageElementCtaLinkFileCreator = require('./page-element-cta-link'); const PageElementCtaOverlayFileCreator = require('./page-element-cta-overlay'); const PageElementImageFileCreator = require('./page-element-image'); const EmbeddedViewsCreator = require('./embedded-views'); const EmbeddedViewCreator = require('./embedded-views/embedded-view'); const MetadataFileCreator = require('./metadata'); const StaticDataFileCreator = require('./static-data'); const isEmpty = require("lodash/isEmpty"); class FileCreator { constructor(_console = console) { Object.assign(this, { console, isEmpty, root_file_creator: new RootConfigFileCreator(_console), page_elements_file_creator: new PageElementsFileCreator(_console), states_file_creator: new StatesFileCreator(_console), html_state_file_creator: new HtmlStateFileCreator(_console), embedded_views_creator: new EmbeddedViewsCreator(_console), embedded_view_creator: new EmbeddedViewCreator(_console), navigation_state_file_creator: new NavigationStateFileCreator(_console), navigation_state_links_file_creator: new NavigationLinksFileCreator(_console), navigation_state_link_file_creator: new NavigationLinkFileCreator(_console), video_state_file_creator: new VideoStateFileCreator(_console), video_tracks_file_creator: new VideoTracksFileCreator(_console), input_state_file_creator: new InputStateFileCreator(_console), input_state_inputs_file_creator: new InputStateInputsFileCreator(_console), input_file_creator: new InputFileCreator(_console), page_element_html_file_creator: new PageElementHtmlFileCreator(_console), page_link_cta_creator: new PageElementCtaLinkFileCreator(_console), page_element_cta_overlay_file_creator: new PageElementCtaOverlayFileCreator(_console), page_element_image_file_creator: new PageElementImageFileCreator(_console), metadata_file_creator: new MetadataFileCreator(_console), static_data_file_creator: new StaticDataFileCreator(_console) }); } createConfigFiles(ivx_js_config, config_path, page_elements_path) { const { root_file_creator, page_elements_file_creator, states_file_creator } = this; root_file_creator.create(ivx_js_config, config_path); page_elements_file_creator.create(ivx_js_config, page_elements_path); } createStatesFiles(states, states_folder_path, common_states, common_states_folder_path) { const { states_file_creator } = this; states_file_creator.create(states, states_folder_path, common_states, common_states_folder_path); } createHtmlStateFiles(state, state_path, state_events_path) { this.html_state_file_creator.create(state, state_path, state_events_path); } createEmbeddedViews(state, state_embedded_views_path, state_embedded_view_paths = [], common_states = []) { const { embedded_views_creator, embedded_view_creator } = this; const { embeddedViews: embedded_views = [] } = state; embedded_views_creator.create(state, state_embedded_views_path); state_embedded_view_paths.forEach(({ id: state_embedded_view_id, path: state_embedded_view_path }) => { const embedded_view = embedded_views.find((_e) => _e.id === state_embedded_view_id) || {}; embedded_view_creator.create(embedded_view, state_embedded_view_path, common_states); }); } createNavigationStateFiles(state, state_path, state_events_path, state_templates_path) { this.navigation_state_file_creator.create(state, state_path, state_events_path, state_templates_path); } createLinksStateFiles(links, state_links_path) { this.navigation_state_links_file_creator.create(links, state_links_path); } createNavigationLinkFiles(link, state, link_path, index) { this.navigation_state_link_file_creator.create(link, state, link_path, index) } createInputStateFiles(state, state_path, state_events_path, state_templates_path) { this.input_state_file_creator.create(state, state_path, state_events_path, state_templates_path); } createInputStateInputsFiles(inputs, state_inputs_path) { this.input_state_inputs_file_creator.create(inputs, state_inputs_path); } createInputFiles(input, input_path, input_template_path, index) { this.input_file_creator.create(input, input_path, input_template_path, index); } createVideoStateFiles(state, state_path, state_events_path, state_templates_pathts) { this.video_state_file_creator.create(state, state_path, state_events_path, state_templates_pathts); } createVideoTracksFiles(tracks, track_path) { this.video_tracks_file_creator.create(tracks, track_path); } createHtmlPageElementFiles(page_element, page_element_path) { this.page_element_html_file_creator.create(page_element, page_element_path); } createCtaLinkPageElementFiles(page_element, page_element_path) { this.page_link_cta_creator.create(page_element, page_element_path) } createCtaOverlayPageElementFiles(page_element, page_element_path, page_element_templates_path, page_element_events_path) { this.page_element_cta_overlay_file_creator.create(page_element, page_element_path, page_element_templates_path, page_element_events_path) } createImagePageElementsFiles(page_element, page_element_path) { this.page_element_image_file_creator.create(page_element, page_element_path); } createMetadataFiles(metadata, metadata_path) { this.metadata_file_creator.create(metadata, metadata_path); } createStaticDataFiles(static_data = {}, static_data_path, basic_data, static_data_complex_paths = []) { this.static_data_file_creator.create(static_data, static_data_path, basic_data, static_data_complex_paths); } } module.exports = FileCreator;