Skip to content

Commit 29b983a

Browse files
authored
Merge pull request #174 from lutovich/1.1-fix-user-agent
Fix user agent
2 parents fd1c85f + d0379c0 commit 29b983a

File tree

6 files changed

+23
-5
lines changed

6 files changed

+23
-5
lines changed

gulpfile.babel.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ var merge = require('merge-stream');
4747
var install = require("gulp-install");
4848
var os = require('os');
4949
var file = require('gulp-file');
50+
var semver = require('semver');
5051

5152
gulp.task('default', ["test"]);
5253

@@ -225,8 +226,13 @@ gulp.task('set', function() {
225226
// Get the --version arg from command line
226227
var version = minimist(process.argv.slice(2), { string: 'version' }).version;
227228

229+
if (!semver.valid(version)) {
230+
throw 'Invalid version "' + version + '"';
231+
}
232+
228233
// Change the version in relevant files
229-
return gulp.src(['package.json'], {base: "./"})
234+
var versionFile = path.join('src', 'version.js');
235+
return gulp.src([versionFile], {base: "./"})
230236
.pipe(replace('0.0.0-dev', version))
231237
.pipe(gulp.dest('./'));
232238

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"start-neo4j": "gulp start-neo4j",
1616
"stop-neo4j": "gulp stop-neo4j",
1717
"run-tck": "gulp run-tck",
18-
"docs": "node_modules/.bin/esdoc -c esdoc.json"
18+
"docs": "node_modules/.bin/esdoc -c esdoc.json",
19+
"versionRelease": "gulp set --version $VERSION && npm version $VERSION --no-git-tag-version"
1920
},
2021
"main": "lib/index.js",
2122
"devDependencies": {
@@ -52,6 +53,7 @@
5253
"minimist": "^1.2.0",
5354
"phantomjs-prebuilt": "^2.1.7 ",
5455
"run-sequence": "^1.1.4",
56+
"semver": "^5.3.0",
5557
"through2": "~2.0.0",
5658
"vinyl-buffer": "^1.0.0",
5759
"vinyl-source-stream": "^1.1.0"

src/v1/driver.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Driver {
4545
* @param {Object} config
4646
* @access private
4747
*/
48-
constructor(url, userAgent = 'neo4j-javascript/0.0', token = {}, config = {}) {
48+
constructor(url, userAgent, token = {}, config = {}) {
4949
this._url = url;
5050
this._userAgent = userAgent;
5151
this._openSessions = {};

src/v1/routing-driver.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import Integer from './integer'
2929
*/
3030
class RoutingDriver extends Driver {
3131

32-
constructor(url, userAgent = 'neo4j-javascript/0.0', token = {}, config = {}) {
32+
constructor(url, userAgent, token = {}, config = {}) {
3333
super(url, userAgent, token, config);
3434
this._clusterView = new ClusterView(new RoundRobinArray([url]));
3535
}

src/version.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@
2424
// This is set up this way to keep the version in the code in
2525
// sync with the npm package version, and to allow the build
2626
// system to control version names at packaging time.
27-
export default { VERSION : "0.0.0-dev" };
27+
export default "0.0.0-dev";

test/v1/driver.test.js

+10
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,16 @@ describe('driver', function() {
142142
driver.session();
143143
});
144144

145+
it('should have correct user agent', () => {
146+
const directDriver = neo4j.driver("bolt://localhost");
147+
expect(directDriver._userAgent).toBe("neo4j-javascript/0.0.0-dev");
148+
directDriver.close();
149+
150+
const routingDriver = neo4j.driver("bolt+routing://localhost");
151+
expect(routingDriver._userAgent).toBe("neo4j-javascript/0.0.0-dev");
152+
routingDriver.close();
153+
});
154+
145155
var exposedTypes = [
146156
'Node',
147157
'Path',

0 commit comments

Comments
 (0)