UNPKG

liquibase

Version:
3 lines (2 loc) 14.2 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("child_process"),t=require("path"),n=require("fs");function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,"symbol"==typeof(o=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(r.key))?o:String(o),r)}var o}function o(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(){return(s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var a,i,u=function(){function t(e){this.logger=new g(e)}return t.prototype.spawnChildProcess=function(t){var n=this;return this.logger.log("Running "+t+"..."),new Promise((function(r,o){e.exec(t,(function(e,t,s){if(n.logger.log("\n "+t),e)return n.logger.error("\n "+s),o(e);r(t)}))}))},t}(),l=function(){function e(){}return e.readFileContent=function(e){return n.readFileSync(e,{encoding:"utf-8"})},o(e,null,[{key:"bundledLiquibasePath",get:function(){return this.bundledLiquibasePathForExternalConsumers}},{key:"bundledLiquibasePathForExternalConsumers",get:function(){return t.join(__dirname,"liquibase/liquibase")}},{key:"bundledLiquibasePathForInternalConsumers",get:function(){return t.join(__dirname,"../../bin/liquibase/liquibase")}}]),e}();(a=exports.LiquibaseCommands||(exports.LiquibaseCommands={})).CalculateCheckSum="calculateCheckSum",a.ChangelogSync="changelogSync",a.ChangelogSyncSql="changelogSyncSQL",a.ChangelogSyncToTag="changelogSyncToTag",a.ChangelogSyncToTagSql="changelogSyncToTagSQL",a.ChecksBulkSet="checksBulkSet",a.ChecksCopy="checksCopy",a.ChecksCreate="checksCreate",a.ChecksCustomize="checksCustomize",a.ChecksDelete="checksDelete",a.ChecksDisable="checksDisable",a.ChecksEnable="checksEnable",a.ChecksReset="checksReset",a.ChecksRun="checksRun",a.ChecksShow="checksShow",a.ClearCheckSums="clearCheckSums",a.Connect="connect",a.DbDoc="dbDoc",a.DbclHistory="dbclHistory",a.DeactivateChangeLog="deactivateChangeLog",a.Diff="diff",a.DiffChangeLog="diffChangeLog",a.DropAll="dropAll",a.ExecuteSql="executeSql",a.Flow="flow",a.FutureRollbackSql="futureRollbackSQL",a.FutureRollbackCountSql="futureRollbackCountSQL",a.GenerateChangeLog="generateChangeLog",a.Help="help",a.History="history",a.Init="init",a.InitCopy="init Copy",a.InitProject="init Project",a.InitStartH2="init StartH2",a.ListLocks="listLocks",a.MarkNextChangeSetRan="markNextChangeSetRan",a.MarkNextChangeSetRanSql="markNextChangeSetRanSQL",a.RegisterChangeLog="registerChangeLog",a.ReleaseLocks="releaseLocks",a.Rollback="rollback",a.RollbackCount="rollbackCount",a.RollbackCountSql="rollbackCountSQL",a.RollbackSql="rollbackSQL",a.RollbackToDate="rollbackToDate",a.RollbackToDateSql="rollbackToDateSQL",a.RollbackOneChangeset="rollbackOneChangeset",a.RollbackOneChangesetSql="rollbackOneChangesetSQL",a.RollbackOneUpdate="rollbackOneUpdate",a.RollbackOneUpdateSql="rollbackOneUpdateSQL",a.SetContexts="setContexts",a.SetLabels="setLabels",a.Snapshot="snapshot",a.SnapshotReference="snapshotReference",a.Status="status",a.SyncHub="syncHub",a.Tag="tag",a.TagExists="tagExists",a.UnexpectedChangeSets="unexpectedChangeSets",a.Update="update",a.UpdateSql="updateSQL",a.UpdateCount="updateCount",a.UpdateCountSql="updateCountSQL",a.UpdateTestingRollback="updateTestingRollback",a.UpdateToTag="updateToTag",a.UpdateToTagSql="updateToTagSQL",a.UpdateOneChangeset="updateOneChangeset",a.UpdateOneChangesetSql="updateOneChangesetSQL",a.Validate="validate",(i=exports.LiquibaseLogLevels||(exports.LiquibaseLogLevels={})).Off="off",i.Severe="severe",i.Warning="warning",i.Info="info",i.Debug="debug";var c,h={url:"jdbc:sqlserver://<IP_OR_HOSTNAME>:;database=sqlserver;",changeLogFile:"/examples/change-log-examples/mssql/changelog.xml",username:"sa",password:"",classpath:t.join(__dirname,"../../../drivers/mssql-jdbc-7.4.1.jre8.jar")},b={changeLogFile:"/node_modules/examples/change-log-examples/postgreSQL/changelog.xml",url:"jdbc:postgresql://localhost:5432/postgres",username:"postgres",password:"",classpath:t.join(__dirname,"drivers/postgresql-42.4.2.jar")},g=function(){function e(e){this.config=e}var t=e.prototype;return t.log=function(e){return this._log(e)},t.debug=function(e){return this._debug(e)},t.info=function(e){return this._info(e)},t.warn=function(e){return this._warn(e)},t.error=function(e){return this._error(e)},t._log=function(e){var t=[exports.LiquibaseLogLevels.Debug,exports.LiquibaseLogLevels.Info,exports.LiquibaseLogLevels.Severe,exports.LiquibaseLogLevels.Warning];if(this.shouldOperate(t))return this.logLevel===exports.LiquibaseLogLevels.Debug?this._debug(e):console.log("[NODE-LIQUIBASE] "+this.sanitizeOutput(e))},t._debug=function(e){var t=[exports.LiquibaseLogLevels.Debug,exports.LiquibaseLogLevels.Info,exports.LiquibaseLogLevels.Severe,exports.LiquibaseLogLevels.Warning];if(this.shouldOperate(t))return console.debug("%s","[NODE-LIQUIBASE] "+e)},t._info=function(e){var t=[exports.LiquibaseLogLevels.Info,exports.LiquibaseLogLevels.Severe,exports.LiquibaseLogLevels.Warning];if(this.shouldOperate(t))return console.info("%s","[NODE-LIQUIBASE] "+this.sanitizeOutput(e))},t._warn=function(e){var t=[exports.LiquibaseLogLevels.Severe,exports.LiquibaseLogLevels.Warning];if(this.shouldOperate(t))return console.warn("%s","[NODE-LIQUIBASE] "+this.sanitizeOutput(e))},t._error=function(e){var t=[exports.LiquibaseLogLevels.Severe];if(this.shouldOperate(t))return console.error("%s","[NODE-LIQUIBASE] "+this.sanitizeOutput(e))},t.shouldOperate=function(e){return e.indexOf(this.logLevel)>-1},t.sanitizeOutput=function(e){return e.replace(/password=("?\S+"?)/gi,"password=******")},o(e,[{key:"logLevel",get:function(){var e;return(null==(e=this.config)?void 0:e.logLevel)||exports.LiquibaseLogLevels.Severe}}]),e}();!function(e){e.futureRollbackCount="futureRollbackCount",e.futureRollbackFromTag="futureRollbackFromTag",e.futureRollbackSQl="futureRollbackSQl",e.rollback="rollback",e.rollbackCount="rollbackCount",e.rollbackCountSQL="rollbackCountSQL",e.rollbackDate="rollbackDate",e.rollbackSql="rollbackSql",e.rollbackToDate="rollbackToDate",e.rollbackToDateSQL="rollbackToDateSQL",e.rollbackOneChangeset="rollbackOneChangeset",e.rollbackOneChangesetSQL="rollbackOneChangesetSQL",e.rollbackOneUpdate="rollbackOneUpdate",e.rollbackOneUpdateSQL="rollbackOneUpdateSQL",e.tag="tag"}(c||(c={}));var p=function(){function e(e){this.config=e,this.config=Object.assign({},{liquibase:l.bundledLiquibasePath,changeLogFile:"",url:"",username:"",password:""},e),this.commandHandler=new u(this.config)}var t=e.prototype;return t.update=function(e){return this.run(exports.LiquibaseCommands.Update,e)},t.updateSQL=function(e){return this.run(exports.LiquibaseCommands.UpdateSql,e)},t.updateCount=function(e){return this.run(exports.LiquibaseCommands.UpdateCount,e)},t.updateCountSQL=function(e){return this.run(exports.LiquibaseCommands.UpdateCountSql,e)},t.updateTestingRollback=function(){return this.run(exports.LiquibaseCommands.UpdateTestingRollback)},t.updateToTag=function(e){return this.run(exports.LiquibaseCommands.UpdateToTag,e)},t.updateToTagSQL=function(e){return this.run(exports.LiquibaseCommands.UpdateToTagSql,e)},t.updateOneChangeset=function(e){return this.run(exports.LiquibaseCommands.UpdateOneChangeset,e)},t.updateOneChangesetSQL=function(e){return this.run(exports.LiquibaseCommands.UpdateOneChangesetSql,e)},t.validate=function(){return this.run(exports.LiquibaseCommands.Validate)},t.calculateCheckSum=function(e){return this.run(exports.LiquibaseCommands.CalculateCheckSum,e)},t.rollback=function(e){return this.run(exports.LiquibaseCommands.Rollback,e)},t.rollbackSQL=function(e){return this.run(exports.LiquibaseCommands.RollbackSql,e)},t.rollbackCount=function(e){return this.run(exports.LiquibaseCommands.RollbackCount,e)},t.rollbackCountSQL=function(e){return this.run(exports.LiquibaseCommands.RollbackCountSql,e)},t.rollbackToDate=function(e){return this.run(exports.LiquibaseCommands.RollbackToDate,e)},t.rollbackToDateSQL=function(e){return this.run(exports.LiquibaseCommands.RollbackToDateSql,e)},t.rollbackOneChangeset=function(e){return this.run(exports.LiquibaseCommands.RollbackOneChangeset,e)},t.rollbackOneChangesetSQL=function(e){return this.run(exports.LiquibaseCommands.RollbackOneChangesetSql,e)},t.rollbackOneUpdate=function(e){return this.run(exports.LiquibaseCommands.RollbackOneUpdate,e)},t.rollbackOneUpdateSQL=function(e){return this.run(exports.LiquibaseCommands.RollbackOneUpdateSql,e)},t.setContexts=function(e){return this.run(exports.LiquibaseCommands.SetContexts,e)},t.setLabels=function(e){return this.run(exports.LiquibaseCommands.SetLabels,e)},t.snapshot=function(e){return this.run(exports.LiquibaseCommands.Snapshot,e)},t.snapshotReference=function(e){return this.run(exports.LiquibaseCommands.SnapshotReference,e)},t.status=function(){return this.run(exports.LiquibaseCommands.Status)},t.syncHub=function(e){return this.run(exports.LiquibaseCommands.SyncHub,e)},t.tag=function(e){return this.run(exports.LiquibaseCommands.Tag,e)},t.tagExists=function(e){return this.run(exports.LiquibaseCommands.TagExists,e)},t.unexpectedChangeSets=function(){return this.run(exports.LiquibaseCommands.UnexpectedChangeSets)},t.dropAll=function(){return this.run(exports.LiquibaseCommands.DropAll)},t.futureRollbackSQL=function(){return this.run(exports.LiquibaseCommands.FutureRollbackSql)},t.futureRollbackCountSQL=function(e){return this.run(exports.LiquibaseCommands.FutureRollbackCountSql,e)},t.generateChangeLog=function(e){return this.run(exports.LiquibaseCommands.GenerateChangeLog,e)},t.help=function(){return this.run(exports.LiquibaseCommands.Help)},t.history=function(){return this.run(exports.LiquibaseCommands.History)},t.listLocks=function(){return this.run(exports.LiquibaseCommands.ListLocks)},t.markNextChangeSetRan=function(){return this.run(exports.LiquibaseCommands.MarkNextChangeSetRan)},t.markNextChangeSetRanSQL=function(){return this.run(exports.LiquibaseCommands.MarkNextChangeSetRanSql)},t.registerChangeLog=function(){return this.run(exports.LiquibaseCommands.RegisterChangeLog)},t.releaseLocks=function(){return this.run(exports.LiquibaseCommands.ReleaseLocks)},t.changelogSync=function(e){return this.run(exports.LiquibaseCommands.ChangelogSync,e)},t.changelogSyncSQL=function(){return this.run(exports.LiquibaseCommands.ChangelogSyncSql)},t.changelogSyncToTag=function(e){return this.run(exports.LiquibaseCommands.ChangelogSyncToTag,e)},t.changelogSyncToTagSQL=function(e){return this.run(exports.LiquibaseCommands.ChangelogSyncToTagSql,e)},t.checksBulkSet=function(e){return this.run(exports.LiquibaseCommands.ChecksBulkSet,e)},t.checksCopy=function(e){return this.run(exports.LiquibaseCommands.ChecksCopy,e)},t.checksCreate=function(e){return this.run(exports.LiquibaseCommands.ChecksCreate,e)},t.checksCustomize=function(e){return this.run(exports.LiquibaseCommands.ChecksCustomize,e)},t.checksDelete=function(e){return this.run(exports.LiquibaseCommands.ChecksDelete,e)},t.checksDisable=function(e){return this.run(exports.LiquibaseCommands.ChecksDisable,e)},t.checksEnable=function(e){return this.run(exports.LiquibaseCommands.ChecksEnable,e)},t.checksReset=function(e){return this.run(exports.LiquibaseCommands.ChecksReset,e)},t.checksRun=function(e){return this.run(exports.LiquibaseCommands.ChecksRun,e)},t.checksShow=function(e){return this.run(exports.LiquibaseCommands.ChecksShow,e)},t.clearCheckSums=function(){return this.run(exports.LiquibaseCommands.ClearCheckSums)},t.connect=function(){return this.run(exports.LiquibaseCommands.Connect)},t.dbDoc=function(e){return this.run(exports.LiquibaseCommands.DbDoc,e)},t.dbclHistory=function(e){return this.run(exports.LiquibaseCommands.DbclHistory,e)},t.deactivateChangeLog=function(){return this.run(exports.LiquibaseCommands.DeactivateChangeLog)},t.diff=function(e){return this.run(exports.LiquibaseCommands.Diff,e)},t.diffChangelog=function(e){return this.run(exports.LiquibaseCommands.DiffChangeLog,e)},t.executeSql=function(e){return this.run(exports.LiquibaseCommands.ExecuteSql,e)},t.flow=function(e){return this.run(exports.LiquibaseCommands.Flow,e)},t.init=function(e){return this.run(exports.LiquibaseCommands.Init,e)},t.stringifyParams=function(e,t){var n=Object.values(c).includes(e),r=this.getPositionalArgumentsAndCommandString(t,n);return r.positionalArguments+" "+r.commandString+" "+this.getSubstitutionArguments(t)},t.getPositionalArgumentsAndCommandString=function(e,t){var n="",r="";for(var o in e){var s=e[o];t?r+=JSON.stringify(s)+" ":n+="--"+o+"="+JSON.stringify(s)+" "}return{commandString:n,positionalArguments:r}},t.getSubstitutionArguments=function(e){var t=e.substitutionParams,n="";if(!t)return n;for(var r=0,o=Object.keys(t);r<o.length;r++){var s=o[r];n+=" -D"+s+'="'+t[s]+'" '}return n},t.loadParamsFromLiquibasePropertiesFileOnDemand=function(e){var t={};if(e)return l.readFileContent(e).split(/\r?\n/).forEach((function(e){var n=e.split(/=?:/,2),r=n[0],o=n[1];t.hasOwnProperty(r)&&(t[r.trim()]=o.trim())})),t},t.run=function(e,t){void 0===t&&(t={});var n=s({},this.loadParamsFromLiquibasePropertiesFileOnDemand(this.config.liquibasePropertiesFile),this.config),r=this.stringifyParams(e,t);return this.spawnChildProcess(this.liquibasePathAndGlobalAttributes(n)+" "+e+" "+r)},t.liquibasePathAndGlobalAttributes=function(e){var t=this,n=""+e.liquibase;return Object.keys(e).forEach((function(e){"liquibase"!==e&&"liquibasePropertiesFile"!==e&&(n=n+" --"+e+'="'+t.config[e]+'"')})),n},t.spawnChildProcess=function(e){return this.commandHandler.spawnChildProcess(e)},e}();exports.CommandHandler=u,exports.FileHelper=l,exports.LIQUIBASE_LABEL="[NODE-LIQUIBASE]",exports.Liquibase=p,exports.Logger=g,exports.MSSQL_DEFAULT_CONFIG=h,exports.POSTGRESQL_DEFAULT_CONFIG=b; //# sourceMappingURL=liquibase.cjs.production.min.js.map