UNPKG

node-liquibase

Version:
3 lines (2 loc) 8.47 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("child_process"),t=require("path"),n=require("fs");function a(){return(a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e}).apply(this,arguments)}var s,r=function(){function t(){}return t.spawnChildProcess=function(t){return console.log("Running "+t+"..."),new Promise((function(n,a){e.exec(t,(function(e,t,s){if(console.log("\n",t),e)return console.error("\n",s),a(e);n(t)}))}))},t}(),i=function(){function e(){}var a;return e.readFileContent=function(e){return n.readFileSync(e,{encoding:"utf-8"})},(a=[{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")}}])&&function(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}(e,a),e}(),o={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")},u={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.2.8.jar")},l=function(){function e(){}return e.log=function(e){console.log("[NODE-LIQUIBASE] "+e)},e.warn=function(e){console.warn("%s","[NODE-LIQUIBASE] "+e)},e.error=function(e){console.error("%s","[NODE-LIQUIBASE] "+e)},e}();(s=exports.LiquibaseCommands||(exports.LiquibaseCommands={})).CalculateCheckSum="calculateCheckSum",s.ChangelogSync="changelogSync",s.ChangelogSyncSql="changelogSyncSQL",s.ChangelogSyncToTag="changelogSyncToTag",s.ChangelogSyncToTagSql="changelogSyncToTagSQL",s.ClearCheckSums="clearCheckSums",s.DbDoc="dbDoc",s.DeactivateChangeLog="deactivateChangeLog",s.Diff="diff",s.DiffChangeLog="diffChangeLog",s.DropAll="dropAll",s.FutureRollbackSql="futureRollbackSQL",s.FutureRollbackCountSql="futureRollbackCountSQL",s.GenerateChangeLog="generateChangeLog",s.Help="help",s.History="history",s.ListLocks="listLocks",s.MarkNextChangeSetRan="markNextChangeSetRan",s.MarkNextChangeSetRanSql="markNextChangeSetRanSQL",s.RegisterChangeLog="registerChangeLog",s.ReleaseLocks="releaseLocks",s.Rollback="rollback",s.RollbackCount="rollbackCount",s.RollbackCountSql="rollbackCountSQL",s.RollbackSql="rollbackSQL",s.RollbackToDate="rollbackToDate",s.RollbackToDateSql="rollbackToDateSQL",s.Snapshot="snapshot",s.SnapshotReference="snapshotReference",s.Status="status",s.SyncHub="syncHub",s.Tag="tag",s.TagExists="tagExists",s.UnexpectedChangeSets="unexpectedChangeSets",s.Update="update",s.UpdateSql="updateSQL",s.UpdateCount="updateCount",s.UpdateCountSql="updateCountSQL",s.UpdateTestingRollback="updateTestingRollback",s.UpdateToTag="updateToTag",s.UpdateToTagSql="updateToTagSQL",s.Validate="validate";var c=function(){function e(e){this.params=e,this.mergeParamsWithDefaults(e)}var t=e.prototype;return t.update=function(e){return this.run(exports.LiquibaseCommands.Update,e),this},t.updateSQL=function(e){return this.run(exports.LiquibaseCommands.UpdateSql,e),this},t.updateCount=function(e){return this.run(exports.LiquibaseCommands.UpdateCount,e),this},t.updateCountSQL=function(e){return this.run(exports.LiquibaseCommands.UpdateCountSql,e),this},t.updateTestingRollback=function(){return this.run(exports.LiquibaseCommands.UpdateTestingRollback),this},t.updateToTag=function(e){return this.run(exports.LiquibaseCommands.UpdateToTag,e),this},t.updateToTagSQL=function(e){return this.run(exports.LiquibaseCommands.UpdateToTagSql,e),this},t.validate=function(){return this.run(exports.LiquibaseCommands.Validate),this},t.calculateCheckSum=function(e){return this.run(exports.LiquibaseCommands.CalculateCheckSum,e),this},t.rollback=function(e){return this.run(exports.LiquibaseCommands.Rollback,e),this},t.rollbackSQL=function(e){return this.run(exports.LiquibaseCommands.RollbackSql,e),this},t.rollbackCount=function(e){return this.run(exports.LiquibaseCommands.RollbackCount,e),this},t.rollbackCountSQL=function(e){return this.run(exports.LiquibaseCommands.RollbackCountSql,e),this},t.rollbackToDate=function(e){return this.run(exports.LiquibaseCommands.RollbackToDate,e),this},t.rollbackToDateSQL=function(e){return this.run(exports.LiquibaseCommands.RollbackToDateSql,e),this},t.snapshot=function(e){return this.run(exports.LiquibaseCommands.Snapshot,e),this},t.snapshotReference=function(e){return this.run(exports.LiquibaseCommands.SnapshotReference,e),this},t.status=function(){return this.run(exports.LiquibaseCommands.Status),this},t.syncHub=function(e){return this.run(exports.LiquibaseCommands.SyncHub,e),this},t.tag=function(e){return this.run(exports.LiquibaseCommands.Tag,e),this},t.tagExists=function(e){return this.run(exports.LiquibaseCommands.TagExists,e),this},t.unexpectedChangeSets=function(){return this.run(exports.LiquibaseCommands.UnexpectedChangeSets),this},t.dropAll=function(){return this.run(exports.LiquibaseCommands.DropAll),this},t.futureRollbackSQL=function(){return this.run(exports.LiquibaseCommands.FutureRollbackSql),this},t.futureRollbackCountSQL=function(e){return this.run(exports.LiquibaseCommands.FutureRollbackCountSql,e),this},t.generateChangeLog=function(e){return this.run(exports.LiquibaseCommands.GenerateChangeLog,e),this},t.help=function(){return this.run(exports.LiquibaseCommands.Help),this},t.history=function(){return this.run(exports.LiquibaseCommands.History),this},t.listLocks=function(){return this.run(exports.LiquibaseCommands.ListLocks),this},t.markNextChangeSetRan=function(){return this.run(exports.LiquibaseCommands.MarkNextChangeSetRan),this},t.markNextChangeSetRanSQL=function(){return this.run(exports.LiquibaseCommands.MarkNextChangeSetRanSql),this},t.registerChangeLog=function(){return this.run(exports.LiquibaseCommands.RegisterChangeLog),this},t.releaseLocks=function(){return this.run(exports.LiquibaseCommands.ReleaseLocks),this},t.changelogSync=function(){return this.run(exports.LiquibaseCommands.ChangelogSync),this},t.changelogSyncSQL=function(){return this.run(exports.LiquibaseCommands.ChangelogSyncSql),this},t.changelogSyncToTag=function(e){return this.run(exports.LiquibaseCommands.ChangelogSyncToTag,e),this},t.changelogSyncToTagSQL=function(e){return this.run(exports.LiquibaseCommands.ChangelogSyncToTagSql,e),this},t.clearCheckSums=function(){return this.run(exports.LiquibaseCommands.ClearCheckSums),this},t.dbDoc=function(e){return this.run(exports.LiquibaseCommands.DbDoc,e),this},t.deactivateChangeLog=function(){return this.run(exports.LiquibaseCommands.DeactivateChangeLog),this},t.diff=function(e){return this.run(exports.LiquibaseCommands.Diff,e),this},t.diffChangelog=function(e){return this.run(exports.LiquibaseCommands.DiffChangeLog,e),this},t.stringifyParams=function(e){var t="";for(var n in e)t+="--"+n+"="+JSON.stringify(e[n])+" ";return t},t.loadParamsFromLiquibasePropertiesFileOnDemands=function(e){var t={};if(e)return i.readFileContent(e).split(/\r?\n/).forEach((function(e){var n=e.split(/=?:/,2),a=n[0],s=n[1];t.hasOwnProperty(a)&&(t[a.trim()]=s.trim())})),t},t.run=function(e,t){void 0===t&&(t={});var n=a({},this.loadParamsFromLiquibasePropertiesFileOnDemands(this.params.liquibasePropertiesFile),this.params),s=this.stringifyParams(t);return this.spawnChildProcess(this.liquibasePathAndGlobalAttributes(n)+" "+e+" "+s)},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.params[e]+'"')})),n},t.spawnChildProcess=function(e){return r.spawnChildProcess(e)},t.mergeParamsWithDefaults=function(e){var t=a({},u,{liquibase:i.bundledLiquibasePath});this.params=Object.assign({},t,e)},e}();exports.CommandHandler=r,exports.FileHelper=i,exports.LIQUIBASE_LABEL="[NODE-LIQUIBASE]",exports.Liquibase=c,exports.Logger=l,exports.MSSQL_DEFAULT_CONFIG=o,exports.POSTGRESQL_DEFAULT_CONFIG=u; //# sourceMappingURL=node-liquibase.cjs.production.min.js.map