Skip to content

Convert to a regular JS module, add build script. #1

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 1 commit into from
Oct 2, 2015
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
22 changes: 2 additions & 20 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@
# Logs
logs
*.log

# Runtime data
.DS_Store
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
build
node_modules
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
The JavaScript driver for Bolt uses the websocket interface and is currently available for use within a browser context only.
To use the driver, simply include the `neo4j.js` file within a page.


## Example

```javascript
Expand Down Expand Up @@ -37,6 +36,13 @@ session.run(statement, parameters,
);
```

## Building & testing

npm install
npm test

This runs the test suite and produces browser-compatible standalone files under `build/`.

## TODO

The JavaScript driver is still missing at least the following:
Expand Down
File renamed without changes.
77 changes: 77 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var gulp = require('gulp');
var gulpif = require('gulp-if');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var streamify = require('gulp-streamify');
var gutil = require('gulp-util');
var download = require("gulp-download");
var gunzip = require('gulp-gunzip');
var untar = require('gulp-untar2');
var jasmine = require('gulp-jasmine');
var reporters = require('jasmine-reporters');
var jasminePhantomJs = require('gulp-jasmine2-phantomjs');


var browserifyTask = function (options) {

// Our app bundler
var appBundler = browserify({
entries: [options.src],
cache: {},
packageCache: {}
});

// Un-minified browser package
appBundler.bundle()
.on('error', gutil.log)
.pipe(source('neo4j-web.js'))
.pipe(gulp.dest(options.dest));


appBundler.bundle()
.on('error', gutil.log)
.pipe(source('neo4j-web.min.js'))
.pipe(gulp.dest(options.dest))
.pipe(gulpif(!options.development, streamify(uglify())))
}

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

gulp.task('browser', function () {

browserifyTask({
src: 'lib/neo4j.js',
dest: 'build/browser'
});

});

gulp.task('test', ["test-nodejs", "test-browser"]);

gulp.task('test-nodejs', function () {
return gulp.src('test/*.test.js')
.pipe(jasmine({
reporter: new reporters.JUnitXmlReporter({
savePath: "build/nodejs-test-reports",
consolidateAll: false
})
}));
});


gulp.task('test-browser', function () {
// TODO: We should not use PhantomJS directly, instead we should run this via Karma to get wide cross-browser testing
gulp.src('./test/*.test.js')
.pipe(concat('all.test.js'))
.pipe(gulp.dest('./build/'));

browserify({ entries: ['build/all.test.js'] })
.bundle()
.on('error', gutil.log)
.pipe(source('neo4j-web.test.js'))
.pipe(gulp.dest('./build/browser/'));

return gulp.src('./test/browser/testrunner-phantomjs.html').pipe(jasminePhantomJs());
});
Loading