Skip to content

Fix user agent #174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"]);

Expand Down Expand Up @@ -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('./'));

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/v1/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down
2 changes: 1 addition & 1 deletion src/v1/routing-driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]));
}
Expand Down
2 changes: 1 addition & 1 deletion src/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
10 changes: 10 additions & 0 deletions test/v1/driver.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down