From 95b3439fab75f533ba239f198a318a536a865b79 Mon Sep 17 00:00:00 2001 From: Philip Ebels Date: Fri, 31 Aug 2018 18:41:57 +0200 Subject: [PATCH 1/3] Fixed version bug --- index.js | 2 ++ lib/xapi.js | 3 +-- package-lock.json | 19 +++++++------------ package.json | 3 +-- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/index.js b/index.js index aa0f9cbb76..8e0a87c113 100644 --- a/index.js +++ b/index.js @@ -11,12 +11,14 @@ const Xapi = require('./lib/xapi.js'); const cmdargs = require('./lib/util/cmd.helper.js'); const cluster = require('cluster'); const numCPUs = require('os').cpus().length; +const { version } = require('./package.json'); function startXmysql(sqlConfig) { /**************** START : setup express ****************/ let app = express(); + app.set('version', version); app.use(morgan('tiny')); app.use(cors()); app.use(bodyParser.json()); diff --git a/lib/xapi.js b/lib/xapi.js index d4ba75059f..c6b6d8fc47 100644 --- a/lib/xapi.js +++ b/lib/xapi.js @@ -4,7 +4,6 @@ var Xsql = require('./xsql.js'); var Xctrl = require('./xctrl.js'); var multer = require('multer'); const path = require('path'); -const pkginfo = require('pkginfo')(module); const v8 = require('v8'), os = require('os'); @@ -444,7 +443,7 @@ class Xapi { let version = {}; - version['Xmysql'] = pkginfo.version; + version['Xmysql'] = this.app.get('version'); version['mysql'] = await this.getMysqlHealth(); version['node'] = process.versions.node; res.json(version); diff --git a/package-lock.json b/package-lock.json index fa59563e0b..e0721dd658 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "xmysql", - "version": "0.4.8", + "version": "0.4.9", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -621,9 +621,9 @@ } }, "nan": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.7.0.tgz", - "integrity": "sha1-2Vv3IeyHfgjbJ27T/G63j5CDrUY=", + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.11.0.tgz", + "integrity": "sha512-F4miItu2rGnV2ySkXOQoA8FKz/SR2Q2sWP0sbTxNxz/tuokeC8WxOhPMcwi0qIyGtVn/rrSeLbvVkznqCdwYnw==", "dev": true }, "negotiator": { @@ -674,11 +674,6 @@ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" }, - "pkginfo": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.4.1.tgz", - "integrity": "sha1-tUGO8EOd5UJfxJlQQtztFPsqhP8=" - }, "process-nextick-args": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", @@ -824,9 +819,9 @@ "dev": true }, "sleep": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/sleep/-/sleep-5.1.1.tgz", - "integrity": "sha1-h4+h1E0I7rDyb7IBjvhinrGjq5Q=", + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/sleep/-/sleep-5.2.3.tgz", + "integrity": "sha512-vC05N1XqgIiPIj6tEq7wt0R32aTycJv4Ymo/jwSEp2PkeU1GCJ1tkl+RdYZEo7Gjebq8QQuhFuEe7vsyVGlFRA==", "dev": true, "requires": { "nan": ">=2.5.1" diff --git a/package.json b/package.json index ec84182f23..234a90f7cd 100644 --- a/package.json +++ b/package.json @@ -33,8 +33,7 @@ "express": "^4.16.1", "morgan": "^1.9.0", "multer": "^1.3.0", - "mysql": "^2.15.0", - "pkginfo": "^0.4.1" + "mysql": "^2.15.0" }, "devDependencies": { "mocha": "^5.2.0", From 0694efdef1634251d07874cca653d19cea110022 Mon Sep 17 00:00:00 2001 From: Philip Ebels Date: Fri, 31 Aug 2018 20:11:23 +0200 Subject: [PATCH 2/3] Removed redundant require of pkginfo, fixed test --- lib/util/cmd.helper.js | 1 - tests/tests.js | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/util/cmd.helper.js b/lib/util/cmd.helper.js index b5dc1f41ab..0aa65ed144 100644 --- a/lib/util/cmd.helper.js +++ b/lib/util/cmd.helper.js @@ -1,7 +1,6 @@ 'use strict'; const program = require('commander'); const colors = require('colors'); -const pkginfo = require('pkginfo')(module); const maxCpus = require('os').cpus().length; diff --git a/tests/tests.js b/tests/tests.js index 7f5cf1137b..987dfb9f5a 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -8,7 +8,6 @@ var whereClause = require('../lib/util/whereClause.helper.js') var should = require('should'); var request = require('supertest') const cmdargs = require('../lib/util/cmd.helper.js'); -const pkginfo = require('pkginfo')(module); var args = {} var app = {} @@ -1895,7 +1894,7 @@ describe('xmysql : tests', function () { return done(err); } - res.body['Xmysql'].should.equals(pkginfo.version); + res.body['Xmysql'].should.not.equals(""); res.body['mysql'].should.not.equals(""); res.body['node'].should.not.equals(""); From 7be93a2fc8fdc5fc22825ac5ce4c05cb08a44772 Mon Sep 17 00:00:00 2001 From: Philip Ebels Date: Sat, 1 Sep 2018 12:52:32 +0200 Subject: [PATCH 3/3] Fixed test --- tests/tests.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/tests.js b/tests/tests.js index 987dfb9f5a..e105fb9c7e 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -8,6 +8,7 @@ var whereClause = require('../lib/util/whereClause.helper.js') var should = require('should'); var request = require('supertest') const cmdargs = require('../lib/util/cmd.helper.js'); +const { version } = require('../package.json'); var args = {} var app = {} @@ -33,7 +34,7 @@ describe('xmysql : tests', function () { mysqlPool = mysql.createPool(args) app = express() - //app.use(morgan('tiny')) + app.set('version', version) app.use(bodyParser.json()) app.use(bodyParser.urlencoded({ extended: true @@ -1894,7 +1895,7 @@ describe('xmysql : tests', function () { return done(err); } - res.body['Xmysql'].should.not.equals(""); + res.body['Xmysql'].should.equals(version); res.body['mysql'].should.not.equals(""); res.body['node'].should.not.equals("");