diff --git a/Gruntfile.js b/Gruntfile.js index f1f0cc5..22fe087 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,16 +1,25 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.initConfig({ + + pkg: grunt.file.readJSON('package.json'), + uglify: { - target1: { - options: { - sourceMap: true - }, + options: { + sourceMap: true, + banner: '/* <%= grunt.task.current.target %> v<%= pkg.version %> <%= grunt.template.today("dd-mm-yyyy") %> (C) 2015 Terikon Software */\n' + }, + + webSqlTracer: { src: 'webSqlTracer.js', dest: 'dist/webSqlTracer.min.js' } + }, + jshint: { + all: ['Gruntfile.js', 'webSqlTracer.js'] } }); diff --git a/bower.json b/bower.json index eb903f6..94d2631 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "websqltracer", "main": "webSqlTracer.js", - "version": "1.0.1", + "version": "1.0.2", "description": "Console tracer for Web SQL or SQLite", "homepage": "https://github.com/terikon/webSqlTracer", diff --git a/dist/webSqlTracer.min.js b/dist/webSqlTracer.min.js index dc5b441..88e8f80 100644 --- a/dist/webSqlTracer.min.js +++ b/dist/webSqlTracer.min.js @@ -1,2 +1,4 @@ +/* webSqlTracer v1.0.2 17-04-2015 (C) 2015 Terikon Software */ + !function(a,b){"use strict";"function"==typeof define&&define.amd?define(["underscore","jquery"],b.bind(null,a)):"undefined"!=typeof module&&null!==module&&null!=module.exports?module.exports.webSqlTracer=b(a,require("underscore"),require("jquery")):a.webSqlTracer=b(a,a._,a.jQuery)}(this,function(a,b,c){"use strict";var d,e,f,g,h=!1,i=[],j=[],k=!1,l={};return{traceOnOpen:function(c,d){var e,f=this;if(h)throw new Error("Call stopTraceOnOpen() before calling traceOnOpen() for second time.");h=!0,g||(g=a.openDatabase),b.isString(c)&&(e=c,c=function(a){return a===e}),a.openDatabase=function(a,b){var e=g.apply(this,arguments);return c(a)&&f.startTrace(e,a,b).then(function(){d&&d(e)}),e}},stopTraceOnOpen:function(){if(!h)throw new Error("Cannot call stopTraceOnOpen() before calling traceOnOpen().");h=!1,a.openDatabase=g},startTrace:function(a,g,h){var m,n,o=new c.Deferred;if(g&&(n=l[g],b.isUndefined(n)&&(n=0),l[g]=n+1,n>0&&(g=g+"("+n+")"),console.log("SQL TRACE : started tracing database "+g+(b.isUndefined(h)?"":" version '"+h+"'"))),b.indexOf(i,a)>=0)throw new Error("startTrace was already started for this db");if(k)o.resolve();else{a.transaction(function(a){var c=Object.getPrototypeOf(a);d||(d=c.executeSql),c.executeSql=function(a,c){var e,f,g=this,h=g._transactionDb,k=b.indexOf(i,h);k>=0&&(e=j[k],f=e||"",console.log("SQL TRACE "+f+": '"+a+"'"+(c&&!b.isEmpty(c)?", args="+JSON.stringify(c):""))),d.apply(this,arguments)},setTimeout(function(){o.resolve()},0)}),m=Object.getPrototypeOf(a),e||(e=m.transaction,f=m.readTransaction);var p=function(a){return function(b,c,d){var e=this;a.call(this,function(a){a._transactionDb=e,b(a)},c,d)}};m.transaction=p(e),m.readTransaction=p(f),k=!0}return i.push(a),j.push(g),o.promise()},stopTrace:function(a){var g,h,l=new c.Deferred,m=b.indexOf(i,a);if(0>m)throw new Error("cannot stopTrace, trace was not started for this db");if(g=1===i.length){var n=Object.getPrototypeOf(a);n.transaction=e,n.readTransaction=f,a.transaction(function(a){var b=Object.getPrototypeOf(a);b.executeSql=d,l.resolve()}),k=!1}return h=j[m],console.log("SQL TRACE : stopped tracing database"+(h?" "+h:"")),i.splice(m,1),j.splice(m,1),g||l.resolve(),l.promise()}}}); //# sourceMappingURL=webSqlTracer.min.js.map \ No newline at end of file diff --git a/dist/webSqlTracer.min.js.map b/dist/webSqlTracer.min.js.map index d1620b8..ab09e9d 100644 --- a/dist/webSqlTracer.min.js.map +++ b/dist/webSqlTracer.min.js.map @@ -1 +1 @@ -{"version":3,"file":"webSqlTracer.min.js","sources":["../webSqlTracer.js"],"names":["root","factory","define","amd","bind","module","exports","webSqlTracer","require","_","jQuery","this","$","originalExecuteSql","originalTransaction","originalReadTransaction","originalOpenDatabase","traceOnOpenSet","dbSubscriptions","dbNames","traceInstalled","namesCounter","traceOnOpen","tracePredicate","traceCallback","tracePredicateStr","that","Error","openDatabase","isString","name","version","db","apply","arguments","startTrace","then","stopTraceOnOpen","dbName","dbVersion","protoDatabase","nameCount","deferred","Deferred","isUndefined","console","log","indexOf","resolve","transaction","t","protoTransaction","Object","getPrototypeOf","executeSql","sqlStatement","args","nameOfSubscription","nameToPrint","tx","transactionDb","_transactionDb","indexOfSubscription","isEmpty","JSON","stringify","setTimeout","readTransaction","makeTransaction","originalAnyTransaction","callback","errorCallback","successCallback","call","push","promise","stopTrace","isLastSubscription","length","splice"],"mappings":"CAMC,SAAUA,EAAMC,GAChB,YACyB,mBAAXC,SAAyBA,OAAOC,IAEvCD,QAAQ,aAAc,UAAWD,EAAQG,KAAK,KAAMJ,IAC9B,mBAAXK,SAAqC,OAAXA,QAAqC,MAAlBA,OAAOC,QAE/DD,OAAOC,QAAQC,aAAeN,EAAQD,EAAMQ,QAAQ,cAAeA,QAAQ,WAG3ER,EAAKO,aAAeN,EAAQD,EAAMA,EAAKS,EAAGT,EAAKU,SAErDC,KAEE,SAAUX,EAAMS,EAAGG,GACrB,YAEM,IAAIC,GACAC,EACAC,EACAC,EACAC,GAAiB,EACjBC,KACAC,KACAC,GAAiB,EACjBC,IAEJ,QAIIC,YAAa,SAAUC,EAAgBC,GACnC,GAAiBC,GAAbC,EAAOf,IAEX,IAAIM,EACA,KAAM,IAAIU,OAAM,uEAGpBV,IAAiB,EAEZD,IACDA,EAAuBhB,EAAK4B,cAG5BnB,EAAEoB,SAASN,KACXE,EAAoBF,EACpBA,EAAiB,SAAUO,GAAQ,MAAOA,KAASL,IAGvDzB,EAAK4B,aAAe,SAAUE,EAAMC,GAChC,GAAIC,GAAKhB,EAAqBiB,MAAMtB,KAAMuB,UAU1C,OARIX,GAAeO,IACfJ,EAAKS,WAAWH,EAAIF,E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BjD,IACpB0D,GAAuBI,KAAK9D,KAAM,SAAUuC,GAExCA,EAAEW,eAAiBD,EAEnBU,EAASpB,IACVqB,EAAeC,IAI1BhC,GAAcS,YAAcmB,EAAgBtD,GAC5C0B,EAAc2B,gBAAkBC,EAAgBrD,GAEhDK,GAAiB,EAQrB,MAHAF,GAAgBwD,KAAK1C,GACrBb,EAAQuD,KAAKpC,GAENI,EAASiC,WAIpBC,UAAW,SAAU5C,GACjB,GAEI6C,GACAvC,EAHAI,EAAW,GAAI9B,GAAE+B,SACjBmB,EAAsBrD,EAAEsC,QAAQ7B,EAAiBc,EAIrD,IAA0B,EAAtB8B,EACA,KAAM,IAAInC,OAAM,sDAKpB,IAFAkD,EAAiD,IAA3B3D,EAAgB4D,OAEd,CAGpB,GAAItC,GAAgBY,OAAOC,eAAerB,EAC1CQ,GAAcS,YAAcnC,EAC5B0B,EAAc2B,gBAAkBpD,EAGhCiB,EAAGiB,YAAY,SAAUC,GACrB,GAAIC,GAAmBC,OAAOC,eAAeH,EAC7CC,GAAiBG,WAAazC,EAC9B6B,EAASM,YAGb5B,GAAiB,EAcrB,MAXAkB,GAASnB,EAAQ2C,GACjBjB,QAAQC,IAAI,wCAA0CR,EAAS,IAAMA,EAAS,KAG9EpB,EAAgB6D,OAAOjB,EAAqB,GAC5C3C,EAAQ4D,OAAOjB,EAAqB,GAE/Be,GACDnC,EAASM,UAGNN,EAASiC"} \ No newline at end of file +{"version":3,"file":"webSqlTracer.min.js","sources":["../webSqlTracer.js"],"names":["root","factory","define","amd","bind","module","exports","webSqlTracer","require","_","jQuery","this","$","originalExecuteSql","originalTransaction","originalReadTransaction","originalOpenDatabase","traceOnOpenSet","dbSubscriptions","dbNames","traceInstalled","namesCounter","traceOnOpen","tracePredicate","traceCallback","tracePredicateStr","that","Error","openDatabase","isString","name","version","db","apply","arguments","startTrace","then","stopTraceOnOpen","dbName","dbVersion","protoDatabase","nameCount","deferred","Deferred","isUndefined","console","log","indexOf","resolve","transaction","t","protoTransaction","Object","getPrototypeOf","executeSql","sqlStatement","args","nameOfSubscription","nameToPrint","tx","transactionDb","_transactionDb","indexOfSubscription","isEmpty","JSON","stringify","setTimeout","readTransaction","makeTransaction","originalAnyTransaction","callback","errorCallback","successCallback","call","push","promise","stopTrace","isLastSubscription","length","splice"],"mappings":";;CAMC,SAAUA,EAAMC,GAChB,YACyB,mBAAXC,SAAyBA,OAAOC,IAEvCD,QAAQ,aAAc,UAAWD,EAAQG,KAAK,KAAMJ,IAC9B,mBAAXK,SAAqC,OAAXA,QAAqC,MAAlBA,OAAOC,QAE/DD,OAAOC,QAAQC,aAAeN,EAAQD,EAAMQ,QAAQ,cAAeA,QAAQ,WAG3ER,EAAKO,aAAeN,EAAQD,EAAMA,EAAKS,EAAGT,EAAKU,SAErDC,KAEE,SAAUX,EAAMS,EAAGG,GACrB,YAEM,IAAIC,GACAC,EACAC,EACAC,EACAC,GAAiB,EACjBC,KACAC,KACAC,GAAiB,EACjBC,IAEJ,QAIIC,YAAa,SAAUC,EAAgBC,GACnC,GAAiBC,GAAbC,EAAOf,IAEX,IAAIM,EACA,KAAM,IAAIU,OAAM,uEAGpBV,IAAiB,EAEZD,IACDA,EAAuBhB,EAAK4B,cAG5BnB,EAAEoB,SAASN,KACXE,EAAoBF,EACpBA,EAAiB,SAAUO,GAAQ,MAAOA,KAASL,IAGvDzB,EAAK4B,aAAe,SAAUE,EAAMC,GAChC,GAAIC,GAAKhB,EAAqBiB,MAAMtB,KAAMuB,UAU1C,OARIX,GAAeO,IACfJ,EAAKS,WAAWH,EAAIF,EAAMC,GAASK,KAAK,WAChCZ,GACAA,EAAcQ,KAKnBA,IAIfK,gBAAiB,WACb,IAAKpB,EACD,KAAM,IAAIU,OAAM,8DAGpBV,IAAiB,EAEjBjB,EAAK4B,aAAeZ,GASxBmB,WAAY,SAAUH,EAAIM,EAAQC,GAC9B,GACIC,GACAC,EAFAC,EAAW,GAAI9B,GAAE+B,QAkBrB,IAdIL,IACAG,EAAYpB,E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,UAAW,SAAU5C,GACjB,GAEI6C,GACAvC,EAHAI,EAAW,GAAI9B,GAAE+B,SACjBmB,EAAsBrD,EAAEsC,QAAQ7B,EAAiBc,EAIrD,IAA0B,EAAtB8B,EACA,KAAM,IAAInC,OAAM,sDAKpB,IAFAkD,EAAiD,IAA3B3D,EAAgB4D,OAEd,CAGpB,GAAItC,GAAgBY,OAAOC,eAAerB,EAC1CQ,GAAcS,YAAcnC,EAC5B0B,EAAc2B,gBAAkBpD,EAGhCiB,EAAGiB,YAAY,SAAUC,GACrB,GAAIC,GAAmBC,OAAOC,eAAeH,EAC7CC,GAAiBG,WAAazC,EAC9B6B,EAASM,YAGb5B,GAAiB,EAcrB,MAXAkB,GAASnB,EAAQ2C,GACjBjB,QAAQC,IAAI,wCAA0CR,EAAS,IAAMA,EAAS,KAG9EpB,EAAgB6D,OAAOjB,EAAqB,GAC5C3C,EAAQ4D,OAAOjB,EAAqB,GAE/Be,GACDnC,EAASM,UAGNN,EAASiC"} \ No newline at end of file diff --git a/package.json b/package.json index 2817553..006d0c6 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,14 @@ { "name": "websqltracer", "title": "webSqlTracer", - "version": "1.0.1", + "version": "1.0.2", "description": "Console tracer for Web SQL or SQLite", "main": "webSqlTracer.js", "scripts": { + "//": "use '|| true' to prevent warning", "build": "npm install && grunt", "test": "echo \"Error: no test specified\" && exit 1", - "jshint": "jshint webSqlTracer.js" + "jshint": "grunt jshint" }, "repository": { "type": "git", @@ -36,8 +37,8 @@ "underscore": "*" }, "devDependencies": { - "jshint": "^2.6.0", "grunt": "^0.4.5", - "grunt-contrib-uglify": "^0.7.0" + "grunt-contrib-uglify": "^0.7.0", + "grunt-contrib-jshint": "^0.11.0" } }