Skip to content

Commit 0ba095a

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

23 files changed

+4726
-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

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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 reporters = require('jasmine-reporters');
14+
var jasminePhantomJs = require('gulp-jasmine2-phantomjs');
15+
16+
17+
var browserifyTask = function (options) {
18+
19+
// Our app bundler
20+
var appBundler = browserify({
21+
entries: [options.src],
22+
cache: {},
23+
packageCache: {}
24+
});
25+
26+
// Un-minified browser package
27+
appBundler.bundle()
28+
.on('error', gutil.log)
29+
.pipe(source('neo4j-web.js'))
30+
.pipe(gulp.dest(options.dest));
31+
32+
33+
appBundler.bundle()
34+
.on('error', gutil.log)
35+
.pipe(source('neo4j-web.min.js'))
36+
.pipe(gulp.dest(options.dest))
37+
.pipe(gulpif(!options.development, streamify(uglify())))
38+
}
39+
40+
gulp.task('default', ["test", "browser"]);
41+
42+
gulp.task('browser', function () {
43+
44+
browserifyTask({
45+
src: 'lib/neo4j.js',
46+
dest: 'build/browser'
47+
});
48+
49+
});
50+
51+
gulp.task('test', ["test-nodejs", "test-browser"]);
52+
53+
gulp.task('test-nodejs', function () {
54+
return gulp.src('test/*.test.js')
55+
.pipe(jasmine({
56+
reporter: new reporters.JUnitXmlReporter({
57+
savePath: "build/nodejs-test-reports",
58+
consolidateAll: false
59+
})
60+
}));
61+
});
62+
63+
64+
gulp.task('test-browser', function () {
65+
// TODO: We should not use PhantomJS directly, instead we should run this via Karma to get wide cross-browser testing
66+
gulp.src('./test/*.test.js')
67+
.pipe(concat('all.test.js'))
68+
.pipe(gulp.dest('./build/'));
69+
70+
browserify({ entries: ['build/all.test.js'] })
71+
.bundle()
72+
.on('error', gutil.log)
73+
.pipe(source('neo4j-web.test.js'))
74+
.pipe(gulp.dest('./build/browser/'));
75+
76+
return gulp.src('./test/browser/testrunner-phantomjs.html').pipe(jasminePhantomJs());
77+
});

0 commit comments

Comments
 (0)