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..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": { @@ -52,6 +53,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" 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',