Skip to content

Commit c553245

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

23 files changed

+4693
-719
lines changed

.gitignore

Lines changed: 2 additions & 20 deletions
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

Lines changed: 7 additions & 1 deletion
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+
gulp
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

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

0 commit comments

Comments
 (0)