From 8d9b4edf95e36abcdd54ad51a453de26fa1dab89 Mon Sep 17 00:00:00 2001 From: lutovich Date: Thu, 15 Dec 2016 15:38:51 +0100 Subject: [PATCH 1/3] Fix user agent string It previously was `neo4j-javascript/[object Object]` because of an incorrect usage of default import. This commit makes it `neo4j-javascript/0.0.0-dev`. Part after `/` will be changed by the pre-release gulp script. --- src/v1/driver.js | 2 +- src/v1/routing-driver.js | 2 +- src/version.js | 2 +- test/v1/driver.test.js | 10 ++++++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/v1/driver.js b/src/v1/driver.js index 907a3bf1a..60fd95810 100644 --- a/src/v1/driver.js +++ b/src/v1/driver.js @@ -45,7 +45,7 @@ class Driver { * @param {Object} config * @access private */ - constructor(url, userAgent = 'neo4j-javascript/0.0', token = {}, config = {}) { + constructor(url, userAgent, token = {}, config = {}) { this._url = url; this._userAgent = userAgent; this._openSessions = {}; diff --git a/src/v1/routing-driver.js b/src/v1/routing-driver.js index d747e6a7b..0da77c4cf 100644 --- a/src/v1/routing-driver.js +++ b/src/v1/routing-driver.js @@ -29,7 +29,7 @@ import Integer from './integer' */ class RoutingDriver extends Driver { - constructor(url, userAgent = 'neo4j-javascript/0.0', token = {}, config = {}) { + constructor(url, userAgent, token = {}, config = {}) { super(url, userAgent, token, config); this._clusterView = new ClusterView(new RoundRobinArray([url])); } diff --git a/src/version.js b/src/version.js index 44d557666..0d5c0eb20 100644 --- a/src/version.js +++ b/src/version.js @@ -24,4 +24,4 @@ // This is set up this way to keep the version in the code in // sync with the npm package version, and to allow the build // system to control version names at packaging time. -export default { VERSION : "0.0.0-dev" }; +export default "0.0.0-dev"; diff --git a/test/v1/driver.test.js b/test/v1/driver.test.js index d48c3f0e2..2a120fa44 100644 --- a/test/v1/driver.test.js +++ b/test/v1/driver.test.js @@ -142,6 +142,16 @@ describe('driver', function() { driver.session(); }); + it('should have correct user agent', () => { + const directDriver = neo4j.driver("bolt://localhost"); + expect(directDriver._userAgent).toBe("neo4j-javascript/0.0.0-dev"); + directDriver.close(); + + const routingDriver = neo4j.driver("bolt+routing://localhost"); + expect(routingDriver._userAgent).toBe("neo4j-javascript/0.0.0-dev"); + routingDriver.close(); + }); + var exposedTypes = [ 'Node', 'Path', From 98272d24ae711e236f11d015b091250c3d0dca63 Mon Sep 17 00:00:00 2001 From: lutovich Date: Thu, 15 Dec 2016 15:44:47 +0100 Subject: [PATCH 2/3] Fix gulp script to change version in the correct file Command `gulp set --version ` was meant to change version in `version.js` which is later used in driver's user agent. However it tried to modify `package.json` file instead of `version.js`. This commit makes it operate on the correct file. --- gulpfile.babel.js | 8 +++++++- package.json | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/gulpfile.babel.js b/gulpfile.babel.js index e0105ef86..d2f77c19e 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -47,6 +47,7 @@ var merge = require('merge-stream'); var install = require("gulp-install"); var os = require('os'); var file = require('gulp-file'); +var semver = require('semver'); gulp.task('default', ["test"]); @@ -225,8 +226,13 @@ gulp.task('set', function() { // Get the --version arg from command line var version = minimist(process.argv.slice(2), { string: 'version' }).version; + if (!semver.valid(version)) { + throw 'Invalid version "' + version + '"'; + } + // Change the version in relevant files - return gulp.src(['package.json'], {base: "./"}) + var versionFile = path.join('src', 'version.js'); + return gulp.src([versionFile], {base: "./"}) .pipe(replace('0.0.0-dev', version)) .pipe(gulp.dest('./')); diff --git a/package.json b/package.json index 97400a5a5..45b61589f 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "minimist": "^1.2.0", "phantomjs-prebuilt": "^2.1.7 ", "run-sequence": "^1.1.4", + "semver": "^5.3.0", "through2": "~2.0.0", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0" From d0379c0b003d98865d0a4bd3022ee92dc2c068e7 Mon Sep 17 00:00:00 2001 From: lutovich Date: Thu, 15 Dec 2016 16:00:09 +0100 Subject: [PATCH 3/3] Add npm script for release versioning Version is set in `package.json` (used as npm package version) and in `src/version.js` (used to create driver's user agent string). Script is named `versionRelease` and requires `VERSION` env variable to be set. Examples: ``` VERSION=1.1.5 npm run versionRelease VERSION=1.1.5-rc01 npm run versionRelease VERSION=1.1.5-alpha03 npm run versionRelease ``` --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 45b61589f..0b858ad00 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "start-neo4j": "gulp start-neo4j", "stop-neo4j": "gulp stop-neo4j", "run-tck": "gulp run-tck", - "docs": "node_modules/.bin/esdoc -c esdoc.json" + "docs": "node_modules/.bin/esdoc -c esdoc.json", + "versionRelease": "gulp set --version $VERSION && npm version $VERSION --no-git-tag-version" }, "main": "lib/index.js", "devDependencies": {