Skip to content

Commit 46f4534

Browse files
committed
Convert to a regular JS module, add build script.
1 parent bc075a3 commit 46f4534

24 files changed

+4763
-719
lines changed

.gitignore

+2-20
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,9 @@
1-
# Logs
21
logs
32
*.log
4-
5-
# Runtime data
3+
.DS_Store
64
pids
75
*.pid
86
*.seed
9-
10-
# Directory for instrumented libs generated by jscoverage/JSCover
11-
lib-cov
12-
13-
# Coverage directory used by tools like istanbul
14-
coverage
15-
16-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17-
.grunt
18-
19-
# node-waf configuration
207
.lock-wscript
21-
22-
# Compiled binary addons (http://nodejs.org/api/addons.html)
23-
build/Release
24-
25-
# Dependency directory
26-
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
8+
build
279
node_modules

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
The JavaScript driver for Bolt uses the websocket interface and is currently available for use within a browser context only.
44
To use the driver, simply include the `neo4j.js` file within a page.
55

6-
76
## Example
87

98
```javascript
@@ -37,6 +36,13 @@ session.run(statement, parameters,
3736
);
3837
```
3938

39+
## Building & testing
40+
41+
npm install
42+
npm test
43+
44+
This runs the test suite and produces browser-compatible standalone files under `build/`.
45+
4046
## TODO
4147

4248
The JavaScript driver is still missing at least the following:
File renamed without changes.

gulpfile.js

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
var browserify = require('browserify');
2+
var source = require('vinyl-source-stream');
3+
var gulp = require('gulp');
4+
var gulpif = require('gulp-if');
5+
var uglify = require('gulp-uglify');
6+
var concat = require('gulp-concat');
7+
var streamify = require('gulp-streamify');
8+
var gutil = require('gulp-util');
9+
var download = require("gulp-download");
10+
var gunzip = require('gulp-gunzip');
11+
var untar = require('gulp-untar2');
12+
var jasmine = require('gulp-jasmine');
13+
var cucumber = require('gulp-cucumber');
14+
var reporters = require('jasmine-reporters');
15+
var jasminePhantomJs = require('gulp-jasmine2-phantomjs');
16+
17+
18+
var browserifyTask = function (options) {
19+
20+
// Our app bundler
21+
var appBundler = browserify({
22+
entries: [options.src],
23+
cache: {},
24+
packageCache: {}
25+
});
26+
27+
// Un-minified browser package
28+
appBundler.bundle()
29+
.on('error', gutil.log)
30+
.pipe(source('neo4j-web.js'))
31+
.pipe(gulp.dest(options.dest));
32+
33+
34+
appBundler.bundle()
35+
.on('error', gutil.log)
36+
.pipe(source('neo4j-web.min.js'))
37+
.pipe(gulp.dest(options.dest))
38+
.pipe(gulpif(!options.development, streamify(uglify())))
39+
}
40+
41+
gulp.task('default', ["test", "browser"]);
42+
43+
gulp.task('browser', function () {
44+
45+
browserifyTask({
46+
src: 'lib/neo4j.js',
47+
dest: 'build/browser'
48+
});
49+
50+
});
51+
52+
gulp.task('test', ["test-nodejs", "test-browser", "test-tck"]);
53+
54+
gulp.task('test-nodejs', function () {
55+
return gulp.src('test/*.test.js')
56+
.pipe(jasmine({
57+
reporter: new reporters.JUnitXmlReporter({
58+
savePath: "build/nodejs-test-reports",
59+
consolidateAll: false
60+
})
61+
}));
62+
});
63+
64+
gulp.task('test-tck', ['download-tck'], function () {
65+
return gulp.src('build/tck/*').pipe(cucumber({
66+
'steps': 'test/tck/*.steps.js',
67+
'format': 'summary'
68+
}));
69+
});
70+
71+
gulp.task('download-tck', function() {
72+
return download("http://alpha.neohq.net/dist/driver-tck.tar.gz")
73+
.pipe(gunzip())
74+
.pipe(untar())
75+
.pipe(gulp.dest('./build'));
76+
});
77+
78+
79+
gulp.task('test-browser', function () {
80+
// TODO: We should not use PhantomJS directly, instead we should run this via Karma to get wide cross-browser testing
81+
gulp.src('./test/*.test.js')
82+
.pipe(concat('all.test.js'))
83+
.pipe(gulp.dest('./build/'));
84+
85+
browserify({ entries: ['build/all.test.js'] })
86+
.bundle()
87+
.on('error', gutil.log)
88+
.pipe(source('neo4j-web.test.js'))
89+
.pipe(gulp.dest('./build/browser/'));
90+
91+
return gulp.src('./test/browser/testrunner-phantomjs.html').pipe(jasminePhantomJs());
92+
});

0 commit comments

Comments
 (0)