UNPKG

asciidoctor-liquibase

Version:

Asciidoctor.js extension to render liquibase changesets as entity relationship diagram

109 lines (105 loc) 5.19 kB
// *** WARNING: DO NOT MODIFY *** This is a generated JavaScript source code! // // Generated by LF-ET 2.2.1 (230826a), https://www.lohrfink.de/lfet // From decision table // "/opt/data/github/asciidoctor/asciidoctor-liquibase/lfet/extractor/include.lfet" // 10.09.2023 22:34 // // Changes to this code resulting from refactorings can be synchronised // with LF-ET using the function "Scrapbook Import". // // Prolog Decision Table ----> const { stringify } = require('../utils') function include (element, currentFile, processModel, logger, vfs) { // Prolog Decision Table <---- // Condition B01/01: definition is based on ... format / yaml / yaml definition if (currentFile.endsWith('yaml')) { // Condition B02/01: yaml based definition - file extension / yaml / yaml if (element.include.file.endsWith('.yaml')) { // Rule R01 ----> // Trace ----> logger.info(`include - 20230910.223434 - 1 / 7 - ${currentFile} - ${stringify(processModel)}`) // Trace <---- // Action A01/01: extract ... / yaml / extract table on yaml definition const YAML = require('yaml') const newChangeLogFile = vfs.createRelativeResourceId(currentFile, element.include.file) const includeFileElements = YAML.parseDocument(vfs.read(newChangeLogFile)).toJSON().databaseChangeLog require('../liquibase-parser.js').parseLiquibaseChangeSet(processModel, newChangeLogFile, includeFileElements, logger, vfs) // Rule R01 <---- // Condition B02/02: yaml based definition - file extension / xml / xml } else if (element.include.file.endsWith('.xml')) { // Rule R02 ----> // Trace ----> logger.info(`include - 20230910.223434 - 2 / 7 - ${currentFile} - ${stringify(processModel)}`) // Trace <---- // Action A02/04: error / MFNS / Mixed liquibase base definitions is not supported. logger.error('include - 20230910.223434 - 2 / 7 - Mixed liquibase base definitions is not supported.') // Rule R02 <---- } else { // Rule R03 ----> // Trace ----> logger.info(`include - 20230910.223434 - 3 / 7 - ${currentFile} - ${stringify(processModel)}`) // Trace <---- // Action A02/02: error / UYFE / YAML liquibase definition unknown file extension. logger.error('include - 20230910.223434 - 3 / 7 - YAML liquibase definition unknown file extension.') // Rule R03 <---- } // Condition B01/02: definition is based on ... format / xml / xml definition } else if (currentFile.endsWith('xml')) { // Condition B03/01: xml based definition - file extension / yaml / yaml if (element.$.file.endsWith('.yaml')) { // Rule R04 ----> // Trace ----> logger.info(`include - 20230910.223434 - 4 / 7 - ${currentFile} - ${stringify(processModel)}`) // Trace <---- // Action A02/04: error / MFNS / Mixed liquibase base definitions is not supported. logger.error('include - 20230910.223434 - 4 / 7 - Mixed liquibase base definitions is not supported.') // Rule R04 <---- // Condition B03/02: xml based definition - file extension / xml / xml } else if (element.$.file.endsWith('.xml')) { // Rule R05 ----> // Trace ----> logger.info(`include - 20230910.223434 - 5 / 7 - ${currentFile} - ${stringify(processModel)}`) // Trace <---- // Action A01/02: extract ... / xml / extract on xml definition const newChangeLogFile = vfs.createRelativeResourceId(currentFile, element.$.file) const XMLParser = require('xml2js').Parser const parser = new XMLParser({ preserveChildrenOrder: true, explicitArray: true, explicitRoot: false, explicitChildren: true }) let includeFileElements = [] parser.parseString(vfs.read(newChangeLogFile), function (err, result) { if (err) { includeFileElements = [] } else { includeFileElements = result.$$ } }) require('../liquibase-parser.js').parseLiquibaseChangeSet(processModel, newChangeLogFile, includeFileElements, logger, vfs) // Rule R05 <---- } else { // Rule R06 ----> // Trace ----> logger.info(`include - 20230910.223434 - 6 / 7 - ${currentFile} - ${stringify(processModel)}`) // Trace <---- // Action A02/03: error / UXFE / XML liquibase definition unknown file extension. logger.error('include - 20230910.223434 - 6 / 7 - XML liquibase definition unknown file extension.') // Rule R06 <---- } } else { // Rule R07 ----> // Trace ----> logger.info(`include - 20230910.223434 - 7 / 7 - ${currentFile} - ${stringify(processModel)}`) // Trace <---- // Action A02/01: error / UDF / Format for '${currentFile}' is not supported. logger.error(`include - 20230910.223434 - 7 / 7 - Format for '${currentFile}' is not supported.`) // Rule R07 <---- } // Epilog Decision Table ----> } module.exports = { extract: (element, currentFile, processModel, logger, vfs) => { return include(element, currentFile, processModel, logger, vfs) } } // Epilog Decision Table <---- // End of generated JavaScript source code // Generated by LF-ET 2.2.1 (230826a), https://www.lohrfink.de/lfet